test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalCaloTowerMonitor.cc
Go to the documentation of this file.
3 
5 
7 
9 {
11 
12  baseFolder_ = rootFolder_+"CaloTowerMonitor";
13  etaMax_ = ps.getUntrackedParameter<double>("MaxEta", 41.5);
14  etaMin_ = ps.getUntrackedParameter<double>("MinEta", -41.5);
15  etaBins_ = (int)(etaMax_ - etaMin_);
16  std::cout << "CaloTower Monitor eta min/max set to " << etaMin_ << "/" << etaMax_ << std::endl;
17 
18  phiMax_ = ps.getUntrackedParameter<double>("MaxPhi", 73);
19  phiMin_ = ps.getUntrackedParameter<double>("MinPhi", 0);
20  phiBins_ = (int)(phiMax_ - phiMin_);
21  std::cout << "CaloTower Monitor phi min/max set to " << phiMin_ << "/" << phiMax_ << std::endl;
22 
23  ievt_=0;
24  // book histograms
26  meEVT_ = ib.bookInt("CaloTower Event Number");
27  meEVT_->Fill(ievt_);
28 
29  // Calo Tower occupancy
30  caloTowerOccMap=ib.book2D("CaloTowerOccupancyMap", "Calo Tower Occupancy Map",
32  phiBins_,phiMin_,phiMax_);
33  // Calo Tower energy
34  caloTowerEnergyMap=ib.book2D("CaloTowerEnergyMap", "Calo Tower Energy Map",
36  phiBins_,phiMin_,phiMax_);
37 
38  caloTowerTime = ib.book1D("CaloTowerTime", "Calo Tower Time",
39  10,0,10);
40  caloTowerEnergy = ib.book1D("CalotowerEnergy", "Calo Tower Energy",
41  100,0,100);
42  caloTowerMeanEnergyEta = ib.bookProfile("CaloTowerMeanEnergyEta","Calo tower Mean Energy vs. Eta",
43  etaBins_,etaMin_,etaMax_,100,0,100);
44 
45  // Make plots of HCAL contributions to tower
46  ib.setCurrentFolder(baseFolder_+"/"+"HCAL");
47  hcalOccMap=ib.book2D("HcalOccupancyMap", "Calo Tower Occupancy Map",
49  phiBins_,phiMin_,phiMax_);
50  // Calo Tower energy
51  hcalEnergyMap=ib.book2D("HcalEnergyMap", "Calo Tower Energy Map",
53  phiBins_,phiMin_,phiMax_);
54 
55  hcalTime = ib.book1D("HcalTime", "Calo Tower Time",
56  10,0,10);
57  hcalEnergy = ib.book1D("HcalEnergy", "Calo Tower Energy",
58  100,0,100);
59  hcalMeanEnergyEta = ib.bookProfile("HcalMeanEnergyEta",
60  "Calo tower Mean Energy vs. Eta",
62  100,0,100);
63 
64 
65  ib.setCurrentFolder(baseFolder_+"/"+"ECAL");
66  ecalOccMap=ib.book2D("EcalOccupancyMap", "Calo Tower Occupancy Map",
68  phiBins_,phiMin_,phiMax_);
69  // Calo Tower energy
70  ecalEnergyMap=ib.book2D("EcalEnergyMap", "Calo Tower Energy Map",
72  phiBins_,phiMin_,phiMax_);
73 
74  ecalTime = ib.book1D("EcalTime", "Calo Tower Time",
75  10,0,10);
76  ecalEnergy = ib.book1D("EcalEnergy", "Calo Tower Energy",
77  100,0,100);
78  ecalMeanEnergyEta = ib.bookProfile("EcalMeanEnergyEta",
79  "Calo tower Mean Energy vs. Eta",
81  100,0,100);
82 
83  // Comparison Plots
84  ib.setCurrentFolder(baseFolder_+"/"+"ComparisonPlots");
85  time_HcalvsEcal=ib.book2D("HcalvsEcalTime",
86  "Hcal Time vs. Ecal time",
87  10,0,10,10,0,10);
88  time_CaloTowervsEcal=ib.book2D("CaloTowervsEcalTime",
89  "Calotower Time vs. Ecal time",
90  10,0,10,10,0,10);
91  time_CaloTowervsHcal=ib.book2D("CaloTowervsHcalTime",
92  "CaloTower Time vs. Hcal time",
93  10,0,10,10,0,10);
94  energy_HcalvsEcal=ib.book2D("HcalvsEcalEnergy",
95  "Hcal Energy vs. Ecal energy",
96  100,0,100,100,0,100);
97  energy_CaloTowervsEcal=ib.book2D("CaloTowervsEcalEnergy",
98  "Calotower Energy vs. Ecal energy",
99  100,0,100,100,0,100);
100  energy_CaloTowervsHcal=ib.book2D("CaloTowervsHcalEnergy",
101  "CaloTower Energy vs. Hcal energy",
102  100,0,100,100,0,100);
103 
104 } //void HcalCaloTowerMonitor::setup(...)
105 
106 
108 {
109  // fill histograms for each event
110 
111  if (fVerbosity) std::cout <<"Processing calotower"<<std::endl;
112 
113 
114  // Store values of hcal, energy for forming averages at each eta
115  float hcalenergy[90]={0.};
116  float ecalenergy[90]={0.};
117  int etacounts[90]={0};
118 
119  for (CaloTowerCollection::const_iterator it=calotower.begin();
120  it!=calotower.end();++it)
121  {
122  //caloTowers give eta and phi; need to map to ieta,iphi
123  // phi is mapped into 72 equally spaced segments (2pi/72=.087 radians each), starting at iphi=1
124  // at ieta=21 (eta=1.74), iphi spaced in 10 degree increments
125  // at ieta=40 (eta=4.716), iphi spaced in 20 degree increments
126  // However, segmentation values are similar
127  // (iphi=1,2,3,4,5 for 5 degree segments,
128  // iphi 1,3,5,... for 10 degree segments, and iphi=3,7,... for 20 deg.)
129  int iphi;
130  double eta=it->eta();
131  double phi=it->phi();
132  // if phi<0; shift it by 2pi (so that phi runs from 0->2pi, rather than -pi->pi)
133  if (phi<0)
134  phi+=2*3.14159265359;
135  iphi = int(phi/.087)+1;
136  if (fabs(eta)>1.74)
137  {
138  if (fabs(eta)<=4.716)
139  iphi=(iphi-1)/2*2+1;
140  else
141  iphi=(iphi-1)/4*4+3;
142 
143  }
144  //ieta is more complicated -- it runs in segments of .087 for the first 20 segments, then the segmentation becomes non-uniform
145  int ieta=getIeta(eta);
146 
147  // Add 42 to the indices. Only index[1...] will have values within [HB...HF]. Index[0] and [84] store values outside the expected calorimeter range.
148  hcalenergy[ieta+42]+=it->hadEnergy();
149  ecalenergy[ieta+42]+=it->emEnergy();
150  etacounts[ieta+42]++;
151 
152  /*
153  std::cout <<"CALOTOWER eta = \t"<<eta<<"\tphi = "<<it->phi()<<std::endl;
154  std::cout <<"\t ieta = \t"<<ieta<<"\tiphi = "<<iphi<<std::endl;
155  */
156 
157  // Fill histograms
158 
159  // calotowers
160  caloTowerOccMap->Fill(ieta,iphi);
161  caloTowerEnergyMap->Fill(ieta,iphi,it->energy());
162  caloTowerTime->Fill((it->ecalTime()+it->hcalTime())/2.);
163  caloTowerEnergy->Fill(it->energy());
164  //std::cout <<"calotower times: "<<it->ecalTime()<<" "<<it->hcalTime()<<std::endlx;
165 
166  //hcal
167  hcalOccMap->Fill(ieta,iphi);
168  hcalEnergyMap->Fill(ieta,iphi,it->hadEnergy());
169  hcalTime->Fill(it->hcalTime());
170  hcalEnergy->Fill(it->hadEnergy());
171 
172  //ecal
173  ecalOccMap->Fill(ieta,iphi);
174  ecalEnergyMap->Fill(ieta,iphi,it->emEnergy());
175  ecalTime->Fill(it->ecalTime());
176  ecalEnergy->Fill(it->emEnergy());
177 
178  time_HcalvsEcal->Fill(it->ecalTime(),it->hcalTime());
179  energy_HcalvsEcal->Fill(it->emEnergy(),it->hadEnergy());
180  } // for CaloTowerCollection::const_iterator it...
181 
182  // Now form average for each eta bin;
183  for (int i=0;i<90;++i)
184  {
185  if (etacounts[i]==0) continue;
186  caloTowerMeanEnergyEta->Fill(i-42, 1.*(hcalenergy[i]+ecalenergy[i])/etacounts[i]);
187  hcalMeanEnergyEta->Fill(i-42, 1.*hcalenergy[i]/etacounts[i]);
188  ecalMeanEnergyEta->Fill(i-42,1.*ecalenergy[i]/etacounts[i]);
189  }
190 }
191 
193 {
194  // return Ieta index given physical eta value
195 
196  double myeta=fabs(eta);
197  int neg=int(eta/myeta); // eta can be negative or positive
198 
199  if (myeta<=1.740) // first 20 bins are spaced evenly in increments of .087 radians, starting at ieta=1
200  return (1+int(myeta/.087))*neg;
201 
202  if (fabs(eta)<=1.83)
203  return int(21*neg);
204  if (fabs(eta)<=1.93)
205  return int(22*neg);
206  if (fabs(eta)<=2.043)
207  return int(23*neg);
208  if (fabs(eta)<=2.172)
209  return int(24*neg);
210  if (fabs(eta)<=2.322)
211  return int(25*neg);
212 
213  if (fabs(eta)<=2.5)
214  return int(26*neg);
215  if (fabs(eta)<=2.65)
216  return int(27*neg);
217 
218  // 28 and 29 aren't quite right -- eta values depend on depth
219  if (fabs(eta)<=2.853)
220  return int(28*neg);
221  if (fabs(eta)<=2.964)
222  return int(29*neg);
223  if (fabs(eta)<=3.139)
224  return int(30*neg);
225 
226  if (fabs(eta)<=3.314)
227  return int(31*neg);
228  if (fabs(eta)<=3.489)
229  return int(32*neg);
230  if (fabs(eta)<=3.664)
231  return int(33*neg);
232  if (fabs(eta)<=3.839)
233  return int(34*neg);
234  if (fabs(eta)<=4.013)
235  return int(35*neg);
236 
237  if (fabs(eta)<=4.191)
238  return int(36*neg);
239  if (fabs(eta)<=4.363)
240  return int(37*neg);
241  if (fabs(eta)<=4.538)
242  return int(38*neg);
243  if (fabs(eta)<=4.716)
244  return int(39*neg);
245  if (fabs(eta)<=4.889)
246  return int(40*neg);
247  if (fabs(eta)<=5.191)
248  return int(41*neg);
249 
250  // Anything with large eta is outside calorimeter; skip it?
251  // Are there ZDC-based calotowers?
252  return 42;
253 
254 } // int HcalCaloTowerMonitor::getIeta(double eta)
255 
256 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * time_CaloTowervsHcal
int ib
Definition: cuy.py:660
MonitorElement * hcalEnergy
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
void setup(const edm::ParameterSet &ps, DQMStore::IBooker &ib)
MonitorElement * hcalEnergyMap
virtual void setup(const edm::ParameterSet &ps, DQMStore::IBooker &ib)
MonitorElement * energy_CaloTowervsHcal
MonitorElement * bookInt(Args &&...args)
Definition: DQMStore.h:103
std::vector< CaloTower >::const_iterator const_iterator
MonitorElement * caloTowerTime
MonitorElement * ecalOccMap
MonitorElement * hcalMeanEnergyEta
MonitorElement * caloTowerEnergy
MonitorElement * caloTowerOccMap
void Fill(long long x)
MonitorElement * caloTowerEnergyMap
MonitorElement * time_HcalvsEcal
std::string rootFolder_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
std::string baseFolder_
const_iterator end() const
MonitorElement * energy_HcalvsEcal
MonitorElement * energy_CaloTowervsEcal
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
MonitorElement * ecalEnergy
MonitorElement * caloTowerMeanEnergyEta
MonitorElement * time_CaloTowervsEcal
MonitorElement * hcalTime
tuple cout
Definition: gather_cfg.py:121
MonitorElement * ecalMeanEnergyEta
MonitorElement * ecalEnergyMap
MonitorElement * ecalTime
const_iterator begin() const
MonitorElement * hcalOccMap