ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArDigitization
src
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
5
#include "
LArDigitization/LArHitEMap.h
"
6
#include <cstdlib>
7
#include <iostream>
8
9
#include "CaloDetDescr/CaloDetDescrElement.h"
10
#include "Identifier/Identifier.h"
11
#include "
Identifier/IdentifierHash.h
"
12
13
14
//For the buildWindow function
15
#include "
GeneratorObjects/McEventCollection.h
"
16
#include "
AtlasHepMC/GenEvent.h
"
17
#include "
AtlasHepMC/GenParticle.h
"
18
#include "
TruthUtils/HepMCHelpers.h
"
19
20
21
//bool LArHitEMap::Initialize(std::vector<bool>& flags, bool windows, bool digit)
22
LArHitEMap::LArHitEMap
(
const
LArOnOffIdMapping
* cabling,
const
CaloCell_ID
* cellid,
const
CaloDetDescrManager
* cddMgr,
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) {
46
IdentifierHash
idHash=
m_calocell_id
->calo_cell_hash(cellid);
47
return
AddEnergy
(idHash,energy,time);
48
}
49
50
bool
LArHitEMap::AddDigit
(
const
LArDigit
* digit) {
51
const
HWIdentifier
ch_id = digit->channelID();
52
if
(
m_cabling
->isOnlineConnected(ch_id)) {
53
Identifier
cellid=
m_cabling
->cnvToIdentifier(ch_id);
54
IdentifierHash
h
=
m_calocell_id
->calo_cell_hash(cellid);
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
bool
LArHitEMap::BuildWindows
(
const
McEventCollection
* mcCollptr,
65
float
deta,
float
dphi,
float
ptmin)
66
{
67
// get list of particles
68
std::vector<double> phiPart;
69
std::vector<double> etaPart;
70
71
etaPart.clear();
72
phiPart.clear();
73
74
if
(!mcCollptr) {
75
return
false
;
76
}
77
78
McEventCollection::const_iterator
itr;
79
// std::cout << " start loop over particles " << std::endl;
80
for
(itr = mcCollptr->
begin
(); itr!=mcCollptr->
end
(); ++itr) {
81
for
(
const
auto
& part: *(*itr))
82
{
83
//works only for photons(22) and electrons(11) primary particle (+pi0 in case not decayed by generator)
84
// with pt>5 GeV
85
// pickup "stable" particle from generator excluding G4 secondaries
86
if
( (
MC::isPhoton
(part) ||
MC::isElectron
(part) || part->pdg_id()==111) && part->momentum().perp()> ptmin
87
&&
MC::isStable
(part) && !
HepMC::is_simulation_particle
(part) )
88
{
89
etaPart.push_back(part->momentum().pseudoRapidity());
90
phiPart.push_back(part->momentum().phi());
91
}
92
}
93
}
94
95
96
if
( etaPart.empty())
return
true
;
97
98
for
(
unsigned
int
i=0; i <
m_emap
.size(); i++)
99
{
100
LArHitList
& theLArHitList =
m_emap
[i];
101
const
CaloDetDescrElement
* calodde =
m_cddMgr
->get_element(
IdentifierHash
(i));
102
double
eta
=calodde->
eta
();
103
double
phi
=calodde->
phi
();
104
for
(
unsigned
int
iPart=0;iPart<etaPart.size();++iPart)
105
{
106
double
deltaPhi
=fmod(phiPart[iPart]-
phi
+3.0*
M_PI
,2.0*
M_PI
)-
M_PI
;
107
double
deltaEta=etaPart[iPart]-
eta
;
108
if
( std::fabs(
deltaPhi
)<dphi/2. &&
109
std::fabs(deltaEta)<deta/2. )
110
{
111
theLArHitList.
setInWindows
();
112
break
;
113
}
114
}
// loop over particles
115
}
// loop over cells
116
return
true
;
117
}
M_PI
#define M_PI
Definition
ActiveFraction.h:14
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
deltaPhi
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Definition
AmgMatrixBasePlugin.h:112
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
GenEvent.h
GenParticle.h
HepMCHelpers.h
ATLAS-specific HepMC functions.
IdentifierHash.h
LArHitEMap.h
McEventCollection.h
h
Header file for AthHistogramAlgorithm.
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition
CaloCell_Base_ID.h:45
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
CaloCell_ID
Helper class for offline cell identifiers.
Definition
CaloCell_ID.h:34
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell.
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
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
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition
CaloDetDescrManager.h:469
DataVector< HepMC::GenEvent >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
HWIdentifier
Definition
HWIdentifier.h:13
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
LArDigit
Liquid Argon digit base class.
Definition
LArDigit.h:25
LArHitEMap::BuildWindows
bool BuildWindows(const McEventCollection *mcCollptr, float deta, float dphi, float ptmin)
Definition
LArHitEMap.cxx:64
LArHitEMap::m_emap
std::vector< LArHitList > m_emap
Definition
LArHitEMap.h:28
LArHitEMap::AddEnergy
bool AddEnergy(const IdentifierHash index, const float energy, const float time)
Definition
LArHitEMap.cxx:38
LArHitEMap::AddDigit
bool AddDigit(const LArDigit *digit)
Definition
LArHitEMap.cxx:50
LArHitEMap::m_calocell_id
const CaloCell_ID * m_calocell_id
Definition
LArHitEMap.h:31
LArHitEMap::LArHitEMap
LArHitEMap()=delete
LArHitEMap::m_cabling
const LArOnOffIdMapping * m_cabling
Definition
LArHitEMap.h:30
LArHitEMap::m_cddMgr
const CaloDetDescrManager * m_cddMgr
Definition
LArHitEMap.h:32
LArHitEMap::m_digmap
DIGMAP m_digmap
Definition
LArHitEMap.h:29
LArHitList
Definition
LArHitList.h:9
LArHitList::setInWindows
void setInWindows()
Definition
LArHitList.h:27
LArOnOffIdMapping
Definition
LArOnOffIdMapping.h:20
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
Definition
McEventCollection.h:31
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:322
Identifier
Definition
IdentifierFieldParser.cxx:14
MC::isPhoton
bool isPhoton(const T &p)
Definition
HepMCHelpers.h:383
MC::isElectron
bool isElectron(const T &p)
Definition
HepMCHelpers.h:209
MC::isStable
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
Definition
HepMCHelpers.h:46
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.17.0