ATLAS Offline Software
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 
5 #include "LArCollisionTimeAlg.h"
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
21 
22  return StatusCode::SUCCESS;
23 
24  }
25 
26 //__________________________________________________________________________
28  {
29  ATH_MSG_DEBUG ("LArCollisionTimeAlg finalize()");
30  return StatusCode::SUCCESS;
31  }
32 
33 //__________________________________________________________________________
34 StatusCode 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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
LArCollisionTimeAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
standard Athena-Algorithm method
Definition: LArCollisionTimeAlg.cxx:34
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AtlasDetectorID::is_lar_fcal
bool is_lar_fcal(Identifier id) const
Definition: AtlasDetectorID.h:839
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
LArCollisionTimeAlg::m_collTimeName
SG::WriteHandleKey< LArCollisionTime > m_collTimeName
Definition: LArCollisionTimeAlg.h:53
CaloCell_Base_ID::calo_sample
int calo_sample(const Identifier id) const
returns an int taken from Sampling enum and describing the subCalo to which the Id belongs.
Definition: CaloCell_Base_ID.cxx:141
CaloCell_Base_ID::is_tile
bool is_tile(const Identifier id) const
test if the id belongs to the Tiles
CaloNoise::getNoise
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
Definition: CaloNoise.h:34
CaloCell_ID.h
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
LArCollisionTimeAlg::m_minCells
Gaudi::Property< int > m_minCells
Definition: LArCollisionTimeAlg.h:49
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArProv::QTPRESENT
@ QTPRESENT
Definition: LArProvenance.h:34
CaloCell_Base_ID::is_em_endcap_inner
bool is_em_endcap_inner(const Identifier id) const
test if the id belongs to the EM Endcap inner wheel
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArProv::DEFAULTRECO
@ DEFAULTRECO
Definition: LArProvenance.h:28
LArCollisionTimeAlg::m_timeCut
Gaudi::Property< float > m_timeCut
Definition: LArCollisionTimeAlg.h:48
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
LArCollisionTimeAlg::m_noiseCDOKey
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
Definition: LArCollisionTimeAlg.h:54
LArProv::DSPCALC
@ DSPCALC
Definition: LArProvenance.h:33
CaloNoise
Definition: CaloNoise.h:16
LArCollisionTimeAlg::m_isMC
Gaudi::Property< bool > m_isMC
Definition: LArCollisionTimeAlg.h:46
LArProv::test
bool test(const uint16_t prov, const LArProvenance check)
Definition: LArProvenance.h:38
LArProv::MASKED
@ MASKED
Definition: LArProvenance.h:32
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArCollisionTimeAlg::finalize
virtual StatusCode finalize() override final
standard Athena-Algorithm method
Definition: LArCollisionTimeAlg.cxx:27
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArCollisionTimeAlg::m_calo_id
const CaloCell_ID * m_calo_id
Definition: LArCollisionTimeAlg.h:41
LArCollisionTimeAlg::m_iterCut
Gaudi::Property< bool > m_iterCut
Definition: LArCollisionTimeAlg.h:47
LArProvenance.h
SG::WriteHandle::put
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an object to the store.
LArProv::ITERCONVERGED
@ ITERCONVERGED
Definition: LArProvenance.h:29
LArProv::LArProvenance
LArProvenance
Definition: LArProvenance.h:13
CaloCell_ID_FCS::FCAL0
@ FCAL0
Definition: FastCaloSim_CaloCell_ID.h:40
LArCollisionTimeAlg::initialize
virtual StatusCode initialize() override final
standard Athena-Algorithm method
Definition: LArCollisionTimeAlg.cxx:10
LArCollisionTimeAlg.h
readCCLHist.float
float
Definition: readCCLHist.py:83
WriteCellNoiseToCool.noise
noise
Definition: WriteCellNoiseToCool.py:380
AthReentrantAlgorithm::setFilterPassed
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Definition: AthReentrantAlgorithm.h:139
LArCollisionTimeAlg::m_cellsContName
SG::ReadHandleKey< CaloCellContainer > m_cellsContName
Definition: LArCollisionTimeAlg.h:52
Identifier
Definition: IdentifierFieldParser.cxx:14