CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ECALRecHitAnalyzer.cc
Go to the documentation of this file.
4 
5 // author: Bobby Scurlock, University of Florida
6 // first version 11/20/2006
7 
8 #define DEBUG(X) { if (debug_) { std::cout << X << std::endl; } }
9 
11 {
12 
13  // Retrieve Information from the Configuration File
14  EBRecHitsLabel_ = iConfig.getParameter<edm::InputTag>("EBRecHitsLabel");
15  EERecHitsLabel_ = iConfig.getParameter<edm::InputTag>("EERecHitsLabel");
16  FolderName_ = iConfig.getUntrackedParameter<std::string>("FolderName");
17  debug_ = iConfig.getParameter<bool>("Debug");
18 
19 
20 }
21 
23 
24 }
25 
26 //void ECALRecHitAnalyzer::beginJob(void){
27 void ECALRecHitAnalyzer::beginRun(const edm::Run& iRun,const edm::EventSetup& iSetup){
28  CurrentEvent = -1;
29  // Book the Histograms
30  // Fill the geometry histograms
31  BookHistos();
32  FillGeometry(iSetup);
33 }
34 
36 {
37  // get ahold of back-end interface
39 
40  if (dbe_) {
41 
42  // Book Geometry Histograms
43  dbe_->setCurrentFolder(FolderName_+"/geometry");
44 
45 
46  // ECAL barrel
47  hEB_ieta_iphi_etaMap = dbe_->book2D("hEB_ieta_iphi_etaMap","", 171, -85, 86, 360, 1, 361);
48  hEB_ieta_iphi_phiMap = dbe_->book2D("hEB_ieta_iphi_phiMap","", 171, -85, 86, 360, 1, 361);
49  hEB_ieta_detaMap = dbe_->book1D("hEB_ieta_detaMap","", 171, -85, 86);
50  hEB_ieta_dphiMap = dbe_->book1D("hEB_ieta_dphiMap","", 171, -85, 86);
51  // ECAL +endcap
52  hEEpZ_ix_iy_irMap = dbe_->book2D("hEEpZ_ix_iy_irMap","", 100,1,101, 100,1,101);
53  hEEpZ_ix_iy_xMap = dbe_->book2D("hEEpZ_ix_iy_xMap","", 100,1,101, 100,1,101);
54  hEEpZ_ix_iy_yMap = dbe_->book2D("hEEpZ_ix_iy_yMap","", 100,1,101, 100,1,101);
55  hEEpZ_ix_iy_zMap = dbe_->book2D("hEEpZ_ix_iy_zMap","", 100,1,101, 100,1,101);
56  hEEpZ_ix_iy_dxMap = dbe_->book2D("hEEpZ_ix_iy_dxMap","", 100,1,101, 100,1,101);
57  hEEpZ_ix_iy_dyMap = dbe_->book2D("hEEpZ_ix_iy_dyMap","", 100,1,101, 100,1,101);
58  // ECAL -endcap
59  hEEmZ_ix_iy_irMap = dbe_->book2D("hEEmZ_ix_iy_irMap","", 100,1,101, 100,1,101);
60  hEEmZ_ix_iy_xMap = dbe_->book2D("hEEmZ_ix_iy_xMap","", 100,1,101, 100,1,101);
61  hEEmZ_ix_iy_yMap = dbe_->book2D("hEEmZ_ix_iy_yMap","", 100,1,101, 100,1,101);
62  hEEmZ_ix_iy_zMap = dbe_->book2D("hEEmZ_ix_iy_zMap","", 100,1,101, 100,1,101);
63  hEEmZ_ix_iy_dxMap = dbe_->book2D("hEEmZ_ix_iy_dxMap","", 100,1,101, 100,1,101);
64  hEEmZ_ix_iy_dyMap = dbe_->book2D("hEEmZ_ix_iy_dyMap","", 100,1,101, 100,1,101);
65 
66  // Initialize bins for geometry to -999 because z = 0 is a valid entry
67  for (int i=1; i<=100; i++)
68  for (int j=1; j<=100; j++)
69  {
76 
83  }
84 
85  for (int i=1; i<=171; i++)
86  {
89  for (int j=1; j<=360; j++)
90  {
93  }
94  }
95 
96  // Book Data Histograms
98 
99  hECAL_Nevents = dbe_->book1D("hECAL_Nevents","",1,0,1);
100 
101 
102  // Energy Histograms by logical index
103  hEEpZ_energy_ix_iy = dbe_->book2D("hEEpZ_energy_ix_iy","", 100,1,101, 100,1,101);
104  hEEmZ_energy_ix_iy = dbe_->book2D("hEEmZ_energy_ix_iy","", 100,1,101, 100,1,101);
105  hEB_energy_ieta_iphi = dbe_->book2D("hEB_energy_ieta_iphi","", 171, -85, 86, 360, 1, 361);
106 
107  hEEpZ_Minenergy_ix_iy = dbe_->book2D("hEEpZ_Minenergy_ix_iy","", 100,1,101, 100,1,101);
108  hEEmZ_Minenergy_ix_iy = dbe_->book2D("hEEmZ_Minenergy_ix_iy","", 100,1,101, 100,1,101);
109  hEB_Minenergy_ieta_iphi = dbe_->book2D("hEB_Minenergy_ieta_iphi","", 171, -85, 86, 360, 1, 361);
110 
111  hEEpZ_Maxenergy_ix_iy = dbe_->book2D("hEEpZ_Maxenergy_ix_iy","", 100,1,101, 100,1,101);
112  hEEmZ_Maxenergy_ix_iy = dbe_->book2D("hEEmZ_Maxenergy_ix_iy","", 100,1,101, 100,1,101);
113  hEB_Maxenergy_ieta_iphi = dbe_->book2D("hEB_Maxenergy_ieta_iphi","", 171, -85, 86, 360, 1, 361);
114 
115  // need to initialize those
116  for (int i=1; i<=171; i++)
117  for (int j=1; j<=360; j++)
118  {
121  }
122  for (int i=1; i<=100; i++)
123  for (int j=1; j<=100; j++)
124  {
129  }
130 
131 
132  // Occupancy Histograms by logical index
133  hEEpZ_Occ_ix_iy = dbe_->book2D("hEEpZ_Occ_ix_iy","", 100,1,101, 100,1,101);
134  hEEmZ_Occ_ix_iy = dbe_->book2D("hEEmZ_Occ_ix_iy","", 100,1,101, 100,1,101);
135  hEB_Occ_ieta_iphi = dbe_->book2D("hEB_Occ_ieta_iphi","",171, -85, 86, 360, 1, 361);
136 
137  // Integrated Histograms
138  if(finebinning_)
139  {
140  hEEpZ_energyvsir = dbe_->book2D("hEEpZ_energyvsir","", 100,1,101, 20110,-10,201);
141  hEEmZ_energyvsir = dbe_->book2D("hEEmZ_energyvsir","", 100,1,101, 20110,-10,201);
142  hEB_energyvsieta = dbe_->book2D("hEB_energyvsieta","", 171, -85, 86, 20110, -10, 201);
143 
144  hEEpZ_Maxenergyvsir = dbe_->book2D("hEEpZ_Maxenergyvsir","", 100,1,101, 20110,-10,201);
145  hEEmZ_Maxenergyvsir = dbe_->book2D("hEEmZ_Maxenergyvsir","", 100,1,101, 20110,-10,201);
146  hEB_Maxenergyvsieta = dbe_->book2D("hEB_Maxenergyvsieta","", 171, -85, 86, 20110, -10, 201);
147 
148  hEEpZ_Minenergyvsir = dbe_->book2D("hEEpZ_Minenergyvsir","", 100,1,101, 20110,-10,201);
149  hEEmZ_Minenergyvsir = dbe_->book2D("hEEmZ_Minenergyvsir","", 100,1,101, 20110,-10,201);
150  hEB_Minenergyvsieta = dbe_->book2D("hEB_Minenergyvsieta","", 171, -85, 86, 20110, -10, 201);
151 
152  hEEpZ_SETvsir = dbe_->book2D("hEEpZ_SETvsir","", 50,1,51, 20010,0,201);
153  hEEmZ_SETvsir = dbe_->book2D("hEEmZ_SETvsir","", 50,1,51, 20010,0,201);
154  hEB_SETvsieta = dbe_->book2D("hEB_SETvsieta","", 171, -85, 86, 20010, 0, 201);
155 
156  hEEpZ_METvsir = dbe_->book2D("hEEpZ_METvsir","", 50,1,51, 20010,0,201);
157  hEEmZ_METvsir = dbe_->book2D("hEEmZ_METvsir","", 50,1,51, 20010,0,201);
158  hEB_METvsieta = dbe_->book2D("hEB_METvsieta","", 171, -85, 86, 20010, 0, 201);
159 
160  hEEpZ_METPhivsir = dbe_->book2D("hEEpZ_METPhivsir","", 50,1,51, 80,-4,4);
161  hEEmZ_METPhivsir = dbe_->book2D("hEEmZ_METPhivsir","", 50,1,51, 80,-4,4);
162  hEB_METPhivsieta = dbe_->book2D("hEB_METPhivsieta","", 171, -85, 86, 80,-4,4);
163 
164  hEEpZ_MExvsir = dbe_->book2D("hEEpZ_MExvsir","", 50,1,51, 10010,-50,51);
165  hEEmZ_MExvsir = dbe_->book2D("hEEmZ_MExvsir","", 50,1,51, 10010,-50,51);
166  hEB_MExvsieta = dbe_->book2D("hEB_MExvsieta","", 171, -85, 86, 10010,-50,51);
167 
168  hEEpZ_MEyvsir = dbe_->book2D("hEEpZ_MEyvsir","", 50,1,51, 10010,-50,51);
169  hEEmZ_MEyvsir = dbe_->book2D("hEEmZ_MEyvsir","", 50,1,51, 10010,-50,51);
170  hEB_MEyvsieta = dbe_->book2D("hEB_MEyvsieta","", 171, -85, 86, 10010,-50,51);
171 
172  hEEpZ_Occvsir = dbe_->book2D("hEEpZ_Occvsir","", 50,1,51, 1000,0,1000);
173  hEEmZ_Occvsir = dbe_->book2D("hEEmZ_Occvsir","", 50,1,51, 1000,0,1000);
174  hEB_Occvsieta = dbe_->book2D("hEB_Occvsieta","", 171, -85, 86, 400,0,400);
175  }
176  else
177  {
178  hEEpZ_energyvsir = dbe_->book2D("hEEpZ_energyvsir","", 100,1,101, 510,-10,100);
179  hEEmZ_energyvsir = dbe_->book2D("hEEmZ_energyvsir","", 100,1,101, 510,-10,100);
180  hEB_energyvsieta = dbe_->book2D("hEB_energyvsieta","", 171, -85, 86, 510, -10, 100);
181 
182  hEEpZ_Maxenergyvsir = dbe_->book2D("hEEpZ_Maxenergyvsir","", 100,1,101, 510,-10,100);
183  hEEmZ_Maxenergyvsir = dbe_->book2D("hEEmZ_Maxenergyvsir","", 100,1,101, 510,-10,100);
184  hEB_Maxenergyvsieta = dbe_->book2D("hEB_Maxenergyvsieta","", 171, -85, 86, 510, -10, 100);
185 
186  hEEpZ_Minenergyvsir = dbe_->book2D("hEEpZ_Minenergyvsir","", 100,1,101, 510,-10,100);
187  hEEmZ_Minenergyvsir = dbe_->book2D("hEEmZ_Minenergyvsir","", 100,1,101, 510,-10,100);
188  hEB_Minenergyvsieta = dbe_->book2D("hEB_Minenergyvsieta","", 171, -85, 86, 510, -10, 100);
189 
190  hEEpZ_SETvsir = dbe_->book2D("hEEpZ_SETvsir","", 50,1,51, 510,0,100);
191  hEEmZ_SETvsir = dbe_->book2D("hEEmZ_SETvsir","", 50,1,51, 510,0,100);
192  hEB_SETvsieta = dbe_->book2D("hEB_SETvsieta","", 171, -85, 86, 510, 0, 100);
193 
194  hEEpZ_METvsir = dbe_->book2D("hEEpZ_METvsir","", 50,1,51, 510,0,100);
195  hEEmZ_METvsir = dbe_->book2D("hEEmZ_METvsir","", 50,1,51, 510,0,100);
196  hEB_METvsieta = dbe_->book2D("hEB_METvsieta","", 171, -85, 86, 510, 0, 100);
197 
198  hEEpZ_METPhivsir = dbe_->book2D("hEEpZ_METPhivsir","", 50,1,51, 80,-4,4);
199  hEEmZ_METPhivsir = dbe_->book2D("hEEmZ_METPhivsir","", 50,1,51, 80,-4,4);
200  hEB_METPhivsieta = dbe_->book2D("hEB_METPhivsieta","", 171, -85, 86, 80,-4,4);
201 
202  hEEpZ_MExvsir = dbe_->book2D("hEEpZ_MExvsir","", 50,1,51, 510,-50,51);
203  hEEmZ_MExvsir = dbe_->book2D("hEEmZ_MExvsir","", 50,1,51, 510,-50,51);
204  hEB_MExvsieta = dbe_->book2D("hEB_MExvsieta","", 171, -85, 86, 510,-50,51);
205 
206  hEEpZ_MEyvsir = dbe_->book2D("hEEpZ_MEyvsir","", 50,1,51, 510,-50,51);
207  hEEmZ_MEyvsir = dbe_->book2D("hEEmZ_MEyvsir","", 50,1,51, 510,-50,51);
208  hEB_MEyvsieta = dbe_->book2D("hEB_MEyvsieta","", 171, -85, 86, 510,-50,51);
209 
210  hEEpZ_Occvsir = dbe_->book2D("hEEpZ_Occvsir","", 50,1,51, 1000,0,1000);
211  hEEmZ_Occvsir = dbe_->book2D("hEEmZ_Occvsir","", 50,1,51, 1000,0,1000);
212  hEB_Occvsieta = dbe_->book2D("hEB_Occvsieta","", 171, -85, 86, 400,0,400);
213 
214  }
215 
216 
217 
218  }
219 }
220 
222 {
223  // Fill geometry histograms
224  using namespace edm;
225  //int b=0;
227  iSetup.get<CaloGeometryRecord>().get(pG);
228  const CaloGeometry cG = *pG;
229 
230  //----Fill Ecal Barrel----//
231  const CaloSubdetectorGeometry* EBgeom=cG.getSubdetectorGeometry(DetId::Ecal,1);
232  int n=0;
233  std::vector<DetId> EBids=EBgeom->getValidDetIds(DetId::Ecal, 1);
234  for (std::vector<DetId>::iterator i=EBids.begin(); i!=EBids.end(); i++) {
235  n++;
236  const CaloCellGeometry* cell=EBgeom->getGeometry(*i);
237  //GlobalPoint p = cell->getPosition();
238 
239  EBDetId EcalID(i->rawId());
240 
241  int Crystal_ieta = EcalID.ieta();
242  int Crystal_iphi = EcalID.iphi();
243  double Crystal_eta = cell->getPosition().eta();
244  double Crystal_phi = cell->getPosition().phi();
245  hEB_ieta_iphi_etaMap->setBinContent(Crystal_ieta+86, Crystal_iphi, Crystal_eta);
246  hEB_ieta_iphi_phiMap->setBinContent(Crystal_ieta+86, Crystal_iphi, (Crystal_phi*180/M_PI) );
247 
248  DEBUG( " Crystal " << n );
249  DEBUG( " ieta, iphi = " << Crystal_ieta << ", " << Crystal_iphi);
250  DEBUG( " eta, phi = " << cell->getPosition().eta() << ", " << cell->getPosition().phi());
251  DEBUG( " " );
252 
253  }
254  //----Fill Ecal Endcap----------//
255  const CaloSubdetectorGeometry* EEgeom=cG.getSubdetectorGeometry(DetId::Ecal,2);
256  n=0;
257  std::vector<DetId> EEids=EEgeom->getValidDetIds(DetId::Ecal, 2);
258  for (std::vector<DetId>::iterator i=EEids.begin(); i!=EEids.end(); i++) {
259  n++;
260  const CaloCellGeometry* cell=EEgeom->getGeometry(*i);
261  //GlobalPoint p = cell->getPosition();
262  EEDetId EcalID(i->rawId());
263  int Crystal_zside = EcalID.zside();
264  int Crystal_ix = EcalID.ix();
265  int Crystal_iy = EcalID.iy();
266  Float_t ix_ = Crystal_ix-50.5;
267  Float_t iy_ = Crystal_iy-50.5;
268  Int_t ir = (Int_t)sqrt(ix_*ix_ + iy_*iy_);
269 
270  //double Crystal_eta = cell->getPosition().eta();
271  //double Crystal_phi = cell->getPosition().phi();
272  double Crystal_x = cell->getPosition().x();
273  double Crystal_y = cell->getPosition().y();
274  double Crystal_z = cell->getPosition().z();
275  // ECAL -endcap
276  if (Crystal_zside == -1)
277  {
278  hEEmZ_ix_iy_irMap->setBinContent(Crystal_ix, Crystal_iy, ir);
279  hEEmZ_ix_iy_xMap->setBinContent(Crystal_ix, Crystal_iy, Crystal_x);
280  hEEmZ_ix_iy_yMap->setBinContent(Crystal_ix, Crystal_iy, Crystal_y);
281  hEEmZ_ix_iy_zMap->setBinContent(Crystal_ix, Crystal_iy, Crystal_z);
282  }
283  // ECAL +endcap
284  if (Crystal_zside == 1)
285  {
286  hEEpZ_ix_iy_irMap->setBinContent(Crystal_ix, Crystal_iy, ir);
287  hEEpZ_ix_iy_xMap->setBinContent(Crystal_ix, Crystal_iy, Crystal_x);
288  hEEpZ_ix_iy_yMap->setBinContent(Crystal_ix, Crystal_iy, Crystal_y);
289  hEEpZ_ix_iy_zMap->setBinContent(Crystal_ix, Crystal_iy, Crystal_z);
290  }
291 
292  DEBUG( " Crystal " << n );
293  DEBUG( " side = " << Crystal_zside );
294  DEBUG(" ix, iy = " << Crystal_ix << ", " << Crystal_iy);
295  DEBUG(" x, y = " << Crystal_x << ", " << Crystal_y);;
296  DEBUG( " " );
297 
298  }
299 
300  //-------Set the cell size for each (ieta, iphi) bin-------//
301  double currentLowEdge_eta = 0;
302  //double currentHighEdge_eta = 0;
303  for (int ieta=1; ieta<=85 ; ieta++)
304  {
305  int ieta_ = 86 + ieta;
306 
307  double eta = hEB_ieta_iphi_etaMap->getBinContent(ieta_, 1);
308  double etam1 = -999;
309 
310  if (ieta==1)
311  etam1 = hEB_ieta_iphi_etaMap->getBinContent(85, 1);
312  else
313  etam1 = hEB_ieta_iphi_etaMap->getBinContent(ieta_ - 1, 1);
314 
315  //double phi = hEB_ieta_iphi_phiMap->getBinContent(ieta_, 1);
316  double deta = fabs( eta - etam1 );
317  double dphi = fabs( hEB_ieta_iphi_phiMap->getBinContent(ieta_, 1) - hEB_ieta_iphi_phiMap->getBinContent(ieta_, 2) );
318 
319  currentLowEdge_eta += deta;
320  hEB_ieta_detaMap->setBinContent(ieta_, deta); // positive rings
321  hEB_ieta_dphiMap->setBinContent(ieta_, dphi); // positive rings
322  hEB_ieta_detaMap->setBinContent(86-ieta, deta); // negative rings
323  hEB_ieta_dphiMap->setBinContent(86-ieta, dphi); // negative rings
324  }
325 }
326 
327 
328 
330 {
331  CurrentEvent++;
332  DEBUG( "Event: " << CurrentEvent);
333  WriteECALRecHits( iEvent, iSetup );
334  hECAL_Nevents->Fill(0.5);
335 }
336 
338 {
341  iEvent.getByLabel( EBRecHitsLabel_, EBRecHits );
342  iEvent.getByLabel( EERecHitsLabel_, EERecHits );
343  DEBUG( "Got ECALRecHits");
344 
345  /*
346  edm::Handle<reco::CandidateCollection> to;
347  iEvent.getByLabel( "caloTowers", to );
348  const CandidateCollection *towers = (CandidateCollection *)to.product();
349  reco::CandidateCollection::const_iterator tower = towers->begin();
350  edm::Ref<CaloTowerCollection> towerRef = tower->get<CaloTowerRef>();
351  const CaloTowerCollection *towerCollection = towerRef.product();
352  CaloTowerCollection::const_iterator calotower = towerCollection->begin();
353  DEBUG( "Got Towers");
354  DEBUG( "tower size = " << towerCollection->size());
355  */
356 
358  iSetup.get<CaloGeometryRecord>().get(pG);
359  const CaloGeometry cG = *pG;
360  //const CaloSubdetectorGeometry* EBgeom=cG.getSubdetectorGeometry(DetId::Ecal,1);
361  //const CaloSubdetectorGeometry* EEgeom=cG.getSubdetectorGeometry(DetId::Ecal,2);
362  DEBUG( "Got Geometry");
363 
364  TLorentzVector vEBMET_EtaRing[171];
365  int EBActiveRing[171];
366  int EBNActiveCells[171];
367  double EBSET_EtaRing[171];
368  double EBMaxEnergy_EtaRing[171];
369  double EBMinEnergy_EtaRing[171];
370  double EBenergy_EtaRing[171];
371 
372  for (int i=0; i<171; i++)
373  {
374  EBActiveRing[i] = 0;
375  EBNActiveCells[i] = 0;
376  EBSET_EtaRing[i] = 0.0;
377  EBMaxEnergy_EtaRing[i] = -999;
378  EBMinEnergy_EtaRing[i] = 14E3;
379  EBenergy_EtaRing[i] = 0.0;
380  }
381 
382  edm::LogInfo("OutputInfo") << "Looping over EB" << std::endl;
383 
385  //int nEBrechit = 0;
386 
387  for (ebrechit = EBRecHits->begin(); ebrechit != EBRecHits->end(); ebrechit++) {
388 
389  EBDetId det = ebrechit->id();
390  double Energy = ebrechit->energy();
391  Int_t ieta = det.ieta();
392  Int_t iphi = det.iphi();
393  int EtaRing = 85 + ieta; // this counts from 0
394  double eta = hEB_ieta_iphi_etaMap->getBinContent(EtaRing+1,iphi);
395  double phi = hEB_ieta_iphi_phiMap->getBinContent(EtaRing+1,iphi);
396  double theta = 2*TMath::ATan(exp(-1*eta));
397  double ET = Energy*TMath::Sin(theta);
398  TLorentzVector v_;
399 
400  if (Energy>EBMaxEnergy_EtaRing[EtaRing]) EBMaxEnergy_EtaRing[EtaRing] = Energy;
401  if (Energy<EBMinEnergy_EtaRing[EtaRing]) EBMinEnergy_EtaRing[EtaRing] = Energy;
402 
403  if (Energy>0)
404  {
405  EBActiveRing[EtaRing] = 1;
406  EBNActiveCells[EtaRing]++;
407  EBSET_EtaRing[EtaRing]+=ET;
408  v_.SetPtEtaPhiE(ET, 0, phi, ET);
409  vEBMET_EtaRing[EtaRing]-=v_;
410  EBenergy_EtaRing[EtaRing]+=Energy;
411  hEB_Occ_ieta_iphi->Fill(ieta, iphi);
412 
413  }
414 
415  hEB_energy_ieta_iphi->Fill(ieta, iphi, Energy);
416  if (Energy>hEB_Maxenergy_ieta_iphi->getBinContent(EtaRing+1, iphi))
417  hEB_Maxenergy_ieta_iphi->setBinContent(EtaRing+1, iphi, Energy);
418  if (Energy<hEB_Minenergy_ieta_iphi->getBinContent(EtaRing+1, iphi))
419  hEB_Minenergy_ieta_iphi->setBinContent(EtaRing+1, iphi, Energy);
420 
421 
422  } // loop over EB
423 
424  for (int iEtaRing = 0; iEtaRing < 171; iEtaRing++)
425  {
426  hEB_Minenergyvsieta->Fill(iEtaRing-85, EBMinEnergy_EtaRing[iEtaRing]);
427  hEB_Maxenergyvsieta->Fill(iEtaRing-85, EBMaxEnergy_EtaRing[iEtaRing]);
428 
429  if (EBActiveRing[iEtaRing])
430  {
431  hEB_METvsieta->Fill(iEtaRing-85, vEBMET_EtaRing[iEtaRing].Pt());
432  hEB_METPhivsieta->Fill(iEtaRing-85, vEBMET_EtaRing[iEtaRing].Phi());
433  hEB_MExvsieta->Fill(iEtaRing-85, vEBMET_EtaRing[iEtaRing].Px());
434  hEB_MEyvsieta->Fill(iEtaRing-85, vEBMET_EtaRing[iEtaRing].Py());
435  hEB_SETvsieta->Fill(iEtaRing-85, EBSET_EtaRing[iEtaRing]);
436  hEB_Occvsieta->Fill(iEtaRing-85, EBNActiveCells[iEtaRing]);
437  hEB_energyvsieta->Fill(iEtaRing-85, EBenergy_EtaRing[iEtaRing]);
438  }
439  }
440 
441 
442  TLorentzVector vEEpZMET_EtaRing[101];
443  int EEpZActiveRing[101];
444  int EEpZNActiveCells[101];
445  double EEpZSET_EtaRing[101];
446  double EEpZMaxEnergy_EtaRing[101];
447  double EEpZMinEnergy_EtaRing[101];
448 
449  TLorentzVector vEEmZMET_EtaRing[101];
450  int EEmZActiveRing[101];
451  int EEmZNActiveCells[101];
452  double EEmZSET_EtaRing[101];
453  double EEmZMaxEnergy_EtaRing[101];
454  double EEmZMinEnergy_EtaRing[101];
455 
456  for (int i=0;i<101; i++)
457  {
458  EEpZActiveRing[i] = 0;
459  EEpZNActiveCells[i] = 0;
460  EEpZSET_EtaRing[i] = 0.0;
461  EEpZMaxEnergy_EtaRing[i] = -999;
462  EEpZMinEnergy_EtaRing[i] = 14E3;
463 
464  EEmZActiveRing[i] = 0;
465  EEmZNActiveCells[i] = 0;
466  EEmZSET_EtaRing[i] = 0.0;
467  EEmZMaxEnergy_EtaRing[i] = -999;
468  EEmZMinEnergy_EtaRing[i] = 14E3;
469  }
470 
471  edm::LogInfo("OutputInfo") << "Looping over EE" << std::endl;
473  //int nEErechit = 0;
474  for (eerechit = EERecHits->begin(); eerechit != EERecHits->end(); eerechit++) {
475 
476  EEDetId det = eerechit->id();
477  double Energy = eerechit->energy();
478  Int_t ix = det.ix();
479  Int_t iy = det.iy();
480  //Float_t ix_ = (Float_t)-999;
481  //Float_t iy_ = (Float_t)-999;
482  Int_t ir = -999;
483  // edm::LogInfo("OutputInfo") << ix << " " << iy << " " << ix_ << " " << iy_ << " " << ir << std::endl;
484 
485  double x = -999;
486  double y = -999;
487  double z = -999;
488  double theta = -999;
489  double phi = -999;
490 
491  int Crystal_zside = det.zside();
492 
493  if (Crystal_zside == -1)
494  {
495  ir = (Int_t)hEEmZ_ix_iy_irMap->getBinContent(ix,iy);
496  x = hEEmZ_ix_iy_xMap->getBinContent(ix,iy);
497  y = hEEmZ_ix_iy_yMap->getBinContent(ix,iy);
498  z = hEEmZ_ix_iy_zMap->getBinContent(ix,iy);
499  }
500  if (Crystal_zside == 1)
501  {
502  ir = (Int_t)hEEpZ_ix_iy_irMap->getBinContent(ix,iy);
503  x = hEEpZ_ix_iy_xMap->getBinContent(ix,iy);
504  y = hEEpZ_ix_iy_yMap->getBinContent(ix,iy);
505  z = hEEpZ_ix_iy_zMap->getBinContent(ix,iy);
506  }
507  TVector3 pos_vector(x,y,z);
508  phi = pos_vector.Phi();
509  theta = pos_vector.Theta();
510  double ET = Energy*TMath::Sin(theta);
511  TLorentzVector v_;
512 
513 
514  if (Crystal_zside == -1)
515  {
516  if (Energy>0)
517  {
518  EEmZActiveRing[ir] = 1;
519  EEmZNActiveCells[ir]++;
520  EEmZSET_EtaRing[ir]+=ET;
521  v_.SetPtEtaPhiE(ET,0,phi,ET);
522  vEEmZMET_EtaRing[ir]-=v_;
523  hEEmZ_Occ_ix_iy->Fill(ix, iy);
524  }
525  hEEmZ_energyvsir->Fill(ir, Energy);
526  hEEmZ_energy_ix_iy->Fill(ix, iy, Energy);
527 
528  if (Energy>EEmZMaxEnergy_EtaRing[ir]) EEmZMaxEnergy_EtaRing[ir] = Energy;
529  if (Energy<EEmZMinEnergy_EtaRing[ir]) EEmZMinEnergy_EtaRing[ir] = Energy;
530 
531  if (Energy>hEEmZ_Maxenergy_ix_iy->getBinContent(ix,iy))
532  hEEmZ_Maxenergy_ix_iy->setBinContent(ix,iy, Energy);
533  if (Energy<hEEmZ_Minenergy_ix_iy->getBinContent(ix,iy))
534  hEEmZ_Minenergy_ix_iy->setBinContent(ix,iy, Energy);
535  }
536  if (Crystal_zside == 1)
537  {
538  if (Energy>0)
539  {
540  EEpZActiveRing[ir] = 1;
541  EEpZNActiveCells[ir]++;
542  EEpZSET_EtaRing[ir]+=ET;
543  v_.SetPtEtaPhiE(ET,0,phi,ET);
544  vEEpZMET_EtaRing[ir]-=v_;
545  hEEpZ_Occ_ix_iy->Fill(ix, iy);
546  }
547  hEEpZ_energyvsir->Fill(ir, Energy);
548  hEEpZ_energy_ix_iy->Fill(ix, iy, Energy);
549 
550  if (Energy>EEpZMaxEnergy_EtaRing[ir]) EEpZMaxEnergy_EtaRing[ir] = Energy;
551  if (Energy<EEpZMinEnergy_EtaRing[ir]) EEpZMinEnergy_EtaRing[ir] = Energy;
552  if (Energy>hEEpZ_Maxenergy_ix_iy->getBinContent(ix,iy))
553  hEEpZ_Maxenergy_ix_iy->setBinContent(ix,iy, Energy);
554  if (Energy<hEEpZ_Minenergy_ix_iy->getBinContent(ix,iy))
555  hEEpZ_Minenergy_ix_iy->setBinContent(ix,iy, Energy);
556  }
557  } // loop over EE
558  edm::LogInfo("OutputInfo") << "Done Looping over EE" << std::endl;
559  for (int iEtaRing = 0; iEtaRing<101; iEtaRing++)
560  {
561  hEEpZ_Maxenergyvsir->Fill(iEtaRing, EEpZMaxEnergy_EtaRing[iEtaRing]);
562  hEEpZ_Minenergyvsir->Fill(iEtaRing, EEpZMinEnergy_EtaRing[iEtaRing]);
563  hEEmZ_Maxenergyvsir->Fill(iEtaRing, EEmZMaxEnergy_EtaRing[iEtaRing]);
564  hEEmZ_Minenergyvsir->Fill(iEtaRing, EEmZMinEnergy_EtaRing[iEtaRing]);
565 
566  if (EEpZActiveRing[iEtaRing])
567  {
568  hEEpZ_METvsir->Fill(iEtaRing, vEEpZMET_EtaRing[iEtaRing].Pt());
569  hEEpZ_METPhivsir->Fill(iEtaRing, vEEpZMET_EtaRing[iEtaRing].Phi());
570  hEEpZ_MExvsir->Fill(iEtaRing, vEEpZMET_EtaRing[iEtaRing].Px());
571  hEEpZ_MEyvsir->Fill(iEtaRing, vEEpZMET_EtaRing[iEtaRing].Py());
572  hEEpZ_SETvsir->Fill(iEtaRing, EEpZSET_EtaRing[iEtaRing]);
573  hEEpZ_Occvsir->Fill(iEtaRing, EEpZNActiveCells[iEtaRing]);
574  }
575 
576  if (EEmZActiveRing[iEtaRing])
577  {
578  hEEmZ_METvsir->Fill(iEtaRing, vEEmZMET_EtaRing[iEtaRing].Pt());
579  hEEmZ_METPhivsir->Fill(iEtaRing, vEEmZMET_EtaRing[iEtaRing].Phi());
580  hEEmZ_MExvsir->Fill(iEtaRing, vEEmZMET_EtaRing[iEtaRing].Px());
581  hEEmZ_MEyvsir->Fill(iEtaRing, vEEmZMET_EtaRing[iEtaRing].Py());
582  hEEmZ_SETvsir->Fill(iEtaRing, EEmZSET_EtaRing[iEtaRing]);
583  hEEmZ_Occvsir->Fill(iEtaRing, EEmZNActiveCells[iEtaRing]);
584  }
585  }
586  edm::LogInfo("OutputInfo") << "Done ..." << std::endl;
587 } // loop over RecHits
588 
589 
590 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
#define DEBUG(X)
MonitorElement * hEB_Maxenergyvsieta
MonitorElement * hEB_MExvsieta
MonitorElement * hEEmZ_ix_iy_dxMap
void setBinContent(int binx, double content)
set content of bin (1-D)
int ix() const
Definition: EEDetId.h:71
MonitorElement * hEEmZ_Occvsir
MonitorElement * hEEpZ_METPhivsir
MonitorElement * hEEmZ_METvsir
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
MonitorElement * hEEpZ_METvsir
MonitorElement * hEB_Maxenergy_ieta_iphi
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
MonitorElement * hEB_METvsieta
MonitorElement * hEEpZ_ix_iy_irMap
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
MonitorElement * hEB_Occvsieta
std::vector< EcalRecHit >::const_iterator const_iterator
Geom::Theta< T > theta() const
T y() const
Definition: PV3DBase.h:62
MonitorElement * hEB_energyvsieta
MonitorElement * hEEpZ_ix_iy_zMap
edm::InputTag EBRecHitsLabel_
T eta() const
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
MonitorElement * hEEpZ_Maxenergy_ix_iy
MonitorElement * hEB_METPhivsieta
double double double z
MonitorElement * hEEmZ_Minenergyvsir
void Fill(long long x)
int iphi() const
get the crystal iphi
Definition: EBDetId.h:46
int iEvent
Definition: GenABIO.cc:243
MonitorElement * hEEmZ_energy_ix_iy
MonitorElement * hEEmZ_energyvsir
MonitorElement * hEEmZ_ix_iy_dyMap
MonitorElement * hEEmZ_Occ_ix_iy
MonitorElement * hECAL_Nevents
MonitorElement * hEB_ieta_dphiMap
T sqrt(T t)
Definition: SSEVec.h:46
T z() const
Definition: PV3DBase.h:63
MonitorElement * hEEmZ_Maxenergyvsir
MonitorElement * hEEmZ_SETvsir
MonitorElement * hEB_Occ_ieta_iphi
MonitorElement * hEEpZ_Minenergyvsir
int zside() const
Definition: EEDetId.h:65
MonitorElement * hEEpZ_Minenergy_ix_iy
MonitorElement * hEB_Minenergy_ieta_iphi
int j
Definition: DBlmapReader.cc:9
MonitorElement * hEEmZ_METPhivsir
MonitorElement * hEEmZ_MEyvsir
MonitorElement * hEEpZ_energyvsir
void FillGeometry(const edm::EventSetup &)
MonitorElement * hEEpZ_ix_iy_dyMap
int iy() const
Definition: EEDetId.h:77
MonitorElement * hEB_ieta_detaMap
MonitorElement * hEEmZ_Minenergy_ix_iy
int ieta() const
get the crystal ieta
Definition: EBDetId.h:44
MonitorElement * hEB_energy_ieta_iphi
MonitorElement * hEB_MEyvsieta
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
MonitorElement * hEB_Minenergyvsieta
ECALRecHitAnalyzer(const edm::ParameterSet &)
edm::InputTag EERecHitsLabel_
MonitorElement * hEEpZ_ix_iy_yMap
MonitorElement * hEEmZ_ix_iy_zMap
#define M_PI
Definition: BFit3D.cc:3
MonitorElement * hEEmZ_Maxenergy_ix_iy
const T & get() const
Definition: EventSetup.h:55
MonitorElement * hEB_ieta_iphi_etaMap
MonitorElement * hEEpZ_SETvsir
MonitorElement * hEEpZ_Maxenergyvsir
T eta() const
Definition: PV3DBase.h:75
virtual void analyze(const edm::Event &, const edm::EventSetup &)
double getBinContent(int binx) const
get content of bin (1-D)
MonitorElement * hEEmZ_MExvsir
MonitorElement * hEEmZ_ix_iy_yMap
MonitorElement * hEEmZ_ix_iy_xMap
MonitorElement * hEEpZ_MEyvsir
void WriteECALRecHits(const edm::Event &, const edm::EventSetup &)
MonitorElement * hEB_SETvsieta
MonitorElement * hEEpZ_MExvsir
MonitorElement * hEEpZ_Occvsir
MonitorElement * hEEpZ_energy_ix_iy
MonitorElement * hEEpZ_Occ_ix_iy
#define ET
MonitorElement * hEEmZ_ix_iy_irMap
MonitorElement * hEB_ieta_iphi_phiMap
Definition: DDAxes.h:10
MonitorElement * hEEpZ_ix_iy_xMap
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:845
T x() const
Definition: PV3DBase.h:61
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33
Definition: DDAxes.h:10
MonitorElement * hEEpZ_ix_iy_dxMap