CMS 3D CMS Logo

MatrixFillMap.cc
Go to the documentation of this file.
5 
7  int WindowY,
8  const std::map<int, int>& xtalReg,
9  double minE,
10  double maxE,
11  const std::map<int, int>& IndexReg,
12  EcalIntercalibConstantMap* barrelMap,
13  EcalIntercalibConstantMap* endcapMap)
14  :
15 
16  VFillMap(WindowX, WindowY, xtalReg, minE, maxE, IndexReg, barrelMap, endcapMap) {}
17 
19 
20 void MatrixFillMap::fillMap(const std::vector<std::pair<DetId, float> >& v1,
21  const DetId Max,
22  const EcalRecHitCollection* barrelHitsCollection,
23  const EcalRecHitCollection* endcapHitsCollection,
24  std::map<int, double>& xtlMap,
25  double& pSubtract) {
26  if (Max.subdetId() == EcalBarrel) {
27  EBDetId EBMax = Max;
28  fillEBMap(EBMax, barrelHitsCollection, xtlMap, m_xtalRegionId[Max.rawId()], pSubtract);
29  } else if (Max.subdetId() == EcalEndcap) {
30  EEDetId EEMax = Max;
31  fillEEMap(EEMax, endcapHitsCollection, xtlMap, m_xtalRegionId[Max.rawId()], pSubtract);
32  }
33 }
34 
36  const EcalRecHitCollection* barrelHitsCollection,
37  std::map<int, double>& EBRegionMap,
38  int EBNumberOfRegion,
39  double& pSubtract) {
40  int curr_eta;
41  int curr_phi;
42  //reads the hits in a recoWindowSide^2 wide region around the MOX
43  for (int ii = 0; ii < m_recoWindowSidex; ++ii)
44  for (int ij = 0; ij < m_recoWindowSidey; ++ij) {
45  curr_eta = EBmax.ieta() + ii - (m_recoWindowSidex / 2);
46  curr_phi = EBmax.iphi() + ij - (m_recoWindowSidey / 2);
47  //skips if the xtals matrix falls over the border
48  if (abs(curr_eta) > 85)
49  continue;
50  //Couples with the zero gap in the barrel eta index
51  if (curr_eta * EBmax.ieta() <= 0) {
52  if (EBmax.ieta() > 0)
53  curr_eta--;
54  else
55  curr_eta++;
56  } // JUMP over 0
57  //The following 2 couples with the ciclicity of the phiIndex
58  if (curr_phi < 1)
59  curr_phi += 360;
60  if (curr_phi >= 360)
61  curr_phi -= 360;
62  //checks if the detId is valid
63  if (EBDetId::validDetId(curr_eta, curr_phi)) {
64  EBDetId det = EBDetId(curr_eta, curr_phi, EBDetId::ETAPHIMODE);
65  int ID = det.rawId();
66  //finds the hit corresponding to the cell
67  EcalRecHitCollection::const_iterator curr_recHit = barrelHitsCollection->find(det);
68  double dummy = 0;
69  dummy = curr_recHit->energy();
70  //checks if the reading of the xtal is in a sensible range
71  if (edm::isNotFinite(dummy)) {
72  dummy = 0;
73  }
75  continue;
77  continue;
78  //corrects the energy with the calibration coeff of the ring
79  dummy *= (*m_barrelMap)[det];
80  //sums the energy of the xtal to the appropiate ring
81  if (m_xtalRegionId[ID] == EBNumberOfRegion)
82  EBRegionMap[m_IndexInRegion[ID]] += dummy;
83  //adds the reading to pSubtract when part of the matrix is outside the region
84  else
85  pSubtract += dummy;
86  }
87  }
88 }
89 
91  const EcalRecHitCollection* endcapHitsCollection,
92  std::map<int, double>& EExtlMap,
93  int EENumberOfRegion,
94  double& pSubtract) {
95  int curr_x;
96  int curr_y;
97  for (int ii = 0; ii < m_recoWindowSidex; ++ii)
98  for (int ij = 0; ij < m_recoWindowSidey; ++ij) {
99  //Works as fillEBMap
100  curr_x = EEmax.ix() - m_recoWindowSidex / 2 + ii;
101  curr_y = EEmax.iy() - m_recoWindowSidey / 2 + ij;
102  if (EEDetId::validDetId(curr_x, curr_y, EEmax.zside())) {
103  EEDetId det = EEDetId(curr_x, curr_y, EEmax.zside(), EEDetId::XYMODE);
104  EcalRecHitCollection::const_iterator curr_recHit = endcapHitsCollection->find(det);
105  double dummy = curr_recHit->energy();
106  if (edm::isNotFinite(dummy)) {
107  dummy = 0;
108  }
110  continue;
112  continue;
113  }
114  dummy *= (*m_endcapMap)[det];
115  int ID = det.rawId();
116  if (m_xtalRegionId[ID] == EENumberOfRegion)
117  EExtlMap[m_IndexInRegion[ID]] += dummy;
118  else
119  pSubtract += dummy;
120  }
121  }
122 }
double m_maxEnergyPerCrystal
Definition: VFillMap.h:38
int m_recoWindowSidex
Definition: VFillMap.h:34
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
uint32_t ID
Definition: Definitions.h:24
static const int XYMODE
Definition: EEDetId.h:333
int ix() const
Definition: EEDetId.h:77
std::vector< EcalRecHit >::const_iterator const_iterator
std::map< int, int > m_IndexInRegion
Definition: VFillMap.h:39
void fillEBMap(EBDetId, const EcalRecHitCollection *, std::map< int, double > &, int, double &)
takes care of the Barrel
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
double m_minEnergyPerCrystal
Definition: VFillMap.h:37
void fillEEMap(EEDetId, const EcalRecHitCollection *, std::map< int, double > &, int, double &)
takes care of the Endcap
MatrixFillMap(int, int, const std::map< int, int > &, double, double, const std::map< int, int > &, EcalIntercalibConstantMap *, EcalIntercalibConstantMap *)
ctor
Definition: MatrixFillMap.cc:6
void fillMap(const std::vector< std::pair< DetId, float > > &, const DetId, const EcalRecHitCollection *, const EcalRecHitCollection *, std::map< int, double > &xtlMap, double &) override
The Map filler.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const int ETAPHIMODE
Definition: EBDetId.h:158
ii
Definition: cuy.py:589
Definition: DetId.h:17
int zside() const
Definition: EEDetId.h:71
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
iterator find(key_type k)
std::map< int, int > m_xtalRegionId
Definition: VFillMap.h:36
int m_recoWindowSidey
Definition: VFillMap.h:35
int iy() const
Definition: EEDetId.h:83
~MatrixFillMap() override
dtor