ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DTDPGAnalysis/src/DTDPGCreateAnalyzerSummary.cc
(Generate patch)

Comparing UserCode/DTDPGAnalysis/src/DTDPGCreateAnalyzerSummary.cc (file contents):
Revision 1.7 by pellicci, Mon May 3 14:38:28 2010 UTC vs.
Revision 1.8 by battilan, Wed Dec 15 11:52:26 2010 UTC

# Line 36 | Line 36
36   #include "TF1.h"
37   #include "TH2F.h"
38   #include "TCanvas.h"
39 + #include "TPad.h"
40   #include "TGraph.h"
41   #include "TPostScript.h"
42   #include "TPaveLabel.h"
# Line 43 | Line 44
44   #include "TProfile.h"
45   #include "TStyle.h"
46   #include "TFolder.h"
47 + #include "TColor.h"
48 + #include "TPaletteAxis.h"
49   #include "boost/filesystem.hpp"
50  
51   using namespace edm;
# Line 65 | Line 68 | DTDPGCreateAnalyzerSummary::~DTDPGCreate
68   }
69  
70  
71 < void DTDPGCreateAnalyzerSummary::beginJob(const edm::EventSetup& context){
71 > void DTDPGCreateAnalyzerSummary::beginJob(){
72  
73    edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: BeginJob";
74  
75   }
76  
77   void DTDPGCreateAnalyzerSummary::analyze(const edm::Event& e, const edm::EventSetup& context){
75  
78   }
79  
80  
# Line 110 | Line 112 | void DTDPGCreateAnalyzerSummary::endJob(
112  
113   }
114  
115 < void DTDPGCreateAnalyzerSummary::createGifFile(string fileName, int wh, int sec, string tag, TCanvas *canvas) {
115 > void DTDPGCreateAnalyzerSummary::createGifFile(string fileName, int wh, int sec, string tag, TCanvas *canvas, bool isExtraFile) {
116  
117    stringstream gifBase;
118    gifBase << "Run" << myRunNumber << "/Wheel" << showpos << wh << "/Sect" << noshowpos << setfill('0')<< setw(2) << sec;
119 +  if (isExtraFile) { gifBase << "/ExtraPlots"; }
120 +
121    try {
122      create_directories(gifBase.str());
123    } catch(const std::exception & ex) {
# Line 127 | Line 131 | void DTDPGCreateAnalyzerSummary::createG
131  
132   }
133  
134 < void DTDPGCreateAnalyzerSummary::createGifFile(string fileName, int wh, string tag, TCanvas *canvas) {
134 > void DTDPGCreateAnalyzerSummary::createGifFile(string fileName, int wh, string tag, TCanvas *canvas, bool isExtraFile) {
135  
136    stringstream gifBase;
137    gifBase << "Run" << myRunNumber << "/Wheel" << showpos << wh << noshowpos;
138 +  if (isExtraFile) { gifBase << "/ExtraPlots"; }
139    try {
140      create_directories(gifBase.str());
141    } catch(const std::exception & ex) {
# Line 143 | Line 148 | void DTDPGCreateAnalyzerSummary::createG
148    canvas->Print(gifFile.c_str());
149  
150   }
151 < void DTDPGCreateAnalyzerSummary::createGifFile(string fileName, string tag, TCanvas *canvas) {
151 >
152 > void DTDPGCreateAnalyzerSummary::createGifFile(string fileName, string tag, TCanvas *canvas, bool isExtraFile) {
153  
154    stringstream gifBase;
155    gifBase << "Run" << myRunNumber;
156 +  if (isExtraFile) { gifBase << "/ExtraPlots"; }
157    try {
158      create_directories(gifBase.str());
159    } catch(const std::exception & ex) {
# Line 161 | Line 168 | void DTDPGCreateAnalyzerSummary::createG
168  
169   }
170    
164  
171   void DTDPGCreateAnalyzerSummary::createSummaryPlots() {
172  
173    string Whname[5]={"Wm2","Wm1","W0","W1","W2"};
# Line 179 | Line 185 | void DTDPGCreateAnalyzerSummary::createS
185  
186    
187    // Get histos to be plotted
182  // char histoname[240];
183  // char htit[240]; // ???
188    TH1F * first_to_paint;
189 +  TH1F * first_to_paint_MB[4];
190    string SLname[3]={"Phi1","Theta","Phi2"};
191  
192    int nbin;
# Line 190 | Line 195 | void DTDPGCreateAnalyzerSummary::createS
195    TH2F *DigiXYS[5][14];
196    TH1F *DigiXSecMBSlLayer[5][14][4][3][4];
197    TH1F *TBoxSecMBSlLayer[5][14][4][3][4];
198 +  TH1F *OccupMB[5][4];
199    TH1F *Correlated_trig_Bx[5][14][4][3];
200    TH1F *hTrg_effnum_SecMB[5][14][4];
201    TH1F *hTrg_effdenum_SecMB[5][14][4];
# Line 331 | Line 337 | void DTDPGCreateAnalyzerSummary::createS
337        int ichmin=1; if (isec==13|| isec==14)ichmin=4;
338        for(int ich=ichmin;ich<5;ich++){
339          for(int isl=1;isl<4;isl++){
334          TCanvas *DigiSL = new TCanvas("DigiSL", "",201,81,999,699);  
340            bool dodraw=1;
341            if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
342            if(dodraw){
343 +            TCanvas *DigiSL = new TCanvas("DigiSL", "",201,81,999,699);  
344              // look first for the maximum bin entries
345              first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
346              float nbmax=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
# Line 348 | Line 354 | void DTDPGCreateAnalyzerSummary::createS
354              }
355              stringstream htitle;  htitle << "Occupancy W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
356              first_to_paint->SetTitle(htitle.str().c_str());
351            //int icpos=(ich-1)*3+isl;
357              first_to_paint->GetYaxis()->SetLabelSize(0.05);
358              first_to_paint->GetXaxis()->SetLabelSize(0.05);
359              first_to_paint->Draw();
# Line 413 | Line 418 | void DTDPGCreateAnalyzerSummary::createS
418        ichmin=1; if (isec==13|| isec==14)ichmin=4;
419        for(int ich=ichmin;ich<5;ich++){
420          for(int isl=1;isl<4;isl++){
416          TCanvas *TboxSL = new TCanvas("TboxSL", "",201,81,999,699);
421            
422            bool dodraw=1;
423            if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
424            if(dodraw){
425 +             TCanvas *TboxSL = new TCanvas("TboxSL", "",201,81,999,699);
426              // look first for the maximum bin entries
427              first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
428              float nbmax=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
# Line 448 | Line 453 | void DTDPGCreateAnalyzerSummary::createS
453      }
454    }//end Loop on sectors/wheels
455  
451
452  //===================================================================================
453  //    Trigger Stuff
454  //===================================================================================
455  
456  TH1F *heffTrgSecMB[5][14][4];
457  string labTriggerMatrix[]={"no trig"," ","MB1","MB2","MB3","MB4"," ","1 & 2","1 & 3","1 & 4","2 & 3","2 & 4",
458                             "3 & 4"," ","1 & 2 & 3","1 & 2 & 4","1 & 3 & 4","2 & 3 & 4"," ","1 & 2 & 3 & 4"};
459
460  whIt  = mySectors.begin();
461  whEnd = mySectors.end();
462  for(;whIt!=whEnd;++whIt) {
463    int iw = (*whIt).first + 2;
464    std::vector<int>::const_iterator secIt  = (*whIt).second.begin();
465    std::vector<int>::const_iterator secEnd = (*whIt).second.end();
466    for(;secIt!=secEnd;++secIt) {
467      int isec = (*secIt);
468      if(isec <13){
469
470        //===================================================================================
471        // BX profiles:
472        //===================================================================================
473        edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing single chamber BX profiles per Sector wh"
474                                          << (iw-2) << " sec " << isec << endl;
475        TCanvas *Trigg = new TCanvas("Trigg", "",201,81,999,699);
476        Trigg->Divide(2,2) ;
477        for(int ich=1;ich<5;ich++){
478          Trigg->cd(ich) ;
479          Trigg->cd(ich)->SetLogy();
480          Correlated_trig_Bx[iw][isec-1][ich-1][2]->GetXaxis()->SetTitle("BX id");
481          stringstream htitle; htitle << "llHlHH_trig_bxMB"<< ich;
482          Correlated_trig_Bx[iw][isec-1][ich-1][2]->SetTitle(htitle.str().c_str());
483          Correlated_trig_Bx[iw][isec-1][ich-1][2]->GetXaxis()->SetTitleSize(0.05);
484          Correlated_trig_Bx[iw][isec-1][ich-1][2]->GetXaxis()->SetLabelSize(0.05);
485          Correlated_trig_Bx[iw][isec-1][ich-1][2]->GetXaxis()->SetLabelSize(0.05);
486          Correlated_trig_Bx[iw][isec-1][ich-1][2]->Draw();
487          Correlated_trig_Bx[iw][isec-1][ich-1][1]->SetLineColor(2);
488          Correlated_trig_Bx[iw][isec-1][ich-1][1]->Draw("same");
489          Correlated_trig_Bx[iw][isec-1][ich-1][0]->SetLineColor(3);
490          Correlated_trig_Bx[iw][isec-1][ich-1][0]->Draw("same");
491        }// end loop on chambers
492
493        createGifFile("Trigger_Summary",(iw-2),isec,"",Trigg);
494        delete Trigg;
495
496        //===================================================================================
497        //    Trigger: HH&HL efficiencies
498        //===================================================================================
499        edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing HH&HL efficiencies wh "
500                                          << (iw-2) << " sec " << isec << endl;
501        TCanvas *EffTrg = new TCanvas("EffTrg", "",201,81,999,699);
502        EffTrg->Divide(2,4); // divide canvas in 2 columns, 4 raws
503
504        for(int ich=1;ich<5;ich++){
505          stringstream histoname; histoname << "heffTrgSec" << isec << "MB" << ich;
506          heffTrgSecMB[iw][isec-1][ich-1] =(TH1F*)hTrg_effnum_SecMB[iw][isec-1][ich-1]->Clone(histoname.str().c_str());
507          heffTrgSecMB[iw][isec-1][ich-1]->Divide(hTrg_effnum_SecMB[iw][isec-1][ich-1]
508                                                  ,hTrg_effdenum_SecMB[iw][isec-1][ich-1],1.0,1.0);
509          heffTrgSecMB[iw][isec-1][ich-1]->SetMaximum(1.1);
510          heffTrgSecMB[iw][isec-1][ich-1]->SetMinimum(0.);
511          heffTrgSecMB[iw][isec-1][ich-1]->GetXaxis()->SetLabelSize(0.05);
512          heffTrgSecMB[iw][isec-1][ich-1]->GetYaxis()->SetLabelSize(0.05);
513          for (int i = 0; i <= hTrg_effdenum_SecMB[iw][isec-1][ich-1]->GetNbinsX()+1; i++ ) {
514            Float_t tot   = hTrg_effdenum_SecMB[iw][isec-1][ich-1]->GetBinContent(i) ;
515            Float_t tot_e = hTrg_effdenum_SecMB[iw][isec-1][ich-1]->GetBinError(i);
516            Float_t eff = heffTrgSecMB[iw][isec-1][ich-1]->GetBinContent(i) ;
517            Float_t Err = 0.;
518            if (tot > 0) Err = tot_e / tot * sqrt( eff* (1-eff) );
519            // if (eff == 1. || isnan(Err) || !isfinite(Err) ) Err=1.e-3;
520            heffTrgSecMB[iw][isec-1][ich-1]->SetBinError(i, Err);
521          }
522        
523          EffTrg->cd((ich-1)*2+1);  
524          heffTrgSecMB[iw][isec-1][ich-1]->Draw();
525          EffTrg->cd((ich-1)*2+2);  
526          hPhiHL_SecMB[iw][isec-1][ich-1]->Draw();
527        }
528
529        createGifFile("TriggEff_HH&HL",(iw-2),isec,"",EffTrg);
530        delete EffTrg;
531
532        //===================================================================================
533        //    Trigger: TriggerMatrix
534        //===================================================================================
535        edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing TriggerMatrix wh "
536                                          << (iw-2) << " sec " << isec << endl;
537
538        for (int ibin=1; ibin<21; ibin++) TriggerMatrix[iw][isec-1]->GetXaxis()->SetBinLabel(ibin,(labTriggerMatrix[ibin-1]).c_str());
539        nbin = TriggerMatrix[iw][isec-1]->GetXaxis()->GetNbins();
540        max = 0;
541        TCanvas *Trigmatri = new TCanvas("TriggerMatrix", "",201,81,999,699);
542        Trigmatri->SetBottomMargin(0.12);
543      
544        for (int ibin=1; ibin<nbin+1; ibin++)
545          max = (max > TriggerMatrix[iw][isec-1]->GetBinContent(ibin) ) ? max : TriggerMatrix[iw][isec-1]->GetBinContent(ibin) ;
546        max1=max*1.3;
547      
548        TriggerMatrix[iw][isec-1]->GetXaxis()->SetLabelOffset(0.043);
549        // TriggerMatrix[iw][isec-1]->GetXaxis()->SetLabelOffset(-0.01);
550        // TriggerMatrix[iw][isec-1]->LabelsOption("v");
551        // TriggerMatrix[iw][isec-1]->GetXaxis()->SetLabelSize(0.04);
552      
553        TriggerMatrix[iw][isec-1]->SetMaximum(max1);
554        TriggerMatrix[iw][isec-1]->Draw();
555      
556        //sid = new TPaveText (-0.5,max1-(max1-max)/2,5,max1);
557        //sprintf (sid1,"YB%i, Sector %u, run %u",wheel, isec, run);
558        //sid->AddText(sid1);
559        //sid->Draw();
560      
561        TPaveText* labcont[50];
562        memset(labcont,0,50*sizeof(TPaveText*));
563        TText* cont[50];
564        memset(cont,0,50*sizeof(TText*));
565        
566        for (int ibin=1; ibin<nbin+1; ibin++) {
567          if (ibin == 2 || ibin == 7 ||  ibin == 14 ||  ibin == 19) continue;
568          float x1 = TriggerMatrix[iw][isec-1]->GetBinCenter(ibin) - TriggerMatrix[iw][isec-1]->GetBinWidth(ibin)/2;
569          float x2 = TriggerMatrix[iw][isec-1]->GetBinCenter(ibin) + TriggerMatrix[iw][isec-1]->GetBinWidth(ibin)/2;
570          float y1 = max + (max1-max)/8;
571          float y2 = max1 - (max1-max)/2;
572          labcont[ibin-1] = new TPaveText (x1,y1,x2,y2);
573          
574          char contbin[6];
575          sprintf (contbin,"%u",int(TriggerMatrix[iw][isec-1]->GetBinContent(ibin)));
576          //  labcont[ibin-1]->AddText(cont[ibin-1]);
577      
578          cont[ibin-1] = labcont[ibin-1]->AddText (contbin);
579          //    isme.SetTextAngle(90.);
580          cont[ibin-1]->SetTextSize(0.02);
581          labcont[ibin-1]->Draw();
582        }
583      
584        createGifFile("TriggerMatrix",(iw-2),isec,"",Trigmatri);
585        delete Trigmatri;
586        for (int i=0;i<50;++i) {
587          if (labcont[i]) delete labcont[i];
588        }
589        
590        //===================================================================================
591        //    Trigger: TriggerInclusive SECTOR BY SECTOR
592        //===================================================================================
593
594        TCanvas *TrigmatriSec = new TCanvas("TriggerInclusive[iw]", "",201,81,999,699);
595        TrigmatriSec->SetBottomMargin(0.12);
596        
597        int ibin_init=(isec-1)*5+1;
598        int xpos_init=(isec-1)*5+1;
599
600        max = 0;
601        for (int ibin=ibin_init; ibin<ibin_init+5; ibin++)
602          max = (max > TriggerInclusive[iw]->GetBinContent(ibin) ) ? max : TriggerInclusive[iw]->GetBinContent(ibin) ;
603        max1=max*1.3;
604
605        TriggerInclusive[iw]->GetXaxis()->SetRange(xpos_init,xpos_init+4);
606        TriggerInclusive[iw]->GetXaxis()->SetLabelSize(0.07);
607        TriggerInclusive[iw]->SetMaximum(max1);
608        TriggerInclusive[iw]->Draw();
609        
610        memset(labcont,0,50*sizeof(TPaveText*));
611        memset(cont,0,50*sizeof(TText*));  
612        for (int ibin=ibin_init; ibin<ibin_init+4; ibin++) {
613          
614          float x1 = TriggerInclusive[iw]->GetBinCenter(ibin) - TriggerInclusive[iw]->GetBinWidth(ibin)/2;
615          float x2 = TriggerInclusive[iw]->GetBinCenter(ibin) + TriggerInclusive[iw]->GetBinWidth(ibin)/2;
616          float y1 = max + (max1-max)/8;
617          float y2 = max1 - (max1-max)/2;
618          labcont[ibin-1] = new TPaveText (x1,y1,x2,y2);
619          
620          char contbin[6];
621          sprintf (contbin,"%u",int(TriggerInclusive[iw]->GetBinContent(ibin)));
622          //  labcont[ibin-1]->AddText(cont[ibin-1]);
623      
624          cont[ibin-1] = labcont[ibin-1]->AddText (contbin);
625          //    isme.SetTextAngle(90.);
626          cont[ibin-1]->SetTextSize(0.04);
627          labcont[ibin-1]->Draw();
628          
629        }
630
631        createGifFile("TriggerInclusive",(iw-2),isec,"",TrigmatriSec);
632        delete TrigmatriSec;
633        for (int i=0;i<50;++i) {
634          if (labcont[i]) delete labcont[i];
635        }
636        
637
638      }// if on isec < 13
639    }// end loop on sectors
640
641    //===================================================================================
642    //    Trigger: TriggerInclusive FULL WHEEL
643    //===================================================================================
644    TCanvas *Trigmatri = new TCanvas("TriggerMatrix", "",201,81,999,699);
645    Trigmatri->SetBottomMargin(0.12);
646
647    nbin = TriggerInclusive[iw]->GetXaxis()->GetNbins();
648    TriggerInclusive[iw]->GetXaxis()->SetRange(1,nbin);
649        
650    max = 0;
651
652    for (int ibin=1; ibin<nbin+1; ibin++)
653      max = (max > TriggerInclusive[iw]->GetBinContent(ibin) ) ? max : TriggerInclusive[iw]->GetBinContent(ibin) ;
654    max1=max*1.3;
655    TriggerInclusive[iw]->SetMaximum(max1);
656    TriggerInclusive[iw]->GetXaxis()->SetLabelSize(0.035);
657    TriggerInclusive[iw]->Draw();
658    
659    TPaveText* sid = new TPaveText (0,max1-(max1-max)/2,2,max1);
660  
661    stringstream chname; chname << "YB," << (iw-2) <<",";
662    sid->AddText(chname.str().c_str());
663    sid->Draw();
664    
665    createGifFile("TriggerInclusive",(iw-2),"",Trigmatri);
666    delete Trigmatri;
667    delete sid;
668        
669  }// end loop on wheels
670
456   }
457  
458   void DTDPGCreateAnalyzerSummary::createSummaryWheelPlots() {
# Line 676 | Line 461 | void DTDPGCreateAnalyzerSummary::createS
461    string SLname[3]={"Phi1","Theta","Phi2"};
462    
463    TH1F *historun   = getHisto<TH1F>("RunInfo_RunNumbers");
464 <  float TotEntries = historun->GetEntries();
464 >  float TotEntries = 999999999.; // It was happen sometime that this histo was not created.
465 >                                 // to protect from this problem
466 >  if(historun != NULL) TotEntries = historun->GetEntries();
467 >  else {
468 >   for(int i=1;i<10;i++)cout << "WARNING!!!! histo RunInfo_RunNumbers was NOT FOUND " << endl;
469 >  }
470    
471    gStyle->SetTitleX(0.01);
472    gStyle->SetTitleY(0.99);
473    
684  gStyle->SetOptStat(10);
685  gStyle->SetStatY(0.97);
686  gStyle->SetStatX(0.98);
687  gStyle->SetStatW(0.35);
688  gStyle->SetStatH(0.45);
689
474    gStyle->SetPalette(1);   // set palette for 2D histos
475    gStyle->SetTitleW(0.97);
476    gStyle->SetTitleH(0.1);
477  
478 +  gStyle->SetOptFit(1);
479 +  gStyle->SetOptStat(10);
480 +  gStyle->SetStatY(0.95); //92
481 +  gStyle->SetStatX(0.98);
482 +  gStyle->SetStatW(0.35); //45
483 +  gStyle->SetStatH(0.45); //85
484 +
485 +
486    TH1F * first_to_paint;
487  
696  //float BXSummary_mean=0.;
697  //float NBXSummary_mean=0.;
488    TH1F *BXSummary[5][4];
489    for(int iw=0;iw<5;iw++){ // Loop in wheels
490      for(int ic=1;ic<5;ic++){
# Line 710 | Line 500 | void DTDPGCreateAnalyzerSummary::createS
500  
501    
502  
503 < for(int iw=0;iw<5;iw++){ // Loop in wheels
503 > for(int iw=0;iw<5;iw++){ // Loop in wheels  
504  
505     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Processing Wheel " << iw-2 << endl;
506     //    Digi scatter plots
# Line 722 | Line 512 | void DTDPGCreateAnalyzerSummary::createS
512     DQM2->Divide(2,3) ;
513     TCanvas *DQM2b = new TCanvas("DQM2b", "",201,81,999,699);
514     DQM2b->Divide(2,3) ;
515 +
516 +   TCanvas *ExtraS13S14 = new TCanvas("ExtraS13S14", "",201,81,1150,950);  
517 +   ExtraS13S14->Divide(2,4);
518 +   int iExtraPad=1;
519    
520      TH2F *hDigiXYList[14];
521    
522 <    for(int isec=1;isec<13;isec++){
522 >    for(int isec=1;isec<15;isec++){
523        stringstream histoname; histoname << "hDigiXY_" << Whname[iw] << "_S" << isec;
524 +      for(int iih=1;iih<25;++iih)
525        hDigiXYList[isec-1]= getHisto<TH2F>(histoname.str());
526      }
527    
528 <    float Max=2000;
528 >    float Max=3000;
529      float Max0[12];
530 <    //float MaxMean=0;
530 >    float MaxMean=0;
531      float MaxMean0=0;
532      float MaxRMS0=0;
533 <    //float MaxRMS=0;
533 >    float MaxRMS=0;
534      int Ns=0;
535      for(int is=0;is<12; is++){
536 +     if(hDigiXYList[is] != NULL)
537 +     {
538        Max0[is]=0;
539        Max0[is]=hDigiXYList[is]->GetMaximum();
540        if(Max0[is]>Max)Max=Max0[is];
541        if(Max0[is]>0){ MaxMean0+=Max0[is]; MaxRMS0+=Max0[is]*Max0[is];Ns++;}
542 +     }
543      }
544  
545 +
546      for(int is=0;is<12; is++){
547        if(is<6){DQM1->cd(is+1); DQM1->cd(is+1)->SetLogz();}
548        else  {DQM2->cd(is-5); DQM2->cd(is-5)->SetLogz();}
549 +     if(hDigiXYList[is] != NULL)
550 +     {
551        hDigiXYList[is]->SetStats(0);
552        hDigiXYList[is]->SetMaximum(Max);
553        hDigiXYList[is]->Draw("colz");
554 +     }
555      }
556  
557      createGifFile("Digi",(iw-2),"_S1-S6",DQM1);
558      createGifFile("Digi",(iw-2),"_S7_S12",DQM2);
559 +  
560 +    // MB4 S13 & S14  
561 +    for(int is=13;is<15; is++){
562 +      ExtraS13S14->cd(iExtraPad);iExtraPad++;
563 +      if(hDigiXYList[is-1] != NULL)
564 +      {
565 +       hDigiXYList[is-1]->SetStats(0);
566 +       hDigiXYList[is-1]->SetMaximum(Max);
567 +       hDigiXYList[is-1]->Draw("colz");
568 +      }
569 +    }
570  
571      if(Max>TotEntries){ // To cut noise cells and see better the
572                          // occupancies on other cells
573        for(int is=0;is<12; is++){
574 <        if(is<6){DQM1b->cd(is+1); DQM1b->cd(is+1)->SetLogz();}
575 <        else  {DQM2b->cd(is-5); DQM2b->cd(is-5)->SetLogz();}
576 <        hDigiXYList[is]->SetStats(0);
577 <        hDigiXYList[is]->SetMaximum(TotEntries);
578 <        hDigiXYList[is]->Draw("colz");
574 >          if(is<6){DQM1b->cd(is+1); DQM1b->cd(is+1)->SetLogz();}
575 >          else  {DQM2b->cd(is-5); DQM2b->cd(is-5)->SetLogz();}
576 >        if(hDigiXYList[is] != NULL)
577 >        {
578 >             hDigiXYList[is]->SetStats(0);
579 >             hDigiXYList[is]->SetMaximum(TotEntries);
580 >             hDigiXYList[is]->Draw("colz");
581 >        }
582        }
583        
584        createGifFile("Digi",(iw-2),"_S1-S6_b",DQM1b);
# Line 771 | Line 587 | void DTDPGCreateAnalyzerSummary::createS
587  
588      //    Ocupancies per SL    
589      // Get histos to be plotted
590 <    //int nbin;
591 <    //float max, max1;
592 <    //TPaveText *sid;
777 <    //char sid1[50]; char answ;
778 <    //TPaveText *labcont[50]; TText *cont[50];
590 >    int nbin;
591 >    float max, max1;
592 >    char sid1[50];
593      
594       // Occupancies
595      TH2F *DigiXYS[5][14];
# Line 803 | Line 617 | void DTDPGCreateAnalyzerSummary::createS
617      }
618      
619      for(int isec=1;isec<15;isec++){
620 +     if(DigiXYS[iw][isec-1] != NULL)
621 +     {
622        int nbx= DigiXYS[iw][isec-1]->GetNbinsX() ;
623 <      //int nby= DigiXYS[iw][isec-1]->GetNbinsY() ;
623 >      int nby= DigiXYS[iw][isec-1]->GetNbinsY() ;
624      
625        for(int ich=1;ich<5;ich++){
626          for(int isl=1;isl<4;isl++){
# Line 829 | Line 645 | void DTDPGCreateAnalyzerSummary::createS
645            }
646          }
647        }
648 +     }
649      }// end loop sector
650  
651 <    //    DIGI's occupancies
652 <
653 <    TCanvas *Digi1 = new TCanvas("Digi1", "",201,81,999,699);  
654 <    TCanvas *Digi2 = new TCanvas("Digi2", "",201,81,999,699);  
838 <    TCanvas *Digi3 = new TCanvas("Digi3", "",201,81,999,699);  
839 <    Digi1->Divide(4,4); Digi2->Divide(4,4); Digi3->Divide(4,4);
651 >    TCanvas *Digi1 = new TCanvas("Digi1", "",201,81,1150,950);  
652 >    TCanvas *Digi2 = new TCanvas("Digi2", "",201,81,1150,950);  
653 >    TCanvas *Digi3 = new TCanvas("Digi3", "",201,81,1150,950);  
654 >    Digi1->Divide(4,12,0.00001,0.00001); Digi2->Divide(4,12,0.00001,0.00001); Digi3->Divide(4,12,0.00001,0.00001);
655      for(int isec=1;isec<13;isec++){ // Loop on sectors
656 <      for(int ich=1;ich<5;ich++){
656 >      gStyle->SetTitleW(0.25);
657 >      gStyle->SetTitleH(0.22);
658 >      gStyle->SetTitleX(0.72);
659 >      gStyle->SetTitleY(0.99);
660 >
661 >
662 >    for(int ich=1;ich<5;ich++){
663 >    for(int isl=1;isl<4;isl++){
664 >     if(!(ich==4 && isl==2)){ // avoid ThetaMB4
665          // look first for the maximum bin entries
666 <        first_to_paint=DigiXSecMBSl[iw][isec-1][ich-1][0];
667 <        float nbmax=DigiXSecMBSl[iw][isec-1][ich-1][0]->GetMaximum();
668 <        for(int isl=1;isl<4;isl++){
669 <          if(!(ich==4 && isl==2)){ // avoid ThetaMB4
847 <            float nbmax0=DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->GetMaximum();
666 >        first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
667 >        float nbmax=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
668 >        for(int il=1;il<5;il++){
669 >            float nbmax0=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
670              if(nbmax0>nbmax){
671 <              first_to_paint=DigiXSecMBSl[iw][isec-1][ich-1][isl-1];
671 >              first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
672                nbmax=nbmax0;
673              }
674 <            DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->SetLineColor(isl);
853 <          }
674 >            DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
675          }
676 <        stringstream htitle; htitle << "Occupancy W" << (iw-2) << " S" << isec << " MB" << ich;
676 >        stringstream htitle; htitle << "W" << (iw-2) << " S" << isec << " MB" << ich << " SL " << isl;
677          first_to_paint->SetTitle(htitle.str().c_str());
678 <        if(isec<5)           {int icpos=(isec-1)*4+ich; Digi1->cd(icpos) ; Digi1->cd(icpos)->SetLogy();}
679 <        if(isec>4 && isec<9) {int icpos=(isec-5)*4+ich; Digi2->cd(icpos) ; Digi2->cd(icpos)->SetLogy();}
680 <        if(isec>8 && isec<13){int icpos=(isec-9)*4+ich; Digi3->cd(icpos) ; Digi3->cd(icpos)->SetLogy();}
681 <        first_to_paint->GetYaxis()->SetLabelSize(0.07);
682 <        first_to_paint->GetXaxis()->SetLabelSize(0.07);
678 >        if(isec<5)           {int icpos=(ich-1)*3*4+(isl-1)*4+isec;     Digi1->cd(icpos) ; Digi1->cd(icpos)->SetBottomMargin(0.15) ; Digi1->cd(icpos)->SetLeftMargin(0.15) ; Digi1->cd(icpos)->SetLogy();}
679 >        if(isec>4 && isec<9) {int icpos=(ich-1)*3*4+(isl-1)*4+(isec-4); Digi2->cd(icpos) ; Digi2->cd(icpos)->SetBottomMargin(0.15) ; Digi2->cd(icpos)->SetLeftMargin(0.15) ; Digi2->cd(icpos)->SetLogy();}
680 >        if(isec>8 && isec<13){int icpos=(ich-1)*3*4+(isl-1)*4+(isec-8); Digi3->cd(icpos) ; Digi3->cd(icpos)->SetBottomMargin(0.15) ; Digi3->cd(icpos)->SetLeftMargin(0.15) ; Digi3->cd(icpos)->SetLogy();}
681 >        first_to_paint->GetYaxis()->SetLabelSize(0.14);
682 >        first_to_paint->GetXaxis()->SetLabelSize(0.14);
683 >        first_to_paint->SetStats(0);
684          first_to_paint->Draw();
685 <        for(int isl=1;isl<4;isl++){
686 <          if(!(ich==4 && isl==2)) // avoid ThetaMB4
687 <            DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->Draw("same");
688 <        }
689 <      }
685 >        for(int il=1;il<5;il++)
686 >            DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
687 >     }
688 >      
689 >     if(ich==4 & isl !=2)
690 >     {
691 >       if(isec ==4 || isec ==10)
692 >       {
693 >        int isec_extra=13;
694 >        if (isec ==10)isec_extra=14;
695 >        ExtraS13S14->cd(iExtraPad); iExtraPad++;
696 >          DigiXSecMBSlLayer[iw][isec_extra-1][ich-1][isl-1][0]->Draw();
697 >          for(int il=2;il<5;il++)
698 >        {
699 >          DigiXSecMBSlLayer[iw][isec_extra-1][ich-1][isl-1][il-1]->SetLineColor(il);
700 >          DigiXSecMBSlLayer[iw][isec_extra-1][ich-1][isl-1][il-1]->Draw("same");
701 >        }
702 >       }
703 >     }
704 >
705 >    }// End Loop in  SLs
706 >    }// End Loop in Chambers
707      }// End Loop on sectors
708      createGifFile("Occupancies_LogScale",(iw-2),"_S1-S4",Digi1);
709      createGifFile("Occupancies_LogScale",(iw-2),"_S5-S8",Digi2);
710      createGifFile("Occupancies_LogScale",(iw-2),"_S9-S12",Digi3);
711  
712 +  gStyle->SetTitleX(0.01);
713 +  gStyle->SetTitleY(0.99);
714 +  gStyle->SetTitleW(0.97);
715 +  gStyle->SetTitleH(0.1);
716 +
717      //    TimeBoxes        
718 <    DQM1->Clear();
719 <    DQM1->Divide(6,2) ;
720 <    for (int ins=1; ins<13;ins++){
721 <      TH1F *hHisto[4];
718 >
719 >    TCanvas *TB1 = new TCanvas("TB1", "",201,81,999,999);
720 >    TCanvas *TB2 = new TCanvas("TB2", "",201,81,999,999);
721 >    TB1->Divide(4,6,0.00001,0.00001) ;
722 >    TB2->Divide(4,6,0.00001,0.00001) ;
723 >    for (int ins=1; ins<13;ins++)
724 >    for(int ic=1;ic<5;ic++){
725 >      TH1F *hHisto[3];
726        int nbmax=0;
727        int nbmax0=0;
728  
729 <      DQM1->cd(ins);
730 <      for(int ic=1;ic<5;ic++){
731 <        stringstream hname; hname << "htime_" << Whname[iw] << "_S" << ins << "_MB" << ic;
732 <        hHisto[ic-1]=getHisto<TH1F>(hname.str());
733 <        hHisto[ic-1]->SetLineColor(ic);
729 >
730 >      for(int isl=1;isl<4;isl++){
731 >        stringstream hname; hname << "htime_" << Whname[iw] << "_S" << ins << "_MB" << ic << "_SL" << isl;
732 >        hHisto[isl-1]=getHisto<TH1F>(hname.str());
733 >        if(hHisto[isl-1] !=NULL) hHisto[isl-1]->SetLineColor(isl);
734        }
735  
736        first_to_paint = hHisto[0];
737 <      nbmax=hHisto[0]->GetMaximum();
737 >      if(first_to_paint !=NULL)nbmax=hHisto[0]->GetMaximum();
738  
739 <      for(int ic=2;ic<5;ic++){
740 <        nbmax0=hHisto[ic-1]->GetMaximum();
739 >      for(int isl=2;isl<4;isl++){
740 >       if(hHisto[isl-1] !=NULL)
741 >       {
742 >        nbmax0=hHisto[isl-1]->GetMaximum();
743          if(nbmax0>nbmax){
744            nbmax=nbmax0;
745 <          first_to_paint=hHisto[ic-1];
745 >          first_to_paint=hHisto[isl-1];
746          }
747 +       }
748        }
749  
750 <      first_to_paint->GetXaxis()->SetLabelSize(0.08);
751 <      first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
752 <      first_to_paint->GetXaxis()->SetTitle("cm");
753 <      first_to_paint->GetXaxis()->SetTitleSize(0.09);
754 <      first_to_paint->GetXaxis()->SetTitleOffset(0.5);
755 <      first_to_paint->GetXaxis()->SetNdivisions(308);
756 <      //char htit[240];
757 <      stringstream htitle; htitle << "TimeBox W" << iw-2 << " S" << ins;
758 <      first_to_paint->SetTitle(htitle.str().c_str());
759 <      first_to_paint->Draw();
760 <      for(int ic=1;ic<5;ic++)hHisto[ic-1]->Draw("same");
761 <      
762 <    }// end loop on sectors
763 <    stringstream fileTBox; fileTBox <<"TBox_r" << myRunNumber <<"_W" << (iw-2);
764 <    createGifFile("TBox",(iw-2),"",DQM1);
750 >      if(ins<7)
751 >      {
752 >         int icpos=(ins-1)*4+ic;
753 >         TB1->cd(icpos);
754 >         TB1->cd(icpos)->SetLeftMargin(0.20);
755 >      }
756 >      else  
757 >      {
758 >         int icpos=(ins-7)*4+ic;
759 >         TB2->cd(icpos);
760 >         TB2->cd(icpos)->SetLeftMargin(0.20);
761 >      }
762 >
763 >      if(first_to_paint != NULL)
764 >      {
765 >        first_to_paint->GetYaxis()->SetLabelSize(0.08);
766 >        first_to_paint->GetXaxis()->SetLabelSize(0.08);
767 >        first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
768 >        first_to_paint->GetXaxis()->SetTitle("ns");
769 >        first_to_paint->GetXaxis()->SetTitleSize(0.09);
770 >        first_to_paint->GetXaxis()->SetTitleOffset(0.5);
771 >        first_to_paint->GetXaxis()->SetNdivisions(308);
772 >        char htit[240];
773 >        stringstream htitle; htitle << "TimeBox W" << iw-2 << " S" << ins << " MB"<< ic;
774 >        first_to_paint->SetTitle(htitle.str().c_str());
775 >        first_to_paint->Draw();
776 >        for(int isl=1;isl<4;isl++) hHisto[isl-1]->Draw("same");
777 >      }
778 >
779 >      if(ic==4)
780 >      {
781 >       if(ins==4 || ins==10)
782 >       {
783 >        int isec_extra=13;
784 >        if (ins ==10)isec_extra=14;
785 >        TH1F *hHisto_extra[3];
786 >        for(int isl=1;isl<4;isl++){
787 >          stringstream hname; hname << "htime_" << Whname[iw] << "_S" << isec_extra << "_MB" << ic << "_SL" << isl;
788 >          hHisto_extra[isl-1]=getHisto<TH1F>(hname.str());
789 >          if(hHisto_extra[isl-1] != NULL) hHisto_extra[isl-1]->SetLineColor(isl);
790 >        }
791 >        ExtraS13S14->cd(iExtraPad); iExtraPad++;
792 >        int nbmax=0;
793 >        first_to_paint=hHisto_extra[0];
794 >        if(first_to_paint !=NULL)nbmax=hHisto[0]->GetMaximum();
795 >        for(int isl=2;isl<4;isl++){
796 >         if(hHisto[isl-1] !=NULL)
797 >         {
798 >          int nbmax0=hHisto[isl-1]->GetMaximum();
799 >          if(nbmax0>nbmax)
800 >           { nbmax=nbmax0; first_to_paint=hHisto[isl-1];}
801 >         }
802 >        }
803 >
804 >        if(first_to_paint!=NULL)
805 >        {
806 >          stringstream nhtitle; nhtitle << "TimeBox W" << iw-2 << " S" << isec_extra << " MB"<< ic;
807 >          first_to_paint->SetTitle(nhtitle.str().c_str());
808 >          first_to_paint->Draw();
809 >          for(int isl=1;isl<4;isl++) hHisto_extra[isl-1]->Draw("same");
810 >        }
811 >       }
812 >      }
813 >        
814 >    }// end loop on sectors & Chambers
815 >    createGifFile("TBox_S1_S6",(iw-2),"",TB1);
816 >    createGifFile("TBox_S7_S12",(iw-2),"",TB2);
817 >
818 >    createGifFile("MB4S13S14Plots",(iw-2),"",ExtraS13S14);
819 >
820  
821      //    Hit Residuals        
822      DQM1->Clear();
# Line 919 | Line 825 | void DTDPGCreateAnalyzerSummary::createS
825      for(int ins=1;ins<13; ins++){
826        TH1F *hHisto[4];
827        DQM1->cd(ins);
828 +      DQM1->cd(ins)->SetLeftMargin(0.20);
829  
830        int nbmax=0;
831        int nbmax0=0;
# Line 940 | Line 847 | void DTDPGCreateAnalyzerSummary::createS
847          }
848        }
849        
850 +      first_to_paint->GetYaxis()->SetLabelSize(0.08);
851        first_to_paint->GetXaxis()->SetLabelSize(0.08);
852        first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
853        first_to_paint->GetXaxis()->SetTitle("cm");
# Line 952 | Line 860 | void DTDPGCreateAnalyzerSummary::createS
860        first_to_paint->Draw();
861        for(int ic=1;ic<5;ic++)
862          hHisto[ic-1]->Draw("same");
863 +
864      }// end loop on sectors
865  
866      createGifFile("HitResiduals",(iw-2),"",DQM1);
# Line 963 | Line 872 | void DTDPGCreateAnalyzerSummary::createS
872      for (int ins=1; ins<13;ins++){
873        TH1F *hPhi[4];
874        DQM1->cd(ins);
875 +      DQM1->cd(ins)->SetLeftMargin(0.20);
876        int nbmax=0;
877        int nbmax0=0;
878        
# Line 983 | Line 893 | void DTDPGCreateAnalyzerSummary::createS
893          }
894        }
895  
896 +      first_to_paint->GetYaxis()->SetLabelSize(0.08);
897        first_to_paint->GetXaxis()->SetLabelSize(0.08);
898        first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
899        first_to_paint->GetXaxis()->SetTitle("deg");
# Line 1004 | Line 915 | void DTDPGCreateAnalyzerSummary::createS
915      DQM1->Clear();
916      
917      stringstream hnameSTADigi; hnameSTADigi << "hHitsPosXYSA_" << Whname[iw];
1007    TH1F *hXYHisto=getHisto<TH1F>(hnameSTADigi.str());;
1008    
1009    hXYHisto->SetStats(0);
1010    hXYHisto->Draw("colz");
918  
919 <    
920 <    createGifFile("STADigi",(iw-2),"",DQM1);
919 >    // STA Plots created only on demand they could not exist
920 >    TH1F *hXYHisto=force_getHisto<TH1F>(hnameSTADigi.str());;
921 >    if(hXYHisto)
922 >    {
923 >      hXYHisto->SetStats(0);
924 >      hXYHisto->Draw("colz");
925 >
926 >      createGifFile("STADigi",(iw-2),"",DQM1);
927 >    }
928 >    else
929 >       edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: STA histo "
930 >            << hnameSTADigi.str() << " not present, skiping STADigi gif file" << endl;
931  
932  
933      //    STA Phi Hits    
934      TCanvas *DQM6 = new TCanvas("DQM6", "",301,81,999,699); // open a large canvas
935      TH1F *hnHitDT= getHisto<TH1F>("hnHitDT");
936 <    Float_t Nevents = hnHitDT->GetEntries();
937 <    edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Total nr. of triggers:" << Nevents << endl;
938 <
939 <    TH1F *hPhiHisto[4];
940 <    TH1F *heff[4];
941 <
942 <    float ymax = 0.1;
943 <    for(int ic=1;ic<5;ic++){
944 <      stringstream hname1, hname2, htitle;
936 >    int hh=0;
937 >    if(hnHitDT != NULL)
938 >    {
939 >       Float_t Nevents = hnHitDT->GetEntries();
940 >       edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Total nr. of triggers:" << Nevents << endl;
941 >      
942 >       TH1F *hPhiHisto[4];
943 >       TH1F *heff[4];
944 >      
945 >       bool doSTAPhiHits=false;
946 >       //float ymax = 0.1;
947 >       float ymax = 0.0;
948 >       for(int ic=1;ic<5;ic++){
949 >         stringstream hname1, hname2, htitle;
950 >      
951 >         hname1 << "hPhiHit_" << Whname[iw] << "_MB" << ic;
952 >         // STA Plots created only on demand they could not exist
953 >         hPhiHisto[ic-1]=force_getHisto<TH1F>(hname1.str());
954 >        
955 >         if(hPhiHisto[ic-1])
956 >         {
957 >           doSTAPhiHits=true;
958 >           hname2 << "heff" << ic;
959 >           heff[ic-1] =(TH1F*) hPhiHisto[ic-1]->Clone(hname2.str().c_str());
960 >           heff[ic-1]->Add(heff[ic-1],heff[ic-1],0.5/Nevents,0.5/Nevents);
961 >          
962 >           float nbmax=heff[ic-1]->GetMaximum();
963 >           if(nbmax>ymax)ymax=nbmax;
964 >           heff[ic-1]->SetStats(0);
965 >           heff[ic-1]->SetLineColor(ic);
966 >           htitle << "Phi of ass. hit, W" << (iw-2);
967 >           heff[0]->SetTitle(htitle.str().c_str());
968 >         }
969 >        
970 >       }
971 >       ymax=ymax*1.1;
972 >       for(int ic=1;ic<5;ic++){
973 >         if(hPhiHisto[ic-1])
974 >         {
975 >           heff[ic-1]->SetMaximum(ymax);
976 >           if(ic==1)heff[ic-1]->Draw();
977 >           else   heff[ic-1]->Draw("same");
978 >         }
979 >       }
980  
981 <      hname1 << "hPhiHit_" << Whname[iw] << "_MB" << ic;
982 <      hPhiHisto[ic-1]=getHisto<TH1F>(hname1.str());
983 <      
984 <      hname2 << "heff" << ic;
985 <      heff[ic-1] =(TH1F*) hPhiHisto[ic-1]->Clone(hname2.str().c_str());
986 <      heff[ic-1]->Add(heff[ic-1],heff[ic-1],0.5/Nevents,0.5/Nevents);
987 <      
988 <      heff[ic-1]->SetMaximum(ymax);
989 <      heff[ic-1]->SetStats(0);
990 <      heff[ic-1]->SetLineColor(ic);
991 <      htitle << "Phi of ass. hit, W" << (iw-2);
992 <      heff[0]->SetTitle(htitle.str().c_str());
993 <      if(ic==1)heff[ic-1]->Draw();
994 <      else   heff[ic-1]->Draw("same");
995 <      
981 >       TLine *l[16];
982 >       l[0] = new TLine(-165, 0, -165, ymax); l[0]->Draw();
983 >       l[1] = new TLine(-135, 0, -135, ymax); l[1]->Draw();
984 >       l[2] = new TLine(-105, 0, -105, ymax); l[2]->Draw();
985 >       l[3] = new TLine( -75, 0,  -75, ymax); l[3]->Draw();
986 >       l[4] = new TLine( -45, 0,  -45, ymax); l[4]->Draw();
987 >       l[5] = new TLine( -15, 0,  -15, ymax); l[5]->Draw();
988 >       l[6] = new TLine(  15, 0,   15, ymax); l[6]->Draw();
989 >       l[7] = new TLine(  45, 0,   45, ymax); l[7]->Draw();
990 >       l[8] = new TLine(  75, 0,   75, ymax); l[8]->Draw();
991 >       l[9] = new TLine( 105, 0,  105, ymax); l[9]->Draw();
992 >       l[10] = new TLine( 135, 0,  135, ymax); l[10]->Draw();
993 >       l[11] = new TLine( 165, 0,  165, ymax); l[11]->Draw();
994 >      
995 >       l[12] = new TLine( -40, 0.8*ymax,  -20, 0.8*ymax); //l->Draw();
996 >       l[12]->SetLineColor(1);
997 >       l[12]->Draw();
998 >       TPaveLabel * box [4];
999 >       box[0] = new TPaveLabel(-10,0.8*ymax,5,0.85*ymax,"MB1");
1000 >       box[0]->Draw();
1001 >      
1002 >       l[13] = new TLine( -40, 0.7*ymax,  -20, 0.7*ymax); //l->Draw();
1003 >       l[13]->SetLineColor(2);
1004 >       l[13]->Draw();
1005 >       box[1] = new TPaveLabel(-10,0.7*ymax,5,0.75*ymax,"MB2");
1006 >       box[1]->Draw();
1007 >      
1008 >       l[14] = new TLine( -40, 0.6*ymax,  -20, 0.6*ymax); //l->Draw();
1009 >       l[14]->SetLineColor(3);
1010 >       l[14]->Draw();
1011 >       box[2] = new TPaveLabel(-10,0.6*ymax,5,0.65*ymax,"MB3");
1012 >       box[2]->Draw();
1013 >      
1014 >       l[15] = new TLine( -40, 0.5*ymax,  -20, 0.5*ymax); //l->Draw();
1015 >       l[15]->SetLineColor(4);
1016 >       l[15]->Draw();
1017 >       box[3] = new TPaveLabel(-10,0.5*ymax,5,0.55*ymax,"MB4");
1018 >       box[3]->Draw();
1019 >      
1020 >       if(doSTAPhiHits) createGifFile("STAPhiHits",(iw-2),"",DQM6);
1021 >      
1022 >       for (int i=0;i<16;++i) delete l[i];
1023 >       for (int i=0;i<4;++i) delete box[i];
1024      }
1025  
1046    TLine *l[16];
1047    l[0] = new TLine(-165, 0, -165, ymax); l[0]->Draw();
1048    l[1] = new TLine(-135, 0, -135, ymax); l[1]->Draw();
1049    l[2] = new TLine(-105, 0, -105, ymax); l[2]->Draw();
1050    l[3] = new TLine( -75, 0,  -75, ymax); l[3]->Draw();
1051    l[4] = new TLine( -45, 0,  -45, ymax); l[4]->Draw();
1052    l[5] = new TLine( -15, 0,  -15, ymax); l[5]->Draw();
1053    l[6] = new TLine(  15, 0,   15, ymax); l[6]->Draw();
1054    l[7] = new TLine(  45, 0,   45, ymax); l[7]->Draw();
1055    l[8] = new TLine(  75, 0,   75, ymax); l[8]->Draw();
1056    l[9] = new TLine( 105, 0,  105, ymax); l[9]->Draw();
1057    l[10] = new TLine( 135, 0,  135, ymax); l[10]->Draw();
1058    l[11] = new TLine( 165, 0,  165, ymax); l[11]->Draw();
1059
1060    l[12] = new TLine( -40, 0.8*ymax,  -20, 0.8*ymax); //l->Draw();
1061    l[12]->SetLineColor(1);
1062    l[12]->Draw();
1063    TPaveLabel * box [4];
1064    box[0] = new TPaveLabel(-10,0.8*ymax,5,0.85*ymax,"MB1");
1065    box[0]->Draw();
1066
1067    l[13] = new TLine( -40, 0.7*ymax,  -20, 0.7*ymax); //l->Draw();
1068    l[13]->SetLineColor(2);
1069    l[13]->Draw();
1070    box[1] = new TPaveLabel(-10,0.7*ymax,5,0.75*ymax,"MB2");
1071    box[1]->Draw();
1072
1073    l[14] = new TLine( -40, 0.6*ymax,  -20, 0.6*ymax); //l->Draw();
1074    l[14]->SetLineColor(3);
1075    l[14]->Draw();
1076    box[2] = new TPaveLabel(-10,0.6*ymax,5,0.65*ymax,"MB3");
1077    box[2]->Draw();
1078    
1079    l[15] = new TLine( -40, 0.5*ymax,  -20, 0.5*ymax); //l->Draw();
1080    l[15]->SetLineColor(4);
1081    l[15]->Draw();
1082    box[3] = new TPaveLabel(-10,0.5*ymax,5,0.55*ymax,"MB4");
1083    box[3]->Draw();
1084    
1085    createGifFile("STAPhiHits",(iw-2),"",DQM6);
1086
1087    for (int i=0;i<16;++i) delete l[i];
1088    for (int i=0;i<4;++i) delete box[i];
1089
1026      //    STA Hits    
1027      DQM1->Clear();
1028      DQM1->Divide(6,2) ;
# Line 1095 | Line 1031 | void DTDPGCreateAnalyzerSummary::createS
1031  
1032      for(int isec=1;isec<13;isec++){
1033        stringstream histoname; histoname << "hNhass_" << Whname[iw] << "_S" << isec;
1034 <      hNassList[isec-1]=getHisto<TH1F>(histoname.str());
1034 >      hNassList[isec-1]=force_getHisto<TH1F>(histoname.str());
1035      }
1036  
1037  
1038 +    bool doSTAHits=false;
1039      for(int is=0;is<12;is++){
1040 +     if(hNassList[is])
1041 +     {
1042 +      doSTAHits=true;
1043 +      hNassList[is]->GetYaxis()->SetLabelSize(0.08);
1044        hNassList[is]->GetXaxis()->SetNdivisions(308);
1045        hNassList[is]->GetXaxis()->SetLabelSize(0.08);
1046        hNassList[is]->GetXaxis()->SetLabelOffset(-0.025);
# Line 1108 | Line 1049 | void DTDPGCreateAnalyzerSummary::createS
1049        hNassList[is]->GetXaxis()->SetTitleOffset(0.5);
1050        
1051        DQM1->cd(is+1);
1052 +      DQM1->cd(is+1)->SetLeftMargin(0.20);
1053        hNassList[is]->SetStats(1);
1054        hNassList[is]->Draw();
1055 +     }
1056      }
1057  
1058 <    createGifFile("STAHits",(iw-2),"",DQM1);
1058 >    if(doSTAHits) createGifFile("STAHits",(iw-2),"",DQM1);
1059  
1060  
1061      //    Segment Hits    
# Line 1122 | Line 1065 | void DTDPGCreateAnalyzerSummary::createS
1065      TH1F *hNhits[12][4];
1066      for (int ins=1; ins<13;ins++){
1067        DQM2->cd(ins);
1068 +      DQM2->cd(ins)->SetLeftMargin(0.20);
1069        int nbmax=0;
1070        int nbmax0=0;
1071        
# Line 1142 | Line 1086 | void DTDPGCreateAnalyzerSummary::createS
1086          }
1087        }
1088  
1089 +      first_to_paint->GetYaxis()->SetLabelSize(0.08);
1090        first_to_paint->GetXaxis()->SetLabelSize(0.08);
1091        first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1092        first_to_paint->GetXaxis()->SetTitle("#hits");
# Line 1153 | Line 1098 | void DTDPGCreateAnalyzerSummary::createS
1098  
1099        first_to_paint->Draw();
1100        for(int ic=1;ic<5;ic++) hNhits[ins-1][ic-1]->Draw( "same");
1101 <      
1101 >
1102      }// end loop on sectors
1103  
1104  
1105      createGifFile("SegHits",(iw-2),"",DQM2);
1106  
1107 +
1108      //    Segment Hits    
1109      DQM1->Clear();
1110      DQM1->Divide(6,2);
# Line 1171 | Line 1117 | void DTDPGCreateAnalyzerSummary::createS
1117      
1118      for(int is=0;is<12;is++){
1119        DQM1->cd(is+1);
1120 +      DQM1->cd(is+1)->SetLeftMargin(0.20);
1121 +      hNsegsList[is]->GetYaxis()->SetLabelSize(0.08);
1122        hNsegsList[is]->GetXaxis()->SetNdivisions(308);
1123        hNsegsList[is]->GetXaxis()->SetLabelSize(0.08);
1124        hNsegsList[is]->GetXaxis()->SetLabelOffset(-0.025);
1125        hNsegsList[is]->GetXaxis()->SetTitleSize(0.09);
1126        hNsegsList[is]->GetXaxis()->SetTitleOffset(0.5);
1127        hNsegsList[is]->SetStats(1);
1128 +      hNsegsList[is]->GetXaxis()->SetRangeUser(1.,10.);
1129        hNsegsList[is]->Draw();
1130      }
1131      
# Line 1184 | Line 1133 | void DTDPGCreateAnalyzerSummary::createS
1133  
1134      //    TMAX
1135      
1136 +
1137 +    gStyle->SetOptStat(10);
1138 +    gStyle->SetStatY(0.95);
1139 +    gStyle->SetStatX(0.98);
1140 +    gStyle->SetStatW(0.35);
1141 +    gStyle->SetStatH(0.45);
1142 +
1143      TCanvas *DQM11 = new TCanvas("DQM11", "1",101,81,999,699);
1144      TCanvas *DQM12 = new TCanvas("DQM12", "2",101,81,999,699);
1145      TCanvas *DQM13 = new TCanvas("DQM13", "3",101,81,999,699);
# Line 1193 | Line 1149 | void DTDPGCreateAnalyzerSummary::createS
1149      DQM13->Divide(4,3) ;
1150      DQM14->Divide(4,3) ;
1151  
1152 +
1153      for (int ins=1; ins<13;ins++){
1154        TH1F *hHisto[2];
1155        for(int ic=1;ic<5;ic++){
1156  
1157 +
1158          stringstream hname; hname << "htmax_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1159          hHisto[0]= getHisto<TH1F>(hname.str()+"_SL1");
1160          hHisto[1]= getHisto<TH1F>(hname.str()+"_SL3");
# Line 1219 | Line 1177 | void DTDPGCreateAnalyzerSummary::createS
1177          }
1178  
1179          hHisto[0]->SetStats(1);
1180 +        gStyle->SetOptFit(1);
1181          hHisto[0]->Draw();
1182 +        if(hHisto[0]->GetEntries()>50) // Problems on version 31X when no entries or few entries
1183          try {
1184            hHisto[0]->Fit("gaus","Q");
1185 +          hHisto[0]->Draw("same");
1186          } catch(const cms::Exception&) {
1187            edm::LogError("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]:  Error fitting " << hname.str() << "_SL1";
1188          }
# Line 1230 | Line 1191 | void DTDPGCreateAnalyzerSummary::createS
1191        }// end loop on chambers
1192      }// end loop on sectors
1193  
1194 <    createGifFile("TMax",(iw-2),"S1-S3",DQM11);
1195 <    createGifFile("TMax",(iw-2),"S4-S6",DQM12);
1196 <    createGifFile("TMax",(iw-2),"S7-S9",DQM13);
1197 <    createGifFile("TMax",(iw-2),"S10-S12",DQM14);
1198 <
1194 >    createGifFile("TMax",(iw-2),"S1-S3",DQM11,true);
1195 >    createGifFile("TMax",(iw-2),"S4-S6",DQM12,true);
1196 >    createGifFile("TMax",(iw-2),"S7-S9",DQM13,true);
1197 >    createGifFile("TMax",(iw-2),"S10-S12",DQM14,true);
1198 >
1199 >     gStyle->SetOptStat(10);
1200 >     gStyle->SetStatY(0.95); //92
1201 >     gStyle->SetStatX(0.98);
1202 >     gStyle->SetStatW(0.35); //45
1203 >     gStyle->SetStatH(0.45); //85
1204  
1205      //    Phi-Trig Efficiency
1206      TCanvas *Eff = new TCanvas("Eff", "",201,81,999,699);
# Line 1247 | Line 1213 | void DTDPGCreateAnalyzerSummary::createS
1213        hHisto[ic-1]= getHisto<TH1F>(hname1.str());
1214  
1215        stringstream hname2; hname2 << "heff" << ic <<"x";
1250      //heffx[ic-1]=hHisto[ic-1]->Clone(hname);
1216        heffx[ic-1] =(TH1F*) hHisto[ic-1]->Clone(hname2.str().c_str());
1217        heffx[ic-1]->SetLineColor(ic);
1218        
# Line 1274 | Line 1239 | void DTDPGCreateAnalyzerSummary::createS
1239        else heffx[ic-1]->Draw("same");
1240      }
1241  
1242 <    ymax = 1.;
1242 >    float ymax = 1.;
1243 >    TLine *l[16];
1244      l[0] = new TLine(-165, 0, -165, ymax); l[0]->Draw();
1245      l[1] = new TLine(-135, 0, -135, ymax); l[1]->Draw();
1246      l[2] = new TLine(-105, 0, -105, ymax); l[2]->Draw();
# Line 1288 | Line 1254 | void DTDPGCreateAnalyzerSummary::createS
1254      l[10] = new TLine( 135, 0,  135, ymax); l[10]->Draw();
1255      l[11] = new TLine( 165, 0,  165, ymax); l[11]->Draw();
1256      
1257 <    createGifFile("TrigEff",(iw-2),"",Eff);
1257 >    createGifFile("TrigEff",(iw-2),"",Eff,true);
1258  
1259 <    for (int i=0;i<12;++i) delete l[i];
1294 <    
1295 <    //    Segment Hits    
1296 <    DQM1->Clear();
1297 <    DQM1->Divide(6,2) ;
1298 <    
1299 <    for (int ins=1; ins<13;ins++){
1300 <     TH1F *hHisto[4];
1301 <     DQM1->cd(ins);
1302 <
1303 <     int nbmax=0;
1304 <     int nbmax0=0;
1305 <
1306 <
1307 <     for(int ic=1;ic<5;ic++){
1308 <       stringstream hname; hname << "hTrigBits_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1309 <       hHisto[ic-1]= getHisto<TH1F>(hname.str());
1310 <       hHisto[ic-1]->SetLineColor(ic);
1311 <     }
1312 <
1313 <     first_to_paint = hHisto[0];
1314 <     nbmax=hHisto[0]->GetMaximum();
1315 <
1316 <     for(int ic=2;ic<5;ic++){
1317 <       nbmax0=hHisto[ic-1]->GetMaximum();
1318 <       if(nbmax0>nbmax){
1319 <         nbmax=nbmax0;
1320 <         first_to_paint=hHisto[ic-1];
1321 <       }
1322 <     }
1323 <     first_to_paint->GetXaxis()->SetLabelSize(0.08);
1324 <     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1325 <     first_to_paint->GetXaxis()->SetTitle("Quality");
1326 <     first_to_paint->GetXaxis()->SetTitleSize(0.09);
1327 <     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1328 <     first_to_paint->GetXaxis()->SetNdivisions(308);
1329 <     stringstream htitle; htitle << "Highest trig qual W" << (iw-2) << " S" << ins;
1330 <     first_to_paint->SetTitle(htitle.str().c_str());
1331 <    
1332 <     first_to_paint->Draw();
1333 <     for(int ic=1;ic<5;ic++)
1334 <       hHisto[ic-1]->Draw("same");
1335 <    
1336 <    }// end loop on sectors
1337 <
1338 <    createGifFile("TrigHighQual",(iw-2),"",DQM1);
1339 <
1340 <
1341 <    //   SC BX Summary
1342 <    TCanvas *BX = new TCanvas("BX", "",201,81,999,699);
1343 <    BX->Divide(6,2);
1344 <    for(int ins=1;ins<13;ins++){ // Loop in sectors
1345 <    
1346 <     int nbmax=0;
1347 <     int nbmax0=0;
1348 <
1349 <     TH1F *hHH[4];
1350 <     TH1F *hHL[4];
1351 <     BX->cd(ins);
1352 <     BX->cd(ins)->SetLogy();
1353 <     for(int ic=1;ic<5;ic++){ // Loop in chambers
1354 <    
1355 <       stringstream hname; hname << "hTrigBX_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1356 <       hHH[ic-1]= getHisto<TH1F>(hname.str()+"_qual6");
1357 <       hHL[ic-1]= getHisto<TH1F>(hname.str()+"_qual5");
1358 <
1359 <       hHH[ic-1]->Add(hHL[ic-1]);
1360 <       hHH[ic-1]->SetLineColor(ic);
1361 <       hHH[ic-1]->SetStats(0);
1362 <     } // end loop in chambers
1363 <    
1364 <     first_to_paint = hHH[0];
1365 <     nbmax=hHH[0]->GetMaximum();
1366 <     first_to_paint->Draw();
1367 <
1368 <     for(int ic=2;ic<5;ic++){
1369 <       nbmax0=hHH[ic-1]->GetMaximum();
1370 <       if(nbmax0>nbmax){
1371 <         nbmax=nbmax0;
1372 <         first_to_paint=hHH[ic-1];
1373 <       }
1374 <     }
1375 <
1376 <     first_to_paint->GetXaxis()->SetLabelSize(0.08);
1377 <     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1378 <     first_to_paint->GetXaxis()->SetTitle("Slot");
1379 <     first_to_paint->GetXaxis()->SetTitleSize(0.09);
1380 <     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1381 <     first_to_paint->GetXaxis()->SetNdivisions(308);
1382 <     stringstream htitle; htitle << "BX for HH,HL W" << (iw-2) << " S" << ins;
1383 <     first_to_paint->SetTitle(htitle.str().c_str());
1384 <
1385 <     first_to_paint->Draw();
1386 <     for(int ic=1;ic<5;ic++)
1387 <       hHH[ic-1]->Draw("same");
1388 <    
1389 <    }// end Loop in sectors
1390 <    
1391 <    createGifFile("TrigBXhhhl",(iw-2),"",BX);
1259 > //     for (int i=0;i<12;++i) delete l[i];
1260  
1261 +    delete TB1;
1262 +    delete TB2;
1263      delete DQM1;
1264      delete DQM2;
1265      delete DQM1b;
# Line 1403 | Line 1273 | void DTDPGCreateAnalyzerSummary::createS
1273      delete DQM12;
1274      delete DQM13;
1275      delete DQM14;
1276 +
1277      delete Eff;
1278 <    delete BX;
1278 >    delete ExtraS13S14;
1279  
1280   }// END loop in wheels
1281 +
1282      
1283   }
1284    
1285  
1286   void DTDPGCreateAnalyzerSummary::createSummaryAllPlots() {
1415  
1287    string Whname[5]={"Wm2","Wm1","W0","W1","W2"};
1288 <  
1288 >
1289 >  gStyle->SetTitleW(0.55);
1290 >  gStyle->SetTitleH(0.13);
1291    gStyle->SetTitleX(0.01);
1292    gStyle->SetTitleY(0.99);
1293    
# Line 1423 | Line 1296 | void DTDPGCreateAnalyzerSummary::createS
1296    gStyle->SetStatX(0.98);
1297    gStyle->SetStatW(0.35);
1298    gStyle->SetStatH(0.45);
1299 <  
1300 <  gStyle->SetPalette(1);   // set palette for 2D histos
1301 <  gStyle->SetTitleW(0.97);
1302 <  gStyle->SetTitleH(0.1);
1303 <  
1304 <  float BXSummary_mean=0.;
1305 <  float NBXSummary_mean=0.;
1306 <  TH1F * BXSummary[5][4];
1307 <  for(int iw=0;iw<5;iw++){ // Loop in wheels
1308 <    for(int ic=1;ic<5;ic++){
1309 <      
1310 <      stringstream hname, htitle;
1311 <      hname  << "BX_mean_MB" << ic << "_W" << (iw-2);
1312 <      htitle << "BX MeanValue (HH,HL) MB" <<  ic << " W" << (iw-2);
1313 <      BXSummary[iw][ic-1]= new TH1F(hname.str().c_str(),htitle.str().c_str(),12,1.,13.);
1314 <      for(int is=1;is<13;is++){
1315 <        stringstream xlab; xlab << "S" << is;
1316 <        BXSummary[iw][ic-1]->GetXaxis()->SetBinLabel(is,xlab.str().c_str());
1299 >
1300 >  //Change standard palette colors
1301 >  const Int_t NRGBs = 5;
1302 >  //const Int_t NCont = 255;
1303 >  const Int_t NCont = 155;
1304 >
1305 >  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
1306 >  Double_t red[NRGBs]   = { 0.99, 0.40, 0.00, 0.80, 0.95 };
1307 >  Double_t green[NRGBs] = { 0.99, 0.40, 0.40, 0.10, 0.00 };
1308 >  Double_t blue[NRGBs]  = { 0.20, 0.00, 0.90, 0.10, 0.00 };
1309 >  // It needs to be initialize if not root gives a warning and cmssw an error and
1310 >  // the program stops
1311 >  TColor::InitializeColors();
1312 >  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
1313 >  //gStyle->SetNumberContours(NCont);
1314 >
1315 >  // Get histos to be plotted
1316 >  TH1F * first_to_paint;
1317 >  TH1F * first_to_paint_MB[4];
1318 >  string SLname[3]={"Phi1","Theta","Phi2"};
1319 >
1320 >  TH1F *DigiXSecMBSlLayer[5][14][4][3][4];
1321 >
1322 >  for(int iw=0;iw<5;++iw)
1323 >  for(int isec=1;isec<15;++isec)
1324 >  for(int ich=1;ich<5;++ich)
1325 >  for(int isl=1;isl<4;++isl)
1326 >  for(int il=1;il<5;++il){
1327 >      // Create individual layer occupancy plots from hDigiXY_S
1328 >      stringstream histoNameOccup;  histoNameOccup  << "Occup_" << Whname[iw] << "_S" << isec << "_MB" << ich << "_SL" << isl << "_L" <<il;
1329 >      stringstream histoTitleOccup; histoTitleOccup << "Occupancy  " << Whname[iw] << " S" << isec << " MB" << ich << " SL" << SLname[isl-1] << "L" << il;
1330 >      DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]= new TH1F(histoNameOccup.str().c_str(),histoTitleOccup.str().c_str(),100, 0.,100.);
1331 >  }
1332 >
1333 >  TH2F *DigiXYS[5][14];
1334 >  TH1F *OccupMB[5][4];
1335 >  TH1F *OccupWh[5];
1336 >
1337 >  std::map<int,std::vector<int> >::const_iterator whIt  = mySectors.begin();
1338 >  std::map<int,std::vector<int> >::const_iterator whEnd = mySectors.end();
1339 >  for(;whIt!=whEnd;++whIt) {
1340 >    int iw = (*whIt).first + 2;
1341 >    std::vector<int>::const_iterator secIt  = (*whIt).second.begin();
1342 >    std::vector<int>::const_iterator secEnd = (*whIt).second.end();
1343 >    for(;secIt!=secEnd;++secIt) {
1344 >      int isec = (*secIt);
1345 >
1346 >     // Occupancies
1347 >      stringstream histoNameOcc; histoNameOcc << "hDigiXY_" << Whname[iw] << "_S" << isec;
1348 >      DigiXYS[iw][isec-1]=getHisto<TH2F>(histoNameOcc.str());
1349 >      int nbx= DigiXYS[iw][isec-1]->GetNbinsX() ;
1350 >
1351 >      for(int ich=1;ich<5;ich++){
1352 >         for(int isl=1;isl<4;isl++){
1353 >          for(int il=1;il<5;il++){
1354 >            int iby=(ich-1)*20+(isl-1)*4+il+1;
1355 >            float totentr=0;
1356 >            for(int ibx=1;ibx<nbx;ibx++){
1357 >              float yval=DigiXYS[iw][isec-1]->GetBinContent(ibx,iby);
1358 >              DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetBinContent(ibx,yval);
1359 >              totentr+=yval;
1360 >            }
1361 >            DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetEntries(totentr);
1362 >          }
1363 >         }
1364        }
1365 +    }// End loop Sectors
1366 +  }//End loop Wheels
1367 +
1368 +  for(int iw=0;iw<5;++iw)
1369 +  for(int ich=1;ich<5;++ich)
1370 +  {
1371 +     stringstream histoNameOccMB; histoNameOccMB << "Digi_" << Whname[iw] << "_MB" << ich;
1372 +     OccupMB[iw][ich-1]= new TH1F(histoNameOccMB.str().c_str(),histoNameOccMB.str().c_str(),14, 0.,14.);
1373 +  }
1374 +  whIt  = mySectors.begin();
1375 +  whEnd = mySectors.end();
1376 +  for(;whIt!=whEnd;++whIt) {
1377 +   int iw = (*whIt).first + 2;
1378 +   for(int ich=1;ich<5;++ich){
1379 +     for(int isec=1;isec<13;isec++){
1380 +      float totentr=0;
1381 +      for(int isl=1;isl<4;isl++){
1382 +        for(int il=1;il<5;il++){
1383 +          totentr+=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetEntries();
1384 +        }
1385 +      }
1386 +      OccupMB[iw][ich-1]->Fill(isec,totentr);
1387 +     }
1388 +   }
1389 +  }
1390 +  
1391 + for(int ic=0;ic<4;ic++)
1392 + {
1393 +   first_to_paint_MB[ic]=OccupMB[0][ic];
1394 +   float nbmax=0;
1395 +   nbmax=OccupMB[0][ic]->GetMaximum();
1396 +   for(int iw=0;iw<5;iw++)
1397 +   {
1398 +      float nbmax0=0;
1399 +      nbmax0=OccupMB[iw][ic]->GetMaximum();
1400 +
1401 +      if(nbmax0>nbmax)
1402 +      {
1403 +         nbmax=nbmax0; first_to_paint_MB[ic]=OccupMB[iw][ic];
1404 +      }
1405 +   }
1406 + }
1407 +
1408 + for(int ic=1;ic<5;ic++)
1409 + {
1410 +   stringstream hname21; hname21 << "Total Occupancy  MB" << ic ;
1411 +   first_to_paint_MB[ic-1]->SetTitle(hname21.str().c_str());
1412 +
1413 +   first_to_paint_MB[ic-1]->GetXaxis()->SetLabelSize(0.09);
1414 +   first_to_paint_MB[ic-1]->GetXaxis()->SetTitleSize(0.09);
1415 +   first_to_paint_MB[ic-1]->GetXaxis()->SetTitleOffset(0.5);
1416 +   first_to_paint_MB[ic-1]->GetXaxis()->SetTitle("Sector   ");
1417 +   first_to_paint_MB[ic-1]->GetYaxis()->SetLabelSize(0.09);
1418 +   first_to_paint_MB[ic-1]->GetYaxis()->SetTitleSize(0.09);
1419 +   first_to_paint_MB[ic-1]->GetYaxis()->SetTitleOffset(0.5);
1420 +   first_to_paint_MB[ic-1]->GetYaxis()->SetTitle("Entries");
1421 +   first_to_paint_MB[ic-1]->SetStats(0);
1422 + }
1423 +
1424 +  gStyle->SetTitleW(0.25);
1425 +  gStyle->SetTitleH(0.22);
1426 +  gStyle->SetTitleX(0.74);
1427 +  gStyle->SetTitleY(0.99);
1428 +
1429 +
1430 + TCanvas *OccupanALL = new TCanvas("OccupanALL", "",201,81,999,950);
1431 + OccupanALL->Divide(1,4) ;
1432 + for(int ic=1;ic<5;ic++)
1433 + {
1434 +    OccupanALL->cd(ic)->SetLogy(1);
1435 +    OccupanALL->cd(ic)->SetFillColor(0);
1436 +    OccupanALL->cd(ic)->SetFrameFillColor(0);
1437 +    OccupanALL->cd(ic);
1438 +    first_to_paint_MB[ic-1]->Draw();
1439 +
1440 +    for(int iw=0;iw<5;iw++)
1441 +    {
1442 +      OccupMB[iw][ic-1]->SetLineColor(iw+1);
1443 +      if(iw==4)
1444 +         OccupMB[iw][ic-1]->SetLineColor(6);
1445 +      OccupanALL->cd(ic);  OccupMB[iw][ic-1]->Draw("same");
1446      }
1447 + }
1448 + createGifFile("OccupancyAll","",OccupanALL,false);
1449 + delete OccupanALL;
1450 +
1451 +
1452 + // Occupancies/Sector
1453 +  for(int iw=0;iw<5;iw++){
1454 +    stringstream histoNameOccMB; histoNameOccMB << "Digi_" << Whname[iw];
1455 +    OccupWh[iw]= new TH1F(histoNameOccMB.str().c_str(),histoNameOccMB.str().c_str(),14, 0.,14.);
1456 +    for(int isec=1;isec<13;isec++){
1457 +     float totentr=0;
1458 +     for(int ich=1;ich<5;++ich){
1459 +      for(int isl=1;isl<4;isl++){
1460 +        for(int il=1;il<5;il++){
1461 +          if(DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1])
1462 +            totentr+=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetEntries();
1463 +        }
1464 +      }
1465 +     OccupWh[iw]->Fill(isec,totentr);
1466 +     }
1467 +   }
1468    }
1469 +
1470 + first_to_paint=OccupWh[0];
1471 + float nbmax=0;
1472 + nbmax=OccupWh[0]->GetMaximum();
1473 + for(int iw=1;iw<5;iw++)
1474 + {
1475 +   float nbmax0=0;
1476 +   nbmax0=OccupWh[iw]->GetMaximum();
1477 +   if(nbmax0>nbmax)
1478 +   {
1479 +      nbmax=nbmax0; first_to_paint=OccupWh[iw];
1480 +   }
1481 + }
1482 +
1483 + stringstream hname21; hname21 << "Total Occupancy ";
1484 + first_to_paint->SetTitle(hname21.str().c_str());
1485 +
1486 + first_to_paint->GetXaxis()->SetLabelSize(0.04);
1487 + first_to_paint->GetXaxis()->SetTitleSize(0.04);
1488 + // first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1489 + first_to_paint->GetXaxis()->SetTitle("Sector   ");
1490 + first_to_paint->GetYaxis()->SetLabelSize(0.04);
1491 + first_to_paint->GetYaxis()->SetTitleSize(0.04);
1492 + // first_to_paint->GetYaxis()->SetTitleOffset(0.5);
1493 + first_to_paint->GetYaxis()->SetTitle("Entries");
1494 + first_to_paint->SetStats(0);
1495 +
1496 +
1497 +  gStyle->SetTitleX(0.1);
1498 +  gStyle->SetTitleY(0.99);
1499 +  gStyle->SetTitleW(0.87);
1500 +  gStyle->SetTitleH(0.1);
1501 +
1502 +
1503 + TCanvas *OccupanSec = new TCanvas("OccupanSec", "",201,81,650,550);
1504 + OccupanSec->SetLogy(1) ;
1505 + first_to_paint->Draw();
1506 + for(int iw=0;iw<5;iw++)
1507 + {
1508 +   OccupWh[iw]->SetLineColor(iw+1);
1509 +   if(iw==4)OccupWh[iw]->SetLineColor(6);
1510 +   OccupWh[iw]->Draw("same");
1511 + }
1512 +
1513 + createGifFile("OccupancySec","",OccupanSec,false);
1514 + delete OccupanSec;
1515 +
1516 +  gStyle->SetTitleW(0.55);
1517 +  gStyle->SetTitleH(0.13);
1518 +  gStyle->SetTitleX(0.01);
1519 +  gStyle->SetTitleY(0.99);
1520    
1521 <  
1522 <  //   SC BX Summary    
1523 <  for(int iw=0;iw<5;iw++){ // Loop in wheels
1524 <    for(int ins=1;ins<13;ins++){ // Loop in sectors
1525 <    
1526 <      TH1F *hHH[4];
1527 <      TH1F *hHL[4];
1528 <      for(int ic=1;ic<5;ic++){ // Loop in chambers
1529 <      
1530 <        stringstream hname; hname << "hTrigBX_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1531 <        hHH[ic-1]= getHisto<TH1F>(hname.str()+"_qual6");
1532 <        hHL[ic-1]= getHisto<TH1F>(hname.str()+"_qual5");
1533 <      
1534 <        hHH[ic-1]->Add(hHL[ic-1]);
1535 <        hHH[ic-1]->SetLineColor(ic);
1536 <        hHH[ic-1]->SetStats(0);
1537 <      
1538 <        // Compute average for BX summary plot
1539 <        int nb=hHH[ic-1]->GetNbinsX();
1540 <        int nbMax=hHH[ic-1]->GetMaximumBin();
1541 <        float xmean=0;
1542 <        float xtot0=0;
1543 <        for(int inb=nbMax-2;inb<nbMax+3;inb++){ // Takes Central BX+-2
1544 <          if(inb>1 && inb<nb){ //To avoid problems if it is on the "border"
1545 <            float yval=hHH[ic-1]->GetBinContent(inb);
1546 <            float xval=hHH[ic-1]->GetBinCenter(inb);
1547 <            xmean+=xval*yval;
1548 <            xtot0+=yval;
1549 <          }
1550 <        }
1551 <        if(xtot0>0){
1552 <          xmean=xmean/xtot0 ;
1553 <          BXSummary[iw][ic-1]->Fill(ins,xmean);
1554 <          BXSummary_mean+=xmean;
1555 <          NBXSummary_mean++;
1556 <        }
1521 >  gStyle->SetOptStat(10);
1522 >  gStyle->SetStatX(0.98);
1523 >  gStyle->SetStatY(0.97);
1524 >  gStyle->SetStatW(0.35);
1525 >  gStyle->SetStatH(0.38);
1526 >
1527 >
1528 > TH1F *TBoxSec[5][12];
1529 > TH1F *TBoxMB[5][4];
1530 > TH1F *TBoxMBTop[5][4];
1531 > TH1F *TBoxMBBottom[5][4];
1532 > TH1F *TBoxMBVertical[5][4];
1533 >
1534 > whIt  = mySectors.begin();
1535 > whEnd = mySectors.end();
1536 > for(;whIt!=whEnd;++whIt) {
1537 >   int iw = (*whIt).first + 2;
1538 >  
1539 >   std::vector<int>::const_iterator secIt  = (*whIt).second.begin();
1540 >   std::vector<int>::const_iterator secEnd = (*whIt).second.end();
1541 >   for(;secIt!=secEnd;++secIt) {
1542 >      int isec = (*secIt);
1543 >    if(isec<13)  
1544 >    for(int ic=1;ic<5;ic++){
1545 >        stringstream hname; hname << "htime_" << Whname[iw] << "_S" << isec << "_MB" << ic;
1546 >        TH1F * theHisto=getHisto<TH1F>(hname.str());
1547 >
1548 >        if(isec==1)
1549 >        {
1550 >           stringstream hname2; hname2 << "htime_" << Whname[iw] << "_MB" << ic ;
1551 >           TBoxMB[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1552 >           TBoxMB[iw][ic-1]->SetTitle(hname2.str().c_str());
1553 >
1554 >           stringstream hname3; hname3 << "htime_" << Whname[iw] << "_MB" << ic << "_Vertical" ;
1555 >           TBoxMBVertical[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1556 >           TBoxMBVertical[iw][ic-1]->SetTitle(hname2.str().c_str());
1557 >        }
1558 >        if(isec==2)
1559 >        {
1560 >           stringstream hname2; hname2 << "htime_" << Whname[iw] << "_MB" << ic << "_Top"  ;
1561 >           TBoxMBTop[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1562 >           TBoxMBTop[iw][ic-1]->SetTitle(hname2.str().c_str());
1563 >        }
1564 >        if(isec==8)
1565 >        {
1566 >           stringstream hname2; hname2 << "htime_" << Whname[iw] << "_MB" << ic << "_Bottom"  ;
1567 >           TBoxMBBottom[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1568 >           TBoxMBBottom[iw][ic-1]->SetTitle(hname2.str().c_str());
1569 >        }
1570 >
1571 >        if(isec>2)TBoxMB[iw][ic-1]->Add(theHisto);   //
1572 >        if(isec>2 && isec<7)TBoxMBTop[iw][ic-1]->Add(theHisto);  
1573 >        if(isec>8)TBoxMBBottom[iw][ic-1]->Add(theHisto);  
1574 >        if(isec==7)TBoxMBVertical[iw][ic-1]->Add(theHisto);   //
1575 >
1576 >        if(ic==1)
1577 >        {
1578 >           stringstream hname2; hname2 << "timebox_" << Whname[iw] << "_S" << isec ;
1579 >           TBoxSec[iw][isec-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1580 >           TBoxSec[iw][isec-1]->SetTitle(hname2.str().c_str());
1581 >
1582 >        }
1583 >        if(ic>1)TBoxSec[iw][isec-1]->Add(theHisto);   //
1584 >
1585 >    }// end loop MB
1586 >   }// end loop Sector
1587 > }// end loop Wheel
1588 >
1589 > TH1F * first_to_paint_MB_typ[4][4];
1590 > for(int ic=0;ic<4;ic++)
1591 > {
1592 >   first_to_paint_MB_typ[ic][0]=TBoxMB[0][ic];
1593 >   first_to_paint_MB_typ[ic][1]=TBoxMBTop[0][ic];
1594 >   first_to_paint_MB_typ[ic][2]=TBoxMBBottom[0][ic];
1595 >   first_to_paint_MB_typ[ic][3]=TBoxMBVertical[0][ic];
1596 >   float nbmax[4]={0,0,0,0};
1597 >   nbmax[0]=TBoxMB[0][ic]->GetMaximum();
1598 >   nbmax[1]=TBoxMBTop[0][ic]->GetMaximum();
1599 >   nbmax[2]=TBoxMBBottom[0][ic]->GetMaximum();
1600 >   nbmax[3]=TBoxMBVertical[0][ic]->GetMaximum();
1601 >   for(int iw=1;iw<5;iw++)
1602 >   {
1603 >      float nbmax0[4]={0,0,0,0};
1604 >      nbmax0[0]=TBoxMB[iw][ic]->GetMaximum();
1605 >      nbmax0[1]=TBoxMBTop[iw][ic]->GetMaximum();
1606 >      nbmax0[2]=TBoxMBBottom[iw][ic]->GetMaximum();
1607 >      nbmax0[3]=TBoxMBVertical[iw][ic]->GetMaximum();
1608 >
1609 >      if(nbmax0[0]>nbmax[0])
1610 >      {
1611 >         nbmax[0]=nbmax0[0]; first_to_paint_MB_typ[ic][0]=TBoxMB[iw][ic];
1612 >      }
1613 >      if(nbmax0[1]>nbmax[1])
1614 >      {
1615 >         nbmax[1]=nbmax0[1]; first_to_paint_MB_typ[ic][1]=TBoxMBTop[iw][ic];
1616 >      }
1617 >      if(nbmax0[2]>nbmax[2])
1618 >      {
1619 >         nbmax[2]=nbmax0[2]; first_to_paint_MB_typ[ic][2]=TBoxMBBottom[iw][ic];
1620 >      }
1621 >      if(nbmax0[3]>nbmax[3])
1622 >      {
1623 >         nbmax[3]=nbmax0[3]; first_to_paint_MB_typ[ic][3]=TBoxMBVertical[iw][ic];
1624        }
1485    }// end Loop in chambers
1486  }// END loop in wheels and sectors
1625  
1626 <  string titlename = "BX Average (HH,HL)";
1627 <  TCanvas *BXaverage = new TCanvas("BXAverage", "",201,81,999,699);
1628 <  BXaverage->SetTopMargin(0.42);
1629 <  BXaverage->SetBottomMargin(0.32);
1630 <  BXaverage->SetRightMargin(0.12);
1631 <  BXaverage->Divide(1,5,0.,0) ;
1632 <  
1633 <  TPaveLabel* title = new TPaveLabel(0.1,0.93,0.85,0.99,titlename.c_str());
1634 <  title->SetFillColor(0);
1635 <  title->SetTextColor(4);
1636 <  title->Draw();
1637 <  TPaveLabel* wheelName[5];
1638 <  memset(wheelName,0,5*sizeof(TPaveLabel*));
1639 <
1640 <  int BXSummary_min=0;
1641 <  int BXSummary_max=0;
1642 <  if(NBXSummary_mean>0)BXSummary_min=-6+int(BXSummary_mean/NBXSummary_mean);
1643 <  if(NBXSummary_mean>0)BXSummary_max=6+int(BXSummary_mean/NBXSummary_mean);
1644 <  for(int iw=0;iw<5;iw++){
1645 <    BXaverage->cd(iw+1);
1646 <    BXaverage->cd(iw+1)->SetGrid();
1626 >   }
1627 > }
1628 > for(int ic=1;ic<5;ic++)
1629 > {
1630 >   stringstream hname21; hname21 << "htime_MB" << ic ;
1631 >   stringstream hname22; hname22 << "htime_MB" << ic << "_Top"  ;
1632 >   stringstream hname23; hname23 << "htime_MB" << ic << "_Bottom"  ;
1633 >   stringstream hname24; hname24 << "htime_MB" << ic << "_Vertical"  ;
1634 >   first_to_paint_MB_typ[ic-1][0]->SetTitle(hname21.str().c_str());
1635 >   first_to_paint_MB_typ[ic-1][1]->SetTitle(hname22.str().c_str());
1636 >   first_to_paint_MB_typ[ic-1][2]->SetTitle(hname23.str().c_str());
1637 >   first_to_paint_MB_typ[ic-1][3]->SetTitle(hname24.str().c_str());
1638 >
1639 >   for(int ityp=0;ityp<4;ityp++)
1640 >   {
1641 >     first_to_paint_MB_typ[ic-1][ityp]->GetXaxis()->SetLabelSize(0.07);
1642 >     first_to_paint_MB_typ[ic-1][ityp]->GetYaxis()->SetLabelSize(0.05);
1643 >     first_to_paint_MB_typ[ic-1][ityp]->SetNdivisions(505);
1644 >   }
1645 > }
1646 >
1647 >
1648 > TCanvas *TBoxAll = new TCanvas("TBoxAll", "",201,81,999,950);
1649 > TBoxAll->Divide(4,4) ;
1650 > for(int ic=1;ic<5;ic++)
1651 > {
1652 >    first_to_paint_MB_typ[ic-1][0]->SetMinimum(0);
1653 >    first_to_paint_MB_typ[ic-1][1]->SetMinimum(0);
1654 >    first_to_paint_MB_typ[ic-1][2]->SetMinimum(0);
1655 >    first_to_paint_MB_typ[ic-1][3]->SetMinimum(0);
1656 >    TBoxAll->cd((ic-1)*4+1); first_to_paint_MB_typ[ic-1][0]->Draw();
1657 >    TBoxAll->cd((ic-1)*4+2); first_to_paint_MB_typ[ic-1][1]->Draw();
1658 >    TBoxAll->cd((ic-1)*4+3); first_to_paint_MB_typ[ic-1][2]->Draw();
1659 >    TBoxAll->cd((ic-1)*4+4); first_to_paint_MB_typ[ic-1][3]->Draw();
1660 >
1661 >    for(int iw=0;iw<5;iw++)
1662 >    {
1663 >      TBoxMB[iw][ic-1]->SetLineColor(iw+1);
1664 >      TBoxMBTop[iw][ic-1]->SetLineColor(iw+1);
1665 >      TBoxMBBottom[iw][ic-1]->SetLineColor(iw+1);
1666 >      TBoxMBVertical[iw][ic-1]->SetLineColor(iw+1);
1667 >      if(iw==4)
1668 >       {
1669 >         TBoxMB[iw][ic-1]->SetLineColor(6);
1670 >         TBoxMBTop[iw][ic-1]->SetLineColor(6);
1671 >         TBoxMBBottom[iw][ic-1]->SetLineColor(6);
1672 >         TBoxMBVertical[iw][ic-1]->SetLineColor(6);
1673 >       }
1674 >      TBoxAll->cd((ic-1)*4+1);  TBoxMB[iw][ic-1]->Draw("same");
1675 >      TBoxAll->cd((ic-1)*4+2);  TBoxMBTop[iw][ic-1]->Draw("same");
1676 >      TBoxAll->cd((ic-1)*4+3);  TBoxMBBottom[iw][ic-1]->Draw("same");
1677 >      TBoxAll->cd((ic-1)*4+4);  TBoxMBVertical[iw][ic-1]->Draw("same");
1678 >    }
1679 > }
1680 >
1681 > createGifFile("TimeBoxAll","",TBoxAll,false);
1682 > delete TBoxAll;
1683 >
1684 >
1685 > TCanvas *TBoxWh[5];
1686 > TBoxWh[0] = new TCanvas("TBoxWh-2", "",201,81,999,950);
1687 > TBoxWh[1] = new TCanvas("TBoxWh-1", "",201,81,999,950);
1688 > TBoxWh[2] = new TCanvas("TBoxWh0", "",201,81,999,950);
1689 > TBoxWh[3] = new TCanvas("TBoxWh+1", "",201,81,999,950);
1690 > TBoxWh[4] = new TCanvas("TBoxWh+2", "",201,81,999,950);
1691 > for(int iw=0;iw<5;iw++)
1692 > {
1693 >   TBoxWh[iw]->Divide(3,4) ;
1694 >   for(int isec=1;isec<13;isec++)
1695 >   {
1696 >      TBoxWh[iw]->cd(isec);
1697 >      TBoxWh[iw]->cd(isec)->SetFillColor(0);
1698 >      TBoxWh[iw]->cd(isec)->SetFrameFillColor(0);
1699 >      TBoxSec[iw][isec-1]->GetXaxis()->SetLabelSize(0.07);
1700 >      TBoxSec[iw][isec-1]->GetYaxis()->SetLabelSize(0.05);
1701 >      TBoxSec[iw][isec-1]->SetNdivisions(505);
1702 >      TBoxSec[iw][isec-1]->Draw();   //
1703 >   }
1704 > }
1705 >
1706 > for(int iw=0;iw<5;iw++)
1707 > {
1708 >    createGifFile("TimeBoxAll",(iw-2),"",TBoxWh[iw]);
1709 >    delete TBoxWh[iw];
1710 > }
1711 >
1712 >
1713 >  gStyle->SetOptStat(10);
1714 >  gStyle->SetStatX(0.4);
1715 >  gStyle->SetStatY(0.88);
1716 >  gStyle->SetStatW(0.29);
1717 >  gStyle->SetStatH(0.38);
1718 >
1719 >
1720 > TH1F *NHitsSec[5][12];
1721 > TH1F *NHitsMB[5][4];
1722 > TH1F *NHitsMBTop[5][4];
1723 > TH1F *NHitsMBBottom[5][4];
1724 > TH1F *NHitsMBVertical[5][4];
1725 > for(int iw=0;iw<5;iw++)
1726 > {
1727 >   for(int isec=0;isec<12;isec++)NHitsSec[iw][isec]=NULL;
1728 >   for(int ic=0;ic<5;ic++)
1729 >   {
1730 >    NHitsMB[iw][ic]=NULL;
1731 >    NHitsMBTop[iw][ic]=NULL;
1732 >    NHitsMBBottom[iw][ic]=NULL;
1733 >    NHitsMBVertical[iw][ic]=NULL;
1734 >   }
1735 > }
1736 >
1737 > whIt  = mySectors.begin();
1738 > whEnd = mySectors.end();
1739 > for(;whIt!=whEnd;++whIt) {
1740 >  int iw = (*whIt).first + 2;
1741 >  std::vector<int>::const_iterator secIt  = (*whIt).second.begin();
1742 >  std::vector<int>::const_iterator secEnd = (*whIt).second.end();
1743 >  for(;secIt!=secEnd;++secIt) {
1744 >    int isec = (*secIt);
1745 >    if(isec<13)
1746      for(int ic=1;ic<5;ic++){
1747 <      BXSummary[iw][ic-1]->SetMaximum(BXSummary_max);
1748 <      BXSummary[iw][ic-1]->SetMinimum(BXSummary_min);
1749 <      BXSummary[iw][ic-1]->SetStats(0);
1750 <      BXSummary[iw][ic-1]->SetTitle(0);
1751 <      BXSummary[iw][ic-1]->SetLineWidth(2);
1752 <      BXSummary[iw][ic-1]->GetXaxis()->SetLabelSize(0.25);
1753 <      BXSummary[iw][ic-1]->GetYaxis()->SetLabelSize(0.2);
1754 <      if(iw==4)BXSummary[iw][ic-1]->GetYaxis()->SetLabelSize(0.15);
1755 <      BXSummary[iw][ic-1]->GetYaxis()->SetNdivisions(502);
1756 <      BXSummary[iw][ic-1]->SetLineColor(ic);
1757 <      if(ic==1)BXSummary[iw][ic-1]->Draw();
1758 <      else BXSummary[iw][ic-1]->Draw("same");
1759 <    }
1760 <    stringstream ptitle; ptitle << "Wheel " << (iw-2);
1761 <    wheelName[iw] = new TPaveLabel(1.00,0.70,1.12,0.90,ptitle.str().c_str(),"NDC");
1762 <    wheelName[iw]->Draw();
1763 <  }
1747 >      //for(int isl=1;isl<4;isl++){
1748 >        //stringstream hname; hname << "hNhits_" << Whname[iw] << "_S" << isec << "_MB" << ic << "_SL" << isl;
1749 >      {
1750 >        stringstream hname; hname << "hNhits_" << Whname[iw] << "_S" << isec << "_MB" << ic;
1751 >        TH1F * theHisto=getHisto<TH1F>(hname.str());
1752 >
1753 >        if(isec==1)
1754 >        {
1755 >           stringstream hname2; hname2 << "nHits_" << Whname[iw] << "_MB" << ic ;
1756 >           NHitsMB[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1757 >           NHitsMB[iw][ic-1]->SetTitle(hname2.str().c_str());
1758 >
1759 >           stringstream hname3; hname3 << "nHits_" << Whname[iw] << "_MB" << ic << "_Vertical";
1760 >           NHitsMBVertical[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1761 >           NHitsMBVertical[iw][ic-1]->SetTitle(hname3.str().c_str());
1762 >        }
1763 >        if(isec==2)
1764 >        {
1765 >           stringstream hname2; hname2 << "nHits_" << Whname[iw] << "_MB" << ic << "_Top"  ;
1766 >           NHitsMBTop[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1767 >           NHitsMBTop[iw][ic-1]->SetTitle(hname2.str().c_str());
1768 >        }
1769 >        if(isec==8)
1770 >        {
1771 >           stringstream hname2; hname2 << "nHits_" << Whname[iw] << "_MB" << ic << "_Bottom"  ;
1772 >           NHitsMBBottom[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1773 >           NHitsMBBottom[iw][ic-1]->SetTitle(hname2.str().c_str());
1774 >        }
1775  
1776 <  createGifFile("TrigBXhhhl_average","",BXaverage);
1777 <  delete BXaverage;
1778 <  delete title;
1779 <  for (int i=0;i<5;++i) {
1780 <    if (wheelName[i]) {
1781 <      delete wheelName[i];
1776 >
1777 >        if(isec>2)NHitsMB[iw][ic-1]->Add(theHisto);   //
1778 >        if(isec>2 && isec<7)NHitsMBTop[iw][ic-1]->Add(theHisto);
1779 >        if(isec>8)NHitsMBBottom[iw][ic-1]->Add(theHisto);
1780 >        if(isec==7)NHitsMBVertical[iw][ic-1]->Add(theHisto);
1781 >
1782 >        if(ic==1)
1783 >        {
1784 >           stringstream hname2; hname2 << "nHits_" << Whname[iw] << "_S"  << isec ;
1785 >           NHitsSec[iw][isec-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1786 >           NHitsSec[iw][isec-1]->SetTitle(hname2.str().c_str());
1787 >
1788 >        }
1789 >        if(ic>1 && ic<4)NHitsSec[iw][isec-1]->Add(theHisto);  // To avoid mix with MB4
1790 >                                                              // that has not Theta SLs
1791 >      }
1792      }
1793    }
1794 + }
1795 +
1796 + for(int ic=0;ic<4;ic++)
1797 + {
1798 +   first_to_paint_MB_typ[ic][0]=NHitsMB[0][ic];
1799 +   first_to_paint_MB_typ[ic][1]=NHitsMBTop[0][ic];
1800 +   first_to_paint_MB_typ[ic][2]=NHitsMBBottom[0][ic];
1801 +   first_to_paint_MB_typ[ic][3]=NHitsMBVertical[0][ic];
1802 +   float nbmax[4]={0,0,0,0};
1803 +   if(NHitsMB[0][ic])nbmax[0]=NHitsMB[0][ic]->GetMaximum();
1804 +   if(NHitsMBTop[0][ic])nbmax[1]=NHitsMBTop[0][ic]->GetMaximum();
1805 +   if(NHitsMBBottom[0][ic])nbmax[2]=NHitsMBBottom[0][ic]->GetMaximum();
1806 +   if(NHitsMBVertical[0][ic])nbmax[3]=NHitsMBVertical[0][ic]->GetMaximum();
1807 +   for(int iw=1;iw<5;iw++)
1808 +   {
1809 +      float nbmax0[4]={0,0,0,0};
1810 +      if(NHitsMB[iw][ic] !=NULL)nbmax0[0]=NHitsMB[iw][ic]->GetMaximum();
1811 +      if(NHitsMBTop[iw][ic] !=NULL)nbmax0[1]=NHitsMBTop[iw][ic]->GetMaximum();
1812 +      if(NHitsMBBottom[iw][ic] !=NULL)nbmax0[2]=NHitsMBBottom[iw][ic]->GetMaximum();
1813 +      if(NHitsMBVertical[iw][ic] !=NULL)nbmax0[3]=NHitsMBVertical[iw][ic]->GetMaximum();
1814 +
1815 +      if(nbmax0[0]>nbmax[0])
1816 +      {
1817 +         nbmax[0]=nbmax0[0]; first_to_paint_MB_typ[ic][0]=NHitsMB[iw][ic];
1818 +      }
1819 +      if(nbmax0[1]>nbmax[1])
1820 +      {
1821 +         nbmax[1]=nbmax0[1]; first_to_paint_MB_typ[ic][1]=NHitsMBTop[iw][ic];
1822 +      }
1823 +      if(nbmax0[2]>nbmax[2])
1824 +      {
1825 +         nbmax[2]=nbmax0[2]; first_to_paint_MB_typ[ic][2]=NHitsMBBottom[iw][ic];
1826 +      }
1827 +      if(nbmax0[3]>nbmax[3])
1828 +      {
1829 +         nbmax[3]=nbmax0[3]; first_to_paint_MB_typ[ic][3]=NHitsMBVertical[iw][ic];
1830 +      }
1831 +   }
1832 + }
1833 +
1834 + for(int ic=1;ic<5;ic++)
1835 + {
1836 +   stringstream hname21; hname21 << "nHits_MB" << ic ;
1837 +   stringstream hname22; hname22 << "nHits_MB" << ic << "_Top"  ;
1838 +   stringstream hname23; hname23 << "nHits_MB" << ic << "_Bottom"  ;
1839 +   stringstream hname24; hname24 << "nHits_MB" << ic << "_Vertical"  ;
1840 +   if(first_to_paint_MB_typ[ic-1][0] != NULL) first_to_paint_MB_typ[ic-1][0]->SetTitle(hname21.str().c_str());
1841 +   if(first_to_paint_MB_typ[ic-1][1] != NULL) first_to_paint_MB_typ[ic-1][1]->SetTitle(hname22.str().c_str());
1842 +   if(first_to_paint_MB_typ[ic-1][2] != NULL) first_to_paint_MB_typ[ic-1][2]->SetTitle(hname23.str().c_str());
1843 +   if(first_to_paint_MB_typ[ic-1][3] != NULL) first_to_paint_MB_typ[ic-1][3]->SetTitle(hname24.str().c_str());
1844 +
1845 +   for(int ityp=0;ityp<4;ityp++)
1846 +   {
1847 +     if(first_to_paint_MB_typ[ic-1][ityp] != NULL)
1848 +     {
1849 +       first_to_paint_MB_typ[ic-1][ityp]->GetXaxis()->SetLabelSize(0.07);
1850 +       first_to_paint_MB_typ[ic-1][ityp]->GetYaxis()->SetLabelSize(0.05);
1851 +       first_to_paint_MB_typ[ic-1][ityp]->SetNdivisions(505);
1852 +     }
1853 +   }
1854 + }
1855 +
1856 + TCanvas *NHitsAll = new TCanvas("NHitsAll", "",201,81,999,950);
1857 + NHitsAll->Divide(4,4) ;
1858 + for(int ip=1;ip<17;ip++)
1859 + {
1860 +    NHitsAll->cd(ip)->SetFillColor(0) ;
1861 +    NHitsAll->cd(ip)->SetFrameFillColor(0) ;
1862 + }
1863 + for(int ic=1;ic<5;ic++)
1864 + {
1865 +    NHitsAll->cd((ic-1)*4+1); if(first_to_paint_MB_typ[ic-1][0] != NULL)first_to_paint_MB_typ[ic-1][0]->Draw();
1866 +    NHitsAll->cd((ic-1)*4+2); if(first_to_paint_MB_typ[ic-1][1] != NULL)first_to_paint_MB_typ[ic-1][1]->Draw();
1867 +    NHitsAll->cd((ic-1)*4+3); if(first_to_paint_MB_typ[ic-1][2] != NULL)first_to_paint_MB_typ[ic-1][2]->Draw();
1868 +    NHitsAll->cd((ic-1)*4+4); if(first_to_paint_MB_typ[ic-1][3] != NULL)first_to_paint_MB_typ[ic-1][3]->Draw();
1869 +
1870 +    for(int iw=0;iw<5;iw++)
1871 +    {
1872 +      if(NHitsMB[iw][ic-1] != NULL)NHitsMB[iw][ic-1]->SetLineColor(iw+1);
1873 +      if(NHitsMBTop[iw][ic-1] != NULL)NHitsMBTop[iw][ic-1]->SetLineColor(iw+1);
1874 +      if(NHitsMBBottom[iw][ic-1] != NULL)NHitsMBBottom[iw][ic-1]->SetLineColor(iw+1);
1875 +      if(NHitsMBVertical[iw][ic-1]!= NULL)NHitsMBVertical[iw][ic-1]->SetLineColor(iw+1);
1876 +      if(iw==4)
1877 +       {
1878 +         if(NHitsMB[iw][ic-1] != NULL)NHitsMB[iw][ic-1]->SetLineColor(6);
1879 +         if(NHitsMBTop[iw][ic-1] != NULL)NHitsMBTop[iw][ic-1]->SetLineColor(6);
1880 +         if(NHitsMBBottom[iw][ic-1] != NULL)NHitsMBBottom[iw][ic-1]->SetLineColor(6);
1881 +         if(NHitsMBVertical[iw][ic-1]!= NULL)NHitsMBVertical[iw][ic-1]->SetLineColor(6);
1882 +       }
1883 +      NHitsAll->cd((ic-1)*4+1);   if(NHitsMB[iw][ic-1] != NULL)NHitsMB[iw][ic-1]->Draw("same");
1884 +      NHitsAll->cd((ic-1)*4+2);   if(NHitsMBTop[iw][ic-1] != NULL)NHitsMBTop[iw][ic-1]->Draw("same");
1885 +      NHitsAll->cd((ic-1)*4+3);   if(NHitsMBBottom[iw][ic-1] != NULL)NHitsMBBottom[iw][ic-1]->Draw("same");
1886 +      NHitsAll->cd((ic-1)*4+4);   if(NHitsMBVertical[iw][ic-1]!= NULL)NHitsMBVertical[iw][ic-1]->Draw("same");
1887 +    }
1888 + }
1889 +
1890 + createGifFile("NHitsAll","",NHitsAll,false);
1891 + delete NHitsAll;
1892 +
1893 +
1894 + TCanvas *NHitsWh[5];
1895 + NHitsWh[0] = new TCanvas("NHitsWh-2", "",201,81,999,950);
1896 + NHitsWh[1] = new TCanvas("NHitsWh-1", "",201,81,999,950);
1897 + NHitsWh[2] = new TCanvas("NHitsWh0", "",201,81,999,950);
1898 + NHitsWh[3] = new TCanvas("NHitsWh+1", "",201,81,999,950);
1899 + NHitsWh[4] = new TCanvas("NHitsWh+2", "",201,81,999,950);
1900 + for(int iw=0;iw<5;iw++)
1901 + {
1902 +   NHitsWh[iw]->Divide(3,4) ;
1903 +   for(int isec=1;isec<13;isec++)
1904 +   {
1905 +      NHitsWh[iw]->cd(isec);
1906 +      NHitsWh[iw]->cd(isec)->SetFillColor(0);
1907 +      NHitsWh[iw]->cd(isec)->SetFrameFillColor(0);
1908 +      if(NHitsSec[iw][isec-1] != NULL)
1909 +      {
1910 +        NHitsSec[iw][isec-1]->GetXaxis()->SetLabelSize(0.07);
1911 +        NHitsSec[iw][isec-1]->GetYaxis()->SetLabelSize(0.05);
1912 +        NHitsSec[iw][isec-1]->SetNdivisions(505);
1913 +        NHitsSec[iw][isec-1]->Draw();   //
1914 +      }
1915 +   }
1916 + }
1917 +
1918 +
1919 + for(int iw=0;iw<5;iw++)
1920 + {
1921 +   createGifFile("NHitsSec",(iw-2),"",NHitsWh[iw]);
1922 +   delete NHitsWh[iw];
1923 + }
1924 +
1925 + TCanvas *NHitsWhAll;
1926 + NHitsWhAll = new TCanvas("NHitsWhAll", "",201,81,999,950);
1927 + NHitsWhAll->Divide(3,4) ;
1928 + for(int ins=1;ins<13;ins++)
1929 + {
1930 +   first_to_paint=NHitsSec[0][ins-1];
1931 +   float nbmax1=0;
1932 +   if(NHitsSec[0][ins-1]!=NULL)NHitsSec[0][ins-1]->GetMaximum();
1933 +   for(int iw=1;iw<5;iw++)
1934 +   {
1935 +      float nbmax2=0;
1936 +      if(NHitsSec[iw][ins-1] != NULL)NHitsSec[iw][ins-1]->GetMaximum();
1937 +      if(nbmax2>nbmax1)
1938 +      {
1939 +         nbmax1=nbmax2; first_to_paint=NHitsSec[iw][ins-1];
1940 +      }
1941 +    }
1942 +
1943 +    NHitsWhAll->cd(ins) ;
1944 +    NHitsWhAll->cd(ins)->SetFillColor(0) ;
1945 +    NHitsWhAll->cd(ins)->SetFrameFillColor(0) ;
1946 +    stringstream hname; hname << "nHits_S"  << ins ;
1947 +    if(first_to_paint != NULL)
1948 +    {
1949 +      first_to_paint->SetTitle(hname.str().c_str());
1950 +      first_to_paint->Draw();
1951 +      for(int iw=0;iw<5;iw++)
1952 +      {
1953 +        if(NHitsSec[iw][ins-1] != NULL)
1954 +        {
1955 +         NHitsSec[iw][ins-1]->SetLineColor(iw+1);
1956 +         if(iw==4) NHitsSec[iw][ins-1]->SetLineColor(6);
1957 +         NHitsSec[iw][ins-1]->Draw("same");
1958 +        }
1959 +      }
1960 +    }
1961 + }
1962 +
1963 + createGifFile("NHitsSec","",NHitsWhAll,false);
1964 +
1965 + delete NHitsWhAll;
1966 +
1967 + gStyle->SetStatY(0.99);
1968 + gStyle->SetStatX(0.98);
1969 + gStyle->SetStatW(0.40);
1970 + gStyle->SetStatH(0.25);
1971 +
1972 +
1973 + stringstream hnameSTA1; hnameSTA1 << "hrIPSA" ;
1974 + stringstream hnameSTA2; hnameSTA2 << "hzIPSA" ;
1975 + stringstream hnameSTA3; hnameSTA3 << "hrVszIPSA" ;
1976 + TH1F * theHistoSTA1=getHisto<TH1F>(hnameSTA1.str());
1977 + TH1F * theHistoSTA2=getHisto<TH1F>(hnameSTA2.str());
1978 + TH2F * theHistoSTA3=getHisto<TH2F>(hnameSTA3.str());
1979 +
1980 + TCanvas *STAatIP;
1981 + STAatIP = new TCanvas("STAatIP", "",201,81,999,400);
1982 + STAatIP->Divide(3,1) ;
1983 + for(int i=1;i<5;i++)
1984 + { STAatIP->cd(i)->SetFillColor(0);STAatIP->cd(i)->SetFrameFillColor(0); }
1985 + STAatIP->cd(1);theHistoSTA1->Draw();
1986 + STAatIP->cd(2);theHistoSTA2->Draw();
1987 + STAatIP->cd(3);theHistoSTA3->Draw("colz");
1988 +
1989 + createGifFile("STATrack_at_IP","",STAatIP,false);
1990 + delete STAatIP;
1991 +
1992 +
1993 + gStyle->SetStatY(0.97);
1994 + gStyle->SetStatX(0.98);
1995 + gStyle->SetStatW(0.25);
1996 + gStyle->SetStatH(0.15);
1997 +
1998 +
1999 + TH1F * segphi=getHisto<TH1F>("segphi");
2000 + TH1F * segphivsz=getHisto<TH1F>("segphivsz");
2001 +
2002 + TH1F * segphiMB[4];
2003 + TH1F * segzMB[4];
2004 + for(int ic=1;ic<5;ic++)
2005 + {
2006 +   stringstream hname1; hname1 << "segphiMB" << ic ;
2007 +   stringstream hname2; hname2 << "segzMB" << ic ;
2008 +   segphiMB[ic-1]=getHisto<TH1F>(hname1.str());
2009 +   segzMB[ic-1]=getHisto<TH1F>(hname2.str());
2010 + }
2011 +
2012 + TCanvas *SegPhiZ;
2013 + SegPhiZ = new TCanvas("SegPhiZ", "",201,81,999,850);
2014 + SegPhiZ->Divide(2,2) ;
2015 + for(int i=1;i<5;i++)
2016 + { SegPhiZ->cd(i)->SetFillColor(0);SegPhiZ->cd(i)->SetFrameFillColor(0); }
2017 +
2018 + SegPhiZ->cd(1);segphi->Draw();
2019 + SegPhiZ->cd(2);segphivsz->Draw("colz");
2020 + first_to_paint=segphiMB[0];
2021 + int nbmaxPSeg=segphiMB[0]->GetMaximum();
2022 + for(int i=1;i<4;i++)
2023 + {
2024 +   int nbmax0=segphiMB[i]->GetMaximum();
2025 +   if(nbmax0>nbmaxPSeg){
2026 +      nbmaxPSeg=nbmax0;
2027 +      first_to_paint=segphiMB[i];
2028 +   }
2029 + }
2030 + first_to_paint->SetTitle("phi of segment position");
2031 + first_to_paint->SetMinimum(0);
2032 + SegPhiZ->cd(3);first_to_paint->Draw();
2033 + for(int i=0;i<4;i++)
2034 + {
2035 +  segphiMB[i]->SetLineColor(i+1);
2036 +  segphiMB[i]->Draw("same");
2037 + }
2038 + first_to_paint=segzMB[0];
2039 + first_to_paint->SetMinimum(0);
2040 + int nbmaxZSeg=segzMB[0]->GetMaximum();
2041 + for(int i=1;i<3;i++) // Not consider the MB4, not Theta Segment
2042 + {
2043 +   int nbmax0=segzMB[i]->GetMaximum();
2044 +   if(nbmax0>nbmaxZSeg){
2045 +      nbmaxZSeg=nbmax0;
2046 +      first_to_paint=segzMB[i];
2047 +   }
2048 + }
2049 + first_to_paint->SetTitle("z of segment position");
2050 + SegPhiZ->cd(4);first_to_paint->Draw();
2051 + for(int i=0;i<3;i++)  // Not consider the MB4, not Theta Segment
2052 + {
2053 +  segzMB[i]->SetLineColor(i+1);
2054 +  segzMB[i]->Draw("same");
2055 + }
2056 +
2057 +
2058 + createGifFile("SegmentPosition","",SegPhiZ,false);
2059 + delete SegPhiZ;
2060 +
2061 + TH1F * difPhi4_all=getHisto<TH1F>("DifPhi4_1");
2062 + TH1F * difPhi4_top=getHisto<TH1F>("DifPhi4_1_top");
2063 + TH1F * difPhi4_bot=getHisto<TH1F>("DifPhi4_1_bot");
2064 +
2065 + TCanvas *DifPhi4;
2066 + DifPhi4 = new TCanvas("DifPhi4", "",201,81,699,400);
2067 + DifPhi4->Divide(2,1) ;
2068 + for(int i=1;i<3;i++)
2069 + { DifPhi4->cd(i)->SetFillColor(0);DifPhi4->cd(i)->SetFrameFillColor(0); }
2070 + TPad *DifPhi4_2 = (TPad*) DifPhi4->GetListOfPrimitives()->FindObject("DifPhi4_2");
2071 +
2072 + DifPhi4->cd(1);difPhi4_all->Draw();
2073 + TPaveLabel * titleDifPhi41 = new TPaveLabel(0.05,0.92,0.7,0.99,"phi pos. in MB4-MB1","NDC");
2074 + titleDifPhi41->Draw();                                                                      
2075 +
2076 + difPhi4_top->SetTitle("Top Sectors"); difPhi4_bot->SetTitle("Bottom Sectors");
2077 + DifPhi4->cd(2)->SetFillColor(0);DifPhi4->cd(2)->SetFrameFillColor(0);
2078 + DifPhi4->cd(2);
2079 + gStyle->SetOptTitle(0);
2080 + double nphi4top=difPhi4_top->GetMaximum();
2081 + double nphi4bot=difPhi4_bot->GetMaximum();
2082 + if(nphi4bot>nphi4top)
2083 + { difPhi4_bot->Draw();difPhi4_top->Draw("same"); }
2084 + else
2085 +  {difPhi4_top->Draw();difPhi4_bot->Draw("same"); }
2086 +  
2087 + DifPhi4_2->BuildLegend();
2088 + titleDifPhi41->Draw();
2089 +
2090 +
2091 + createGifFile("DifPhi14","",DifPhi4,false);
2092 +
2093 + delete DifPhi4;
2094 +
2095 + gStyle->SetOptTitle(1);
2096 +
2097 +
2098 + TCanvas *hSeg;
2099 + hSeg = new TCanvas("hSeg", "",201,81,999,850);
2100 + hSeg->Divide(2,2);
2101 + for(int i=1;i<4;i++)
2102 + { hSeg->cd(i)->SetFillColor(0);hSeg->cd(i)->SetFrameFillColor(0); }
2103 +
2104 + TH1F * hnSegDT=getHisto<TH1F>("hnSegDT");
2105 + TH1F * hnHSegDT=getHisto<TH1F>("hnHSegDT");
2106 + TH1F * hnSegMB1=getHisto<TH1F>("hnSegMB1");
2107 + TH1F * hnHSegMB1=getHisto<TH1F>("hnHSegMB1");
2108 +
2109 + hSeg->cd(1);hnSegDT->Draw();
2110 + hSeg->cd(2);hnHSegDT->Draw();
2111 + hSeg->cd(3);hnSegMB1->Draw();
2112 + hSeg->cd(4);hnHSegMB1->Draw();
2113 +
2114 + createGifFile("SegmentsAll","",hSeg,false);
2115 + delete hSeg;
2116  
2117   }
2118  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines