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 
26 // system include files
27 #include <memory>
28 
29 // user include files
32 
35 
37 //#include "DataFormats/HOCalibHit/interface/HOCalibVariables.h"
44 
45 #include "TMath.h"
46 #include "TFile.h"
47 #include "TH1F.h"
48 #include "TH2F.h"
49 #include "TTree.h"
50 #include "TProfile.h"
51 #include "TPostScript.h"
52 #include "TCanvas.h"
53 #include "TF1.h"
54 #include "TStyle.h"
55 #include "TMinuit.h"
56 #include "TMath.h"
57 
58 #include <string>
59 
60 #include <iostream>
61 #include <fstream>
62 #include <iomanip>
63 //#include <sstream>
64 
65 
66  //
67  // Look for nearby pixel through eta, phi informations for pixel cross-talk
68  // 1. Look PIXEL code from (eta,phi)
69  // 2. Go to nearby pixel code
70  // 3. Come back to (eta,phi) from pixel code
71  // Though it works, it is a very ugly/crude way to get cross talk, need better algorithms
72  //
73 
74 static const int mapx1[6][3]={{1,4,8}, {12,7,3}, {5,9,13}, {11,6,2}, {16,15,14}, {19,18,17}};
75 
76 static const int mapx2[6][3]={{1,4,8}, {12,7,3}, {5,9,13}, {11,6,2}, {16,15,14}, {-1,-1,-1}};
77 
78 static const int mapx0p[9][2]={{3,1}, {7,4}, {6,5}, {12,8}, {0,0}, {11,9}, {16,13}, {15,14}, {19,17}};
79 static const int mapx0m[9][2]={{17,19}, {14,15}, {13,16}, {9,11}, {0,0}, {8,12}, {5,6}, {4,7}, {1,3}};
80 
81 static const int etamap[4][21]={{-1, 0,3,1, 0,2,3, 1,0,2, -1, 3,1,2, 4,4,4, -1,-1,-1, -1}, //etamap2
82  {-1, 0,3,1, 0,2,3, 1,0,2, -1, 3,1,2, 4,4,4, 5,5,5, -1}, //etamap1
83  {-1, 0,-1,0, 1,2,2, 1,3,5, -1, 5,3,6, 7,7,6, 8,-1,8, -1}, //etamap0p
84  {-1, 8,-1,8, 7,6,6, 7,5,3, -1, 3,5,2, 1,1,2, 0,-1,0, -1}}; //etamap0m
85 
86 static const int phimap[4][21] ={{-1, 0,2,2, 1,0,1, 1,2,1, -1, 0,0,2, 2,1,0, 2,1,0, -1}, //phimap2
87  {-1, 0,2,2, 1,0,1, 1,2,1, -1, 0,0,2, 2,1,0, 2,1,0, -1}, //phimap1
88  {-1, 1,-1,0, 1,1,0, 0,1,1, -1, 0,0,1, 1,0,0, 1,-1,0, -1}, //phimap0p
89  {-1, 0,-1,1, 0,0,1, 1,0,0, -1, 1,1,0, 0,1,1, 0,-1,1, -1}}; //phimap0m
90 //swapped phi map for R0+/R0- (15/03/07)
91 
92 static const int npixleft[21]={0, 0, 1, 2, 0, 4, 5, 6, 0, 8, 0, 0,11, 0,13,14,15, 0,17,18,0};
93 static const int npixrigh[21]={0, 2, 3, 0, 5, 6, 7, 0, 9, 0, 0,12, 0,14,15,16, 0,18,19, 0,0};
94 static const int npixlebt[21]={0, 0, 0, 0, 0, 1, 2, 3, 0, 4, 0, 6, 7, 8, 9, 0,11,13,14,15,0};
95 static const int npixribt[21]={0, 0, 0, 0, 1, 2, 3, 0, 4, 5, 0, 7, 0, 9, 0,11,12,14,15,16,0};
96 static const int npixleup[21]={0, 4, 5, 6, 8, 9, 0,11, 0,13, 0,15,16, 0,17,18,19, 0, 0, 0,0};
97 static const int npixriup[21]={0, 5, 6, 7, 9, 0,11,12,13,14, 0,16, 0,17,18,19, 0, 0, 0, 0,0};
98 
99 static const int netamx=30;
100 static const int nphimx =72;
101 static const int nbgpr = 3;
102 static const int nsgpr = 7;
103 
106 std::vector<float>sig_reg[netamx][nphimx+1];
107 std::vector<float>cro_ssg[netamx][nphimx+1];
108 
109 
110 //#define CORREL
111 //
112 // class decleration
113 //
114 
115 Double_t gausX(Double_t* x, Double_t* par){
116  return par[0]*(TMath::Gaus(x[0], par[1], par[2], kTRUE));
117 }
118 
119 Double_t langaufun(Double_t *x, Double_t *par) {
120 
121  //Fit parameters:
122  //par[0]*par[1]=Width (scale) parameter of Landau density
123  //par[1]=Most Probable (MP, location) parameter of Landau density
124  //par[2]=Total area (integral -inf to inf, normalization constant)
125  //par[3]=Width (sigma) of convoluted Gaussian function
126  //
127  //In the Landau distribution (represented by the CERNLIB approximation),
128  //the maximum is located at x=-0.22278298 with the location parameter=0.
129  //This shift is corrected within this function, so that the actual
130  //maximum is identical to the MP parameter.
131  // /*
132  // Numeric constants
133  Double_t invsq2pi = 0.3989422804014; // (2 pi)^(-1/2)
134  Double_t mpshift = -0.22278298; // Landau maximum location
135 
136  // Control constants
137  Double_t np = 100.0; // number of convolution steps
138  Double_t sc = 5.0; // convolution extends to +-sc Gaussian sigmas
139 
140  // Variables
141  Double_t xx;
142  Double_t mpc;
143  Double_t fland;
144  Double_t sum = 0.0;
145  Double_t xlow,xupp;
146  Double_t step;
147 
148  // MP shift correction
149  mpc = par[1] - mpshift * par[0]*par[1];
150 
151  // Range of convolution integral
152  xlow = x[0] - sc * par[3];
153  xupp = x[0] + sc * par[3];
154 
155  step = (xupp-xlow) / np;
156 
157  // Convolution integral of Landau and Gaussian by sum
158  for(double ij=1.0; ij<=np/2; ij++) {
159  xx = xlow + (ij-.5) * step;
160  fland = TMath::Landau(xx,mpc,par[0]*par[1], kTRUE); // / par[0];
161  sum += fland * TMath::Gaus(x[0],xx,par[3]);
162  xx = xupp - (ij-.5) * step;
163  fland = TMath::Landau(xx,mpc,par[0]*par[1], kTRUE); // / par[0];
164  sum += fland * TMath::Gaus(x[0],xx,par[3]);
165  }
166 
167  return (par[2] * step * sum * invsq2pi / par[3]);
168 }
169 
170 Double_t totalfunc(Double_t* x, Double_t* par){
171  return gausX(x, par) + langaufun(x, &par[3]);
172 }
173 
174 void fcnbg(Int_t &npar, Double_t* gin, Double_t &f, Double_t* par, Int_t flag) {
175 
176  double fval = -par[0];
177  for (unsigned ij=0; ij<cro_ssg[ietafit][iphifit].size(); ij++) {
178  double xval = (double)cro_ssg[ietafit][iphifit][ij];
179  fval +=std::log(std::max(1.e-30,par[0]*TMath::Gaus(xval, par[1], par[2], true)));
180  // fval +=std::log(par[0]*TMath::Gaus(xval, par[1], par[2], 1));
181  }
182  f = -fval;
183 }
184 
185 void fcnsg(Int_t &npar, Double_t* gin, Double_t &f, Double_t* par, Int_t flag) {
186 
187  double xval[2];
188  double fval = -(par[0]+par[5]);
189  for (unsigned ij=0; ij<sig_reg[ietafit][iphifit].size(); ij++) {
190  xval[0] = (double)sig_reg[ietafit][iphifit][ij];
191  fval +=std::log(totalfunc(xval, par));
192  }
193  f = -fval;
194 }
195 
196 void set_mean(double& x, bool mdigi) {
197  if(mdigi) {
198  x = std::min(x, 0.5);
199  x = std::max(x, -0.5);
200  } else {
201  x = std::min(x, 0.1);
202  x = std::max(x, -0.1);
203  }
204 }
205 
206 void set_sigma(double& x, bool mdigi) {
207  if(mdigi) {
208  x = std::min(x, 1.2);
209  x = std::max(x, -1.2);
210  } else {
211  x = std::min(x, 0.24);
212  x = std::max(x, 0.03);
213  }
214 }
215 
216 
217 
219  public:
220  explicit HOCalibAnalyzer(const edm::ParameterSet&);
221  ~HOCalibAnalyzer() override;
222 
223 
224  private:
225 
226  void beginJob() override ;
227  void analyze(const edm::Event&, const edm::EventSetup&) override;
228  void endJob() override ;
229 
230  int getHOieta(int ij) { return (ij<netamx/2) ? -netamx/2 + ij : -netamx/2 + ij + 1;}
231  int invert_HOieta(int ieta) {return (ieta<0) ? netamx/2 + ieta : netamx/2 + ieta - 1;}
232 
233 
234 
235  TFile* theFile;
239 
241  bool m_hotime;
242  bool m_hbtime;
243  bool m_correl;
245  bool m_hbinfo;
248  bool m_figure;
249  bool m_cosmic;
250  bool m_histfit;
252  double m_sigma;
253 
254  static const int ncut = 13;
255  static const int mypow_2_ncut = 8192; // 2^13, should be changed to match ncut
256 
257  int ipass;
258 
259  TTree* T1;
260 
261  TH2F* ho_entry;
262  TH2F* ho_energy;
263  TH2F* ho_energy2;
264  TH2F* ho_rms;
266 
267  TH1F* muonnm;
268  TH1F* muonmm;
269  TH1F* muonth;
270  TH1F* muonph;
271  TH1F* muonch;
272 
273  TH1F* sel_muonnm;
274  TH1F* sel_muonmm;
275  TH1F* sel_muonth;
276  TH1F* sel_muonph;
277  TH1F* sel_muonch;
278 
279  TProfile* hotime[netamx][nphimx];
280  TProfile* hopedtime[netamx][nphimx];
281  TProfile* hbtime[netamx][nphimx];
282 
288 
291 
292  TH1F* mncorrsglb;
293  TH1F* mncorrsgrb;
294  TH1F* mncorrsglu;
295  TH1F* mncorrsgru;
296  TH1F* mncorrsgall;
297 
298  TH1F* mncorrsgl;
299  TH1F* mncorrsgr;
300 
301  TH1F* rmscorrsglb;
302  TH1F* rmscorrsgrb;
303  TH1F* rmscorrsglu;
304  TH1F* rmscorrsgru;
306 
307  TH1F* rmscorrsgl;
308  TH1F* rmscorrsgr;
309 
310  TH1F* nevcorrsglb;
311  TH1F* nevcorrsgrb;
312  TH1F* nevcorrsglu;
313  TH1F* nevcorrsgru;
315 
316  TH1F* nevcorrsgl;
317  TH1F* nevcorrsgr;
318 
320  TH1F* mncorrsgc;
321  TH1F* rmscorrsgc;
322  TH1F* nevcorrsgc;
323 
324  TH1F* sigrsg[netamx][nphimx+1];
325  TH1F* crossg[netamx][nphimx+1];
326  float invang[netamx][nphimx+1];
327 
328  TH1F* mnsigrsg;
329  TH1F* mncrossg;
330 
331  TH1F* rmssigrsg;
332  TH1F* rmscrossg;
333 
334  TH1F* nevsigrsg;
335  TH1F* nevcrossg;
336 
337  TH1F* ho_sig2p[9];
338  TH1F* ho_sig1p[9];
339  TH1F* ho_sig00[9];
340  TH1F* ho_sig1m[9];
341  TH1F* ho_sig2m[9];
342 
343  TH1F* hbhe_sig[9];
344 
345  static const int ringmx=5;
346  static const int sectmx=12;
347  static const int routmx=36;
348  static const int rout12mx=24;
349  static const int neffip=6;
350 
351  TProfile* com_hotime[ringmx][sectmx];
353 
354  TProfile* com_hbtime[ringmx][sectmx];
355 
361 
364 
366 
367  TH1F* com_sigrsg[ringmx][routmx+1];
368  TH1F* com_crossg[ringmx][routmx+1];
369  float com_invang[ringmx][routmx+1];
370 
371  TH1F* ped_evt;
372  TH1F* ped_mean;
373  TH1F* ped_width;
374  TH1F* fit_chi;
375  TH1F* sig_evt;
376  TH1F* fit_sigevt;
377  TH1F* fit_bkgevt;
378  TH1F* sig_mean;
379  TH1F* sig_diff;
380  TH1F* sig_width;
381  TH1F* sig_sigma;
382  TH1F* sig_meanerr;
384  TH1F* sig_signf;
385 
388  TH1F* ped_rms;
389  TH1F* sig_rms;
390 
392 
394  TH1F* stat_eta[netamx];
396  TH1F* peak_eta[netamx];
397 
399  // TH1F* stat_hpdrm[ringmx];
400  // TH1F* statmn_hpdrm[ringmx];
402 
406 
407  TH2F* sig_effi[neffip];
408  TH2F* mean_energy;
409 
410  double fitprm[nsgpr][netamx];
411 
412 
413  TProfile* sigvsevt[15][ncut];
414 
415 
416  // int irun, ievt, itrg1, itrg2, isect, nrecht, nfound, nlost, ndof, nmuon;
417  unsigned ievt, hoflag;
419 
421  hoang, htime, hosig[9], hocorsig[18], hocro, hbhesig[9], caloen[3];
423 
424  int Nevents;
425  int nbn;
426  float alow;
427  float ahigh;
428  float binwid;
429  int irunold;
430 
434  // ----------member data ---------------------------
435 
436 };
437 
438 const int HOCalibAnalyzer::ringmx;
439 const int HOCalibAnalyzer::sectmx;
440 const int HOCalibAnalyzer::routmx;
441 const int HOCalibAnalyzer::rout12mx;
442 const int HOCalibAnalyzer::neffip;
443 
444 //
445 // constants, enums and typedefs
446 //
447 
448 //
449 // static data member definitions
450 //
451 
452 //
453 // constructors and destructor
454 //
455 
457  // It is very likely you want the following in your configuration
458  // hoCalibVariableCollectionTag = cms.InputTag('hoCalibProducer', 'HOCalibVariableCollection')
459 {
460  tok_ho_ = consumes<HOCalibVariableCollection>(iConfig.getParameter<edm::InputTag>("hoCalibVariableCollectionTag"));
461  tok_allho_ = consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInputTag"));
462  //now do what ever initialization is needed
463  ipass = 0;
464  Nevents = 0;
465 
466  theRootFileName = iConfig.getUntrackedParameter<std::string>("RootFileName", "test.root");
467  theoutputtxtFile = iConfig.getUntrackedParameter<std::string>("txtFileName", "test.txt");
468  theoutputpsFile = iConfig.getUntrackedParameter<std::string>("psFileName", "test.ps");
469 
470  m_allHOsignal = iConfig.getUntrackedParameter<bool>("allsignal", false);
471  m_hbinfo = iConfig.getUntrackedParameter<bool>("hbinfo", false);
472  m_hbtime = iConfig.getUntrackedParameter<bool>("hbtime", false);
473  m_hotime = iConfig.getUntrackedParameter<bool>("hotime", false);
474  m_correl = iConfig.getUntrackedParameter<bool>("correl", false);
475  m_checkmap = iConfig.getUntrackedParameter<bool>("checkmap", false);
476  m_combined = iConfig.getUntrackedParameter<bool>("combined", false);
477  m_constant = iConfig.getUntrackedParameter<bool>("get_constant", false);
478  m_figure = iConfig.getUntrackedParameter<bool>("get_figure", true);
479  m_histfit = iConfig.getUntrackedParameter<bool>("histFit", true);
480  m_pedsuppr = iConfig.getUntrackedParameter<bool>("pedSuppr", true);
481  m_cosmic = iConfig.getUntrackedParameter<bool>("cosmic", true);
482  m_sigma = iConfig.getUntrackedParameter<double>("sigma", 0.05);
483 
485 
486  theFile = new TFile(theRootFileName.c_str(), "RECREATE");
487  theFile->cd();
488 
489  T1 = new TTree("T1", "DT+CSC+HO");
490 
491  T1->Branch("irun",&irun,"irun/I");
492  T1->Branch("ievt",&ievt,"ievt/i");
493 
494  // T1->Branch("itrg1",&itrg1,"itrg1/I");
495  // T1->Branch("itrg2",&itrg2,"itrg2/I");
496 
497  T1->Branch("isect",&isect,"isect/I");
498  T1->Branch("isect2",&isect2,"isect2/I");
499  T1->Branch("ndof",&ndof,"ndof/I");
500  T1->Branch("nmuon",&nmuon,"nmuon/I");
501 
502  T1->Branch("ilumi", &ilumi, "ilumi/I");
503  if (!m_cosmic) {
504  T1->Branch("inslumi",&inslumi,"inslumi/F");
505  T1->Branch("nprim", &nprim, "nprim/I");
506  T1->Branch("tkpt03", &tkpt03," tkpt03/F");
507  T1->Branch("ecal03", &ecal03," ecal03/F");
508  T1->Branch("hcal03", &hcal03," hcal03/F");
509  }
510 
511  T1->Branch("trkdr",&trkdr,"trkdr/F");
512  T1->Branch("trkdz",&trkdz,"trkdz/F");
513 
514  T1->Branch("trkvx",&trkvx,"trkvx/F");
515  T1->Branch("trkvy",&trkvy,"trkvy/F");
516  T1->Branch("trkvz",&trkvz,"trkvz/F");
517  T1->Branch("trkmm",&trkmm,"trkmm/F");
518  T1->Branch("trkth",&trkth,"trkth/F");
519  T1->Branch("trkph",&trkph,"trkph/F");
520 
521  T1->Branch("chisq",&chisq,"chisq/F");
522  T1->Branch("therr",&therr,"therr/F");
523  T1->Branch("pherr",&pherr,"pherr/F");
524  T1->Branch("hodx",&hodx,"hodx/F");
525  T1->Branch("hody",&hody,"hody/F");
526  T1->Branch("hoang",&hoang,"hoang/F");
527 
528  T1->Branch("momatho", &momatho,"momatho/F");
529  T1->Branch("hoflag",&hoflag,"hoflag/i");
530  T1->Branch("htime",&htime,"htime/F");
531  T1->Branch("hosig",hosig,"hosig[9]/F");
532  T1->Branch("hocro",&hocro,"hocro/F");
533  T1->Branch("hocorsig",hocorsig,"hocorsig[18]/F");
534  T1->Branch("caloen",caloen,"caloen[3]/F");
535 
536 
537  if (m_hbinfo) { // #ifdef HBINFO
538  T1->Branch("hbhesig",hbhesig,"hbhesig[9]/F");
539  } //m_hbinfo #endif
540 
541  char name[200];
542  char title[200];
543 
544  if (m_allHOsignal) {
545  ho_entry = fs->make<TH2F>("ho_entry", "ho entry", netamx+1, -netamx/2-0.5, netamx/2+0.5, nphimx, 0.5, nphimx+0.5);
546 
547  ho_energy = fs->make<TH2F>("ho_energy", "ho energy (GeV)", netamx+1, -netamx/2-0.5, netamx/2+0.5, nphimx, 0.5, nphimx+0.5);
548 
549  ho_energy2 = fs->make<TH2F>("ho_energy2", "ho energy2 (GeV*GeV)", netamx+1, -netamx/2-0.5, netamx/2+0.5, nphimx, 0.5, nphimx+0.5);
550 
551  ho_rms = fs->make<TH2F>("ho_rms", "ho rms (GeV)", netamx+1, -netamx/2-0.5, netamx/2+0.5, nphimx, 0.5, nphimx+0.5);
552 
553  for (int ij=0; ij<netamx; ij++) {
554  int ieta=getHOieta(ij);
555  for (int jk=0; jk<nphimx; jk++) {
556  sprintf(name, "ho_indenergy_%i_%i", ij, jk);
557  sprintf(title, "ho IndEnergy (GeV) i#eta=%i i#phi=%i", ieta, jk+1);
558  ho_indenergy[ij][jk] = fs->make<TH1F> (name, title, 120, -5., 55.);
559  }
560  }
561  }
562 
563  muonnm = fs->make<TH1F>("muonnm", "No of muon", 10, -0.5, 9.5);
564  muonmm = fs->make<TH1F>("muonmm", "P_{mu}", 200, -100., 100.);
565  muonth = fs->make<TH1F>("muonth", "{Theta}_{mu}", 180, 0., 180.);
566  muonph = fs->make<TH1F>("muonph", "{Phi}_{mu}", 180, -180., 180.);
567  muonch = fs->make<TH1F>("muonch", "{chi^2}/ndf", 100, 0., 1000.);
568 
569  sel_muonnm = fs->make<TH1F>("sel_muonnm", "No of muon(sel)", 10, -0.5, 9.5);
570  sel_muonmm = fs->make<TH1F>("sel_muonmm", "P_{mu}(sel)", 200, -100., 100.);
571  sel_muonth = fs->make<TH1F>("sel_muonth", "{Theta}_{mu}(sel)", 180, 0., 180.);
572  sel_muonph = fs->make<TH1F>("sel_muonph", "{Phi}_{mu}(sel)", 180, -180., 180.);
573  sel_muonch = fs->make<TH1F>("sel_muonch", "{chi^2}/ndf(sel)", 100, 0., 1000.);
574 
575 
576  int nbin = 50; //40;// 45; //50; //55; //60; //55; //45; //40; //50;
577  alow = -2.0;// -1.85; //-1.90; // -1.95; // -2.0;
578  ahigh = 8.0;// 8.15; // 8.10; // 8.05; // 8.0;
579 
580  float tmpwid = (ahigh-alow)/nbin;
581  nbn = int(-alow/tmpwid)+1;
582  if (nbn <0) nbn = 0;
583  if (nbn>nbin) nbn = nbin;
584 
585 
586  edm::LogInfo("HOCalib") <<"nbin "<< nbin<<" "<<alow<<" "<<ahigh<<" "<<tmpwid<<" "<<nbn;
587 
588  for (int ij=0; ij<15; ij++) {
589 
590  sprintf(title, "sigvsndof_ring%i", ij+1);
591  sigvsevt[ij][0] = fs->make<TProfile>(title, title, 50, 0., 50.,-9., 20.);
592 
593  sprintf(title, "sigvschisq_ring%i", ij+1);
594  sigvsevt[ij][1] = fs->make<TProfile>(title, title, 50, 0., 30.,-9., 20.);
595 
596  sprintf(title, "sigvsth_ring%i", ij+1);
597  sigvsevt[ij][2] = fs->make<TProfile>(title, title, 50, .7, 2.4,-9., 20.);
598 
599  sprintf(title, "sigvsph_ring%i", ij+1);
600  sigvsevt[ij][3] = fs->make<TProfile>(title, title, 50, -2.4, -0.7,-9., 20.);
601 
602  sprintf(title, "sigvstherr_ring%i", ij+1);
603  sigvsevt[ij][4] = fs->make<TProfile>(title, title, 50, 0., 0.2,-9., 20.);
604 
605  sprintf(title, "sigvspherr_ring%i", ij+1);
606  sigvsevt[ij][5] = fs->make<TProfile>(title, title, 50, 0., 0.2,-9., 20.);
607 
608  sprintf(title, "sigvsdircos_ring%i", ij+1);
609  sigvsevt[ij][6] = fs->make<TProfile>(title, title, 50, 0.5, 1.,-9., 20.);
610 
611  sprintf(title, "sigvstrkmm_ring%i", ij+1);
612  sigvsevt[ij][7] = fs->make<TProfile>(title, title, 50, 0., 50.,-9., 20.);
613 
614  sprintf(title, "sigvsnmuon_ring%i", ij+1);
615  sigvsevt[ij][8] = fs->make<TProfile>(title, title, 5, 0.5, 5.5,-9., 20.);
616 
617  sprintf(title, "sigvserr_ring%i", ij+1);
618  sigvsevt[ij][9] = fs->make<TProfile>(title, title, 50, 0., .3, -9., 20.);
619 
620  sprintf(title, "sigvsaccx_ring%i", ij+1);
621  sigvsevt[ij][10] = fs->make<TProfile>(title, title, 100, -25., 25., -9., 20.);
622 
623  sprintf(title, "sigvsaccy_ring%i", ij+1);
624  sigvsevt[ij][11] = fs->make<TProfile>(title, title, 100, -25., 25., -9., 20.);
625 
626  sprintf(title, "sigvscalo_ring%i", ij+1);
627  sigvsevt[ij][12] = fs->make<TProfile>(title, title, 100, 0., 15., -9., 20.);
628  }
629 
630  for (int jk=0; jk<netamx; jk++) {
631  int ieta = (jk<15) ? jk+1 : 14-jk;
632  for (int ij=0; ij<nphimx+1; ij++) {
633  if (ij==nphimx) {
634  sprintf(title, "sig_eta%i_allphi", ieta);
635  } else {
636  sprintf(title, "sig_eta%i_phi%i", ieta,ij+1);
637  }
638  sigrsg[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
639  if (ij==nphimx) {
640  sprintf(title, "ped_eta%i_allphi", ieta);
641  } else {
642  sprintf(title, "ped_eta%i_phi%i", ieta,ij+1);
643  }
644  crossg[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
645  }
646 
647  for (int ij=0; ij<nphimx; ij++) {
648  if (m_hotime) { //#ifdef HOTIME
649  sprintf(title, "hotime_eta%i_phi%i", (jk<=14) ? jk+1 : 14-jk, ij+1);
650  hotime[jk][ij] = fs->make<TProfile>(title, title, 10, -0.5, 9.5, -1.0, 30.0);
651 
652  sprintf(title, "hopedtime_eta%i_phi%i", (jk<=14) ? jk+1 : 14-jk, ij+1);
653  hopedtime[jk][ij] = fs->make<TProfile>(title, title, 10, -0.5, 9.5, -1.0, 30.0);
654 
655  } //m_hotime #endif
656  if (m_hbtime) { //#ifdef HBTIME
657  sprintf(title, "hbtime_eta%i_phi%i", (jk<=15) ? jk+1 : 15-jk, ij+1);
658  hbtime[jk][ij] = fs->make<TProfile>(title, title, 10, -0.5, 9.5, -1.0, 30.0);
659  } //m_hbtime #endif
660 
661  if (m_correl) { //#ifdef CORREL
662  sprintf(title, "corrsg_eta%i_phi%i_leftbottom", ieta,ij+1);
663  corrsglb[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
664 
665  sprintf(title, "corrsg_eta%i_phi%i_rightbottom", ieta,ij+1);
666  corrsgrb[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
667 
668  sprintf(title, "corrsg_eta%i_phi%i_leftup", ieta,ij+1);
669  corrsglu[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
670 
671  sprintf(title, "corrsg_eta%i_phi%i_rightup", ieta,ij+1);
672  corrsgru[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
673 
674  sprintf(title, "corrsg_eta%i_phi%i_all", ieta,ij+1);
675  corrsgall[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
676 
677  sprintf(title, "corrsg_eta%i_phi%i_left", ieta,ij+1);
678  corrsgl[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
679 
680  sprintf(title, "corrsg_eta%i_phi%i_right", ieta,ij+1);
681  corrsgr[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
682  } //m_correl #endif
683  if (m_checkmap) {// #ifdef CHECKMAP
684  sprintf(title, "corrsg_eta%i_phi%i_centrl", ieta,ij+1);
685  corrsgc[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
686  } //m_checkmap #endif
687  }
688  }
689 
690  mnsigrsg = fs->make<TH1F>("mnsigrsg","mnsigrsg", netamx*nphimx+ringmx*routmx, -0.5, netamx*nphimx+ringmx*routmx -0.5);
691  rmssigrsg = fs->make<TH1F>("rmssigrsg","rmssigrsg", netamx*nphimx+ringmx*routmx, -0.5, netamx*nphimx+ringmx*routmx -0.5);
692  nevsigrsg = fs->make<TH1F>("nevsigrsg","nevsigrsg", netamx*nphimx+ringmx*routmx, -0.5, netamx*nphimx+ringmx*routmx -0.5);
693 
694  mncrossg = fs->make<TH1F>("mncrossg","mncrossg", netamx*nphimx+ringmx*routmx, -0.5, netamx*nphimx+ringmx*routmx -0.5);
695  rmscrossg = fs->make<TH1F>("rmscrossg","rmscrossg", netamx*nphimx+ringmx*routmx, -0.5, netamx*nphimx+ringmx*routmx -0.5);
696  nevcrossg = fs->make<TH1F>("nevcrossg","nevcrossg", netamx*nphimx+ringmx*routmx, -0.5, netamx*nphimx+ringmx*routmx -0.5);
697 
698 
699  for (int ij=0; ij<neffip; ij++) {
700  if (ij==0) {
701  sprintf(title, "Total projected muon in tower");
702  sprintf(name, "total_evt");
703  } else {
704  sprintf(title, "Efficiency with sig >%i #sigma", ij);
705  sprintf(name, "Effi_with_gt%i_sig", ij);
706  }
707  sig_effi[ij] = fs->make<TH2F>(name, title, netamx+1, -netamx/2-0.5, netamx/2+0.5, nphimx, 0.5, nphimx+0.5);
708  }
709 
710  sprintf(title, "Mean Energy of all towers");
711  sprintf(name, "mean_energy");
712  mean_energy = fs->make<TH2F>(name, title, netamx+1, -netamx/2-0.5, netamx/2+0.5, nphimx, 0.5, nphimx+0.5);
713 
714  if (m_correl) { //#ifdef CORREL
715  mncorrsglb = fs->make<TH1F>("mncorrsglb","mncorrsglb", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
716  rmscorrsglb = fs->make<TH1F>("rmscorrsglb","rmscorrsglb", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
717  nevcorrsglb = fs->make<TH1F>("nevcorrsglb","nevcorrsglb", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
718 
719  mncorrsgrb = fs->make<TH1F>("mncorrsgrb","mncorrsgrb", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
720  rmscorrsgrb = fs->make<TH1F>("rmscorrsgrb","rmscorrsgrb", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
721  nevcorrsgrb = fs->make<TH1F>("nevcorrsgrb","nevcorrsgrb", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
722 
723  mncorrsglu = fs->make<TH1F>("mncorrsglu","mncorrsglu", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
724  rmscorrsglu = fs->make<TH1F>("rmscorrsglu","rmscorrsglu", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
725  nevcorrsglu = fs->make<TH1F>("nevcorrsglu","nevcorrsglu", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
726 
727  mncorrsgru = fs->make<TH1F>("mncorrsgru","mncorrsgru", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
728  rmscorrsgru = fs->make<TH1F>("rmscorrsgru","rmscorrsgru", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
729  nevcorrsgru = fs->make<TH1F>("nevcorrsgru","nevcorrsgru", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
730 
731  mncorrsgall = fs->make<TH1F>("mncorrsgall","mncorrsgall", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
732  rmscorrsgall = fs->make<TH1F>("rmscorrsgall","rmscorrsgall", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
733  nevcorrsgall = fs->make<TH1F>("nevcorrsgall","nevcorrsgall", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
734 
735  mncorrsgl = fs->make<TH1F>("mncorrsgl","mncorrsgl", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
736  rmscorrsgl = fs->make<TH1F>("rmscorrsgl","rmscorrsgl", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
737  nevcorrsgl = fs->make<TH1F>("nevcorrsgl","nevcorrsgl", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
738 
739  mncorrsgr = fs->make<TH1F>("mncorrsgr","mncorrsgr", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
740  rmscorrsgr = fs->make<TH1F>("rmscorrsgr","rmscorrsgr", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
741  nevcorrsgr = fs->make<TH1F>("nevcorrsgr","nevcorrsgr", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
742  } //m_correl #endif
743 
744  if (m_checkmap) { //#ifdef CHECKMAP
745  mncorrsgc = fs->make<TH1F>("mncorrsgc","mncorrsgc", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
746  rmscorrsgc = fs->make<TH1F>("rmscorrsgc","rmscorrsgc", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
747  nevcorrsgc = fs->make<TH1F>("nevcorrsgc","nevcorrsgc", netamx*nphimx+60, -0.5, netamx*nphimx+59.5);
748  } //m_checkmap #endif
749 
750  if (m_combined) { //#ifdef COMBINED
751  for (int jk=0; jk<ringmx; jk++) {
752 
753  for (int ij=0; ij<routmx+1; ij++) {
754  if (jk!=2 && ij>rout12mx) continue;
755  int phmn = 3*ij-1;
756  int phmx = 3*ij+1;
757  if (jk==2) {phmn = 2*ij-1; phmx=2*ij;}
758  if (phmn <=0) phmn = nphimx+phmn;
759  if (phmx <=0) phmx = nphimx+phmx;
760 
761  if ((jk==2 && ij==routmx) || (jk!=2 && ij==rout12mx)) {
762  sprintf(title, "sig_ring%i_allrm", jk-2);
763  sprintf(name, "sig_ring%i_allrm", jk-2);
764  } else {
765  sprintf(title, "sig_ring%i_phi%i-%i", jk-2,phmn,phmx);
766  sprintf(name, "sig_ring%i_rout%i", jk-2,ij+1);
767  }
768  com_sigrsg[jk][ij] = fs->make<TH1F>(name, title, nbin, alow, ahigh);
769  if ((jk==2 && ij==routmx) || (jk!=2 && ij==rout12mx)) {
770  sprintf(title, "ped_ring%i_allrm", jk-2);
771  sprintf(name, "ped_ring%i_allrm", jk-2);
772  } else {
773  sprintf(title, "ped_ring%i_phi%i-%i", jk-2,phmn, phmx);
774  sprintf(name, "ped_ring%i_rout%i", jk-2,ij+1);
775  }
776  com_crossg[jk][ij] = fs->make<TH1F>(name, title, nbin, alow, ahigh);
777  }
778 
779  for (int ij=0; ij<sectmx; ij++) {
780  if (m_hotime) { //#ifdef HOTIME
781  sprintf(title, "com_hotime_ring%i_sect%i", jk-2, ij+1);
782  com_hotime[jk][ij] = fs->make<TProfile>(title, title, 10, -0.5, 9.5, -1.0, 30.0);
783 
784  sprintf(title, "com_hopedtime_ring%i_sect%i", jk-2, ij+1);
785  com_hopedtime[jk][ij] = fs->make<TProfile>(title, title, 10, -0.5, 9.5, -1.0, 30.0);
786  } //m_hotime #endif
787  if (m_hbtime){ //#ifdef HBTIME
788  sprintf(title, "_com_hbtime_ring%i_serrct%i", jk-2, ij+1);
789  com_hbtime[jk][ij] = fs->make<TProfile>(title, title, 10, -0.5, 9.5, -1.0, 30.0);
790  } //m_hbtime #endif
791 
792  if (m_correl) { //#ifdef CORREL
793  sprintf(title, "com_corrsg_ring%i_sect%i_leftbottom", jk-2,ij+1);
794  com_corrsglb[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
795 
796  sprintf(title, "com_corrsg_ring%i_sect%i_rightbottom", jk-2,ij+1);
797  com_corrsgrb[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
798 
799  sprintf(title, "com_corrsg_ring%i_sect%i_leftup", jk-2,ij+1);
800  com_corrsglu[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
801 
802  sprintf(title, "com_corrsg_ring%i_sect%i_rightup", jk-2,ij+1);
803  com_corrsgru[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
804 
805  sprintf(title, "com_corrsg_ring%i_sect%i_all", jk-2,ij+1);
806  com_corrsgall[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
807 
808  sprintf(title, "com_corrsg_ring%i_sect%i_left", jk-2,ij+1);
809  com_corrsgl[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
810 
811  sprintf(title, "com_corrsg_ring%i_sect%i_right", jk-2,ij+1);
812  com_corrsgr[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
813  } //m_correl #endif
814 
815  if (m_checkmap) { // #ifdef CHECKMAP
816  sprintf(title, "com_corrsg_ring%i_sect%i_centrl", jk-2,ij+1);
817  com_corrsgc[jk][ij] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
818  } //m_checkmap #endif
819  }
820  }
821  } //m_combined #endif
822 
823  for (int ij=-1; ij<=1; ij++) {
824  for (int jk=-1; jk<=1; jk++) {
825  int kl = 3*(ij+1)+jk+1;
826 
827  sprintf(title, "hosct2p_eta%i_phi%i", ij, jk);
828  ho_sig2p[kl] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
829 
830  sprintf(title, "hosct1p_eta%i_phi%i", ij, jk);
831  ho_sig1p[kl] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
832 
833  sprintf(title, "hosct00_eta%i_phi%i", ij, jk);
834  ho_sig00[kl] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
835 
836  sprintf(title, "hosct1m_eta%i_phi%i", ij, jk);
837  ho_sig1m[kl] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
838 
839  sprintf(title, "hosct2m_eta%i_phi%i", ij, jk);
840  ho_sig2m[kl] = fs->make<TH1F>(title, title, nbin, alow, ahigh);
841 
842  if (m_hbinfo) { // #ifdef HBINFO
843  sprintf(title, "hbhesig_eta%i_phi%i", ij, jk);
844  hbhe_sig[kl] = fs->make<TH1F>(title, title, 51, -10.5, 40.5);
845  } //m_hbinfo #endif
846  }
847  }
848 
849  if (m_constant) {
850  ped_evt = fs->make<TH1F>("ped_evt", "ped_evt", netamx*nphimx, -0.5, netamx*nphimx-0.5);
851  ped_mean = fs->make<TH1F>("ped_mean", "ped_mean", netamx*nphimx, -0.5, netamx*nphimx-0.5);
852  ped_width = fs->make<TH1F>("ped_width", "ped_width", netamx*nphimx, -0.5, netamx*nphimx-0.5);
853 
854  fit_chi = fs->make<TH1F>("fit_chi", "fit_chi", netamx*nphimx, -0.5, netamx*nphimx-0.5);
855  sig_evt = fs->make<TH1F>("sig_evt", "sig_evt", netamx*nphimx, -0.5, netamx*nphimx-0.5);
856  fit_sigevt = fs->make<TH1F>("fit_sigevt", "fit_sigevt", netamx*nphimx, -0.5, netamx*nphimx-0.5);
857  fit_bkgevt = fs->make<TH1F>("fit_bkgevt", "fit_bkgevt", netamx*nphimx, -0.5, netamx*nphimx-0.5);
858  sig_mean = fs->make<TH1F>("sig_mean", "sig_mean", netamx*nphimx, -0.5, netamx*nphimx-0.5);
859  sig_diff = fs->make<TH1F>("sig_diff", "sig_diff", netamx*nphimx, -0.5, netamx*nphimx-0.5);
860  sig_width = fs->make<TH1F>("sig_width", "sig_width", netamx*nphimx, -0.5, netamx*nphimx-0.5);
861  sig_sigma = fs->make<TH1F>("sig_sigma", "sig_sigma", netamx*nphimx, -0.5, netamx*nphimx-0.5);
862  sig_meanerr = fs->make<TH1F>("sig_meanerr", "sig_meanerr", netamx*nphimx, -0.5, netamx*nphimx-0.5);
863  sig_meanerrp = fs->make<TH1F>("sig_meanerrp", "sig_meanerrp", netamx*nphimx, -0.5, netamx*nphimx-0.5);
864  sig_signf = fs->make<TH1F>("sig_signf", "sig_signf", netamx*nphimx, -0.5, netamx*nphimx-0.5);
865 
866  ped_statmean = fs->make<TH1F>("ped_statmean", "ped_statmean", netamx*nphimx, -0.5, netamx*nphimx-0.5);
867  sig_statmean = fs->make<TH1F>("sig_statmean", "sig_statmean", netamx*nphimx, -0.5, netamx*nphimx-0.5);
868  ped_rms = fs->make<TH1F>("ped_rms", "ped_rms", netamx*nphimx, -0.5, netamx*nphimx-0.5);
869  sig_rms = fs->make<TH1F>("sig_rms", "sig_rms", netamx*nphimx, -0.5, netamx*nphimx-0.5);
870 
871  const_eta_phi = fs->make<TH2F>("const_eta_phi", "const_eta_phi", netamx+1, -(netamx+1)/2., (netamx+1)/2., nphimx, 0.5, nphimx+0.5);
872 
873  for (int ij=0; ij<netamx; ij++) {
874  int ieta = (ij<15) ? ij+1 : 14-ij;
875  sprintf(title, "Cont_Eta_%i", ieta);
876  const_eta[ij] = fs->make<TH1F>(title, title, nphimx, 0.5, nphimx+0.5);
877 
878  sprintf(title, "Peak_Eta_%i", ieta);
879  peak_eta[ij] = fs->make<TH1F>(title, title, nphimx, 0.5, nphimx+0.5);
880  }
881 
882  for (int ij=0; ij<ringmx; ij++) {
883  int iring = ij-2;
884  int iread = (ij==2) ? routmx : rout12mx;
885  sprintf(title, "Cont_hpdrm_%i", iring);
886  const_hpdrm[ij] = fs->make<TH1F>(title, title, iread, 0.5, iread+0.5);
887 
888  sprintf(title, "Peak_hpdrm_%i", iring);
889  peak_hpdrm[ij] = fs->make<TH1F>(title, title, iread, 0.5, iread+0.5);
890  }
891 
892  mean_phi_hst = fs->make<TH1F>("mean_phi_hst", "mean_phi_hst", netamx+1, -(netamx+1)/2., (netamx+1)/2.);
893  mean_phi_ave = fs->make<TH1F>("mean_phi_ave", "mean_phi_ave", netamx+1, -(netamx+1)/2., (netamx+1)/2.);
894 
895  mean_eta_ave = fs->make<TH1F>("mean_eta_ave", "mean_eta_ave", nphimx, 0.5, nphimx+0.5);
896 
897  } //m_constant
898 
899  for (int ij=0; ij<netamx; ij++) {
900  int ieta = (ij<15) ? ij+1 : 14-ij;
901 
902  sprintf(title, "Stat_Eta_%i", ieta);
903  stat_eta[ij] = fs->make<TH1F>(title, title, nphimx, 0.5, nphimx+0.5);
904 
905  sprintf(title, "#mu(stat)_Eta_%i", ieta);
906  statmn_eta[ij] = fs->make<TH1F>(title, title, nphimx, 0.5, nphimx+0.5);
907  }
908 
909  for (int jk=0; jk<netamx; jk++) {
910  for (int ij=0; ij<nphimx; ij++) {
911  invang[jk][ij] = 0.0;
912  }
913  }
914  for (int jk=0; jk<ringmx; jk++) {
915  for (int ij=0; ij<routmx+1; ij++) {
916  com_invang[jk][ij] = 0.0;
917  }
918  }
919 
920 }
921 
922 
924 {
925 
926  // do anything here that needs to be done at desctruction time
927  // (e.g. close files, deallocate resources etc.)
928 
929  theFile->cd();
930  theFile->Write();
931  theFile->Close();
932  edm::LogInfo("HOCalib") <<" Ttoal events = "<< Nevents<<" Selected events # is "<<ipass;
933 }
934 
935 
936 //
937 // member functions
938 //
939 
940 // ------------ method called to for each event ------------
941 void
943 {
944 
945  // calcualte these once (and avoid the pow(int,int) ambiguities for c++)
946  int mypow_2_0 = 1; // 2^0
947  int mypow_2_1 = 2; // 2^1
948  int mypow_2_2 = 4; // 2^2
949 
950  int mypow_2_3 = 8; // 2^3
951  int mypow_2_4 = 16; // 2^4
952  int mypow_2_5 = 32; // 2^5
953  int mypow_2_6 = 64; // 2^6
954  int mypow_2_7 = 128; // 2^7
955  int mypow_2_8 = 256; // 2^8
956  int mypow_2_9 = 512; // 2^9
957  int mypow_2_10 = 1024; // 2^10
958  int mypow_2_11 = 2048; // 2^11
959  int mypow_2_12 = 4096; // 2^12
960 
961  /*
962  //FIXGM Put this is initialiser
963  int mapx1[6][3]={{1,4,8}, {12,7,3}, {5,9,13}, {11,6,2}, {16,15,14}, {19,18,17}};
964  // int etamap1[21]={-1, 0,3,1, 0,2,3, 1,0,2, -1, 3,1,2, 4,4,4, 5,5,5, -1};
965  // int phimap1[21]={-1, 0,2,2, 1,0,1, 1,2,1, -1, 0,0,2, 2,1,0, 2,1,0,-1};
966 
967  int mapx2[6][3]={{1,4,8}, {12,7,3}, {5,9,13}, {11,6,2}, {16,15,14}, {-1,-1,-1}};
968  // int etamap2[21]={-1, 0,3,1, 0,2,3, 1,0,2, -1, 3,1,2, 4,4,4, -1,-1,-1, -1};
969  // int phimap2[21]={-1, 0,2,2, 1,0,1, 1,2,1, -1, 0,0,2, 2,1,0, 2, 1, 0, -1};
970 
971  int mapx0p[9][2]={{3,1}, {7,4}, {6,5}, {12,8}, {0,0}, {11,9}, {16,13}, {15,14}, {19,17}};
972  int mapx0m[9][2]={{17,19}, {14,15}, {13,16}, {9,11}, {0,0}, {8,12}, {5,6}, {4,7}, {1,3}};
973 
974  // int etamap0p[21]={-1, 0,-1,0, 1,2,2, 1,3,5, -1, 5,3,6, 7,7,6, 8,-1,8, -1};
975  // int phimap0p[21]={-1, 1,-1,0, 1,1,0, 0,1,1, -1, 0,0,1, 1,0,0, 1,-1,0, -1};
976 
977  // int etamap0m[21]={-1, 8,-1,8, 7,6,6, 7,5,3, -1, 3,5,2, 1,1,2, 0,-1,0, -1};
978  // int phimap0m[21]={-1, 0,-1,1, 0,0,1, 1,0,0, -1, 1,1,0, 0,1,1, 0,-1,1, -1};
979 
980  int etamap[4][21]={{-1, 0,3,1, 0,2,3, 1,0,2, -1, 3,1,2, 4,4,4, -1,-1,-1, -1}, //etamap2
981  {-1, 0,3,1, 0,2,3, 1,0,2, -1, 3,1,2, 4,4,4, 5,5,5, -1}, //etamap1
982  {-1, 0,-1,0, 1,2,2, 1,3,5, -1, 5,3,6, 7,7,6, 8,-1,8, -1}, //etamap0p
983  {-1, 8,-1,8, 7,6,6, 7,5,3, -1, 3,5,2, 1,1,2, 0,-1,0, -1}}; //etamap0m
984 
985  int phimap[4][21] ={{-1, 0,2,2, 1,0,1, 1,2,1, -1, 0,0,2, 2,1,0, 2,1,0, -1}, //phimap2
986  {-1, 0,2,2, 1,0,1, 1,2,1, -1, 0,0,2, 2,1,0, 2,1,0, -1}, //phimap1
987  {-1, 1,-1,0, 1,1,0, 0,1,1, -1, 0,0,1, 1,0,0, 1,-1,0, -1}, //phimap0p
988  {-1, 0,-1,1, 0,0,1, 1,0,0, -1, 1,1,0, 0,1,1, 0,-1,1, -1}}; //phimap0m
989  //swapped phi map for R0+/R0- (15/03/07)
990  for (int ij=0; ij<4; ij++) {
991  for (int jk=0; jk<21; jk++) {
992  edm::LogInfo("HOCalib") <<"ieta "<<ij<<" "<<jk<<" "<<etamap[ij][jk];
993  }
994  }
995 
996  // Character convention for R+/-1/2
997  // int npixleft[21] = {-1, F, Q,-1, M, D, J,-1, T,-1, C,-1, R, P, H,-1, N, G};
998  // int npixrigh[21] = { Q, S,-1, D, J, L,-1, K,-1, E,-1, P, H, B,-1, G, A,-1};
999 
1000  // int npixlb1[21]={-1,-1,-1,-1, F, Q, S,-1, M, J, L, T, K,-1, C, R, P, H};
1001  // int npixrb1[21]={-1,-1,-1, F, Q, S,-1, M, D, L,-1, K,-1, C, E, P, H, B};
1002  // int npixlu1[21]={ M, D, J, T, K,-1, C,-1, R, H, B,-1, N, G, A,-1,-1,-1};
1003  // int npixru1[21]={ D, J, L, K,-1, C, E, R, P, B,-1, N, G, A,-1,-1,-1,-1};
1004 
1005  int npixleft[21]={0, 0, 1, 2, 0, 4, 5, 6, 0, 8, 0, 0,11, 0,13,14,15, 0,17,18,0};
1006  int npixrigh[21]={0, 2, 3, 0, 5, 6, 7, 0, 9, 0, 0,12, 0,14,15,16, 0,18,19, 0,0};
1007  int npixlebt[21]={0, 0, 0, 0, 0, 1, 2, 3, 0, 4, 0, 6, 7, 8, 9, 0,11,13,14,15,0};
1008  int npixribt[21]={0, 0, 0, 0, 1, 2, 3, 0, 4, 5, 0, 7, 0, 9, 0,11,12,14,15,16,0};
1009  int npixleup[21]={0, 4, 5, 6, 8, 9, 0,11, 0,13, 0,15,16, 0,17,18,19, 0, 0, 0,0};
1010  int npixriup[21]={0, 5, 6, 7, 9, 0,11,12,13,14, 0,16, 0,17,18,19, 0, 0, 0, 0,0};
1011  */
1012 
1013  int iaxxx = 0;
1014  int ibxxx = 0;
1015 
1016  Nevents++;
1017 
1018  using namespace edm;
1019 
1020  float pival = acos(-1.);
1021  irunold = irun = iEvent.id().run();
1022  ievt = iEvent.id().event();
1023  ilumi = iEvent.luminosityBlock();
1024 
1025  if (m_allHOsignal) {
1027  iEvent.getByToken(tok_allho_,hoht);
1028  if (hoht.isValid() && !(*hoht).empty()) {
1029  ho_entry->Fill(-1., -1.); //Count of total number of entries
1030  for (HORecHitCollection::const_iterator ij=(*hoht).begin(); ij!=(*hoht).end(); ij++){
1031  HcalDetId id =(*ij).id();
1032  int tmpeta= id.ieta();
1033  int tmpphi= id.iphi();
1034  float signal = (*ij).energy();
1035  ho_entry->Fill(tmpeta, tmpphi);
1036  ho_energy->Fill(tmpeta, tmpphi, signal);
1037  ho_energy2->Fill(tmpeta, tmpphi, signal*signal);
1038 
1039  int inveta = invert_HOieta(tmpeta);
1040  ho_indenergy[inveta][tmpphi-1]->Fill(signal);
1041  }
1042  }
1043  }
1044 
1045 
1046 
1047 
1048 
1050  bool isCosMu = true;
1051  try {
1052  iEvent.getByToken(tok_ho_, HOCalib);
1053 
1054  } catch ( cms::Exception &iEvent ) { isCosMu = false; }
1055  if (Nevents%5000==1) edm::LogInfo("HOCalib") <<"nmuon event # "<<Nevents<<" Run # "<<iEvent.id().run()<<" Evt # "<<iEvent.id().event()<<" "<<ipass;
1056 
1057  if (isCosMu && !(*HOCalib).empty() ) {
1058  nmuon = (*HOCalib).size();
1059  for (HOCalibVariableCollection::const_iterator hoC=(*HOCalib).begin(); hoC!=(*HOCalib).end(); hoC++){
1060  // itrg1 = (*hoC).trig1;
1061  // itrg2 = (*hoC).trig2;
1062  trkdr = (*hoC).trkdr;
1063  trkdz = (*hoC).trkdz;
1064 
1065  trkvx = (*hoC).trkvx;
1066  trkvy = (*hoC).trkvy;
1067  trkvz = (*hoC).trkvz;
1068 
1069  trkmm = (*hoC).trkmm;
1070  trkth = (*hoC).trkth;
1071  trkph = (*hoC).trkph;
1072 
1073  ndof = (int)(*hoC).ndof;
1074  // nrecht = (int)(*hoC).nrecht;
1075  chisq = (*hoC).chisq;
1076  momatho = (*hoC).momatho;
1077 
1078  therr = (*hoC).therr;
1079  pherr = (*hoC).pherr;
1080  trkph = (*hoC).trkph;
1081 
1082  if (!m_cosmic) {
1083  nprim = (*hoC).nprim;
1084  inslumi = (*hoC).inslumi;
1085  tkpt03 = (*hoC).tkpt03;
1086  ecal03 = (*hoC).ecal03;
1087  hcal03 = (*hoC).hcal03;
1088  }
1089 
1090  isect = (*hoC).isect;
1091  isect2 = (*hoC).isect2;
1092  hodx = (*hoC).hodx;
1093  hody = (*hoC).hody;
1094  hoang = (*hoC).hoang;
1095  htime = (*hoC).htime;
1096  hoflag = (*hoC).hoflag;
1097  for (int ij=0; ij<9; ij++) { hosig[ij] = (*hoC).hosig[ij];} //edm::LogInfo("HOCalib")<<"hosig "<<i<<" "<<hosig[ij];}
1098  for (int ij=0; ij<18; ij++) { hocorsig[ij] = (*hoC).hocorsig[ij];} // edm::LogInfo("HOCalib")<<"hocorsig "<<i<<" "<<hocorsig[ij];}
1099  hocro = (*hoC).hocro;
1100  for (int ij=0; ij<3; ij++) { caloen[ij] = (*hoC).caloen[ij];}
1101 
1102  if (m_hbinfo) { for (int ij=0; ij<9; ij++) { hbhesig[ij] = (*hoC).hbhesig[ij];}} // edm::LogInfo("HOCalib")<<"hbhesig "<<ij<<" "<<hbhesig[ij];}}
1103 
1104  T1->Fill();
1105 
1106  int ipsall=0;
1107  int ips0=0;
1108  int ips1=0;
1109  int ips2=0;
1110  int ips3=0;
1111  int ips4=0;
1112  int ips5=0;
1113  int ips6=0;
1114  int ips7=0;
1115  int ips8=0;
1116  int ips9=0;
1117  int ips10 =0;
1118  int ips11 =0;
1119  int ips12 = 0;
1120 
1121  // int iselect3 = 0;
1122  // if (ndof >=15 && chisq <30) iselect3 = 1;
1123 
1124  if (isect <0) continue; //FIXGM Is it proper place ?
1125  if (fabs(trkth-pival/2)<0.000001) continue; //22OCT07
1126 
1127  int ieta = int((abs(isect)%10000)/100.)-50; //an offset to acodate -ve eta values
1128  if (abs(ieta)>=16) continue;
1129  int iphi = abs(isect)%100;
1130 
1131  int tmpsect = int((iphi + 1)/6.) + 1;
1132  if (tmpsect >12) tmpsect = 1;
1133 
1134  int iring = 0;
1135  int tmpeta = ieta + 4; //For pixel mapping
1136  if (ieta >=-15 && ieta <=-11) {iring = -2; tmpeta =-11-ieta; } //abs(ieta)-11;}
1137  if (ieta >=-10 && ieta <=-5) {iring = -1; tmpeta =-5-ieta; } // abs(ieta)-5;}
1138  if (ieta >= 5 && ieta <= 10) {iring = 1; tmpeta =ieta-5; }
1139  if (ieta >= 11 && ieta <= 15) {iring = 2; tmpeta =ieta-11;}
1140 
1141  int iring2 = iring + 2;
1142 
1143  int tmprout = int((iphi + 1)/3.) + 1;
1144  int tmproutmx =routmx;
1145  if (iring==0) {
1146  tmprout = int((iphi + 1)/2.) + 1;
1147  if (tmprout >routmx) tmprout = 1;
1148  } else {
1149  if (tmprout >rout12mx) tmprout = 1;
1150  tmproutmx =rout12mx;
1151  }
1152 
1153  // CRUZET1
1154  if (m_cosmic) {
1155  /* GMA temoparily change to increase event size at 3 & 9 O'clock position */
1156  if (abs(ndof) >=20 && abs(ndof) <40) {ips0 = (int)mypow_2_0; ipsall += ips0;}
1157  if (chisq >0 && chisq<15) {ips1 = (int)mypow_2_1; ipsall +=ips1;} //18Jan2008
1158  if (fabs(trkth-pival/2) <21.5) {ips2 = (int)mypow_2_2; ipsall +=ips2;} //No nead for pp evt
1159  if (fabs(trkph+pival/2) <21.5) {ips3 = (int)mypow_2_3; ipsall +=ips3;} //No nead for pp evt
1160 
1161  if (therr <0.02) {ips4 = (int)mypow_2_4; ipsall +=ips4;}
1162  if (pherr <0.0002) {ips5 = (int)mypow_2_5; ipsall +=ips5;}
1163  if (fabs(hoang) >0.30) {ips6 = (int)mypow_2_6; ipsall +=ips6;}
1164  if (fabs(trkmm) >0.100) {ips7 = (int)mypow_2_7; ipsall +=ips7;}
1165  // if (nmuon ==1) {ips8 = (int)mypow_2_8; ipsall +=ips8;}
1166  if (nmuon >=1 && nmuon <=4) {ips8 = (int)mypow_2_8; ipsall +=ips8;}
1167 
1168  if (iring2==2) {
1169  if (fabs(hodx)<100 && fabs(hodx)>2 && fabs(hocorsig[8]) <40 && fabs(hocorsig[8]) >2 )
1170  {ips10=(int)mypow_2_10;ipsall +=ips10;}
1171 
1172  if (fabs(hody)<100 && fabs(hody)>2 && fabs(hocorsig[9]) <40 && fabs(hocorsig[9]) >2 )
1173  {ips11=(int)mypow_2_11;ipsall +=ips11;}
1174 
1175  } else {
1176  if (fabs(hodx)<100 && fabs(hodx)>2 )
1177  {ips10=(int)mypow_2_10;ipsall +=ips10;}
1178 
1179  if (fabs(hody)<100 && fabs(hody)>2)
1180  {ips11=(int)mypow_2_11;ipsall +=ips11;}
1181  }
1182  if (caloen[0] ==0) { ips12=(int)mypow_2_12;ipsall +=ips12;}
1183  } else {
1184  //csa08
1185  if (abs(ndof) >=20 && abs(ndof) <40) {ips0 = (int)mypow_2_0; ipsall += ips0;}
1186  if (chisq >0 && chisq<15) {ips1 = (int)mypow_2_1; ipsall +=ips1;} //18Jan2008
1187  if (fabs(trkth-pival/2) <21.5) {ips2 = (int)mypow_2_2; ipsall +=ips2;} //No nead for pp evt
1188  if (fabs(trkph+pival/2) <21.5) {ips3 = (int)mypow_2_3; ipsall +=ips3;} //No nead for pp evt
1189 
1190  if (therr <0.02) {ips4 = (int)mypow_2_4; ipsall +=ips4;}
1191  if (pherr <0.0002) {ips5 = (int)mypow_2_5; ipsall +=ips5;}
1192  if (fabs(hoang) >0.30) {ips6 = (int)mypow_2_6; ipsall +=ips6;}
1193  if (fabs(trkmm) >4.0) {ips7 = (int)mypow_2_7; ipsall +=ips7;}
1194  if (nmuon >=1 && nmuon <=2) {ips8 = (int)mypow_2_8; ipsall +=ips8;}
1195 
1196  if (iring2==2) {
1197  if (fabs(hodx)<100 && fabs(hodx)>2 && fabs(hocorsig[8]) <40 && fabs(hocorsig[8]) >2 )
1198  {ips10=(int)mypow_2_10;ipsall +=ips10;}
1199 
1200  if (fabs(hody)<100 && fabs(hody)>2 && fabs(hocorsig[9]) <40 && fabs(hocorsig[9]) >2 )
1201  {ips11=(int)mypow_2_11;ipsall +=ips11;}
1202 
1203  } else {
1204  if (fabs(hodx)<100 && fabs(hodx)>2 )
1205  {ips10=(int)mypow_2_10;ipsall +=ips10;}
1206 
1207  if (fabs(hody)<100 && fabs(hody)>2)
1208  {ips11=(int)mypow_2_11;ipsall +=ips11;}
1209  }
1210  // if (m_cosmic || (caloen[0] >0.5 && caloen[0]<5.0)) {ips12=(int)pow_2_12;ipsall +=ips12;}
1211  if (ndof >0 && caloen[0]<5.0) {ips12=(int)mypow_2_12;ipsall +=ips12;}
1212  /* */
1213  }
1214 
1215  if (htime >-40 && htime <60) {ips9=(int)mypow_2_9;ipsall +=ips9;}
1216 
1217  if (ipsall-ips0==mypow_2_ncut-mypow_2_0-1) sigvsevt[iring2][0]->Fill(abs(ndof), hosig[4]);
1218  if (ipsall-ips1==mypow_2_ncut-mypow_2_1-1) sigvsevt[iring2][1]->Fill(chisq, hosig[4]);
1219  if (ipsall-ips2==mypow_2_ncut-mypow_2_2-1) sigvsevt[iring2][2]->Fill(trkth, hosig[4]);
1220  if (ipsall-ips3==mypow_2_ncut-mypow_2_3-1) sigvsevt[iring2][3]->Fill(trkph, hosig[4]);
1221  if (ipsall-ips4==mypow_2_ncut-mypow_2_4-1) sigvsevt[iring2][4]->Fill(therr, hosig[4]);
1222  if (ipsall-ips5==mypow_2_ncut-mypow_2_5-1) sigvsevt[iring2][5]->Fill(pherr, hosig[4]);
1223  if (ipsall-ips6==mypow_2_ncut-mypow_2_6-1) sigvsevt[iring2][6]->Fill(hoang, hosig[4]);
1224  if (ipsall-ips7==mypow_2_ncut-mypow_2_7-1) sigvsevt[iring2][7]->Fill(fabs(trkmm), hosig[4]);
1225  if (ipsall-ips8==mypow_2_ncut-mypow_2_8-1) sigvsevt[iring2][8]->Fill(nmuon, hosig[4]);
1226  if (ipsall-ips9==mypow_2_ncut-mypow_2_9-1) sigvsevt[iring2][9]->Fill(htime, hosig[4]);
1227  if (ipsall-ips10==mypow_2_ncut-mypow_2_10-1) sigvsevt[iring2][10]->Fill(hodx, hosig[4]);
1228  if (ipsall-ips11==mypow_2_ncut-mypow_2_11-1) sigvsevt[iring2][11]->Fill(hody, hosig[4]);
1229  if (!m_cosmic) {
1230  if (ipsall-ips12==mypow_2_ncut-mypow_2_12-1) sigvsevt[iring2][12]->Fill(caloen[0], hosig[4]);
1231  }
1232 
1233  sigvsevt[iring2+5][0]->Fill(abs(ndof), hosig[4]);
1234  if (ips0 >0) {
1235  sigvsevt[iring2+5][1]->Fill(chisq, hosig[4]);
1236  if (ips1 >0) {
1237  sigvsevt[iring2+5][2]->Fill(trkth, hosig[4]);
1238  if (ips2 >0) {
1239  sigvsevt[iring2+5][3]->Fill(trkph, hosig[4]);
1240  if (ips3 >0) {
1241  sigvsevt[iring2+5][4]->Fill(therr, hosig[4]);
1242  if (ips4 >0) {
1243  sigvsevt[iring2+5][5]->Fill(pherr, hosig[4]);
1244  if (ips5 >0) {
1245  sigvsevt[iring2+5][6]->Fill(hoang, hosig[4]);
1246  if (ips6 >0) {
1247  sigvsevt[iring2+5][7]->Fill(fabs(trkmm), hosig[4]);
1248  if (ips7 >0) {
1249  sigvsevt[iring2+5][8]->Fill(nmuon, hosig[4]);
1250  if (ips8 >0) {
1251  sigvsevt[iring2+5][9]->Fill(htime, hosig[4]);
1252  if (ips9 >0) {
1253  sigvsevt[iring2+5][10]->Fill(hodx, hosig[4]);
1254  if (ips10>0) {
1255  sigvsevt[iring2+5][11]->Fill(hody, hosig[4]);
1256  if (ips11>0) {
1257  if (!m_cosmic) sigvsevt[iring2+5][12]->Fill(caloen[0], hosig[4]);
1258  }
1259  }
1260  }
1261  }
1262  }
1263  }
1264  }
1265  }
1266  }
1267  }
1268  }
1269  }
1270 
1271  sigvsevt[iring2+10][0]->Fill(abs(ndof), hosig[4]);
1272  sigvsevt[iring2+10][1]->Fill(chisq, hosig[4]);
1273  sigvsevt[iring2+10][2]->Fill(trkth, hosig[4]);
1274  sigvsevt[iring2+10][3]->Fill(trkph, hosig[4]);
1275  sigvsevt[iring2+10][4]->Fill(therr, hosig[4]);
1276  sigvsevt[iring2+10][5]->Fill(pherr, hosig[4]);
1277  sigvsevt[iring2+10][6]->Fill(hoang, hosig[4]);
1278  sigvsevt[iring2+10][7]->Fill(fabs(trkmm), hosig[4]);
1279  sigvsevt[iring2+10][8]->Fill(nmuon, hosig[4]);
1280  sigvsevt[iring2+10][9]->Fill(htime, hosig[4]);
1281  sigvsevt[iring2+10][10]->Fill(hodx, hosig[4]);
1282  sigvsevt[iring2+10][11]->Fill(hody, hosig[4]);
1283  if (!m_cosmic) sigvsevt[iring2+10][12]->Fill(caloen[0], hosig[4]);
1284 
1285  int iselect = (ipsall == mypow_2_ncut - 1) ? 1 : 0;
1286 
1287  if (hocro !=-100.0 && hocro <-50.0) hocro +=100.;
1288 
1289  muonnm->Fill(nmuon);
1290  muonmm->Fill(trkmm);
1291  muonth->Fill(trkth*180/pival);
1292  muonph->Fill(trkph*180/pival);
1293  muonch->Fill(chisq);
1294 
1295  if (iselect==1) {
1296  ipass++;
1297  sel_muonnm->Fill(nmuon);
1298  sel_muonmm->Fill(trkmm);
1299  sel_muonth->Fill(trkth*180/pival);
1300  sel_muonph->Fill(trkph*180/pival);
1301  sel_muonch->Fill(chisq);
1302  }
1303 
1304  // if (iselect3) T1->Fill();
1305 
1306  int tmpphi = (iphi + 1)%3; //pixel mapping
1307  int npixel = 0;
1308  int itag = -1;
1309  int iflip = 0;
1310  int fact = 2;
1311 
1312  if (iring ==0) {
1313  tmpphi = (iphi+1)%2;
1314  if (tmpsect==2 || tmpsect==3 || tmpsect==6 || tmpsect==7 || tmpsect==10 || tmpsect==11) {
1315  npixel = mapx0p[tmpeta][tmpphi];
1316  itag = 2;
1317  } else {
1318  npixel = mapx0m[tmpeta][tmpphi];
1319  itag = 3;
1320  }
1321  } else {
1322  fact = 3;
1323  if (tmpsect%2==1) iflip =1;
1324  if (abs(iring)==1) {
1325  npixel = mapx1[tmpeta][(iflip==0) ? tmpphi : abs(tmpphi-2)];
1326  itag = 1;
1327  } else {
1328  npixel = mapx2[tmpeta][(iflip==0) ? tmpphi : abs(tmpphi-2)];
1329  itag = 0;
1330  }
1331  }
1332 
1333  int tmpeta1 = (ieta>0) ? ieta -1 : -ieta +14;
1334 
1335  //Histogram filling for noise study: phi shift according to DTChamberAnalysis
1336  int tmpphi1 = iphi -1 ; //(iphi+6 <=nphimx) ? iphi+5 : iphi+5-nphimx;
1337 
1338  int iselect2=0;
1339  if (hosig[4]!=-100) {
1340  if (m_cosmic) {
1341  if (caloen[2]<=0.0) iselect2=1;
1342  } else {
1343  if (caloen[2]<=3.0) iselect2=1;
1344  }
1345  }
1346 
1347  // edm::LogInfo("HOCalib") <<"cosmic "<<hosig[4]<<" "<<caloen[3]<<" "<<int(iselect2)<<" "<<int(m_cosmic);
1348 
1349 
1350  if (iselect2==1) {
1351  int tmpphi2 = iphi - 1;
1352  tmpphi2 = (iphi+6 <=nphimx) ? iphi+5 : iphi+5-nphimx;
1353 
1354  int tmpsect2 = int((tmpphi2 + 2)/6.) + 1;
1355  if (tmpsect2 >12) tmpsect2 = 1;
1356 
1357  int tmprout2 = int((tmpphi2 + 2)/3.) + 1;
1358  if (iring==0) {
1359  tmprout2 = int((tmpphi2 + 2)/2.) + 1;
1360  if (tmprout2 >routmx) tmprout2 = 1;
1361  } else {
1362  if (tmprout2 >rout12mx) tmprout2 = 1;
1363  }
1364 
1365  if (cro_ssg[tmpeta1][tmpphi2].size()<4000) {
1366  if (hocro>alow && hocro<ahigh) {
1367  if (!m_histfit) cro_ssg[tmpeta1][tmpphi2].push_back(hocro);
1368  crossg[tmpeta1][tmpphi2]->Fill(hocro);
1369  }
1370  }
1371 
1372  if (tmpphi2 >=0 && tmpphi2 <nphimx) {
1373  crossg[tmpeta1][nphimx]->Fill(hocro);
1374  }
1375  if (m_combined) {
1376  com_crossg[iring2][tmprout2-1]->Fill(hocro);
1377  com_crossg[iring2][tmproutmx]->Fill(hocro);
1378  }
1379  }
1380 
1381  if (iselect==1) {
1382  for (int ij=0; ij<neffip; ij++) {
1383  if (ij==0) {
1384  sig_effi[ij]->Fill(ieta, iphi, 1.);
1385  } else {
1386  if (hosig[4] >ij*m_sigma) {
1387  sig_effi[ij]->Fill(ieta, iphi, 1.);
1388  }
1389  }
1390  }
1391 
1392  tmpphi1 = iphi - 1;
1393 
1394  if (sig_reg[tmpeta1][tmpphi1].size()<4000 ) {
1395  if (hosig[4]>-50&& hosig[4] <15) {
1396  sigrsg[tmpeta1][tmpphi1]->Fill(hosig[4]);
1397  if (!m_histfit && hosig[4]<=ahigh/2.) sig_reg[tmpeta1][tmpphi1].push_back(hosig[4]);
1398  invang[tmpeta1][tmpphi1] += 1./fabs(hoang);
1399  }
1400  }
1401 
1402  if (tmpphi1 >=0 && tmpphi1 <nphimx) { //GREN
1403  sigrsg[tmpeta1][nphimx]->Fill(hosig[4]);
1404  invang[tmpeta1][nphimx] += 1./fabs(hoang);
1405  }
1406 
1407  if (m_combined) { //#ifdef COMBINED
1408  com_sigrsg[iring2][tmprout-1]->Fill(hosig[4]);
1409  com_invang[iring2][tmprout-1] += 1./fabs(hoang);
1410 
1411  com_sigrsg[iring2][tmproutmx]->Fill(hosig[4]);
1412  com_invang[iring2][tmproutmx] += 1./fabs(hoang);
1413  } //m_combined #endif
1414 
1415  if (m_checkmap || m_correl) { //#ifdef CHECKMAP
1416  tmpeta = etamap[itag][npixel];
1417  tmpphi = phimap[itag][npixel];
1418  if (tmpeta>=0 && tmpphi >=0) {
1419  if (iflip !=0) tmpphi = abs(tmpphi-2);
1420  if (int((hocorsig[fact*tmpeta+tmpphi]-hosig[4])*10000)/10000.!=0) {
1421  iaxxx++;
1422  edm::LogInfo("HOCalib")<<"iring2xxx "<<irun<<" "<<ievt<<" "<<isect<<" "<<iring<<" "<<tmpsect<<" "<<ieta<<" "<<iphi<<" "<<npixel<<" "<<tmpeta<<" "<<tmpphi<<" "<<tmpeta1<<" "<<tmpphi1<<" itag "<<itag<<" "<<iflip<<" "<<fact<<" "<<hocorsig[fact*tmpeta+tmpphi]<<" "<<fact*tmpeta+tmpphi<<" "<<hosig[4]<<" "<<hodx<<" "<<hody;
1423 
1424  for (int ij=0; ij<18; ij++) {edm::LogInfo("HOCalib") <<" "<<ij<<" "<<hocorsig[ij];}
1425  edm::LogInfo("HOCalib")<<" ix "<<iaxxx<<" "<<ibxxx;
1426  } else { ibxxx++; }
1427 
1428  corrsgc[tmpeta1][tmpphi1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1429  if (m_combined) { //#ifdef COMBINED
1430  com_corrsgc[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1431  } //m_combined #endif
1432  }
1433  } //m_checkmap #endif
1434 
1435  if (m_correl) { //#ifdef CORREL
1436  float allcorsig = 0.0;
1437 
1438  tmpeta = etamap[itag][npixleft[npixel]];
1439  tmpphi = phimap[itag][npixleft[npixel]];
1440 
1441  if (tmpeta>=0 && tmpphi >=0) {
1442  if (iflip !=0) tmpphi = abs(tmpphi-2);
1443  corrsgl[tmpeta1][tmpphi1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1444  allcorsig +=hocorsig[fact*tmpeta+tmpphi];
1445  if (m_combined) { //#ifdef COMBINED
1446  com_corrsgl[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1447  } //m_combined #endif
1448  }
1449 
1450  tmpeta = etamap[itag][npixrigh[npixel]];
1451  tmpphi = phimap[itag][npixrigh[npixel]];
1452  if (tmpeta>=0 && tmpphi >=0) {
1453  if (iflip !=0) tmpphi = abs(tmpphi-2);
1454  corrsgr[tmpeta1][tmpphi1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1455  allcorsig +=hocorsig[fact*tmpeta+tmpphi];
1456  if (m_combined) { // #ifdef COMBINED
1457  com_corrsgr[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1458  } //m_combined #endif
1459  }
1460 
1461  tmpeta = etamap[itag][npixlebt[npixel]];
1462  tmpphi = phimap[itag][npixlebt[npixel]];
1463  if (tmpeta>=0 && tmpphi >=0) {
1464  if (iflip !=0) tmpphi = abs(tmpphi-2);
1465  corrsglb[tmpeta1][tmpphi1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1466  allcorsig +=hocorsig[fact*tmpeta+tmpphi];
1467  if (m_combined){ //#ifdef COMBINED
1468  com_corrsglb[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1469  } //m_combined #endif
1470  }
1471 
1472  tmpeta = etamap[itag][npixribt[npixel]];
1473  tmpphi = phimap[itag][npixribt[npixel]];
1474  if (tmpeta>=0 && tmpphi >=0) {
1475  if (iflip !=0) tmpphi = abs(tmpphi-2);
1476  corrsgrb[tmpeta1][tmpphi1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1477  allcorsig +=hocorsig[fact*tmpeta+tmpphi];
1478  if (m_combined) { // #ifdef COMBINED
1479  com_corrsgrb[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1480  } //m_combined #endif
1481  }
1482 
1483  tmpeta = etamap[itag][npixleup[npixel]];
1484  tmpphi = phimap[itag][npixleup[npixel]];
1485  if (tmpeta>=0 && tmpphi >=0) {
1486  if (iflip !=0) tmpphi = abs(tmpphi-2);
1487  corrsglu[tmpeta1][tmpphi1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1488  allcorsig +=hocorsig[fact*tmpeta+tmpphi];
1489  if (m_combined) {// #ifdef COMBINED
1490  com_corrsglu[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1491  } //m_combined #endif
1492  }
1493 
1494  tmpeta = etamap[itag][npixriup[npixel]];
1495  tmpphi = phimap[itag][npixriup[npixel]];
1496  if (tmpeta>=0 && tmpphi >=0) {
1497  if (iflip !=0) tmpphi = abs(tmpphi-2);
1498  corrsgru[tmpeta1][tmpphi1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1499  allcorsig +=hocorsig[fact*tmpeta+tmpphi];
1500  if (m_combined) { // #ifdef COMBINED
1501  com_corrsgru[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]);
1502  } //m_combined #endif
1503  }
1504  corrsgall[tmpeta1][tmpphi1]->Fill(allcorsig);
1505  if (m_combined) { // #ifdef COMBINED
1506  com_corrsgall[iring2][tmpsect-1]->Fill(allcorsig);
1507  } //m_combined #endif
1508 
1509 
1510  } //m_correl #endif
1511  for (int k=0; k<9; k++) {
1512  switch (iring)
1513  {
1514  case 2 : ho_sig2p[k]->Fill(hosig[k]); break;
1515  case 1 : ho_sig1p[k]->Fill(hosig[k]); break;
1516  case 0 : ho_sig00[k]->Fill(hosig[k]); break;
1517  case -1 : ho_sig1m[k]->Fill(hosig[k]); break;
1518  case -2 : ho_sig2m[k]->Fill(hosig[k]); break;
1519  }
1520  if (m_hbinfo) { // #ifdef HBINFO
1521  hbhe_sig[k]->Fill(hbhesig[k]);
1522  // edm::LogInfo("HOCalib") <<"hbhe "<<k<<" "<<hbhesig[k];
1523  } //m_hbinfo #endif
1524  }
1525  } //if (iselect==1)
1526 
1527 
1528  } //for (HOCalibVariableCollection::const_iterator hoC=(*HOCalib).begin(); hoC!=(*HOCalib).end(); hoC++){
1529 
1530  } //if (isCosMu)
1531 
1532 }
1533 
1534 
1535 // ------------ method called once each job just before starting event loop ------------
1536 void
1538 {
1539 }
1540 
1541 // ------------ method called once each job just after ending the event loop ------------
1542 void
1544 
1545  theFile->cd();
1546 
1547  if (m_allHOsignal) {
1548  for (int jk=0; jk<ho_energy->GetNbinsX(); jk++) {
1549  for (int kl=0; kl<ho_energy->GetNbinsY(); kl++) {
1550  double entry=ho_entry->GetBinContent(jk+1, kl+1);
1551  if (entry <1.) entry=1.;
1552 
1553  double energy = ho_energy->GetBinContent(jk+1, kl+1)/entry;
1554  double energy2 = ho_energy2->GetBinContent(jk+1, kl+1)/entry;
1555  double rms = sqrt(energy2 - energy*energy);
1556 
1557  double xval = ho_energy->GetXaxis()->GetBinCenter(jk+1);
1558  double yval = ho_energy->GetYaxis()->GetBinCenter(kl+1);
1559 
1560  ho_rms->Fill(xval, yval, rms);
1561  }
1562  }
1563  }
1564 
1565  for (int ij=0; ij<nphimx; ij++) {
1566  for (int jk=0; jk<netamx; jk++) {
1567 
1568  nevsigrsg->Fill(netamx*ij+jk, sigrsg[jk][ij]->GetEntries());
1569  mnsigrsg->Fill(netamx*ij+jk, sigrsg[jk][ij]->GetMean());
1570  rmssigrsg->Fill(netamx*ij+jk, sigrsg[jk][ij]->GetRMS());
1571 
1572  nevcrossg->Fill(netamx*ij+jk, crossg[jk][ij]->GetEntries());
1573  mncrossg->Fill(netamx*ij+jk, crossg[jk][ij]->GetMean());
1574  rmscrossg->Fill(netamx*ij+jk, crossg[jk][ij]->GetRMS());
1575 
1576  if (m_correl) { //#ifdef CORREL
1577 
1578  nevcorrsglb->Fill(netamx*ij+jk, corrsglb[jk][ij]->GetEntries());
1579  mncorrsglb->Fill(netamx*ij+jk, corrsglb[jk][ij]->GetMean());
1580  rmscorrsglb->Fill(netamx*ij+jk, corrsglb[jk][ij]->GetRMS());
1581 
1582  nevcorrsgrb->Fill(netamx*ij+jk, corrsgrb[jk][ij]->GetEntries());
1583  mncorrsgrb->Fill(netamx*ij+jk, corrsgrb[jk][ij]->GetMean());
1584  rmscorrsgrb->Fill(netamx*ij+jk, corrsgrb[jk][ij]->GetRMS());
1585 
1586  nevcorrsglu->Fill(netamx*ij+jk, corrsglu[jk][ij]->GetEntries());
1587  mncorrsglu->Fill(netamx*ij+jk, corrsglu[jk][ij]->GetMean());
1588  rmscorrsglu->Fill(netamx*ij+jk, corrsglu[jk][ij]->GetRMS());
1589 
1590  nevcorrsgru->Fill(netamx*ij+jk, corrsgru[jk][ij]->GetEntries());
1591  mncorrsgru->Fill(netamx*ij+jk, corrsgru[jk][ij]->GetMean());
1592  rmscorrsgru->Fill(netamx*ij+jk, corrsgru[jk][ij]->GetRMS());
1593 
1594  nevcorrsgall->Fill(netamx*ij+jk, corrsgall[jk][ij]->GetEntries());
1595  mncorrsgall->Fill(netamx*ij+jk, corrsgall[jk][ij]->GetMean());
1596  rmscorrsgall->Fill(netamx*ij+jk, corrsgall[jk][ij]->GetRMS());
1597 
1598  nevcorrsgl->Fill(netamx*ij+jk, corrsgl[jk][ij]->GetEntries());
1599  mncorrsgl->Fill(netamx*ij+jk, corrsgl[jk][ij]->GetMean());
1600  rmscorrsgl->Fill(netamx*ij+jk, corrsgl[jk][ij]->GetRMS());
1601 
1602  nevcorrsgr->Fill(netamx*ij+jk, corrsgr[jk][ij]->GetEntries());
1603  mncorrsgr->Fill(netamx*ij+jk, corrsgr[jk][ij]->GetMean());
1604  rmscorrsgr->Fill(netamx*ij+jk, corrsgr[jk][ij]->GetRMS());
1605  } //m_correl #endif
1606  if (m_checkmap) { //#ifdef CHECKMAP
1607  nevcorrsgc->Fill(netamx*ij+jk, corrsgc[jk][ij]->GetEntries());
1608  mncorrsgc->Fill(netamx*ij+jk, corrsgc[jk][ij]->GetMean());
1609  rmscorrsgc->Fill(netamx*ij+jk, corrsgc[jk][ij]->GetRMS());
1610  } //m_checkmap #endif
1611  }
1612  }
1613 
1614  if (m_combined) { // #ifdef COMBINED
1615  for (int jk=0; jk<ringmx; jk++) {
1616  for (int ij=0; ij<routmx; ij++) {
1617  if (jk!=2 && ij>=rout12mx) continue;
1618  nevsigrsg->Fill(netamx*nphimx+ringmx*ij+jk, com_sigrsg[jk][ij]->GetEntries());
1619  mnsigrsg->Fill(netamx*nphimx+ringmx*ij+jk, com_sigrsg[jk][ij]->GetMean());
1620  rmssigrsg->Fill(netamx*nphimx+ringmx*ij+jk, com_sigrsg[jk][ij]->GetRMS());
1621 
1622  nevcrossg->Fill(netamx*nphimx+ringmx*ij+jk, com_crossg[jk][ij]->GetEntries());
1623  mncrossg->Fill(netamx*nphimx+ringmx*ij+jk, com_crossg[jk][ij]->GetMean());
1624  rmscrossg->Fill(netamx*nphimx+ringmx*ij+jk, com_crossg[jk][ij]->GetRMS());
1625  }
1626  }
1627 
1628  for (int ij=0; ij<sectmx; ij++) {
1629  for (int jk=0; jk<ringmx; jk++) {
1630  if (m_correl) { // #ifdef CORREL
1631  nevcorrsglb->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsglb[jk][ij]->GetEntries());
1632  mncorrsglb->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsglb[jk][ij]->GetMean());
1633  rmscorrsglb->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsglb[jk][ij]->GetRMS());
1634 
1635  nevcorrsgrb->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgrb[jk][ij]->GetEntries());
1636  mncorrsgrb->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgrb[jk][ij]->GetMean());
1637  rmscorrsgrb->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgrb[jk][ij]->GetRMS());
1638 
1639  nevcorrsglu->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsglu[jk][ij]->GetEntries());
1640  mncorrsglu->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsglu[jk][ij]->GetMean());
1641  rmscorrsglu->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsglu[jk][ij]->GetRMS());
1642 
1643  nevcorrsgru->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgru[jk][ij]->GetEntries());
1644  mncorrsgru->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgru[jk][ij]->GetMean());
1645  rmscorrsgru->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgru[jk][ij]->GetRMS());
1646 
1647  nevcorrsgall->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgall[jk][ij]->GetEntries());
1648  mncorrsgall->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgall[jk][ij]->GetMean());
1649  rmscorrsgall->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgall[jk][ij]->GetRMS());
1650 
1651  nevcorrsgl->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgl[jk][ij]->GetEntries());
1652  mncorrsgl->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgl[jk][ij]->GetMean());
1653  rmscorrsgl->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgl[jk][ij]->GetRMS());
1654 
1655  nevcorrsgr->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgr[jk][ij]->GetEntries());
1656  mncorrsgr->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgr[jk][ij]->GetMean());
1657  rmscorrsgr->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgr[jk][ij]->GetRMS());
1658  } //m_correl #endif
1659  if (m_checkmap) { // #ifdef CHECKMAP
1660  nevcorrsgc->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgc[jk][ij]->GetEntries());
1661  mncorrsgc->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgc[jk][ij]->GetMean());
1662  rmscorrsgc->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgc[jk][ij]->GetRMS());
1663  } //m_checkmap #endif
1664  }
1665  }
1666  } //m_combined #endif
1667 
1668 
1669  for (int ij=1; ij<neffip; ij++) {
1670  sig_effi[ij]->Divide(sig_effi[0]);
1671  }
1672  for (int ij=0; ij<netamx; ij++) {
1673  for (int jk = 0; jk <nphimx; jk++) {
1674  int ieta = (ij<15) ? ij+1 : 14-ij;
1675  int iphi = jk+1;
1676  double signal = sigrsg[ij][jk]->GetMean();
1677  mean_energy->Fill(ieta, iphi, signal);
1678  }
1679  }
1680 
1681  int irunold = irun;
1682 
1683 
1684  gStyle->SetOptLogy(0);
1685  gStyle->SetTitleFillColor(10);
1686  gStyle->SetStatColor(10);
1687 
1688  gStyle->SetCanvasColor(10);
1689  gStyle->SetOptStat(0); //1110);
1690  gStyle->SetOptTitle(1);
1691 
1692  gStyle->SetTitleColor(10);
1693  gStyle->SetTitleFontSize(0.09);
1694  gStyle->SetTitleOffset(-0.05);
1695  gStyle->SetTitleBorderSize(1);
1696 
1697  gStyle->SetPadColor(10);
1698  gStyle->SetPadBorderMode(0);
1699  gStyle->SetStatColor(10);
1700  gStyle->SetPadBorderMode(0);
1701  gStyle->SetStatBorderSize(1);
1702  gStyle->SetStatFontSize(.07);
1703 
1704  gStyle->SetStatStyle(1001);
1705  gStyle->SetOptFit(101);
1706  gStyle->SetCanvasColor(10);
1707  gStyle->SetCanvasBorderMode(0);
1708 
1709  gStyle->SetStatX(.99);
1710  gStyle->SetStatY(.99);
1711  gStyle->SetStatW(.45);
1712  gStyle->SetStatH(.16);
1713  gStyle->SetLabelSize(0.075,"XY");
1714  gStyle->SetLabelOffset(0.21,"XYZ");
1715  gStyle->SetTitleSize(0.065,"XY");
1716  gStyle->SetTitleOffset(0.06,"XYZ");
1717  gStyle->SetPadTopMargin(.09);
1718  gStyle->SetPadBottomMargin(0.11);
1719  gStyle->SetPadLeftMargin(0.12);
1720  gStyle->SetPadRightMargin(0.15);
1721  gStyle->SetPadGridX(true);
1722  gStyle->SetPadGridY(true);
1723  gStyle->SetGridStyle(2);
1724  gStyle->SetNdivisions(303,"XY");
1725 
1726  gStyle->SetMarkerSize(0.60);
1727  gStyle->SetMarkerColor(2);
1728  gStyle->SetMarkerStyle(20);
1729  gStyle->SetTitleFontSize(0.07);
1730 
1731  char out_file[200];
1732  int xsiz = 700;
1733  int ysiz = 500;
1734 
1735 // TCanvas *c2 = new TCanvas("c2", "Statistics and efficiency", xsiz, ysiz);
1736 // c2->Divide(2,1); //(3,2);
1737 // for (int ij=0; ij<neffip; ij=ij+3) {
1738 // sig_effi[ij]->GetXaxis()->SetTitle("#eta");
1739 // sig_effi[ij]->GetXaxis()->SetTitleSize(0.075);
1740 // sig_effi[ij]->GetXaxis()->SetTitleOffset(0.65); //0.85
1741 // sig_effi[ij]->GetXaxis()->CenterTitle();
1742 // sig_effi[ij]->GetXaxis()->SetLabelSize(0.055);
1743 // sig_effi[ij]->GetXaxis()->SetLabelOffset(0.001);
1744 
1745 // sig_effi[ij]->GetYaxis()->SetTitle("#phi");
1746 // sig_effi[ij]->GetYaxis()->SetTitleSize(0.075);
1747 // sig_effi[ij]->GetYaxis()->SetTitleOffset(0.9);
1748 // sig_effi[ij]->GetYaxis()->CenterTitle();
1749 // sig_effi[ij]->GetYaxis()->SetLabelSize(0.055);
1750 // sig_effi[ij]->GetYaxis()->SetLabelOffset(0.01);
1751 
1752 // c2->cd(int(ij/3.)+1); sig_effi[ij]->Draw("colz");
1753 // }
1754 // sprintf(out_file, "comb_hosig_evt_%i.jpg",irunold);
1755 // c2->SaveAs(out_file);
1756 
1757 // gStyle->SetTitleFontSize(0.045);
1758 // gStyle->SetPadRightMargin(0.1);
1759 // gStyle->SetPadLeftMargin(0.1);
1760 // gStyle->SetPadBottomMargin(0.12);
1761 
1762 // TCanvas *c1 = new TCanvas("c1", "Mean signal in each tower", xsiz, ysiz);
1763 
1764 // mean_energy->GetXaxis()->SetTitle("#eta");
1765 // mean_energy->GetXaxis()->SetTitleSize(0.075);
1766 // mean_energy->GetXaxis()->SetTitleOffset(0.65); //0.6
1767 // mean_energy->GetXaxis()->CenterTitle();
1768 // mean_energy->GetXaxis()->SetLabelSize(0.045);
1769 // mean_energy->GetXaxis()->SetLabelOffset(0.001);
1770 
1771 // mean_energy->GetYaxis()->SetTitle("#phi");
1772 // mean_energy->GetYaxis()->SetTitleSize(0.075);
1773 // mean_energy->GetYaxis()->SetTitleOffset(0.5);
1774 // mean_energy->GetYaxis()->CenterTitle();
1775 // mean_energy->GetYaxis()->SetLabelSize(0.045);
1776 // mean_energy->GetYaxis()->SetLabelOffset(0.01);
1777 
1778 // mean_energy->Draw("colz");
1779 // sprintf(out_file, "homean_energy_%i.jpg",irunold);
1780 // c1->SaveAs(out_file);
1781 
1782 // delete c1;
1783 // delete c2;
1784 
1785  gStyle->SetPadBottomMargin(0.14);
1786  gStyle->SetPadLeftMargin(0.17);
1787  gStyle->SetPadRightMargin(0.03);
1788 
1789  gStyle->SetOptStat(1110);
1790 
1791  const int nsample =8;
1792  TF1* gx0[nsample]={nullptr};
1793  TF1* ped0fun[nsample]={nullptr};
1794  TF1* signal[nsample]={nullptr};
1795  TF1* pedfun[nsample]={nullptr};
1796  TF1* sigfun[nsample]={nullptr};
1797  TF1* signalx[nsample]={nullptr};
1798 
1799  TH1F* signall[nsample]={nullptr};
1800  TH1F* pedstll[nsample]={nullptr};
1801 
1802  if (m_constant) {
1803 
1804  gStyle->SetOptFit(101);
1805  gStyle->SetCanvasBorderMode(0);
1806  gStyle->SetPadBorderMode(0);
1807  gStyle->SetStatBorderSize(1);
1808  gStyle->SetStatStyle(1001);
1809  gStyle->SetTitleColor(10);
1810  gStyle->SetTitleFontSize(0.09);
1811  gStyle->SetTitleOffset(-0.05);
1812  gStyle->SetTitleBorderSize(1);
1813 
1814  gStyle->SetCanvasColor(10);
1815  gStyle->SetPadColor(10);
1816  gStyle->SetStatColor(10);
1817  gStyle->SetStatFontSize(.07);
1818  gStyle->SetStatX(0.99);
1819  gStyle->SetStatY(0.99);
1820  gStyle->SetStatW(0.30);
1821  gStyle->SetStatH(0.10);
1822  gStyle->SetTitleSize(0.065,"XYZ");
1823  gStyle->SetLabelSize(0.075,"XYZ");
1824  gStyle->SetLabelOffset(0.012,"XYZ");
1825  gStyle->SetPadGridX(true);
1826  gStyle->SetPadGridY(true);
1827  gStyle->SetGridStyle(3);
1828  gStyle->SetNdivisions(101,"XY");
1829  gStyle->SetOptLogy(0);
1830  int iiter = 0;
1831 
1832 
1833  std::ofstream file_out(theoutputtxtFile.c_str());
1834  // TPostScript* ps=0;
1835  int ips=111;
1836  TPostScript ps(theoutputpsFile.c_str(),ips);
1837  ps.Range(20,28);
1838 
1839  xsiz = 900; //900;
1840  ysiz = 1200; //600;
1841  TCanvas *c0 = new TCanvas("c0", " Pedestal vs signal", xsiz, ysiz);
1842 
1843 // Fix is done for eta-phi
1844 
1845  float mean_eta[netamx];
1846  float mean_phi[nphimx];
1847  float rms_eta[netamx];
1848  float rms_phi[nphimx];
1849 
1850  for (int ij=0; ij<nphimx; ++ij) {mean_phi[ij] = 0; rms_phi[ij] = 0;}
1851  for (int ij=0; ij<netamx; ++ij) {mean_eta[ij] = 0; rms_eta[ij] = 0;}
1852 
1853  int mxeta = 0;
1854  int mxphi = 0;
1855  int mneta = 0;
1856  int mnphi = 0;
1857 
1858  //iijj = 0 : Merging all ring
1859  // = 1 : Individual HPD
1860  //iijj = 2 : merging all phi
1861  // = 3 : Individual tower
1862 
1863  for (int iijj = 0; iijj <4; iijj++) {
1864  // if ((!mx_combined) && iijj==1) continue; //Use this only for combined data
1865  if (iijj==0){
1866  mxeta = ringmx; mxphi = 1; mneta = 0; mnphi = 0;
1867  } else if (iijj==1) {
1868  mxeta = ringmx; mxphi = routmx;
1869  mneta = 0; mnphi = 0;
1870  } else if (iijj==2) {
1871  mxeta = netamx; mxphi = 1; mneta = 0; mnphi = 0;
1872  } else if (iijj==3) {
1873  mxeta = netamx; mxphi = nphimx;
1874  mneta = 0; mnphi = 0;
1875  }
1876 
1877  for (int jk=mneta; jk<mxeta; jk++) {
1878  for (int ij=mnphi; ij<mxphi; ij++) {
1879  if (iijj==1) continue;
1880  if ((iijj==0 || iijj==1) && jk !=2 && ij >=rout12mx) continue;
1881  int izone = iiter%nsample;
1882 
1883  if (iijj==0) {
1884  int iread = (jk==2) ? routmx : rout12mx;
1885  signall[izone] = (TH1F*)com_sigrsg[jk][iread]->Clone("hnew");
1886  pedstll[izone] = (TH1F*)com_crossg[jk][iread]->Clone("hnew");
1887  } else if (iijj==1) {
1888  signall[izone] = (TH1F*)com_sigrsg[jk][ij]->Clone("hnew");
1889  pedstll[izone] = (TH1F*)com_crossg[jk][ij]->Clone("hnew");
1890  } else if (iijj==2) {
1891  signall[izone] = (TH1F*)sigrsg[jk][nphimx]->Clone("hnew");
1892  pedstll[izone] = (TH1F*)crossg[jk][nphimx]->Clone("hnew");
1893  } else if (iijj==3) {
1894  signall[izone] = (TH1F*)sigrsg[jk][ij]->Clone("hnew");
1895  pedstll[izone] = (TH1F*)crossg[jk][ij]->Clone("hnew");
1896  }
1897 
1898  pedstll[izone]->SetLineWidth(2);
1899  signall[izone]->SetLineWidth(2);
1900  pedstll[izone]->SetLineColor(2);
1901  signall[izone]->SetLineColor(4);
1902  pedstll[izone]->SetNdivisions(506,"XY");
1903  signall[izone]->SetNdivisions(506,"XY");
1904 
1905  signall[izone]->GetXaxis()->SetLabelSize(.065);
1906  signall[izone]->GetYaxis()->SetLabelSize(.06);
1907  signall[izone]->GetXaxis()->SetTitle("Signal (GeV)");
1908 
1909  signall[izone]->GetXaxis()->SetTitleSize(.065);
1910  signall[izone]->GetXaxis()->CenterTitle();
1911 
1912  if (izone==0) { //iiter%8 ==0) {
1913  ps.NewPage();
1914  c0->Divide(4,4); //c0->Divide(2,4); // c0->Divide(1,2);
1915  }
1916  c0->cd(2*izone+1); // (iiter%8)+1); //c0->cd(iiter%8+1);
1917 
1918  /*
1919  if (iijj==0 && izone==0) {
1920  gStyle->SetOptLogy(1);
1921  gStyle->SetOptStat(0);
1922  gStyle->SetOptFit(0);
1923  c0->Divide(3,2);
1924  }
1925 
1926  if (iijj>0) {
1927  gStyle->SetOptLogy(0);
1928  gStyle->SetOptStat(1110);
1929  gStyle->SetOptFit(101);
1930 
1931  if (iiter==0) {
1932  int ips=111;
1933  ps = new TPostScript(theoutputpsFile.c_str(),ips);
1934  ps.Range(20,28);
1935  xsiz = 900; //900;
1936  ysiz = 1200; //600;
1937  c0 = new TCanvas("c0", " Pedestal vs signal", xsiz, ysiz);
1938  }
1939  if (izone==0) {
1940  ps.NewPage();
1941  c0->Divide(4,4);
1942  }
1943  }
1944  if (iijj==0) {c0->cd(izone+1); } else { c0->cd(2*izone+1);}
1945  */
1946 
1947  float mean = pedstll[izone]->GetMean();
1948  float rms = pedstll[izone]->GetRMS();
1949 
1950  if (rms <0.10) rms = 0.10;
1951  if (rms >0.15) rms=0.15;
1952  if (mean >0.20) mean = 0.20;
1953  if (mean <-0.20) mean = -0.20;
1954 
1955  float xmn = mean-6.*rms;
1956  float xmx = mean+6.*rms;
1957 
1958  binwid = pedstll[izone]->GetBinWidth(1);
1959  if (xmx > pedstll[izone]->GetXaxis()->GetXmax()) xmx = pedstll[izone]->GetXaxis()->GetXmax()-0.5*binwid;
1960  if (xmn < pedstll[izone]->GetXaxis()->GetXmin()) xmn = pedstll[izone]->GetXaxis()->GetXmin()+0.5*binwid;
1961 
1962  float height = pedstll[izone]->GetEntries();
1963 
1964  double par[nbgpr] ={height, mean, 0.75*rms};
1965 
1966  double gaupr[nbgpr];
1967  double parer[nbgpr];
1968 
1969  ietafit = jk;
1970  iphifit = ij;
1971  pedstll[izone]->GetXaxis()->SetLabelSize(.065);
1972  pedstll[izone]->GetYaxis()->SetLabelSize(.06);
1973 
1974  // if (iijj==0) {
1975  // pedstll[izone]->GetXaxis()->SetRangeUser(alow, ahigh);
1976  // } else {
1977  pedstll[izone]->GetXaxis()->SetRangeUser(xmn, xmx);
1978  // }
1979 
1980  if (iijj==0) {
1981  pedstll[izone]->GetXaxis()->SetTitle("Pedestal/Signal (GeV)");
1982  } else {
1983  pedstll[izone]->GetXaxis()->SetTitle("Pedestal (GeV)");
1984  }
1985  pedstll[izone]->GetXaxis()->SetTitleSize(.065);
1986  pedstll[izone]->GetXaxis()->CenterTitle();
1987  // pedstll[izone]->SetLineWidth(2);
1988 
1989  pedstll[izone]->Draw();
1990  if (m_pedsuppr) {
1991  gaupr[0] = 0;
1992  gaupr[1] = 0.0; // pedmean[ietafit][iphifit];
1993  gaupr[2] = 0.15; //GMA need from database
1994  parer[0] = parer[1] = parer[2] = 0;
1995  } else {
1996 
1997  if (pedstll[izone]->GetEntries() >5) {
1998 
1999  if ((iijj!=3) || m_histfit) {
2000  char temp[20];
2001  sprintf(temp, "gx0_%i",izone);
2002  gx0[izone] = new TF1(temp, gausX, xmn, xmx, nbgpr);
2003  gx0[izone]->SetParameters(par);
2004  gx0[izone]->SetLineWidth(1);
2005  pedstll[izone]->Fit(gx0[izone], "R+");
2006 
2007  for (int k=0; k<nbgpr; k++) {
2008  parer[k] = gx0[izone]->GetParError(k);
2009  gaupr[k] = gx0[izone]->GetParameter(k);
2010  }
2011  } else {
2012  double strt[nbgpr] = {height, mean, 0.75*rms};
2013  double step[nbgpr] = {1.0, 0.001, 0.001};
2014  double alowmn[nbgpr] = {0.5*height, mean-rms, 0.3*rms};
2015  double ahighmn[nbgpr] ={1.5*height, mean+rms, 1.5*rms};
2016 
2017  TMinuit *gMinuit = new TMinuit(nbgpr);
2018  gMinuit->SetFCN(fcnbg);
2019 
2020  double arglist[10];
2021  int ierflg = 0;
2022  arglist[0] =0.5;
2023  gMinuit->mnexcm("SET ERR", arglist, 1, ierflg);
2024  char name[100];
2025  for (int k=0; k<nbgpr; k++) {
2026  sprintf(name, "pedpar%i",k);
2027  gMinuit->mnparm(k, name, strt[k], step[k], alowmn[k], ahighmn[k],ierflg);
2028  }
2029 
2030  arglist[0] = 0;
2031  gMinuit->mnexcm("SIMPLEX", arglist, 0, ierflg);
2032 
2033  arglist[0] = 0;
2034  gMinuit->mnexcm("IMPROVE", arglist, 0, ierflg);
2035 
2036  TString chnam;
2037  double parv,err,xlo,xup, plerr, mierr, eparab, gcc;
2038  int iuit;
2039 
2040  for (int k=0; k<nbgpr; k++) {
2041  if (step[k] >-10) {
2042  gMinuit->mnpout(k, chnam, parv, err, xlo, xup, iuit);
2043  gMinuit->mnerrs(k, plerr, mierr, eparab, gcc);
2044  // edm::LogInfo("HOCalib") <<"k "<< k<<" "<<chnam<<" "<<parv<<" "<<err<<" "<<xlo<<" "<<xup<<" "<<plerr<<" "<<mierr<<" "<<eparab;
2045  if (k==0) {
2046  gaupr[k] = parv*binwid;
2047  parer[k] = err*binwid;
2048  } else {
2049  gaupr[k] = parv;
2050  parer[k] = err;
2051  }
2052  }
2053  }
2054 
2055  // gx0[izone]->SetParameters(gaupr);
2056 
2057  char temp[20];
2058  sprintf(temp, "ped0fun_%i",izone);
2059  ped0fun[izone] = new TF1(temp, gausX, xmn, xmx, nbgpr);
2060  ped0fun[izone]->SetParameters(gaupr);
2061  ped0fun[izone]->SetLineColor(3);
2062  ped0fun[izone]->SetLineWidth(1);
2063  ped0fun[izone]->Draw("same");
2064 
2065  delete gMinuit;
2066  }
2067  } else {
2068  for (int k=0; k<nbgpr; k++) {gaupr[k] = par[k]; }
2069  gaupr[2] = 0.15;
2070  }
2071  }
2072  // if (iijj!=0)
2073  c0->cd(2*izone+2);
2074  if (signall[izone]->GetEntries() >5) {
2075  Double_t parall[nsgpr];
2076  double parserr[nsgpr];
2077  double fitres[nsgpr];
2078  double pedht = 0;
2079 
2080  char temp[20];
2081  sprintf(temp, "signal_%i",izone);
2082  xmn = signall[izone]->GetXaxis()->GetXmin();
2083  xmx = 0.5*signall[izone]->GetXaxis()->GetXmax();
2084  signal[izone] = new TF1(temp, totalfunc, xmn, xmx, nsgpr);
2085  xmx *=2.0;
2086  if ((iijj!=3) || m_histfit) {
2087  pedht = (signall[izone]->GetBinContent(nbn-1)+
2088  signall[izone]->GetBinContent(nbn)+
2089  signall[izone]->GetBinContent(nbn+1))/3.;
2090 
2091  if (m_pedsuppr) {
2092  parall[1] = 0.0; // pedmean[ietafit][iphifit];
2093  parall[2] = 0.15;
2094  } else {
2095  for (int lm=0; lm<nbgpr; lm++) {parall[lm] = gaupr[lm];}
2096  }
2097 
2098  set_mean(parall[1], false);
2099  set_sigma(parall[2], false);
2100 
2101  parall[0] = 0.9*pedht; //GM for Z-mumu, there is almost no pedestal
2102  parall[3] = 0.14;
2103  double area = binwid*signall[izone]->GetEntries();
2104  parall[5]= area;
2105 
2106  if (iijj==3) {
2107  parall[4] = fitprm[4][jk];
2108  parall[6] = fitprm[6][jk];
2109  } else {
2110  parall[4] = signall[izone]->GetMean();
2111  parall[6]=parall[2];
2112  }
2113 
2114  signal[izone]->SetParameters(parall);
2115  signal[izone]->FixParameter(1, parall[1]);
2116  signal[izone]->FixParameter(2, parall[2]);
2117  signal[izone]->SetParLimits(0, 0.00, 2.0*pedht+0.1);
2118  signal[izone]->FixParameter(3, 0.14);
2119 
2120  signal[izone]->SetParLimits(5, 0.40*area, 1.15*area);
2121  // if (m_histfit) { //GMA
2122  if (iijj==3) {
2123  signal[izone]->SetParLimits(4, 0.2*fitprm[4][jk], 2.0*fitprm[4][jk]);
2124  signal[izone]->SetParLimits(6, 0.2*fitprm[6][jk], 2.0*fitprm[6][jk]);
2125  } else {
2126  signal[izone]->SetParLimits(4, 0.1, 1.0);
2127  signal[izone]->SetParLimits(6, 0.035, 0.3);
2128  }
2129  signal[izone]->SetParNames("const", "mean", "sigma","Width","MP","Area","GSigma");
2130  signall[izone]->Fit(signal[izone], "0R+");
2131 
2132  signall[izone]->GetXaxis()->SetRangeUser(xmn,xmx);
2133  for (int k=0; k<nsgpr; k++) {
2134  fitres[k] = fitprm[k][jk] = signal[izone]->GetParameter(k);
2135  parserr[k] = signal[izone]->GetParError(k);
2136  }
2137 
2138  } else {
2139  double pedhtx = 0;
2140  for (unsigned i =0; i<sig_reg[ietafit][iphifit].size(); i++) {
2141  if (sig_reg[ietafit][iphifit][ij] >gaupr[1]-3*gaupr[2] && sig_reg[ietafit][iphifit][ij]<gaupr[1]+gaupr[2]) pedhtx++;
2142  }
2143 
2144  set_mean(gaupr[1], false);
2145  set_sigma(gaupr[2], false);
2146 
2147  TString name[nsgpr] = {"const", "mean", "sigma","Width","MP","Area","GSigma"};
2148  double strt[nsgpr] = {0.9*pedhtx, gaupr[1], gaupr[2], fitprm[3][jk], fitprm[4][jk], signall[izone]->GetEntries(), fitprm[6][jk]};
2149  double alowmn[nsgpr] = {0.1*pedhtx-0.1, gaupr[1]-0.1, gaupr[2]-0.1,0.07, 0.2*strt[4], 0.1*strt[5], 0.2*strt[6]};
2150  double ahighmn[nsgpr] ={1.2*pedhtx+0.1, gaupr[1]+0.1, gaupr[2]+0.1,0.20, 2.5*strt[4], 1.5*strt[5], 2.2*strt[6]};
2151  double step[nsgpr] = {1.0, 0.0, 0.0, 0.0, 0.001, 1.0, 0.002};
2152 
2153  TMinuit *gMinuit = new TMinuit(nsgpr);
2154  gMinuit->SetFCN(fcnsg);
2155 
2156  double arglist[10];
2157  int ierflg = 0;
2158  arglist[0] =0.5;
2159  gMinuit->mnexcm("SET ERR", arglist, 1, ierflg);
2160 
2161  for (int k=0; k<nsgpr; k++) {
2162  gMinuit->mnparm(k, name[k], strt[k], step[k], alowmn[k], ahighmn[k],ierflg);
2163  }
2164 
2165  arglist[0] = 0;
2166  gMinuit->mnexcm("SIMPLEX", arglist, 0, ierflg);
2167 
2168  arglist[0] = 0;
2169  gMinuit->mnexcm("IMPROVE", arglist, 0, ierflg);
2170 
2171  TString chnam;
2172  double parv,err,xlo,xup, plerr, mierr, eparab, gcc;
2173  int iuit;
2174 
2175  for (int k=0; k<nsgpr; k++) {
2176  if (step[k] >-10) {
2177  gMinuit->mnpout(k, chnam, parv, err, xlo, xup, iuit);
2178  gMinuit->mnerrs(k, plerr, mierr, eparab, gcc);
2179  if (k==0 || k==5) {
2180  fitres[k] = parv*binwid;
2181  parserr[k]= err*binwid;
2182  } else {
2183  fitres[k] = parv;
2184  parserr[k]= err;
2185  }
2186 
2187  }
2188  }
2189 
2190  delete gMinuit;
2191  }
2192 
2193  // if (iijj==0) {
2194  // signall[izone]->Draw("same");
2195  // } else {
2196  signall[izone]->Draw();
2197  // }
2198 
2199  sprintf(temp, "pedfun_%i",izone);
2200  pedfun[izone] = new TF1(temp, gausX, xmn, xmx, nbgpr);
2201  pedfun[izone]->SetParameters(fitres);
2202  pedfun[izone]->SetLineColor(3);
2203  pedfun[izone]->SetLineWidth(1);
2204  pedfun[izone]->Draw("same");
2205 
2206  sprintf(temp, "signalfun_%i",izone);
2207  sigfun[izone] = new TF1(temp, langaufun, xmn, xmx, nsgpr-nbgpr);
2208  sigfun[izone]->SetParameters(&fitres[3]);
2209  sigfun[izone]->SetLineWidth(1);
2210  sigfun[izone]->SetLineColor(4);
2211  sigfun[izone]->Draw("same");
2212 
2213  sprintf(temp, "total_%i",izone);
2214  signalx[izone] = new TF1(temp, totalfunc, xmn, xmx, nsgpr);
2215  signalx[izone]->SetParameters(fitres);
2216  signalx[izone]->SetLineWidth(1);
2217  signalx[izone]->Draw("same");
2218 
2219  int kl = (jk<15) ? jk+1 : 14-jk;
2220 
2221  edm::LogInfo("HOCalib")<<"histinfo"<<iijj<<" fit "
2222  <<std::setw(3)<< kl<<" "
2223  <<std::setw(3)<< ij+1<<" "
2224  <<std::setw(5)<<pedstll[izone]->GetEntries()<<" "
2225  <<std::setw(6)<<pedstll[izone]->GetMean()<<" "
2226  <<std::setw(6)<<pedstll[izone]->GetRMS()<<" "
2227  <<std::setw(5)<<signall[izone]->GetEntries()<<" "
2228  <<std::setw(6)<<signall[izone]->GetMean()<<" "
2229  <<std::setw(6)<<signall[izone]->GetRMS()<<" "
2230  <<std::setw(6)<< signal[izone]->GetChisquare()<<" "
2231  <<std::setw(3)<< signal[izone]->GetNDF();
2232 
2233  file_out<<"histinfo"<<iijj<<" fit "
2234  <<std::setw(3)<< kl<<" "
2235  <<std::setw(3)<< ij+1<<" "
2236  <<std::setw(5)<<pedstll[izone]->GetEntries()<<" "
2237  <<std::setw(6)<<pedstll[izone]->GetMean()<<" "
2238  <<std::setw(6)<<pedstll[izone]->GetRMS()<<" "
2239  <<std::setw(5)<<signall[izone]->GetEntries()<<" "
2240  <<std::setw(6)<<signall[izone]->GetMean()<<" "
2241  <<std::setw(6)<<signall[izone]->GetRMS()<<" "
2242  <<std::setw(6)<< signal[izone]->GetChisquare()<<" "
2243  <<std::setw(3)<< signal[izone]->GetNDF()<<std::endl;
2244 
2245  file_out <<"fitres x"<<iijj<<" "<<kl<<" "<<ij+1<<" "<< fitres[0]<<" "<< fitres[1]<<" "<< fitres[2]<<" "<< fitres[3]<<" "<< fitres[4]<<" "<< fitres[5]<<" "<< fitres[6]<<std::endl;
2246  file_out <<"parserr"<<iijj<<" "<<kl<<" "<<ij+1<<" "<< parserr[0]<<" "<< parserr[1]<<" "<< parserr[2]<<" "<< parserr[3]<<" "<< parserr[4]<<" "<< parserr[5]<<" "<< parserr[6]<<std::endl;
2247 
2248  double diff=fitres[4]-fitres[1];
2249  if (diff <=0) diff = 0.000001;
2250  double error=parserr[4]*parserr[4]+parer[2]*parer[2];
2251  error = pow(error,0.5);
2252 
2253  int ieta = (jk<15) ? (15+jk) : (29-jk);
2254  int ifl = nphimx*ieta + ij;
2255 
2256  if (iijj==3) {
2257  ped_evt->Fill(ifl,pedstll[izone]->GetEntries());
2258  ped_mean->Fill(ifl,gaupr[1]);
2259  ped_width->Fill(ifl,gaupr[2]);
2260  fit_chi->Fill(ifl,signal[izone]->GetChisquare());
2261  sig_evt->Fill(ifl, signall[izone]->GetEntries());
2262  fit_sigevt->Fill(ifl, fitres[5]);
2263  fit_bkgevt->Fill(ifl, fitres[0]*sqrt(2*acos(-1.))*gaupr[2]);
2264  sig_mean->Fill(ifl, fitres[4]);
2265  sig_diff->Fill(ifl, fitres[4]-fitres[1]);
2266  sig_width->Fill(ifl, fitres[3]);
2267  sig_sigma->Fill(ifl, fitres[6]);
2268  sig_meanerr->Fill(ifl, parserr[4]);
2269  if (fitres[4]-fitres[1] !=0) sig_meanerrp->Fill(ifl, 100*parserr[4]/(fitres[4]-fitres[1]));
2270  if (gaupr[2]!=0) sig_signf->Fill(ifl,(fitres[4]-fitres[1])/gaupr[2]);
2271 
2272  ped_statmean->Fill(ifl,pedstll[izone]->GetMean());
2273  sig_statmean->Fill(ifl,signall[izone]->GetMean());
2274  ped_rms->Fill(ifl,pedstll[izone]->GetRMS());
2275  sig_rms->Fill(ifl,signall[izone]->GetRMS());
2276  }
2277 
2278  if ((iijj==2) || (iijj==3) || (iijj==1)) {
2279  if (signall[izone]->GetEntries() >5 && fitres[4]>0.1) {
2280  //GMA need to put this==1 in future
2281  float fact=0.812;
2282  if (abs(kl)<=4) fact=0.895;
2283  fact *=0.19; //conversion factor for GeV/fC
2284 
2285  float fact2 = 0;
2286  if (iijj==2) fact2 = invang[jk][nphimx];
2287  if (iijj==3) fact2 = invang[jk][ij];
2288  if (iijj==1) fact2 = com_invang[jk][ij];
2289 
2290  float calibc = fact*fact2/(fitres[4]*signall[izone]->GetEntries());
2291  float caliberr= TMath::Abs(calibc*parserr[4]/std::max(0.001,fitres[4]));
2292 
2293  if (iijj==2) {
2294  int ieta = (jk<15) ? jk+1 : 14-jk;
2295  mean_phi_hst->Fill(ieta, calibc);
2296  mean_phi_hst->SetBinError(mean_phi_hst->FindBin(ieta), caliberr);
2297  file_out<<"intieta "<<jk<<" "<<ij<<" "<<ieta<<" "<<mean_phi_hst->FindBin(double(ieta))<<" "<<calibc<<" "<<caliberr<<std::endl;
2298  } else if (iijj==3) {
2299  const_eta[jk]->Fill(ij+1,calibc);
2300  const_eta[jk]->SetBinError(const_eta[jk]->FindBin(ij+1), caliberr);
2301 
2302  peak_eta[jk]->Fill(ij+1,fitres[4]);
2303  peak_eta[jk]->SetBinError(peak_eta[jk]->FindBin(ij+1),parserr[4]);
2304 
2305  int ieta = (jk<15) ? jk+1 : 14-jk;
2306  const_eta_phi->Fill(ieta, ij+1,calibc);
2307  file_out<<"intietax "<<jk<<" "<<ij<<" "<<ieta<<" "<<const_eta_phi->FindBin(ieta, ij+1)<<std::endl;
2308  if (caliberr >0) {
2309  const_eta_phi->SetBinError(const_eta_phi->FindBin(ieta, ij+1),caliberr);
2310 
2311  mean_eta[ij] +=calibc/(caliberr*caliberr);
2312  mean_phi[jk] +=calibc/(caliberr*caliberr);
2313 
2314  rms_eta[ij] +=1./(caliberr*caliberr);
2315  rms_phi[jk] +=1./(caliberr*caliberr);
2316 
2317  } else {
2318  const_eta_phi->SetBinError(const_eta_phi->FindBin(ieta, ij+1), 0.0);
2319  }
2320  } else if (iijj==1) {
2321  const_hpdrm[jk]->Fill(ij+1,calibc);
2322  const_hpdrm[jk]->SetBinError(const_hpdrm[jk]->FindBin(ij+1), caliberr);
2323 
2324  peak_hpdrm[jk]->Fill(ij+1,fitres[4]);
2325  peak_hpdrm[jk]->SetBinError(peak_hpdrm[jk]->FindBin(ij+1),parserr[4]);
2326  }
2327 
2328  file_out<<"HO 4 "<<iijj<<" "<< std::setw(3)<<kl<<" "<<std::setw(3)<<ij+1<<" "
2329  <<std::setw(7)<<calibc<<" "<<std::setw(7)<<caliberr<<std::endl;
2330  }
2331  }
2332 
2333  } else { //if (signall[izone]->GetEntries() >10) {
2334  signall[izone]->Draw();
2335  float varx = 0.000;
2336  int kl = (jk<15) ? jk+1 : 14-jk;
2337  file_out<<"histinfo"<<iijj<<" nof "
2338  <<std::setw(3)<< kl<<" "
2339  <<std::setw(3)<< ij+1<<" "
2340  <<std::setw(5)<<pedstll[izone]->GetEntries()<<" "
2341  <<std::setw(6)<<pedstll[izone]->GetMean()<<" "
2342  <<std::setw(6)<<pedstll[izone]->GetRMS()<<" "
2343  <<std::setw(5)<<signall[izone]->GetEntries()<<" "
2344  <<std::setw(6)<<signall[izone]->GetMean()<<" "
2345  <<std::setw(6)<<signall[izone]->GetRMS()<<" "
2346  <<std::setw(6)<< varx<<" "
2347  <<std::setw(3)<< varx<<std::endl;
2348 
2349  file_out <<"fitres x"<<iijj<<" "<<kl<<" "<<ij+1<<" "<< varx<<" "<< varx<<" "<< varx<<" "<< varx<<" "<< varx<<" "<< varx<<" "<< varx<<std::endl;
2350  file_out <<"parserr"<<iijj<<" "<<kl<<" "<<ij+1<<" "<< varx<<" "<< varx<<" "<< varx<<" "<< varx<<" "<< varx<<" "<< varx<<" "<< varx<<std::endl;
2351 
2352  }
2353  iiter++;
2354  if (iiter%nsample==0) {
2355  c0->Update();
2356 
2357  for (int kl=0; kl<nsample; kl++) {
2358  if (gx0[kl]) {delete gx0[kl];gx0[kl] = nullptr;}
2359  if (ped0fun[kl]) {delete ped0fun[kl];ped0fun[kl] = nullptr;}
2360  if (signal[kl]) {delete signal[kl];signal[kl] = nullptr;}
2361  if (pedfun[kl]) {delete pedfun[kl];pedfun[kl] = nullptr;}
2362  if (sigfun[kl]) {delete sigfun[kl];sigfun[kl] = nullptr;}
2363  if (signalx[kl]) {delete signalx[kl];signalx[kl] = nullptr;}
2364  if (signall[kl]) {delete signall[kl];signall[kl] = nullptr;}
2365  if (pedstll[kl]) {delete pedstll[kl];pedstll[kl] = nullptr;}
2366  }
2367 
2368  }
2369  } //for (int jk=0; jk<netamx; jk++) {
2370  } //for (int ij=0; ij<nphimx; ij++) {
2371 
2372  // if (iijj==0) {
2373  // sprintf(out_file, "comb_hosig_allring_%i.jpg", irunold);
2374  // c0->SaveAs(out_file);
2375  // iiter = 0;
2376  // } else {
2377  // // c0->Update();
2378  // }
2379 
2380  // iiter = 0;
2381  } //end of iijj
2382  if (iiter%nsample!=0) {
2383  c0->Update();
2384  for (int kl=0; kl<nsample; kl++) {
2385  if (gx0[kl]) {delete gx0[kl];gx0[kl] = nullptr;}
2386  if (ped0fun[kl]) {delete ped0fun[kl];ped0fun[kl] = nullptr;}
2387  if (signal[kl]) {delete signal[kl];signal[kl] = nullptr;}
2388  if (pedfun[kl]) {delete pedfun[kl];pedfun[kl] = nullptr;}
2389  if (sigfun[kl]) {delete sigfun[kl];sigfun[kl] = nullptr;}
2390  if (signalx[kl]) {delete signalx[kl];signalx[kl] = nullptr;}
2391  if (signall[kl]) {delete signall[kl];signall[kl] = nullptr;}
2392  if (pedstll[kl]) {delete pedstll[kl];pedstll[kl] = nullptr;}
2393  }
2394  }
2395 
2396  delete c0;
2397 
2398  xsiz = 600; //int xsiz = 600;
2399  ysiz = 800; //int ysiz = 800;
2400 
2401  gStyle->SetTitleFontSize(0.05);
2402  gStyle->SetTitleSize(0.025,"XYZ");
2403  gStyle->SetLabelSize(0.025,"XYZ");
2404  gStyle->SetStatFontSize(.045);
2405 
2406  gStyle->SetOptStat(0);
2407  ps.NewPage(); TCanvas *c1 = new TCanvas("c1", " Pedestal vs signal", xsiz, ysiz);
2408  ped_evt->Draw(); c1->Update();
2409 
2410  ps.NewPage();
2411  ped_statmean->Draw(); c1->Update();
2412 
2413  ps.NewPage();
2414  ped_rms->Draw(); c1->Update();
2415 
2416  ps.NewPage();
2417  ped_mean->Draw(); c1->Update();
2418 
2419  ps.NewPage();
2420  ped_width->Draw(); c1->Update();
2421 
2422  ps.NewPage();
2423  sig_evt->Draw(); c1->Update();
2424 
2425  ps.NewPage();
2426  sig_statmean->Draw(); c1->Update();
2427 
2428  ps.NewPage();
2429  sig_rms->Draw(); c1->Update();
2430 
2431  ps.NewPage();
2432  fit_chi->Draw(); c1->Update();
2433 
2434  ps.NewPage();
2435  fit_sigevt->Draw(); c1->Update();
2436 
2437  ps.NewPage();
2438  fit_bkgevt->Draw(); c1->Update();
2439 
2440  ps.NewPage();
2441  sig_mean->Draw(); c1->Update();
2442 
2443  ps.NewPage();
2444  sig_width->Draw(); c1->Update();
2445 
2446  ps.NewPage();
2447  sig_sigma->Draw(); c1->Update();
2448 
2449  ps.NewPage();
2450  sig_meanerr->Draw(); c1->Update();
2451 
2452  ps.NewPage();
2453  sig_meanerrp->Draw(); c1->Update();
2454 
2455  ps.NewPage();
2456  sig_signf->Draw(); c1->Update();
2457 
2458  ps.Close();
2459  delete c1;
2460 
2461  file_out.close();
2462 
2463  if (m_figure) {
2464  xsiz = 700;
2465  ysiz = 450;
2466 
2467  gStyle->SetTitleFontSize(0.09);
2468  gStyle->SetPadBottomMargin(0.17);
2469  gStyle->SetPadLeftMargin(0.18);
2470  gStyle->SetPadRightMargin(0.01);
2471  gStyle->SetOptLogy(0);
2472  gStyle->SetOptStat(0);
2473 
2474  TCanvas *c2 = new TCanvas("c2", "runfile", xsiz, ysiz);
2475  c2->Divide(5,3);
2476 
2477  for (int side=0; side <2; side++) {
2478  gStyle->SetNdivisions(303,"XY");
2479  gStyle->SetPadRightMargin(0.01);
2480  int nmn = 0;
2481  int nmx = netamx/2;
2482  if (side==1) {
2483  nmn = netamx/2;
2484  nmx = netamx;
2485  }
2486 
2487  int nzone = 0;
2488 
2489  for (int ij=nmn; ij<nmx; ij++) {
2490 
2491  c2->cd(nzone+1);
2492  const_eta[ij]->GetXaxis()->SetTitle("#phi index");
2493  const_eta[ij]->GetXaxis()->SetTitleSize(.08);
2494  const_eta[ij]->GetXaxis()->CenterTitle();
2495  const_eta[ij]->GetXaxis()->SetTitleOffset(0.9);
2496  const_eta[ij]->GetXaxis()->SetLabelSize(.085);
2497  const_eta[ij]->GetXaxis()->SetLabelOffset(.01);
2498 
2499  const_eta[ij]->GetYaxis()->SetLabelSize(.08);
2500  const_eta[ij]->GetYaxis()->SetLabelOffset(.01);
2501  const_eta[ij]->GetYaxis()->SetTitle("GeV/MIP-GeV!!");
2502 
2503  const_eta[ij]->GetYaxis()->SetTitleSize(.085);
2504  const_eta[ij]->GetYaxis()->CenterTitle();
2505  const_eta[ij]->GetYaxis()->SetTitleOffset(1.3);
2506  const_eta[ij]->SetMarkerSize(0.60);
2507  const_eta[ij]->SetMarkerColor(2);
2508  const_eta[ij]->SetMarkerStyle(20);
2509 
2510 
2511  const_eta[ij]->Draw();
2512  nzone++;
2513  }
2514 
2515  sprintf(out_file, "calibho_%i_side%i.eps", irunold, side);
2516  c2->SaveAs(out_file);
2517 
2518  sprintf(out_file, "calibho_%i_side%i.jpg", irunold, side);
2519  c2->SaveAs(out_file);
2520 
2521  nzone = 0;
2522  for (int ij=nmn; ij<nmx; ij++) {
2523  c2->cd(nzone+1);
2524  peak_eta[ij]->GetXaxis()->SetTitle("#phi index");
2525  peak_eta[ij]->GetXaxis()->SetTitleSize(.08);
2526  peak_eta[ij]->GetXaxis()->CenterTitle();
2527  peak_eta[ij]->GetXaxis()->SetTitleOffset(0.90);
2528  peak_eta[ij]->GetXaxis()->SetLabelSize(.08);
2529  peak_eta[ij]->GetXaxis()->SetLabelOffset(.01);
2530 
2531  peak_eta[ij]->GetYaxis()->SetLabelSize(.08);
2532  peak_eta[ij]->GetYaxis()->SetLabelOffset(.01);
2533  peak_eta[ij]->GetYaxis()->SetTitle("GeV");
2534 
2535  peak_eta[ij]->GetYaxis()->SetTitleSize(.085);
2536  peak_eta[ij]->GetYaxis()->CenterTitle();
2537  peak_eta[ij]->GetYaxis()->SetTitleOffset(1.3);
2538 
2539  peak_eta[ij]->SetMarkerSize(0.60);
2540  peak_eta[ij]->SetMarkerColor(2);
2541  peak_eta[ij]->SetMarkerStyle(20);
2542 
2543  peak_eta[ij]->Draw();
2544  nzone++;
2545  }
2546 
2547  sprintf(out_file, "peakho_%i_side%i.eps", irunold, side);
2548  c2->SaveAs(out_file);
2549 
2550  sprintf(out_file, "peakho_%i_side%i.jpg", irunold, side);
2551  c2->SaveAs(out_file);
2552  }
2553  delete c2;
2554 
2555  // if (m_combined) {
2556  gStyle->SetTitleFontSize(0.045);
2557  gStyle->SetPadRightMargin(0.13);
2558  gStyle->SetPadBottomMargin(0.15);
2559  gStyle->SetPadLeftMargin(0.1);
2560  gStyle->SetOptStat(0);
2561  xsiz = 700;
2562  ysiz = 600;
2563  TCanvas *c1 = new TCanvas("c1", "Fitted const in each tower", xsiz, ysiz);
2564  const_eta_phi->GetXaxis()->SetTitle("#eta");
2565  const_eta_phi->GetXaxis()->SetTitleSize(0.065);
2566  const_eta_phi->GetXaxis()->SetTitleOffset(0.85); //6);
2567  const_eta_phi->GetXaxis()->CenterTitle();
2568  const_eta_phi->GetXaxis()->SetLabelSize(0.045);
2569  const_eta_phi->GetXaxis()->SetLabelOffset(0.01);
2570 
2571  const_eta_phi->GetYaxis()->SetTitle("#phi");
2572  const_eta_phi->GetYaxis()->SetTitleSize(0.075);
2573  const_eta_phi->GetYaxis()->SetTitleOffset(0.5);
2574  const_eta_phi->GetYaxis()->CenterTitle();
2575  const_eta_phi->GetYaxis()->SetLabelSize(0.045);
2576  const_eta_phi->GetYaxis()->SetLabelOffset(0.01);
2577 
2578  const_eta_phi->Draw("colz");
2579  sprintf(out_file, "high_hoconst_eta_phi_%i.jpg",irunold);
2580  c1->SaveAs(out_file);
2581 
2582  delete c1;
2583 
2584  for (int jk=0; jk<netamx; jk++) {
2585  int ieta = (jk<15) ? jk+1 : 14-jk;
2586  if (rms_phi[jk]>0) {
2587  mean_phi_ave->Fill(ieta, mean_phi[jk]/rms_phi[jk]);
2588  mean_phi_ave->SetBinError(mean_phi_ave->FindBin(ieta), pow(double(rms_phi[jk]), -0.5));
2589  }
2590  }
2591 
2592  for (int ij=0; ij<nphimx; ij++) {
2593  if (rms_eta[ij] >0) {
2594  mean_eta_ave->Fill(ij+1, mean_eta[ij]/rms_eta[ij]);
2595  mean_eta_ave->SetBinError(mean_eta_ave->FindBin(ij+1), pow(double(rms_eta[ij]), -0.5));
2596  }
2597  }
2598 
2599  ysiz =450;
2600  gStyle->SetPadLeftMargin(0.13);
2601  gStyle->SetPadRightMargin(0.03);
2602 
2603 
2604  TCanvas *c2y = new TCanvas("c2", "Avearge signal in eta and phi", xsiz, ysiz);
2605  c2y->Divide(2,1);
2606  mean_eta_ave->GetXaxis()->SetTitle("#phi");
2607  mean_eta_ave->GetXaxis()->SetTitleSize(0.085);
2608  mean_eta_ave->GetXaxis()->SetTitleOffset(0.65);
2609  mean_eta_ave->GetXaxis()->CenterTitle();
2610  mean_eta_ave->GetXaxis()->SetLabelSize(0.05);
2611  mean_eta_ave->GetXaxis()->SetLabelOffset(0.001);
2612 
2613  mean_eta_ave->GetYaxis()->SetTitle("Signal (GeV)/MIP");
2614  mean_eta_ave->GetYaxis()->SetTitleSize(0.055);
2615  mean_eta_ave->GetYaxis()->SetTitleOffset(1.3);
2616  mean_eta_ave->GetYaxis()->CenterTitle();
2617  mean_eta_ave->GetYaxis()->SetLabelSize(0.045);
2618  mean_eta_ave->GetYaxis()->SetLabelOffset(0.01);
2619  mean_eta_ave->SetMarkerSize(0.60);
2620  mean_eta_ave->SetMarkerColor(2);
2621  mean_eta_ave->SetMarkerStyle(20);
2622 
2623  c2y->cd(1); mean_eta_ave->Draw();
2624 
2625  mean_phi_ave->GetXaxis()->SetTitle("#eta");
2626  mean_phi_ave->GetXaxis()->SetTitleSize(0.085);
2627  mean_phi_ave->GetXaxis()->SetTitleOffset(0.65); //55);
2628  mean_phi_ave->GetXaxis()->CenterTitle();
2629  mean_phi_ave->GetXaxis()->SetLabelSize(0.05);
2630  mean_phi_ave->GetXaxis()->SetLabelOffset(0.001);
2631 
2632  mean_phi_ave->GetYaxis()->SetTitle("Signal (GeV)/MIP");
2633  mean_phi_ave->GetYaxis()->SetTitleSize(0.055);
2634  mean_phi_ave->GetYaxis()->SetTitleOffset(1.3);
2635  mean_phi_ave->GetYaxis()->CenterTitle();
2636  mean_phi_ave->GetYaxis()->SetLabelSize(0.045);
2637  mean_phi_ave->GetYaxis()->SetLabelOffset(0.01);
2638  mean_phi_ave->SetMarkerSize(0.60);
2639  mean_phi_ave->SetMarkerColor(2);
2640  mean_phi_ave->SetMarkerStyle(20);
2641 
2642  c2y->cd(2); mean_phi_ave->Draw();
2643 
2644  sprintf(out_file, "high_hoaverage_eta_phi_%i.jpg",irunold);
2645  c2y->SaveAs(out_file);
2646 
2647  delete c2y;
2648  // } else { //m_combined
2649 
2650  xsiz = 800;
2651  ysiz = 450;
2652  TCanvas *c3 = new TCanvas("c3", "Avearge signal in eta and phi", xsiz, ysiz);
2653  c3->Divide(2,1);
2654  mean_phi_hst->GetXaxis()->SetTitle("#eta");
2655  mean_phi_hst->GetXaxis()->SetTitleSize(0.065);
2656  mean_phi_hst->GetXaxis()->SetTitleOffset(0.9);
2657  mean_phi_hst->GetXaxis()->CenterTitle();
2658  mean_phi_hst->GetXaxis()->SetLabelSize(0.065);
2659  mean_phi_hst->GetXaxis()->SetLabelOffset(0.001);
2660 
2661  mean_phi_hst->GetYaxis()->SetTitle("GeV/MIP");
2662  mean_phi_hst->GetYaxis()->SetTitleSize(0.055);
2663  mean_phi_hst->GetYaxis()->SetTitleOffset(0.9);
2664  mean_phi_hst->GetYaxis()->CenterTitle();
2665  mean_phi_hst->GetYaxis()->SetLabelSize(0.065);
2666  mean_phi_hst->GetYaxis()->SetLabelOffset(0.01);
2667 
2668  mean_phi_hst->SetMarkerColor(4);
2669  mean_phi_hst->SetMarkerSize(0.8);
2670  mean_phi_hst->SetMarkerStyle(20);
2671  mean_phi_hst->Draw();
2672 
2673  sprintf(out_file, "low_mean_phi_hst_%i.jpg",irunold);
2674  c3->SaveAs(out_file);
2675 
2676  delete c3;
2677 
2678  // } //m_combined
2679 
2680 
2681  gStyle->SetOptLogy(1);
2682  gStyle->SetPadTopMargin(.1);
2683  gStyle->SetPadLeftMargin(.15);
2684  xsiz = 800;
2685  ysiz = 500;
2686  TCanvas *c0x = new TCanvas("c0x", "Signal in each ring", xsiz, ysiz);
2687 
2688  c0x->Divide(3,2);
2689  for (int ij=0; ij<ringmx; ij++) {
2690  int iread = (ij==2) ? routmx : rout12mx;
2691  com_sigrsg[ij][iread]->GetXaxis()->SetTitle("Signal/ped (GeV)");
2692 
2693  com_sigrsg[ij][iread]->GetXaxis()->SetTitleSize(0.060);
2694  com_sigrsg[ij][iread]->GetXaxis()->SetTitleOffset(1.05);
2695  com_sigrsg[ij][iread]->GetXaxis()->CenterTitle();
2696  com_sigrsg[ij][iread]->GetXaxis()->SetLabelSize(0.065);
2697  com_sigrsg[ij][iread]->GetXaxis()->SetLabelOffset(0.01);
2698 
2699  com_sigrsg[ij][iread]->GetYaxis()->SetLabelSize(0.065);
2700  com_sigrsg[ij][iread]->GetYaxis()->SetLabelOffset(0.01);
2701 
2702 
2703  com_sigrsg[ij][iread]->SetLineWidth(3);
2704  com_sigrsg[ij][iread]->SetLineColor(4);
2705 
2706  c0x->cd(ij+1); com_sigrsg[ij][iread]->Draw();
2707 
2708  com_crossg[ij][iread]->SetLineWidth(2);
2709  com_crossg[ij][iread]->SetLineColor(2);
2710  com_crossg[ij][iread]->Draw("same");
2711  }
2712  sprintf(out_file, "hosig_ring_%i.jpg",irunold);
2713  c0x->SaveAs(out_file);
2714  delete c0x;
2715 
2716  gStyle->SetTitleFontSize(0.06);
2717  gStyle->SetOptStat(0);
2718  gStyle->SetOptLogy(0);
2719 
2720  TCanvas *c0 = new TCanvas("c0", "Signal in each ring", xsiz, ysiz);
2721 
2722  c0->Divide(3,2);
2723  for (int jk=0; jk<ringmx; jk++) {
2724  peak_hpdrm[jk]->GetXaxis()->SetTitle("RM #");
2725  peak_hpdrm[jk]->GetXaxis()->SetTitleSize(0.070);
2726  peak_hpdrm[jk]->GetXaxis()->SetTitleOffset(1.0);
2727  peak_hpdrm[jk]->GetXaxis()->CenterTitle();
2728  peak_hpdrm[jk]->GetXaxis()->SetLabelSize(0.065);
2729  peak_hpdrm[jk]->GetXaxis()->SetLabelOffset(0.01);
2730 
2731  peak_hpdrm[jk]->GetYaxis()->SetTitle("Peak(GeV)/MIP");
2732 
2733  peak_hpdrm[jk]->GetYaxis()->SetTitleSize(0.07);
2734  peak_hpdrm[jk]->GetYaxis()->SetTitleOffset(1.3);
2735  peak_hpdrm[jk]->GetYaxis()->CenterTitle();
2736  peak_hpdrm[jk]->GetYaxis()->SetLabelSize(0.065);
2737  peak_hpdrm[jk]->GetYaxis()->SetLabelOffset(0.01);
2738  // peak_hpdrm[jk]->SetLineWidth(3);
2739  // peak_hpdrm[jk]->SetLineColor(4);
2740  peak_hpdrm[jk]->SetMarkerSize(0.60);
2741  peak_hpdrm[jk]->SetMarkerColor(2);
2742  peak_hpdrm[jk]->SetMarkerStyle(20);
2743 
2744 
2745  c0->cd(jk+1); peak_hpdrm[jk]->Draw();
2746  }
2747  sprintf(out_file, "comb_peak_hpdrm_%i.jpg",irunold);
2748  c0->SaveAs(out_file);
2749 
2750  delete c0;
2751 
2752  TCanvas *c1y = new TCanvas("c1y", "Signal in each ring", xsiz, ysiz);
2753 
2754  c1y->Divide(3,2);
2755  for (int jk=0; jk<ringmx; jk++) {
2756  const_hpdrm[jk]->GetXaxis()->SetTitle("RM #");
2757  const_hpdrm[jk]->GetXaxis()->SetTitleSize(0.070);
2758  const_hpdrm[jk]->GetXaxis()->SetTitleOffset(1.3);
2759  const_hpdrm[jk]->GetXaxis()->CenterTitle();
2760  const_hpdrm[jk]->GetXaxis()->SetLabelSize(0.065);
2761  const_hpdrm[jk]->GetXaxis()->SetLabelOffset(0.01);
2762 
2763  const_hpdrm[jk]->GetYaxis()->SetTitle("Peak(GeV)");
2764  const_hpdrm[jk]->GetYaxis()->SetTitleSize(0.065);
2765  const_hpdrm[jk]->GetYaxis()->SetTitleOffset(1.0);
2766  const_hpdrm[jk]->GetYaxis()->CenterTitle();
2767  const_hpdrm[jk]->GetYaxis()->SetLabelSize(0.065);
2768  const_hpdrm[jk]->GetYaxis()->SetLabelOffset(0.01);
2769  // const_hpdrm[jk]->SetLineWidth(3);
2770  // const_hpdrm[jk]->SetLineColor(4);
2771  const_hpdrm[jk]->SetMarkerSize(0.60);
2772  const_hpdrm[jk]->SetMarkerColor(2);
2773  const_hpdrm[jk]->SetMarkerStyle(20);
2774 
2775  c1y->cd(jk+1); const_hpdrm[jk]->Draw();
2776  }
2777 
2778  sprintf(out_file, "comb_const_hpdrm_%i.jpg",irunold);
2779  c1y->SaveAs(out_file);
2780 
2781  delete c1y;
2782 
2783  } //if (m_figure) {
2784 
2785  // ps.Close();
2786  // file_out.close();
2787 
2788  }// if (m_constant){
2789 
2790 
2791  if (m_figure) {
2792  for (int ij=0; ij<nphimx; ij++) {
2793  for (int jk=0; jk<netamx; jk++) {
2794  stat_eta[jk]->Fill(ij+1,sigrsg[jk][ij]->GetEntries());
2795  statmn_eta[jk]->Fill(ij+1,sigrsg[jk][ij]->GetMean());
2796  }
2797  }
2798 
2799  xsiz = 700;
2800  ysiz = 450;
2801  gStyle->SetTitleFontSize(0.09);
2802  gStyle->SetPadBottomMargin(0.14);
2803  gStyle->SetPadLeftMargin(0.17);
2804  gStyle->SetPadRightMargin(0.01);
2805  gStyle->SetNdivisions(303,"XY");
2806  gStyle->SetOptLogy(1);
2807 
2808  TCanvas *c2x = new TCanvas("c2x", "runfile", xsiz, ysiz);
2809  c2x->Divide(5,3);
2810  for (int side=0; side <2; side++) {
2811  int nmn = 0;
2812  int nmx = netamx/2;
2813  if (side==1) {
2814  nmn = netamx/2;
2815  nmx = netamx;
2816  }
2817  int nzone = 0;
2818  char name[200];
2819 
2820  for (int ij=nmn; ij<nmx; ij++) {
2821  int ieta = (ij<15) ? ij+1 : 14-ij;
2822  c2x->cd(nzone+1);
2823  sprintf(name,"GeV(#eta=%i)",ieta);
2824  sigrsg[ij][nphimx]->GetXaxis()->SetTitle(name);
2825  sigrsg[ij][nphimx]->GetXaxis()->SetTitleSize(.08);
2826  sigrsg[ij][nphimx]->GetXaxis()->CenterTitle();
2827  sigrsg[ij][nphimx]->GetXaxis()->SetTitleOffset(0.90);
2828  sigrsg[ij][nphimx]->GetXaxis()->SetLabelSize(.08);
2829  sigrsg[ij][nphimx]->GetXaxis()->SetLabelOffset(.01);
2830 
2831  sigrsg[ij][nphimx]->GetYaxis()->SetLabelSize(.08);
2832  sigrsg[ij][nphimx]->GetYaxis()->SetLabelOffset(.01);
2833  sigrsg[ij][nphimx]->SetLineWidth(2);
2834  sigrsg[ij][nphimx]->SetLineColor(4);
2835  sigrsg[ij][nphimx]->Draw();
2836  crossg[ij][nphimx]->SetLineWidth(2);
2837  crossg[ij][nphimx]->SetLineColor(2);
2838  crossg[ij][nphimx]->Draw("same");
2839  nzone++;
2840  }
2841 
2842  sprintf(out_file, "sig_ho_%i_side%i.eps", irunold, side);
2843  c2x->SaveAs(out_file);
2844 
2845  sprintf(out_file, "sig_ho_%i_side%i.jpg", irunold, side);
2846  c2x->SaveAs(out_file);
2847  }
2848 
2849  gStyle->SetOptLogy(0);
2850  c2x = new TCanvas("c2x", "runfile", xsiz, ysiz);
2851  c2x->Divide(5,3);
2852  for (int side=0; side <2; side++) {
2853  int nmn = 0;
2854  int nmx = netamx/2;
2855  if (side==1) {
2856  nmn = netamx/2;
2857  nmx = netamx;
2858  }
2859  int nzone = 0;
2860 
2861  nzone = 0;
2862  for (int ij=nmn; ij<nmx; ij++) {
2863  c2x->cd(nzone+1);
2864  statmn_eta[ij]->SetLineWidth(2);
2865  statmn_eta[ij]->SetLineColor(4);
2866  statmn_eta[ij]->GetXaxis()->SetTitle("#phi index");
2867  statmn_eta[ij]->GetXaxis()->SetTitleSize(.08);
2868  statmn_eta[ij]->GetXaxis()->CenterTitle();
2869  statmn_eta[ij]->GetXaxis()->SetTitleOffset(0.9);
2870  statmn_eta[ij]->GetYaxis()->SetLabelSize(.08);
2871  statmn_eta[ij]->GetYaxis()->SetLabelOffset(.01);
2872  statmn_eta[ij]->GetXaxis()->SetLabelSize(.08);
2873  statmn_eta[ij]->GetXaxis()->SetLabelOffset(.01);
2874  statmn_eta[ij]->GetYaxis()->SetTitle("GeV");
2875  statmn_eta[ij]->GetYaxis()->SetTitleSize(.075);
2876  statmn_eta[ij]->GetYaxis()->CenterTitle();
2877  statmn_eta[ij]->GetYaxis()->SetTitleOffset(1.30);
2878 
2879  statmn_eta[ij]->Draw();
2880  nzone++;
2881  }
2882 
2883  sprintf(out_file, "statmnho_%i_side%i.eps", irunold, side);
2884  c2x->SaveAs(out_file);
2885 
2886  sprintf(out_file, "statmnho_%i_side%i.jpg", irunold, side);
2887  c2x->SaveAs(out_file);
2888 
2889  gStyle->SetOptLogy(1);
2890  gStyle->SetNdivisions(203,"XY");
2891 
2892  nzone = 0;
2893  for (int ij=nmn; ij<nmx; ij++) {
2894  c2x->cd(nzone+1);
2895  stat_eta[ij]->SetLineWidth(2);
2896  stat_eta[ij]->SetLineColor(4);
2897  stat_eta[ij]->GetXaxis()->SetTitle("#phi index");
2898  stat_eta[ij]->GetXaxis()->SetTitleSize(.08);
2899  stat_eta[ij]->GetXaxis()->CenterTitle();
2900  stat_eta[ij]->GetXaxis()->SetTitleOffset(0.80);
2901  stat_eta[ij]->GetXaxis()->SetLabelSize(.08);
2902  stat_eta[ij]->GetXaxis()->SetLabelOffset(.01);
2903  stat_eta[ij]->GetYaxis()->SetLabelSize(.08);
2904  stat_eta[ij]->GetYaxis()->SetLabelOffset(.01);
2905 
2906  stat_eta[ij]->Draw();
2907  nzone++;
2908  }
2909 
2910  sprintf(out_file, "statho_%i_side%i.eps", irunold, side);
2911  c2x->SaveAs(out_file);
2912 
2913  sprintf(out_file, "statho_%i_side%i.jpg", irunold, side);
2914  c2x->SaveAs(out_file);
2915  }
2916  delete c2x;
2917 
2918  } //if (m_figure) {
2919 
2920  if (!m_constant) { //m_constant
2921  for (int jk=0; jk<netamx; jk++) {
2922  for (int ij=0; ij<nphimx; ij++) {
2923  if (crossg[jk][ij]) { delete crossg[jk][ij];}
2924  if (sigrsg[jk][ij]) { delete sigrsg[jk][ij];}
2925  }
2926  }
2927  }
2928 }
2929 
2930 //define this as a plug-in
2932 
2933 /*
2934 75minute
2935 112MB data
2936 1M events
2937 
2938 */
2939 
RunNumber_t run() const
Definition: EventID.h:39
TH1F * corrsgrb[netamx][nphimx]
size
Write out results.
TH2F * sig_effi[neffip]
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
T getUntrackedParameter(std::string const &, T const &) const
TH1F * const_hpdrm[ringmx]
static const int ringmx
TH1F * com_crossg[ringmx][routmx+1]
std::string theRootFileName
TH1F * corrsgr[netamx][nphimx]
static const int npixrigh[21]
static const int mapx2[6][3]
static const int npixleft[21]
TH1F * corrsglu[netamx][nphimx]
std::vector< float > cro_ssg[netamx][nphimx+1]
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
HOCalibAnalyzer(const edm::ParameterSet &)
static const int rout12mx
TH1F * crossg[netamx][nphimx+1]
void beginJob() override
std::vector< HORecHit >::const_iterator const_iterator
static const int phimap[4][21]
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
TH1F * com_corrsgall[ringmx][sectmx]
float invang[netamx][nphimx+1]
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
TH1F * corrsgc[netamx][nphimx]
TH1F * peak_hpdrm[ringmx]
void endJob() override
static const int mapx1[6][3]
TH1F * corrsglb[netamx][nphimx]
TH1F * sigrsg[netamx][nphimx+1]
void analyze(const edm::Event &, const edm::EventSetup &) override
static const int netamx
TH1F * com_corrsglu[ringmx][sectmx]
static const int npixriup[21]
TH1F * ho_indenergy[netamx][nphimx]
static const int neffip
edm::InputTag hoCalibVariableCollectionTag
void set_sigma(double &x, bool mdigi)
TProfile * hopedtime[netamx][nphimx]
TProfile * hbtime[netamx][nphimx]
static const int ncut
std::string theoutputtxtFile
TH1F * com_sigrsg[ringmx][routmx+1]
TProfile * com_hbtime[ringmx][sectmx]
float com_invang[ringmx][routmx+1]
int iEvent
Definition: GenABIO.cc:230
int np
Definition: AMPTWrapper.h:33
Double_t totalfunc(Double_t *x, Double_t *par)
static const int nphimx
T sqrt(T t)
Definition: SSEVec.h:18
std::string theoutputpsFile
static const int npixribt[21]
TH1F * corrsgl[netamx][nphimx]
T Abs(T a)
Definition: MathUtil.h:49
TH1F * com_corrsgc[ringmx][sectmx]
int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
int iphifit
TH1F * com_corrsgrb[ringmx][sectmx]
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TH1F * com_corrsgr[ringmx][sectmx]
void fcnsg(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t flag)
double f[11][100]
static const int nbgpr
int getHOieta(int ij)
double fitprm[nsgpr][netamx]
T min(T a, T b)
Definition: MathUtil.h:58
bool isValid() const
Definition: HandleBase.h:74
TProfile * hotime[netamx][nphimx]
static const int npixleup[21]
Double_t gausX(Double_t *x, Double_t *par)
int invert_HOieta(int ieta)
int k[5][pyjets_maxn]
static const int nsgpr
TH1F * corrsgru[netamx][nphimx]
static const int routmx
const double fact
TH1F * com_corrsgl[ringmx][sectmx]
static const int mapx0m[9][2]
TH1F * com_corrsglb[ringmx][sectmx]
std::vector< float > sig_reg[netamx][nphimx+1]
edm::EDGetTokenT< HORecHitCollection > tok_allho_
void set_mean(double &x, bool mdigi)
TH1F * peak_eta[netamx]
static const int sectmx
TProfile * com_hopedtime[ringmx][sectmx]
edm::EventID id() const
Definition: EventBase.h:60
HLT enums.
edm::EDGetTokenT< HOCalibVariableCollection > tok_ho_
static const int mapx0p[9][2]
~HOCalibAnalyzer() override
TH1F * const_eta[netamx]
TH1F * com_corrsgru[ringmx][sectmx]
int ietafit
step
TProfile * com_hotime[ringmx][sectmx]
void fcnbg(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t flag)
Double_t langaufun(Double_t *x, Double_t *par)
static const int etamap[4][21]
static const int npixlebt[21]
static const int mypow_2_ncut
TH1F * statmn_eta[netamx]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
TProfile * sigvsevt[15][ncut]
TH1F * corrsgall[netamx][nphimx]
TH1F * stat_eta[netamx]