Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:55

0001 /*
0002 Identify digi and other correlaions
0003 Increase range of Digi plots
0004 Swap digi reco option
0005 Noise : Second TS has sharp fall
0006 Previous postion of SiPM : Problematic
0007 
0008 
0009 hadd hist_hoprompt_r2017ae.root hist_r2017a_hoprompt_v2a_1.root hist_r2017a_hoprompt_v3a_1.root hist_hoprompt_r2017b_v1.root hist_r2017b_hoprompt_v2a_1.root hist_r2017c_hoprompt_v1a_1.root hist_hoprompt_r2017c_v2.root hist_hoprompt_r2017c_v3.root hist_hoprompt_r2017d_v1.root hist_hoprompt_r2017e_v1.root
0010 
0011 
0012 */
0013 const int netamx = 30;
0014 const int nphimx = 72;
0015 int getieta(int ij) { return (ij < netamx / 2) ? -netamx / 2 + ij : -netamx / 2 + ij + 1; }
0016 int invert_ieta(int ieta) { return (ieta < 0) ? netamx / 2 + ieta : netamx / 2 + ieta - 1; }
0017 
0018 const int ncut = 14;
0019 const int ringmx = 5;
0020 const int nchnmx = 10;
0021 const int routmx = 36;
0022 const int rout12mx = 24;
0023 
0024 const int rbxmx = 12;     // HO readout box in Ring 0
0025 const int rbx12mx = 6;    //HO readout box in Ring+-1/2
0026 const int nprojtype = 5;  // Varities due to types of muon projection
0027 const char* projname[nprojtype] = {"Noise", "In RM", "3x3", "Proj", "Signal"};
0028 const int nprojmx = 4;
0029 const int nseltype = 4;  //Different crit for muon selection
0030 const int nadmx = 18;
0031 const int shapemx = 10;  //checking shape
0032 
0033 static const int nhothresh = 10;  // set threshold for noise filter
0034 
0035 TH2F* totalmuon;
0036 TH2F* totalproj[9];
0037 TH2F* totalhpd[18];
0038 
0039 TH2F* totalprojsig[9];
0040 TH2F* totalhpdsig[18];
0041 
0042 TH2F* total2muon;
0043 TH2F* total2proj[9];
0044 TH2F* total2hpd[18];
0045 
0046 TH2F* total2projsig[9];
0047 TH2F* total2hpdsig[18];
0048 
0049 Double_t gausX(Double_t* x, Double_t* par) { return par[0] * (TMath::Gaus(x[0], par[1], par[2], kTRUE)); }
0050 
0051 Double_t landX(Double_t* x, Double_t* par) { return par[0] * (TMath::Landau(x[0], par[1], par[2])); }
0052 
0053 Double_t completefit(Double_t* x, Double_t* par) { return gausX(x, par) + landX(x, &par[3]); }
0054 
0055 Double_t langaufun(Double_t* x, Double_t* par) {
0056   //Fit parameters:
0057   //par[0]*par[1]=Width (scale) parameter of Landau density
0058   //par[1]=Most Probable (MP, location) parameter of Landau density
0059   //par[2]=Total area (integral -inf to inf, normalization constant)
0060   //par[3]=Width (sigma) of convoluted Gaussian function
0061   //
0062   //In the Landau distribution (represented by the CERNLIB approximation),
0063   //the maximum is located at x=-0.22278298 with the location parameter=0.
0064   //This shift is corrected within this function, so that the actual
0065   //maximum is identical to the MP parameter.
0066   // /*
0067   // Numeric constants
0068   Double_t invsq2pi = 0.3989422804014;  // (2 pi)^(-1/2)
0069   Double_t mpshift = -0.22278298;       // Landau maximum location
0070 
0071   // Control constants
0072   Double_t np = 100.0;  // number of convolution steps
0073   Double_t sc = 5.0;    // convolution extends to +-sc Gaussian sigmas
0074 
0075   // Variables
0076   Double_t xx;
0077   Double_t mpc;
0078   Double_t fland;
0079   Double_t sum = 0.0;
0080   Double_t xlow, xupp;
0081   Double_t step;
0082 
0083   // MP shift correction
0084   mpc = par[1] - mpshift * par[0] * par[1];
0085   double scale = 1;   // par[1];
0086   double scale2 = 1;  //anormglb; // for notmalisation this is one, otehrwise use the normalisation;
0087   if (scale2 < .1)
0088     scale2 = 0.1;
0089   //  double scale=par[1];
0090   // Range of convolution integral
0091   xlow = x[0] - sc * scale * par[3];
0092   xupp = x[0] + sc * scale * par[3];
0093 
0094   step = (xupp - xlow) / np;
0095 
0096   // Convolution integral of Landau and Gaussian by sum
0097   for (double ij = 1.0; ij <= np / 2; ij++) {
0098     xx = xlow + (ij - .5) * step;
0099     fland = TMath::Landau(xx, mpc, par[0] * par[1], kTRUE);  // / par[0];
0100     if (xx > par[1]) {
0101       fland *= exp(-(xx - par[1]) / par[4]);
0102     }
0103     sum += fland * TMath::Gaus(x[0], xx, scale * par[3]);
0104     xx = xupp - (ij - .5) * step;
0105     fland = TMath::Landau(xx, mpc, par[0] * par[1], kTRUE);  // / par[0];
0106     if (xx > par[1]) {
0107       fland *= exp(-(xx - par[1]) / par[4]);
0108     }
0109     sum += fland * TMath::Gaus(x[0], xx, scale * par[3]);
0110   }
0111   return (par[2] * step * sum * invsq2pi / (scale2 * par[3]));
0112 }
0113 
0114 Double_t totalfunc(Double_t* x, Double_t* par) {
0115   return gausX(x, par) + langaufun(x, &par[3]);  // /max(.001,anormglb);
0116 }
0117 // binroot hocalib_r2017e_hoprompt_v1a_1.root hocalib_r2017g_hoprompt_v1a_1.root hocalib_r2017h_hoprompt_v1a_1.root
0118 void momentum() {
0119   gStyle->SetOptStat(1110);
0120   const int nfile = 3;
0121   TH1F* histx[nfile];
0122   TTree* T1x;
0123   char name[100];
0124   TCanvas* c1 = new TCanvas("c1", "runfile", 700, 300);
0125   c1->Divide(3, 1);
0126 
0127   for (int ij = 0; ij < nfile; ij++) {
0128     c1->cd(ij + 1);
0129     sprintf(name, "hist_%i", ij);
0130     histx[ij] = new TH1F(name, name, 120, -150., 150.);
0131     if (ij == 0) {
0132       //      _file2->cd(); // T1x = (TTree*)_file0->Get("T1");
0133     } else if (ij == 1) {
0134       //      _file0->cd(); // T1x = (TTree*)_file1->Get("T1");
0135     } else {
0136       //      _file2->cd();// T1x = (TTree*)_file2->Get("T1");
0137     }
0138     switch (ij) {
0139       case 0:
0140         _file0->cd();
0141         break;
0142       case 1:
0143         _file1->cd();
0144         break;
0145       case 2:
0146         _file2->cd();
0147         break;
0148     }
0149 
0150     T1x = (TTree*)gDirectory->Get("T1");
0151     T1x->Project(name, "trkmm");
0152     //    histx[ij]->Scale(1./TMath::Max(1.,histx[ij]->Integral()));
0153     histx[ij]->Draw();
0154     //    T1x->Draw("trkmm");
0155   }
0156 }
0157 
0158 /*
0159 binroot histalla_hcalcalho_2016btog.root
0160  .L tdrstyle.C 
0161 setTDRStyle()
0162 .L hocalib_pl16.C
0163 plot_fitres(23, 42);
0164 
0165 
0166 */
0167 
0168 void plot_fitres(int ieta = 13, int iphi = 70) {
0169   gStyle->SetOptTitle(0);
0170   gStyle->SetOptLogy(1);
0171   //   gStyle->SetOptStat(0); //1110);
0172   //   gStyle->SetLabelSize(0.095,"XYZ");
0173   //   gStyle->SetLabelOffset(0.01,"XYZ");
0174   //   gStyle->SetHistLineColor(1);
0175   //   gStyle->SetHistLineWidth(3);
0176   //   gStyle->SetPadTopMargin(0.02);
0177   //   gStyle->SetPadBottomMargin(0.12);
0178   //   gStyle->SetPadLeftMargin(0.14);
0179   //   gStyle->SetPadRightMargin(0.04);
0180   //   gStyle->SetPadGridX(3);
0181   //   gStyle->SetPadGridY(3);
0182   //   gStyle->SetGridStyle(2);
0183   //   gStyle->SetMarkerColor(1);
0184   //   gStyle->SetMarkerStyle(20);
0185   //   gStyle->SetMarkerSize(0.95);
0186   //   gStyle->SetNdivisions(506,"XY");
0187   //   gStyle->SetLabelSize(0.095,"XYZ");
0188   //   gStyle->SetLabelOffset(0.01,"XYZ");
0189   //   gStyle->SetStatH(.1);
0190   //   gStyle->SetStatW(.4);
0191 
0192   // -14, 1 plot_fitres(1,0);
0193   //  double par[8]={139.1, 0.0327856, 0.070529, 0.137647, 1.69858, 79549.1, 0.307275, 5.71755};
0194 
0195   // -8, 1 plot_fitres(7,0);
0196   //  double par[8]={31.5185, 0.0342954, 0.0599271, 0.151538, 1.10591, 91530.5, 0.22909, 8.65218};
0197   // -1, 1 plot_fitres(14,0);
0198   double par[8] = {23.6947, 0.0178834, 0.0318413, 0.160218, 0.985584, 77652.5, 0.15613, 10.0053};
0199 
0200   //-15, 1
0201   //  double par[8]={89.055, 0.0277592, 0.057265, 0.106515, 1.80511, 36326, 0.36995, 6.04276};
0202   // 9, 43  plot_fitres(23,42)
0203   //  double par[8]={ 29.3954, 0.0339121, 0.0644736, 0.160249, 1.15268, 94723.6, 0.239194, 10.5442};
0204   // 10, 43 plot_fitres(24,42)
0205   //  double par[8]={0.100621, 0.0413684, 0.077322, 0.154082, 1.22422, 80333, 0.315477, 12.1145};
0206   // 11, 43 plot_fitres(25,42)
0207   //  double par[8]={0.91, 0.0523604, 0.1, 0.25, 1.24822, 71042.8, 0.373684, 5.42163};
0208   // 12, 43 plot_fitres(26,42)
0209   //  double par[8]={0.550151, 0.0584881, 0.1, 0.246599, 1.38702, 84966.5, 0.35758, 4.92687};
0210 
0211   par[0] /= 18.0;
0212   par[5] /= 18.0;
0213 
0214   const char title[100];
0215   TH1F* histx[2];
0216   TH1F* histy[2];
0217 
0218   TF1* ped0fun;
0219   TF1* pedfun;
0220   TF1* sigfun;
0221   TF1* signalx;
0222   double xmn = -15.;
0223   double xmx = 20.;
0224 
0225   TCanvas* c1 = new TCanvas("c1", "runfile", 600, 600);
0226   //  c1->Divide(2,1);
0227   for (int i = 1; i < 2; i++) {
0228     //    c1->cd(i+1);
0229     switch (i) {
0230       case 0:
0231         sprintf(title, "hoCalibc/ped_eta%i_phi%i", ieta, iphi);
0232         break;
0233       case 1:
0234         sprintf(title, "hoCalibc/sig_eta%i_phi%i", ieta, iphi);
0235         break;
0236     }
0237 
0238     histy[i] = (TH1F*)gDirectory->Get(title);
0239     histx[i] = (TH1F*)histy[i]->Clone();
0240     cout << "name " << title << " " << histx[i]->GetBinWidth(100) << " " << histx[i]->GetTitle() << endl;
0241     //    histx[i]->GetXaxis()->SetRangeUser(xmn, (i+1)*xmx);
0242     histx[i]->SetLineColor(2 * (i + 1));
0243     histx[i]->SetLineWidth(2);
0244     histx[i]->Rebin(10);
0245 
0246     histx[i]->SetMaximum(1.52 * histx[i]->GetMaximum());
0247 
0248     //    histx[i]->SetNdivisions(506,"XY");
0249 
0250     //    histx[i]->GetXaxis()->SetLabelSize(.055);
0251     //    histx[i]->GetYaxis()->SetLabelSize(.055);
0252     //    histx[i]->GetYaxis()->SetTitleOffset(1.4);
0253 
0254     switch (i) {
0255       case 0:
0256         histx[i]->GetXaxis()->SetRangeUser(-16., 16.);
0257         histx[i]->GetXaxis()->SetTitle("HO Pedestal (GeV)");
0258         break;
0259       case 1:
0260         histx[i]->GetXaxis()->SetRangeUser(-20., 40.);
0261         histx[i]->GetXaxis()->SetTitle("HO Signal (GeV)");
0262         break;
0263     }
0264     //    histx[i]->GetXaxis()->SetTitleSize(.055);
0265     //    //      histx[i]->GetXaxis()->CenterTitle();
0266     histx[i]->GetYaxis()->SetTitle("Nevents");
0267     //    histx[i]->GetYaxis()->SetTitleSize(.055);
0268     //      if (i==0) histx[i]->GetXaxis()->SetRangeUser(-5., 5.);
0269     histx[i]->Draw();
0270   }
0271 
0272   //   c1->cd(1);
0273   //   TPaveText *ptst1 = new TPaveText(.85,0.9,.90,.95,"brNDC");
0274   //   ptst1->SetFillColor(10);
0275   //   TText* text1 = ptst1->AddText("(a)");
0276   //   text1->SetTextSize(0.062);
0277   //   ptst1->SetBorderSize(0);
0278   //   ptst1->Draw();
0279 
0280   //   ped0fun = new TF1("temp", gausX, xmn, xmx, 3);
0281   //   ped0fun->SetParameters(gaupr);
0282   //   ped0fun->SetLineColor(3);
0283   //   ped0fun->SetLineWidth(2);
0284   //   ped0fun->Draw("same");
0285 
0286   //   c1->cd(2);
0287 
0288   //   TPaveText *ptst = new TPaveText(0.85,0.9,0.90,.95,"brNDC");
0289   //   ptst->SetFillColor(10);
0290   //   TText* text = ptst->AddText("(b)");
0291   //   text->SetTextSize(0.062);
0292   //   ptst->SetBorderSize(0);
0293   //   ptst->Draw();
0294 
0295   pedfun = new TF1("ped0", gausX, xmn, 4 * xmx, 3);
0296   pedfun->SetParameters(par);
0297   pedfun->SetLineWidth(2);
0298   pedfun->SetLineColor(3);
0299   pedfun->Draw("same");
0300 
0301   sigfun = new TF1("signalfun", langaufun, xmn, 4 * xmx, 5);
0302   sigfun->SetParameters(&par[3]);
0303   sigfun->SetLineWidth(2);
0304   sigfun->SetLineColor(4);
0305   sigfun->Draw("same");
0306 
0307   signalx = new TF1("total", totalfunc, xmn, 4 * xmx, 8);
0308   signalx->SetParameters(par);
0309   signalx->SetLineWidth(2);
0310   signalx->SetLineWidth(1);
0311   signalx->Draw("same");
0312 
0313   cmsPrel(.55, .75, .55, .75, 0.045, 35);
0314 }
0315 
0316 /*
0317  binroot fit_2016btog_ar1_float_par8_rng30.root
0318  .L tdrstyle.C 
0319 setTDRStyle()
0320 .L hocalib_pl16.C
0321 const_term_1dx("const_eta_phi")
0322 const_term_2d()
0323 */
0324 
0325 /*
0326 binroot fit_r2017a_v2_ar1_float_par8_rng25.root fit_r2017a_v3_ar1_float_par8_rng25.root fit_r2017b_v1_ar1_float_par8_rng25.root fit_r2017b_v2_ar1_float_par8_rng25.root fit_r2017c_v1_ar1_float_par8_rng25.root fit_r2017c_v2_ar1_float_par8_rng25.root fit_r2017c_v3_ar1_float_par8_rng25.root fit_r2017d_v1_ar1_float_par8_rng25.root fit_r2017e_v1_ar1_float_par8_rng25.root fit_r2017f_v1_ar1_float_par8_rng25.root fit_r2017g_v1_ar1_float_par8_rng25.root fit_r2017h_v1_ar1_float_par8_rng25.root fit_r2017ae_ar1_float_par8_rng25.root fit_r2017af_ar1_float_par8_rng25.root
0327 
0328 
0329 
0330 
0331 */
0332 
0333 void all_1d4x() {
0334   TCanvas* c1 = new TCanvas("c1", "c1", 700, 500);
0335   c1->Divide(2, 2);
0336 
0337   _file0->cd();
0338   const_term_1d4x();
0339   _file1->cd();
0340   const_term_1d4x();
0341   _file2->cd();
0342   const_term_1d4x();
0343   _file3->cd();
0344   const_term_1d4x();
0345   _file4->cd();
0346   const_term_1d4x();
0347   _file5->cd();
0348   const_term_1d4x();
0349   _file6->cd();
0350   const_term_1d4x();
0351   _file7->cd();
0352   const_term_1d4x();
0353   _file8->cd();
0354   const_term_1d4x();
0355   _file9->cd();
0356   const_term_1d4x();
0357   _file10->cd();
0358   const_term_1d4x();
0359   _file11->cd();
0360   const_term_1d4x();
0361   _file12->cd();
0362   const_term_1d4x();
0363   _file13->cd();
0364   const_term_1d4x();
0365 
0366   /*
0367 fit_r2017a_v2_a
0368 val   0.363+- 0.294  0.211+- 0.173  0.468+- 0.184  0.282+-  0.11
0369 err   5.461+-  0.27  4.622+- 0.155  4.444+- 0.177  4.765+- 0.092
0370 fit_r2017a_v3_a
0371 val   0.554+- 0.105 -0.372+- 0.073 -0.165+-  0.08 -0.063+- 0.047
0372 err   2.205+- 0.096  2.039+-  0.06  2.029+- 0.066  2.159+- 0.037
0373 fit_r2017b_v1_a
0374 val   1.577+- 0.043  0.964+- 0.032  1.234+- 0.035  1.208+- 0.021
0375 err   0.944+- 0.036    0.9+- 0.027  0.934+- 0.028  0.974+- 0.018
0376 fit_r2017b_v2_a
0377 val   2.209+- 0.072  1.826+-  0.05  2.038+- 0.055  1.969+- 0.032
0378 err    1.54+- 0.073   1.37+- 0.039  1.397+- 0.047  1.485+- 0.026
0379 fit_r2017c_v1_a
0380 val   2.439+- 0.056  1.933+-  0.04  2.125+- 0.046  2.118+- 0.027
0381 err   1.208+-  0.05   1.12+- 0.032  1.225+- 0.038   1.22+- 0.022
0382 fit_r2017c_v2_a
0383 val   2.569+- 0.045  1.996+- 0.032  2.289+- 0.038  2.247+- 0.022
0384 err   0.969+- 0.035   0.93+- 0.028   0.97+- 0.034  0.995+- 0.018
0385 fit_r2017c_v3_a
0386 val   2.657+- 0.044  2.128+- 0.033  2.349+- 0.036  2.332+- 0.021
0387 err   0.909+- 0.034  0.952+-  0.03  0.955+-  0.03  0.985+- 0.019
0388 fit_r2017d_v1_a
0389 val   2.852+- 0.044  2.287+- 0.037  2.512+- 0.037  2.512+- 0.023
0390 err   0.925+- 0.042  1.019+- 0.032  0.925+- 0.031  1.018+-  0.02
0391 fit_r2017e_v1_a
0392 val    3.04+- 0.042  2.448+- 0.034  2.836+- 0.036  2.742+- 0.021
0393 err   0.872+- 0.034  0.856+- 0.028    0.9+-  0.03  0.932+- 0.017
0394 fit_r2017f_v1_a
0395 val    3.18+- 0.048  2.541+- 0.037  2.868+- 0.039  2.817+- 0.024
0396 err   1.036+- 0.037  1.038+- 0.033  1.038+- 0.035  1.092+- 0.021
0397 fit_r2017g_v1_a
0398 val   0.035+- 0.155 -2.666+- 0.116 -4.415+- 0.099 -2.728+- 0.084
0399 err    3.17+- 0.141  3.098+- 0.102   2.42+- 0.087  3.351+- 0.062
0400 fit_r2017h_v1_a
0401 val   0.116+- 0.079 -2.594+- 0.057 -4.639+- 0.055 -2.684+- 0.061
0402 err   1.705+- 0.077  1.531+- 0.052   1.43+- 0.041  2.384+- 0.041
0403 fit_r2017ae_ar1
0404 val   2.569+- 0.032  1.989+- 0.027  2.265+- 0.029  2.238+- 0.017
0405 err   0.711+- 0.027  0.738+- 0.023  0.761+- 0.026  0.795+- 0.015
0406 fit_r2017af_ar1
0407 val    2.68+- 0.032  2.064+- 0.027   2.36+- 0.029  2.328+- 0.018
0408 err   0.694+- 0.025  0.748+- 0.023   0.76+- 0.025  0.804+- 0.014
0409 
0410 
0411 
0412 
0413   */
0414 }
0415 
0416 void all_2d() {
0417   TCanvas* c1 = new TCanvas("c1", "c1", 700, 400);
0418   //  c1->Divide(2,2);
0419 
0420   _file0->cd();
0421   const_term_2d();
0422   _file1->cd();
0423   const_term_2d();
0424   _file2->cd();
0425   const_term_2d();
0426   _file3->cd();
0427   const_term_2d();
0428   _file4->cd();
0429   const_term_2d();
0430   _file5->cd();
0431   const_term_2d();
0432   _file6->cd();
0433   const_term_2d();
0434   _file7->cd();
0435   const_term_2d();
0436   _file8->cd();
0437   const_term_2d();
0438   _file9->cd();
0439   const_term_2d();
0440   _file10->cd();
0441   const_term_2d();
0442   _file11->cd();
0443   const_term_2d();
0444   _file12->cd();
0445   const_term_2d();
0446   _file13->cd();
0447   const_term_2d();
0448 }
0449 
0450 void const_term_1d4x(const char* varname = "const_eta_phi") {
0451   gStyle->SetOptTitle(0);
0452   gStyle->SetOptFit(111);
0453   gStyle->SetOptStat(1110);
0454   gStyle->SetOptLogy(1);
0455   gStyle->SetPadTopMargin(0.01);
0456   gStyle->SetPadBottomMargin(0.13);
0457   gStyle->SetPadLeftMargin(0.12);
0458   gStyle->SetPadRightMargin(0.01);
0459   gStyle->SetStatY(.99);  //89);
0460   gStyle->SetStatX(.99);  //94);
0461   gStyle->SetStatH(.22);
0462   gStyle->SetStatW(.27);
0463 
0464   TLatex latex;
0465   latex.SetNDC();
0466   latex.SetTextSize(0.075);
0467   latex.SetTextFont(42);
0468   latex.SetTextAlign(31);  // align right
0469 
0470   TCanvas* c1 = new TCanvas("c1", "c1", 700, 400);
0471   c1->Divide(2, 2);
0472 
0473   //  for (int ixj=0; ixj<14; ixj++) {
0474   //     switch(ixj) {
0475   //     case 0 : _file0->cd(); break;
0476   //     case 1 : _file1->cd(); break;
0477   //     case 2 : _file2->cd(); break;
0478   //     case 3 : _file3->cd(); break;
0479   //     case 4 : _file4->cd(); break;
0480   //     case 5 : _file5->cd(); break;
0481   //     case 6 : _file6->cd(); break;
0482   //     case 7 : _file7->cd(); break;
0483   //     case 8 : _file8->cd(); break;
0484   //     case 9 : _file9->cd(); break;
0485   //     case 10 : _file10->cd(); break;
0486   //     case 11 : _file11->cd(); break;
0487   //     case 12 : _file12->cd(); break;
0488   //     case 13 : _file13->cd(); break;
0489   //     default : _file0->cd(); break;
0490   //     }
0491 
0492   TH2F* hist2d = (TH2F*)gDirectory->Get(varname);
0493   TH1F* histx[4];
0494   histx[0] = new TH1F("histx0", "Correction factor - 1 (R0)", 120, -0.11, 0.29);     //.9, 1.3);
0495   histx[1] = new TH1F("histx1", "Correction factor - 1 (R#pm1)", 120, -0.11, 0.29);  //.9, 1.3);
0496   histx[2] = new TH1F("histx2", "Correction factor - 1 (R#pm2)", 120, -0.11, 0.29);  //.9, 1.3);
0497   histx[3] = new TH1F("histx3", "Correction factor - 1 (All)", 120, -0.11, 0.29);    //.9, 1.3);
0498 
0499   char name[100] = gDirectory->GetName();
0500   char namex[20];
0501   char namey[50];
0502   strncpy(namex, name, 15);
0503   char* pchy = strchr(namex, '_');
0504   int len = pchy - namex;
0505   strncpy(namey, namex, len);
0506 
0507   cout << namex << " " << namey << endl;
0508   float value[2][4] = {0};
0509   float error[2][4] = {0};
0510 
0511   for (int ij = 0; ij < hist2d->GetNbinsX(); ij++) {
0512     int ieta = getieta(ij);
0513     for (int jk = 0; jk < hist2d->GetNbinsY(); jk++) {
0514       double xx = hist2d->GetBinContent(ij + 1, jk + 1) - 1.0;
0515       if (xx > -0.5) {
0516         if (abs(ieta) <= 4) {
0517           histx[0]->Fill(xx);
0518         } else if (abs(ieta) <= 10) {
0519           histx[1]->Fill(xx);
0520         } else if (abs(ieta) <= 15) {
0521           histx[2]->Fill(xx);
0522         }
0523         histx[3]->Fill(xx);
0524       }
0525     }
0526   }
0527   for (int ij = 0; ij < 4; ij++) {
0528     c1->cd(ij + 1);
0529     histx[ij]->GetXaxis()->SetTitle(histx[ij]->GetTitle());
0530     histx[ij]->GetXaxis()->SetLabelOffset(.001);
0531     histx[ij]->GetXaxis()->SetLabelSize(0.0645);
0532     histx[ij]->GetXaxis()->SetTitleSize(0.065);
0533     histx[ij]->GetXaxis()->SetTitleOffset(0.99);
0534 
0535     histx[ij]->GetYaxis()->SetTitle("Entries/0.005");
0536     histx[ij]->GetYaxis()->SetLabelOffset(.001);
0537     histx[ij]->GetYaxis()->SetLabelSize(0.0645);
0538     histx[ij]->GetYaxis()->SetTitleSize(0.065);
0539     histx[ij]->GetYaxis()->SetTitleOffset(0.85);
0540 
0541     histx[ij]->SetLineWidth(1);
0542     TFitResultPtr ptr = histx[ij]->Fit("gaus", "QS");
0543     Int_t fitStatus = ptr;
0544     if (fitStatus == 0) {
0545       value[0][ij] = int(100000 * ptr->Parameter(1)) / 1000.;
0546       value[1][ij] = int(100000 * ptr->Parameter(2)) / 1000.;
0547       error[0][ij] = int(100000 * ptr->ParError(1)) / 1000.;
0548       error[1][ij] = int(100000 * ptr->ParError(2)) / 1000.;
0549 
0550       //      cout<<ij<<" "<<int(100000*ptr->Parameter(1))/1000.<<"+-"<< int(100000*ptr->ParError(1))/1000.<<" "<<int(100000*ptr->Parameter(2))/1000.<<"+-"<< int(100000*ptr->ParError(2))/1000.<<endl;
0551     }
0552   }
0553   //    latex.DrawLatex(0.85, 0.45, namex);
0554 
0555   sprintf(namey, "const_term_1d4x_%s.png", namex);
0556   c1->SaveAs(namey);
0557 
0558   cout << "val ";
0559   for (int ij = 0; ij < 4; ij++) {
0560     cout << " " << setw(6) << value[0][ij] << "+-" << setw(6) << error[0][ij];
0561   }
0562   cout << endl;
0563   cout << "err ";
0564   for (int ij = 0; ij < 4; ij++) {
0565     cout << " " << setw(6) << value[1][ij] << "+-" << setw(6) << error[1][ij];
0566   }
0567   cout << endl;
0568   for (int ij = 0; ij < 4; ij++) {
0569     if (histx[ij]) {
0570       delete histx[ij];
0571       histx[ij] = 0;
0572     }
0573   }
0574   //  }
0575 }
0576 
0577 void const_term_1dx(const char* varname = "const_eta_phi") {
0578   ofstream file_out("test_output.log");
0579   gStyle->SetOptFit(101);
0580   gStyle->SetOptStat(0);
0581   gStyle->SetOptLogy(1);
0582   gStyle->SetPadTopMargin(0.1);
0583   gStyle->SetPadBottomMargin(0.11);
0584   gStyle->SetPadLeftMargin(0.14);
0585   gStyle->SetPadRightMargin(0.03);
0586   gStyle->SetStatY(.93);  //89);
0587   gStyle->SetStatX(.98);  //94);
0588   gStyle->SetStatH(.16);
0589   gStyle->SetStatW(.19);
0590 
0591   TH2F* hist2d[3];
0592 
0593   hist2d[0] = (TH2F*)gDirectory->Get(varname);
0594   hist2d[1] = (TH2F*)gDirectory->Get("const_eta_phisum");
0595   TH1F* histx[3];
0596   histx[0] = new TH1F("histx0", "const_eta_phi", 120, .7, 1.3);
0597   histx[1] = new TH1F("histx1", "const_eta_phisum", 120, .7, 1.3);
0598   histx[2] = new TH1F("histx2", "Correction term", 120, -.2, .2);
0599   hist2d[2] = new TH2F("hist2d2", "hist2d2", 120, .9, 1.1, 120, .9, 1.1);
0600   for (int ij = 0; ij < hist2d[0]->GetNbinsX(); ij++) {
0601     //    if (hist2d[0]->GetBinCenter(ij+1)==0) continue;
0602     for (int jk = 0; jk < hist2d[0]->GetNbinsY(); jk++) {
0603       double xx = hist2d[0]->GetBinContent(ij + 1, jk + 1);
0604       if (xx > 0.5) {
0605         histx[0]->Fill(xx);
0606       }
0607       if (ij != 15)
0608         file_out << hist2d[0]->GetXaxis()->GetBinCenter(ij + 1) << "\t" << jk + 1 << "\t " << xx << endl;
0609 
0610       double yy = hist2d[1]->GetBinContent(ij + 1, jk + 1);
0611       if (yy > 0.5) {
0612         histx[1]->Fill(yy);
0613       }
0614       if (xx > .5 && yy > .5) {
0615         histx[2]->Fill(yy - xx);
0616         hist2d[2]->Fill(xx, yy);
0617       }
0618     }
0619   }
0620   TCanvas* c1 = new TCanvas("c1", "c1", 500, 500);
0621   //  c1->Divide(2,2);
0622   /*  c1->cd(1);  histx[0]->Fit("gaus");
0623       c1->cd(2);  histx[1]->Fit("gaus");
0624       c1->cd(3); histx[2]->Fit("gaus");
0625   */
0626 
0627   histx[0]->GetXaxis()->SetTitle("Correction factor");
0628   histx[0]->GetXaxis()->SetLabelOffset(.001);
0629   histx[0]->GetXaxis()->SetLabelSize(0.0645);
0630   histx[0]->GetXaxis()->SetTitleSize(0.065);
0631   histx[0]->GetXaxis()->SetTitleOffset(0.75);
0632 
0633   histx[0]->GetYaxis()->SetTitle("Entries/0.005");
0634   histx[0]->GetYaxis()->SetLabelOffset(.001);
0635   histx[0]->GetYaxis()->SetLabelSize(0.0645);
0636   histx[0]->GetYaxis()->SetTitleSize(0.065);
0637   histx[0]->GetYaxis()->SetTitleOffset(1.05);
0638 
0639   histx[0]->SetLineWidth(1);
0640   histx[0]->Fit("gaus");
0641   //  c1->cd(4);  gPad->SetLogy(0); hist2d[2]->Draw("colz");
0642   //  cmsPrel(.25, .45, .85, .62, 0.04, 35);
0643   file_out.close();
0644 }
0645 
0646 void const_term_2dx(const char* varname = "const_eta_phi") {
0647   gStyle->SetOptStat(0);
0648   gStyle->SetOptTitle(0);
0649   gStyle->SetOptLogy(0);
0650 
0651   gStyle->SetPalette(1, 0);
0652   gStyle->SetPadTopMargin(0.12);
0653   gStyle->SetPadBottomMargin(0.12);
0654   gStyle->SetPadLeftMargin(0.08);
0655   gStyle->SetPadRightMargin(0.15);
0656 
0657   TH2F* hist2d = (TH2F*)gDirectory->Get(varname);
0658 
0659   hist2d->SetMaximum(1.5);
0660   hist2d->SetMinimum(0.7);
0661   hist2d->GetXaxis()->SetTitle("i#eta");
0662   hist2d->GetYaxis()->SetTitle("i#phi");
0663 
0664   hist2d->Draw("colz");
0665 
0666   cmsPrel2(.75, .5, .15, .92, 0.025, 35);
0667 }
0668 
0669 double hothreshs[nhothresh + 1] = {0.15, 0.25, 0.5, 1.0, 2.0, 5.0, 10.0, 20., 50, 100., 10000.};
0670 void def_setting() {
0671   gStyle->SetPadTopMargin(0.02);
0672   gStyle->SetPadBottomMargin(0.15);
0673   gStyle->SetPadLeftMargin(0.08);
0674   gStyle->SetPadRightMargin(0.16);
0675   gStyle->SetOptStat(0);
0676   //  gStyle->SetPadGridX(1);
0677   //  gStyle->SetPadGridY(1);
0678   //  gStyle->SetGridStyle(3);
0679   gStyle->SetGridWidth(1);
0680   gStyle->SetTitleFontSize(0.09);
0681   gStyle->SetTitleOffset(-0.09);
0682   gStyle->SetTitleBorderSize(1);
0683   gStyle->SetLabelSize(0.095, "XY");
0684   gStyle->SetOptTitle(0);
0685   gStyle->SetOptStat(0);
0686   gStyle->SetNdivisions(404, "XYZ");
0687 
0688   gStyle->SetStatTextColor(1);
0689   gStyle->SetStatX(.99);
0690   gStyle->SetStatY(.99);
0691   gStyle->SetStatW(.3);
0692   gStyle->SetStatH(.2);
0693 
0694   gStyle->SetOptLogy(0);
0695 }
0696 
0697 void const_term(const char* varname = "const_eta_phi") {
0698   ofstream file_out("test_output.log");
0699   gStyle->SetOptFit(101);
0700   gStyle->SetOptStat(0);
0701   gStyle->SetOptLogy(1);
0702   gStyle->SetLabelSize(.065, "XY");
0703 
0704   TH2F* hist2d[3];
0705 
0706   hist2d[0] = (TH2F*)gDirectory->Get("const_eta_phi");
0707   hist2d[1] = (TH2F*)gDirectory->Get("const_eta_phisum");
0708 
0709   TH1F* histx[3];
0710   histx[0] = new TH1F("histx0", "const_eta_phi", 120, .7, 1.3);
0711   histx[1] = new TH1F("histx1", "const_eta_phisum", 120, .7, 1.3);
0712   histx[2] = new TH1F("histx2", "diff", 120, -.2, .2);
0713   hist2d[2] = new TH2F("hist2d2", "hist2d2", 120, .9, 1.1, 120, .9, 1.1);
0714 
0715   for (int ij = 0; ij < hist2d[0]->GetNbinsX(); ij++) {
0716     //    if (hist2d[0]->GetBinCenter(ij+1)==0) continue;
0717     for (int jk = 0; jk < hist2d[0]->GetNbinsY(); jk++) {
0718       double xx = hist2d[0]->GetBinContent(ij + 1, jk + 1);
0719       if (xx > 0.5) {
0720         histx[0]->Fill(xx);
0721       }
0722       if (ij != 15)
0723         file_out << hist2d[0]->GetXaxis()->GetBinCenter(ij + 1) << "\t" << jk + 1 << "\t " << xx << endl;
0724 
0725       double yy = hist2d[1]->GetBinContent(ij + 1, jk + 1);
0726       if (yy > 0.5) {
0727         histx[1]->Fill(yy);
0728       }
0729       if (xx > .5 && yy > .5) {
0730         histx[2]->Fill(yy - xx);
0731         hist2d[2]->Fill(xx, yy);
0732       }
0733     }
0734   }
0735   TCanvas* c1 = new TCanvas("c1", "c1", 700, 900);
0736   c1->Divide(2, 2);
0737   c1->cd(1);
0738   histx[0]->Fit("gaus");
0739   c1->cd(2);
0740   histx[1]->Fit("gaus");
0741   c1->cd(3);
0742   histx[2]->Fit("gaus");
0743   c1->cd(4);
0744   gPad->SetLogy(0);
0745   hist2d[2]->Draw("colz");
0746   file_out.close();
0747 }
0748 
0749 void const_term_2d(const char* varname = "const_eta_phi") {
0750   gStyle->SetOptStat(0);
0751   gStyle->SetOptTitle(0);
0752   gStyle->SetPalette(1, 0);
0753   gStyle->SetPadTopMargin(0.09);
0754   gStyle->SetPadBottomMargin(0.11);
0755   gStyle->SetPadLeftMargin(0.11);
0756   gStyle->SetPadRightMargin(0.15);
0757 
0758   TLatex latex;
0759   latex.SetNDC();
0760   latex.SetTextSize(0.065);
0761   latex.SetTextFont(42);
0762   latex.SetTextAlign(31);  // align right
0763 
0764   TH2F* hist2d = (TH2F*)gDirectory->Get(varname);
0765 
0766   hist2d->GetXaxis()->SetLabelOffset(.001);
0767   hist2d->GetXaxis()->SetLabelSize(0.064);
0768   hist2d->GetXaxis()->SetTitle("i#eta");
0769   hist2d->GetXaxis()->SetTitleSize(0.065);
0770   hist2d->GetXaxis()->SetTitleOffset(0.75);
0771   hist2d->GetXaxis()->SetTitleColor(1);
0772   hist2d->GetXaxis()->CenterTitle();
0773 
0774   hist2d->GetYaxis()->SetLabelOffset(.001);
0775   hist2d->GetYaxis()->SetLabelSize(0.064);
0776   hist2d->GetYaxis()->SetTitleSize(0.065);
0777   hist2d->GetYaxis()->SetTitle("i#phi");
0778   hist2d->GetYaxis()->SetTitleOffset(0.68);
0779   hist2d->GetYaxis()->CenterTitle();
0780 
0781   hist2d->GetZaxis()->SetLabelSize(0.045);
0782 
0783   //  hist2d->SetMaximum(1.2);
0784   hist2d->SetMinimum(0.7);
0785   hist2d->Draw("colz");  //"colz");
0786                          //   //c1->SaveAs("test.png");
0787                          //    cout <<"XX "<<endl;
0788                          //    TPaletteAxis* palette = new TPaletteAxis(15.7, 0.5, 18.5, 72.5, hist2d);
0789                          //    cout <<"XX "<<endl;
0790                          //    palette->SetLabelColor(1);
0791                          //    palette->SetLabelFont(22);
0792                          //    palette->SetLabelOffset(0.005);
0793                          //    palette->SetLabelSize(0.0436);
0794                          //    palette->SetTitleOffset(1);
0795                          //    palette->SetTitleSize(0.08);
0796                          //    palette->SetFillColor(100);
0797                          //    palette->SetFillStyle(1001);
0798                          //    hist2d->GetListOfFunctions()->Add(palette,"br");
0799                          //    hist2d->Draw("colz");
0800                          //    //  cmsPrel2(.75, .5, .15, .92, 0.03, 35);
0801 
0802   char name[100] = gDirectory->GetName();
0803   char namex[20];
0804   char namey[50];
0805   strncpy(namex, name, 15);
0806   cout << namex << endl;
0807   latex.DrawLatex(0.65, 0.92, namex);
0808   sprintf(namey, "statistics_2d_%s.png", namex);
0809   c1->SaveAs(namey);
0810 }
0811 
0812 void signal4(int ival = 0, int ndvy = 3) {
0813   gStyle->SetOptStat(0);
0814   gStyle->SetPadTopMargin(0.11);
0815   gStyle->SetPadBottomMargin(0.08);
0816   gStyle->SetPadLeftMargin(0.08);
0817   gStyle->SetPadRightMargin(0.20);
0818   TCanvas* c1 = new TCanvas("c1", "c1", 700, 900);
0819 
0820   char name[100];
0821 
0822   c1->Divide(3, ndvy);
0823 
0824   TH2F* histx[100];
0825   for (int ij = 0; ij < 3 * ndvy; ij++) {
0826     //    sprintf(name, "hoCalibc/%s_%i", varnam, ij);
0827     histx[ij] = (TH2F*)gDirectory->Get(name);
0828     switch (ival) {
0829       case 0:
0830         histx[ij] = (TH2F*)totalproj[ij]->Clone();
0831         break;
0832       case 1:
0833         histx[ij] = (TH2F*)total2proj[ij]->Clone();
0834         break;
0835       case 2:
0836         histx[ij] = (TH2F*)totalprojsig[ij]->Clone();
0837         break;
0838       case 3:
0839         histx[ij] = (TH2F*)total2projsig[ij]->Clone();
0840         break;
0841       case 4:
0842         histx[ij] = (TH2F*)totalhpd[ij]->Clone();
0843         break;
0844       case 5:
0845         histx[ij] = (TH2F*)total2hpd[ij]->Clone();
0846         break;
0847       case 6:
0848         histx[ij] = (TH2F*)totalhpdsig[ij]->Clone();
0849         break;
0850       case 7:
0851         histx[ij] = (TH2F*)total2hpdsig[ij]->Clone();
0852         break;
0853       default:
0854         break;
0855     }
0856     c1->cd(ij + 1);
0857     if (strstr(histx[ij]->GetName(), "sig")) {
0858       histx[ij]->SetMaximum(TMath::Min(3., histx[ij]->GetMaximum()));
0859     }
0860     histx[ij]->GetXaxis()->SetLabelSize(0.075);
0861     histx[ij]->GetYaxis()->SetLabelSize(0.075);
0862     histx[ij]->GetZaxis()->SetLabelSize(0.065);
0863     histx[ij]->GetXaxis()->SetNdivisions(404);
0864     histx[ij]->GetYaxis()->SetNdivisions(404);
0865     histx[ij]->Draw("colz");
0866   }
0867   c1->Update();
0868 }
0869 
0870 // plot_var("sigvsacc")
0871 void plot_var(int icut) {
0872   const int nvar = 15;
0873   gStyle->SetTitleFontSize(0.075);
0874   gStyle->SetTitleBorderSize(1);
0875   gStyle->SetPadTopMargin(0.10);
0876   gStyle->SetPadBottomMargin(0.10);
0877   char title[100];
0878   TCanvas* c1 = new TCanvas("c1", "runfile", 700., 900.);
0879   c1->Divide(5, 3, 1.e-5, 1.e-5, 0);
0880 
0881   TH2F* fprofx[nvar];
0882   for (int ij = 0; ij < nvar; ij++) {
0883     c1->cd(ij + 1);
0884     sprintf(title, "hoCalibc/sigring_%i_%i", icut, ij);
0885 
0886     fprofx[ij] = (TH2F*)gDirectory->Get(title);
0887     fprofx[ij]->GetXaxis()->SetLabelOffset(-0.03);
0888     fprofx[ij]->GetXaxis()->SetLabelSize(0.085);
0889     fprofx[ij]->GetYaxis()->SetLabelSize(0.075);
0890     fprofx[ij]->GetZaxis()->SetLabelSize(0.065);
0891     fprofx[ij]->GetYaxis()->SetNdivisions(404);
0892     fprofx[ij]->GetXaxis()->SetNdivisions(404);
0893     fprofx[ij]->SetLineColor(2);
0894     fprofx[ij]->SetLineWidth(2);
0895 
0896     fprofx[ij]->Draw("colz");
0897     fprofx[ij]->ProfileX()->Draw("same");
0898 
0899     //     if (ij==7) {
0900     //       TPaveStats *ptst = new TPaveStats(0.5,0.5,0.7,0.6,"brNDC");
0901     //       ptst->SetFillColor(10);
0902     //       TText* text = ptst->AddText(var);
0903     //       text->SetTextSize(0.092);
0904     //       ptst->SetBorderSize(1);
0905     //       //   ptst->AddText(name);
0906     //       ptst->Draw();
0907     //     }
0908   }
0909   c1->Update();
0910 }
0911 
0912 // plot_var("sigvsacc")
0913 void plot_varprof(int icut) {
0914   const int nvar = 15;
0915   gStyle->SetTitleFontSize(0.075);
0916   gStyle->SetTitleBorderSize(1);
0917   gStyle->SetPadTopMargin(0.12);
0918   gStyle->SetPadBottomMargin(0.10);
0919   char title[100];
0920   TCanvas* c1 = new TCanvas("c1", "runfile", 700., 900.);
0921   c1->Divide(5, 3, 1.e-5, 1.e-5, 0);
0922 
0923   TProfile* fprofx[nvar];
0924   for (int ij = 0; ij < nvar; ij++) {
0925     c1->cd(ij + 1);
0926     sprintf(title, "hoCalibc/sigring_%i_%i", icut, ij);
0927 
0928     fprofx[ij] = (TProfile*)(((TH2F*)gDirectory->Get(title))->ProfileX());
0929     fprofx[ij]->GetXaxis()->SetLabelOffset(-0.03);
0930     fprofx[ij]->GetXaxis()->SetLabelSize(0.085);
0931     fprofx[ij]->GetYaxis()->SetLabelSize(0.075);
0932     fprofx[ij]->GetYaxis()->SetNdivisions(404);
0933     fprofx[ij]->GetXaxis()->SetNdivisions(404);
0934     fprofx[ij]->SetLineColor(2);
0935     fprofx[ij]->SetLineWidth(2);
0936 
0937     fprofx[ij]->Draw();
0938 
0939     //     if (ij==7) {
0940     //       TPaveStats *ptst = new TPaveStats(0.5,0.5,0.7,0.6,"brNDC");
0941     //       ptst->SetFillColor(10);
0942     //       TText* text = ptst->AddText(var);
0943     //       text->SetTextSize(0.092);
0944     //       ptst->SetBorderSize(1);
0945     //       //   ptst->AddText(name);
0946     //       ptst->Draw();
0947     //     }
0948   }
0949   c1->Update();
0950 }
0951 
0952 void plot_var_tray(int id = 0, int icut = 0) {
0953   //plot_var_tray(0,1)
0954 
0955   char title[100];
0956   TCanvas* c1 = new TCanvas("c1", "runfile", 700., 900.);
0957   c1->Divide(5, 6, 1.e-5, 1.e-5, 0);
0958 
0959   TH2F* fprofx[30];
0960   int itag = 0;
0961   for (int jk = 0; jk < 6; jk++) {
0962     for (int ij = 0; ij < 5; ij++) {
0963       c1->cd(itag + 1);
0964       sprintf(title, "hoCalibc/sigtray_%i_%i_%i", icut, 5 * id + ij, jk);
0965 
0966       fprofx[itag] = (TH2F*)gDirectory->Get(title);
0967       fprofx[itag]->GetXaxis()->SetLabelOffset(-.001);
0968       fprofx[itag]->GetXaxis()->SetLabelSize(0.085);
0969       fprofx[itag]->GetYaxis()->SetLabelSize(0.085);
0970       fprofx[itag]->GetZaxis()->SetLabelSize(0.065);
0971       fprofx[itag]->GetYaxis()->SetNdivisions(404);
0972       fprofx[itag]->GetXaxis()->SetNdivisions(404);
0973       fprofx[itag]->SetLineColor(2);
0974       fprofx[itag]->SetLineWidth(2);
0975 
0976       fprofx[itag]->Draw("colz");
0977       fprofx[itag]->ProfileX()->Draw("same");
0978       //       if (itag==7) {
0979       //    TPaveStats *ptst = new TPaveStats(0.5,0.5,0.7,0.6,"brNDC");
0980       //    ptst->SetFillColor(10);
0981       //    TText* text = ptst->AddText(var);
0982       //    text->SetTextSize(0.092);
0983       //    ptst->SetBorderSize(1);
0984       //    //   ptst->AddText(name);
0985       //    ptst->Draw();
0986       //       }
0987 
0988       itag++;
0989     }
0990   }
0991   c1->Update();
0992 }
0993 
0994 void plot_var_trayprof(int id = 0, int icut = 0) {
0995   //plot_var_tray(0,1)
0996 
0997   char title[100];
0998   TCanvas* c1 = new TCanvas("c1", "runfile", 700., 900.);
0999   c1->Divide(5, 6, 1.e-5, 1.e-5, 0);
1000 
1001   TProfile* fprofx[30];
1002   int itag = 0;
1003   for (int jk = 0; jk < 6; jk++) {
1004     for (int ij = 0; ij < 5; ij++) {
1005       c1->cd(itag + 1);
1006       sprintf(title, "hoCalibc/sigtray_%i_%i_%i", icut, 5 * id + ij, jk);
1007 
1008       fprofx[itag] = (TProfile*)(((TH2F*)gDirectory->Get(title))->ProfileX());
1009       fprofx[itag]->GetXaxis()->SetLabelOffset(-.001);
1010       fprofx[itag]->GetXaxis()->SetLabelSize(0.085);
1011       fprofx[itag]->GetYaxis()->SetLabelSize(0.085);
1012       fprofx[itag]->GetYaxis()->SetNdivisions(404);
1013       fprofx[itag]->GetXaxis()->SetNdivisions(404);
1014       fprofx[itag]->SetLineColor(2);
1015       fprofx[itag]->SetLineWidth(2);
1016 
1017       fprofx[itag]->Draw();
1018       //       if (itag==7) {
1019       //    TPaveStats *ptst = new TPaveStats(0.5,0.5,0.7,0.6,"brNDC");
1020       //    ptst->SetFillColor(10);
1021       //    TText* text = ptst->AddText(var);
1022       //    text->SetTextSize(0.092);
1023       //    ptst->SetBorderSize(1);
1024       //    //   ptst->AddText(name);
1025       //    ptst->Draw();
1026       //       }
1027 
1028       itag++;
1029     }
1030   }
1031   c1->Update();
1032 }
1033 
1034 void plot_var_eta(int id = 0, int icut = 0) {
1035   //plot_var_eta(0,1)
1036 
1037   const int netamx = 30;
1038 
1039   char title[100];
1040   TCanvas* c1 = new TCanvas("c1", "runfile", 700., 900.);
1041   c1->Divide(5, 6, 1.e-5, 1.e-5, 0);
1042 
1043   TH2F* fprofx[netamx];
1044   for (int ij = 0; ij < netamx; ij++) {
1045     c1->cd(ij + 1);
1046     sprintf(title, "hoCalibc/sigeta_%i_%i_%i", icut, id, ij);
1047     fprofx[ij] = (TH2F*)gDirectory->Get(title);
1048     fprofx[ij]->GetXaxis()->SetLabelOffset(-0.001);
1049     fprofx[ij]->GetXaxis()->SetLabelSize(0.085);
1050     fprofx[ij]->GetYaxis()->SetLabelSize(0.085);
1051     fprofx[ij]->GetZaxis()->SetLabelSize(0.065);
1052     fprofx[ij]->GetYaxis()->SetNdivisions(404);
1053     fprofx[ij]->GetXaxis()->SetNdivisions(404);
1054     fprofx[ij]->SetLineColor(2);
1055     fprofx[ij]->SetLineWidth(2);
1056 
1057     fprofx[ij]->Draw("colz");
1058     fprofx[ij]->ProfileX()->Draw("same");
1059 
1060     //     if (ij==7) {
1061     //       TPaveStats *ptst = new TPaveStats(0.5,0.5,0.7,0.6,"brNDC");
1062     //       ptst->SetFillColor(10);
1063     //       TText* text = ptst->AddText(var);
1064     //       text->SetTextSize(0.092);
1065     //       ptst->SetBorderSize(1);
1066     //       //   ptst->AddText(name);
1067     //       ptst->Draw();
1068     //     }
1069   }
1070   c1->Update();
1071 }
1072 
1073 void plot_var_etaprof(int id = 0, int icut = 0) {
1074   //plot_var_eta(0,1)
1075 
1076   const int netamx = 30;
1077 
1078   char title[100];
1079   TCanvas* c1 = new TCanvas("c1", "runfile", 700., 900.);
1080   c1->Divide(5, 6, 1.e-5, 1.e-5, 0);
1081 
1082   TProfile* fprofx[netamx];
1083   for (int ij = 0; ij < netamx; ij++) {
1084     c1->cd(ij + 1);
1085     sprintf(title, "hoCalibc/sigeta_%i_%i_%i", icut, id, ij);
1086     fprofx[ij] = (TProfile*)(((TH2F*)gDirectory->Get(title))->ProfileX());
1087     fprofx[ij]->GetXaxis()->SetLabelOffset(-0.001);
1088     fprofx[ij]->GetXaxis()->SetLabelSize(0.085);
1089     fprofx[ij]->GetYaxis()->SetLabelSize(0.085);
1090     fprofx[ij]->GetYaxis()->SetNdivisions(404);
1091     fprofx[ij]->GetXaxis()->SetNdivisions(404);
1092     fprofx[ij]->SetLineColor(2);
1093     fprofx[ij]->SetLineWidth(2);
1094 
1095     fprofx[ij]->Draw();
1096   }
1097   c1->Update();
1098 }
1099 
1100 void plotyx() {
1101   //  //  sprintf (outfile,"%s.ps",outfilx);
1102   //  TPostScript ps("test.ps",111);
1103   //  ps.Range(20,28);
1104   TCanvas* c1 = new TCanvas("c1", "runfile", 700., 900.);
1105 
1106   for (int kl = 0; kl < ncut; kl++) {
1107     //    ps.NewPage();
1108     plot_var(kl);
1109   }
1110   //  ps.Close();
1111 }
1112 
1113 void plotallx() {
1114   //   //  gDirectory->DeleteAll();
1115   //   gStyle->Reset();
1116   gStyle->SetTitleFontSize(0.075);
1117   gStyle->SetTitleBorderSize(1);
1118   gStyle->SetPadTopMargin(0.12);
1119   gStyle->SetPadBottomMargin(0.10);
1120   gStyle->SetPadGridX(1);
1121   gStyle->SetPadGridY(1);
1122   gStyle->SetGridStyle(3);
1123   gStyle->SetOptStat(0);
1124   gStyle->SetTitleBorderSize(1);
1125 
1126   TCanvas* c1 = new TCanvas("c1", "runfile", 700., 900.);
1127   int ips = 111;
1128   //  //  sprintf (outfile,"%s.ps",outfilx);
1129   TPostScript ps("test_2016e.ps", ips);
1130   ps.Range(20, 28);
1131   bool m_select_plot = true;
1132   //   cout<<"1xx "<<endl;
1133   if (m_select_plot) {
1134     for (int kl = 0; kl < ncut; kl++) {
1135       ps.NewPage();
1136       plot_var(kl);
1137       ps.NewPage();
1138       plot_varprof(kl);
1139     }
1140 
1141     gStyle->SetTitleFontSize(0.095);
1142     for (int ix = 0; ix < 3; ix++) {
1143       for (int iy = 0; iy < ncut; iy++) {
1144         ps.NewPage();
1145         plot_var_eta(ix, iy);
1146         ps.NewPage();
1147         plot_var_etaprof(ix, iy);
1148       }
1149     }
1150 
1151     for (int ix = 0; ix < 3; ix++) {
1152       for (int iy = 0; iy < ncut; iy++) {
1153         ps.NewPage();
1154         plot_var_tray(ix, iy);
1155         ps.NewPage();
1156         plot_var_trayprof(ix, iy);
1157       }
1158     }
1159   }
1160 
1161   char name[100];
1162   totalmuon = (TH2F*)gDirectory->Get("hoCalibc/totalmuon");
1163   total2muon = (TH2F*)gDirectory->Get("hoCalibc/total2muon");
1164 
1165   for (int ij = 0; ij < 9; ij++) {
1166     sprintf(name, "hoCalibc/totalproj_%i", ij);
1167     totalproj[ij] = (TH2F*)gDirectory->Get(name);
1168 
1169     sprintf(name, "hoCalibc/totalprojsig_%i", ij);
1170     totalprojsig[ij] = (TH2F*)gDirectory->Get(name);
1171 
1172     sprintf(name, "hoCalibc/total2proj_%i", ij);
1173     total2proj[ij] = (TH2F*)gDirectory->Get(name);
1174 
1175     sprintf(name, "hoCalibc/total2projsig_%i", ij);
1176     total2projsig[ij] = (TH2F*)gDirectory->Get(name);
1177 
1178     total2projsig[ij]->Divide(total2proj[ij]);
1179     totalprojsig[ij]->Divide(totalproj[ij]);
1180 
1181     total2proj[ij]->Divide(total2muon);
1182     totalproj[ij]->Divide(totalmuon);
1183   }
1184 
1185   for (int ij = 0; ij < 18; ij++) {
1186     sprintf(name, "hoCalibc/totalhpd_%i", ij);
1187     totalhpd[ij] = (TH2F*)gDirectory->Get(name);
1188 
1189     sprintf(name, "hoCalibc/totalhpdsig_%i", ij);
1190     totalhpdsig[ij] = (TH2F*)gDirectory->Get(name);
1191 
1192     sprintf(name, "hoCalibc/total2hpd_%i", ij);
1193     total2hpd[ij] = (TH2F*)gDirectory->Get(name);
1194 
1195     sprintf(name, "hoCalibc/total2hpdsig_%i", ij);
1196     total2hpdsig[ij] = (TH2F*)gDirectory->Get(name);
1197 
1198     total2hpdsig[ij]->Divide(total2hpd[ij]);
1199     totalhpdsig[ij]->Divide(totalhpd[ij]);
1200 
1201     total2hpd[ij]->Divide(total2muon);
1202     totalhpd[ij]->Divide(totalmuon);
1203   }
1204   for (int ij = 0; ij < 8; ij++) {
1205     ps.NewPage();
1206     signal4(ij, (ij <= 3) ? 3 : 6);
1207   }
1208   //   cout<<"8xx "<<endl;
1209   // //   ps.NewPage(); signal4("hoCalibc/totalproj",3);
1210   // //   ps.NewPage(); signal4("hoCalibc/total2proj",3);
1211   // //   ps.NewPage(); signal4("hoCalibc/totalprojsig",3);
1212   // //   ps.NewPage(); signal4("hoCalibc/total2projsig",3);
1213 
1214   // //   ps.NewPage(); signal4("hoCalibc/totalhpd",6);
1215   // //   ps.NewPage(); signal4("hoCalibc/total2hpd",6);
1216   // //   ps.NewPage(); signal4("hoCalibc/totalhpdsig",6);
1217   // //   ps.NewPage(); signal4("hoCalibc/total2hpdsig",6);
1218 
1219   //  ps.Close();
1220 }
1221 
1222 void signal1() {
1223   TCanvas* c1 = new TCanvas("c1", "c1", 800., 600.);
1224   c1->Divide(4, 2);
1225   c1->cd(1);
1226   totalmuon->Draw("colz");
1227   c1->cd(2);
1228   totalproj_3->Draw("colz");
1229   c1->cd(3);
1230   totalproj_4->Draw("colz");
1231   c1->cd(4);
1232   totalproj_5->Draw("colz");
1233   c1->cd(5);
1234   total2muon->Draw("colz");
1235   c1->cd(6);
1236   total2proj_3->Draw("colz");
1237   c1->cd(7);
1238   total2proj_4->Draw("colz");
1239   c1->cd(8);
1240   total2proj_5->Draw("colz");
1241 }
1242 
1243 void signal2() {
1244   TCanvas* c1 = new TCanvas("c1", "c1", 800., 600.);
1245   c1->Divide(4, 2);
1246   c1->cd(1);
1247   totalmuon->Draw("colz");
1248   c1->cd(2);
1249   totalproj_3->Draw("colz");
1250   c1->cd(3);
1251   totalproj_4->Draw("colz");
1252   c1->cd(4);
1253   totalproj_5->Draw("colz");
1254 
1255   c1->cd(6);
1256   totalprojsig_3->Draw("colz");
1257   c1->cd(7);
1258   totalprojsig_4->Draw("colz");
1259   c1->cd(8);
1260   totalprojsig_5->Draw("colz");
1261 }
1262 void signal3() {
1263   TCanvas* c1 = new TCanvas("c1", "c1", 800., 600.);
1264   c1->Divide(4, 2);
1265   c1->cd(1);
1266   total2muon->Draw("colz");
1267   c1->cd(2);
1268   total2proj_3->Draw("colz");
1269   c1->cd(3);
1270   total2proj_4->Draw("colz");
1271   c1->cd(4);
1272   total2proj_5->Draw("colz");
1273 
1274   c1->cd(6);
1275   total2projsig_3->Draw("colz");
1276   c1->cd(7);
1277   total2projsig_4->Draw("colz");
1278   c1->cd(8);
1279   total2projsig_5->Draw("colz");
1280 }
1281 
1282 //signal4("totalproj",3);
1283 //signal4("total2proj",3);
1284 //signal4("totalprojsig",3);
1285 //signal4("total2projsig",3);
1286 
1287 //signal4("totalhpd",6);
1288 //signal4("total2hpd",6);
1289 //signal4("totalhpdsig",6);
1290 //signal4("total2hpdsig",6);
1291 
1292 // void signal4(const char* varnam="total2proj", int ndvy=3) {
1293 //   gStyle->SetOptStat(0);
1294 
1295 //   TCanvas* c1 = new TCanvas("c1", "c1", 1200., 600.);
1296 
1297 //   char name[100];
1298 //   TH2F* histx[100];
1299 //   c1->Divide(ndvy, 3);
1300 //   for (int ij=0; ij <3*ndvy; ij++) {
1301 //     sprintf(name, "%s_%i", varnam, ij);
1302 //     histx[ij] = (TH2F*)gDirectory->Get(name);
1303 //     c1->cd(ij+1);
1304 //     histx[ij]->Draw("colz");
1305 //   }
1306 // }
1307 
1308 void testplotx2(int thmn = 2, int thmx = 6) {
1309   gStyle->SetPadTopMargin(0.11);
1310   gStyle->SetPadBottomMargin(0.04);
1311   gStyle->SetPadLeftMargin(0.06);
1312   gStyle->SetPadRightMargin(0.02);
1313   gStyle->SetOptStat(0);
1314   gStyle->SetOptTitle();
1315   gStyle->SetPadGridX(1);
1316   gStyle->SetPadGridY(1);
1317   gStyle->SetGridStyle(3);
1318   gStyle->SetGridWidth(1);
1319   gStyle->SetTitleColor(10);
1320   gStyle->SetTitleFontSize(0.09);
1321   gStyle->SetTitleOffset(-0.09);
1322   gStyle->SetTitleBorderSize(1);
1323   gStyle->SetLabelSize(0.095, "XY");
1324 
1325   //  const int nfile=3;
1326   //  char* indexx[nfile]={"1_27", "28_122", "123_181"};
1327 
1328   const int nringmx = 5;
1329 
1330   const int routmx = 36;
1331   const int rout12mx = 24;
1332 
1333   const int rbxmx = 12;   // HO readout box in Ring 0
1334   const int rbx12mx = 6;  //HO readout box in Ring+-1/2
1335 
1336   const int nprojmx = 4;
1337   const int nseltype = 4;  //Different crit for muon selection
1338   const int nadmx = 18;
1339   const int shapemx = 10;  //checking shape
1340 
1341   char* projname[nprojmx] = {"totalproj", "totalprojsig", "totalhpd", "totalhpdsig"};
1342 
1343   //  TH2F* total2muon;
1344 
1345   TH2F* totalmuon[nseltype];
1346   TH2F* totalproj[nseltype][nprojmx][nadmx];
1347 
1348   const int nprojtype = 5;  // Varities due to types of muon projection
1349   TH2F* histent[nprojtype + 3];
1350   TH2F* histen[nprojtype + 3];
1351   TH2F* histen2[nprojtype + 3];
1352   TH2F* histerr[nprojtype];
1353 
1354   const int nhothresh = 10;
1355   TH2F* h_allmucorrel[nhothresh];
1356   TH2F* hnorm_allmucorrel[nhothresh];
1357 
1358   TH1F* endigicnt[nprojtype + 1][nhothresh];
1359   TH1F* endigisig[nprojtype + 1][nhothresh];
1360 
1361   TH2F* rmdigicnt[nprojtype + 1][nhothresh];
1362   TH2F* rmdigisig[nprojtype + 1][nhothresh];
1363 
1364   TH2F* ringdigicnt[nprojtype + 1][nhothresh];
1365   TH2F* ringdigisig[nprojtype + 1][nhothresh];
1366 
1367   TH2F* inddigicnt[nprojtype + 1][nhothresh];
1368   TH2F* inddigisig[nprojtype + 1][nhothresh];
1369 
1370   TH2F* indrecocnt[nprojtype + 1][nhothresh];
1371   TH2F* indrecosig[nprojtype + 1][nhothresh];
1372 
1373   TH1F* rout_mult[nhothresh][nringmx][routmx + 1];
1374   TH1F* rbx_mult[nhothresh][nringmx][rbxmx + 1];
1375 
1376   TH1F* rout_ind_energy[nringmx][routmx + 1];
1377 
1378   TH2F* h_correlht[nhothresh];
1379   TH2F* h_correlsig[nringmx][nhothresh];
1380   TH2F* h_rmoccu[nhothresh];
1381   TH2F* h_rmcorrel[nhothresh];
1382 
1383   TH2F* h_allcorrelsig[nhothresh];
1384 
1385   TH2F* rbx_shape[shapemx][nringmx][routmx + 1];
1386 
1387   char name[100];
1388 
1389   int ips = 111;
1390   TPostScript ps("allmuho.ps", ips);
1391   ps.Range(20, 28);
1392 
1393   TFile* fx = new TFile("histall_apr14b_cosmic_csa14_cosmic.root", "read");
1394   //  TFile* fx = new TFile("hist_apr14c_cosmic_csa14_cosmic.root", "read");
1395   //  TFile* fx = new TFile("histall_cosmic_csa14_cosmic_set.root", "read");
1396   //  TFile* fx = new TFile("apr14/apr14b/hist_cosmic_csa14_cosmic_set52.root", "read");
1397   for (int isel = 0; isel < nseltype; isel++) {
1398     sprintf(name, "hoCalibc/totalmuon_%i", isel);
1399     totalmuon[isel] = (TH2F*)fx->Get(name);
1400   }
1401   //  total2muon = (TH2F*) fx->Get("hoCalibc/total2muon");
1402 
1403   TCanvas* c0 = new TCanvas("c0", "mean rms", 600, 800);
1404   c0->Divide(2, 2);
1405 
1406   TCanvas* c3 = new TCanvas("c3", "mean rms", 600, 800);
1407 
1408   TCanvas* c1 = new TCanvas("c1", "c1", 600, 900);
1409   c1->Divide(3, 3);
1410 
1411   TCanvas* c2 = new TCanvas("c2", "c2", 600, 900);
1412   c2->Divide(3, 6);
1413 
1414   TCanvas* c4x = new TCanvas("c4x", "c4x", 600., 800.);
1415   c4x->Divide(2, 6);
1416 
1417   TCanvas* c4 = new TCanvas("c4", "c4", 600., 800.);
1418   c4->Divide(2, 6);
1419 
1420   TCanvas* c5 = new TCanvas("c5", "c5", 600., 800.);
1421   c5->Divide(6, 6);
1422 
1423   TCanvas* c6 = new TCanvas("c6", "c6", 600., 800.);
1424   c6->Divide(2, 5);
1425 
1426   TH2F* h2d_nhocapid[nprojtype];
1427   TH2F* h2d_hocapidsig[nprojtype];
1428   TH2F* h2d_hocapidsigwo[nprojtype];
1429 
1430   for (int ij = 0; ij < nprojtype; ij++) {
1431     sprintf(name, "hoCalibc/nhocapid_%i", ij);
1432     h2d_nhocapid[ij] = (TH2F*)fx->Get(name);
1433 
1434     sprintf(name, "hoCalibc/hocapidsig_%i", ij);
1435     h2d_hocapidsig[ij] = (TH2F*)fx->Get(name);
1436 
1437     sprintf(name, "hoCalibc/hocapidsigwo_%i", ij);
1438     h2d_hocapidsigwo[ij] = (TH2F*)fx->Get(name);
1439 
1440     h2d_hocapidsig[ij]->Divide(h2d_nhocapid[ij]);
1441     h2d_hocapidsigwo[ij]->Divide(h2d_nhocapid[ij]);
1442 
1443     ps.NewPage();
1444     c3->cd();
1445     h2d_hocapidsig[ij]->Draw("colz");
1446     c3->Update();
1447 
1448     ps.NewPage();
1449     c3->cd();
1450     h2d_hocapidsigwo[ij]->Draw("colz");
1451     c3->Update();
1452   }
1453 
1454   for (int ij = 0; ij < nprojtype; ij++) {
1455     sprintf(name, "hoCalibc/hbentry_d%i", ij + 3);
1456     cout << "ij " << name << endl;
1457     histent[ij] = (TH2F*)fx->Get(name);
1458     //    histent[ij]->Draw();
1459     sprintf(name, "hoCalibc/hbsig_d%i", ij + 3);
1460     histen[ij] = (TH2F*)fx->Get(name);
1461     sprintf(name, "hoCalibc/hbsig2_d%i", ij + 3);
1462     histen2[ij] = (TH2F*)fx->Get(name);
1463 
1464     int nentry = TMath::Max(1., histent[ij]->GetBinContent(0, 0));
1465     cout << "ij " << nentry << endl;
1466 
1467     histen[ij]->Divide(histent[ij]);
1468     histen2[ij]->Divide(histent[ij]);
1469 
1470     histent[ij]->Scale(1. / nentry);
1471 
1472     int xbin = histen[ij]->GetNbinsX();
1473     int ybin = histen[ij]->GetNbinsY();
1474     sprintf(name, "histerr_%i", ij);  //, indexx[ij]);
1475     histerr[ij] = new TH2F(name,
1476                            name,
1477                            xbin,
1478                            histent[ij]->GetXaxis()->GetXmin(),
1479                            histent[ij]->GetXaxis()->GetXmax(),
1480                            ybin,
1481                            histent[ij]->GetYaxis()->GetXmin(),
1482                            histent[ij]->GetYaxis()->GetXmax());
1483 
1484     for (int jk = 1; jk <= xbin; jk++) {
1485       for (int kl = 1; kl <= ybin; kl++) {
1486         double err = sqrt(histen2[ij]->GetBinContent(jk, kl) -
1487                           histen[ij]->GetBinContent(jk, kl) * histen[ij]->GetBinContent(jk, kl));
1488 
1489         histerr[ij]->Fill(histent[ij]->GetXaxis()->GetBinCenter(jk), histent[ij]->GetYaxis()->GetBinCenter(kl), err);
1490       }
1491     }
1492 
1493     ps.NewPage();
1494     cout << "ij11 " << ij << " " << histent[ij]->GetBinContent(22, 22) << endl;
1495     c0->cd(1); /*histent[ij]->GetXaxis()->SetRangeUser(-15.49,15.49);*/
1496     histent[ij]->Draw("colz");
1497     cout << "ij12 " << ij << " " << histen[ij]->GetBinContent(22, 22) << endl;
1498     c0->cd(2);
1499     histen[ij]->GetXaxis()->SetRangeUser(-15.49, 15.49);
1500     histen[ij]->Draw("colz");
1501     cout << "ij13 " << ij << endl;
1502     c0->cd(3);
1503     histen2[ij]->GetXaxis()->SetRangeUser(-15.49, 15.49);
1504     histen2[ij]->Draw("colz");
1505     cout << "ij14 " << ij << endl;
1506     c0->cd(4);
1507     histerr[ij]->GetXaxis()->SetRangeUser(-15.49, 15.49);
1508     histerr[ij]->Draw("colz");
1509     cout << "ij15 " << ij << endl;
1510     c0->Update();
1511     cout << "ij16 " << ij << endl;
1512   }
1513 
1514   for (int jk = 0; jk < nringmx; jk++) {
1515     for (int kl = 0; kl <= rbxmx; kl++) {
1516       if (jk != 2 && kl > rbx12mx)
1517         continue;
1518       ps.NewPage();
1519       for (int lm = 0; lm < shapemx; lm++) {
1520         if (kl == 0) {
1521           sprintf(name, "hoCalibc/rbx_shape_%i_r%i_allrbx", lm, jk);
1522         } else {
1523           sprintf(name, "hoCalibc/rbx_shape_%i_r%i_%i", lm, jk, kl);
1524         }
1525         rbx_shape[lm][jk][kl] = (TH2F*)fx->Get(name);
1526         c6->cd(int(lm / 5) + 2 * (lm % 5) + 1);
1527 
1528         rbx_shape[lm][jk][kl]->Draw("colz");
1529       }
1530       c6->Update();
1531     }
1532   }
1533 
1534   //Correlations
1535   for (int ij = thmn; ij < thmx; ij++) {
1536     sprintf(name, "hoCalibc/hocorrelht_%i", ij);
1537     h_correlht[ij] = (TH2F*)fx->Get(name);
1538 
1539     h_correlht[ij]->Scale(1. / nentry);
1540 
1541     sprintf(name, "hoCalibc/hormoccu_%i", ij);
1542     h_rmoccu[ij] = (TH2F*)fx->Get(name);
1543     h_rmoccu[ij]->Scale(1. / nentry);
1544 
1545     sprintf(name, "hoCalibc/hormcorrel_%i", ij);
1546     h_rmcorrel[ij] = (TH2F*)fx->Get(name);
1547     h_rmcorrel[ij]->Scale(1. / nentry);
1548 
1549     for (int jk = 0; jk < nringmx; jk++) {
1550       sprintf(name, "hoCalibc/hocorrelsig_%i_%i", jk, ij);
1551       h_correlsig[jk][ij] = (TH2F*)fx->Get(name);
1552       h_correlsig[jk][ij]->Scale(1. / nentry);
1553     }
1554 
1555     cout << "ij2 " << ij << endl;
1556     ps.NewPage();
1557 
1558     c1->cd(1);
1559     h_correlht[ij]->Draw("colz");
1560     //    c1->cd(2); h_correlhten[ij][ij]->Draw("colz");
1561     c1->cd(2);
1562     h_rmoccu[ij]->Draw("colz");
1563     c1->cd(3);
1564     h_rmcorrel[ij]->Draw("colz");
1565     cout << "ij23 " << ij << endl;
1566     for (int jk = 0; jk < nringmx; jk++) {
1567       cout << "ij22 " << ij << endl;
1568       c1->cd(jk + 4);
1569       h_correlsig[jk][ij]->Draw("colz");
1570     }
1571     cout << "ij21 " << ij << endl;
1572     c1->Update();
1573 
1574     sprintf(name, "hoCalibc/hoallcorrelsig_%i", ij);
1575     cout << "ij24 " << ij << " " << name << endl;
1576     h_allcorrelsig[ij] = (TH2F*)fx->Get(name);
1577     h_allcorrelsig[ij]->Scale(1. / nentry);
1578     cout << "ij25 " << ij << endl;
1579     ps.NewPage();
1580     c3->cd();
1581     h_allcorrelsig[ij]->Draw("colz");
1582     c3->Update();
1583     cout << "ij2 " << ij << endl;
1584   }
1585 
1586   for (int jk = 0; jk < nringmx; jk++) {
1587     ps.NewPage();
1588     for (int kl = 1; kl <= routmx; kl++) {
1589       if (jk != 2 && kl > rout12mx)
1590         continue;
1591       c5->cd(kl);
1592       gPad->SetLogy(1);
1593       if (kl == 0) {
1594         sprintf(name, "hoCalibc/rout_ind_energy_r%i_allrout", jk);
1595       } else {
1596         sprintf(name, "hoCalibc/rout_ind_energy_r%i_%i", jk, kl);
1597       }
1598       rout_ind_energy[jk][kl] = (TH1F*)fx->Get(name);
1599       rout_ind_energy[jk][kl]->Draw();
1600     }
1601     c5->Update();
1602   }
1603 
1604   for (int ij = thmn; ij < thmx; ij++) {
1605     //    int klx=0;
1606     for (int jk = 0; jk < nringmx; jk++) {
1607       ps.NewPage();
1608       for (int kl = 1; kl <= routmx; kl++) {
1609         if (jk != 2 && kl > rout12mx)
1610           continue;
1611         c5->cd(kl);
1612         gPad->SetLogy(1);
1613         if (kl == 0) {
1614           sprintf(name, "hoCalibc/rout_mult_%i_r%i_allrout", ij, jk);
1615         } else {
1616           sprintf(name, "hoCalibc/rout_mult_%i_r%i_%i", ij, jk, kl);
1617         }
1618         rout_mult[ij][jk][kl] = (TH1F*)fx->Get(name);
1619         rout_mult[ij][jk][kl]->Draw();
1620       }
1621       c5->Update();
1622     }
1623   }
1624 
1625   for (int ij = thmn; ij < thmx; ij++) {
1626     int klx = 0;
1627     for (int jk = 0; jk < nringmx; jk++) {
1628       if (klx % 12 == 0)
1629         ps.NewPage();
1630       for (int kl = 1; kl <= rbxmx; kl++) {
1631         if (jk != 2 && kl > rbx12mx)
1632           continue;
1633         c4x->cd(klx % 12 + 1);
1634         klx++;
1635         gPad->SetLogy(1);
1636         if (kl == 0) {
1637           sprintf(name, "hoCalibc/rbx_mult_%i_r%i_allrbx", ij, jk);
1638         } else {
1639           sprintf(name, "hoCalibc/rbx_mult_%i_r%i_%i", ij, jk, kl);
1640         }
1641         rbx_mult[ij][jk][kl] = (TH1F*)fx->Get(name);
1642         rbx_mult[ij][jk][kl]->Draw();
1643       }
1644       if (klx % 12 == 0)
1645         c4x->Update();
1646     }
1647   }
1648 
1649   for (int ij = thmn; ij < thmx; ij++) {
1650     for (int jk = 0; jk < nprojtype + 1; jk++) {
1651       sprintf(name, "hoCalibc/endigisig_%i_%i", jk, ij);
1652       cout << "name " << name << endl;
1653       endigisig[jk][ij] = (TH1F*)fx->Get(name);
1654       sprintf(name, "hoCalibc/endigicnt_%i_%i", jk, ij);
1655       endigicnt[jk][ij] = (TH1F*)fx->Get(name);
1656 
1657       sprintf(name, "hoCalibc/rmdigisig_%i_%i", jk, ij);
1658       rmdigisig[jk][ij] = (TH2F*)fx->Get(name);
1659       sprintf(name, "hoCalibc/rmdigicnt_%i_%i", jk, ij);
1660       rmdigicnt[jk][ij] = (TH2F*)fx->Get(name);
1661 
1662       sprintf(name, "hoCalibc/ringdigisig_%i_%i", jk, ij);
1663       ringdigisig[jk][ij] = (TH2F*)fx->Get(name);
1664       sprintf(name, "hoCalibc/ringdigicnt_%i_%i", jk, ij);
1665       ringdigicnt[jk][ij] = (TH2F*)fx->Get(name);
1666 
1667       sprintf(name, "hoCalibc/inddigisig_%i_%i", jk, ij);
1668       inddigisig[jk][ij] = (TH2F*)fx->Get(name);
1669       sprintf(name, "hoCalibc/inddigicnt_%i_%i", jk, ij);
1670       inddigicnt[jk][ij] = (TH2F*)fx->Get(name);
1671 
1672       sprintf(name, "hoCalibc/indrecosig_%i_%i", jk, ij);
1673       indrecosig[jk][ij] = (TH2F*)fx->Get(name);
1674       sprintf(name, "hoCalibc/indrecocnt_%i_%i", jk, ij);
1675       indrecocnt[jk][ij] = (TH2F*)fx->Get(name);
1676 
1677       endigisig[jk][ij]->Divide(endigicnt[jk][ij]);
1678       rmdigisig[jk][ij]->Divide(rmdigicnt[jk][ij]);
1679       ringdigisig[jk][ij]->Divide(ringdigicnt[jk][ij]);
1680       inddigisig[jk][ij]->Divide(inddigicnt[jk][ij]);
1681       indrecosig[jk][ij]->Divide(indrecocnt[jk][ij]);
1682     }
1683   }
1684 
1685   ps.NewPage();
1686 
1687   for (int ij = thmn; ij < thmx; ij++) {
1688     ps.NewPage();
1689     for (int jk = 0; jk < nprojtype + 1; jk++) {
1690       c4->cd(2 * jk + 1);
1691       endigicnt[jk][ij]->Draw();
1692       c4->cd(2 * jk + 2);
1693       endigisig[jk][ij]->Draw();
1694     }
1695     c4->Update();
1696   }
1697 
1698   for (int ij = thmn; ij < thmx; ij++) {
1699     ps.NewPage();
1700     for (int jk = 0; jk < nprojtype + 1; jk++) {
1701       c4->cd(2 * jk + 1);
1702       rmdigicnt[jk][ij]->Draw("colz");
1703       c4->cd(2 * jk + 2);
1704       rmdigisig[jk][ij]->Draw("colz");
1705     }
1706     c4->Update();
1707   }
1708 
1709   for (int ij = thmn; ij < thmx; ij++) {
1710     ps.NewPage();
1711     for (int jk = 0; jk < nprojtype + 1; jk++) {
1712       c4->cd(2 * jk + 1);
1713       ringdigicnt[jk][ij]->Draw("colz");
1714       c4->cd(2 * jk + 2);
1715       ringdigisig[jk][ij]->Draw("colz");
1716     }
1717     c4->Update();
1718   }
1719 
1720   for (int ij = thmn; ij < thmx; ij++) {
1721     ps.NewPage();
1722     for (int jk = 0; jk < nprojtype + 1; jk++) {
1723       c4->cd(2 * jk + 1);
1724       inddigicnt[jk][ij]->Draw("colz");
1725       c4->cd(2 * jk + 2);
1726       inddigisig[jk][ij]->Draw("colz");
1727     }
1728     c4->Update();
1729   }
1730 
1731   for (int ij = thmn; ij < thmx; ij++) {
1732     ps.NewPage();
1733     for (int jk = 0; jk < nprojtype + 1; jk++) {
1734       c4->cd(2 * jk + 1);
1735       indrecocnt[jk][ij]->Draw("colz");
1736       c4->cd(2 * jk + 2);
1737       indrecosig[jk][ij]->Draw("colz");
1738     }
1739     c4->Update();
1740   }
1741 
1742   for (int ij = thmn; ij < thmx; ij++) {
1743     sprintf(name, "hoCalibc/hoallmucorrel_%i", ij);
1744 
1745     double total = 0;
1746     h_allmucorrel[ij] = (TH2F*)fx->Get(name);
1747     hnorm_allmucorrel[ij] = (TH2F*)h_allmucorrel[ij]->Clone();
1748     for (int ix = 1; ix <= h_allmucorrel[ij]->GetNbinsX(); ix++) {
1749       float anent = h_allmucorrel[ij]->GetBinContent(ix, 0);
1750       total += anent;
1751       cout << "ix " << ij << " " << ix << " " << anent << " " << total << endl;
1752       if (anent < 1.)
1753         anent = 1.;
1754       for (int iy = 1; iy <= h_allmucorrel[ij]->GetNbinsY(); iy++) {
1755         hnorm_allmucorrel[ij]->SetBinContent(ix, iy, h_allmucorrel[ij]->GetBinContent(ix, iy) / anent);
1756       }
1757     }
1758     ps.NewPage();
1759     c3->cd();
1760     hnorm_allmucorrel[ij]->Draw("colz");
1761     c3->Update();
1762   }
1763 
1764   cout << "ij116 " << endl;
1765 
1766   for (int isel = 0; isel < nseltype; isel++) {
1767     for (int ij = 0; ij < nprojmx / 2; ij++) {
1768       ps.NewPage();
1769       for (int jk = 0; jk < nadmx / 2; jk++) {
1770         sprintf(name, "hoCalibc/%s_%i_%i", projname[ij], isel, jk);
1771         cout << "name " << name << endl;
1772         totalproj[isel][ij][jk] = (TH2F*)fx->Get(name);
1773       }
1774     }
1775     cout << "1ij116 " << endl;
1776     for (int jk = 0; jk < nadmx / 2; jk++) {
1777       totalproj[isel][1][jk]->Divide(totalproj[isel][0][jk]);
1778       totalproj[isel][0][jk]->Divide(totalmuon[isel]);
1779     }
1780 
1781     for (int ij = 0; ij < nprojmx / 2; ij++) {
1782       ps.NewPage();
1783       for (int jk = 0; jk < nadmx / 2; jk++) {
1784         c1->cd(jk + 1);
1785         totalproj[isel][ij][jk]->Draw("colz");
1786       }
1787       c1->Update();
1788     }
1789 
1790     cout << "2ij116 " << endl;
1791     for (int ij = 2; ij < nprojmx; ij++) {
1792       for (int jk = 0; jk < nadmx; jk++) {
1793         sprintf(name, "hoCalibc/%s_%i_%i", projname[ij], isel, jk);
1794         cout << "ij2 " << ij << " " << jk << " " << name << endl;
1795         totalproj[isel][ij][jk] = (TH2F*)fx->Get(name);
1796       }
1797     }
1798     cout << "3ij116 " << endl;
1799     for (int jk = 0; jk < nadmx / 2; jk++) {
1800       totalproj[isel][3][jk]->Divide(totalproj[isel][2][jk]);
1801       totalproj[isel][2][jk]->Divide(totalmuon[isel]);
1802     }
1803     cout << "4ij116 " << endl;
1804 
1805     for (int ij = 2; ij < nprojmx; ij++) {
1806       ps.NewPage();
1807       for (int jk = 0; jk < nadmx; jk++) {
1808         c2->cd(jk + 1);
1809         totalproj[isel][ij][jk]->Draw("colz");
1810       }
1811       c2->Update();
1812     }
1813 
1814     cout << "5ij116 " << endl;
1815   }
1816 
1817   ps.Close();
1818 }
1819 
1820 void testxx(int nproj = 1) {
1821   def_setting();
1822   const int nprojtype = 5;  // Varities due to types of muon projection
1823   TH2F* histent[nprojtype + 3];
1824   TH2F* histen[nprojtype + 3];
1825   TH2F* histen2[nprojtype + 3];
1826   TH2F* histerr[nprojtype];
1827   gStyle->SetOptStat(0);
1828   gStyle->SetPadTopMargin(0.06);
1829   gStyle->SetPadBottomMargin(0.13);
1830   gStyle->SetPadLeftMargin(0.10);
1831   gStyle->SetPadRightMargin(0.12);
1832   gStyle->SetLabelSize(0.065, "XY");
1833 
1834   TLatex latex;
1835   latex.SetNDC();
1836   latex.SetTextSize(0.07);
1837   latex.SetTextFont(42);
1838   latex.SetTextAlign(1);  //(31); // align right
1839 
1840   cout << "testxxxx1 " << endl;
1841   TCanvas* c1 = new TCanvas("c1", "c1", 800, 550);
1842   cout << "testxxxx2 " << endl;
1843   c1->Divide(2, 2);
1844   //  TFile* fx = new TFile("histall_apr14b_cosmic_csa14_cosmic.root", "read");
1845   char name[100];
1846 
1847   for (int ij = 0; ij < nproj; ij++) {
1848     sprintf(name, "hoCalibc/hbentry_d%i", ij + 3);
1849     cout << "ij " << name << endl;
1850     histent[ij] = (TH2F*)gDirectory->Get(name);
1851     sprintf(name, "hoCalibc/hbsig_d%i", ij + 3);
1852     histen[ij] = (TH2F*)gDirectory->Get(name);
1853     sprintf(name, "hoCalibc/hbsig2_d%i", ij + 3);
1854     histen2[ij] = (TH2F*)gDirectory->Get(name);
1855 
1856     int nentry = TMath::Max(1., histent[ij]->GetBinContent(0, 0));
1857     histen[ij]->Divide(histent[ij]);
1858     histen2[ij]->Divide(histent[ij]);
1859 
1860     histent[ij]->Scale(1. / nentry);
1861 
1862     histen[ij]->GetXaxis()->SetLabelSize(0.065);
1863     histen[ij]->GetYaxis()->SetLabelSize(0.065);
1864     histen2[ij]->GetXaxis()->SetLabelSize(0.065);
1865     histen2[ij]->GetYaxis()->SetLabelSize(0.065);
1866     histent[ij]->GetXaxis()->SetLabelSize(0.065);
1867     histent[ij]->GetYaxis()->SetLabelSize(0.065);
1868 
1869     int xbin = histen[ij]->GetNbinsX();
1870     int ybin = histen[ij]->GetNbinsY();
1871     sprintf(name, "histerr_%i", ij);  //, indexx[ij]);
1872     histerr[ij] = new TH2F(name,
1873                            name,
1874                            xbin,
1875                            histent[ij]->GetXaxis()->GetXmin(),
1876                            histent[ij]->GetXaxis()->GetXmax(),
1877                            ybin,
1878                            histent[ij]->GetYaxis()->GetXmin(),
1879                            histent[ij]->GetYaxis()->GetXmax());
1880 
1881     for (int jk = 1; jk <= xbin; jk++) {
1882       for (int kl = 1; kl <= ybin; kl++) {
1883         double err = sqrt(histen2[ij]->GetBinContent(jk, kl) -
1884                           histen[ij]->GetBinContent(jk, kl) * histen[ij]->GetBinContent(jk, kl));
1885 
1886         histerr[ij]->Fill(histent[ij]->GetXaxis()->GetBinCenter(jk), histent[ij]->GetYaxis()->GetBinCenter(kl), err);
1887       }
1888     }
1889 
1890     cout << "ij11 " << ij << " " << histent[ij]->GetBinContent(22, 22) << endl;
1891     histent[ij]->GetXaxis()->SetTitle("i#eta");
1892     histent[ij]->GetXaxis()->SetTitleSize(0.075);
1893     histent[ij]->GetXaxis()->SetTitleOffset(0.8);
1894     histent[ij]->GetXaxis()->CenterTitle();
1895     histent[ij]->GetYaxis()->SetTitle("i#phi");
1896     histent[ij]->GetYaxis()->SetTitleSize(0.075);
1897     histent[ij]->GetYaxis()->SetTitleOffset(0.6);
1898     histent[ij]->GetYaxis()->CenterTitle();
1899 
1900     c1->cd(1);
1901     histent[ij]->Draw("colz");
1902     latex.DrawLatex(0.5, 0.95, "Occupancy");
1903     cout << "ij12 " << ij << " " << histen[ij]->GetBinContent(22, 22) << endl;
1904     histen[ij]->GetXaxis()->SetTitle("i#eta");
1905     histen[ij]->GetXaxis()->SetTitleSize(0.075);
1906     histen[ij]->GetXaxis()->SetTitleOffset(0.8);
1907     histen[ij]->GetXaxis()->CenterTitle();
1908     histen[ij]->GetYaxis()->SetTitle("i#phi");
1909     histen[ij]->GetYaxis()->SetTitleSize(0.075);
1910     histen[ij]->GetYaxis()->SetTitleOffset(0.6);
1911     histen[ij]->GetYaxis()->CenterTitle();
1912 
1913     c1->cd(2);
1914     histen[ij]->Draw("colz");
1915     latex.DrawLatex(0.5, 0.95, "Mean");
1916     histen2[ij]->GetXaxis()->SetTitle("i#eta");
1917     histen2[ij]->GetXaxis()->SetTitleSize(0.075);
1918     histen2[ij]->GetXaxis()->SetTitleOffset(0.8);
1919     histen2[ij]->GetXaxis()->CenterTitle();
1920     histen2[ij]->GetYaxis()->SetTitle("i#phi");
1921     histen2[ij]->GetYaxis()->SetTitleSize(0.075);
1922     histen2[ij]->GetYaxis()->SetTitleOffset(0.6);
1923     histen2[ij]->GetYaxis()->CenterTitle();
1924 
1925     c1->cd(3);
1926     histen2[ij]->Draw("colz");
1927     latex.DrawLatex(0.5, 0.95, "(Mean^{2})");
1928     cout << "ij14 " << ij << endl;
1929     histerr[ij]->GetXaxis()->SetTitle("i#eta");
1930     histerr[ij]->GetXaxis()->SetTitleSize(0.075);
1931     histerr[ij]->GetXaxis()->SetTitleOffset(0.8);
1932     histerr[ij]->GetXaxis()->CenterTitle();
1933     histerr[ij]->GetYaxis()->SetTitle("i#phi");
1934     histerr[ij]->GetYaxis()->SetTitleSize(0.075);
1935     histerr[ij]->GetYaxis()->SetTitleOffset(0.6);
1936     histerr[ij]->GetYaxis()->CenterTitle();
1937 
1938     c1->cd(4);
1939     histerr[ij]->Draw("colz");
1940     latex.DrawLatex(0.5, 0.95, "RMS");
1941 
1942     cout << "ij15 " << ij << endl;
1943     c1->Update();
1944     cout << "ij16 " << ij << endl;
1945 
1946     int nentry = TMath::Max(1., histent[ij]->GetBinContent(0, 0));
1947     cout << "ij " << nentry << endl;
1948   }
1949 }
1950 
1951 // plot000(-1,6,7,5)
1952 // plot000(0,6,7,5)
1953 // plot000(2,12,13,5)
1954 // plot000(2,1,2,5)
1955 // plot000(-1,1,2,5)
1956 // plot000(3)
1957 // plot000(2,5,10,5)
1958 
1959 void plot000(int irng = -1, int isect = 0, int isect2 = 5, int ntype = 1, const char* tag = "", int extcol = 0) {
1960   def_setting();
1961   gStyle->SetOptLogy(1);
1962   gStyle->SetOptStat(0);
1963   gStyle->SetStatTextColor(3);
1964   gStyle->SetStatY(.99);
1965   gStyle->SetPadLeftMargin(0.12);
1966   gStyle->SetPadRightMargin(0.02);
1967   gStyle->SetPadTopMargin(0.02);
1968   gStyle->SetPadBottomMargin(0.12);
1969   TLatex latex;
1970   latex.SetNDC();
1971   latex.SetTextSize(0.07);
1972   //  latex.SetTextColor(extcol+1);
1973   latex.SetTextFont(42);
1974   latex.SetTextAlign(1);  //(31); // align right
1975   /*
1976   char  pch1[200];
1977   cout<<" namec "<<gDirectory->GetName()<<endl;
1978   char* namex = gDirectory->GetName();
1979   int len =strstr(namex, ".");
1980   int len1 =strstr(namex, "\\"); 
1981   int len2=strlen(namex);
1982 
1983   strncpy (pch1, namex+17, len2-22);
1984   cout <<"name "<< namex<<" "<<len<<" "<<len1<<" "<<len2<<" "<<pch1<<endl;
1985   */
1986 
1987   TLegend* tleg = new TLegend(.5, 0.65, 0.75, 0.85, "", "brNDC");
1988   tleg->SetFillColor(10);
1989   tleg->SetBorderSize(0);
1990   tleg->SetTextFont(42);
1991 
1992   char name[100];
1993   if (!strstr(tag, "same")) {
1994     TCanvas* c1 = new TCanvas("c1", "c1", 1000, 600);
1995     if (irng >= 0 && isect2 - isect < 2) {
1996       c1->Divide(5, 2, 1.e-6, 1.e-6);
1997       tleg->SetTextSize(0.06);
1998     } else {
1999       if (irng < 0) {
2000         c1->Divide(nchnmx, ringmx, 1.e-6, 1.e-6);
2001       } else {
2002         c1->Divide(nchnmx, ringmx + 1, 1.e-6, 1.e-6);
2003       }
2004       tleg->SetTextSize(0.10);
2005     }
2006   }
2007 
2008   TH1F* histx[nprojtype][ringmx][nchnmx];
2009   TH1F* histy[nprojtype][ringmx][nchnmx];
2010 
2011   int nloop = (irng < 0) ? ringmx : isect2 - isect + 1;
2012   cout << "nloop " << nloop << endl;
2013   bool iscomb = false;  //For combined sect
2014   //  for (int kl=0; kl<nprojtype; kl++) {
2015   for (int kl = 0; kl < ntype; kl++) {
2016     int ipad = 0;
2017     int icol = extcol + kl + 1;
2018     if (icol >= 5)
2019       icol++;
2020     if (icol >= 10)
2021       icol++;
2022     if (extcol > 0)
2023       latex.SetTextColor(icol);
2024     for (int ij = 0; ij < nloop; ij++) {
2025       for (int jk = 0; jk < nchnmx; jk++) {
2026         if (irng < 0) {
2027           sprintf(name, "hoCalibc/ringavedigi_%i_%i_%i_%i", kl, ij, (ij == 2) ? rbxmx : rbx12mx, jk);
2028           iscomb = true;
2029         } else {
2030           sprintf(name, "hoCalibc/ringavedigi_%i_%i_%i_%i", kl, irng, isect + ij, jk);
2031           if ((irng == 2 && isect + ij == rbxmx) || (irng != 2 && isect + ij == rbx12mx))
2032             iscomb = true;
2033         }
2034         //      cout<<"ij "<<ij<<" "<<jk<<" "<<name<<endl;
2035         histy[kl][ij][jk] = (TH1F*)gDirectory->Get(name);
2036         histx[kl][ij][jk] = (TH1F*)histy[kl][ij][jk]->Clone();
2037         histx[kl][ij][jk]->Rebin(3);
2038         histx[kl][ij][jk]->Scale(1. / TMath::Max(1., histx[kl][ij][jk]->Integral()));
2039         c1->cd(++ipad);
2040         histx[kl][ij][jk]->GetXaxis()->SetTitle("HO digi");
2041         histx[kl][ij][jk]->GetXaxis()->SetTitleSize(0.075);
2042         histx[kl][ij][jk]->GetXaxis()->SetTitleOffset(0.7);  //0.85
2043         histx[kl][ij][jk]->GetXaxis()->CenterTitle();
2044         histx[kl][ij][jk]->GetXaxis()->SetLabelSize(0.075);
2045         histx[kl][ij][jk]->GetXaxis()->SetLabelOffset(-0.005);
2046 
2047         histx[kl][ij][jk]->GetYaxis()->SetTitle();
2048         histx[kl][ij][jk]->GetYaxis()->SetTitleSize(0.085);
2049         histx[kl][ij][jk]->GetYaxis()->SetTitleOffset(0.9);
2050         histx[kl][ij][jk]->GetYaxis()->CenterTitle();
2051         histx[kl][ij][jk]->GetYaxis()->SetLabelSize(0.065);
2052         histx[kl][ij][jk]->GetYaxis()->SetLabelOffset(0.01);
2053 
2054         histx[kl][ij][jk]->GetXaxis()->SetNdivisions(404);
2055         histx[kl][ij][jk]->GetYaxis()->SetNdivisions(404);
2056 
2057         histx[kl][ij][jk]->SetLineColor(icol);
2058         if (kl == 0) {
2059           //      histx[kl][ij][jk]->GetXaxis()->SetRangeUser(-1,300);
2060           histx[kl][ij][jk]->Draw(tag);
2061           if (jk == 0) {
2062             if (irng < 0) {
2063               latex.DrawLatex(0.65, 0.62, Form("Ring %i", ij - 2));
2064             } else {
2065               if (iscomb) {
2066                 latex.DrawLatex(0.65, 0.85 - 0.08 * extcol, Form("R %i", irng - 2));
2067               } else {
2068                 latex.DrawLatex(0.65, 0.90 - 0.045 * extcol, Form("R%i Rbx%i", irng - 2, isect + ij));
2069               }
2070             }
2071           }
2072           if (ij == 0 && (!strstr(tag, "same")))
2073             latex.DrawLatex(0.45, 0.88, Form("TS %i", jk));
2074         } else {
2075           histx[kl][ij][jk]->Draw("same");
2076         }
2077 
2078         if (ij == 0 && jk == 0 && (!strstr(tag, "same"))) {
2079           tleg->AddEntry(histx[kl][ij][jk], projname[kl], "lpfe");
2080         }
2081 
2082         cout << "kl " << kl << "" << ij << "" << jk << " " << histx[kl][ij][jk]->Integral() << " "
2083              << histx[kl][ij][jk]->GetTitle() << endl;
2084       }
2085     }
2086   }
2087   if (!strstr(tag, "same")) {
2088     tleg->Draw();
2089   }
2090   if (strstr(tag, "sames")) {
2091     c1->Update();
2092   }
2093 }
2094 
2095 void plot000r(int irng = -1, int isup = 0, double xup = 200) {
2096   def_setting();
2097   gStyle->SetOptLogy(1);
2098   gStyle->SetOptStat(0);
2099   gStyle->SetStatTextColor(3);
2100   gStyle->SetStatY(.99);
2101   gStyle->SetPadLeftMargin(0.14);
2102   gStyle->SetPadRightMargin(0.02);
2103   gStyle->SetPadTopMargin(0.02);
2104   gStyle->SetPadBottomMargin(0.12);
2105   TLatex latex;
2106   latex.SetNDC();
2107   if (irng < 0) {
2108     latex.SetTextSize(0.08);
2109   } else {
2110     latex.SetTextSize(0.075);
2111   }
2112   //  latex.SetTextColor(extcol+1);
2113   latex.SetTextFont(42);
2114   latex.SetTextAlign(1);  //(31); // align right
2115 
2116   TLegend* tleg = new TLegend(.5, 0.3, 0.8, 0.9, "", "brNDC");
2117   tleg->SetFillColor(10);
2118   tleg->SetBorderSize(0);
2119   tleg->SetTextFont(42);
2120 
2121   cout << "xx1x " << endl;
2122   char name[100];
2123   int ysiz = (irng < 0) ? 350 : 450;
2124   TCanvas* c1 = new TCanvas("c1", "c1", 900., ysiz);
2125   tleg->SetTextSize(0.035);
2126   if (irng < 0) {
2127     tleg->SetTextSize(0.045);
2128     c1->Divide(5, 1, 1.e-6, 1.e-6);
2129   } else if (irng == 2) {
2130     c1->Divide(4, 3, 1.e-6, 1.e-6);
2131   } else {
2132     c1->Divide(3, 2, 1.e-6, 1.e-6);
2133   }
2134 
2135   cout << "xxx " << endl;
2136   TH1F* histx[ringmx][routmx + 1];
2137   TH1F* histy[ringmx][routmx + 1];
2138 
2139   int nloop11 = (irng < 0) ? 0 : irng;
2140   int nloop12 = (irng < 0) ? ringmx : irng + 1;
2141   int nloop2 = (irng < 0 && isup == 0) ? 1 : ((irng == 2 || isup > 0) ? 36 : 24);  //12 : 6);
2142 
2143   bool iscomb = false;  //For combined sect
2144   cout << "xxx2 " << nloop11 << " " << nloop12 << " " << nloop2 << endl;
2145   int ipad = 0;
2146   for (int ij = nloop11; ij < nloop12; ij++) {
2147     if (isup > 0)
2148       c1->cd(++ipad);
2149     for (int jk = 0; jk < nloop2; jk++) {
2150       if (ij != 2 && jk >= 24)
2151         continue;
2152       cout << "xxx3 " << ij << " " << jk << endl;
2153       if (irng < 0 && isup == 0) {
2154         sprintf(name, "hoCalibc/rout_ind_energy_r%i_0", ij);
2155         iscomb = true;
2156       } else {
2157         sprintf(name, "hoCalibc/rout_ind_energy_r%i_%i", ij, jk + 1);
2158       }
2159 
2160       cout << "name " << name << endl;
2161       histy[ij][jk] = (TH1F*)gDirectory->Get(name);
2162       histx[ij][jk] = (TH1F*)histy[ij][jk]->Clone();
2163       //      histx[ij][jk]->Rebin(2);
2164       histx[ij][jk]->Scale(1. / TMath::Max(1., histx[ij][jk]->Integral()));
2165       if (isup <= 0)
2166         c1->cd(++ipad);
2167       histx[ij][jk]->GetXaxis()->SetTitle("HO RECO (GeV)");
2168       histx[ij][jk]->GetXaxis()->SetTitleSize(0.065);
2169       histx[ij][jk]->GetXaxis()->SetTitleOffset(0.85);  //0.85
2170       histx[ij][jk]->GetXaxis()->CenterTitle();
2171       histx[ij][jk]->GetXaxis()->SetLabelSize(0.07);
2172       histx[ij][jk]->GetXaxis()->SetLabelOffset(-0.003);
2173 
2174       histx[ij][jk]->GetYaxis()->SetTitle();
2175       histx[ij][jk]->GetYaxis()->SetTitleSize(0.085);
2176       histx[ij][jk]->GetYaxis()->SetTitleOffset(0.9);
2177       histx[ij][jk]->GetYaxis()->CenterTitle();
2178       histx[ij][jk]->GetYaxis()->SetLabelSize(0.07);
2179       histx[ij][jk]->GetYaxis()->SetLabelOffset(0.01);
2180 
2181       histx[ij][jk]->GetXaxis()->SetNdivisions(404);
2182       histx[ij][jk]->GetYaxis()->SetNdivisions(404);
2183       histx[ij][jk]->GetXaxis()->SetRangeUser(0., xup);
2184       //      histx[ij][jk]->SetMinimum(1.e-8);
2185       if (isup > 0)
2186         histx[ij][jk]->SetLineColor(jk + 1);
2187       histx[ij][jk]->Draw((jk > 0 && isup > 0) ? "same" : "");
2188 
2189       if (isup > 0 && ij == 2) {
2190         cout << "jk " << jk << endl;
2191         tleg->AddEntry(histx[ij][jk], Form("RM %i", jk), "lpfe");
2192       }
2193 
2194       if (irng < 0) {
2195         latex.DrawLatex(0.55, 0.92, Form("Ring %i", ij - 2));
2196       } else {
2197         latex.DrawLatex(0.55, 0.92, Form("Ring %i Sec%i", ij - 2, jk));
2198       }
2199     }
2200     if (isup > 0 && ij == 2)
2201       tleg->Draw();
2202   }
2203   //  if (!strstr(tag,"same")) tleg->Draw();
2204   c1->Update();
2205 }
2206 
2207 void plot00(int ityp = 0, int isect = 0) {
2208   def_setting();
2209   gStyle->SetOptLogy(1);
2210   gStyle->SetOptStat(1100);
2211   gStyle->SetStatTextColor(3);
2212   gStyle->SetStatY(.99);
2213   gStyle->SetPadLeftMargin(0.09);
2214   gStyle->SetPadRightMargin(0.02);
2215   gStyle->SetPadTopMargin(0.02);
2216   gStyle->SetPadBottomMargin(0.07);
2217   TLatex latex;
2218   latex.SetNDC();
2219   latex.SetTextSize(0.11);
2220   latex.SetTextFont(42);
2221   latex.SetTextAlign(1);  //(31); // align right
2222 
2223   char name[100];
2224   TCanvas* c1 = new TCanvas("c1", "c1", 1000., 600.);
2225   c1->Divide(nchnmx, ringmx, 1.e-6, 1.e-6);
2226 
2227   TH1F* histx[ringmx][nchnmx];
2228   int icol = 0;
2229   for (int ij = 0; ij < ringmx; ij++) {
2230     for (int jk = 0; jk < nchnmx; jk++) {
2231       //      sprintf(name, "hoCalibc/ringavedigi_%i_%i", ij, jk);
2232       sprintf(name, "hoCalibc/ringavedigi_%i_%i_%i_%i", ityp, ij, isect, jk);
2233       //      cout<<"ij "<<ij<<" "<<jk<<" "<<name<<endl;
2234       histx[ij][jk] = (TH1F*)gDirectory->Get(name);
2235 
2236       c1->cd(++icol);
2237       histx[ij][jk]->GetXaxis()->SetTitle("HO digi");
2238       histx[ij][jk]->GetXaxis()->SetTitleSize(0.095);
2239       histx[ij][jk]->GetXaxis()->SetTitleOffset(0.75);  //0.85
2240       histx[ij][jk]->GetXaxis()->CenterTitle();
2241       histx[ij][jk]->GetXaxis()->SetLabelSize(0.085);
2242       histx[ij][jk]->GetXaxis()->SetLabelOffset(0.001);
2243 
2244       histx[ij][jk]->GetYaxis()->SetTitle();
2245       histx[ij][jk]->GetYaxis()->SetTitleSize(0.085);
2246       histx[ij][jk]->GetYaxis()->SetTitleOffset(0.9);
2247       histx[ij][jk]->GetYaxis()->CenterTitle();
2248       histx[ij][jk]->GetYaxis()->SetLabelSize(0.07);
2249       histx[ij][jk]->GetYaxis()->SetLabelOffset(0.01);
2250 
2251       histx[ij][jk]->SetLineColor(3);
2252       histx[ij][jk]->Draw();
2253       if (jk == 0)
2254         latex.DrawLatex(0.65, 0.62, Form("Ring %i", ij - 2));
2255       if (ij == 0)
2256         latex.DrawLatex(0.65, 0.42, Form("TS %i", jk));
2257     }
2258   }
2259   c1->Update();
2260 }
2261 
2262 //root hocalib_cosmic_csa14_cosmic_set50_59.root
2263 // root apr14/apr14b/hocalib_apr14b_cosmic_csa14_cosmic.root
2264 // plot01(0) : //signal refion
2265 // plot01(1) : //noise region
2266 // plot01(2) : //total region
2267 void plot01(int ityp = 0, int islocal = 1) {
2268   def_setting();
2269   gStyle->SetOptLogy(1);
2270   gStyle->SetOptStat(0);
2271   gStyle->SetStatTextColor(3);
2272   gStyle->SetStatY(.99);
2273   gStyle->SetPadRightMargin(0.02);
2274 
2275   gStyle->SetPadTopMargin(0.02);
2276   TLatex latex;
2277   latex.SetNDC();
2278   latex.SetTextSize(0.08);
2279   latex.SetTextFont(42);
2280   latex.SetTextAlign(1);  //(31); // align right
2281 
2282   char name[100];
2283   TCanvas* c1 = new TCanvas("c1", "c1", 800., 400.);
2284   c1->Divide(5, 1);
2285 
2286   TH1F* histx[ringmx][nprojtype];
2287   TH1F* histy[ringmx][nprojtype];
2288 
2289   int nloop = (islocal == 1) ? 1 : nprojtype;
2290   for (int jk = 0; jk < nloop; jk++) {
2291     for (int ij = 0; ij < ringmx; ij++) {
2292       sprintf(name, "hoCalibc/hoindringen_%i_%i", ij, jk);
2293 
2294       cout << "name " << name << endl;
2295       histy[ij][jk] = (TH1F*)gDirectory->Get(name);
2296       histx[ij][jk] = (TH1F*)histy[ij][jk]->Clone();
2297       histx[ij][jk]->Rebin(4);
2298       histx[ij][jk]->Scale(1. / histx[ij][jk]->Integral());
2299     }
2300   }
2301   for (int jk = 0; jk < nloop; jk++) {
2302     for (int ij = 0; ij < ringmx; ij++) {
2303       c1->cd(ij + 1);
2304       histx[ij][jk]->GetXaxis()->SetTitle((islocal) ? "Noise (GeV)" : "HO signal/noise (GeV)");
2305       histx[ij][jk]->GetXaxis()->SetTitleSize(0.075);
2306       histx[ij][jk]->GetXaxis()->SetTitleOffset(0.65);  //0.85
2307       histx[ij][jk]->GetXaxis()->CenterTitle();
2308       histx[ij][jk]->GetXaxis()->SetLabelSize(0.065);
2309       histx[ij][jk]->GetXaxis()->SetLabelOffset(-0.001);
2310 
2311       histx[ij][jk]->GetYaxis()->SetTitle();
2312       histx[ij][jk]->GetYaxis()->SetTitleSize(0.075);
2313       histx[ij][jk]->GetYaxis()->SetTitleOffset(0.9);
2314       histx[ij][jk]->GetYaxis()->CenterTitle();
2315       histx[ij][jk]->GetYaxis()->SetLabelSize(0.05);
2316       histx[ij][jk]->GetYaxis()->SetLabelOffset(0.01);
2317 
2318       histx[ij][jk]->SetLineColor(jk + 1);
2319       if (jk == 0) {
2320         double xmn = histx[ij][jk]->GetXaxis()->GetXmin();
2321         double xmx = histx[ij][jk]->GetXaxis()->GetXmax();
2322         if (ityp == 0) {
2323           histx[ij][jk]->GetXaxis()->SetRangeUser(xmn, 5.);
2324         } else if (ityp == 1) {
2325           histx[ij][jk]->GetXaxis()->SetRangeUser(2, xmx);
2326         } else {
2327           histx[ij][jk]->GetXaxis()->SetRangeUser(xmn, xmx);
2328         }
2329         //  histx[ij][jk]->Scale(1./histx[ij][jk]->GetEntries());
2330         histx[ij][jk]->Draw();
2331         latex.DrawLatex(0.25, 0.82, Form("Ring %i", ij - 2));
2332       } else {
2333         histx[ij][jk]->Draw("same");
2334       }
2335       //      cout<<"ijjk "<< ij<<" "<<jk<<" "<<histx[ij][jk]->GetEntries()<<" " <<histx[ij][jk]->Integral()<<" "<<histx[ij][jk]->GetTitle()<<endl;
2336     }
2337   }
2338   c1->Update();
2339 }
2340 
2341 //root hocalib_cosmic_csa14_cosmic_set50_59.root
2342 // root apr14/apr14b/hocalib_apr14b_cosmic_csa14_cosmic.root
2343 void plot1() {
2344   def_setting();
2345   gStyle->SetOptStat(1100);
2346   gStyle->SetStatTextColor(3);
2347   gStyle->SetStatY(.99);
2348   gStyle->SetPadRightMargin(0.02);
2349 
2350   gStyle->SetPadTopMargin(0.05);
2351   TLatex latex;
2352   latex.SetNDC();
2353   latex.SetTextSize(0.08);
2354   latex.SetTextFont(42);
2355   latex.SetTextAlign(1);  //(31); // align right
2356 
2357   char name[100];
2358   TCanvas* c1 = new TCanvas("c1", "c1", 800., 600.);
2359   c1->Divide(2, 2);
2360 
2361   TH1F* histx[8];
2362   for (int ij = 0; ij < 8; ij++) {
2363     sprintf(name, "signal_%i", ij);
2364     histx[ij] = new TH1F(name, name, 100, -0.2, 5.8);
2365     //  histx[1] = new TH1F("noise", "noise", 100, -.2, 5.8);
2366 
2367     //  TTree Ttree = gDirectory->Get("T1");
2368     switch (ij) {
2369       case 0:
2370         T1->Project(name, "hosig[4]", "isect>0&&(int(isect/100)-50)<-10&&abs(hodx)>1&&abs(hody)>1&&ndof>20");
2371         break;
2372       case 1:
2373         T1->Project(name,
2374                     "hosig[4]",
2375                     "isect>0&&(int(isect/100)-50)>=-10&&(int(isect/100)-50)<-5&&abs(hodx)>1&&abs(hody)>1&&ndof>20");
2376         break;
2377       case 2:
2378         T1->Project(name,
2379                     "hosig[4]",
2380                     "isect>0&&(int(isect/100)-50)>=-4&&(int(isect/100)-50)<5&&abs(hodx)>1&&abs(hody)>1&&ndof>20");
2381         break;
2382       case 3:
2383         T1->Project(name,
2384                     "hosig[4]",
2385                     "isect>0&&(int(isect/100)-50)>=4&&(int(isect/100)-50)<11&&abs(hodx)>1&&abs(hody)>1&&ndof>20");
2386         break;
2387       case 4:
2388         T1->Project(name, "hocro", "isect>0&&(int(isect/100)-50)<-10&&abs(hodx)>1&&abs(hody)>1&&ndof>20");
2389         break;
2390       case 5:
2391         T1->Project(name,
2392                     "hocro",
2393                     "isect>0&&(int(isect/100)-50)>=-10&&(int(isect/100)-50)<-5&&abs(hodx)>1&&abs(hody)>1&&ndof>20");
2394         break;
2395       case 6:
2396         T1->Project(name,
2397                     "hocro",
2398                     "isect>0&&(int(isect/100)-50)>=-4&&(int(isect/100)-50)<5&&abs(hodx)>1&&abs(hody)>1&&ndof>20");
2399         break;
2400       case 7:
2401         T1->Project(name,
2402                     "hocro",
2403                     "isect>0&&(int(isect/100)-50)>=4&&(int(isect/100)-50)<11&&abs(hodx)>1&&abs(hody)>1&&ndof>20");
2404         break;
2405     }
2406   }
2407   for (int ij = 0; ij < 8; ij++) {
2408     c1->cd(ij % 4 + 1);
2409     histx[ij]->GetXaxis()->SetTitle("HO signal/noise (GeV)");
2410     histx[ij]->GetXaxis()->SetTitleSize(0.075);
2411     histx[ij]->GetXaxis()->SetTitleOffset(0.75);  //0.85
2412     histx[ij]->GetXaxis()->CenterTitle();
2413     histx[ij]->GetXaxis()->SetLabelSize(0.065);
2414     histx[ij]->GetXaxis()->SetLabelOffset(0.001);
2415 
2416     histx[ij]->GetYaxis()->SetTitle();
2417     histx[ij]->GetYaxis()->SetTitleSize(0.075);
2418     histx[ij]->GetYaxis()->SetTitleOffset(0.9);
2419     histx[ij]->GetYaxis()->CenterTitle();
2420     histx[ij]->GetYaxis()->SetLabelSize(0.05);
2421     histx[ij]->GetYaxis()->SetLabelOffset(0.01);
2422 
2423     if (ij < 4) {
2424       histx[ij]->SetLineColor(3);
2425       histx[ij]->SetMaximum(1.1 * histx[ij + 4]->GetMaximum());
2426       histx[ij]->Draw();
2427       latex.DrawLatex(0.25, 0.82, Form("Ring %i", ij - 2));
2428     } else {
2429       if (ij == 4) {
2430         c1->Update();
2431         gStyle->SetStatTextColor(2);
2432         gStyle->SetStatY(.79);
2433       }
2434       histx[ij]->SetLineColor(2);
2435       histx[ij]->Draw("sames");
2436     }
2437     //    histx[1]->Draw("sames");
2438   }
2439   c1->Update();
2440 }
2441 
2442 //root hocalib_cosmic_csa14_cosmic_set50_59.root
2443 // root apr14/apr14b/hocalib_apr14b_cosmic_csa14_cosmic.root
2444 void plot1a() {
2445   def_setting();
2446   gStyle->SetOptStat(1100);
2447   gStyle->SetOptLogy(1);
2448   gStyle->SetStatTextColor(3);
2449   gStyle->SetStatY(.99);
2450   gStyle->SetPadRightMargin(0.02);
2451   TLatex latex;
2452   latex.SetNDC();
2453   latex.SetTextSize(0.08);
2454   latex.SetTextFont(42);
2455   latex.SetTextAlign(1);  //(31); // align right
2456 
2457   char name[100];
2458   TCanvas* c1 = new TCanvas("c1", "c1", 800., 600.);
2459   c1->Divide(2, 2);
2460 
2461   TH1F* histx[8];
2462   for (int ij = 0; ij < 8; ij++) {
2463     sprintf(name, "signal_%i", ij);
2464     histx[ij] = new TH1F(name, name, 100, 0.5, 19.5);
2465     //  histx[1] = new TH1F("noise", "noise", 100, -.2, 5.8);
2466 
2467     //  TTree Ttree = gDirectory->Get("Tcor1");
2468     switch (ij) {
2469       case 0:
2470         Tcor1->Project(name, "hocellen", "hocomu>0&&(int(hocomu/100)-50)<-10&&int(icapid/10.)==4");
2471         break;
2472       case 1:
2473         Tcor1->Project(
2474             name, "hocellen", "hocomu>0&&(int(hocomu/100)-50)>=-10&&(int(hocomu/100)-50)<-5&&int(icapid/10.)==4");
2475         break;
2476       case 2:
2477         Tcor1->Project(
2478             name, "hocellen", "hocomu>0&&(int(hocomu/100)-50)>=-4&&(int(hocomu/100)-50)<5&&int(icapid/10.)==4");
2479         break;
2480       case 3:
2481         Tcor1->Project(
2482             name, "hocellen", "hocomu>0&&(int(hocomu/100)-50)>=4&&(int(hocomu/100)-50)<11&&int(icapid/10.)==4");
2483         break;
2484       case 4:
2485         Tcor1->Project(name, "hocellen", "hocomu>0&&(int(hocomu/100)-50)<-10&&int(icapid/10.)==0");
2486         break;
2487       case 5:
2488         Tcor1->Project(
2489             name, "hocellen", "hocomu>0&&(int(hocomu/100)-50)>=-10&&(int(hocomu/100)-50)<-5&&int(icapid/10.)==0");
2490         break;
2491       case 6:
2492         Tcor1->Project(
2493             name, "hocellen", "hocomu>0&&(int(hocomu/100)-50)>=-4&&(int(hocomu/100)-50)<5&&int(icapid/10.)==0");
2494         break;
2495       case 7:
2496         Tcor1->Project(
2497             name, "hocellen", "hocomu>0&&(int(hocomu/100)-50)>=4&&(int(hocomu/100)-50)<11&&int(icapid/10.)==0");
2498         break;
2499     }
2500 
2501     c1->cd(ij % 4 + 1);
2502     histx[ij]->GetXaxis()->SetTitle("HO signal/noise (GeV)");
2503     histx[ij]->GetXaxis()->SetTitleSize(0.075);
2504     histx[ij]->GetXaxis()->SetTitleOffset(0.75);  //0.85
2505     histx[ij]->GetXaxis()->CenterTitle();
2506     histx[ij]->GetXaxis()->SetLabelSize(0.065);
2507     histx[ij]->GetXaxis()->SetLabelOffset(0.001);
2508 
2509     histx[ij]->GetYaxis()->SetTitle();
2510     histx[ij]->GetYaxis()->SetTitleSize(0.075);
2511     histx[ij]->GetYaxis()->SetTitleOffset(0.9);
2512     histx[ij]->GetYaxis()->CenterTitle();
2513     histx[ij]->GetYaxis()->SetLabelSize(0.055);
2514     histx[ij]->GetYaxis()->SetLabelOffset(0.01);
2515 
2516     if (ij < 4) {
2517       histx[ij]->SetLineColor(3);
2518 
2519       histx[ij]->Draw();
2520       latex.DrawLatex(0.25, 0.82, Form("Ring %i", ij - 2));
2521 
2522     } else {
2523       if (ij == 4) {
2524         c1->Update();
2525         gStyle->SetStatTextColor(2);
2526         gStyle->SetStatY(.79);
2527       }
2528 
2529       histx[ij]->SetLineColor(2);
2530       histx[ij]->Draw("sames");
2531     }
2532     //    histx[1]->Draw("sames");
2533   }
2534   c1->Update();
2535 }
2536 
2537 // root histall_apr14b_cosmic_csa14_cosmic.root
2538 //plot2(1,4,0)
2539 
2540 void plot2(int ith1 = 1, int ith2 = 4, int iproj = 0) {
2541   def_setting();
2542   gStyle->SetOptStat(0);
2543   gStyle->SetPadTopMargin(0.07);
2544   gStyle->SetPadBottomMargin(0.12);
2545   gStyle->SetPadLeftMargin(0.11);
2546   gStyle->SetPadRightMargin(0.14);
2547 
2548   TLatex latex;
2549   latex.SetNDC();
2550   latex.SetTextSize(0.06);
2551   latex.SetTextFont(42);
2552   latex.SetTextAlign(1);  //(31); // align right
2553 
2554   char name[100];
2555   TH2F* histx[10];
2556   TH2F* histy[10];
2557   TCanvas* c1 = new TCanvas("c1", "c1", 800., 600.);
2558   c1->Divide(2, 2);
2559   TH2F* histz = (TH2F*)gDirectory->Get("hoCalibc/hbentry_d3");
2560   int nentry = histz->GetBinContent(0, 0);
2561 
2562   icnt = 0;
2563   cout << "nentry = " << nentry << endl;
2564   for (int ij = ith1; ij <= ith2; ij++) {
2565     //  sprintf(name, "hoCalibc/indrecosig_%i_%i", iproj, ij);
2566     //  indrecosig[jk][ij] = (TH2F*)fx->Get(name);
2567     sprintf(name, "hoCalibc/indrecocnt_%i_%i", iproj, ij);
2568     histy[icnt] = (TH2F*)gDirectory->Get(name);
2569     histx[icnt] = (TH2F*)histy[icnt]->Clone();
2570 
2571     c1->cd(icnt + 1);
2572     cout << "icnt " << icnt << " " << histx[icnt]->GetTitle() << endl;
2573     histx[icnt]->Scale(1. / nentry);
2574     histx[icnt]->GetXaxis()->SetTitle("i#eta");
2575     histx[icnt]->GetXaxis()->SetTitleSize(0.075);
2576     histx[icnt]->GetXaxis()->SetTitleOffset(0.75);  //0.85
2577     histx[icnt]->GetXaxis()->CenterTitle();
2578     histx[icnt]->GetXaxis()->SetLabelSize(0.065);
2579     histx[icnt]->GetXaxis()->SetLabelOffset(0.001);
2580 
2581     histx[icnt]->GetYaxis()->SetTitle("i#phi");
2582     histx[icnt]->GetYaxis()->SetTitleSize(0.075);
2583     histx[icnt]->GetYaxis()->SetTitleOffset(0.7);
2584     histx[icnt]->GetYaxis()->CenterTitle();
2585     histx[icnt]->GetYaxis()->SetLabelSize(0.065);
2586     histx[icnt]->GetYaxis()->SetLabelOffset(0.01);
2587 
2588     histx[icnt]->GetZaxis()->SetLabelSize(0.048);
2589     histx[icnt]->GetZaxis()->SetLabelOffset(0.01);
2590     histx[icnt]->GetZaxis()->SetNdivisions(406);
2591 
2592     histx[icnt]->Draw("colz");
2593     latex.DrawLatex(.4, .95, Form("%g <E_{th} < %g", hothreshs[ij], hothreshs[ij + 1]));
2594     icnt++;
2595   }
2596   c1->Update();
2597 }
2598 // root histall_apr14b_cosmic_csa14_cosmic.root
2599 //xx  plot3(0)
2600 //xx  plot3(1)
2601 //xx  plot3(2)
2602 //xx  plot3(3)
2603 
2604 void plot3(int isel = 0) {
2605   def_setting();
2606   gStyle->SetOptStat(0);
2607   gStyle->SetPadTopMargin(0.05);
2608   gStyle->SetPadBottomMargin(0.1);
2609   gStyle->SetPadLeftMargin(0.08);
2610   gStyle->SetPadRightMargin(0.14);
2611   char name[100];
2612   TH2F* histx[9];
2613   TH2F* histy[9];
2614 
2615   TLatex latex;
2616   latex.SetNDC();
2617   latex.SetTextSize(0.08);
2618   latex.SetTextFont(42);
2619   latex.SetTextAlign(1);  //(31); // align right
2620 
2621   sprintf(name, "hoCalibc/totalmuon_%i", isel);
2622   TH2F* totalmuon = (TH2F*)gDirectory->Get(name);
2623 
2624   TCanvas* c1 = new TCanvas("c1", "c1", 800., 600.);
2625   c1->Divide(3, 3, 1.e-6, 1.e-6);
2626   for (int ij = 0; ij < 9; ij++) {
2627     sprintf(name, "hoCalibc/totalproj_%i_%i", isel, ij);
2628     histy[ij] = (TH2F*)gDirectory->Get(name);
2629     histx[ij] = (TH2F*)histy[ij]->Clone();
2630 
2631     histx[ij]->Divide(totalmuon);
2632 
2633     c1->cd(ij + 1);
2634     //   histx[ij]->GetXaxis()->SetTitle("i#eta");
2635     histx[ij]->GetXaxis()->SetTitleSize(0.075);
2636     histx[ij]->GetXaxis()->SetTitleOffset(0.75);  //0.85
2637     histx[ij]->GetXaxis()->CenterTitle();
2638     histx[ij]->GetXaxis()->SetLabelSize(0.065);
2639     histx[ij]->GetXaxis()->SetLabelOffset(0.001);
2640 
2641     //    histx[ij]->GetYaxis()->SetTitle("i#phi");
2642     histx[ij]->GetYaxis()->SetTitleSize(0.075);
2643     histx[ij]->GetYaxis()->SetTitleOffset(0.7);
2644     histx[ij]->GetYaxis()->CenterTitle();
2645     histx[ij]->GetYaxis()->SetLabelSize(0.055);
2646     histx[ij]->GetYaxis()->SetLabelOffset(0.01);
2647 
2648     histx[ij]->GetZaxis()->SetLabelSize(0.055);
2649     histx[ij]->GetZaxis()->SetLabelOffset(0.01);
2650     histx[ij]->GetZaxis()->SetNdivisions(406);
2651     histx[ij]->Draw("colz");
2652   }
2653   c1->Update();
2654 }
2655 // root histall_apr14b_cosmic_csa14_cosmic.root
2656 // plot4(1,3,0,0)
2657 void plot4(int ith1 = 0, int ith2 = 8, int isel1 = 0, int isel2 = 0) {
2658   def_setting();
2659   gStyle->SetOptStat(0);
2660   gStyle->SetPadTopMargin(0.02);
2661   gStyle->SetPadBottomMargin(0.15);
2662   gStyle->SetPadLeftMargin(0.15);
2663   gStyle->SetPadRightMargin(0.02);
2664   char name[100];
2665   TH1F* histx[10][9];
2666   TH1F* histy[10][9];
2667   TH1F* histz[10][9];
2668 
2669   TLatex latex;
2670   latex.SetNDC();
2671   latex.SetTextSize(0.055);
2672   latex.SetTextFont(42);
2673   latex.SetTextAlign(3);  //(31); // align right
2674 
2675   int nydiv = (isel2 == isel1) ? 1 : 2;
2676   //  TCanvas* c1 = new TCanvas("c1", "c1", 800., (nydiv==1) ? 350 : 600.);
2677   //  c1->Divide(3,nydiv,1.e-6,1.e-6);
2678   TCanvas* c1 = new TCanvas("c1", "c1", 800., 600.);
2679   c1->Divide(3, 3, 1.e-6, 1.e-6);
2680 
2681   const int nbin = 5;
2682   TString labels[nbin] = {"Ring-2", "Ring-1", "Ring0", "Ring+1", "Ring+2"};
2683 
2684   for (int ij = ith1; ij <= ith2; ij++) {
2685     sprintf(name, "hoCalibc/endigisig_%i_%i", isel1, ij);
2686     histz[0][ij] = (TH1F*)gDirectory->Get(name);
2687 
2688     sprintf(name, "hoCalibc/endigisig_%i_%i", isel2, ij);
2689     histz[1][ij] = (TH1F*)gDirectory->Get(name);
2690 
2691     sprintf(name, "hoCalibc/endigicnt_%i_%i", isel1, ij);
2692     histy[0][ij] = (TH1F*)gDirectory->Get(name);
2693 
2694     sprintf(name, "hoCalibc/endigicnt_%i_%i", isel2, ij);
2695     histy[1][ij] = (TH1F*)gDirectory->Get(name);
2696   }
2697 
2698   int icol = 0;
2699   for (int jk = 0; jk < nydiv; jk++) {
2700     for (int ij = ith1; ij <= ith2; ij++) {
2701       histx[jk][ij] = (TH1F*)histz[jk][ij]->Clone();
2702       histx[jk][ij]->Divide(histy[jk][ij]);
2703       c1->cd(++icol);
2704       cout << "ij " << icol << " " << ij << " " << jk << " " << histy[jk][ij]->GetTitle() << endl;
2705 
2706       histx[jk][ij]->GetXaxis()->SetLabelSize(0.05);
2707       histx[jk][ij]->GetXaxis()->SetLabelOffset(0.001);
2708 
2709       histx[jk][ij]->GetYaxis()->SetLabelSize(0.045);
2710       histx[jk][ij]->GetYaxis()->SetLabelOffset(0.01);
2711 
2712       histx[jk][ij]->GetXaxis()->SetTitle("Time slice in Five rings");
2713       histx[jk][ij]->GetXaxis()->SetTitleSize(0.055);
2714       histx[jk][ij]->GetXaxis()->SetTitleOffset(1.2);  //0.85
2715       histx[jk][ij]->GetXaxis()->CenterTitle();
2716       histx[jk][ij]->GetXaxis()->SetLabelSize(0.075);
2717       histx[jk][ij]->GetXaxis()->SetLabelOffset(0.01);
2718 
2719       histx[jk][ij]->GetYaxis()->SetTitle("Signal (fC/GeV)");
2720       histx[jk][ij]->GetYaxis()->SetTitleSize(0.055);
2721       histx[jk][ij]->GetYaxis()->SetTitleOffset(1.3);
2722       histx[jk][ij]->GetYaxis()->CenterTitle();
2723       histx[jk][ij]->GetYaxis()->SetLabelSize(0.065);
2724       histx[jk][ij]->GetYaxis()->SetLabelOffset(0.01);
2725 
2726       histx[jk][ij]->GetXaxis()->SetNdivisions(406);
2727       histx[jk][ij]->GetYaxis()->SetNdivisions(406);
2728 
2729       for (int kl = 0; kl < nbin; kl++) {
2730         histx[jk][ij]->GetXaxis()->SetBinLabel(10 * kl + 6, labels[kl]);
2731       }
2732       histx[jk][ij]->GetXaxis()->LabelsOption("h");
2733       histx[jk][ij]->Draw();
2734 
2735       latex.DrawLatex(0.40, 0.93, Form("%g <E_{RECO} <%g GeV", hothreshs[ij], hothreshs[ij + 1]));
2736     }
2737   }
2738   c1->Update();
2739 }
2740 
2741 // root histall_apr14b_cosmic_csa14_cosmic.root
2742 // plot5(1,3,0,0)
2743 void plot5(int ith1 = 1, int ith2 = 3, int isel1 = 0, int isel2 = 4, double amx = -1.0) {
2744   def_setting();
2745   gStyle->SetOptStat(0);
2746   gStyle->SetPadTopMargin(0.02);
2747   gStyle->SetPadBottomMargin(0.15);
2748   gStyle->SetPadLeftMargin(0.15);
2749   gStyle->SetPadRightMargin(0.14);
2750 
2751   char name[100];
2752   TH2F* histx[5][9];
2753   TH2F* histy[5][9];
2754   TH2F* histz[5][9];
2755 
2756   const int nbin = 5;
2757   TString labels[nbin] = {"Ring-2", "Ring-1", "Ring0", "Ring+1", "Ring+2"};
2758 
2759   int nydiv = (isel1 == isel2) ? 1 : 2;
2760   TCanvas* c1 = new TCanvas("c1", "c1", 800., (nydiv == 1) ? 350 : 600.);
2761   c1->Divide(3, nydiv, 1.e-6, 1.e-6);
2762 
2763   for (int ij = ith1; ij <= ith2; ij++) {
2764     sprintf(name, "hoCalibc/rmdigisig_%i_%i", isel1, ij);
2765     histz[0][ij] = (TH2F*)gDirectory->Get(name);
2766 
2767     sprintf(name, "hoCalibc/rmdigisig_%i_%i", isel2, ij);
2768     histz[1][ij] = (TH2F*)gDirectory->Get(name);
2769 
2770     sprintf(name, "hoCalibc/rmdigicnt_%i_%i", isel1, ij);
2771     histy[0][ij] = (TH2F*)gDirectory->Get(name);
2772 
2773     sprintf(name, "hoCalibc/rmdigicnt_%i_%i", isel2, ij);
2774     histy[1][ij] = (TH2F*)gDirectory->Get(name);
2775   }
2776 
2777   int icol = 0;
2778   for (int jk = 0; jk < nydiv; jk++) {
2779     for (int ij = ith1; ij <= ith2; ij++) {
2780       histx[jk][ij] = (TH2F*)histz[jk][ij]->Clone();
2781       histx[jk][ij]->Divide(histy[jk][ij]);
2782       c1->cd(++icol);
2783       cout << "ij " << icol << " " << ij << " " << jk << " " << histy[jk][ij]->GetTitle() << endl;
2784 
2785       histx[jk][ij]->GetXaxis()->SetTitle("Time slice in Five rings");
2786       histx[jk][ij]->GetXaxis()->SetTitleSize(0.055);
2787       histx[jk][ij]->GetXaxis()->SetTitleOffset(1.2);  //0.85
2788       histx[jk][ij]->GetXaxis()->CenterTitle();
2789       histx[jk][ij]->GetXaxis()->SetLabelSize(0.065);
2790       histx[jk][ij]->GetXaxis()->SetLabelOffset(0.01);
2791 
2792       histx[jk][ij]->GetYaxis()->SetTitle("RM#");
2793       histx[jk][ij]->GetYaxis()->SetTitleSize(0.055);
2794       histx[jk][ij]->GetYaxis()->SetTitleOffset(1.3);
2795       histx[jk][ij]->GetYaxis()->CenterTitle();
2796       histx[jk][ij]->GetYaxis()->SetLabelSize(0.065);
2797       histx[jk][ij]->GetYaxis()->SetLabelOffset(0.01);
2798 
2799       histx[jk][ij]->GetZaxis()->SetLabelSize(0.048);
2800       histx[jk][ij]->GetZaxis()->SetLabelOffset(0.01);
2801 
2802       histx[jk][ij]->GetXaxis()->SetNdivisions(202);
2803       //      histx[jk][ij]->GetYaxis()->SetNdivisions(406);
2804       //      histx[jk][ij]->GetZaxis()->SetNdivisions(406);
2805       if (amx > 0)
2806         histx[jk][ij]->SetMaximum(amx);
2807       //      for (int kl=0; kl<nbin; kl++) {
2808       //    histx[jk][ij]->GetXaxis()->SetBinLabel(10*kl+6, labels[kl]);
2809       //       }
2810       //       histx[jk][ij]->GetXaxis()->LabelsOption("h");
2811       histx[jk][ij]->GetXaxis()->SetNdivisions(810);
2812       histx[jk][ij]->Draw("colz");
2813     }
2814   }
2815   c1->Update();
2816 }
2817 
2818 // root histall_apr14b_cosmic_csa14_cosmic.root
2819 // plot6(-2,3)
2820 void plot6(int iring = -2, int irbx = 3) {
2821   def_setting();
2822   gStyle->SetOptStat(0);
2823   gStyle->SetPadTopMargin(0.10);
2824   gStyle->SetPadBottomMargin(0.08);
2825   gStyle->SetPadLeftMargin(0.20);
2826   gStyle->SetPadRightMargin(0.20);
2827   char name[100];
2828   const int shapemx = 10;
2829   TH2F* histx[shapemx];
2830   //  const char* shape_name[shapemx]={"N:T3/T34", "N:T34/Sum2-5", "N:T3/Sum2-5", "N:T4/Sum2-5", "N:Oth/Sum2-5",
2831   //                   "S:T3/T34", "S:T34/Sum2-5", "S:T3/Sum2-5", "S:T4/Sum2-5", "S:Oth/Sum2-5"};
2832 
2833   const char* shape_name[shapemx] = {
2834       "T3/T4", "T4/Sum45", "T45/Sum4-7", "T4-7/All", "T0-3/T4-7", "T0-3/All", "T0-3/T4-7", "T67/T45", "xx", "xx"};
2835 
2836   TCanvas* c1 = new TCanvas("c1", "c1", 800., 500.);
2837   c1->Divide(4, 2, 1.e-6, 1.e-6);
2838 
2839   for (int ij = 0; ij < shapemx - 2; ij++) {
2840     c1->cd(ij + 1);
2841     sprintf(name, "hoCalibc/rbx_shape_%i_r%i_%i", ij, iring + 2, irbx);
2842     histx[ij] = (TH2F*)gDirectory->Get(name);
2843     cout << "ij " << ij << " " << histx[ij]->GetTitle() << endl;
2844 
2845     if (ij == 0 || ij == 5) {
2846       //      histx[ij]->GetXaxis()->SetTitle("T2+T3");
2847     } else {
2848       //      histx[ij]->GetXaxis()->SetTitle("Sum T2-5");
2849     }
2850     histx[ij]->GetXaxis()->SetTitleSize(0.065);
2851     histx[ij]->GetXaxis()->SetTitleOffset(0.65);  //0.85
2852     histx[ij]->GetXaxis()->CenterTitle();
2853     histx[ij]->GetXaxis()->SetLabelSize(0.065);
2854     histx[ij]->GetXaxis()->SetLabelOffset(-0.01);
2855 
2856     histx[ij]->GetYaxis()->SetTitle(shape_name[ij]);
2857     histx[ij]->GetYaxis()->SetTitleSize(0.065);
2858     histx[ij]->GetYaxis()->SetTitleOffset(1.3);
2859     histx[ij]->GetYaxis()->CenterTitle();
2860     histx[ij]->GetYaxis()->SetLabelSize(0.065);
2861     histx[ij]->GetYaxis()->SetLabelOffset(0.01);
2862 
2863     histx[ij]->GetZaxis()->SetLabelSize(0.07);
2864     histx[ij]->GetZaxis()->SetLabelOffset(0.01);
2865 
2866     histx[ij]->GetXaxis()->SetNdivisions(406);
2867     histx[ij]->GetYaxis()->SetNdivisions(406);
2868     histx[ij]->GetZaxis()->SetNdivisions(406);
2869 
2870     histx[ij]->Draw("colz");
2871   }
2872   c1->Update();
2873 }
2874 
2875 // root histall_apr14b_cosmic_csa14_cosmic.root
2876 // plot7(2,0)
2877 void plot7(int ith = 2, int irbx = 0) {
2878   def_setting();
2879 
2880   TLatex latex;
2881   latex.SetNDC();
2882   latex.SetTextSize(0.08);
2883   latex.SetTextFont(42);
2884   latex.SetTextAlign(1);  //(31); // align right
2885 
2886   const int nringmx = 5;
2887   gStyle->SetOptLogy(1);
2888   gStyle->SetOptStat(0);
2889   gStyle->SetPadTopMargin(0.02);
2890   gStyle->SetPadBottomMargin(0.13);
2891   gStyle->SetPadLeftMargin(0.14);
2892   gStyle->SetPadRightMargin(0.02);
2893   char name[100];
2894   TCanvas* c1 = new TCanvas("c1", "c1", 800., 500.);
2895   c1->Divide(5, 2, 1.e-6, 1.e-6);
2896 
2897   TH1F* histx[2][nringmx];
2898 
2899   int icol = 0;
2900 
2901   for (int ij = 0; ij < 2; ij++) {
2902     for (int jk = 0; jk < nringmx; jk++) {
2903       if (ij == 0) {
2904         sprintf(name, "hoCalibc/rbx_mult_%i_r%i_%i", ith, jk, irbx);
2905       } else {
2906         sprintf(name, "hoCalibc/rout_mult_%i_r%i_%i", ith, jk, irbx);
2907       }
2908 
2909       histx[ij][jk] = (TH1F*)gDirectory->Get(name);
2910       cout << "name " << name << endl;
2911       c1->cd(++icol);
2912 
2913       if (ij == 0) {
2914         histx[ij][jk]->GetXaxis()->SetTitle("# in RBX");
2915       } else {
2916         histx[ij][jk]->GetXaxis()->SetTitle("# in RM");
2917       }
2918       histx[ij][jk]->GetXaxis()->SetTitleSize(0.085);
2919       histx[ij][jk]->GetXaxis()->SetTitleOffset(0.7);  //0.85
2920       histx[ij][jk]->GetXaxis()->CenterTitle();
2921       histx[ij][jk]->GetXaxis()->SetLabelSize(0.085);
2922       histx[ij][jk]->GetXaxis()->SetLabelOffset(-0.01);
2923 
2924       histx[ij][jk]->GetYaxis()->SetTitle();  //shape_name[ij][jk]);
2925       histx[ij][jk]->GetYaxis()->SetTitleSize(0.075);
2926       histx[ij][jk]->GetYaxis()->SetTitleOffset(1.3);
2927       histx[ij][jk]->GetYaxis()->CenterTitle();
2928       histx[ij][jk]->GetYaxis()->SetLabelSize(0.085);
2929       histx[ij][jk]->GetYaxis()->SetLabelOffset(0.01);
2930 
2931       histx[ij][jk]->GetXaxis()->SetNdivisions(404);
2932       histx[ij][jk]->GetYaxis()->SetNdivisions(404);
2933 
2934       histx[ij][jk]->Draw();
2935       cout << "ijjk " << ij << " " << jk << " " << histx[ij][jk]->GetTitle() << endl;
2936       latex.DrawLatex(0.35, 0.8, Form("Ring %i", jk - 2));
2937     }
2938   }
2939   c1->Update();
2940 }
2941 
2942 void plot7a(int irng = -1, int ith = 2, int isrm = 0) {
2943   def_setting();
2944 
2945   TLatex latex;
2946   latex.SetNDC();
2947   latex.SetTextSize(0.08);
2948   latex.SetTextFont(42);
2949   latex.SetTextAlign(1);  //(31); // align right
2950 
2951   const int nringmx = 5;
2952   gStyle->SetOptLogy(1);
2953   gStyle->SetOptStat(0);
2954   gStyle->SetPadTopMargin(0.02);
2955   gStyle->SetPadBottomMargin(0.13);
2956   gStyle->SetPadLeftMargin(0.14);
2957   gStyle->SetPadRightMargin(0.02);
2958   char name[100];
2959   TCanvas* c1 = new TCanvas("c1", "c1", 800., 500.);
2960   if (irng < 0) {
2961     c1->Divide(5, 2, 1.e-6, 1.e-6);
2962   } else if (isrm) {
2963     if (irng == 2) {
2964       c1->Divide(6, 6, 1.e-6, 1.e-6);
2965     } else {
2966       c1->Divide(6, 4, 1.e-6, 1.e-6);
2967     }
2968   } else {
2969     if (irng == 2) {
2970       c1->Divide(4, 3, 1.e-6, 1.e-6);
2971     } else {
2972       c1->Divide(3, 2, 1.e-6, 1.e-6);
2973     }
2974   }
2975   TH1F* histx[routmx + 1][routmx + 1];
2976 
2977   int icol = 0;
2978 
2979   int nloop1 = 2;
2980   int nloop2 = nringmx;
2981   if (irng >= 0) {
2982     nloop1 = 1;
2983     if (isrm) {
2984       nloop2 = (irng == 2) ? 36 : 24;
2985     } else {
2986       nloop2 = (irng == 2) ? 12 : 6;
2987     }
2988   }
2989 
2990   for (int ij = 0; ij < nloop1; ij++) {    //ij<2
2991     for (int jk = 0; jk < nloop2; jk++) {  //ij<nringmx;
2992 
2993       if (irng < 0) {
2994         if (ij == 0) {
2995           sprintf(name, "hoCalibc/rbx_mult_%i_r%i_0", ith, jk);  //, irbx);
2996         } else {
2997           sprintf(name, "hoCalibc/rout_mult_%i_r%i_0", ith, jk);  //, irbx);
2998         }
2999       } else if (isrm) {
3000         sprintf(name, "hoCalibc/rout_mult_%i_r%i_%i", ith, irng, jk);
3001       } else {
3002         sprintf(name, "hoCalibc/rbx_mult_%i_r%i_%i", ith, irng, jk);
3003       }
3004 
3005       histx[ij][jk] = (TH1F*)gDirectory->Get(name);
3006       cout << "name " << name << endl;
3007       c1->cd(++icol);
3008       if (irng < 0) {
3009         if (ij == 0) {
3010           histx[ij][jk]->GetXaxis()->SetTitle("# in RBX");
3011         } else {
3012           histx[ij][jk]->GetXaxis()->SetTitle("# in RM");
3013         }
3014       } else if (isrm) {
3015         histx[ij][jk]->GetXaxis()->SetTitle("# in RM");
3016       } else {
3017         histx[ij][jk]->GetXaxis()->SetTitle("# in RBX");
3018       }
3019 
3020       histx[ij][jk]->GetXaxis()->SetTitleSize(0.085);
3021       histx[ij][jk]->GetXaxis()->SetTitleOffset(0.7);  //0.85
3022       histx[ij][jk]->GetXaxis()->CenterTitle();
3023       histx[ij][jk]->GetXaxis()->SetLabelSize(0.085);
3024       histx[ij][jk]->GetXaxis()->SetLabelOffset(-0.01);
3025 
3026       histx[ij][jk]->GetYaxis()->SetTitle();  //shape_name[ij][jk]);
3027       histx[ij][jk]->GetYaxis()->SetTitleSize(0.075);
3028       histx[ij][jk]->GetYaxis()->SetTitleOffset(1.3);
3029       histx[ij][jk]->GetYaxis()->CenterTitle();
3030       histx[ij][jk]->GetYaxis()->SetLabelSize(0.085);
3031       histx[ij][jk]->GetYaxis()->SetLabelOffset(0.01);
3032 
3033       histx[ij][jk]->GetXaxis()->SetNdivisions(404);
3034       histx[ij][jk]->GetYaxis()->SetNdivisions(404);
3035 
3036       histx[ij][jk]->Draw();
3037       cout << "ijjk " << ij << " " << jk << " " << histx[ij][jk]->GetTitle() << endl;
3038       if (irng < 0) {
3039         latex.DrawLatex(0.35, 0.8, Form("Ring %i E>%g", jk - 2, hothreshs[ith]));
3040       } else if (isrm) {
3041         latex.DrawLatex(0.35, 0.8, Form("Ring %i RM%i E>%g", irng, jk, hothreshs[ith]));
3042       } else {
3043         latex.DrawLatex(0.35, 0.8, Form("Ring %i RBX%i E>%g", irng, jk, hothreshs[ith]));
3044       }
3045     }
3046   }
3047   c1->Update();
3048 }
3049 
3050 void plot7b(int irng = -1, int th1 = 2, int th2 = 5, int isrm = 0) {
3051   def_setting();
3052 
3053   TLatex latex;
3054   latex.SetNDC();
3055   latex.SetTextSize(0.065);
3056   latex.SetTextFont(42);
3057   latex.SetTextAlign(1);  //(31); // align right
3058 
3059   TLegend* tleg = new TLegend(.75, 0.35, 0.95, 0.9, "", "brNDC");
3060   tleg->SetFillColor(10);
3061   tleg->SetBorderSize(0);
3062   tleg->SetTextFont(42);
3063   tleg->SetTextSize(0.07);
3064 
3065   const int nringmx = 5;
3066   gStyle->SetOptLogy(1);
3067   gStyle->SetOptStat(0);
3068   gStyle->SetPadTopMargin(0.02);
3069   gStyle->SetPadBottomMargin(0.13);
3070   gStyle->SetPadLeftMargin(0.14);
3071   gStyle->SetPadRightMargin(0.02);
3072   char name[100];
3073   TCanvas* c1 = new TCanvas("c1", "c1", 800., 500.);
3074   if (irng < 0) {
3075     c1->Divide(5, 2, 1.e-6, 1.e-6);
3076   } else if (isrm) {
3077     if (irng == 2) {
3078       c1->Divide(6, 6, 1.e-6, 1.e-6);
3079     } else {
3080       c1->Divide(6, 4, 1.e-6, 1.e-6);
3081     }
3082   } else {
3083     if (irng == 2) {
3084       c1->Divide(4, 3, 1.e-6, 1.e-6);
3085     } else {
3086       c1->Divide(3, 2, 1.e-6, 1.e-6);
3087     }
3088   }
3089   TH1F* histx[routmx + 1][routmx + 1][nhothresh];
3090 
3091   int icol = 0;
3092 
3093   int nloop1 = 2;
3094   int nloop2 = nringmx;
3095   if (irng >= 0) {
3096     nloop1 = 1;
3097     if (isrm) {
3098       nloop2 = (irng == 2) ? 36 : 24;
3099     } else {
3100       nloop2 = (irng == 2) ? 12 : 6;
3101     }
3102   }
3103 
3104   for (int ij = 0; ij < nloop1; ij++) {    //ij<2
3105     for (int jk = 0; jk < nloop2; jk++) {  //ij<nringmx;
3106       for (int kl = th1; kl <= th2; kl++) {
3107         if (irng < 0) {
3108           if (ij == 0) {
3109             sprintf(name, "hoCalibc/rbx_mult_%i_r%i_0", kl, jk);  //, irbx);
3110           } else {
3111             sprintf(name, "hoCalibc/rout_mult_%i_r%i_0", kl, jk);  //, irbx);
3112           }
3113         } else if (isrm) {
3114           sprintf(name, "hoCalibc/rout_mult_%i_r%i_%i", kl, irng, jk + 1);
3115         } else {
3116           sprintf(name, "hoCalibc/rbx_mult_%i_r%i_%i", kl, irng, jk + 1);
3117         }
3118 
3119         histx[ij][jk][kl] = (TH1F*)gDirectory->Get(name);
3120         cout << "name " << name << endl;
3121         if (kl == th1)
3122           c1->cd(++icol);
3123         if (irng < 0) {
3124           if (ij == 0) {
3125             histx[ij][jk][kl]->GetXaxis()->SetTitle("# in RBX");
3126           } else {
3127             histx[ij][jk][kl]->GetXaxis()->SetTitle("# in RM");
3128           }
3129         } else if (isrm) {
3130           histx[ij][jk][kl]->GetXaxis()->SetTitle("# in RM");
3131         } else {
3132           histx[ij][jk][kl]->GetXaxis()->SetTitle("# in RBX");
3133         }
3134 
3135         histx[ij][jk][kl]->GetXaxis()->SetTitleSize(0.065);
3136         histx[ij][jk][kl]->GetXaxis()->SetTitleOffset(0.75);  //0.85
3137         histx[ij][jk][kl]->GetXaxis()->CenterTitle();
3138         histx[ij][jk][kl]->GetXaxis()->SetLabelSize(0.075);
3139         histx[ij][jk][kl]->GetXaxis()->SetLabelOffset(-0.01);
3140 
3141         histx[ij][jk][kl]->GetYaxis()->SetTitle();  //shape_name[ij][jk][kl]);
3142         histx[ij][jk][kl]->GetYaxis()->SetTitleSize(0.065);
3143         histx[ij][jk][kl]->GetYaxis()->SetTitleOffset(1.3);
3144         histx[ij][jk][kl]->GetYaxis()->CenterTitle();
3145         histx[ij][jk][kl]->GetYaxis()->SetLabelSize(0.075);
3146         histx[ij][jk][kl]->GetYaxis()->SetLabelOffset(0.01);
3147 
3148         histx[ij][jk][kl]->GetXaxis()->SetNdivisions(404);
3149         histx[ij][jk][kl]->GetYaxis()->SetNdivisions(404);
3150 
3151         histx[ij][jk][kl]->SetLineColor(kl - th1 + 1);
3152         histx[ij][jk][kl]->Draw((kl == th1) ? "" : "same");
3153         cout << "ijjk " << ij << " " << jk << " " << kl - th1 + 1 << " " << histx[ij][jk][kl]->GetTitle() << endl;
3154         if (kl == th1) {
3155           if (irng < 0) {
3156             latex.DrawLatex(0.35, 0.85, Form("R%i", jk - 2));
3157           } else if (isrm) {
3158             latex.DrawLatex(0.35, 0.85, Form("R%i RM%i", irng - 2, jk));
3159           } else {
3160             latex.DrawLatex(0.35, 0.85, Form("R%i RBX%i", irng - 2, jk));
3161           }
3162         }
3163         if (ij == 0 && jk == 0) {
3164           tleg->AddEntry(histx[ij][jk][kl], Form("th>%g", hothreshs[kl]), "lpfe");
3165         }
3166       }
3167     }
3168   }
3169   tleg->Draw();
3170   c1->Update();
3171 }
3172 
3173 // root histall_apr14b_cosmic_csa14_cosmic.root
3174 // plot8(0,5,0)
3175 // plot8(0,5,1)
3176 void plot8(int ith1 = 1, int ith2 = 8, int ityp = 1) {
3177   def_setting();
3178 
3179   gStyle->SetPadGridX(0);
3180   gStyle->SetPadGridY(0);
3181 
3182   TLatex latex;
3183   latex.SetNDC();
3184   latex.SetTextSize(0.06);
3185   latex.SetTextFont(42);
3186   latex.SetTextAlign(1);  //(31); // align right
3187 
3188   const int nringmx = 5;
3189   gStyle->SetOptStat(0);
3190   gStyle->SetPadTopMargin(0.06);
3191   gStyle->SetPadBottomMargin(0.16);
3192   gStyle->SetPadLeftMargin(0.16);
3193   gStyle->SetPadRightMargin(0.16);
3194 
3195   char name[100];
3196   TCanvas* c1 = new TCanvas("c1", "c1", 800., 500.);
3197   c1->Divide(4, 2, 1.e-6, 1.e-6);
3198   //  sprintf(name, "hoCalibc/hbentry_d%i", ij+3);
3199   int nentry = ((TH1F*)gDirectory->Get("hoCalibc/hbentry_d3"))->GetBinContent(0, 0);
3200   TH2F* histx[11];
3201   TH2F* histy[11];
3202 
3203   int icol = 0;
3204   for (int ij = ith1; ij <= ith2; ij++) {
3205     //    histx[1] = (TH2F*)gDirectory->Get(name);
3206     if (ityp == 0) {
3207       sprintf(name, "hoCalibc/hormoccu_%i", ij);
3208     } else {
3209       sprintf(name, "hoCalibc/hocorrelht_%i", ij);
3210     }
3211     cout << "nentry " << nentry << endl;
3212     histy[ij] = (TH2F*)gDirectory->Get(name);
3213     histx[ij] = (TH2F*)histy[ij]->Clone();
3214     histx[ij]->Scale(1. / nentry);
3215     histx[ij]->GetXaxis()->SetTitle((ityp == 0) ? "iRing" : "i#eta");
3216     histx[ij]->GetXaxis()->SetTitleSize(0.075);
3217     histx[ij]->GetXaxis()->SetTitleOffset(0.85);  //0.85
3218     histx[ij]->GetXaxis()->CenterTitle();
3219     histx[ij]->GetXaxis()->SetLabelSize(0.075);
3220     histx[ij]->GetXaxis()->SetLabelOffset(0.01);
3221 
3222     histx[ij]->GetYaxis()->SetTitle((ityp == 0) ? "RM" : "i#phi");
3223     histx[ij]->GetYaxis()->SetTitleSize(0.065);
3224     histx[ij]->GetYaxis()->SetTitleOffset(1.1);
3225     histx[ij]->GetYaxis()->CenterTitle();
3226     histx[ij]->GetYaxis()->SetLabelSize(0.065);
3227     histx[ij]->GetYaxis()->SetLabelOffset(0.01);
3228 
3229     histx[ij]->GetZaxis()->SetLabelSize(0.055);
3230     histx[ij]->GetZaxis()->SetLabelOffset(0.01);
3231 
3232     histx[ij]->GetXaxis()->SetNdivisions(202);
3233     histx[ij]->GetYaxis()->SetNdivisions(202);
3234     histx[ij]->GetZaxis()->SetNdivisions(202);
3235 
3236     c1->cd(++icol);
3237     histx[ij]->Draw("colz");
3238     latex.DrawLatex(0.58, 0.85, Form("E_{th}=%g GeV", hothreshs[ij]));
3239   }
3240   c1->Update();
3241 }
3242 
3243 // root histall_apr14b_cosmic_csa14_cosmic.root
3244 // plot9(2,0)
3245 // plot9(2,1)
3246 void plot9(int ith = 2, int ityp = 0) {
3247   def_setting();
3248 
3249   TLatex latex;
3250   latex.SetNDC();
3251   latex.SetTextSize(0.075);
3252   latex.SetTextFont(42);
3253   latex.SetTextAlign(1);  //(31); // align right
3254 
3255   const int nringmx = 5;
3256   gStyle->SetOptStat(0);
3257   gStyle->SetPadTopMargin(0.07);
3258   gStyle->SetPadBottomMargin(0.13);
3259   gStyle->SetPadLeftMargin(0.20);
3260   gStyle->SetPadRightMargin(0.17);
3261   char name[100];
3262   TCanvas* c1 = new TCanvas("c1", "c1", 800., 500.);
3263   c1->Divide(3, 2, 1.e-6, 1.e-6);
3264 
3265   int nentry = ((TH2F*)gDirectory->Get("hoCalibc/hbentry_d3"))->GetBinContent(0, 0);
3266   TH2F* histx[6];
3267   TH2F* histy[6];
3268 
3269   sprintf(name, "hoCalibc/hormcorrel_%i", ith);
3270 
3271   histy[0] = (TH2F*)gDirectory->Get(name);
3272   for (int jk = 0; jk < nringmx; jk++) {
3273     if (ityp == 0) {
3274       sprintf(name, "hoCalibc/hocorrelsig_%i_%i", jk, ith);
3275     } else {
3276       sprintf(name, "hoCalibc/hocorrel2sig_%i_%i", jk, ith);
3277     }
3278     histy[1 + jk] = (TH2F*)gDirectory->Get(name);
3279   }
3280 
3281   for (int ij = 0; ij < 6; ij++) {
3282     histx[ij] = (TH2F*)histy[ij]->Clone();
3283     histx[ij]->Scale(1. / nentry);
3284 
3285     if (ij == 0) {
3286       histx[ij]->GetXaxis()->SetTitle("# of RM in Rings");
3287       histx[ij]->GetYaxis()->SetTitle("# of RM in Rings");
3288     } else {
3289       if (ityp == 0) {
3290         histx[ij]->GetXaxis()->SetTitle("72 #times i#eta + i#phi");
3291         histx[ij]->GetYaxis()->SetTitle("72 #times i#eta + i#phi");
3292       } else {
3293         sprintf(name, "%i #times i#phi + i#eta", (ij == 1 || ij == 5) ? 5 : ((ij == 3) ? 8 : 6));
3294         histx[ij]->GetXaxis()->SetTitle(name);
3295         histx[ij]->GetYaxis()->SetTitle(name);
3296       }
3297     }
3298 
3299     histx[ij]->GetXaxis()->SetTitleSize(0.065);
3300     histx[ij]->GetXaxis()->SetTitleOffset(0.90);  //0.85
3301     histx[ij]->GetXaxis()->CenterTitle();
3302     histx[ij]->GetXaxis()->SetLabelSize(0.065);
3303     histx[ij]->GetXaxis()->SetLabelOffset(0.001);
3304 
3305     histx[ij]->GetYaxis()->SetTitleSize(0.065);
3306     histx[ij]->GetYaxis()->SetTitleOffset(1.3);
3307     histx[ij]->GetYaxis()->CenterTitle();
3308     histx[ij]->GetYaxis()->SetLabelSize(0.065);
3309     histx[ij]->GetYaxis()->SetLabelOffset(0.01);
3310 
3311     histx[ij]->GetZaxis()->SetLabelSize(0.055);
3312     histx[ij]->GetZaxis()->SetLabelOffset(0.01);
3313 
3314     histx[ij]->GetXaxis()->SetNdivisions(404);
3315     histx[ij]->GetYaxis()->SetNdivisions(404);
3316     histx[ij]->GetZaxis()->SetNdivisions(406);
3317 
3318     c1->cd(ij + 1);
3319     histx[ij]->Draw("colz");
3320     if (ij == 0)
3321       latex.DrawLatex(0.24, 0.85, Form("E_{th}=%g GeV", hothreshs[ith]));
3322     cout << "ij " << ij << " " << histx[ij]->GetTitle() << endl;
3323   }
3324   c1->Update();
3325 }
3326 
3327 // root histall_apr14b_cosmic_csa14_cosmic.root
3328 //  plot10(4,5)
3329 void plot10(int ith1 = 2, int ith2 = 3) {
3330   def_setting();
3331   TLatex latex;
3332   latex.SetNDC();
3333   latex.SetTextSize(0.05);
3334   latex.SetTextFont(42);
3335   latex.SetTextAlign(1);  //(31); // align right
3336   const int nringmx = 5;
3337   gStyle->SetOptStat(0);
3338   gStyle->SetPadTopMargin(0.06);
3339   gStyle->SetPadBottomMargin(0.10);
3340   gStyle->SetPadLeftMargin(0.16);
3341   gStyle->SetPadRightMargin(0.16);
3342   char name[100];
3343   TCanvas* c1 = new TCanvas("c1", "c1", 800., 500.);
3344   c1->Divide(2, 1, 1.e-6, 1.e-6);
3345   int nentry = ((TH2F*)gDirectory->Get("hoCalibc/hbentry_d3"))->GetBinContent(0, 0);
3346   TH2F* histx[2];
3347   TH2F* histy[2];
3348 
3349   sprintf(name, "hoCalibc/hoallcorrelsig_%i", ith1);
3350   histy[0] = (TH2F*)gDirectory->Get(name);
3351 
3352   sprintf(name, "hoCalibc/hoallcorrelsig_%i", ith2);
3353   histy[1] = (TH2F*)gDirectory->Get(name);
3354 
3355   for (int ij = 0; ij < 2; ij++) {
3356     histx[ij] = (TH2F*)histy[ij]->Clone();
3357     histx[ij]->Scale(1. / nentry);
3358 
3359     histx[ij]->GetXaxis()->SetTitle("72 #times i#eta+i#phi");
3360     histx[ij]->GetYaxis()->SetTitle("72 #times i#eta+i#phi");
3361 
3362     histx[ij]->GetXaxis()->SetTitleSize(0.045);
3363     histx[ij]->GetXaxis()->SetTitleOffset(0.90);  //0.85
3364     histx[ij]->GetXaxis()->CenterTitle();
3365     histx[ij]->GetXaxis()->SetLabelSize(0.045);
3366     histx[ij]->GetXaxis()->SetLabelOffset(0.001);
3367 
3368     histx[ij]->GetYaxis()->SetTitleSize(0.045);
3369     histx[ij]->GetYaxis()->SetTitleOffset(1.65);
3370     histx[ij]->GetYaxis()->CenterTitle();
3371     histx[ij]->GetYaxis()->SetLabelSize(0.045);
3372     histx[ij]->GetYaxis()->SetLabelOffset(0.01);
3373 
3374     histx[ij]->GetZaxis()->SetLabelSize(0.045);
3375     histx[ij]->GetZaxis()->SetLabelOffset(0.01);
3376 
3377     histx[ij]->GetXaxis()->SetNdivisions(406);
3378     histx[ij]->GetYaxis()->SetNdivisions(406);
3379     histx[ij]->GetZaxis()->SetNdivisions(406);
3380     if (ij == 0)
3381       histx[ij]->SetMaximum(0.000001);
3382     //    if (ij==1) histx[ij]->SetMaximum(0.0000005);
3383     c1->cd(ij + 1);
3384     histx[ij]->Draw("colz");
3385     latex.DrawLatex(0.28, 0.85, Form("E_{th}=%g GeV", hothreshs[(ij == 0) ? ith1 : ith2]));
3386 
3387     cout << "ij " << histx[ij]->GetTitle() << endl;
3388   }
3389   c1->Update();
3390 }
3391 
3392 // root histall_apr14b_cosmic_csa14_cosmic.root
3393 //NO  plot11(2,3)
3394 void plot11(int ith1 = 2, int ith2 = 3) {
3395   def_setting();
3396 
3397   TLatex latex;
3398   latex.SetNDC();
3399   latex.SetTextSize(0.05);
3400   latex.SetTextFont(42);
3401   latex.SetTextAlign(1);  //(31); // align right
3402   const int nringmx = 5;
3403   gStyle->SetOptStat(0);
3404   gStyle->SetPadTopMargin(0.06);
3405   gStyle->SetPadBottomMargin(0.10);
3406   gStyle->SetPadLeftMargin(0.16);
3407   gStyle->SetPadRightMargin(0.16);
3408 
3409   char name[100];
3410   TCanvas* c1 = new TCanvas("c1", "c1", 800., 500.);
3411   c1->Divide(2, 1, 1.e-6, 1.e-6);
3412   int nentry = ((TH2F*)gDirectory->Get("hoCalibc/hbentry_d3"))->GetBinContent(0, 0);
3413   TH2F* histx[2];
3414   TH2F* histy[2];
3415 
3416   sprintf(name, "hoCalibc/hoallmucorrel_%i", ith1);
3417   histy[0] = (TH2F*)gDirectory->Get(name);
3418 
3419   sprintf(name, "hoCalibc/hoallmucorrel_%i", ith2);
3420   histy[1] = (TH2F*)gDirectory->Get(name);
3421 
3422   for (int ij = 0; ij < 2; ij++) {
3423     double total = 0;
3424     histx[ij] = (TH2F*)histy[ij]->Clone();
3425     for (int ix = 1; ix <= histy[ij]->GetNbinsX(); ix++) {
3426       float anent = histy[ij]->GetBinContent(ix, 0);
3427       total += anent;
3428       //      cout<<"ix "<< ij<<" "<<ix<<" "<<anent<<" "<<total<<endl;
3429       if (anent < 1.)
3430         anent = 1.;
3431       for (int iy = 1; iy <= histy[ij]->GetNbinsY(); iy++) {
3432         histx[ij]->SetBinContent(ix, iy, histy[ij]->GetBinContent(ix, iy) / anent);
3433       }
3434     }
3435 
3436     histx[ij]->GetXaxis()->SetTitle("Projected muon (72 #times i#eta+i#phi)");
3437     histx[ij]->GetYaxis()->SetTitle("Signal in HO tower (72 #times i#eta+i#phi)");
3438 
3439     histx[ij]->GetXaxis()->SetTitleSize(0.045);
3440     histx[ij]->GetXaxis()->SetTitleOffset(0.90);  //0.85
3441     histx[ij]->GetXaxis()->CenterTitle();
3442     histx[ij]->GetXaxis()->SetLabelSize(0.04);
3443     histx[ij]->GetXaxis()->SetLabelOffset(0.001);
3444 
3445     histx[ij]->GetYaxis()->SetTitleSize(0.045);
3446     histx[ij]->GetYaxis()->SetTitleOffset(1.65);
3447     histx[ij]->GetYaxis()->CenterTitle();
3448     histx[ij]->GetYaxis()->SetLabelSize(0.04);
3449     histx[ij]->GetYaxis()->SetLabelOffset(0.01);
3450 
3451     histx[ij]->GetZaxis()->SetLabelSize(0.04);
3452     histx[ij]->GetZaxis()->SetLabelOffset(0.01);
3453 
3454     histx[ij]->GetXaxis()->SetNdivisions(406);
3455     histx[ij]->GetYaxis()->SetNdivisions(406);
3456     histx[ij]->GetZaxis()->SetNdivisions(406);
3457     //    if (ij==0) histx[ij]->SetMaximum(0.002);
3458     //    if (ij==1) histx[ij]->SetMaximum(0.001);
3459     c1->cd(ij + 1);
3460     histx[ij]->Draw("colz");
3461     latex.DrawLatex(0.28, 0.85, Form("E_{th}=%g GeV", hothreshs[(ij == 0) ? ith1 : ith2]));
3462     cout << "ij " << histx[ij]->GetTitle() << endl;
3463   }
3464   c1->Update();
3465 }
3466 
3467 /*
3468 
3469 root ../local/loc2014/hist_local_*_Cosmics.root
3470  .L anal_csa14_pl.C
3471 alllocal(6);
3472 root ../local/loc2014/hist_local_*_40fC.root
3473  .L anal_csa14_pl.C
3474 alllocal(6);
3475 root ../local/loc2014/hist_local_*_50fC.root
3476  .L anal_csa14_pl.C
3477 alllocal(3);
3478 root ../local/loc2014/hist_local_*_60fC.root
3479  .L anal_csa14_pl.C
3480 alllocal(9);
3481 root ../local/loc2014/hist_local_*_peds.root
3482  .L anal_csa14_pl.C
3483 alllocal(3);
3484 */
3485 
3486 void alllocal(int nfile = 9) {
3487   char pch1[200];
3488   for (int ij = 0; ij < nfile; ij++) {
3489     switch (ij) {
3490       case 0:
3491         _file0->cd();
3492         break;
3493       case 1:
3494         _file1->cd();
3495         break;
3496       case 2:
3497         _file2->cd();
3498         break;
3499       case 3:
3500         _file3->cd();
3501         break;
3502       case 4:
3503         _file4->cd();
3504         break;
3505       case 5:
3506         _file5->cd();
3507         break;
3508       case 6:
3509         _file6->cd();
3510         break;
3511       case 7:
3512         _file7->cd();
3513         break;
3514       case 8:
3515         _file8->cd();
3516         break;
3517       case 9:
3518         _file9->cd();
3519         break;
3520       default:
3521         _file0->cd();
3522         break;
3523     }
3524 
3525     cout << "xx1 " << endl;
3526     char* namex = gDirectory->GetName();
3527     int len2 = strlen(namex);
3528     strncpy(pch1, namex + 17, len2 - 22);
3529     pch1[len2 - 22] = '\0';
3530     sprintf(pch1, "%s.ps", pch1);
3531     TPostScript pss(pch1, 112);
3532     pss.Range(28, 20);  //pss.Range(20,28);
3533     cout << "xx2 " << endl;
3534     pss.NewPage();
3535     pss.NewPage();
3536     testxx();
3537     pss.NewPage();
3538     /*
3539     pss.NewPage(); plot000(-1,6,6,1); 
3540     pss.NewPage(); plot000(0,6,6,1);
3541     pss.NewPage(); plot000(1,6,6,1); 
3542     pss.NewPage(); plot000(2,12,12,1);
3543     pss.NewPage(); plot000(3,6,6,1); 
3544     pss.NewPage(); plot000(4,6,6,1);
3545     */
3546 
3547     pss.NewPage();
3548     plot000(0, 6, 6, 1);
3549     plot000(1, 6, 6, 1, "same", 1);
3550     plot000(2, 12, 12, 1, "same", 2);
3551     plot000(3, 6, 6, 1, "same", 3);
3552     plot000(4, 6, 6, 1, "sames", 4);
3553 
3554     for (int jk = 0; jk < 5; jk++) {
3555       pss.NewPage();
3556       plot000(jk, 0, 0, 1);
3557       for (int kl = 1; kl < 12; kl++) {
3558         if (jk != 2 && kl > 5)
3559           continue;
3560         cout << "jk " << jk << " " << kl << endl;
3561         if ((jk == 2 && kl == 11) || (jk != 2 && kl == 5)) {
3562           plot000(jk, kl, kl, 1, "sames", kl);
3563         } else {
3564           plot000(jk, kl, kl, 1, "same", kl);
3565         }
3566       }
3567     }
3568 
3569     //     //    pss.NewPage(); plot000(1,0,0,1);
3570     //     //    plot000(1,1,1,1, "same",1);
3571     //     //    plot000(1,2,2,1, "same",2);
3572     //     //    plot000(1,3,3,1, "same",3);
3573     //     //    plot000(1,4,4,1, "same",4);
3574     //     //    plot000(1,5,5,1, "sames",5);
3575 
3576     // //     /*
3577     // //     pss.NewPage(); plot000(0,0,5,1);
3578     // //     pss.NewPage(); plot000(1,0,5,1);
3579     // //     pss.NewPage(); plot000(2,0,5,1);
3580     // //     pss.NewPage(); plot000(2,6,11,1);
3581     // //     pss.NewPage(); plot000(3,0,5,1);
3582     // //     pss.NewPage(); plot000(4,0,5,1);
3583     // //     */
3584 
3585     pss.NewPage();
3586     plot000r(-1);
3587     pss.NewPage();
3588     plot000r(0);
3589     pss.NewPage();
3590     plot000r(1);
3591     pss.NewPage();
3592     plot000r(2);
3593     pss.NewPage();
3594     plot000r(3);
3595     pss.NewPage();
3596     plot000r(4);
3597 
3598     // //     /*
3599     // //     pss.NewPage(); plot01(0,1);
3600     // //     pss.NewPage(); plot01(1,1);
3601     // //     */
3602     pss.NewPage();
3603     plot01(2, 1);
3604 
3605     pss.NewPage();
3606     plot2(0, 4, 0);
3607     pss.NewPage();
3608     plot2(4, 8, 0);
3609 
3610     // //     pss.NewPage(); plot4(0,8,0,0);
3611     // //     //    pss.NewPage(); plot4(3,5,0,0);
3612     // //     //    pss.NewPage(); plot4(6,8,0,0);
3613 
3614     // //     //    pss.NewPage(); plot5(0,2,0,0);
3615     // //     //    pss.NewPage(); plot5(3,5,0,0);
3616     // //     //    pss.NewPage(); plot5(6,8,0,0);
3617 
3618     pss.NewPage();
3619     plot6(-2, 0);
3620     pss.NewPage();
3621     plot6(-1, 0);
3622     pss.NewPage();
3623     plot6(0, 0);
3624     pss.NewPage();
3625     plot6(1, 0);
3626     pss.NewPage();
3627     plot6(2, 0);
3628 
3629     // // //     pss.NewPage(); plot7(0,0);
3630     // // //     pss.NewPage(); plot7(1,0);
3631     // // //     pss.NewPage(); plot7(2,0);
3632     // // //     pss.NewPage(); plot7(3,0);
3633     // // //     pss.NewPage(); plot7(4,0);
3634     // // //     pss.NewPage(); plot7(2,2);
3635 
3636     pss.NewPage();
3637     plot7b(-1, 3);
3638     pss.NewPage();
3639     plot7b(0, 2, 8, 0);
3640     pss.NewPage();
3641     plot7b(1, 2, 8, 0);
3642     pss.NewPage();
3643     plot7b(2, 2, 8, 0);
3644     pss.NewPage();
3645     plot7b(3, 2, 8, 0);
3646     pss.NewPage();
3647     plot7b(4, 2, 8, 0);
3648     pss.NewPage();
3649     plot7b(0, 2, 8, 1);
3650     pss.NewPage();
3651     plot7b(1, 2, 8, 1);
3652     pss.NewPage();
3653     plot7b(2, 2, 8, 1);
3654     pss.NewPage();
3655     plot7b(3, 2, 8, 1);
3656     pss.NewPage();
3657     plot7b(4, 2, 8, 1);
3658 
3659     pss.NewPage();
3660     plot8(1, 8, 0);
3661     pss.NewPage();
3662     plot8(1, 8, 1);
3663 
3664     pss.NewPage();
3665     plot9(2, 0);
3666     pss.NewPage();
3667     plot9(2, 1);
3668 
3669     //    pss.NewPage(); plot10(4,5);
3670 
3671     pss.Close();
3672   }
3673 }
3674 /*
3675 hadd histall_local_peds.root hist_local_*_peds.root
3676 hadd histall_local_40fc.root hist_local_22*_40fC.root
3677 hadd histall_local_50fc.root hist_local_22*_50fC.root
3678 hadd histall_local_60fc.root hist_local_221848_60fC.root hist_local_221945_60fC.root hist_local_222770_60fC.root
3679 hadd histall_local_cosmics.root hist_local_220619_Cosmics.root hist_local_220620_Cosmics.root hist_local_220625_Cosmics.root
3680 */
3681 
3682 void alllocalx(int nfile = 9) {
3683   char pch1[200];
3684   for (int ij = 0; ij < nfile; ij++) {
3685     switch (ij) {
3686       case 0:
3687         _file0->cd();
3688         break;
3689       case 1:
3690         _file1->cd();
3691         break;
3692       case 2:
3693         _file2->cd();
3694         break;
3695       case 3:
3696         _file3->cd();
3697         break;
3698       case 4:
3699         _file4->cd();
3700         break;
3701       case 5:
3702         _file5->cd();
3703         break;
3704       case 6:
3705         _file6->cd();
3706         break;
3707       case 7:
3708         _file7->cd();
3709         break;
3710       case 8:
3711         _file8->cd();
3712         break;
3713       case 9:
3714         _file9->cd();
3715         break;
3716       case 10:
3717         _file10->cd();
3718         break;
3719       case 11:
3720         _file11->cd();
3721         break;
3722       case 12:
3723         _file12->cd();
3724         break;
3725       case 13:
3726         _file13->cd();
3727         break;
3728       case 14:
3729         _file14->cd();
3730         break;
3731       case 15:
3732         _file15->cd();
3733         break;
3734       case 16:
3735         _file16->cd();
3736         break;
3737       case 17:
3738         _file17->cd();
3739         break;
3740       case 18:
3741         _file18->cd();
3742         break;
3743       case 19:
3744         _file19->cd();
3745         break;
3746       case 20:
3747         _file20->cd();
3748         break;
3749       case 21:
3750         _file21->cd();
3751         break;
3752       case 22:
3753         _file22->cd();
3754         break;
3755       case 23:
3756         _file23->cd();
3757         break;
3758       case 24:
3759         _file24->cd();
3760         break;
3761       case 25:
3762         _file25->cd();
3763         break;
3764       case 26:
3765         _file26->cd();
3766         break;
3767       case 27:
3768         _file27->cd();
3769         break;
3770       case 28:
3771         _file28->cd();
3772         break;
3773       case 29:
3774         _file29->cd();
3775         break;
3776 
3777       default:
3778         _file0->cd();
3779         break;
3780     }
3781 
3782     char* namex = gDirectory->GetName();
3783     int len2 = strlen(namex);
3784     strncpy(pch1, namex + 17, len2 - 22);
3785     pch1[len2 - 22] = '\0';
3786     sprintf(pch1, "xx_%s.ps", pch1);
3787     TPostScript pss(pch1, 112);
3788     pss.Range(28, 20);  //pss.Range(20,28);
3789 
3790     pss.NewPage();
3791     pss.NewPage();
3792     testxx();
3793     pss.NewPage();
3794     testxx();
3795 
3796     pss.NewPage();
3797     plot000r(-1, 0, 140);
3798     pss.NewPage();
3799     plot000r(-1, 1, 140);
3800 
3801     //    pss.NewPage(); plot000r(0);
3802     //    pss.NewPage(); plot000r(1);
3803     //    pss.NewPage(); plot000r(2);
3804     //    pss.NewPage(); plot000r(3);
3805     //    pss.NewPage(); plot000r(4);
3806 
3807     pss.NewPage();
3808     plot2(0, 4, 0);
3809     pss.NewPage();
3810     plot2(4, 8, 0);
3811 
3812     //    pss.NewPage(); plot000r(0);
3813     //    pss.NewPage(); plot000r(1);
3814     //    pss.NewPage(); plot000r(2);
3815     //    pss.NewPage(); plot000r(3);
3816     //    pss.NewPage(); plot000r(4);
3817 
3818     pss.NewPage();
3819     plot01(2, 1);
3820 
3821     pss.NewPage();
3822     plot7b(-1, 2, 8);
3823     pss.NewPage();
3824     plot7b(0, 2, 8, 0);
3825     pss.NewPage();
3826     plot7b(1, 2, 8, 0);
3827     pss.NewPage();
3828     plot7b(2, 2, 8, 0);
3829     pss.NewPage();
3830     plot7b(3, 2, 8, 0);
3831     pss.NewPage();
3832     plot7b(4, 2, 8, 0);
3833     pss.NewPage();
3834     plot7b(0, 2, 8, 1);
3835     pss.NewPage();
3836     plot7b(1, 2, 8, 1);
3837     pss.NewPage();
3838     plot7b(2, 2, 8, 1);
3839     pss.NewPage();
3840     plot7b(3, 2, 8, 1);
3841     pss.NewPage();
3842     plot7b(4, 2, 8, 1);
3843 
3844     pss.NewPage();
3845     plot8(1, 8, 0);
3846     pss.NewPage();
3847     plot8(1, 8, 1);
3848 
3849     pss.NewPage();
3850     plot9(2, 0);
3851     //     pss.NewPage(); plot9(2,1);
3852 
3853     //    pss.NewPage(); plot10(4,5);
3854 
3855     pss.NewPage();
3856     plot4(0, 8, 0, 0);
3857 
3858     // //     //    pss.NewPage(); plot5(0,2,0,0);
3859     // //     //    pss.NewPage(); plot5(3,5,0,0);
3860     // //     //    pss.NewPage(); plot5(6,8,0,0);
3861 
3862     pss.NewPage();
3863     plot000(0, 6, 6, 1);
3864     plot000(1, 6, 6, 1, "same", 1);
3865     plot000(2, 12, 12, 1, "same", 2);
3866     plot000(3, 6, 6, 1, "same", 3);
3867     plot000(4, 6, 6, 1, "sames", 4);
3868 
3869     for (int jk = 0; jk < 5; jk++) {
3870       pss.NewPage();
3871       plot000(jk, 0, 0, 1);
3872       for (int kl = 1; kl < 12; kl++) {
3873         if (jk != 2 && kl > 5)
3874           continue;
3875         cout << "jk " << jk << " " << kl << endl;
3876         if ((jk == 2 && kl == 11) || (jk != 2 && kl == 5)) {
3877           plot000(jk, kl, kl, 1, "sames", kl);
3878         } else {
3879           plot000(jk, kl, kl, 1, "same", kl);
3880         }
3881       }
3882     }
3883 
3884     pss.NewPage();
3885     plot6(-2, 0);
3886     pss.NewPage();
3887     plot6(-1, 0);
3888     pss.NewPage();
3889     plot6(0, 0);
3890     pss.NewPage();
3891     plot6(1, 0);
3892     pss.NewPage();
3893     plot6(2, 0);
3894 
3895     pss.Close();
3896   }
3897 }
3898 
3899 // scp hcal_local_*_peds.root hcal_local_*_40fC.root hcal_local_*_50fC.root hcal_local_*_60fC.root hist_local_*_peds.root hist_local_*_40fC.root hist_local_*_50fC.root hist_local_*_60fC.root gobinda@158.144.54.116:/data/gobinda/anal/hcal/local/loc2014/
3900 
3901 void test1x() {
3902   for (int ij = 1; ij < 14; ij++) {
3903     cout << "INR " << 6200 * ij + 4000 << " (for " << ij << " nights)" << endl;
3904   }
3905 }
3906 
3907 void sigpedrun(int nrn = 100) {
3908   TPostScript ps("testxx.ps", 111);
3909   ps.Range(20, 28);
3910   TCanvas* c0x = new TCanvas("c0x", " Pedestal and signal", 900, 1200);
3911   c0x->Divide(5, 4, 1.e-5, 1.e-5, 0);
3912 
3913   TH1F* signal_run[5][3000];
3914   char name[100];
3915 
3916   for (int ix = 0; ix < nrn; ix++) {
3917     int ixxy = ix % 4;
3918     if (ixxy == 0) {
3919       ps.NewPage();
3920     }
3921     for (int iy = 0; iy < ringmx; iy++) {
3922       sprintf(name, "noise_ring_%i_run%i", iy, ix);
3923       signal_run[iy][ix] = (TH1F*)gDirectory->Get(name);
3924       double mean = signal_run[iy][ix]->GetMean();
3925       double rms = signal_run[iy][ix]->GetRMS();
3926       if (iy == 0)
3927         cout << ix << " " << signal_run[iy][ix]->GetTitle() << " ";
3928       //      cout <<" "<<signal_run[iy][ix]->GetEntries()<<" "<<mean<<" "<<rms;
3929       cout << " " << mean;
3930       c0x->cd(ringmx * ixxy + iy + 1);
3931       signal_run[iy][ix]->SetLineColor(3);
3932       signal_run[iy][ix]->GetXaxis()->SetLabelSize(0.095);
3933       signal_run[iy][ix]->GetXaxis()->SetNdivisions(404);
3934       signal_run[iy][ix]->GetYaxis()->SetLabelSize(0.095);
3935       signal_run[iy][ix]->GetXaxis()->SetLabelOffset(-0.02);
3936       signal_run[iy][ix]->Draw();
3937       if (ixxy == 3) {
3938         c0x->Update();
3939       }
3940     }
3941     cout << endl;
3942   }
3943 
3944   ps.Close();
3945 }
3946 /*
3947  Run # 297180 Evt # 102392070 1 7024424
3948 
3949 All    94.67     92.49     95.35      92.7     94.71 
3950 
3951 ndof    93.37        92     94.58     92.21      93.3 
3952 chisq    93.34     91.96     94.53     92.16     93.27 
3953 angle    93.33     91.96     94.53     92.16     93.27 
3954 pt    92.13     90.45     92.22     90.63     92.01 
3955 isol    62.28        56     55.51     56.17     62.68 
3956 phi    56.27      50.7     47.38     50.85     56.58 
3957 eta    52.41     46.51     36.64     46.69      52.7 
3958 Time    52.24      46.4     36.63     46.54     52.54 
3959 
3960 
3961 hodx    99.31     97.74     99.62     98.03     99.32 
3962 iso    96.61     94.44        97     94.67     96.68 
3963 pt     96.4     94.17     96.81      94.4     96.48 
3964 
3965 
3966 
3967    1  Constant     8.56917e+01   2.42013e+00   7.85930e-03   3.06102e-06
3968    2  Mean         1.00342e+00   1.07020e-03   4.43892e-06   3.20972e-03
3969    3  Sigma        4.79270e-02   8.60831e-04   1.86192e-05  -5.88994e-03
3970 
3971    1  Constant     1.92784e+02   5.34817e+00   1.63458e-02  -1.85787e-06
3972    2  Mean         9.99574e-01   4.75653e-04   1.82064e-06   2.98504e-02
3973    3  Sigma        2.14641e-02   3.63935e-04   1.51944e-05  -3.40005e-03
3974 
3975    1  Constant     4.23168e+02   1.23598e+01   3.79784e-02  -4.19190e-05
3976    2  Mean         1.01199e+00   2.17199e-04   8.81854e-07  -3.90635e-01
3977    3  Sigma        9.80276e-03   1.89893e-04   1.59833e-05  -2.89784e-02
3978 
3979    1  Constant     2.73388e+02   7.95311e+00   2.29623e-02   1.00544e-07
3980    2  Mean         1.01965e+00   3.34716e-04   1.28072e-06   1.32401e-01
3981    3  Sigma        1.52308e-02   2.92214e-04   1.60562e-05  -4.93738e-03
3982 
3983    1  Constant     3.33148e+02   9.67580e+00   2.88215e-02  -1.45420e-05
3984    2  Mean         1.02102e+00   2.74804e-04   1.08052e-06  -2.43768e+00
3985    3  Sigma        1.24753e-02   2.37824e-04   1.60597e-05   3.78574e-02
3986 
3987    1  Constant     4.11514e+02   1.19379e+01   3.34777e-02  -1.48396e-07
3988    2  Mean         1.02247e+00   2.23653e-04   8.24581e-07   3.21928e-03
3989    3  Sigma        1.01355e-02   1.93182e-04   1.45150e-05  -2.31771e-04
3990 
3991    1  Constant     4.17155e+02   1.22384e+01   3.67076e-02  -3.41070e-05
3992    2  Mean         1.02334e+00   2.19820e-04   8.75434e-07  -4.30174e+00
3993    3  Sigma        9.95279e-03   1.94035e-04   1.57779e-05   1.98571e-02
3994 
3995    1  Constant     3.99846e+02   1.20076e+01   4.10521e-02   1.64058e-06
3996    2  Mean         1.02511e+00   2.34554e-04   1.05387e-06   4.74777e-02
3997    3  Sigma        1.02668e-02   2.09319e-04   1.83947e-05   1.76225e-02
3998 
3999 
4000 CRO_pulse->Draw("c2PeakTime_1[0]","c1PeakTime_1[0]>-100&&c2PeakTime_1[0]>-100&&")
4001 
4002 CRO_pulse->Draw("c4PeakTime_1[1]","c3PeakTime_1[1]>-100&&c4PeakTime_1[1]>-100&&c3PeakTime_1[1]>1.e-6&&c4PeakTime_1[1]>1.e-6")
4003 
4004 
4005 */