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 
36 
42 
43 #include "TFile.h"
44 #include "TH1F.h"
45 #include "TH2F.h"
46 #include "TTree.h"
47 #include "TProfile.h"
48 
49 #include <string>
50 
51 #include <iostream>
52 #include <fstream>
53 #include <iomanip>
54 
55 using namespace std;
56 using namespace edm;
57 
58 //#define EDM_ML_DEBUG
59 //
60 // class decleration
61 //
62 
63 class HOCalibAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
64 public:
65  explicit HOCalibAnalyzer(const edm::ParameterSet&);
66  ~HOCalibAnalyzer() override;
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 * fabs(log(8 * 2.8)) + 0.033 * 8 * (1.0 - 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 
95  int ipass;
96 
97  TTree* T1;
98 
99  TH1F* ho_indenergy[netamx][nphimx];
100 
101  TH1F* muonnm;
102  TH1F* muonmm;
103  TH1F* muonth;
104  TH1F* muonph;
105  TH1F* muonch;
106 
107  TH1F* sel_muonnm;
108  TH1F* sel_muonmm;
109  TH1F* sel_muonth;
110  TH1F* sel_muonph;
111  TH1F* sel_muonch;
112 
113  // TProfile* sigvsevt[15][ncut];
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;
121  int irun, ilumi, nprim, isect, isect2, ndof, nmuon;
122 
123  float inslumi, trkdr, trkdz, trkvx, trkvy, trkvz, trkmm, trkth, trkph, chisq, therr, pherr, hodx, hody, hoang, htime,
124  hosig[9], hocorsig[18], hocro, hbhesig[9], caloen[3];
125  float momatho, tkpt03, ecal03, hcal03;
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  tok_ho_(consumes<HOCalibVariableCollection>(iConfig.getParameter<edm::InputTag>("hoCalibVariableCollectionTag"))),
159  tok_allho_(consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInputTag"))) {
160  // It is very likely you want the following in your configuration
161  // hoCalibVariableCollectionTag = cms.InputTag('hoCalibProducer', 'HOCalibVariableCollection')
162 
163  usesResource(TFileService::kSharedResource);
164 
165  //now do what ever initialization is needed
166  ipass = 0;
167  for (int ij = 0; ij < 10; ij++) {
168  nevents[ij] = 0;
169  }
170 
172 
173  T1 = fs->make<TTree>("T1", "HOSignal");
174 
175  T1->Branch("irun", &irun, "irun/I");
176  T1->Branch("ievt", &ievt, "ievt/i");
177 
178  T1->Branch("isect", &isect, "isect/I");
179  T1->Branch("isect2", &isect2, "isect2/I");
180  T1->Branch("ndof", &ndof, "ndof/I");
181  T1->Branch("nmuon", &nmuon, "nmuon/I");
182 
183  T1->Branch("ilumi", &ilumi, "ilumi/I");
184  if (!m_cosmic) {
185  T1->Branch("inslumi", &inslumi, "inslumi/F");
186  T1->Branch("nprim", &nprim, "nprim/I");
187  T1->Branch("tkpt03", &tkpt03, " tkpt03/F");
188  T1->Branch("ecal03", &ecal03, " ecal03/F");
189  T1->Branch("hcal03", &hcal03, " hcal03/F");
190  }
191 
192  T1->Branch("trkdr", &trkdr, "trkdr/F");
193  T1->Branch("trkdz", &trkdz, "trkdz/F");
194 
195  T1->Branch("trkvx", &trkvx, "trkvx/F");
196  T1->Branch("trkvy", &trkvy, "trkvy/F");
197  T1->Branch("trkvz", &trkvz, "trkvz/F");
198  T1->Branch("trkmm", &trkmm, "trkmm/F");
199  T1->Branch("trkth", &trkth, "trkth/F");
200  T1->Branch("trkph", &trkph, "trkph/F");
201 
202  T1->Branch("chisq", &chisq, "chisq/F");
203  T1->Branch("therr", &therr, "therr/F");
204  T1->Branch("pherr", &pherr, "pherr/F");
205  T1->Branch("hodx", &hodx, "hodx/F");
206  T1->Branch("hody", &hody, "hody/F");
207  T1->Branch("hoang", &hoang, "hoang/F");
208 
209  T1->Branch("momatho", &momatho, "momatho/F");
210  T1->Branch("hoflag", &hoflag, "hoflag/i");
211  T1->Branch("htime", &htime, "htime/F");
212  T1->Branch("hosig", hosig, "hosig[9]/F");
213  T1->Branch("hocro", &hocro, "hocro/F");
214  T1->Branch("hocorsig", hocorsig, "hocorsig[18]/F");
215  T1->Branch("caloen", caloen, "caloen[3]/F");
216 
217  char name[200];
218  char title[200];
219 
220  if (m_histFill) {
221  for (int ij = 0; ij < netamx; ij++) {
222  int ieta = getHOieta(ij);
223  for (int jk = 0; jk < nphimx; jk++) {
224  sprintf(name, "ho_indenergy_%i_%i", ij, jk);
225  sprintf(title, "ho IndEnergy (GeV) i#eta=%i i#phi=%i", ieta, jk + 1);
226  ho_indenergy[ij][jk] = fs->make<TH1F>(name, title, 1200, m_low, m_ahigh);
227  }
228  }
229  }
230 
231  muonnm = fs->make<TH1F>("muonnm", "No of muon", 10, -0.5, 9.5);
232  muonmm = fs->make<TH1F>("muonmm", "P_{mu}", 200, -100., 100.);
233  muonth = fs->make<TH1F>("muonth", "{Theta}_{mu}", 180, 0., 180.);
234  muonph = fs->make<TH1F>("muonph", "{Phi}_{mu}", 180, -180., 180.);
235  muonch = fs->make<TH1F>("muonch", "{chi^2}/ndf", 100, 0., 1000.);
236 
237  sel_muonnm = fs->make<TH1F>("sel_muonnm", "No of muon(sel)", 10, -0.5, 9.5);
238  sel_muonmm = fs->make<TH1F>("sel_muonmm", "P_{mu}(sel)", 200, -100., 100.);
239  sel_muonth = fs->make<TH1F>("sel_muonth", "{Theta}_{mu}(sel)", 180, 0., 180.);
240  sel_muonph = fs->make<TH1F>("sel_muonph", "{Phi}_{mu}(sel)", 180, -180., 180.);
241  sel_muonch = fs->make<TH1F>("sel_muonch", "{chi^2}/ndf(sel)", 100, 0., 1000.);
242 
243  float pival = acos(-1.);
244 
245  //if change order, change in iselect_wotime also and other efficiency numbers
246  const char* varnam[ncut] = {"ndof",
247  "chisq",
248  "th",
249  "ph",
250  "therr",
251  "pherr",
252  "dircos",
253  "trkmm",
254  "nmuon",
255  "calo",
256  "trkiso",
257  "#phi-dir",
258  "#eta-dir",
259  "time"};
260  int nbinxx[ncut] = {25, 60, 60, 60, 60, 60, 60, 120, 6, 60, 60, 120, 120, 60};
261  double alowxx[ncut] = {5.5, 0., 0., -pival, 0.0, 0.0, 0.0, 0., 0.5, 0.0, 0.0, -20., -32., -45.0};
262  double ahghxx[ncut] = {30.5, 40., pival, pival, 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] = 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  // do anything here that needs to be done at desctruction time
318  // (e.g. close files, deallocate resources etc.)
319 
320  edm::LogVerbatim("HOCalibAnalyzer") << " Total events = " << setw(7) << nevents[0] << " " << setw(7) << nevents[1]
321  << " " << setw(7) << nevents[2] << " " << setw(7) << nevents[3] << " " << setw(7)
322  << nevents[4] << " " << setw(7) << nevents[5] << " Selected events # is "
323  << ipass;
324 }
325 
326 //
327 // member functions
328 //
329 
330 // ------------ method called to for each event ------------
332  nevents[0]++;
333 
334  using namespace edm;
335 
336  float pival = acos(-1.);
337 
338  ievt = iEvent.id().event();
339  ilumi = iEvent.luminosityBlock();
340 
341  const edm::Handle<HOCalibVariableCollection>& HOCalib = iEvent.getHandle(tok_ho_);
342 
343  if (nevents[0] % 20000 == 1) {
344  edm::LogVerbatim("HOCalibAnalyzer") << "nmuon event # " << setw(7) << nevents[0] << " " << setw(7) << nevents[1]
345  << " " << setw(7) << nevents[2] << " " << setw(7) << nevents[3] << " "
346  << setw(7) << nevents[4] << " " << setw(7) << nevents[5];
347  edm::LogVerbatim("HOCalibAnalyzer") << " Run # " << iEvent.id().run() << " Evt # " << iEvent.id().event() << " "
348  << int(HOCalib.isValid()) << " " << ipass;
349  }
350 
351  if (HOCalib.isValid()) {
352  nevents[1]++;
353  nmuon = (*HOCalib).size();
354 
355  for (HOCalibVariableCollection::const_iterator hoC = (*HOCalib).begin(); hoC != (*HOCalib).end(); hoC++) {
356  trkdr = (*hoC).trkdr;
357  trkdz = (*hoC).trkdz;
358 
359  trkvx = (*hoC).trkvx;
360  trkvy = (*hoC).trkvy;
361  trkvz = (*hoC).trkvz;
362 
363  trkmm = (*hoC).trkmm;
364  trkth = (*hoC).trkth;
365  trkph = (*hoC).trkph;
366 
367  ndof = (int)(*hoC).ndof;
368  chisq = (*hoC).chisq;
369  momatho = (*hoC).momatho;
370 
371  therr = (*hoC).therr;
372  pherr = (*hoC).pherr;
373  trkph = (*hoC).trkph;
374 
375  if (!m_cosmic) {
376  nprim = (*hoC).nprim;
377  inslumi = (*hoC).inslumi;
378  tkpt03 = (*hoC).tkpt03;
379  ecal03 = (*hoC).ecal03;
380  hcal03 = (*hoC).hcal03;
381  }
382 
383  isect = (*hoC).isect;
384  isect2 = (*hoC).isect2;
385  hodx = (*hoC).hodx;
386  hody = (*hoC).hody;
387  hoang = (*hoC).hoang;
388 
389  tmphoang = sin(trkth) - hoang;
390 
391  htime = (*hoC).htime;
392  hoflag = (*hoC).hoflag;
393  for (int ij = 0; ij < 9; ij++) {
394  hosig[ij] = (*hoC).hosig[ij];
395 #ifdef EDM_ML_DEBUG
396  edm::LogVerbatim("HOCalibAnalyzer") << "hosig " << ij << " " << hosig[ij];
397 #endif
398  }
399  for (int ij = 0; ij < 18; ij++) {
400  hocorsig[ij] = (*hoC).hocorsig[ij];
401 #ifdef EDM_ML_DEBUG
402  edm::LogVerbatim("HOCalibAnalyzer") << "hocorsig " << ij << " " << hocorsig[ij];
403 #endif
404  }
405  hocro = (*hoC).hocro;
406  for (int ij = 0; ij < 3; ij++) {
407  caloen[ij] = (*hoC).caloen[ij];
408  }
409 
410  int ipsall = 0;
411  int ips0 = 0;
412  int ips1 = 0;
413  int ips2 = 0;
414  int ips3 = 0;
415  int ips4 = 0;
416  int ips5 = 0;
417  int ips6 = 0;
418  int ips7 = 0;
419  int ips8 = 0;
420  int ips9 = 0;
421  int ips10 = 0;
422  int ips11 = 0;
423  int ips12 = 0;
424  int ips13 = 0;
425 
426  nevents[2]++;
427  bool isZSps = (hosig[4] < -99.0) ? false : true;
428 
429  if ((!m_cosmic) && fabs(trkmm) < momatho)
430  continue;
431 
432  nevents[3]++;
433  if (fabs(trkth - pival / 2) < 0.000001)
434  continue; //22OCT07
435  nevents[4]++;
436 
437  int ieta = int((abs(isect) % 10000) / 100.) - 50; //an offset to acodate -ve eta values
438  if (abs(ieta) >= 16)
439  continue;
440  nevents[5]++;
441  int iphi = abs(isect) % 100;
442 
443  int iring = 0;
444 
445  int iring2 = iring + 2;
446 
447  double abshoang = (m_cosmic) ? fabs(hoang) : hoang;
448 
449  double elos = 1.0 / TMath::Max(0.1, abs(1.0 * hoang));
450 
451  if (!m_zeroField)
452  elos *= ((14.9 + 0.96 * fabs(log(momatho * 2.8)) + 0.033 * momatho * (1.0 - pow(momatho, -0.33))) / elosfact);
453 
454  if (m_cosmic) {
455  if (abs(ndof) >= 20 && abs(ndof) < 55) {
456  ips0 = mypow_2[0];
457  ipsall += ips0;
458  }
459  if (chisq > 0 && chisq < 12) {
460  ips1 = mypow_2[1];
461  ipsall += ips1;
462  } //18Jan2008
463 
464  if (trkth > 0.3 && trkth < pival - 0.3) {
465  ips2 = mypow_2[2];
466  ipsall += ips2;
467  } //No nead for pp evt
468  if (trkph > -pival + 0.1 && trkph < -0.1) {
469  ips3 = mypow_2[3];
470  ipsall += ips3;
471  } //No nead for pp evt
472 
473  if (therr < 0.02) {
474  ips4 = mypow_2[4];
475  ipsall += ips4;
476  }
477  if (pherr < 0.0002) {
478  ips5 = mypow_2[5];
479  ipsall += ips5;
480  }
481  if (abshoang > 0.60 && abshoang < 1.0) {
482  ips6 = mypow_2[6];
483  ipsall += ips6;
484  }
485 
486  if (m_zeroField || (fabs(momatho) > 5.0 && fabs(momatho) < 2000.0)) {
487  ips7 = mypow_2[7];
488  ipsall += ips7;
489  }
490 
491  if (nmuon >= 1 && nmuon <= 3) {
492  ips8 = mypow_2[8];
493  ipsall += ips8;
494  }
495 
496  // if (hodx>0 && hody>0) { }
497  ips9 = mypow_2[9];
498  ipsall += ips9;
499 
500  ips10 = mypow_2[10];
501  ipsall += ips10;
502 
503  if (iring2 == 2) {
504  if (fabs(hodx) < 100 && fabs(hodx) > 2 && fabs(hocorsig[8]) < 40 && fabs(hocorsig[8]) > 2) {
505  ips11 = mypow_2[11];
506  ipsall += ips11;
507  }
508 
509  if (fabs(hody) < 100 && fabs(hody) > 2 && fabs(hocorsig[9]) < 40 && fabs(hocorsig[9]) > 2) {
510  ips12 = mypow_2[12];
511  ipsall += ips12;
512  }
513 
514  } else {
515  if (fabs(hodx) < 100 && fabs(hodx) > 2) {
516  ips11 = mypow_2[11];
517  ipsall += ips11;
518  }
519 
520  if (fabs(hody) < 100 && fabs(hody) > 2) {
521  ips12 = mypow_2[12];
522  ipsall += ips12;
523  }
524  }
525 
526  if (m_zeroField) {
527  if (iring2 == 0) {
528  if (htime > -60 && htime < 60) {
529  ips13 = mypow_2[13];
530  ipsall += ips13;
531  }
532  }
533  if (iring2 == 1) {
534  if (htime > -60 && htime < 60) {
535  ips13 = mypow_2[13];
536  ipsall += ips13;
537  }
538  }
539  if (iring2 == 2) {
540  if (htime > -60 && htime < 60) {
541  ips13 = mypow_2[13];
542  ipsall += ips13;
543  }
544  }
545  if (iring2 == 3) {
546  if (htime > -60 && htime < 60) {
547  ips13 = mypow_2[13];
548  ipsall += ips13;
549  }
550  }
551  if (iring2 == 4) {
552  if (htime > -60 && htime < 60) {
553  ips13 = mypow_2[13];
554  ipsall += ips13;
555  }
556  }
557  } else {
558  if (htime > -100 && htime < 100) {
559  ips13 = mypow_2[13];
560  ipsall += ips13;
561  }
562  }
563  } else {
564  if (abs(ndof) >= 10 && abs(ndof) < 25) {
565  ips0 = mypow_2[0];
566  ipsall += ips0;
567  }
568  if (chisq > 0 && chisq < 10) {
569  ips1 = mypow_2[1];
570  ipsall += ips1;
571  } //18Jan2008
572 
573  if (fabs(trkth - pival / 2) < 21.5) {
574  ips2 = mypow_2[2];
575  ipsall += ips2;
576  } //No nead for pp evt
577  if (fabs(trkph + pival / 2) < 21.5) {
578  ips3 = mypow_2[3];
579  ipsall += ips3;
580  } //No nead for pp evt
581 
582  if (therr < 0.00002) {
583  ips4 = mypow_2[4];
584  ipsall += ips4;
585  }
586  if (pherr < 0.000002) {
587  ips5 = mypow_2[5];
588  ipsall += ips5;
589  }
590  // if (abshoang >0.40 && abshoang <1.0) {ips6 = mypow_2[6]; ipsall +=ips6;}
591  if (tmphoang < 0.065) {
592  ips6 = mypow_2[6];
593  ipsall += ips6;
594  }
595 
596  if (fabs(momatho) < 250.0 && fabs(momatho) > 15.0) {
597  if (iring2 == 2) {
598  ips7 = mypow_2[7];
599  ipsall += ips7;
600  }
601  if ((iring2 == 1 || iring2 == 3) && fabs(momatho) > 17.0) {
602  ips7 = mypow_2[7];
603  ipsall += ips7;
604  }
605  if ((iring2 == 0 || iring2 == 4) && fabs(momatho) > 20.0) {
606  ips7 = mypow_2[7];
607  ipsall += ips7;
608  }
609  }
610 
611  if (nmuon >= 1 && nmuon <= 3) {
612  ips8 = mypow_2[8];
613  ipsall += ips8;
614  }
615 
616  if (ndof > 0 && caloen[0] < 15.0) {
617  ips9 = mypow_2[9];
618  ipsall += ips9;
619  } //5.0
620  if (tkpt03 < 5.0) {
621  ips10 = mypow_2[10];
622  ipsall += ips10;
623  } //4.0
624 
625  if (iring2 == 2) {
626  if (fabs(hodx) < 100 && fabs(hodx) > 2 && fabs(hocorsig[8]) < 40 && fabs(hocorsig[8]) > 2) {
627  ips11 = mypow_2[11];
628  ipsall += ips11;
629  }
630 
631  if (fabs(hody) < 100 && fabs(hody) > 2 && fabs(hocorsig[9]) < 40 && fabs(hocorsig[9]) > 2) {
632  ips12 = mypow_2[12];
633  ipsall += ips12;
634  }
635 
636  } else {
637  if (fabs(hodx) < 100 && fabs(hodx) > 2) {
638  ips11 = mypow_2[11];
639  ipsall += ips11;
640  }
641 
642  if (fabs(hody) < 100 && fabs(hody) > 2) {
643  ips12 = mypow_2[12];
644  ipsall += ips12;
645  }
646  }
647 
648  if (iring2 == 0) {
649  if (htime > -20 && htime < 20) {
650  ips13 = mypow_2[13];
651  ipsall += ips13;
652  }
653  }
654  if (iring2 == 1) {
655  if (htime > -20 && htime < 20) {
656  ips13 = mypow_2[13];
657  ipsall += ips13;
658  }
659  }
660  if (iring2 == 2) {
661  if (htime > -30 && htime < 20) {
662  ips13 = mypow_2[13];
663  ipsall += ips13;
664  }
665  }
666  if (iring2 == 3) {
667  if (htime > -20 && htime < 20) {
668  ips13 = mypow_2[13];
669  ipsall += ips13;
670  }
671  }
672  if (iring2 == 4) {
673  if (htime > -20 && htime < 20) {
674  ips13 = mypow_2[13];
675  ipsall += ips13;
676  }
677  }
678  }
679  int tmpxet = invert_HOieta(ieta);
680  double nomHOSig = hosig[4] / elos;
681 
682  if (ipsall - ips0 == mypow_2[ncut] - mypow_2[0] - 1) {
683  if (isZSps) {
684  sigvsevt[iring2][0]->Fill(abs(ndof), nomHOSig);
685  sig_eta_evt[tmpxet][0]->Fill(abs(ndof), nomHOSig);
686  }
687  variab[iring2][0]->Fill(abs(ndof));
688  }
689  if (ipsall - ips1 == mypow_2[ncut] - mypow_2[1] - 1) {
690  if (isZSps) {
691  sigvsevt[iring2][1]->Fill(chisq, nomHOSig);
692  sig_eta_evt[tmpxet][1]->Fill(chisq, nomHOSig);
693  }
694  variab[iring2][1]->Fill(chisq);
695  }
696  if (ipsall - ips2 == mypow_2[ncut] - mypow_2[2] - 1) {
697  if (isZSps) {
698  sigvsevt[iring2][2]->Fill(trkth, nomHOSig);
699  sig_eta_evt[tmpxet][2]->Fill(trkth, nomHOSig);
700  }
701  variab[iring2][2]->Fill(trkth);
702  }
703  if (ipsall - ips3 == mypow_2[ncut] - mypow_2[3] - 1) {
704  if (isZSps) {
705  sigvsevt[iring2][3]->Fill(trkph, nomHOSig);
706  sig_eta_evt[tmpxet][3]->Fill(trkph, nomHOSig);
707  }
708  variab[iring2][3]->Fill(trkph);
709  }
710  if (ipsall - ips4 == mypow_2[ncut] - mypow_2[4] - 1) {
711  if (isZSps) {
712  sigvsevt[iring2][4]->Fill(1000 * therr, nomHOSig);
713  sig_eta_evt[tmpxet][4]->Fill(1000 * therr, nomHOSig);
714  }
715  variab[iring2][4]->Fill(1000 * therr);
716  }
717  if (ipsall - ips5 == mypow_2[ncut] - mypow_2[5] - 1) {
718  if (isZSps) {
719  sigvsevt[iring2][5]->Fill(1000 * pherr, nomHOSig);
720  sig_eta_evt[tmpxet][5]->Fill(1000 * pherr, nomHOSig);
721  }
722  variab[iring2][5]->Fill(1000 * pherr);
723  }
724  if (ipsall - ips6 == mypow_2[ncut] - mypow_2[6] - 1) {
725  if (isZSps) {
726  sigvsevt[iring2][6]->Fill(tmphoang, (nomHOSig)*abshoang);
727  sig_eta_evt[tmpxet][6]->Fill(tmphoang, (nomHOSig)*abshoang);
728  }
729  variab[iring2][6]->Fill(tmphoang);
730  }
731  if (ipsall - ips7 == mypow_2[ncut] - mypow_2[7] - 1) {
732  if (isZSps) {
733  sigvsevt[iring2][7]->Fill(fabs(trkmm), nomHOSig);
734  sig_eta_evt[tmpxet][7]->Fill(fabs(trkmm), nomHOSig);
735  }
736  variab[iring2][7]->Fill(fabs(trkmm));
737  }
738  if (ipsall - ips8 == mypow_2[ncut] - mypow_2[8] - 1) {
739  if (isZSps) {
740  sigvsevt[iring2][8]->Fill(nmuon, nomHOSig);
741  sig_eta_evt[tmpxet][8]->Fill(nmuon, nomHOSig);
742  }
743  variab[iring2][8]->Fill(nmuon);
744  }
745  if (!m_cosmic) {
746  if (ipsall - ips9 == mypow_2[ncut] - mypow_2[9] - 1) {
747  if (isZSps) {
748  sigvsevt[iring2][9]->Fill(caloen[0], nomHOSig);
749  sig_eta_evt[tmpxet][9]->Fill(caloen[0], nomHOSig);
750  }
751  variab[iring2][9]->Fill(caloen[0]);
752  }
753  }
754  if (ipsall - ips10 == mypow_2[ncut] - mypow_2[10] - 1) {
755  if (isZSps) {
756  sigvsevt[iring2][10]->Fill(tkpt03, nomHOSig);
757  sig_eta_evt[tmpxet][10]->Fill(tkpt03, nomHOSig);
758  }
759  variab[iring2][10]->Fill(tkpt03);
760  }
761  if (ipsall - ips11 == mypow_2[ncut] - mypow_2[11] - 1) {
762  if (isZSps) {
763  sigvsevt[iring2][11]->Fill(hodx, nomHOSig);
764  sig_eta_evt[tmpxet][11]->Fill(hodx, nomHOSig);
765  }
766  variab[iring2][11]->Fill(hodx);
767  }
768  if (ipsall - ips12 == mypow_2[ncut] - mypow_2[12] - 1) {
769  if (isZSps) {
770  sigvsevt[iring2][12]->Fill(hody, nomHOSig);
771  sig_eta_evt[tmpxet][12]->Fill(hody, nomHOSig);
772  }
773  variab[iring2][12]->Fill(hody);
774  }
775 
776  if (ipsall - ips13 == mypow_2[ncut] - mypow_2[13] - 1) {
777  if (isZSps) {
778  sigvsevt[iring2][13]->Fill(htime, nomHOSig);
779  sig_eta_evt[tmpxet][13]->Fill(htime, nomHOSig);
780  }
781  variab[iring2][13]->Fill(htime);
782  }
783 
784  if (isZSps) {
785  sigvsevt[iring2 + ringmx][0]->Fill(abs(ndof), nomHOSig);
786  sig_eta_evt[netamx + tmpxet][0]->Fill(abs(ndof), nomHOSig);
787  }
788  variab[iring2 + 5][0]->Fill(abs(ndof));
789 
790  ncount[iring2][0]++;
791  if (isZSps) {
792  ncount[iring2][1]++;
793  }
794  if (ips0 > 0) {
795  if (isZSps) {
796  ncount[iring2][10]++;
797  sigvsevt[iring2 + ringmx][1]->Fill(chisq, nomHOSig);
798  sig_eta_evt[netamx + tmpxet][1]->Fill(chisq, nomHOSig);
799  }
800  variab[iring2 + ringmx][1]->Fill(chisq);
801  mu_projection[1]->Fill(ieta, iphi);
802  if (ips1 > 0) {
803  if (isZSps) {
804  ncount[iring2][11]++;
805  sigvsevt[iring2 + ringmx][2]->Fill(trkth, nomHOSig);
806  sig_eta_evt[netamx + tmpxet][2]->Fill(trkth, nomHOSig);
807  }
808  variab[iring2 + ringmx][2]->Fill(trkth);
809  mu_projection[2]->Fill(ieta, iphi);
810  if (ips2 > 0) {
811  if (isZSps) {
812  ncount[iring2][12]++;
813  sigvsevt[iring2 + ringmx][3]->Fill(trkph, nomHOSig);
814  sig_eta_evt[netamx + tmpxet][3]->Fill(trkph, nomHOSig);
815  }
816  variab[iring2 + ringmx][3]->Fill(trkph);
817  mu_projection[3]->Fill(ieta, iphi);
818  if (ips3 > 0) {
819  if (isZSps) {
820  ncount[iring2][13]++;
821  sigvsevt[iring2 + ringmx][4]->Fill(1000 * therr, nomHOSig);
822  sig_eta_evt[netamx + tmpxet][4]->Fill(1000 * therr, nomHOSig);
823  }
824  variab[iring2 + ringmx][4]->Fill(1000 * therr);
825  mu_projection[4]->Fill(ieta, iphi);
826  if (ips4 > 0) {
827  if (isZSps) {
828  ncount[iring2][14]++;
829  sigvsevt[iring2 + ringmx][5]->Fill(1000 * pherr, nomHOSig);
830  sig_eta_evt[netamx + tmpxet][5]->Fill(1000 * pherr, nomHOSig);
831  }
832  variab[iring2 + ringmx][5]->Fill(1000 * pherr);
833  mu_projection[5]->Fill(ieta, iphi);
834  if (ips5 > 0) {
835  if (isZSps) {
836  ncount[iring2][15]++;
837  sigvsevt[iring2 + ringmx][6]->Fill(tmphoang, (nomHOSig)*abshoang);
838  sig_eta_evt[netamx + tmpxet][6]->Fill(tmphoang, (nomHOSig)*abshoang);
839  }
840  variab[iring2 + ringmx][6]->Fill(tmphoang);
841  mu_projection[6]->Fill(ieta, iphi);
842  if (ips6 > 0) {
843  if (isZSps) {
844  ncount[iring2][16]++;
845  sigvsevt[iring2 + ringmx][7]->Fill(fabs(trkmm), nomHOSig);
846  sig_eta_evt[netamx + tmpxet][7]->Fill(fabs(trkmm), nomHOSig);
847  }
848  variab[iring2 + ringmx][7]->Fill(fabs(trkmm));
849  mu_projection[7]->Fill(ieta, iphi);
850  if (ips7 > 0) {
851  ncount[iring2][4]++; //Efficiency of Muon detection
852  if (isZSps) {
853  ncount[iring2][17]++;
854  sigvsevt[iring2 + ringmx][8]->Fill(nmuon, nomHOSig);
855  sig_eta_evt[netamx + tmpxet][8]->Fill(nmuon, nomHOSig);
856  }
857  variab[iring2 + ringmx][8]->Fill(nmuon);
858  mu_projection[8]->Fill(ieta, iphi);
859  if (ips8 > 0) {
860  if (!m_cosmic) {
861  if (isZSps) {
862  ncount[iring2][18]++;
863  sigvsevt[iring2 + ringmx][9]->Fill(caloen[0], nomHOSig);
864  sig_eta_evt[netamx + tmpxet][9]->Fill(caloen[0], nomHOSig);
865  }
866  variab[iring2 + ringmx][9]->Fill(caloen[0]);
867  mu_projection[9]->Fill(ieta, iphi);
868  }
869  if (ips9 > 0) {
870  if (isZSps) {
871  ncount[iring2][19]++;
872  sigvsevt[iring2 + ringmx][10]->Fill(tkpt03, nomHOSig);
873  sig_eta_evt[netamx + tmpxet][10]->Fill(tkpt03, nomHOSig);
874  }
875  variab[iring2 + ringmx][10]->Fill(tkpt03);
876  mu_projection[10]->Fill(ieta, iphi);
877  if (ips10 > 0) {
878  ncount[iring2][3]++; //Efficiency of Muon detection
879  if (isZSps) {
880  ncount[iring2][20]++;
881  sigvsevt[iring2 + ringmx][11]->Fill(hodx, nomHOSig);
882  sig_eta_evt[netamx + tmpxet][11]->Fill(hodx, nomHOSig);
883  }
884  variab[iring2 + ringmx][11]->Fill(hodx);
885  mu_projection[11]->Fill(ieta, iphi);
886 
887  if (ips11 > 0) {
888  if (isZSps) {
889  ncount[iring2][21]++;
890  sigvsevt[iring2 + ringmx][12]->Fill(hody, nomHOSig);
891  sig_eta_evt[netamx + tmpxet][12]->Fill(hody, nomHOSig);
892  }
893  variab[iring2 + ringmx][12]->Fill(hody);
894  mu_projection[12]->Fill(ieta, iphi);
895 
896  if (ips12 > 0) {
897  ncount[iring2][2]++; //Efficiency of Muon detection
898  if (isZSps) {
899  ncount[iring2][22]++;
900  sigvsevt[iring2 + ringmx][13]->Fill(htime, nomHOSig);
901  sig_eta_evt[tmpxet + ringmx][13]->Fill(htime, nomHOSig);
902  }
903  variab[iring2 + ringmx][13]->Fill(htime);
904  mu_projection[13]->Fill(ieta, iphi);
905 
906  if (ips13 > 0) {
907  if (isZSps) {
908  ncount[iring2][23]++;
909  mu_projection[14]->Fill(ieta, iphi);
910  }
911  }
912  }
913  }
914  }
915  }
916  }
917  }
918  }
919  }
920  }
921  }
922  }
923  }
924  }
925  if (isZSps) {
926  sigvsevt[iring2 + 2 * ringmx][0]->Fill(abs(ndof), nomHOSig);
927  sigvsevt[iring2 + 2 * ringmx][1]->Fill(chisq, nomHOSig);
928  sigvsevt[iring2 + 2 * ringmx][2]->Fill(trkth, nomHOSig);
929  sigvsevt[iring2 + 2 * ringmx][3]->Fill(trkph, nomHOSig);
930  sigvsevt[iring2 + 2 * ringmx][4]->Fill(1000 * therr, nomHOSig);
931  sigvsevt[iring2 + 2 * ringmx][5]->Fill(1000 * pherr, nomHOSig);
932  if (abshoang > 0.01) {
933  sigvsevt[iring2 + 2 * ringmx][6]->Fill(tmphoang, (nomHOSig)*abshoang);
934  }
935  sigvsevt[iring2 + 2 * ringmx][7]->Fill(fabs(trkmm), nomHOSig);
936  sigvsevt[iring2 + 2 * ringmx][8]->Fill(nmuon, nomHOSig);
937  if (!m_cosmic)
938  sigvsevt[iring2 + 2 * ringmx][9]->Fill(caloen[0], nomHOSig);
939  sigvsevt[iring2 + 2 * ringmx][10]->Fill(tkpt03, nomHOSig);
940  sigvsevt[iring2 + 2 * ringmx][11]->Fill(hodx, nomHOSig);
941  sigvsevt[iring2 + 2 * ringmx][12]->Fill(hody, nomHOSig);
942  sigvsevt[iring2 + 2 * ringmx][13]->Fill(htime, nomHOSig);
943 
944  sig_eta_evt[2 * netamx + tmpxet][0]->Fill(abs(ndof), nomHOSig);
945  sig_eta_evt[2 * netamx + tmpxet][1]->Fill(chisq, nomHOSig);
946  sig_eta_evt[2 * netamx + tmpxet][2]->Fill(trkth, nomHOSig);
947  sig_eta_evt[2 * netamx + tmpxet][3]->Fill(trkph, nomHOSig);
948  sig_eta_evt[2 * netamx + tmpxet][4]->Fill(1000 * therr, nomHOSig);
949  sig_eta_evt[2 * netamx + tmpxet][5]->Fill(1000 * pherr, nomHOSig);
950  if (abshoang > 0.01) {
951  sig_eta_evt[2 * netamx + tmpxet][6]->Fill(tmphoang, (nomHOSig)*abshoang);
952  }
953  sig_eta_evt[2 * netamx + tmpxet][7]->Fill(fabs(trkmm), nomHOSig);
954  sig_eta_evt[2 * netamx + tmpxet][8]->Fill(nmuon, nomHOSig);
955  if (!m_cosmic)
956  sig_eta_evt[2 * netamx + tmpxet][9]->Fill(caloen[0], nomHOSig);
957  sig_eta_evt[2 * netamx + tmpxet][10]->Fill(tkpt03, nomHOSig);
958  sig_eta_evt[2 * netamx + tmpxet][11]->Fill(hodx, nomHOSig);
959  sig_eta_evt[2 * netamx + tmpxet][12]->Fill(hody, nomHOSig);
960  sig_eta_evt[2 * netamx + tmpxet][13]->Fill(htime, nomHOSig);
961  }
962 
963  variab[iring2 + 2 * ringmx][0]->Fill(abs(ndof));
964  variab[iring2 + 2 * ringmx][1]->Fill(chisq);
965  variab[iring2 + 2 * ringmx][2]->Fill(trkth);
966  variab[iring2 + 2 * ringmx][3]->Fill(trkph);
967  variab[iring2 + 2 * ringmx][4]->Fill(1000 * therr);
968  variab[iring2 + 2 * ringmx][5]->Fill(1000 * pherr);
969  variab[iring2 + 2 * ringmx][6]->Fill(tmphoang);
970  variab[iring2 + 2 * ringmx][7]->Fill(fabs(trkmm));
971  variab[iring2 + 2 * ringmx][8]->Fill(nmuon);
972  if (!m_cosmic)
973  variab[iring2 + 2 * ringmx][9]->Fill(caloen[0]);
974  variab[iring2 + 2 * ringmx][10]->Fill(tkpt03);
975  variab[iring2 + 2 * ringmx][11]->Fill(hodx);
976  variab[iring2 + 2 * ringmx][12]->Fill(hody);
977  variab[iring2 + 2 * ringmx][13]->Fill(htime);
978 
979  muonnm->Fill(nmuon);
980  muonmm->Fill(trkmm);
981  muonth->Fill(trkth * 180 / pival);
982  muonph->Fill(trkph * 180 / pival);
983  muonch->Fill(chisq);
984 
985  int iselect = (ipsall == mypow_2[ncut] - 1) ? 1 : 0;
986 
987  if (iselect == 1) {
988  ipass++;
989  sel_muonnm->Fill(nmuon);
990  sel_muonmm->Fill(trkmm);
991  sel_muonth->Fill(trkth * 180 / pival);
992  sel_muonph->Fill(trkph * 180 / pival);
993  sel_muonch->Fill(chisq);
994  if (m_histFill && tmpxet >= 0 && tmpxet < netamx && iphi >= 0 && iphi < nphimx) {
995  ho_indenergy[tmpxet][iphi - 1]->Fill(nomHOSig);
996  }
997  if (m_treeFill) {
998  T1->Fill();
999  }
1000  }
1001  } //for (HOCalibVariableCollection::const_iterator hoC=(*HOCalib).begin(); hoC!=(*HOCalib).end(); hoC++){
1002  } //if (isCosMu)
1003 }
1004 
1005 //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
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HOCalibAnalyzer(const edm::ParameterSet &)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void beginJob() override
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
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
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 char * varcrit[3]
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int getHOieta(int ij)
int invert_HOieta(int ieta)
const bool m_treeFill
const bool m_zeroField
std::vector< HOCalibVariables > HOCalibVariableCollection
collection of HOcalibration variabale
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]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29