CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CalibrationCluster.cc
Go to the documentation of this file.
2 #include <iostream>
3 #include <string>
4 
5 using namespace std;
6 
8 
10 
12 
13 std::vector<EBDetId> CalibrationCluster::get5x5Id(EBDetId const& maxHitId) {
14  Xtals5x5.clear();
15 
16  // std::cout << "get5x5Id: max Containment crystal " << maxHitId.ic() << " eta " << maxHitId.ieta() << " phi " << maxHitId.iphi() << std::endl;
17 
18  for (unsigned int icry = 0; icry < 25; icry++) {
19  unsigned int row = icry / 5;
20  unsigned int column = icry % 5;
21  // std::cout << "CalibrationCluster::icry = " << icry << std::endl;
22 
23  int curr_eta = maxHitId.ieta() + column - (5 / 2);
24  int curr_phi = maxHitId.iphi() + row - (5 / 2);
25 
26  if (curr_eta * maxHitId.ieta() <= 0) {
27  if (maxHitId.ieta() > 0)
28  curr_eta--;
29  else
30  curr_eta++;
31  } // JUMP over 0
32  if (curr_phi < 1)
33  curr_phi += 360;
34  if (curr_phi > 360)
35  curr_phi -= 360;
36 
37  try {
38  // Xtals5x5.push_back(EBDetId(maxHitId.ieta()+column-2,maxHitId.iphi()+row-2,EBDetId::ETAPHIMODE));
39  Xtals5x5.push_back(EBDetId(curr_eta, curr_phi, EBDetId::ETAPHIMODE));
40  } catch (...) {
41  std::cout << "Cannot construct 5x5 matrix around EBDetId " << maxHitId << std::endl;
42  }
43  }
44 
45  return Xtals5x5;
46 }
47 
49 
50 std::vector<EBDetId> CalibrationCluster::get3x3Id(EBDetId const& maxHitId) {
51  Xtals3x3.clear();
52 
53  for (unsigned int icry = 0; icry < 9; icry++) {
54  unsigned int row = icry / 3;
55  unsigned int column = icry % 3;
56 
57  try {
58  Xtals3x3.push_back(EBDetId(maxHitId.ieta() + column - 1, maxHitId.iphi() + row - 1, EBDetId::ETAPHIMODE));
59  } catch (...) {
60  std::cout << "Cannot construct 3x3 matrix around EBDetId " << maxHitId << std::endl;
61  }
62  }
63 
64  return Xtals3x3;
65 }
66 
68 
70  calibRegion.clear();
71  int rowSize = maxEta - minEta + 1;
72  int columnSize = maxPhi - minPhi + 1;
73  int reducedSize = rowSize * columnSize;
74 
75  for (int icry = 0; icry < reducedSize; icry++) {
76  unsigned int eta = minEta + icry / columnSize;
77  unsigned int phi = minPhi + icry % columnSize;
78 
79  try {
80  calibRegion.insert(pippo(EBDetId(eta, phi, EBDetId::ETAPHIMODE), icry));
81  } catch (...) {
82  std::cout << "Cannot construct full matrix !!! " << std::endl;
83  }
84  }
85 
86  return calibRegion;
87 }
88 
90 
92  CalibMap& ReducedMap,
93  std::vector<EBDetId>& XstalsNxN,
94  float& outBoundEnergy,
95  int& nXtalsOut) {
96  energyVector.clear();
97  std::vector<EBDetId>::iterator it;
98 
99  // std::cout << "Reduced Map Size =" << ReducedMap.size() << std::endl;
100  // std::cout << "XstalsNxN Size =" << XstalsNxN.size() << std::endl;
101  energyVector.resize(ReducedMap.size(), 0.);
102 
103  outBoundEnergy = 0.;
104  nXtalsOut = 0;
105  for (it = XstalsNxN.begin(); it != XstalsNxN.end(); ++it) {
106  if (ReducedMap.find(*it) != ReducedMap.end()) {
107  CalibMap::iterator it2 = ReducedMap.find(*it);
108 
109  int icry = it2->second;
110 
111  energyVector[icry] = (hits->find(*it))->energy();
112 
113  } else {
114  // std::cout << " Cell out of Reduced map: did you subtracted the cell energy from P ???" << std::endl;
115  outBoundEnergy += (hits->find(*it))->energy();
116  nXtalsOut++;
117  }
118  }
119 
120  return energyVector;
121 }
CalibMap::value_type pippo
CalibMap getMap(int, int, int, int)
std::map< EBDetId, unsigned int > CalibMap
double maxEta
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
std::vector< float > getEnergyVector(const EBRecHitCollection *, CalibMap &, std::vector< EBDetId > &, float &, int &)
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
static const int ETAPHIMODE
Definition: EBDetId.h:158
std::vector< EBDetId > get3x3Id(EBDetId const &)
iterator find(key_type k)
tuple cout
Definition: gather_cfg.py:144
std::vector< EBDetId > get5x5Id(EBDetId const &)