CMS 3D CMS Logo

HOCalibAnalyzer.cc
Go to the documentation of this file.
1 //April 2015 : Removal of itrg1, itrg2, but addition of isect2, same is true in HOCalibVariables.h
2 // -*- C++ -*-
3 //
4 // Package: HOCalibAnalyzer
5 // Class: HOCalibAnalyzer
6 //
19 //
20 // Original Author: Gobinda Majumder
21 // Created: Sat Jul 7 09:51:31 CEST 2007
22 //
23 //
24 
25 // system include files
26 #include <memory>
27 
28 // user include files
31 
37 
44 
45 #include "TFile.h"
46 #include "TH1F.h"
47 #include "TH2F.h"
48 #include "TTree.h"
49 #include "TProfile.h"
50 
51 #include <iostream>
52 #include <fstream>
53 #include <iomanip>
54 #include <string>
55 #include <vector>
56 
57 //
58 // class decleration
59 //
60 
61 class HOCalibAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
62 public:
63  explicit HOCalibAnalyzer(const edm::ParameterSet&);
64  ~HOCalibAnalyzer() override;
65 
66  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
67 
68 private:
69  void beginJob() override {}
70  void analyze(const edm::Event&, const edm::EventSetup&) override;
71  void endJob() override {}
72 
73  static constexpr int netamx = 30;
74  static constexpr int nphimx = 72;
75  static constexpr int ringmx = 5;
76  static constexpr int ncut = 14;
77 
78  const char* varcrit[3] = {"All", "steps", "n-1"}; // or opposite
79 
80  const double elosfact = (14.9 + 0.96 * std::fabs(std::log(8 * 2.8)) + 0.033 * 8 * (1.0 - std::pow(8, -0.33)));
81 
82  int getHOieta(int ij) { return (ij < netamx / 2) ? -netamx / 2 + ij : -netamx / 2 + ij + 1; }
83  int invert_HOieta(int ieta) { return (ieta < 0) ? netamx / 2 + ieta : netamx / 2 + ieta - 1; }
84 
85  int mypow_2[31];
86 
87  const bool m_cosmic;
88  const bool m_zeroField;
89  const int m_bins;
90  const double m_low;
91  const double m_ahigh;
92  const bool m_histFill; //Stored signals of individual HO towers with default selection criteria
93  const bool m_treeFill; //Store rootuple without almost any selection criteria except a quality on muon
94  const bool m_verbose;
95 
96  int ipass;
97 
98  TTree* T1;
99 
101 
102  TH1F* muonnm;
103  TH1F* muonmm;
104  TH1F* muonth;
105  TH1F* muonph;
106  TH1F* muonch;
107 
108  TH1F* sel_muonnm;
109  TH1F* sel_muonmm;
110  TH1F* sel_muonth;
111  TH1F* sel_muonph;
112  TH1F* sel_muonch;
113 
114  TH2F* sig_eta_evt[3 * netamx][ncut]; //For individual eta
115  TH2F* sigvsevt[3 * netamx][ncut];
116  TH1F* variab[3 * netamx][ncut];
117 
118  TH2F* mu_projection[ncut + 1];
119 
120  unsigned ievt, hoflag;
122 
124  hosig[9], hocorsig[18], hocro, hbhesig[9], caloen[3];
126  float tmphoang;
127 
128  int nevents[10];
129 
130  float ncount[ringmx][ncut + 10];
131 
135  // ----------member data ---------------------------
136 };
137 
138 //
139 // constants, enums and typedefs
140 //
141 
142 //
143 // static data member definitions
144 //
145 
146 //
147 // constructors and destructor
148 //
149 
151  : m_cosmic(iConfig.getUntrackedParameter<bool>("cosmic", true)),
152  m_zeroField(iConfig.getUntrackedParameter<bool>("zeroField", false)),
153  m_bins(iConfig.getUntrackedParameter<int>("HOSignalBins", 120)),
154  m_low(iConfig.getUntrackedParameter<double>("lowerRange", -1.0)),
155  m_ahigh(iConfig.getUntrackedParameter<double>("upperRange", 29.0)),
156  m_histFill(iConfig.getUntrackedParameter<bool>("histFill", true)),
157  m_treeFill(iConfig.getUntrackedParameter<bool>("treeFill", false)),
158  m_verbose(iConfig.getUntrackedParameter<bool>("verbose", false)),
159  tok_ho_(consumes<HOCalibVariableCollection>(iConfig.getParameter<edm::InputTag>("hoCalibVariableCollectionTag"))),
160  tok_allho_(consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInputTag"))) {
161  // It is very likely you want the following in your configuration
162  // hoCalibVariableCollectionTag = cms.InputTag('hoCalibProducer', 'HOCalibVariableCollection')
163 
164  usesResource(TFileService::kSharedResource);
165 
166  //now do what ever initialization is needed
167  ipass = 0;
168  for (int ij = 0; ij < 10; ij++) {
169  nevents[ij] = 0;
170  }
171 
173 
174  T1 = fs->make<TTree>("T1", "HOSignal");
175 
176  T1->Branch("irun", &irun, "irun/I");
177  T1->Branch("ievt", &ievt, "ievt/i");
178 
179  T1->Branch("isect", &isect, "isect/I");
180  T1->Branch("isect2", &isect2, "isect2/I");
181  T1->Branch("ndof", &ndof, "ndof/I");
182  T1->Branch("nmuon", &nmuon, "nmuon/I");
183 
184  T1->Branch("ilumi", &ilumi, "ilumi/I");
185  if (!m_cosmic) {
186  T1->Branch("pileup", &pileup, "pileup/F");
187  T1->Branch("nprim", &nprim, "nprim/I");
188  T1->Branch("tkpt03", &tkpt03, " tkpt03/F");
189  T1->Branch("ecal03", &ecal03, " ecal03/F");
190  T1->Branch("hcal03", &hcal03, " hcal03/F");
191  }
192 
193  T1->Branch("trkdr", &trkdr, "trkdr/F");
194  T1->Branch("trkdz", &trkdz, "trkdz/F");
195 
196  T1->Branch("trkvx", &trkvx, "trkvx/F");
197  T1->Branch("trkvy", &trkvy, "trkvy/F");
198  T1->Branch("trkvz", &trkvz, "trkvz/F");
199  T1->Branch("trkmm", &trkmm, "trkmm/F");
200  T1->Branch("trkth", &trkth, "trkth/F");
201  T1->Branch("trkph", &trkph, "trkph/F");
202 
203  T1->Branch("chisq", &chisq, "chisq/F");
204  T1->Branch("therr", &therr, "therr/F");
205  T1->Branch("pherr", &pherr, "pherr/F");
206  T1->Branch("hodx", &hodx, "hodx/F");
207  T1->Branch("hody", &hody, "hody/F");
208  T1->Branch("hoang", &hoang, "hoang/F");
209 
210  T1->Branch("momatho", &momatho, "momatho/F");
211  T1->Branch("hoflag", &hoflag, "hoflag/i");
212  T1->Branch("htime", &htime, "htime/F");
213  T1->Branch("hosig", hosig, "hosig[9]/F");
214  T1->Branch("hocro", &hocro, "hocro/F");
215  T1->Branch("hocorsig", hocorsig, "hocorsig[18]/F");
216  T1->Branch("caloen", caloen, "caloen[3]/F");
217 
218  char name[200];
219  char title[200];
220 
221  if (m_histFill) {
222  for (int ij = 0; ij < netamx; ij++) {
223  int ieta = getHOieta(ij);
224  for (int jk = 0; jk < nphimx; jk++) {
225  sprintf(name, "ho_indenergy_%i_%i", ij, jk);
226  sprintf(title, "ho IndEnergy (GeV) i#eta=%i i#phi=%i", ieta, jk + 1);
227  ho_indenergy[ij][jk] = fs->make<TH1F>(name, title, 1200, m_low, m_ahigh);
228  }
229  }
230  }
231 
232  muonnm = fs->make<TH1F>("muonnm", "No of muon", 10, -0.5, 9.5);
233  muonmm = fs->make<TH1F>("muonmm", "P_{mu}", 200, -100., 100.);
234  muonth = fs->make<TH1F>("muonth", "{Theta}_{mu}", 180, 0., 180.);
235  muonph = fs->make<TH1F>("muonph", "{Phi}_{mu}", 180, -180., 180.);
236  muonch = fs->make<TH1F>("muonch", "{chi^2}/ndf", 100, 0., 1000.);
237 
238  sel_muonnm = fs->make<TH1F>("sel_muonnm", "No of muon(sel)", 10, -0.5, 9.5);
239  sel_muonmm = fs->make<TH1F>("sel_muonmm", "P_{mu}(sel)", 200, -100., 100.);
240  sel_muonth = fs->make<TH1F>("sel_muonth", "{Theta}_{mu}(sel)", 180, 0., 180.);
241  sel_muonph = fs->make<TH1F>("sel_muonph", "{Phi}_{mu}(sel)", 180, -180., 180.);
242  sel_muonch = fs->make<TH1F>("sel_muonch", "{chi^2}/ndf(sel)", 100, 0., 1000.);
243 
244  //if change order, change in iselect_wotime also and other efficiency numbers
245  const char* varnam[ncut] = {"ndof",
246  "chisq",
247  "th",
248  "ph",
249  "therr",
250  "pherr",
251  "dircos",
252  "trkmm",
253  "nmuon",
254  "calo",
255  "trkiso",
256  "#phi-dir",
257  "#eta-dir",
258  "time"};
259  int nbinxx[ncut] = {25, 60, 60, 60, 60, 60, 60, 120, 6, 60, 60, 120, 120, 60};
260  double alowxx[ncut] = {5.5, 0., 0., -angle_units::piRadians, 0.0, 0.0, 0.0, 0., 0.5, 0.0, 0.0, -20., -32., -45.0};
261  double ahghxx[ncut] = {
262  30.5, 40., angle_units::piRadians, angle_units::piRadians, 0.8, 0.02, 0.5, 300., 6.5, 10.0, 24.0, 20.0, 32.0, 45.0};
263 
264  for (int kl = 0; kl < ncut; kl++) {
265  for (int jk = 0; jk < 3; jk++) {
266  for (int ij = 0; ij < netamx; ij++) {
267  sprintf(name, "sigeta_%i_%i_%i", kl, jk, ij);
268  sprintf(title, "sigeta %s %s i#eta=%i", varnam[kl], varcrit[jk], getHOieta(ij));
269  sig_eta_evt[netamx * jk + ij][kl] =
270  fs->make<TH2F>(name, title, nbinxx[kl], alowxx[kl], ahghxx[kl], m_bins, m_low, m_ahigh);
271  }
272  }
273  }
274 
275  for (int kl = 0; kl < ncut; kl++) {
276  for (int ij = 0; ij < ringmx * 3; ij++) {
277  int iring = ij % ringmx - 2;
278  int iset = ij / ringmx;
279  sprintf(name, "sigring_%i_%i", kl, ij);
280  sprintf(title, "Signal %s %s Ring%i", varnam[kl], varcrit[iset], iring);
281  sigvsevt[ij][kl] = fs->make<TH2F>(name, title, nbinxx[kl], alowxx[kl], ahghxx[kl], m_bins, m_low, m_ahigh);
282  }
283  }
284 
285  for (int kl = 0; kl < ncut; kl++) {
286  for (int ij = 0; ij < ringmx * 3; ij++) {
287  int iring = ij % ringmx - 2;
288  int iset = ij / ringmx;
289  sprintf(name, "varring_%i_%i", kl, ij);
290  sprintf(title, "%s %s Ring%i", varnam[kl], varcrit[iset], iring);
291  variab[ij][kl] = fs->make<TH1F>(name, title, nbinxx[kl], alowxx[kl], ahghxx[kl]);
292  }
293  }
294 
295  for (int ij = 0; ij <= ncut; ij++) {
296  sprintf(name, "mu_projection_%i", ij);
297  if (ij == 0) {
298  sprintf(title, "All projected muon");
299  } else {
300  sprintf(title, "Projected muon with selection %s", varnam[ij - 1]);
301  }
302  mu_projection[ij] =
303  fs->make<TH2F>(name, title, netamx + 1, -netamx / 2 - 0.5, netamx / 2 + 0.5, nphimx, 0.5, nphimx + 0.5);
304  }
305 
306  for (int ij = 0; ij < 31; ij++) {
307  mypow_2[ij] = std::pow(2, ij);
308  }
309  for (int ij = 0; ij < ringmx; ij++) {
310  for (int jk = 0; jk < ncut + 10; jk++) {
311  ncount[ij][jk] = 0.0;
312  }
313  }
314 }
315 
317  edm::LogVerbatim("HOCalibAnalyzer") << " Total events = " << std::setw(7) << nevents[0] << " " << std::setw(7)
318  << nevents[1] << " " << std::setw(7) << nevents[2] << " " << std::setw(7)
319  << nevents[3] << " " << std::setw(7) << nevents[4] << " " << std::setw(7)
320  << nevents[5] << " Selected events # is " << ipass;
321 }
322 
323 //
324 // member functions
325 //
328  desc.add<edm::InputTag>("hoCalibVariableCollectionTag",
329  edm::InputTag("hoCalibProducer", "HOCalibVariableCollection"));
330  desc.add<edm::InputTag>("hoInputTag", edm::InputTag("horeco"));
331  desc.addUntracked<bool>("cosmic", true);
332  desc.addUntracked<bool>("zeroField", false);
333  desc.addUntracked<int>("HOSignalBins", 120);
334  desc.addUntracked<double>("lowerRange", -1.0);
335  desc.addUntracked<double>("upperRange", 29.0);
336  desc.addUntracked<bool>("histFill", true);
337  desc.addUntracked<bool>("treeFill", false);
338  desc.addUntracked<double>("sigma", 0.05);
339  desc.addUntracked<bool>("verbose", false);
340  descriptions.add("hoCalibAnalyzer", desc);
341 }
342 
343 // ------------ method called to for each event ------------
345  nevents[0]++;
346 
347  ievt = iEvent.id().event();
348  ilumi = iEvent.luminosityBlock();
349 
350  const edm::Handle<HOCalibVariableCollection>& HOCalib = iEvent.getHandle(tok_ho_);
351 
352  if (nevents[0] % 20000 == 1) {
353  edm::LogVerbatim("HOCalibAnalyzer") << "nmuon event # " << std::setw(7) << nevents[0] << " " << std::setw(7)
354  << nevents[1] << " " << std::setw(7) << nevents[2] << " " << std::setw(7)
355  << nevents[3] << " " << std::setw(7) << nevents[4] << " " << std::setw(7)
356  << nevents[5];
357  edm::LogVerbatim("HOCalibAnalyzer") << " Run # " << iEvent.id().run() << " Evt # " << iEvent.id().event() << " "
358  << int(HOCalib.isValid()) << " " << ipass;
359  }
360 
361  if (HOCalib.isValid()) {
362  nevents[1]++;
363  nmuon = (*HOCalib).size();
364 
365  for (HOCalibVariableCollection::const_iterator hoC = (*HOCalib).begin(); hoC != (*HOCalib).end(); hoC++) {
366  trkdr = (*hoC).trkdr;
367  trkdz = (*hoC).trkdz;
368 
369  trkvx = (*hoC).trkvx;
370  trkvy = (*hoC).trkvy;
371  trkvz = (*hoC).trkvz;
372 
373  trkmm = (*hoC).trkmm;
374  trkth = (*hoC).trkth;
375  trkph = (*hoC).trkph;
376 
377  ndof = static_cast<int>((*hoC).ndof);
378  chisq = (*hoC).chisq;
379  momatho = (*hoC).momatho;
380 
381  therr = (*hoC).therr;
382  pherr = (*hoC).pherr;
383  trkph = (*hoC).trkph;
384 
385  if (!m_cosmic) {
386  nprim = (*hoC).nprim;
387  pileup = (*hoC).pileup;
388  tkpt03 = (*hoC).tkpt03;
389  ecal03 = (*hoC).ecal03;
390  hcal03 = (*hoC).hcal03;
391  }
392 
393  isect = (*hoC).isect;
394  isect2 = (*hoC).isect2;
395  hodx = (*hoC).hodx;
396  hody = (*hoC).hody;
397  hoang = (*hoC).hoang;
398 
400 
401  htime = (*hoC).htime;
402  hoflag = (*hoC).hoflag;
403  for (int ij = 0; ij < 9; ij++) {
404  hosig[ij] = (*hoC).hosig[ij];
405  if (m_verbose)
406  edm::LogVerbatim("HOCalibAnalyzer") << "hosig " << ij << " " << hosig[ij];
407  }
408  for (int ij = 0; ij < 18; ij++) {
409  hocorsig[ij] = (*hoC).hocorsig[ij];
410  if (m_verbose)
411  edm::LogVerbatim("HOCalibAnalyzer") << "hocorsig " << ij << " " << hocorsig[ij];
412  }
413  hocro = (*hoC).hocro;
414  for (int ij = 0; ij < 3; ij++) {
415  caloen[ij] = (*hoC).caloen[ij];
416  }
417 
418  int ipsall = 0;
419  int ips0 = 0;
420  int ips1 = 0;
421  int ips2 = 0;
422  int ips3 = 0;
423  int ips4 = 0;
424  int ips5 = 0;
425  int ips6 = 0;
426  int ips7 = 0;
427  int ips8 = 0;
428  int ips9 = 0;
429  int ips10 = 0;
430  int ips11 = 0;
431  int ips12 = 0;
432  int ips13 = 0;
433 
434  nevents[2]++;
435  bool isZSps = (hosig[4] < -99.0) ? false : true;
436 
437  if ((!m_cosmic) && std::fabs(trkmm) < momatho)
438  continue;
439 
440  nevents[3]++;
441  if (std::fabs(trkth - angle_units::piRadians / 2) < 0.000001)
442  continue; //22OCT07
443  nevents[4]++;
444 
445  int ieta = int((std::abs(isect) % 10000) / 100.) - 50; //an offset to acodate -ve eta values
446  if (std::abs(ieta) >= 16)
447  continue;
448  nevents[5]++;
449  int iphi = std::abs(isect) % 100;
450 
451  int iring = 0;
452 
453  int iring2 = iring + 2;
454 
455  double abshoang = (m_cosmic) ? std::fabs(hoang) : hoang;
456 
457  double elos = 1.0 / std::max(0.1, std::abs(static_cast<double>(hoang)));
458 
459  if (!m_zeroField)
460  elos *= ((14.9 + 0.96 * std::fabs(log(momatho * 2.8)) + 0.033 * momatho * (1.0 - std::pow(momatho, -0.33))) /
461  elosfact);
462 
463  if (m_cosmic) {
464  if (std::abs(ndof) >= 20 && std::abs(ndof) < 55) {
465  ips0 = mypow_2[0];
466  ipsall += ips0;
467  }
468  if (chisq > 0 && chisq < 12) {
469  ips1 = mypow_2[1];
470  ipsall += ips1;
471  } //18Jan2008
472 
473  if (trkth > 0.3 && trkth < angle_units::piRadians - 0.3) {
474  ips2 = mypow_2[2];
475  ipsall += ips2;
476  } //No nead for pp evt
477  if (trkph > -angle_units::piRadians + 0.1 && trkph < -0.1) {
478  ips3 = mypow_2[3];
479  ipsall += ips3;
480  } //No nead for pp evt
481 
482  if (therr < 0.02) {
483  ips4 = mypow_2[4];
484  ipsall += ips4;
485  }
486  if (pherr < 0.0002) {
487  ips5 = mypow_2[5];
488  ipsall += ips5;
489  }
490  if (abshoang > 0.60 && abshoang < 1.0) {
491  ips6 = mypow_2[6];
492  ipsall += ips6;
493  }
494 
495  if (m_zeroField || (std::fabs(momatho) > 5.0 && std::fabs(momatho) < 2000.0)) {
496  ips7 = mypow_2[7];
497  ipsall += ips7;
498  }
499 
500  if (nmuon >= 1 && nmuon <= 3) {
501  ips8 = mypow_2[8];
502  ipsall += ips8;
503  }
504 
505  // initially for: if (hodx>0 && hody>0) { }
506  ips9 = mypow_2[9];
507  ipsall += ips9;
508 
509  ips10 = mypow_2[10];
510  ipsall += ips10;
511 
512  if (iring2 == 2) {
513  if (std::fabs(hodx) < 100 && std::fabs(hodx) > 2 && std::fabs(hocorsig[8]) < 40 &&
514  std::fabs(hocorsig[8]) > 2) {
515  ips11 = mypow_2[11];
516  ipsall += ips11;
517  }
518 
519  if (std::fabs(hody) < 100 && std::fabs(hody) > 2 && std::fabs(hocorsig[9]) < 40 &&
520  std::fabs(hocorsig[9]) > 2) {
521  ips12 = mypow_2[12];
522  ipsall += ips12;
523  }
524 
525  } else {
526  if (std::fabs(hodx) < 100 && std::fabs(hodx) > 2) {
527  ips11 = mypow_2[11];
528  ipsall += ips11;
529  }
530 
531  if (std::fabs(hody) < 100 && std::fabs(hody) > 2) {
532  ips12 = mypow_2[12];
533  ipsall += ips12;
534  }
535  }
536 
537  if (m_zeroField) {
538  if (iring2 == 0) {
539  if (htime > -60 && htime < 60) {
540  ips13 = mypow_2[13];
541  ipsall += ips13;
542  }
543  }
544  if (iring2 == 1) {
545  if (htime > -60 && htime < 60) {
546  ips13 = mypow_2[13];
547  ipsall += ips13;
548  }
549  }
550  if (iring2 == 2) {
551  if (htime > -60 && htime < 60) {
552  ips13 = mypow_2[13];
553  ipsall += ips13;
554  }
555  }
556  if (iring2 == 3) {
557  if (htime > -60 && htime < 60) {
558  ips13 = mypow_2[13];
559  ipsall += ips13;
560  }
561  }
562  if (iring2 == 4) {
563  if (htime > -60 && htime < 60) {
564  ips13 = mypow_2[13];
565  ipsall += ips13;
566  }
567  }
568  } else {
569  if (htime > -100 && htime < 100) {
570  ips13 = mypow_2[13];
571  ipsall += ips13;
572  }
573  }
574  } else {
575  if (std::abs(ndof) >= 10 && std::abs(ndof) < 25) {
576  ips0 = mypow_2[0];
577  ipsall += ips0;
578  }
579  if (chisq > 0 && chisq < 10) {
580  ips1 = mypow_2[1];
581  ipsall += ips1;
582  } //18Jan2008
583 
584  if (std::fabs(trkth - angle_units::piRadians / 2) < 21.5) {
585  ips2 = mypow_2[2];
586  ipsall += ips2;
587  } //No nead for pp evt
588  if (std::fabs(trkph + angle_units::piRadians / 2) < 21.5) {
589  ips3 = mypow_2[3];
590  ipsall += ips3;
591  } //No nead for pp evt
592 
593  if (therr < 0.00002) {
594  ips4 = mypow_2[4];
595  ipsall += ips4;
596  }
597  if (pherr < 0.000002) {
598  ips5 = mypow_2[5];
599  ipsall += ips5;
600  }
601  // earlier: if (abshoang >0.40 && abshoang <1.0) {ips6 = mypow_2[6]; ipsall +=ips6;}
602  if (tmphoang < 0.065) {
603  ips6 = mypow_2[6];
604  ipsall += ips6;
605  }
606 
607  if (std::fabs(momatho) < 250.0 && std::fabs(momatho) > 15.0) {
608  if (iring2 == 2) {
609  ips7 = mypow_2[7];
610  ipsall += ips7;
611  }
612  if ((iring2 == 1 || iring2 == 3) && std::fabs(momatho) > 17.0) {
613  ips7 = mypow_2[7];
614  ipsall += ips7;
615  }
616  if ((iring2 == 0 || iring2 == 4) && std::fabs(momatho) > 20.0) {
617  ips7 = mypow_2[7];
618  ipsall += ips7;
619  }
620  }
621 
622  if (nmuon >= 1 && nmuon <= 3) {
623  ips8 = mypow_2[8];
624  ipsall += ips8;
625  }
626 
627  if (ndof > 0 && caloen[0] < 15.0) {
628  ips9 = mypow_2[9];
629  ipsall += ips9;
630  } //5.0
631  if (tkpt03 < 5.0) {
632  ips10 = mypow_2[10];
633  ipsall += ips10;
634  } //4.0
635 
636  if (iring2 == 2) {
637  if (std::fabs(hodx) < 100 && std::fabs(hodx) > 2 && std::fabs(hocorsig[8]) < 40 &&
638  std::fabs(hocorsig[8]) > 2) {
639  ips11 = mypow_2[11];
640  ipsall += ips11;
641  }
642 
643  if (std::fabs(hody) < 100 && std::fabs(hody) > 2 && std::fabs(hocorsig[9]) < 40 &&
644  std::fabs(hocorsig[9]) > 2) {
645  ips12 = mypow_2[12];
646  ipsall += ips12;
647  }
648 
649  } else {
650  if (std::fabs(hodx) < 100 && std::fabs(hodx) > 2) {
651  ips11 = mypow_2[11];
652  ipsall += ips11;
653  }
654 
655  if (std::fabs(hody) < 100 && std::fabs(hody) > 2) {
656  ips12 = mypow_2[12];
657  ipsall += ips12;
658  }
659  }
660 
661  if (iring2 == 0) {
662  if (htime > -20 && htime < 20) {
663  ips13 = mypow_2[13];
664  ipsall += ips13;
665  }
666  }
667  if (iring2 == 1) {
668  if (htime > -20 && htime < 20) {
669  ips13 = mypow_2[13];
670  ipsall += ips13;
671  }
672  }
673  if (iring2 == 2) {
674  if (htime > -30 && htime < 20) {
675  ips13 = mypow_2[13];
676  ipsall += ips13;
677  }
678  }
679  if (iring2 == 3) {
680  if (htime > -20 && htime < 20) {
681  ips13 = mypow_2[13];
682  ipsall += ips13;
683  }
684  }
685  if (iring2 == 4) {
686  if (htime > -20 && htime < 20) {
687  ips13 = mypow_2[13];
688  ipsall += ips13;
689  }
690  }
691  }
692  int tmpxet = invert_HOieta(ieta);
693  double nomHOSig = hosig[4] / elos;
694 
695  if (ipsall - ips0 == mypow_2[ncut] - mypow_2[0] - 1) {
696  if (isZSps) {
697  sigvsevt[iring2][0]->Fill(std::abs(ndof), nomHOSig);
698  sig_eta_evt[tmpxet][0]->Fill(std::abs(ndof), nomHOSig);
699  }
700  variab[iring2][0]->Fill(std::abs(ndof));
701  }
702  if (ipsall - ips1 == mypow_2[ncut] - mypow_2[1] - 1) {
703  if (isZSps) {
704  sigvsevt[iring2][1]->Fill(chisq, nomHOSig);
705  sig_eta_evt[tmpxet][1]->Fill(chisq, nomHOSig);
706  }
707  variab[iring2][1]->Fill(chisq);
708  }
709  if (ipsall - ips2 == mypow_2[ncut] - mypow_2[2] - 1) {
710  if (isZSps) {
711  sigvsevt[iring2][2]->Fill(trkth, nomHOSig);
712  sig_eta_evt[tmpxet][2]->Fill(trkth, nomHOSig);
713  }
714  variab[iring2][2]->Fill(trkth);
715  }
716  if (ipsall - ips3 == mypow_2[ncut] - mypow_2[3] - 1) {
717  if (isZSps) {
718  sigvsevt[iring2][3]->Fill(trkph, nomHOSig);
719  sig_eta_evt[tmpxet][3]->Fill(trkph, nomHOSig);
720  }
721  variab[iring2][3]->Fill(trkph);
722  }
723  if (ipsall - ips4 == mypow_2[ncut] - mypow_2[4] - 1) {
724  if (isZSps) {
725  sigvsevt[iring2][4]->Fill(1000 * therr, nomHOSig);
726  sig_eta_evt[tmpxet][4]->Fill(1000 * therr, nomHOSig);
727  }
728  variab[iring2][4]->Fill(1000 * therr);
729  }
730  if (ipsall - ips5 == mypow_2[ncut] - mypow_2[5] - 1) {
731  if (isZSps) {
732  sigvsevt[iring2][5]->Fill(1000 * pherr, nomHOSig);
733  sig_eta_evt[tmpxet][5]->Fill(1000 * pherr, nomHOSig);
734  }
735  variab[iring2][5]->Fill(1000 * pherr);
736  }
737  if (ipsall - ips6 == mypow_2[ncut] - mypow_2[6] - 1) {
738  if (isZSps) {
739  sigvsevt[iring2][6]->Fill(tmphoang, (nomHOSig)*abshoang);
740  sig_eta_evt[tmpxet][6]->Fill(tmphoang, (nomHOSig)*abshoang);
741  }
742  variab[iring2][6]->Fill(tmphoang);
743  }
744  if (ipsall - ips7 == mypow_2[ncut] - mypow_2[7] - 1) {
745  if (isZSps) {
746  sigvsevt[iring2][7]->Fill(std::fabs(trkmm), nomHOSig);
747  sig_eta_evt[tmpxet][7]->Fill(std::fabs(trkmm), nomHOSig);
748  }
749  variab[iring2][7]->Fill(std::fabs(trkmm));
750  }
751  if (ipsall - ips8 == mypow_2[ncut] - mypow_2[8] - 1) {
752  if (isZSps) {
753  sigvsevt[iring2][8]->Fill(nmuon, nomHOSig);
754  sig_eta_evt[tmpxet][8]->Fill(nmuon, nomHOSig);
755  }
756  variab[iring2][8]->Fill(nmuon);
757  }
758  if (!m_cosmic) {
759  if (ipsall - ips9 == mypow_2[ncut] - mypow_2[9] - 1) {
760  if (isZSps) {
761  sigvsevt[iring2][9]->Fill(caloen[0], nomHOSig);
762  sig_eta_evt[tmpxet][9]->Fill(caloen[0], nomHOSig);
763  }
764  variab[iring2][9]->Fill(caloen[0]);
765  }
766  }
767  if (ipsall - ips10 == mypow_2[ncut] - mypow_2[10] - 1) {
768  if (isZSps) {
769  sigvsevt[iring2][10]->Fill(tkpt03, nomHOSig);
770  sig_eta_evt[tmpxet][10]->Fill(tkpt03, nomHOSig);
771  }
772  variab[iring2][10]->Fill(tkpt03);
773  }
774  if (ipsall - ips11 == mypow_2[ncut] - mypow_2[11] - 1) {
775  if (isZSps) {
776  sigvsevt[iring2][11]->Fill(hodx, nomHOSig);
777  sig_eta_evt[tmpxet][11]->Fill(hodx, nomHOSig);
778  }
779  variab[iring2][11]->Fill(hodx);
780  }
781  if (ipsall - ips12 == mypow_2[ncut] - mypow_2[12] - 1) {
782  if (isZSps) {
783  sigvsevt[iring2][12]->Fill(hody, nomHOSig);
784  sig_eta_evt[tmpxet][12]->Fill(hody, nomHOSig);
785  }
786  variab[iring2][12]->Fill(hody);
787  }
788 
789  if (ipsall - ips13 == mypow_2[ncut] - mypow_2[13] - 1) {
790  if (isZSps) {
791  sigvsevt[iring2][13]->Fill(htime, nomHOSig);
792  sig_eta_evt[tmpxet][13]->Fill(htime, nomHOSig);
793  }
794  variab[iring2][13]->Fill(htime);
795  }
796 
797  if (isZSps) {
798  sigvsevt[iring2 + ringmx][0]->Fill(std::abs(ndof), nomHOSig);
799  sig_eta_evt[netamx + tmpxet][0]->Fill(std::abs(ndof), nomHOSig);
800  }
801  variab[iring2 + 5][0]->Fill(std::abs(ndof));
802 
803  ncount[iring2][0]++;
804  if (isZSps) {
805  ncount[iring2][1]++;
806  }
807  if (ips0 > 0) {
808  if (isZSps) {
809  ncount[iring2][10]++;
810  sigvsevt[iring2 + ringmx][1]->Fill(chisq, nomHOSig);
811  sig_eta_evt[netamx + tmpxet][1]->Fill(chisq, nomHOSig);
812  }
813  variab[iring2 + ringmx][1]->Fill(chisq);
814  mu_projection[1]->Fill(ieta, iphi);
815  if (ips1 > 0) {
816  if (isZSps) {
817  ncount[iring2][11]++;
818  sigvsevt[iring2 + ringmx][2]->Fill(trkth, nomHOSig);
819  sig_eta_evt[netamx + tmpxet][2]->Fill(trkth, nomHOSig);
820  }
821  variab[iring2 + ringmx][2]->Fill(trkth);
822  mu_projection[2]->Fill(ieta, iphi);
823  if (ips2 > 0) {
824  if (isZSps) {
825  ncount[iring2][12]++;
826  sigvsevt[iring2 + ringmx][3]->Fill(trkph, nomHOSig);
827  sig_eta_evt[netamx + tmpxet][3]->Fill(trkph, nomHOSig);
828  }
829  variab[iring2 + ringmx][3]->Fill(trkph);
830  mu_projection[3]->Fill(ieta, iphi);
831  if (ips3 > 0) {
832  if (isZSps) {
833  ncount[iring2][13]++;
834  sigvsevt[iring2 + ringmx][4]->Fill(1000 * therr, nomHOSig);
835  sig_eta_evt[netamx + tmpxet][4]->Fill(1000 * therr, nomHOSig);
836  }
837  variab[iring2 + ringmx][4]->Fill(1000 * therr);
838  mu_projection[4]->Fill(ieta, iphi);
839  if (ips4 > 0) {
840  if (isZSps) {
841  ncount[iring2][14]++;
842  sigvsevt[iring2 + ringmx][5]->Fill(1000 * pherr, nomHOSig);
843  sig_eta_evt[netamx + tmpxet][5]->Fill(1000 * pherr, nomHOSig);
844  }
845  variab[iring2 + ringmx][5]->Fill(1000 * pherr);
846  mu_projection[5]->Fill(ieta, iphi);
847  if (ips5 > 0) {
848  if (isZSps) {
849  ncount[iring2][15]++;
850  sigvsevt[iring2 + ringmx][6]->Fill(tmphoang, (nomHOSig)*abshoang);
851  sig_eta_evt[netamx + tmpxet][6]->Fill(tmphoang, (nomHOSig)*abshoang);
852  }
853  variab[iring2 + ringmx][6]->Fill(tmphoang);
854  mu_projection[6]->Fill(ieta, iphi);
855  if (ips6 > 0) {
856  if (isZSps) {
857  ncount[iring2][16]++;
858  sigvsevt[iring2 + ringmx][7]->Fill(std::fabs(trkmm), nomHOSig);
859  sig_eta_evt[netamx + tmpxet][7]->Fill(std::fabs(trkmm), nomHOSig);
860  }
861  variab[iring2 + ringmx][7]->Fill(std::fabs(trkmm));
862  mu_projection[7]->Fill(ieta, iphi);
863  if (ips7 > 0) {
864  ncount[iring2][4]++; //Efficiency of Muon detection
865  if (isZSps) {
866  ncount[iring2][17]++;
867  sigvsevt[iring2 + ringmx][8]->Fill(nmuon, nomHOSig);
868  sig_eta_evt[netamx + tmpxet][8]->Fill(nmuon, nomHOSig);
869  }
870  variab[iring2 + ringmx][8]->Fill(nmuon);
871  mu_projection[8]->Fill(ieta, iphi);
872  if (ips8 > 0) {
873  if (!m_cosmic) {
874  if (isZSps) {
875  ncount[iring2][18]++;
876  sigvsevt[iring2 + ringmx][9]->Fill(caloen[0], nomHOSig);
877  sig_eta_evt[netamx + tmpxet][9]->Fill(caloen[0], nomHOSig);
878  }
879  variab[iring2 + ringmx][9]->Fill(caloen[0]);
880  mu_projection[9]->Fill(ieta, iphi);
881  }
882  if (ips9 > 0) {
883  if (isZSps) {
884  ncount[iring2][19]++;
885  sigvsevt[iring2 + ringmx][10]->Fill(tkpt03, nomHOSig);
886  sig_eta_evt[netamx + tmpxet][10]->Fill(tkpt03, nomHOSig);
887  }
888  variab[iring2 + ringmx][10]->Fill(tkpt03);
889  mu_projection[10]->Fill(ieta, iphi);
890  if (ips10 > 0) {
891  ncount[iring2][3]++; //Efficiency of Muon detection
892  if (isZSps) {
893  ncount[iring2][20]++;
894  sigvsevt[iring2 + ringmx][11]->Fill(hodx, nomHOSig);
895  sig_eta_evt[netamx + tmpxet][11]->Fill(hodx, nomHOSig);
896  }
897  variab[iring2 + ringmx][11]->Fill(hodx);
898  mu_projection[11]->Fill(ieta, iphi);
899 
900  if (ips11 > 0) {
901  if (isZSps) {
902  ncount[iring2][21]++;
903  sigvsevt[iring2 + ringmx][12]->Fill(hody, nomHOSig);
904  sig_eta_evt[netamx + tmpxet][12]->Fill(hody, nomHOSig);
905  }
906  variab[iring2 + ringmx][12]->Fill(hody);
907  mu_projection[12]->Fill(ieta, iphi);
908 
909  if (ips12 > 0) {
910  ncount[iring2][2]++; //Efficiency of Muon detection
911  if (isZSps) {
912  ncount[iring2][22]++;
913  sigvsevt[iring2 + ringmx][13]->Fill(htime, nomHOSig);
914  sig_eta_evt[tmpxet + ringmx][13]->Fill(htime, nomHOSig);
915  }
916  variab[iring2 + ringmx][13]->Fill(htime);
917  mu_projection[13]->Fill(ieta, iphi);
918 
919  if (ips13 > 0) {
920  if (isZSps) {
921  ncount[iring2][23]++;
922  mu_projection[14]->Fill(ieta, iphi);
923  }
924  }
925  }
926  }
927  }
928  }
929  }
930  }
931  }
932  }
933  }
934  }
935  }
936  }
937  }
938  if (isZSps) {
939  sigvsevt[iring2 + 2 * ringmx][0]->Fill(std::abs(ndof), nomHOSig);
940  sigvsevt[iring2 + 2 * ringmx][1]->Fill(chisq, nomHOSig);
941  sigvsevt[iring2 + 2 * ringmx][2]->Fill(trkth, nomHOSig);
942  sigvsevt[iring2 + 2 * ringmx][3]->Fill(trkph, nomHOSig);
943  sigvsevt[iring2 + 2 * ringmx][4]->Fill(1000 * therr, nomHOSig);
944  sigvsevt[iring2 + 2 * ringmx][5]->Fill(1000 * pherr, nomHOSig);
945  if (abshoang > 0.01) {
946  sigvsevt[iring2 + 2 * ringmx][6]->Fill(tmphoang, (nomHOSig)*abshoang);
947  }
948  sigvsevt[iring2 + 2 * ringmx][7]->Fill(std::fabs(trkmm), nomHOSig);
949  sigvsevt[iring2 + 2 * ringmx][8]->Fill(nmuon, nomHOSig);
950  if (!m_cosmic)
951  sigvsevt[iring2 + 2 * ringmx][9]->Fill(caloen[0], nomHOSig);
952  sigvsevt[iring2 + 2 * ringmx][10]->Fill(tkpt03, nomHOSig);
953  sigvsevt[iring2 + 2 * ringmx][11]->Fill(hodx, nomHOSig);
954  sigvsevt[iring2 + 2 * ringmx][12]->Fill(hody, nomHOSig);
955  sigvsevt[iring2 + 2 * ringmx][13]->Fill(htime, nomHOSig);
956 
957  sig_eta_evt[2 * netamx + tmpxet][0]->Fill(std::abs(ndof), nomHOSig);
958  sig_eta_evt[2 * netamx + tmpxet][1]->Fill(chisq, nomHOSig);
959  sig_eta_evt[2 * netamx + tmpxet][2]->Fill(trkth, nomHOSig);
960  sig_eta_evt[2 * netamx + tmpxet][3]->Fill(trkph, nomHOSig);
961  sig_eta_evt[2 * netamx + tmpxet][4]->Fill(1000 * therr, nomHOSig);
962  sig_eta_evt[2 * netamx + tmpxet][5]->Fill(1000 * pherr, nomHOSig);
963  if (abshoang > 0.01) {
964  sig_eta_evt[2 * netamx + tmpxet][6]->Fill(tmphoang, (nomHOSig)*abshoang);
965  }
966  sig_eta_evt[2 * netamx + tmpxet][7]->Fill(std::fabs(trkmm), nomHOSig);
967  sig_eta_evt[2 * netamx + tmpxet][8]->Fill(nmuon, nomHOSig);
968  if (!m_cosmic)
969  sig_eta_evt[2 * netamx + tmpxet][9]->Fill(caloen[0], nomHOSig);
970  sig_eta_evt[2 * netamx + tmpxet][10]->Fill(tkpt03, nomHOSig);
971  sig_eta_evt[2 * netamx + tmpxet][11]->Fill(hodx, nomHOSig);
972  sig_eta_evt[2 * netamx + tmpxet][12]->Fill(hody, nomHOSig);
973  sig_eta_evt[2 * netamx + tmpxet][13]->Fill(htime, nomHOSig);
974  }
975 
976  variab[iring2 + 2 * ringmx][0]->Fill(std::abs(ndof));
977  variab[iring2 + 2 * ringmx][1]->Fill(chisq);
978  variab[iring2 + 2 * ringmx][2]->Fill(trkth);
979  variab[iring2 + 2 * ringmx][3]->Fill(trkph);
980  variab[iring2 + 2 * ringmx][4]->Fill(1000 * therr);
981  variab[iring2 + 2 * ringmx][5]->Fill(1000 * pherr);
982  variab[iring2 + 2 * ringmx][6]->Fill(tmphoang);
983  variab[iring2 + 2 * ringmx][7]->Fill(std::fabs(trkmm));
984  variab[iring2 + 2 * ringmx][8]->Fill(nmuon);
985  if (!m_cosmic)
986  variab[iring2 + 2 * ringmx][9]->Fill(caloen[0]);
987  variab[iring2 + 2 * ringmx][10]->Fill(tkpt03);
988  variab[iring2 + 2 * ringmx][11]->Fill(hodx);
989  variab[iring2 + 2 * ringmx][12]->Fill(hody);
990  variab[iring2 + 2 * ringmx][13]->Fill(htime);
991 
992  muonnm->Fill(nmuon);
993  muonmm->Fill(trkmm);
994  muonth->Fill(trkth * 180 / angle_units::piRadians);
995  muonph->Fill(trkph * 180 / angle_units::piRadians);
996  muonch->Fill(chisq);
997 
998  int iselect = (ipsall == mypow_2[ncut] - 1) ? 1 : 0;
999 
1000  if (iselect == 1) {
1001  ipass++;
1002  sel_muonnm->Fill(nmuon);
1003  sel_muonmm->Fill(trkmm);
1004  sel_muonth->Fill(trkth * 180 / angle_units::piRadians);
1005  sel_muonph->Fill(trkph * 180 / angle_units::piRadians);
1006  sel_muonch->Fill(chisq);
1007  if (m_histFill && tmpxet >= 0 && tmpxet < netamx && iphi >= 0 && iphi < nphimx) {
1008  ho_indenergy[tmpxet][iphi - 1]->Fill(nomHOSig);
1009  }
1010  if (m_treeFill) {
1011  T1->Fill();
1012  }
1013  }
1014  } //close the for loop: (HOCalibVariableCollection::const_iterator hoC=(*HOCalib).begin(); hoC!=(*HOCalib).end(); hoC++){
1015  } //end of the if loop (isCosMu)
1016 }
1017 
1018 //define this as a plug-in
static const std::string kSharedResource
Definition: TFileService.h:76
Log< level::Info, true > LogVerbatim
const edm::EDGetTokenT< HORecHitCollection > tok_allho_
const edm::EDGetTokenT< HOCalibVariableCollection > tok_ho_
const double m_low
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HOCalibAnalyzer(const edm::ParameterSet &)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void beginJob() override
constexpr int pow(int x)
Definition: conifer.h:24
void endJob() override
void analyze(const edm::Event &, const edm::EventSetup &) override
static constexpr int ncut
TH1F * variab[3 *netamx][ncut]
TH1F * ho_indenergy[netamx][nphimx]
edm::InputTag hoCalibVariableCollectionTag
TH2F * sig_eta_evt[3 *netamx][ncut]
static constexpr int nphimx
static constexpr int ringmx
const double m_ahigh
const double elosfact
float ncount[ringmx][ncut+10]
int iEvent
Definition: GenABIO.cc:224
const bool m_verbose
const char * varcrit[3]
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int getHOieta(int ij)
int invert_HOieta(int ieta)
const bool m_treeFill
constexpr double piRadians(M_PI)
const bool m_zeroField
std::vector< HOCalibVariables > HOCalibVariableCollection
collection of HOcalibration variabale
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool isValid() const
Definition: HandleBase.h:70
const bool m_cosmic
HLT enums.
static constexpr int netamx
TH2F * sigvsevt[3 *netamx][ncut]
const bool m_histFill
~HOCalibAnalyzer() override
TH2F * mu_projection[ncut+1]