CMS 3D CMS Logo

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