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