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