CMS 3D CMS Logo

CaloCellManager.cc
Go to the documentation of this file.
1 /* class CaloCellManager
2  *
3  * Simple eta-phi cell structure manager, mimic calorimetric tower structure
4  *
5  *
6  */
7 
9 
10 #include "CLHEP/Units/defs.h"
11 #include "CLHEP/Units/SystemOfUnits.h"
12 
13 #include <iomanip>
14 
15 CaloCellManager::CaloCellManager(const unsigned int theVerbosity) : verbosity(theVerbosity) {
16  //initialize constants
17 
18  init();
19 
20  // build the calo cells identifiers
21 
22  builder();
23 }
24 
26  for (unsigned int i = 0; i < theCellCollection.size(); i++) {
27  delete theCellCollection[i];
28  }
29 }
30 
32  etaLim.reserve(nBarrelEta + nEndcapEta + nForwardEta + 1);
33  phiLimBar.reserve(nBarrelEta + 1);
34  phiLimEnd.reserve(nEndcapEta + 1);
35  phiLimFor.reserve(nForwardEta + 1);
36 
37  // Barrel ranges
38 
39  double firstEta = 0.;
40  double etaBarrelBin = 0.087;
41  for (unsigned int ietabin = 0; ietabin <= nBarrelEta; ietabin++) {
42  etaLim.push_back(firstEta + ietabin * etaBarrelBin);
43  }
44 
45  double firstPhi = -180.;
46  double phiBarrelBin = (double)360 / nBarrelPhi;
47  for (unsigned int iphibin = 0; iphibin <= nBarrelPhi; iphibin++) {
48  phiLimBar.push_back((firstPhi + iphibin * phiBarrelBin) * CLHEP::degree);
49  }
50 
51  // Endcap ranges (compromise wrt real CMS)
52 
53  firstEta = etaBarrelBin * nBarrelEta;
54  double etaEndcapBin = 0.131;
55  for (unsigned int ietabin = 1; ietabin <= nEndcapEta; ietabin++) {
56  etaLim.push_back(firstEta + ietabin * etaEndcapBin);
57  }
58  double phiEndcapBin = (double)360 / nEndcapPhi;
59  for (unsigned int iphibin = 0; iphibin <= nEndcapPhi; iphibin++) {
60  phiLimEnd.push_back((firstPhi + iphibin * phiEndcapBin) * CLHEP::degree);
61  }
62 
63  // Forward ranges (compromise wrt real CMS)
64 
65  etaLim.push_back(3.139);
66  etaLim.push_back(3.314);
67  etaLim.push_back(3.489);
68  etaLim.push_back(3.664);
69  etaLim.push_back(3.839);
70  etaLim.push_back(4.013);
71  etaLim.push_back(4.191);
72  etaLim.push_back(4.363);
73  etaLim.push_back(4.538);
74  etaLim.push_back(4.716);
75  etaLim.push_back(4.889);
76  etaLim.push_back(5.191);
77 
78  double phiForwardBin = (double)360 / nForwardPhi;
79  for (unsigned int iphibin = 0; iphibin <= nForwardPhi; iphibin++) {
80  phiLimFor.push_back((firstPhi + iphibin * phiForwardBin) * CLHEP::degree);
81  }
82 
83  if (verbosity > 0) {
84  std::cout << "Number of eta ranges = " << nBarrelEta + nEndcapEta + nForwardEta << std::endl;
85  for (unsigned int i = 0; i < etaLim.size(); i++) {
86  std::cout << "Eta range limit # " << i << " = " << etaLim[i] << std::endl;
87  }
88  for (unsigned int i = 0; i < phiLimBar.size(); i++) {
89  std::cout << "Phi barrel range limit # " << i << " = " << phiLimBar[i] << std::endl;
90  }
91  for (unsigned int i = 0; i < phiLimEnd.size(); i++) {
92  std::cout << "Phi endcap range limit # " << i << " = " << phiLimEnd[i] << std::endl;
93  }
94  for (unsigned int i = 0; i < phiLimFor.size(); i++) {
95  std::cout << "Phi forward range limit # " << i << " = " << phiLimFor[i] << std::endl;
96  }
97  }
98 }
99 
101  theCellCollection.reserve(nCaloCell);
102 
103  // Barrel
104 
106 
107  for (unsigned int iphi = 0; iphi < nBarrelPhi; iphi++) {
108  for (unsigned int ieta = 0; ieta < nBarrelEta; ieta++) {
109  CaloCellId* thisCell =
110  new CaloCellId(etaLim[ieta], etaLim[ieta + 1], phiLimBar[iphi], phiLimBar[iphi + 1], theSys);
111  theCellCollection.push_back(thisCell);
112  }
113  for (unsigned int ieta = 0; ieta < nBarrelEta; ieta++) {
114  CaloCellId* thisCell =
115  new CaloCellId(-1. * etaLim[ieta + 1], -1. * etaLim[ieta], phiLimBar[iphi], phiLimBar[iphi + 1], theSys);
116  theCellCollection.push_back(thisCell);
117  }
118  }
119 
120  // Endcap
121 
122  theSys = CaloCellId::Endcap;
123 
124  for (unsigned int iphi = 0; iphi < nEndcapPhi; iphi++) {
125  for (unsigned int ieta = nBarrelEta; ieta < nBarrelEta + nEndcapEta; ieta++) {
126  CaloCellId* thisCell =
127  new CaloCellId(etaLim[ieta], etaLim[ieta + 1], phiLimEnd[iphi], phiLimEnd[iphi + 1], theSys);
128  theCellCollection.push_back(thisCell);
129  }
130  for (unsigned int ieta = nBarrelEta; ieta < nBarrelEta + nEndcapEta; ieta++) {
131  CaloCellId* thisCell =
132  new CaloCellId(-1. * etaLim[ieta + 1], -1. * etaLim[ieta], phiLimEnd[iphi], phiLimEnd[iphi + 1], theSys);
133  theCellCollection.push_back(thisCell);
134  }
135  }
136 
137  // Forward
138 
139  theSys = CaloCellId::Forward;
140 
141  for (unsigned int iphi = 0; iphi < nForwardPhi; iphi++) {
142  for (unsigned int ieta = nBarrelEta + nEndcapEta; ieta < nBarrelEta + nEndcapEta + nForwardEta; ieta++) {
143  CaloCellId* thisCell =
144  new CaloCellId(etaLim[ieta], etaLim[ieta + 1], phiLimFor[iphi], phiLimFor[iphi + 1], theSys);
145  theCellCollection.push_back(thisCell);
146  }
147  for (unsigned int ieta = nBarrelEta + nEndcapEta; ieta < nBarrelEta + nEndcapEta + nForwardEta; ieta++) {
148  CaloCellId* thisCell =
149  new CaloCellId(-1. * etaLim[ieta + 1], -1. * etaLim[ieta], phiLimFor[iphi], phiLimFor[iphi + 1], theSys);
150  theCellCollection.push_back(thisCell);
151  }
152  }
153 
154  if (verbosity > 0) {
155  std::cout << "Number of cells = " << nCaloCell << std::endl;
156  for (unsigned int i = 0; i < theCellCollection.size(); i++) {
157  std::cout << "Cell # " << std::setfill(' ') << std::setw(4) << i << " = " << *(theCellCollection[i]) << std::endl;
158  }
159  }
160 }
161 
162 unsigned int CaloCellManager::getCellIndexFromAngle(double eta, double phi) {
163  unsigned int theIndex = 1000000;
164  for (unsigned int i = 0; i < theCellCollection.size(); i++) {
165  if (theCellCollection[i]->isInCell(eta, phi)) {
166  theIndex = i;
167  continue;
168  }
169  }
170  return theIndex;
171 }
172 
174  if (id < theCellCollection.size()) {
175  return theCellCollection[id];
176  }
177  return nullptr;
178 }
179 
180 std::vector<double> CaloCellManager::getEtaRanges() {
181  std::vector<double> theEtaRanges(etaLim);
182  return theEtaRanges;
183 }
HIPAlignmentAlgorithm_cfi.verbosity
verbosity
Definition: HIPAlignmentAlgorithm_cfi.py:7
CaloCellManager::nForwardPhi
static const unsigned int nForwardPhi
Definition: CaloCellManager.h:34
mps_fire.i
i
Definition: mps_fire.py:428
CaloCellManager::nCaloCell
static const unsigned int nCaloCell
Definition: CaloCellManager.h:40
CaloCellId::Barrel
Definition: CaloCellId.h:16
gather_cfg.cout
cout
Definition: gather_cfg.py:144
CaloCellManager::builder
void builder()
Definition: CaloCellManager.cc:100
CaloCellId
Definition: CaloCellId.h:14
CaloCellManager::getEtaRanges
std::vector< double > getEtaRanges()
Definition: CaloCellManager.cc:180
CaloCellManager::CaloCellManager
CaloCellManager(unsigned int theVerbosity)
Definition: CaloCellManager.cc:15
CaloCellManager::etaLim
std::vector< double > etaLim
Definition: CaloCellManager.h:48
CaloCellManager::phiLimFor
std::vector< double > phiLimFor
Definition: CaloCellManager.h:51
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
CaloCellManager::nForwardEta
static const unsigned int nForwardEta
Definition: CaloCellManager.h:30
CaloCellManager::~CaloCellManager
virtual ~CaloCellManager()
Definition: CaloCellManager.cc:25
CaloCellManager::phiLimBar
std::vector< double > phiLimBar
Definition: CaloCellManager.h:49
CaloCellId::System
System
Definition: CaloCellId.h:16
PVValHelper::eta
Definition: PVValidationHelpers.h:70
CaloCellId::Endcap
Definition: CaloCellId.h:16
CaloCellManager::nEndcapEta
static const unsigned int nEndcapEta
Definition: CaloCellManager.h:29
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
CaloCellManager::getCellIndexFromAngle
unsigned int getCellIndexFromAngle(double eta, double phi)
Definition: CaloCellManager.cc:162
PVValHelper::phi
Definition: PVValidationHelpers.h:69
CaloCellManager::theCellCollection
CaloCellCollection theCellCollection
Definition: CaloCellManager.h:53
CaloCellManager::verbosity
unsigned int verbosity
Definition: CaloCellManager.h:46
CaloCellManager::nBarrelPhi
static const unsigned int nBarrelPhi
Definition: CaloCellManager.h:32
DDAxes::phi
CaloCellId::Forward
Definition: CaloCellId.h:16
CaloCellManager::getCellFromIndex
CaloCellId * getCellFromIndex(unsigned int id)
Definition: CaloCellManager.cc:173
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
CaloCellManager::nBarrelEta
static const unsigned int nBarrelEta
Definition: CaloCellManager.h:28
CaloCellManager.h
CaloCellManager::nEndcapPhi
static const unsigned int nEndcapPhi
Definition: CaloCellManager.h:33
CaloCellManager::phiLimEnd
std::vector< double > phiLimEnd
Definition: CaloCellManager.h:50
CaloCellManager::init
void init()
Definition: CaloCellManager.cc:31