CMS 3D CMS Logo

EcalFloatCondObjectContainerUtils.h
Go to the documentation of this file.
5 
6 #include "TH2F.h"
7 #include <string>
8 
9 enum {kEBChannels = 61200, kEEChannels = 14648};
10 enum {MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 85, MAX_IPHI = 360, EBhistEtaMax = 171}; // barrel lower and upper bounds on eta and phi
11 enum {IX_MIN = 1, IY_MIN = 1, IX_MAX = 100, IY_MAX = 100, EEhistXMax = 220}; // endcaps lower and upper bounds on x and y
12 
13 
14 template <class floatCondObj>
15 void fillEBMap_SingleIOV(std::shared_ptr<floatCondObj> payload, TH2F* & barrel){
16 
17  for(int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
18  uint32_t rawid = EBDetId::unhashIndex(cellid);
19  EcalCondObjectContainer<float>::const_iterator value_ptr = payload->find(rawid);
20  if (value_ptr == payload->end())
21  continue; // cell absent from payload
22 
23  float weight = (float)(*value_ptr);
24  Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
25  Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
26 
27  if(eta > 0.)
28  eta = eta - 0.5; // 0.5 to 84.5
29  else
30  eta = eta + 0.5; // -84.5 to -0.5
31 
32  barrel->Fill(phi, eta, weight);
33  }// loop over cellid
34 
35 }
36 
37 
38 template <class floatCondObj>
39 void fillEEMap_SingleIOV(std::shared_ptr<floatCondObj> payload, TH2F* & endc_m, TH2F* & endc_p){
40  // looping over the EE channels
41  for(int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
42  for(int iy = IY_MIN; iy < IY_MAX+IY_MIN; iy++)
43  for(int ix = IX_MIN; ix < IX_MAX+IX_MIN; ix++)
44  if(EEDetId::validDetId(ix, iy, iz)) {
45  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
46  uint32_t rawid = myEEId.rawId();
47  EcalCondObjectContainer<float>::const_iterator value_ptr = payload->find(rawid);
48  if (value_ptr == payload->end())
49  continue; // cell absent from payload
50 
51  float weight = (float)(*value_ptr);
52  if(iz == 1)
53  endc_p->Fill(ix, iy, weight);
54  else
55  endc_m->Fill(ix, iy, weight);
56 
57  } // validDetId
58 }
59 
60 
61 template <class floatCondObj>
62 void fillEBMap_DiffIOV(std::shared_ptr<floatCondObj> payload, TH2F* & barrel,int irun,
63  float pEB[], float & pEBmin, float & pEBmax){
64 
65  for(int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
66  uint32_t rawid = EBDetId::unhashIndex(cellid);
67  EcalCondObjectContainer<float>::const_iterator value_ptr = payload->find(rawid);
68  if (value_ptr == payload->end())
69  continue; // cell absent from payload
70 
71  float weight = (float)(*value_ptr);
72  if(irun == 0)
73  pEB[cellid] = weight;
74  else {
75  Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
76  Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
77 
78  if(eta > 0.)
79  eta = eta - 0.5; // 0.5 to 84.5
80  else
81  eta = eta + 0.5; // -84.5 to -0.5
82 
83  double diff = weight - pEB[cellid];
84 
85  if(diff < pEBmin)
86  pEBmin = diff;
87  if(diff > pEBmax)
88  pEBmax = diff;
89 
90  barrel->Fill(phi, eta, diff);
91  }
92 
93  }// loop over cellid
94 
95 
96 }
97 
98 
99 template <class floatCondObj>
100 void fillEEMap_DiffIOV(std::shared_ptr<floatCondObj> payload, TH2F* & endc_m, TH2F* & endc_p, int irun,
101  float pEE[], float & pEEmin, float & pEEmax){
102 
103  // looping over the EE channels
104  for(int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
105  for(int iy = IY_MIN; iy < IY_MAX+IY_MIN; iy++)
106  for(int ix = IX_MIN; ix < IX_MAX+IX_MIN; ix++)
107  if(EEDetId::validDetId(ix, iy, iz)) {
108  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
109  uint32_t cellid = myEEId.hashedIndex();
110  uint32_t rawid = myEEId.rawId();
111  EcalCondObjectContainer<float>::const_iterator value_ptr = payload->find(rawid);
112 
113  if (value_ptr == payload->end())
114  continue; // cell absent from payload
115  float weight = (float)(*value_ptr);
116 
117  if(irun == 0)
118  pEE[cellid] = weight;
119  else {
120  double diff = weight - pEE[cellid];
121  if(diff < pEEmin)
122  pEEmin = diff;
123 
124  if(diff > pEEmax)
125  pEEmax = diff;
126  if(iz == 1)
127  endc_p->Fill(ix, iy, diff);
128  else
129  endc_m->Fill(ix, iy, diff);
130  }
131 
132  } // validDetId
133 
134 }
135 
136 
138  const float & mean_x_EB,const float & rms_EB,const int & num_x_EB,
139  const float & mean_x_EE,const float & rms_EE,const int & num_x_EE){
140 
141  int NbRows=2;
142  align = new TH2F(title.c_str(),"EB/EE mean_x rms num_x", 4, 0, 4, NbRows, 0, NbRows);
143 
144  double row = NbRows-0.5;
145 
146  align->Fill(0.5,row,1);
147  align->Fill(1.5,row,mean_x_EB);
148  align->Fill(2.5,row,rms_EB);
149  align->Fill(3.5,row,num_x_EB);
150 
151  row--;
152 
153  align->Fill(0.5,row,2);
154  align->Fill(1.5,row,mean_x_EE);
155  align->Fill(2.5,row,rms_EE);
156  align->Fill(3.5,row,num_x_EE);
157 
158 
159  align->GetXaxis()->SetTickLength(0.);
160  align->GetXaxis()->SetLabelSize(0.);
161  align->GetYaxis()->SetTickLength(0.);
162  align->GetYaxis()->SetLabelSize(0.);
163 
164 }
void fillTableWithSummary(TH2F *&align, std::string title, const float &mean_x_EB, const float &rms_EB, const int &num_x_EB, const float &mean_x_EE, const float &rms_EE, const int &num_x_EE)
static const int XYMODE
Definition: EEDetId.h:339
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
Definition: weight.py:1
static const int MIN_HASH
Definition: EBDetId.h:156
void fillEEMap_DiffIOV(std::shared_ptr< floatCondObj > payload, TH2F *&endc_m, TH2F *&endc_p, int irun, float pEE[], float &pEEmin, float &pEEmax)
int hashedIndex() const
Definition: EEDetId.h:182
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
void fillEEMap_SingleIOV(std::shared_ptr< floatCondObj > payload, TH2F *&endc_m, TH2F *&endc_p)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:114
const_iterator find(uint32_t rawId) const
const_iterator end() const
void fillEBMap_DiffIOV(std::shared_ptr< floatCondObj > payload, TH2F *&barrel, int irun, float pEB[], float &pEBmin, float &pEBmax)
void fillEBMap_SingleIOV(std::shared_ptr< floatCondObj > payload, TH2F *&barrel)