ATLAS Offline Software
LArHitEMap.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 <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 
21 //bool LArHitEMap::Initialize(std::vector<bool>& flags, bool windows, bool digit)
23  m_cabling(cabling),
24  m_calocell_id(cellid),
25  m_cddMgr(cddMgr) {
26 
27  //the last cell of the FCAL is the hash-max for LAr (ignore the Tile part)
28  IdentifierHash fcalCellMin, fcalCellMax;
29  cellid->calo_cell_hash_range(CaloCell_ID::LARFCAL,fcalCellMin,fcalCellMax);
30 
31  //fill energy map up to fcal-hashmax(= lar-hashmax)
32  m_emap.resize(fcalCellMax);
33  if (digit) m_digmap.resize(fcalCellMax,nullptr);
34 }
35 
36 
37 // add energy using the calo-cell hash
38 bool LArHitEMap::AddEnergy(const IdentifierHash index, const float energy, const float time) {
39  if(index >= m_emap.size()) return(false);
40  m_emap[index].AddHit(energy,time);
41  return true;
42 }
43 
44 // add energy using identifier
45 bool LArHitEMap::AddEnergy(const Identifier cellid, const float energy, const float time) {
47  return AddEnergy(idHash,energy,time);
48 }
49 
51  const HWIdentifier ch_id = digit->channelID();
52  if (m_cabling->isOnlineConnected(ch_id)) {
53  Identifier cellid=m_cabling->cnvToIdentifier(ch_id);
55 
56  if (h>=m_digmap.size()) return false ;
57  m_digmap[h]=digit;
58  return true;
59  }
60  else
61  return false;
62 }
63 
64 int LArHitEMap::GetNbCells(void) const
65 {
66  return m_emap.size() ;
67 }
68 
70  float deta,float dphi, float ptmin)
71 {
72 // get list of particles
73  std::vector<double> phiPart;
74  std::vector<double> etaPart;
75 
76  etaPart.clear();
77  phiPart.clear();
78 
79  if (!mcCollptr) {
80  return false;
81  }
82 
84 // std::cout << " start loop over particles " << std::endl;
85  for (itr = mcCollptr->begin(); itr!=mcCollptr->end(); ++itr) {
86  for (const auto& part: *(*itr))
87  {
88  //works only for photons(22) and electrons(11) primary particle (+pi0 in case not decayed by generator)
89  // with pt>5 GeV
90  // pickup "stable" particle from generator excluding G4 secondaries
91  if( ( MC::isPhoton(part) || MC::isElectron(part) || part->pdg_id()==111) && part->momentum().perp()> ptmin
93  {
94  etaPart.push_back(part->momentum().pseudoRapidity());
95  phiPart.push_back(part->momentum().phi());
96  }
97  }
98  }
99 
100 
101  if ( etaPart.empty()) return true;
102 
103  for (unsigned int i=0; i < m_emap.size(); i++)
104  {
105  LArHitList& theLArHitList = m_emap[i];
107  double eta=calodde->eta();
108  double phi=calodde->phi();
109  for(unsigned int iPart=0;iPart<etaPart.size();++iPart)
110  {
111  double deltaPhi=fmod(phiPart[iPart]-phi+3.0*M_PI,2.0*M_PI)-M_PI;
112  double deltaEta=etaPart[iPart]-eta;
113  if( std::fabs(deltaPhi)<dphi/2. &&
114  std::fabs(deltaEta)<deta/2. )
115  {
116  theLArHitList.setInWindows();
117  break;
118  }
119  } // loop over particles
120  } // loop over cells
121  return true;
122 }
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:67
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:83
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:1226
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:38
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:50
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
HWIdentifier
Definition: HWIdentifier.h:13
GenParticle.h
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:355
McEventCollection.h
P4Helpers::deltaEta
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition: P4Helpers.h:66
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:85
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
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:69
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:364
MC::isStable
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
Definition: HepMCHelpers.h:45
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:64
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
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
Identifier
Definition: IdentifierFieldParser.cxx:14