ATLAS Offline Software
LArHitEMap.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <cstdlib>
7 #include <iostream>
8 
9 #include "CaloDetDescr/CaloDetDescrElement.h"
10 #include "Identifier/Identifier.h"
12 
13 
14 //For the buildWindow function
16 #include "AtlasHepMC/GenEvent.h"
17 #include "AtlasHepMC/GenParticle.h"
19 
20 LArHitEMap::~LArHitEMap() = default;
21 
22 //bool LArHitEMap::Initialize(std::vector<bool>& flags, bool windows, bool digit)
24  m_cabling(cabling),
25  m_calocell_id(cellid),
26  m_cddMgr(cddMgr) {
27 
28  //the last cell of the FCAL is the hash-max for LAr (ignore the Tile part)
29  IdentifierHash fcalCellMin, fcalCellMax;
30  cellid->calo_cell_hash_range(CaloCell_ID::LARFCAL,fcalCellMin,fcalCellMax);
31 
32  //fill energy map up to fcal-hashmax(= lar-hashmax)
33  m_emap.resize(fcalCellMax);
34  if (digit) m_digmap.resize(fcalCellMax,nullptr);
35 }
36 
37 
38 // add energy using the calo-cell hash
39 bool LArHitEMap::AddEnergy(const IdentifierHash index, const float energy, const float time) {
40  if(index >= m_emap.size()) return(false);
41  m_emap[index].AddHit(energy,time);
42  return true;
43 }
44 
45 // add energy using identifier
46 bool LArHitEMap::AddEnergy(const Identifier cellid, const float energy, const float time) {
48  return AddEnergy(idHash,energy,time);
49 }
50 
52  const HWIdentifier ch_id = digit->channelID();
53  if (m_cabling->isOnlineConnected(ch_id)) {
54  Identifier cellid=m_cabling->cnvToIdentifier(ch_id);
56 
57  if (h>=m_digmap.size()) return false ;
58  m_digmap[h]=digit;
59  return true;
60  }
61  else
62  return false;
63 }
64 
65 int LArHitEMap::GetNbCells(void) const
66 {
67  return m_emap.size() ;
68 }
69 
71  float deta,float dphi, float ptmin)
72 {
73 // get list of particles
74  std::vector<double> phiPart;
75  std::vector<double> etaPart;
76 
77  etaPart.clear();
78  phiPart.clear();
79 
80  if (!mcCollptr) {
81  return false;
82  }
83 
85 // std::cout << " start loop over particles " << std::endl;
86  for (itr = mcCollptr->begin(); itr!=mcCollptr->end(); ++itr) {
87  for (const auto& part: *(*itr))
88  {
89  //works only for photons(22) and electrons(11) primary particle (+pi0 in case not decayed by generator)
90  // with pt>5 GeV
91  // pickup "stable" particle from generator excluding G4 secondaries
92  if( ( MC::isPhoton(part) || MC::isElectron(part) || part->pdg_id()==111) && part->momentum().perp()> ptmin
94  {
95  etaPart.push_back(part->momentum().pseudoRapidity());
96  phiPart.push_back(part->momentum().phi());
97  }
98  }
99  }
100 
101 
102  if ( etaPart.empty()) return true;
103 
104  for (unsigned int i=0; i < m_emap.size(); i++)
105  {
106  LArHitList& theLArHitList = m_emap[i];
108  double eta=calodde->eta();
109  double phi=calodde->phi();
110  for(unsigned int iPart=0;iPart<etaPart.size();++iPart)
111  {
112  double deltaPhi=fmod(phiPart[iPart]-phi+3.0*M_PI,2.0*M_PI)-M_PI;
113  double deltaEta=etaPart[iPart]-eta;
114  if( std::fabs(deltaPhi)<dphi/2. &&
115  std::fabs(deltaEta)<deta/2. )
116  {
117  theLArHitList.setInWindows();
118  break;
119  }
120  } // loop over particles
121  } // loop over cells
122  return true;
123 }
LArHitList::setInWindows
void setInWindows()
Definition: LArHitList.h:27
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition: CaloCell_Base_ID.h:46
LArHitEMap::m_digmap
DIGMAP m_digmap
Definition: LArHitEMap.h:29
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
GenEvent.h
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
LArHitEMap::LArHitEMap
LArHitEMap()=delete
LArHitEMap::m_calocell_id
const CaloCell_ID * m_calocell_id
Definition: LArHitEMap.h:31
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
index
Definition: index.py:1
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
TrigJetMonitorAlgorithm.ptmin
ptmin
Definition: TrigJetMonitorAlgorithm.py:1081
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
LArHitEMap::AddEnergy
bool AddEnergy(const IdentifierHash index, const float energy, const float time)
Definition: LArHitEMap.cxx:39
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
M_PI
#define M_PI
Definition: ActiveFraction.h:11
LArHitEMap::AddDigit
bool AddDigit(const LArDigit *digit)
Definition: LArHitEMap.cxx:51
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
HWIdentifier
Definition: HWIdentifier.h:13
GenParticle.h
LArHitEMap::~LArHitEMap
~LArHitEMap(void)
LArHitEMap::m_cabling
const LArOnOffIdMapping * m_cabling
Definition: LArHitEMap.h:30
LArHitEMap.h
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
HepMC::is_simulation_particle
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
Definition: MagicNumbers.h:299
McEventCollection.h
P4Helpers::deltaEta
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition: P4Helpers.h:53
LArHitEMap::m_cddMgr
const CaloDetDescrManager * m_cddMgr
Definition: LArHitEMap.h:32
LArDigit
Liquid Argon digit base class.
Definition: LArDigit.h:25
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloCell_Base_ID::calo_cell_hash_range
void calo_cell_hash_range(const Identifier id, IdentifierHash &caloCellMin, IdentifierHash &caloCellMax) const
to loop on 'global' cell hashes of one sub-calorimeter alone
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
extractSporadic.h
list h
Definition: extractSporadic.py:97
xAOD::EgammaHelpers::isElectron
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
Definition: EgammaxAODHelpers.cxx:12
LArHitEMap::m_emap
std::vector< LArHitList > m_emap
Definition: LArHitEMap.h:28
LArHitEMap::BuildWindows
bool BuildWindows(const McEventCollection *mcCollptr, float deta, float dphi, float ptmin)
Definition: LArHitEMap.cxx:70
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
LArHitList
Definition: LArHitList.h:9
IdentifierHash.h
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DeMoScan.index
string index
Definition: DeMoScan.py:362
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
h
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
LArOnOffIdMapping::cnvToIdentifier
Identifier cnvToIdentifier(const HWIdentifier &sid) const
create an Identifier from a HWIdentifier (inline)
Definition: LArOnOffIdMapping.h:116
xAOD::EgammaHelpers::isPhoton
bool isPhoton(const xAOD::Egamma *eg)
is the object a photon
Definition: EgammaxAODHelpers.cxx:21
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloDetDescrElement::phi
float phi() const
cell phi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:346
LArHitEMap::GetNbCells
int GetNbCells(void) const
Definition: LArHitEMap.cxx:65
IdentifierHash
Definition: IdentifierHash.h:38
LArOnOffIdMapping::isOnlineConnected
bool isOnlineConnected(const HWIdentifier &sid) const
Test whether a HWIdentifier is connected of not (inline)
Definition: LArOnOffIdMapping.h:121
HepMCHelpers.h
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20