ATLAS Offline Software
CaloCellList.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Given an input eta,phi, deta,dphi - this class will return you
6 // either an iterator over a list of cells (pointers) in this cone
7 // and the total cell energy of the cells in this cone.
8 // (11/10/2004) Method added: returns number of strips for an input
9 // eta,phi,ncell_eta,ncell_phi. The List of cells replaced by
10 // the Vector of cells.
11 
12 #include "CaloUtils/CaloCellList.h"
14 #include "CaloEvent/CaloCell.h"
16 #include "CaloGeoHelpers/CaloSampling.h"
17 #include "CaloGeoHelpers/proxim.h"
18 
19 #include <cmath>
20 
21 namespace {
22 inline double
23 square(double x)
24 {
25  return x * x;
26 }
27 }
28 
30  : m_cellcont(cell_container)
31  , m_mgr(mgr)
32  , m_energy(0)
33  , m_et(0)
34 {
35  m_caloNums.clear();
36  // NSUBCALO indicate take them all
38 }
39 
40 // specify one calo number
42  : m_cellcont(cell_container)
43  , m_mgr(mgr)
44  , m_energy(0)
45  , m_et(0)
46 {
47  m_caloNums.clear();
48  m_caloNums.push_back(caloNum);
49 }
50 
51 // specify a vector of calonumber
52 // (if all calo it is more efficient to not specify anything)
54  const std::vector<CaloCell_ID::SUBCALO>& caloNums)
55  : m_cellcont(cell_container)
56  , m_mgr(mgr)
57  , m_energy(0)
58  , m_et(0)
59 
60 {
61  m_caloNums.clear();
62  std::copy(caloNums.begin(), caloNums.end(), back_inserter(m_caloNums));
63 }
64 
65 
66 void
67 CaloCellList::select(double eta, double phi, double deta, double dphi)
68 {
69  doSelect(eta, phi, deta, dphi, -1);
70 }
71 
72 void
73 CaloCellList::select(double eta, double phi, double deta, double dphi, int sam)
74 {
75  doSelect(eta, phi, deta, dphi, -1, static_cast<CaloCell_ID::CaloSample>(sam));
76 }
77 
78 void
79 CaloCellList::select(double eta, double phi, double dR)
80 {
81  doSelect(eta, phi, dR, dR, dR);
82 }
83 
84 void
85 CaloCellList::select(double eta, double phi, double dR, int sam)
86 {
87  doSelect(eta, phi, dR, dR, dR, static_cast<CaloCell_ID::CaloSample>(sam));
88 }
89 
90 void
92  double phi,
93  double deta,
94  double dphi,
95  double dR,
96  CaloCell_ID::CaloSample sam /*= CaloCell_ID::Unknown*/)
97 {
98 
99  m_theCellVector.clear();
100  m_energy = 0;
101  m_et = 0;
102  m_nBadT0 = 0;
103  m_nBadT12 = 0;
104  if (m_cellcont->empty()){
105  return;
106  }
107  std::vector<IdentifierHash> calo_mgr_vect;
108  std::vector<CaloCell_ID::SUBCALO>::const_iterator itrCaloNum = m_caloNums.begin();
109  std::vector<CaloCell_ID::SUBCALO>::const_iterator itrEndCaloNum = m_caloNums.end();
110 
111  double dR2 = dR*dR;
112 
113  for (; itrCaloNum != itrEndCaloNum; ++itrCaloNum) {
114  CaloCell_ID::SUBCALO caloNum = *itrCaloNum;
115  if (sam != CaloCell_ID::Unknown) {
116  m_mgr->cellsInZone(eta - deta, eta + deta, phi - dphi, phi + dphi, sam, calo_mgr_vect);
117  itrCaloNum = itrEndCaloNum - 1;
118  } else if (caloNum == CaloCell_ID::NSUBCALO) {
119  m_mgr->cellsInZone(eta - deta, eta + deta, phi - dphi, phi + dphi, calo_mgr_vect);
120  } else if (caloNum != CaloCell_ID::NOT_VALID) {
121  m_mgr->cellsInZone(eta - deta, eta + deta, phi - dphi, phi + dphi, caloNum, calo_mgr_vect);
122  } else {
123  continue;
124  }
125  m_theCellVector.reserve(m_theCellVector.size() + calo_mgr_vect.size());
126 
127  for (unsigned int i = 0; i < calo_mgr_vect.size(); i++) {
128  const CaloCell* cell = m_cellcont->findCell(calo_mgr_vect[i]);
129  if (cell) {
130  double pphi = proxim(cell->phi(), phi);
131  if ( (dR > 0 && square(eta - cell->eta()) + square(pphi - phi) < dR2) ||
132  (dR < 0 && std::fabs(eta - cell->eta()) < deta && std::fabs(phi - pphi) < dphi) ) {
133  m_theCellVector.push_back(cell);
134  m_energy += cell->energy();
135  m_et += cell->et();
136  if (cell->badcell()) {
137  if (sam == CaloCell_ID::TileBar0 || sam == CaloCell_ID::TileExt0)
138  m_nBadT0++;
139  else if (sam == CaloCell_ID::TileBar1 || sam == CaloCell_ID::TileExt1 ||
140  sam == CaloCell_ID::TileBar2 || sam == CaloCell_ID::TileExt2 ||
142  m_nBadT12++;
143  }
144  }
145  }
146  }
147  } // end loop on calorimeters
148 }
149 
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
CaloCellList::CaloCellList
CaloCellList()=delete
CaloCellList::m_theCellVector
vector_type m_theCellVector
Definition: CaloCellList.h:80
CaloCell_ID_FCS::TileExt2
@ TileExt2
Definition: FastCaloSim_CaloCell_ID.h:39
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
CaloCellList::select
void select(double eta, double phi, double deta, double dphi)
Definition: CaloCellList.cxx:67
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
CaloCellList::m_mgr
const CaloDetDescrManager * m_mgr
Definition: CaloCellList.h:78
CaloCellList.h
CaloCell_ID_FCS::TileExt0
@ TileExt0
Definition: FastCaloSim_CaloCell_ID.h:37
CaloCell_ID_FCS::TileBar1
@ TileBar1
Definition: FastCaloSim_CaloCell_ID.h:32
proxim
double proxim(double b, double a)
Definition: proxim.h:17
CaloCell.h
x
#define x
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
proxim.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CaloCell_ID_FCS::TileBar0
@ TileBar0
Definition: FastCaloSim_CaloCell_ID.h:31
CaloCellList::m_nBadT12
unsigned short m_nBadT12
Definition: CaloCellList.h:83
CaloCell_ID_FCS::TileGap2
@ TileGap2
Definition: FastCaloSim_CaloCell_ID.h:35
CaloCell_Base_ID::SUBCALO
SUBCALO
enumeration of sub calorimeters
Definition: CaloCell_Base_ID.h:46
CaloCellList::doSelect
void doSelect(double eta, double phi, double deta, double dphi, double dR, CaloCell_ID::CaloSample sam=CaloCell_ID::Unknown)
Definition: CaloCellList.cxx:91
CaloDetDescrManager_Base::cellsInZone
void cellsInZone(double eta_min, double eta_max, double phi_min, double phi_max, std::vector< IdentifierHash > &cell_list) const
the only client is CaloCellList class
Definition: CaloDetDescrManager.cxx:793
CaloCell_ID_FCS::TileGap1
@ TileGap1
Definition: FastCaloSim_CaloCell_ID.h:34
CaloCellList::m_caloNums
std::vector< CaloCell_ID::SUBCALO > m_caloNums
Definition: CaloCellList.h:79
CaloCellContainer::findCell
const CaloCell * findCell(const IdentifierHash theHash) const
fast find method given identifier hash.
Definition: CaloCellContainer.cxx:345
CaloCell_ID_FCS::TileExt1
@ TileExt1
Definition: FastCaloSim_CaloCell_ID.h:38
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloCellList::m_nBadT0
unsigned short m_nBadT0
Definition: CaloCellList.h:83
CaloCellList::m_energy
double m_energy
Definition: CaloCellList.h:81
CaloCellList::m_et
double m_et
Definition: CaloCellList.h:82
CaloCell_Base_ID::NSUBCALO
@ NSUBCALO
Definition: CaloCell_Base_ID.h:46
calibdata.copy
bool copy
Definition: calibdata.py:27
CaloCellList::m_cellcont
const CaloCellContainer * m_cellcont
Definition: CaloCellList.h:77
CaloCell_Base_ID::NOT_VALID
@ NOT_VALID
Definition: CaloCell_Base_ID.h:46
CaloCell_ID_FCS::TileBar2
@ TileBar2
Definition: FastCaloSim_CaloCell_ID.h:33
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.