CMS 3D CMS Logo

Analyzer_minbias.cc
Go to the documentation of this file.
1 // system include files
2 #include <map>
3 #include <memory>
4 #include <string>
5 #include <iostream>
6 #include <fstream>
7 #include <sstream>
8 #include <vector>
9 
10 // user include files
16 
42 
44 
54 
59 
60 #include "TFile.h"
61 #include "TH1.h"
62 #include "TH2.h"
63 #include "TTree.h"
64 
65 //
66 // class declaration
67 //
68 namespace cms {
69  class Analyzer_minbias : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
70  public:
71  explicit Analyzer_minbias(const edm::ParameterSet&);
72  ~Analyzer_minbias() override;
73 
74  void beginJob() override;
75  void analyze(edm::Event const&, edm::EventSetup const&) override;
76  void beginRun(edm::Run const&, edm::EventSetup const&) override;
77  void endRun(edm::Run const&, edm::EventSetup const&) override;
78  void endJob() override;
79 
80  private:
81  // ----------member data ---------------------------
85  std::ofstream* myout_hcal;
86 
87  // names of modules, producing object collections
88  TFile* hOutputFile;
89  TTree* myTree;
90  TH1F* hCalo1[73][43];
91  TH1F* hCalo2[73][43];
92  TH1F* hCalo1mom2[73][43];
93  TH1F* hCalo2mom2[73][43];
94  TH1F* hbheNoiseE;
95  TH1F* hbheSignalE;
96  TH1F* hfNoiseE;
97  TH1F* hfSignalE;
98 
101  // Root tree members
104  float phi, eta;
108 
109  // Noise subtraction
110 
111  double meannoise_pl[73][43], meannoise_min[73][43];
112  double noise_pl[73][43], noise_min[73][43];
113 
114  // counters
115 
116  double nevent;
117  double theMBFillDetMapPl0[5][5][73][43];
118  double theMBFillDetMapPl1[5][5][73][43];
119  double theMBFillDetMapPl2[5][5][73][43];
120  double theMBFillDetMapPl4[5][5][73][43];
121 
122  double theMBFillDetMapMin0[5][5][73][43];
123  double theMBFillDetMapMin1[5][5][73][43];
124  double theMBFillDetMapMin2[5][5][73][43];
125  double theMBFillDetMapMin4[5][5][73][43];
126 
127  double theNSFillDetMapPl0[5][5][73][43];
128  double theNSFillDetMapPl1[5][5][73][43];
129  double theNSFillDetMapPl2[5][5][73][43];
130  double theNSFillDetMapPl4[5][5][73][43];
131 
132  double theNSFillDetMapMin0[5][5][73][43];
133  double theNSFillDetMapMin1[5][5][73][43];
134  double theNSFillDetMapMin2[5][5][73][43];
135  double theNSFillDetMapMin4[5][5][73][43];
136 
137  double theDFFillDetMapPl0[5][5][73][43];
138  double theDFFillDetMapPl1[5][5][73][43];
139  double theDFFillDetMapPl2[5][5][73][43];
140  double theDFFillDetMapMin0[5][5][73][43];
141  double theDFFillDetMapMin1[5][5][73][43];
142  double theDFFillDetMapMin2[5][5][73][43];
143 
147 
149 
153 
154  //
157 
160  };
161 } // namespace cms
162 
163 //
164 // constructors and destructor
165 //
166 namespace cms {
168  : fOutputFileName_(iConfig.getUntrackedParameter<std::string>("HistOutFile")),
169  theRecalib_(iConfig.getParameter<bool>("Recalib")),
170  tok_hbhe_(consumes<HBHERecHitCollection>(iConfig.getParameter<edm::InputTag>("hbheInputMB"))),
171  tok_ho_(consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInputMB"))),
172  tok_hf_(consumes<HFRecHitCollection>(iConfig.getParameter<edm::InputTag>("hfInputMB"))),
173  tok_data_(consumes<FEDRawDataCollection>(edm::InputTag(iConfig.getParameter<std::string>("InputLabel")))),
174  tok_hbheNoise_(consumes<HBHERecHitCollection>(iConfig.getParameter<edm::InputTag>("hbheInputNoise"))),
175  tok_hoNoise_(consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInputNoise"))),
176  tok_hfNoise_(consumes<HFRecHitCollection>(iConfig.getParameter<edm::InputTag>("hfInputNoise"))),
177  tok_gtRec_(consumes<L1GlobalTriggerReadoutRecord>(edm::InputTag("gtDigisAlCaMB"))),
178  tok_hbheNorm_(consumes<HBHERecHitCollection>(edm::InputTag("hbhereco"))),
179  tok_respCorr_(esConsumes<HcalRespCorrs, HcalRespCorrsRcd>()),
181  usesResource(TFileService::kSharedResource);
182  // get name of output file with histogramms
183  // get names of modules, producing object collections
184  // some of the label names are hardcodded..
185  //
186  for (int i = 0; i < 73; i++) {
187  for (int j = 0; j < 43; j++) {
188  noise_min[i][j] = 0.;
189  noise_pl[i][j] = 0.;
190  }
191  }
192  }
193 
195  // do anything here that needs to be done at desctruction time
196  // (e.g. close files, deallocate resources etc.)
197  }
198 
201  edm::LogVerbatim("AnalyzerMB") << " Runnumber " << r.run() << " Nevents " << nevent_run;
202  }
203 
206  myTree = fs->make<TTree>("RecJet", "RecJet Tree");
207  myTree->Branch("mydet", &mydet, "mydet/I");
208  myTree->Branch("mysubd", &mysubd, "mysubd/I");
209  myTree->Branch("depth", &depth, "depth/I");
210  myTree->Branch("ieta", &ieta, "ieta/I");
211  myTree->Branch("iphi", &iphi, "iphi/I");
212  myTree->Branch("eta", &eta, "eta/F");
213  myTree->Branch("phi", &phi, "phi/F");
214 
215  myTree->Branch("mom0_MB", &mom0_MB, "mom0_MB/F");
216  myTree->Branch("mom1_MB", &mom1_MB, "mom1_MB/F");
217  myTree->Branch("mom2_MB", &mom2_MB, "mom2_MB/F");
218  myTree->Branch("mom4_MB", &mom4_MB, "mom4_MB/F");
219 
220  myTree->Branch("mom0_Noise", &mom0_Noise, "mom0_Noise/F");
221  myTree->Branch("mom1_Noise", &mom1_Noise, "mom1_Noise/F");
222  myTree->Branch("mom2_Noise", &mom2_Noise, "mom2_Noise/F");
223  myTree->Branch("mom4_Noise", &mom4_Noise, "mom4_Noise/F");
224 
225  myTree->Branch("mom0_Diff", &mom0_Diff, "mom0_Diff/F");
226  myTree->Branch("mom1_Diff", &mom1_Diff, "mom1_Diff/F");
227  myTree->Branch("mom2_Diff", &mom2_Diff, "mom2_Diff/F");
228 
229  myTree->Branch("occup", &occup, "occup/F");
230 
231  edm::LogVerbatim("AnalyzerMB") << " Before ordering Histos ";
232 
233  char str0[32];
234  char str1[32];
235 
236  char str10[32];
237  char str11[32];
238 
239  int k = 0;
240  nevent = 0;
241  // Size of collections
242 
244  fs->make<TH2F>("hHBHEsize_vs_run", "hHBHEsize_vs_run", 500, 111500., 112000., 6101, -100.5, 6000.5);
245  hHFsize_vs_run = fs->make<TH2F>("hHFsize_vs_run", "hHFsize_vs_run", 500, 111500., 112000., 6101, -100.5, 6000.5);
246 
247  for (int i = 1; i < 73; i++) {
248  for (int j = 1; j < 43; j++) {
249  meannoise_pl[i][j] = 0.;
250  meannoise_min[i][j] = 0.;
251 
252  k = i * 1000 + j;
253  sprintf(str0, "mpl%d", k);
254  sprintf(str1, "mmin%d", k);
255 
256  sprintf(str10, "vpl%d", k);
257  sprintf(str11, "vmin%d", k);
258  if (j < 30) {
259  // first order moment
260  hCalo1[i][j] = fs->make<TH1F>(str0, "h0", 320, -10., 10.);
261  hCalo2[i][j] = fs->make<TH1F>(str1, "h1", 320, -10., 10.);
262 
263  // second order moment
264  hCalo1mom2[i][j] = fs->make<TH1F>(str10, "h10", 320, 0., 20.);
265  hCalo2mom2[i][j] = fs->make<TH1F>(str11, "h11", 320, 0., 20.);
266  } else {
267  // HF
268  // first order moment
269  if (j < 40) {
270  hCalo1[i][j] = fs->make<TH1F>(str0, "h0", 320, -10., 10.);
271  hCalo2[i][j] = fs->make<TH1F>(str1, "h1", 320, -10., 10.);
272  //
273  // second order moment
274  hCalo1mom2[i][j] = fs->make<TH1F>(str10, "h10", 320, 0., 40.);
275  hCalo2mom2[i][j] = fs->make<TH1F>(str11, "h11", 320, 0., 40.);
276  } else {
277  hCalo1[i][j] = fs->make<TH1F>(str0, "h0", 320, -10., 10.);
278  hCalo2[i][j] = fs->make<TH1F>(str1, "h1", 320, -10., 10.);
279 
280  // second order moment
281  hCalo1mom2[i][j] = fs->make<TH1F>(str10, "h10", 320, 0., 120.);
282  hCalo2mom2[i][j] = fs->make<TH1F>(str11, "h11", 320, 0., 120.);
283  }
284  } // HE/HF boundary
285  } // j
286  } // i
287 
288  hbheNoiseE = fs->make<TH1F>("hbheNoiseE", "hbheNoiseE", 320, -10., 10.);
289  hfNoiseE = fs->make<TH1F>("hfNoiseE", "hfNoiseE", 320, -10., 10.);
290  hbheSignalE = fs->make<TH1F>("hbheSignalE", "hbheSignalE", 320, -10., 10.);
291  hfSignalE = fs->make<TH1F>("hfSignalE", "hfSignalE", 320, -10., 10.);
292 
293  edm::LogVerbatim("AnalyzerMB") << " After ordering Histos ";
294 
295  std::string ccc = "noise_0.dat";
296 
297  myout_hcal = new std::ofstream(ccc.c_str());
298  if (!myout_hcal)
299  edm::LogVerbatim("AnalyzerMB") << " Output file not open!!! ";
300 
301  //
302  for (int i = 0; i < 5; i++) {
303  for (int j = 0; j < 5; j++) {
304  for (int k = 0; k < 73; k++) {
305  for (int l = 0; l < 43; l++) {
306  theMBFillDetMapPl0[i][j][k][l] = 0.;
307  theMBFillDetMapPl1[i][j][k][l] = 0.;
308  theMBFillDetMapPl2[i][j][k][l] = 0.;
309  theMBFillDetMapPl4[i][j][k][l] = 0.;
310 
311  theMBFillDetMapMin0[i][j][k][l] = 0.;
312  theMBFillDetMapMin1[i][j][k][l] = 0.;
313  theMBFillDetMapMin2[i][j][k][l] = 0.;
314  theMBFillDetMapMin4[i][j][k][l] = 0.;
315 
316  theNSFillDetMapPl0[i][j][k][l] = 0.;
317  theNSFillDetMapPl1[i][j][k][l] = 0.;
318  theNSFillDetMapPl2[i][j][k][l] = 0.;
319  theNSFillDetMapPl4[i][j][k][l] = 0.;
320 
321  theNSFillDetMapMin0[i][j][k][l] = 0.;
322  theNSFillDetMapMin1[i][j][k][l] = 0.;
323  theNSFillDetMapMin2[i][j][k][l] = 0.;
324  theNSFillDetMapMin4[i][j][k][l] = 0.;
325 
326  theDFFillDetMapPl0[i][j][k][l] = 0.;
327  theDFFillDetMapPl1[i][j][k][l] = 0.;
328  theDFFillDetMapPl2[i][j][k][l] = 0.;
329  theDFFillDetMapMin0[i][j][k][l] = 0.;
330  theDFFillDetMapMin1[i][j][k][l] = 0.;
331  theDFFillDetMapMin2[i][j][k][l] = 0.;
332  }
333  }
334  }
335  }
336 
337  return;
338  }
339  //
340  // EndJob
341  //
343  int ii = 0;
344 
345  for (int i = 1; i < 5; i++) {
346  for (int j = 1; j < 5; j++) {
347  for (int k = 1; k < 73; k++) {
348  for (int l = 1; l < 43; l++) {
349  if (theMBFillDetMapPl0[i][j][k][l] > 0) {
361 
362  mysubd = i;
363  depth = j;
364  ieta = l;
365  iphi = k;
366  edm::LogVerbatim("AnalyzerMB") << " Result Plus= " << mysubd << " " << ieta << " " << iphi << " mom0 "
367  << mom0_MB << " mom1 " << mom1_MB << " mom2 " << mom2_MB;
368  myTree->Fill();
369  ii++;
370  } // Pl > 0
371 
372  if (theMBFillDetMapMin0[i][j][k][l] > 0) {
384 
385  mysubd = i;
386  depth = j;
387  ieta = -1 * l;
388  iphi = k;
389  edm::LogVerbatim("AnalyzerMB") << " Result Minus= " << mysubd << " " << ieta << " " << iphi << " mom0 "
390  << mom0_MB << " mom1 " << mom1_MB << " mom2 " << mom2_MB;
391  myTree->Fill();
392  ii++;
393 
394  } // Min>0
395  } // ieta
396  } // iphi
397  } // depth
398  } //subd
399 
400  edm::LogVerbatim("AnalyzerMB") << " Number of cells " << ii;
401 
402  for (int i = 1; i < 73; i++) {
403  for (int j = 1; j < 43; j++) {
404  hCalo1[i][j]->Write();
405  hCalo2[i][j]->Write();
406  hCalo1mom2[i][j]->Write();
407  hCalo2mom2[i][j]->Write();
408  }
409  }
410 
411  edm::LogVerbatim("AnalyzerMB") << " File is closed ";
412 
413  return;
414  }
415 
416  //
417  // member functions
418  //
419 
420  // ------------ method called to produce the data ------------
422  edm::LogVerbatim("AnalyzerMB") << " Start Analyzer_minbias::analyze " << nevent;
423  nevent++;
424  nevent_run++;
425 
426  float rnnum = (float)iEvent.run();
427 
428  std::vector<edm::StableProvenance const*> theProvenance;
429  iEvent.getAllStableProvenance(theProvenance);
430 
431  for (auto const& provenance : theProvenance) {
432  edm::LogVerbatim("AnalyzerMB") << " Print all process/modulelabel/product names " << provenance->processName()
433  << " , " << provenance->moduleLabel() << " , "
434  << provenance->productInstanceName();
435  }
436  const HcalRespCorrs* myRecalib = nullptr;
437  if (theRecalib_) {
438  myRecalib = &iSetup.getData(tok_respCorr_);
439  } // theRecalib_
440 
441  // Noise part for HB HE
442 
443  double tmpNSFillDetMapPl1[5][5][73][43];
444  double tmpNSFillDetMapMin1[5][5][73][43];
445 
446  for (int i = 0; i < 5; i++) {
447  for (int j = 0; j < 5; j++) {
448  for (int k = 0; k < 73; k++) {
449  for (int l = 0; l < 43; l++) {
450  tmpNSFillDetMapPl1[i][j][k][l] = 0.;
451  tmpNSFillDetMapMin1[i][j][k][l] = 0.;
452  }
453  }
454  }
455  }
456 
457  const edm::Handle<HBHERecHitCollection> hbheNormal = iEvent.getHandle(tok_hbheNorm_);
458  if (!hbheNormal.isValid()) {
459  edm::LogWarning("AnalyzerMB") << " hbheNormal failed ";
460  } else {
461  edm::LogVerbatim("AnalyzerMB") << " The size of the normal collection " << hbheNormal->size();
462  }
463 
464  const edm::Handle<HBHERecHitCollection> hbheNS = iEvent.getHandle(tok_hbheNoise_);
465 
466  if (!hbheNS.isValid()) {
467  edm::LogWarning("AnalyzerMB") << "HcalCalibAlgos: Error! can't get hbhe"
468  << " product! No HBHE MS ";
469  return;
470  }
471 
472  const HBHERecHitCollection HithbheNS = *(hbheNS.product());
473  edm::LogVerbatim("AnalyzerMB") << " HBHE NS size of collection " << HithbheNS.size();
474  hHBHEsize_vs_run->Fill(rnnum, (float)HithbheNS.size());
475 
476  if (HithbheNS.size() != 5184) {
477  edm::LogWarning("AnalyzerMB") << " HBHE problem " << rnnum << " " << HithbheNS.size();
478  }
479  const edm::Handle<HBHERecHitCollection> hbheMB = iEvent.getHandle(tok_hbhe_);
480 
481  if (!hbheMB.isValid()) {
482  edm::LogWarning("AnalyzerMB") << "HcalCalibAlgos: Error! can't get hbhe"
483  << " product! No HBHE MB";
484  }
485 
486  const HBHERecHitCollection HithbheMB = *(hbheMB.product());
487  edm::LogVerbatim("AnalyzerMB") << " HBHE MB size of collection " << HithbheMB.size();
488  if (HithbheMB.size() != 5184) {
489  edm::LogWarning("AnalyzerMB") << " HBHE problem " << rnnum << " " << HithbheMB.size();
490  }
491 
492  const edm::Handle<HFRecHitCollection> hfNS = iEvent.getHandle(tok_hfNoise_);
493 
494  if (!hfNS.isValid()) {
495  edm::LogWarning("AnalyzerMB") << "HcalCalibAlgos: Error! can't get hf"
496  << " product! No HF NS ";
497  }
498 
499  const HFRecHitCollection HithfNS = *(hfNS.product());
500  edm::LogVerbatim("AnalyzerMB") << " HFE NS size of collection " << HithfNS.size();
501  hHFsize_vs_run->Fill(rnnum, (float)HithfNS.size());
502  if (HithfNS.size() != 1728) {
503  edm::LogWarning("AnalyzerMB") << " HF problem " << rnnum << " " << HithfNS.size();
504  }
505 
506  const edm::Handle<HFRecHitCollection> hfMB = iEvent.getHandle(tok_hf_);
507 
508  if (!hfMB.isValid()) {
509  edm::LogWarning("AnalyzerMB") << "HcalCalibAlgos: Error! can't get hf"
510  << " product! No HF MB";
511  }
512 
513  const HFRecHitCollection HithfMB = *(hfMB.product());
514  edm::LogVerbatim("AnalyzerMB") << " HF MB size of collection " << HithfMB.size();
515  if (HithfMB.size() != 1728) {
516  edm::LogWarning("AnalyzerMB") << " HF problem " << rnnum << " " << HithfMB.size();
517  }
518 
519  for (HBHERecHitCollection::const_iterator hbheItr = HithbheNS.begin(); hbheItr != HithbheNS.end(); hbheItr++) {
520  // Recalibration of energy
521  float icalconst = 1.;
522  DetId mydetid = hbheItr->id().rawId();
523  if (theRecalib_)
524  icalconst = myRecalib->getValues(mydetid)->getValue();
525 
526  HBHERecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time());
527 
528  double energyhit = aHit.energy();
529 
530  DetId id = (*hbheItr).detid();
531  HcalDetId hid = HcalDetId(id);
532 
533  int mysu = ((hid).rawId() >> 25) & 0x7;
534  if (hid.ieta() > 0) {
535  theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
536  theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] + 1.;
537  theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
538  theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + energyhit;
539  theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
540  theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(energyhit, 2);
541  theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
542  theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(energyhit, 4);
543 
544  tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit;
545 
546  } else {
547  theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
548  theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + 1.;
549  theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
550  theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + energyhit;
551  theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
552  theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 2);
553  theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
554  theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 4);
555 
556  tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit;
557  }
558 
559  if (hid.depth() == 1) {
560  hbheNoiseE->Fill(energyhit);
561 
562  if (energyhit < -2.)
563  edm::LogVerbatim("AnalyzerMB") << " Run " << rnnum << " ieta,iphi " << hid.ieta() << " " << hid.iphi()
564  << energyhit;
565 
566  } // depth=1
567 
568  } // HBHE_NS
569 
570  // Signal part for HB HE
571 
572  for (HBHERecHitCollection::const_iterator hbheItr = HithbheMB.begin(); hbheItr != HithbheMB.end(); hbheItr++) {
573  // Recalibration of energy
574  float icalconst = 1.;
575  DetId mydetid = hbheItr->id().rawId();
576  if (theRecalib_)
577  icalconst = myRecalib->getValues(mydetid)->getValue();
578 
579  HBHERecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time());
580 
581  double energyhit = aHit.energy();
582 
583  DetId id = (*hbheItr).detid();
584  HcalDetId hid = HcalDetId(id);
585 
586  int mysu = ((hid).rawId() >> 25) & 0x7;
587  if (hid.ieta() > 0) {
588  theMBFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] += 1.;
589  theMBFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] += energyhit;
590  theMBFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] += pow(energyhit, 2);
591  theMBFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] += pow(energyhit, 4);
592  float mydiff = energyhit - tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()];
593 
594  theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
595  theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + mydiff;
596  theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
597  theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(mydiff, 2);
598  } else {
599  theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
600  theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + 1.;
601  theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
602  theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + energyhit;
603  theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
604  theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 2);
605  theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
606  theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 4);
607 
608  float mydiff = energyhit - tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()];
609  theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
610  theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + mydiff;
611  theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
612  theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(mydiff, 2);
613  }
614 
615  if (hid.depth() == 1) {
616  hbheSignalE->Fill(energyhit);
617 
618  if (hid.ieta() > 0) {
619  hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit);
620  hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit, 2));
621  } else {
622  hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit);
623  hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit, 2));
624  } // eta><0
625 
626  } // depth=1
627 
628  } // HBHE_MB
629 
630  // HF
631 
632  for (HFRecHitCollection::const_iterator hbheItr = HithfNS.begin(); hbheItr != HithfNS.end(); hbheItr++) {
633  // Recalibration of energy
634  float icalconst = 1.;
635  DetId mydetid = hbheItr->id().rawId();
636  if (theRecalib_)
637  icalconst = myRecalib->getValues(mydetid)->getValue();
638 
639  HFRecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time());
640 
641  double energyhit = aHit.energy();
642  //
643  // Remove PMT hits
644  //
645  DetId id = (*hbheItr).detid();
646  HcalDetId hid = HcalDetId(id);
647 
648  if (fabs(energyhit) > 40.)
649  continue;
650 
651  int mysu = hid.subdetId();
652  if (hid.ieta() > 0) {
653  theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
654  theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] + 1.;
655  theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
656  theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + energyhit;
657  theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
658  theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(energyhit, 2);
659  theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
660  theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(energyhit, 4);
661 
662  tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit;
663 
664  } else {
665  theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
666  theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + 1.;
667  theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
668  theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + energyhit;
669  theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
670  theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 2);
671  theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
672  theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 4);
673 
674  tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit;
675  }
676 
677  if (hid.depth() == 1) {
678  hfNoiseE->Fill(energyhit);
679 
680  } // depth=1
681 
682  } // HBHE_NS
683 
684  // Signal part for HB HE
685 
686  for (HFRecHitCollection::const_iterator hbheItr = HithfMB.begin(); hbheItr != HithfMB.end(); hbheItr++) {
687  // Recalibration of energy
688  float icalconst = 1.;
689  DetId mydetid = hbheItr->id().rawId();
690  if (theRecalib_)
691  icalconst = myRecalib->getValues(mydetid)->getValue();
692 
693  HFRecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time());
694 
695  double energyhit = aHit.energy();
696  //
697  // Remove PMT hits
698  //
699  if (fabs(energyhit) > 40.)
700  continue;
701 
702  DetId id = (*hbheItr).detid();
703  HcalDetId hid = HcalDetId(id);
704 
705  int mysu = ((hid).rawId() >> 25) & 0x7;
706  if (hid.ieta() > 0) {
707  theMBFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
708  theMBFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] + 1.;
709  theMBFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
710  theMBFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + energyhit;
711  theMBFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
712  theMBFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(energyhit, 2);
713  theMBFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
714  theMBFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(energyhit, 4);
715 
716  theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
717  theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + energyhit -
718  tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()];
719  theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
720  theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] +
721  pow((energyhit - tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]), 2);
722  } else {
723  theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
724  theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + 1.;
725  theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
726  theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + energyhit;
727  theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
728  theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 2);
729  theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] =
730  theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 4);
731 
732  theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
733  theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + energyhit -
734  tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()];
735  theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
736  theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] +
737  pow((energyhit - tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()]), 2);
738  }
739 
740  if (hid.depth() == 1) {
741  hfSignalE->Fill(energyhit);
742 
743  if (hid.ieta() > 0) {
744  hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit);
745  hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit, 2));
746  } else {
747  hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit);
748  hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit, 2));
749  } // eta><0
750 
751  } // depth=1
752 
753  } // HF_MB
754 
755  edm::LogVerbatim("AnalyzerMB") << " Event is finished ";
756  }
757 } // namespace cms
758 
760 
762 
static const std::string kSharedResource
Definition: TFileService.h:76
double theMBFillDetMapMin0[5][5][73][43]
double theMBFillDetMapMin2[5][5][73][43]
Log< level::Info, true > LogVerbatim
double theDFFillDetMapPl2[5][5][73][43]
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const edm::EDGetTokenT< HFRecHitCollection > tok_hfNoise_
double theMBFillDetMapMin1[5][5][73][43]
const edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd > tok_l1gt_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::EDGetTokenT< HBHERecHitCollection > tok_hbheNorm_
double theNSFillDetMapPl4[5][5][73][43]
void analyze(edm::Event const &, edm::EventSetup const &) override
double theNSFillDetMapPl0[5][5][73][43]
double theNSFillDetMapMin0[5][5][73][43]
double theMBFillDetMapPl0[5][5][73][43]
size_type size() const
TH1F * hCalo2mom2[73][43]
const edm::EDGetTokenT< HBHERecHitCollection > tok_hbheNoise_
T const * product() const
Definition: Handle.h:70
std::vector< T >::const_iterator const_iterator
double theDFFillDetMapPl1[5][5][73][43]
std::ofstream * myout_hcal
const edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > tok_gtRec_
double meannoise_pl[73][43]
double theNSFillDetMapPl2[5][5][73][43]
double theDFFillDetMapMin2[5][5][73][43]
TH1F * hCalo1mom2[73][43]
const edm::EDGetTokenT< HFRecHitCollection > tok_hf_
const Item * getValues(DetId fId, bool throwOnFail=true) const
constexpr float energy() const
Definition: CaloRecHit.h:29
double theNSFillDetMapPl1[5][5][73][43]
const edm::EDGetTokenT< HORecHitCollection > tok_ho_
double theMBFillDetMapPl1[5][5][73][43]
Analyzer_minbias(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
void beginRun(edm::Run const &, edm::EventSetup const &) override
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
const edm::EDGetTokenT< FEDRawDataCollection > tok_data_
double theDFFillDetMapPl0[5][5][73][43]
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const edm::ESGetToken< HcalRespCorrs, HcalRespCorrsRcd > tok_respCorr_
double theMBFillDetMapPl4[5][5][73][43]
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
double theNSFillDetMapMin1[5][5][73][43]
double theNSFillDetMapMin4[5][5][73][43]
const_iterator begin() const
double theDFFillDetMapMin0[5][5][73][43]
void endRun(edm::Run const &, edm::EventSetup const &) override
double theMBFillDetMapPl2[5][5][73][43]
ii
Definition: cuy.py:589
Namespace of DDCMS conversion namespace.
const_iterator end() const
void beginJob() override
Definition: DetId.h:17
float getValue() const
Definition: HcalRespCorr.h:19
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
double theMBFillDetMapMin4[5][5][73][43]
bool isValid() const
Definition: HandleBase.h:70
double meannoise_min[73][43]
HLT enums.
Log< level::Warning, false > LogWarning
double theNSFillDetMapMin2[5][5][73][43]
double theDFFillDetMapMin1[5][5][73][43]
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
const edm::EDGetTokenT< HORecHitCollection > tok_hoNoise_
Definition: Run.h:45
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164