ATLAS Offline Software
Loading...
Searching...
No Matches
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"
19
20
21//bool LArHitEMap::Initialize(std::vector<bool>& flags, bool windows, bool digit)
22LArHitEMap::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
38bool 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
45bool 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
50bool 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
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
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
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}
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Scalar phi() const
phi method
ATLAS-specific HepMC functions.
Header file for AthHistogramAlgorithm.
void calo_cell_hash_range(const Identifier id, IdentifierHash &caloCellMin, IdentifierHash &caloCellMax) const
to loop on 'global' cell hashes of one sub-calorimeter alone
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
This class groups all DetDescr information related to a CaloCell.
This class provides the client interface for accessing the detector description information common to...
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
This is a "hash" representation of an Identifier.
Liquid Argon digit base class.
Definition LArDigit.h:25
bool BuildWindows(const McEventCollection *mcCollptr, float deta, float dphi, float ptmin)
std::vector< LArHitList > m_emap
Definition LArHitEMap.h:28
bool AddEnergy(const IdentifierHash index, const float energy, const float time)
bool AddDigit(const LArDigit *digit)
const CaloCell_ID * m_calocell_id
Definition LArHitEMap.h:31
LArHitEMap()=delete
const LArOnOffIdMapping * m_cabling
Definition LArHitEMap.h:30
const CaloDetDescrManager * m_cddMgr
Definition LArHitEMap.h:32
DIGMAP m_digmap
Definition LArHitEMap.h:29
void setInWindows()
Definition LArHitList.h:27
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
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...
bool isPhoton(const T &p)
bool isElectron(const T &p)
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
Definition index.py:1