ATLAS Offline Software
Loading...
Searching...
No Matches
LArCollisionTimeAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "Identifier/Identifier.h"
9
11 {
12 ATH_MSG_DEBUG ("LArCollisionTimeAlg initialize()");
13
14 //retrieve ID helpers
15 ATH_CHECK(detStore()->retrieve(m_calo_id,"CaloCell_ID"));
16
17 //Initialize VarHandles
18 ATH_CHECK( m_noiseCDOKey.initialize() );
19 ATH_CHECK( m_cellsContName.initialize() );
20 ATH_CHECK( m_collTimeName.initialize() );
21
22 return StatusCode::SUCCESS;
23
24 }
25
26//__________________________________________________________________________
28 {
29 ATH_MSG_DEBUG ("LArCollisionTimeAlg finalize()");
30 return StatusCode::SUCCESS;
31 }
32
33//__________________________________________________________________________
34StatusCode LArCollisionTimeAlg::execute(const EventContext& ctx) const
35 {
36 //.............................................
37
38 ATH_MSG_DEBUG ("LArCollisionTimeAlg execute()");
39
40 //Input read handle:
42
43 //Output write handle:
45
46 if(!cell_container.isValid()) {
47 ATH_MSG_INFO (" Could not get pointer to Cell Container ");
48 // Construct a dummy output object
49 ATH_CHECK( larTimeWH.record (std::make_unique<LArCollisionTime>()) );
50
51 return StatusCode::SUCCESS;
52 }
53
54
56 const CaloNoise* noiseCDO=*noiseHdl;
57
58
59 // Loop over the CaloCellContainer
60 int ncellA=0;
61 int ncellC=0;
62 float energyA=0.;
63 float energyC=0.;
64 float timeA=0.;
65 float timeC=0.;
66
67 for (const CaloCell* cell : *cell_container) {
68 Identifier cellID = cell->ID();
69 if (m_calo_id->is_tile(cellID)) continue;
70
71 const double eta = cell->eta();
72 if (std::fabs(eta)<1.5) continue;
73
74 const uint16_t provenance =cell->provenance();
75//
76// check time correctly available
77// for Data: offline Iteration 0x2000 time available, 0x0100 Iteration converted, not 0x0200 and not 0x0400 (bad cells), 0x00A5 (correctly calibrated)
78// DSP time 0x1000 : cell from DSP, 0x2000 time available, not 0x0200 and not 0x0400
79// for MC check time available 0x2000, and not bad cell
80 if (!LArProv::test(provenance, LArProv::QTPRESENT))
81 continue;
82 if (LArProv::test(provenance, LArProv::MASKED))
83 continue;
84
85 if (!m_isMC) {
86 if (m_iterCut) {
88 continue;
89 } else {
90 if (!LArProv::test(provenance, LArProv::DEFAULTRECO) && !LArProv::test(provenance, LArProv::DSPCALC))
91 continue;
92 }
93 }
94
95 const double energy=cell->energy();
96 const double noise=noiseCDO->getNoise(cellID,cell->gain());
97 double signif=9999.;
98 if (noise>0.) signif = energy/noise;
99 if (signif < 5.) continue;
100
101 double ecut=-1;
102 if (m_calo_id->is_lar_fcal(cellID) && m_calo_id->calo_sample(cellID)==CaloCell_ID::FCAL0) ecut=1200.;
103 if (m_calo_id->is_em_endcap_inner(cellID) ) ecut=250.;
104
105 if (ecut<0.) continue;
106 if (energy<ecut) continue;
107
108 double time = cell->time();
109
110 if (eta>0.) {
111 ncellA += 1;
112 energyA += energy;
113 timeA += time;
114 }
115 else {
116 ncellC += 1;
117 energyC += energy;
118 timeC += time;
119 }
120
121 }
122 if (ncellA>0) timeA = timeA/((float)(ncellA));
123 if (ncellC>0) timeC = timeC/((float)(ncellC));
124
125 if (ncellA>m_minCells && ncellC > m_minCells && std::fabs(timeA-timeC)<m_timeCut)
126 setFilterPassed(true,ctx);
127 else
128 setFilterPassed(false,ctx);
129
130 ATH_MSG_DEBUG( " ncellA, ncellA, energyA, energyC, timeA, timeC " << ncellA << " " << ncellC << " " << energyA << " " << energyC << " " << timeA << " " << timeC);
131 auto larTime = std::make_unique<LArCollisionTime>(ncellA,ncellC,energyA,energyC,timeA,timeC);
132 // Construct the output object
133 if (! larTimeWH.put (std::move (larTime)) ) {
134 ATH_MSG_WARNING( "Could not record the LArCollisionTime object with key "<<m_collTimeName );
135
136 }
137
138 return StatusCode::SUCCESS;
139}
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
const ServiceHandle< StoreGateSvc > & detStore() const
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
Definition CaloNoise.h:34
Gaudi::Property< int > m_minCells
virtual StatusCode finalize() override final
standard Athena-Algorithm method
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
Gaudi::Property< bool > m_iterCut
virtual StatusCode initialize() override final
standard Athena-Algorithm method
const CaloCell_ID * m_calo_id
SG::ReadHandleKey< CaloCellContainer > m_cellsContName
virtual StatusCode execute(const EventContext &ctx) const override final
standard Athena-Algorithm method
Gaudi::Property< float > m_timeCut
SG::WriteHandleKey< LArCollisionTime > m_collTimeName
Gaudi::Property< bool > m_isMC
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an object to the store.
bool test(const uint16_t prov, const LArProvenance check)