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.2 by battilan, Mon Nov 3 11:06:39 2008 UTC vs.
Revision 1.11 by pellicci, Wed Jan 30 14:42:51 2013 UTC

# Line 12 | Line 12
12  
13  
14   #include <UserCode/DTDPGAnalysis/src/DTDPGCreateAnalyzerSummary.h>
15 + #include "UserCode/DTDPGAnalysis/src/DTROUtility.h"
16  
17   // Framework
18   #include <FWCore/Framework/interface/Event.h>
# Line 35 | 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 42 | 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 64 | 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){
74  
78   }
79  
80  
# Line 90 | Line 93 | void DTDPGCreateAnalyzerSummary::endJob(
93    myMainFolder.append(cMainFolder);
94    myMainFolder.append("/DT/Run summary/DTOfflineAnalyzer/");
95  
96 <
96 >  string mainFold;
97 >  mainFold.append(cMainFolder);
98 >  mainFold.append("/DT/Run summary/");
99    edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Creating summaries!";
100 <  
101 <  if (myParameters.getUntrackedParameter<bool>("FullWheelHistos", false))    { createFullWheelPlots(); }
100 >
101 >  DTROUtility roUtil(myFile,mainFold);
102 >  mySectors = roUtil.getSectorMap();
103 >
104 >  if (myParameters.getUntrackedParameter<bool>("SummaryHistos", false))    { createSummaryPlots(); }
105    if (myParameters.getUntrackedParameter<bool>("SummaryWheelHistos", false)) { createSummaryWheelPlots(); }
106    if (myParameters.getUntrackedParameter<bool>("SummaryAllHistos", false))   { createSummaryAllPlots(); }
107  
# Line 104 | 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 121 | 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 137 | 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 155 | Line 168 | void DTDPGCreateAnalyzerSummary::createG
168  
169   }
170    
171 <  
159 < void DTDPGCreateAnalyzerSummary::createFullWheelPlots() {
171 > void DTDPGCreateAnalyzerSummary::createSummaryPlots() {
172  
173    string Whname[5]={"Wm2","Wm1","W0","W1","W2"};
174  
# Line 173 | Line 185 | void DTDPGCreateAnalyzerSummary::createF
185  
186    
187    // Get histos to be plotted
176  // char histoname[240];
177  // 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;
193 <  float max, max1;
183 <  TPaveText* sid;
184 <  TPaveText* labcont[50]; TText* cont[50];
192 >  //int nbin;
193 >  //float max, max1;
194  
186
187  // Occupancies
195    TH2F *DigiXYS[5][14];
196 <  for(int iw=0;iw<5;++iw) {
197 <    for(int isec=1;isec<15;isec++) {
198 <      stringstream histoname; histoname << "hDigiXY_" << Whname[iw] << "_S" << isec;
199 <      DigiXYS[iw][isec-1]=getHisto<TH2F>(histoname.str());
200 <    }
201 <  }
202 <
203 <   // Crea and fill individual layer occupancy plots from hDigiXY_S
204 <   TH1F * DigiXSecMBSlLayer[5][14][4][3][4];
205 <   for(int iw=0;iw<5;++iw){
206 <     for(int isec=1;isec<15;++isec){
207 <       for(int ich=1;ich<5;++ich){
208 <         for(int isl=1;isl<4;++isl){
209 <           for(int il=1;il<5;++il){
210 <             stringstream histoname;  histoname  << "Occup_" << Whname[iw] << "_S" << isec << "_MB" << ich << "_SL" << isl << "_L" <<il;
211 <             stringstream histotitle; histotitle << "Occupancy  " << Whname[iw] << " S" << isec << " MB" << ich << " SL" << SLname[isl-1] << "L" << il;
212 <             DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]= new TH1F(histoname.str().c_str(),histotitle.str().c_str(),100, 0.,100.);
213 <           }
214 <         }
215 <       }
216 <     }
217 <   }
218 <
219 <   for(int iw=0;iw<5;iw++){
220 <     for(int isec=1;isec<15;isec++){
221 <      
222 <       int nbx= DigiXYS[iw][isec-1]->GetNbinsX() ;
223 <       //int nby= DigiXYS[iw][isec-1]->GetNbinsY() ;
224 <
225 <       for(int ich=1;ich<5;ich++){
226 <         for(int isl=1;isl<4;isl++){
227 <           for(int il=1;il<5;il++){
228 <             int iby=(ich-1)*20+(isl-1)*4+il+1;
229 <             float totentr=0;
230 <             for(int ibx=1;ibx<nbx;ibx++){
231 <               float yval=DigiXYS[iw][isec-1]->GetBinContent(ibx,iby);
232 <               DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetBinContent(ibx,yval);
233 <               totentr+=yval;
234 <             }
235 <             DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetEntries(totentr);
236 <           }
237 <         }
238 <       }
239 <     }
240 <   }// end loop sector
241 <
242 <   // TBoxes
236 <   TH1F * TBoxSecMBSlLayer[5][14][4][3][4];
237 <   for(int iw=0;iw<5;iw++){
238 <     for(int isec=1;isec<15;isec++){
239 <       for(int ich=1;ich<5;ich++){
240 <         for(int isl=1;isl<4;isl++){
241 <           for(int il=1;il<5;il++){
242 <             stringstream histoname; histoname << "htime_" << Whname[iw] << "_S" << isec << "_MB" << ich << "_SL" << isl << "_L" << il;
243 <             TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]=getHisto<TH1F>(histoname.str());
244 <           }
245 <         }
246 <       }
247 <     }
248 <   }
249 <
250 <   TH1F *Correlated_trig_Bx[5][14][4][3];
251 <   for(int iw=0;iw<5;iw++){
252 <     for(int isec=1;isec<15;isec++){
253 <       for(int ich=1;ich<5;ich++){
254 <         for(int iq=4;iq<7;iq++){
255 <           stringstream histoname; histoname << "hTrigBX_" << Whname[iw] << "_S" << isec << "_MB" << ich << "_qual" << iq;
256 <           Correlated_trig_Bx[iw][isec-1][ich-1][iq-4]=getHisto<TH1F>(histoname.str());
257 <         }
258 <       }
259 <     }
260 <   }
261 <
262 <   TH1F *hTrg_effnum_SecMB[5][14][4];
263 <   TH1F *hTrg_effdenum_SecMB[5][14][4];
264 <   TH1F *hPhiHL_SecMB[5][14][4];
265 <   for(int iw=0;iw<5;iw++){
266 <     for(int isec=1;isec<15;isec++){
267 <       for(int ich=1;ich<5;ich++){
268 <         stringstream htag; htag << "_" << Whname[iw] << "_S" << isec << "_MB" << ich;
269 <         stringstream heffden; heffden << "hTrg_effdenum" << htag.str();
270 <         hTrg_effdenum_SecMB[iw][isec-1][ich-1]=getHisto<TH1F>(heffden.str());
271 <         stringstream heffnum; heffnum  << "hTrg_effnum" << htag.str();
272 <         hTrg_effnum_SecMB[iw][isec-1][ich-1]=getHisto<TH1F>(heffnum.str());
273 <         stringstream phihl; phihl << "hPhiHL" << htag.str();
274 <         hPhiHL_SecMB[iw][isec-1][ich-1]=getHisto<TH1F>(phihl.str());
275 <       }
276 <     }
277 <   }
278 <
279 <   TH1F *TriggerMatrix[5][15];
280 <   for(int iw=0;iw<5;iw++){
281 <     for(int isec=1;isec<15;isec++){
282 <       stringstream histoname; histoname << "TriggerMatrix" << Whname[iw] << "_S" << isec;
283 <       TriggerMatrix[iw][isec-1]=getHisto<TH1F>(histoname.str());
284 <     }
285 <   }
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];
202 >  //TH1F *hPhiHL_SecMB[5][14][4];
203 >  //TH1F *TriggerMatrix[5][15];
204 >  TH1F * TriggerInclusive[5];
205 >
206 >  std::map<int,std::vector<int> >::const_iterator whIt  = mySectors.begin();
207 >  std::map<int,std::vector<int> >::const_iterator whEnd = mySectors.end();
208 >  for(;whIt!=whEnd;++whIt) {
209 >    int iw = (*whIt).first + 2;
210 >    std::vector<int>::const_iterator secIt  = (*whIt).second.begin();
211 >    std::vector<int>::const_iterator secEnd = (*whIt).second.end();
212 >    for(;secIt!=secEnd;++secIt) {
213 >      int isec = (*secIt);
214 >
215 >     // Occupancies
216 >      stringstream histoNameOcc; histoNameOcc << "hDigiXY_" << Whname[iw] << "_S" << isec;
217 >      DigiXYS[iw][isec-1]=getHisto<TH2F>(histoNameOcc.str());
218 >      for(int ich=1;ich<5;++ich){
219 >        for(int isl=1;isl<4;++isl){
220 >          for(int il=1;il<5;++il){
221 >            // Create and fill individual layer occupancy plots from hDigiXY_S
222 >            stringstream histoNameOccup;  histoNameOccup  << "Occup_" << Whname[iw] << "_S" << isec << "_MB" << ich << "_SL" << isl << "_L" <<il;
223 >            stringstream histoTitleOccup; histoTitleOccup << "Occupancy  " << Whname[iw] << " S" << isec << " MB" << ich << " SL" << SLname[isl-1] << "L" << il;
224 >            DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]= new TH1F(histoNameOccup.str().c_str(),histoTitleOccup.str().c_str(),100, 0.,100.);
225 >            // TBoxes
226 >            stringstream histoNameTBox; histoNameTBox << "htime_" << Whname[iw] << "_S" << isec << "_MB" << ich << "_SL" << isl << "_L" << il;
227 >            TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]=getHisto<TH1F>(histoNameTBox.str());
228 >          }
229 >        }
230 >        // Correlated Triggers
231 >        for(int iq=4;iq<7;iq++){
232 >          stringstream histoNameTrQual; histoNameTrQual << "hTrigBX_" << Whname[iw] << "_S" << isec << "_MB" << ich << "_qual" << iq;
233 >          //Correlated_trig_Bx[iw][isec-1][ich-1][iq-4]=getHisto<TH1F>(histoNameTrQual.str());
234 >        }
235 >        // Trig Eff
236 >        stringstream htag; htag << "_" << Whname[iw] << "_S" << isec << "_MB" << ich;
237 >        stringstream heffden; heffden << "hTrg_effdenum" << htag.str();
238 >        //hTrg_effdenum_SecMB[iw][isec-1][ich-1]=getHisto<TH1F>(heffden.str());
239 >        stringstream heffnum; heffnum  << "hTrg_effnum" << htag.str();
240 >        //hTrg_effnum_SecMB[iw][isec-1][ich-1]=getHisto<TH1F>(heffnum.str());
241 >        stringstream phihl; phihl << "hPhiHL" << htag.str();
242 >        //hPhiHL_SecMB[iw][isec-1][ich-1]=getHisto<TH1F>(phihl.str());
243  
244 <   TH1F * TriggerInclusive[5];
288 <   for(int iw=0;iw<5;iw++){
289 <     stringstream histoname; histoname << "TriggerInclusive" << Whname[iw];
290 <     TriggerInclusive[iw]=getHisto<TH1F>(histoname.str());
291 <   }
244 >      }
245  
246 <   //===================================================================================
294 <   //    DIGI's occupancies
295 <   //===================================================================================
296 <
297 <   edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing  DIGI's occupancies per layer in 1 single page per Sector" << endl;
298 <   for(int iw=0;iw<5;iw++){ //Loop on wheels
299 <     for(int isec=1;isec<15;isec++){ // Loop on sectors
246 >      int nbx= DigiXYS[iw][isec-1]->GetNbinsX() ;
247  
248 <       TCanvas *Digi = new TCanvas("Digi", "",201,81,999,699);  
249 <       Digi->Divide(3,4) ;
248 >      for(int ich=1;ich<5;ich++){
249 >        for(int isl=1;isl<4;isl++){
250 >          for(int il=1;il<5;il++){
251 >            int iby=(ich-1)*20+(isl-1)*4+il+1;
252 >            float totentr=0;
253 >            for(int ibx=1;ibx<nbx;ibx++){
254 >              float yval=DigiXYS[iw][isec-1]->GetBinContent(ibx,iby);
255 >              DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetBinContent(ibx,yval);
256 >              totentr+=yval;
257 >            }
258 >            DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetEntries(totentr);
259 >          }
260 >        }
261 >      }
262  
263 <       for(int ich=1;ich<5;ich++){
264 <         for(int isl=1;isl<4;isl++){
265 <           bool dodraw=1;
307 <           if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
308 <           if(dodraw){
309 <             // look first for the maximum bin entries
310 <             first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
311 <             float nbmax=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
312 <             for(int il=2;il<5;il++){
313 <               float nbmax0=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
314 <               if(nbmax0>nbmax){
315 <                 first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
316 <                 nbmax=nbmax0;
317 <               }
318 <               DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
319 <             }
320 <             stringstream htitle; htitle << "Occupancy W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
321 <             first_to_paint->SetTitle(htitle.str().c_str());
322 <             int icpos=(ich-1)*3+isl;
323 <             Digi->cd(icpos) ;
324 <             Digi->cd(icpos)->SetLogy();
325 <             first_to_paint->GetYaxis()->SetLabelSize(0.07);
326 <             first_to_paint->GetXaxis()->SetLabelSize(0.07);
327 <             first_to_paint->Draw();
328 <             for(int il=1;il<5;il++){
329 <               DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
330 <             }
331 <           }
332 <         }
333 <       }
263 >      // Trigger matrix
264 >      stringstream histoNameTrMatrix; histoNameTrMatrix << "TriggerMatrix" << Whname[iw] << "_S" << isec;
265 >      //TriggerMatrix[iw][isec-1]=getHisto<TH1F>(histoNameTrMatrix.str());
266  
267 <       createGifFile("Occupancies_LogScale",iw-2,isec,"",Digi);
268 <       delete Digi;
269 <     }
270 <   }// End Loop on sectors
267 >    }
268 >    // Trigger Inclusive
269 >    stringstream histoNameTrInclusive; histoNameTrInclusive << "TriggerInclusive" << Whname[iw];
270 >    TriggerInclusive[iw]=getHisto<TH1F>(histoNameTrInclusive.str());
271 >    for (int isec=1;isec<13;++isec) {
272 >      for (int ibin=1; ibin<5; ibin++) {
273 >        stringstream hlabel; hlabel << "S" << isec << "MB" << ibin;
274 >        TriggerInclusive[iw]->GetXaxis()->SetBinLabel((isec-1)*5+ibin,hlabel.str().c_str());
275 >      }
276 >      TriggerInclusive[iw]->GetXaxis()->SetBinLabel(isec*5," ");
277 >    }  
278 >  }
279  
280 +  whIt  = mySectors.begin();
281 +  whEnd = mySectors.end();
282 +  for(;whIt!=whEnd;++whIt) {
283 +    int iw = (*whIt).first + 2;
284 +    std::vector<int>::const_iterator secIt  = (*whIt).second.begin();
285 +    std::vector<int>::const_iterator secEnd = (*whIt).second.end();
286 +    for(;secIt!=secEnd;++secIt) {
287 +      int isec = (*secIt);
288 +
289 +      //===================================================================================
290 +      //    DIGI's occupancies
291 +      //===================================================================================
292 +      edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing DIGI's occupancies per layer in 1 single page per Sector wh "
293 +                                        << (iw-2) << " sec " << isec << endl;
294  
295 <   //===================================================================================
296 <   //    DIGI's occupancies
343 <   //    now print 1 page per SL
344 <   //===================================================================================
295 >      TCanvas *Digi = new TCanvas("Digi", "",201,81,999,699);  
296 >      Digi->Divide(3,4) ;
297  
298 <   edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing DIGI's occupancies  per layer in 1 single page per SL" << endl;
299 <   for(int iw=0;iw<5;iw++){ //Loop on wheels
300 <     for(int isec=1;isec<15;isec++){ // Loop on sectors
298 >      for(int ich=1;ich<5;ich++){
299 >        for(int isl=1;isl<4;isl++){
300 >          bool dodraw=1;
301 >          if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
302 >          if(dodraw){
303 >            // look first for the maximum bin entries
304 >            first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
305 >            float nbmax=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
306 >            for(int il=2;il<5;il++){
307 >              float nbmax0=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
308 >              if(nbmax0>nbmax){
309 >                first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
310 >                nbmax=nbmax0;
311 >              }
312 >              DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
313 >            }
314 >            stringstream htitle; htitle << "Occupancy W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
315 >            first_to_paint->SetTitle(htitle.str().c_str());
316 >            int icpos=(ich-1)*3+isl;
317 >            Digi->cd(icpos) ;
318 >            Digi->cd(icpos)->SetLogy();
319 >            first_to_paint->GetYaxis()->SetLabelSize(0.07);
320 >            first_to_paint->GetXaxis()->SetLabelSize(0.07);
321 >            first_to_paint->Draw();
322 >            for(int il=1;il<5;il++){
323 >              DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
324 >            }
325 >          }
326 >        }
327 >      }
328 >      createGifFile("Occupancies_LogScale",iw-2,isec,"",Digi);
329 >      delete Digi;
330  
331 <       int ichmin=1; if (isec==13|| isec==14)ichmin=4;
332 <       for(int ich=ichmin;ich<5;ich++){
333 <         for(int isl=1;isl<4;isl++){
334 <           TCanvas *DigiSL = new TCanvas("DigiSL", "",201,81,999,699);  
335 <           bool dodraw=1;
336 <           if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
337 <           if(dodraw){
338 <             // look first for the maximum bin entries
339 <             first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
340 <             float nbmax=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
341 <             for(int il=2;il<5;il++){
342 <               float nbmax0=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
343 <               if(nbmax0>nbmax){
344 <                 first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
345 <                 nbmax=nbmax0;
346 <               }
347 <               DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
348 <             }
349 <             stringstream htitle;  htitle << "Occupancy W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
350 <             first_to_paint->SetTitle(htitle.str().c_str());
351 <             //int icpos=(ich-1)*3+isl;
352 <             first_to_paint->GetYaxis()->SetLabelSize(0.05);
353 <             first_to_paint->GetXaxis()->SetLabelSize(0.05);
354 <             first_to_paint->Draw();
355 <             for(int il=1;il<5;il++){
356 <               DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
357 <             }
331 >      //===================================================================================
332 >      //    DIGI's occupancies
333 >      //    now print 1 page per SL
334 >      //===================================================================================
335 >      edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing DIGI's occupancies  per layer in 1 single page per SL wh "
336 >                                        << (iw-2) << " sec " << isec << endl;
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++){
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();
347 >            for(int il=2;il<5;il++){
348 >              float nbmax0=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
349 >              if(nbmax0>nbmax){
350 >                first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
351 >                nbmax=nbmax0;
352 >              }
353 >              DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
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());
357 >            first_to_paint->GetYaxis()->SetLabelSize(0.05);
358 >            first_to_paint->GetXaxis()->SetLabelSize(0.05);
359 >            first_to_paint->Draw();
360 >            for(int il=1;il<5;il++){
361 >              DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
362 >            }
363              
364 <             stringstream fileTag; fileTag << "_MB" << ich << "_SL" << SLname[isl-1];
365 <             createGifFile("Occupancies",(iw-2),isec,fileTag.str(),DigiSL);
366 <             delete DigiSL;
367 <           }
364 >            stringstream fileTag; fileTag << "_MB" << ich << "_SL" << SLname[isl-1];
365 >            createGifFile("Occupancies",(iw-2),isec,fileTag.str(),DigiSL);
366 >            delete DigiSL;
367 >          }
368            
369 <         }//end Loop Superlayers
370 <       }//end Loop chambers
385 <     }// End Loop on sectors
386 <   }// End Loop on wheels
369 >        }//end Loop Superlayers
370 >      }//end Loop chambers
371  
372 +      //====================================================================================
373 +      //    Time boxes: all in 1 single page (Layer granularity)
374 +      //===================================================================================
375 +      edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing Time boxes per layer in 1 single page per Sector wh "
376 +                                        << (iw-2) << " sec " << isec << endl;
377 +      TCanvas *Tboxes = new TCanvas("Tboxes", "",201,81,999,699);
378 +      Tboxes->Divide(3,4) ;
379  
380 <   //====================================================================================
381 <   //    Time boxes: all in 1 single page (Layer granularity)
382 <   //===================================================================================
383 <  
384 <   edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing Time boxes per layer in 1 single page per Sector" << endl;
385 <   //for(int isec=1;isec<15;isec++) // Loop on sectors
386 <   for(int iw=0;iw<5;iw++){ //Loop on wheels
387 <     for(int isec=1;isec<15;isec++){ // Loop on sectors
388 <      
389 <       TCanvas *Tboxes = new TCanvas("Tboxes", "",201,81,999,699);
390 <       Tboxes->Divide(3,4) ;
391 <
392 <       for(int ich=1;ich<5;ich++){
393 <         for(int isl=1;isl<4;isl++){
394 <           bool dodraw=1;
395 <           if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
396 <           if(dodraw){
397 <               // look first for the maximum bin entries
398 <               first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
399 <               float nbmax=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
400 <               for(int il=2;il<5;il++){
401 <                 float nbmax0=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
402 <                 if(nbmax0>nbmax){
403 <                   first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
404 <                   nbmax=nbmax0;
405 <                 }
406 <                 TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
407 <               }
408 <               stringstream htitle; htitle << "TimeBox W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
418 <               first_to_paint->SetTitle(htitle.str().c_str());
419 <               int icpos=(ich-1)*3+isl;
420 <               Tboxes->cd(icpos) ;
421 <               first_to_paint->GetYaxis()->SetLabelSize(0.07);
422 <               first_to_paint->GetXaxis()->SetLabelSize(0.07);
423 <               first_to_paint->Draw();
424 <               for(int il=1;il<5;il++){
425 <                 TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
426 <               }
427 <           }
428 <         }
429 <       }
380 >      for(int ich=1;ich<5;ich++){
381 >        for(int isl=1;isl<4;isl++){
382 >          bool dodraw=1;
383 >          if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
384 >          if(dodraw){
385 >            // look first for the maximum bin entries
386 >            first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
387 >            float nbmax=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
388 >            for(int il=2;il<5;il++){
389 >              float nbmax0=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
390 >              if(nbmax0>nbmax){
391 >                first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
392 >                nbmax=nbmax0;
393 >              }
394 >              TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
395 >            }
396 >            stringstream htitle; htitle << "TimeBox W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
397 >            first_to_paint->SetTitle(htitle.str().c_str());
398 >            int icpos=(ich-1)*3+isl;
399 >            Tboxes->cd(icpos) ;
400 >            first_to_paint->GetYaxis()->SetLabelSize(0.07);
401 >            first_to_paint->GetXaxis()->SetLabelSize(0.07);
402 >            first_to_paint->Draw();
403 >            for(int il=1;il<5;il++){
404 >              TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
405 >            }
406 >          }
407 >        }
408 >      }
409    
410 <       createGifFile("Tboxes",(iw-2),isec,"",Tboxes);
411 <       delete Tboxes;
433 <     }// End Loop on sectors
434 <   }// End Loop on wheels
410 >      createGifFile("Tboxes",(iw-2),isec,"",Tboxes);
411 >      delete Tboxes;
412  
413 <
414 <   //===================================================================================
415 <   //    Time boxes: 1 page per SL
416 <   //===================================================================================
417 <  
418 <   edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing Time boxes per layer in 1 single page per SL" << endl;
419 <   for(int iw=0;iw<5;iw++){ //Loop on wheels
420 <     for(int isec=1;isec<15;isec++){ // Loop on sectors
444 <      
445 <       int ichmin=1; if (isec==13|| isec==14)ichmin=4;
446 <       for(int ich=ichmin;ich<5;ich++){
447 <         for(int isl=1;isl<4;isl++){
448 <           TCanvas *TboxSL = new TCanvas("TboxSL", "",201,81,999,699);
413 >      //===================================================================================
414 >      //    Time boxes: 1 page per SL
415 >      //===================================================================================
416 >      edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing Time boxes per layer in 1 single page per SL wh "
417 >                                        << (iw-2) << " sec " << isec << endl;
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++){
421            
422 <           bool dodraw=1;
423 <           if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
424 <           if(dodraw){
425 <             // look first for the maximum bin entries
426 <             first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
427 <             float nbmax=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
428 <             for(int il=2;il<5;il++){
429 <               float nbmax0=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
430 <               if(nbmax0>nbmax){
431 <                 first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
432 <                 nbmax=nbmax0;
433 <               }
434 <               TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
435 <             }
436 <             stringstream htitle; htitle << "TimeBox W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
437 <             first_to_paint->SetTitle(htitle.str().c_str());
438 <             first_to_paint->GetYaxis()->SetLabelSize(0.04);
439 <             first_to_paint->GetXaxis()->SetLabelSize(0.04);
440 <             first_to_paint->Draw();
441 <             for(int il=1;il<5;il++){
442 <               TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
443 <             }
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();
429 >            for(int il=2;il<5;il++){
430 >              float nbmax0=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
431 >              if(nbmax0>nbmax){
432 >                first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
433 >                nbmax=nbmax0;
434 >              }
435 >              TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
436 >            }
437 >            stringstream htitle; htitle << "TimeBox W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
438 >            first_to_paint->SetTitle(htitle.str().c_str());
439 >            first_to_paint->GetYaxis()->SetLabelSize(0.04);
440 >            first_to_paint->GetXaxis()->SetLabelSize(0.04);
441 >            first_to_paint->Draw();
442 >            for(int il=1;il<5;il++){
443 >              TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
444 >            }
445              
446 <             stringstream fileTag; fileTag << "_MB" << ich << "_SL" << SLname[isl-1];
447 <             createGifFile("Tboxes",(iw-2),isec,fileTag.str(),TboxSL);
448 <             delete TboxSL;
449 <           }
450 <         }//end loop SL      
451 <       }//end loop chambers
479 <     }// End Loop on sectors
480 <   } // End Loop on wheels
481 <
482 <
483 <   //===================================================================================
484 <   //    Trigger: Summary & BX profile
485 <   //===================================================================================
486 <  
487 <   edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing single chamber BX profiles per Sector" << endl;
488 <   // BX profiles:
489 <   for(int iw=0;iw<5;iw++){ //Loop on wheels
490 <     for(int isec=1;isec<15;isec++){ // Loop on sectors
491 <      
492 <       if(isec <13){
493 <         TCanvas *Trigg = new TCanvas("Trigg", "",201,81,999,699);
494 <         Trigg->Divide(2,2) ;
495 <         for(int ich=1;ich<5;ich++){
496 <           Trigg->cd(ich) ;
497 <           Trigg->cd(ich)->SetLogy();
498 <           Correlated_trig_Bx[iw][isec-1][ich-1][2]->GetXaxis()->SetTitle("BX id");
499 <           stringstream htitle; htitle << "llHlHH_trig_bxMB"<< ich;
500 <           Correlated_trig_Bx[iw][isec-1][ich-1][2]->SetTitle(htitle.str().c_str());
501 <           Correlated_trig_Bx[iw][isec-1][ich-1][2]->GetXaxis()->SetTitleSize(0.05);
502 <           Correlated_trig_Bx[iw][isec-1][ich-1][2]->GetXaxis()->SetLabelSize(0.05);
503 <           Correlated_trig_Bx[iw][isec-1][ich-1][2]->GetXaxis()->SetLabelSize(0.05);
504 <           Correlated_trig_Bx[iw][isec-1][ich-1][2]->Draw();
505 <           Correlated_trig_Bx[iw][isec-1][ich-1][1]->SetLineColor(2);
506 <           Correlated_trig_Bx[iw][isec-1][ich-1][1]->Draw("same");
507 <           Correlated_trig_Bx[iw][isec-1][ich-1][0]->SetLineColor(3);
508 <           Correlated_trig_Bx[iw][isec-1][ich-1][0]->Draw("same");
509 <         }// end loop on chambers
510 <         createGifFile("Trigger_Summary",(iw-2),isec,"",Trigg);
511 <         delete Trigg;
512 <       }
513 <     }// end loop on sectors
514 <   }// end loop on wheels
515 <
516 <
517 <   //===================================================================================
518 <   //    Trigger: HH&HL efficiencies
519 <   //===================================================================================
520 <   edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing HH&HL efficiencies" << endl;
521 <   TH1F *heffTrgSecMB[5][14][4];
522 <   for(int iw=0;iw<5;iw++){ //Loop on wheels
523 <     for(int isec=1;isec<15;isec++){ // Loop on sectors
524 <       if(isec <13){
525 <         TCanvas *EffTrg = new TCanvas("EffTrg", "",201,81,999,699);
526 <         EffTrg->Divide(2,4); // divide canvas in 2 columns, 4 raws
527 <         for(int ich=1;ich<5;ich++){
528 <           stringstream histoname; histoname << "heffTrgSec" << isec << "MB" << ich;
529 <           heffTrgSecMB[iw][isec-1][ich-1] =(TH1F*)hTrg_effnum_SecMB[iw][isec-1][ich-1]->Clone(histoname.str().c_str());
530 <           heffTrgSecMB[iw][isec-1][ich-1]->Divide(hTrg_effnum_SecMB[iw][isec-1][ich-1]
531 <                                                   ,hTrg_effdenum_SecMB[iw][isec-1][ich-1],1.0,1.0);
532 <           heffTrgSecMB[iw][isec-1][ich-1]->SetMaximum(1.1);
533 <           heffTrgSecMB[iw][isec-1][ich-1]->SetMinimum(0.);
534 <           heffTrgSecMB[iw][isec-1][ich-1]->GetXaxis()->SetLabelSize(0.05);
535 <           heffTrgSecMB[iw][isec-1][ich-1]->GetYaxis()->SetLabelSize(0.05);
536 <           for (int i = 0; i <= hTrg_effdenum_SecMB[iw][isec-1][ich-1]->GetNbinsX()+1; i++ ) {
537 <             Float_t tot   = hTrg_effdenum_SecMB[iw][isec-1][ich-1]->GetBinContent(i) ;
538 <             Float_t tot_e = hTrg_effdenum_SecMB[iw][isec-1][ich-1]->GetBinError(i);
539 <             Float_t eff = heffTrgSecMB[iw][isec-1][ich-1]->GetBinContent(i) ;
540 <             Float_t Err = 0.;
541 <             if (tot > 0) Err = tot_e / tot * sqrt( eff* (1-eff) );
542 <             // if (eff == 1. || isnan(Err) || !isfinite(Err) ) Err=1.e-3;
543 <             heffTrgSecMB[iw][isec-1][ich-1]->SetBinError(i, Err);
544 <           }
545 <        
546 <           EffTrg->cd((ich-1)*2+1);  
547 <           heffTrgSecMB[iw][isec-1][ich-1]->Draw();
548 <           EffTrg->cd((ich-1)*2+2);  
549 <           hPhiHL_SecMB[iw][isec-1][ich-1]->Draw();
550 <         }
551 <        
552 <         createGifFile("TriggEff_HH&HL",(iw-2),isec,"",EffTrg);
553 <         delete EffTrg;
554 <       }
555 <
556 <     }// End loop on sectors
557 <   }// End loop on wheels
558 <
559 <
560 <   //===================================================================================
561 <   //    Trigger: TriggerMatrix
562 <   //===================================================================================
563 <  
564 <   edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing TriggerMatrix" << endl;
565 <
566 <   char * labTriggerMatrix[]={"no trig"," ","MB1","MB2","MB3","MB4"," ","1 & 2","1 & 3","1 & 4","2 & 3","2 & 4",
567 <                              "3 & 4"," ","1 & 2 & 3","1 & 2 & 4","1 & 3 & 4","2 & 3 & 4"," ","1 & 2 & 3 & 4"};
568 <   for(int iw=0;iw<5;iw++){ //Loop on wheels
569 <     for(int isec=1;isec<15;isec++){ // Loop on sectors
570 <       if(isec <13){
571 <         for (int ibin=1; ibin<21; ibin++) TriggerMatrix[iw][isec-1]->GetXaxis()->SetBinLabel(ibin,labTriggerMatrix[ibin-1]);
572 <         nbin = TriggerMatrix[iw][isec-1]->GetXaxis()->GetNbins();
573 <         max = 0;
574 <         TCanvas *Trigmatri = new TCanvas("TriggerMatrix", "",201,81,999,699);
575 <         Trigmatri->SetBottomMargin(0.12);
576 <      
577 <         for (int ibin=1; ibin<nbin+1; ibin++)
578 <           max = (max > TriggerMatrix[iw][isec-1]->GetBinContent(ibin) ) ? max : TriggerMatrix[iw][isec-1]->GetBinContent(ibin) ;
579 <         max1=max*1.3;
580 <      
581 <         TriggerMatrix[iw][isec-1]->GetXaxis()->SetLabelOffset(0.043);
582 <         // TriggerMatrix[iw][isec-1]->GetXaxis()->SetLabelOffset(-0.01);
583 <         // TriggerMatrix[iw][isec-1]->LabelsOption("v");
584 <         // TriggerMatrix[iw][isec-1]->GetXaxis()->SetLabelSize(0.04);
585 <      
586 <         TriggerMatrix[iw][isec-1]->SetMaximum(max1);
587 <         TriggerMatrix[iw][isec-1]->Draw();
588 <      
589 <         //sid = new TPaveText (-0.5,max1-(max1-max)/2,5,max1);
590 <         //sprintf (sid1,"YB%i, Sector %u, run %u",wheel, isec, run);
591 <         //sid->AddText(sid1);
592 <         //sid->Draw();
593 <      
594 <         for (int ibin=1; ibin<nbin+1; ibin++) {
595 <           if (ibin == 2 || ibin == 7 ||  ibin == 14 ||  ibin == 19) continue;
596 <           float x1 = TriggerMatrix[iw][isec-1]->GetBinCenter(ibin) - TriggerMatrix[iw][isec-1]->GetBinWidth(ibin)/2;
597 <           float x2 = TriggerMatrix[iw][isec-1]->GetBinCenter(ibin) + TriggerMatrix[iw][isec-1]->GetBinWidth(ibin)/2;
598 <           float y1 = max + (max1-max)/8;
599 <           float y2 = max1 - (max1-max)/2;
600 <           labcont[ibin-1] = new TPaveText (x1,y1,x2,y2);
601 <          
602 <           char contbin[6];
603 <           sprintf (contbin,"%u",int(TriggerMatrix[iw][isec-1]->GetBinContent(ibin)));
604 <           //  labcont[ibin-1]->AddText(cont[ibin-1]);
605 <      
606 <           cont[ibin-1] = labcont[ibin-1]->AddText (contbin);
607 <           //    isme.SetTextAngle(90.);
608 <           cont[ibin-1]->SetTextSize(0.02);
609 <           labcont[ibin-1]->Draw();
610 <         }
611 <      
612 <         createGifFile("TriggerMatrix",(iw-2),isec,"",Trigmatri);
613 <         delete Trigmatri;
614 <       }
615 <
616 <     }// End loop on sectors
617 <   }// End loop on wheels
618 <
619 <
620 <   //===================================================================================
621 <   //    Trigger: TriggerInclusive
622 <   //===================================================================================
623 <
624 <   //=======   ALL   SECTORS             ===============================================
625 <   edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing TriggerInclusive Sector by Sector" << endl;
626 <   for(int iw=0;iw<5;iw++){ //Loop on wheels
627 <     for (int ise=1; ise<13; ise++) { //Set TriggerInclusive Labels
628 <       for (int ibin=1; ibin<5; ibin++) {
629 <         stringstream hlabel; hlabel << "S" << ise << "MB" << ibin;
630 <         TriggerInclusive[iw]->GetXaxis()->SetBinLabel((ise-1)*5+ibin,hlabel.str().c_str());
631 <       }
632 <       TriggerInclusive[iw]->GetXaxis()->SetBinLabel(ise*5," ");
633 <     }
634 <     TCanvas *Trigmatri = new TCanvas("TriggerMatrix", "",201,81,999,699);
635 <     Trigmatri->SetBottomMargin(0.12);
636 <
637 <     nbin = TriggerInclusive[iw]->GetXaxis()->GetNbins();
638 <     max = 0;
446 >            stringstream fileTag; fileTag << "_MB" << ich << "_SL" << SLname[isl-1];
447 >            createGifFile("Tboxes",(iw-2),isec,fileTag.str(),TboxSL);
448 >            delete TboxSL;
449 >          }
450 >        }//end loop SL      
451 >      }//end loop chambers
452  
453 <     for (int ibin=1; ibin<nbin+1; ibin++)
454 <       max = (max > TriggerInclusive[iw]->GetBinContent(ibin) ) ? max : TriggerInclusive[iw]->GetBinContent(ibin) ;
642 <     max1=max*1.3;
643 <     TriggerInclusive[iw]->SetMaximum(max1);
644 <     TriggerInclusive[iw]->GetXaxis()->SetLabelSize(0.035);
645 <     TriggerInclusive[iw]->Draw();
646 <    
647 <     sid = new TPaveText (0,max1-(max1-max)/2,2,max1);
648 <  
649 <     //cout <<" --> wheel, sector, run "; cin >>wheel>>sector>>run;
650 <     stringstream chname; chname << "YB," << (iw-2) <<",";
651 <     sid->AddText(chname.str().c_str());
652 <     sid->Draw();
653 <    
654 <     createGifFile("TriggerInclusive",(iw-2),"",Trigmatri);
655 <     delete Trigmatri;
656 <   }
657 <
658 <   //=======   SECTOR By SECTOR             ============================================
659 <   edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing TriggerInclusive Sector by Sector" << endl;
660 <   for(int iw=0;iw<5;iw++){ //Loop on wheels
661 <     for(int isec=1;isec<15;isec++){ // Loop on sectors
662 <       if(isec<13){
663 <        TCanvas *TrigmatriSec = new TCanvas("TriggerInclusive[iw]", "",201,81,999,699);
664 <        TrigmatriSec->SetBottomMargin(0.12);
665 <        
666 <        int ibin_init=(isec-1)*5+1;
667 <        int xpos_init=(isec-1)*5+1;
668 <
669 <        max = 0;
670 <        for (int ibin=ibin_init; ibin<ibin_init+5; ibin++)
671 <          max = (max > TriggerInclusive[iw]->GetBinContent(ibin) ) ? max : TriggerInclusive[iw]->GetBinContent(ibin) ;
672 <        max1=max*1.3;
673 <
674 <        TriggerInclusive[iw]->GetXaxis()->SetRange(xpos_init,xpos_init+4);
675 <        TriggerInclusive[iw]->GetXaxis()->SetLabelSize(0.07);
676 <        TriggerInclusive[iw]->SetMaximum(max1);
677 <        TriggerInclusive[iw]->Draw();
678 <        
679 <        sid = new TPaveText (0,max1-(max1-max)/2,2,max1);
680 <        for (int ibin=ibin_init; ibin<ibin_init+4; ibin++) {
681 <          
682 <          float x1 = TriggerInclusive[iw]->GetBinCenter(ibin) - TriggerInclusive[iw]->GetBinWidth(ibin)/2;
683 <          float x2 = TriggerInclusive[iw]->GetBinCenter(ibin) + TriggerInclusive[iw]->GetBinWidth(ibin)/2;
684 <          float y1 = max + (max1-max)/8;
685 <          float y2 = max1 - (max1-max)/2;
686 <          labcont[ibin-1] = new TPaveText (x1,y1,x2,y2);
687 <          
688 <          char contbin[6];
689 <          sprintf (contbin,"%u",int(TriggerInclusive[iw]->GetBinContent(ibin)));
690 <          //  labcont[ibin-1]->AddText(cont[ibin-1]);
691 <      
692 <          cont[ibin-1] = labcont[ibin-1]->AddText (contbin);
693 <          //    isme.SetTextAngle(90.);
694 <          cont[ibin-1]->SetTextSize(0.04);
695 <          labcont[ibin-1]->Draw();
696 <          
697 <        }
453 >    }
454 >  }//end Loop on sectors/wheels
455  
699        createGifFile("TriggerInclusive",(iw-2),isec,"",TrigmatriSec);
700        delete TrigmatriSec;
701      }
702    }// End loop on sectors
703  }// End loop on wheels
704  
456   }
457  
707
458   void DTDPGCreateAnalyzerSummary::createSummaryWheelPlots() {
459  
460    string Whname[5]={"Wm2","Wm1","W0","W1","W2"};
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    
719  gStyle->SetOptStat(10);
720  gStyle->SetStatY(0.97);
721  gStyle->SetStatX(0.98);
722  gStyle->SetStatW(0.35);
723  gStyle->SetStatH(0.45);
724
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  
731  float BXSummary_mean=0.;
732  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 745 | 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;
751   //===================================================================================
506     //    Digi scatter plots
753   //===================================================================================
507     TCanvas *DQM1 = new TCanvas("DQM1", "",201,81,999,699);
508     DQM1->Divide(2,3) ;
509     TCanvas *DQM1b = new TCanvas("DQM1b", "",201,81,999,699);
# Line 759 | 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  
792    stringstream fileDigi; fileDigi <<"Digi_r" << myRunNumber <<"_W" << (iw-2);
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);
585        createGifFile("Digi",(iw-2),"_S7-S12_b",DQM2b);
586      }
587  
588 <    //===================================================================================
811 <    //    Ocupancies per SL
812 <    //===================================================================================
813 <    
588 >    //    Ocupancies per SL    
589      // Get histos to be plotted
590 <    int nbin;
591 <    float max, max1;
592 <    TPaveText *sid;
818 <    char sid1[50]; char answ;
819 <    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 844 | 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 870 | Line 645 | void DTDPGCreateAnalyzerSummary::createS
645            }
646          }
647        }
648 +     }
649      }// end loop sector
650  
651 <    //===================================================================================
652 <    //    DIGI's occupancies
653 <    //===================================================================================
654 <
879 <    TCanvas *Digi1 = new TCanvas("Digi1", "",201,81,999,699);  
880 <    TCanvas *Digi2 = new TCanvas("Digi2", "",201,81,999,699);  
881 <    TCanvas *Digi3 = new TCanvas("Digi3", "",201,81,999,699);  
882 <    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
890 <            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);
896 <          }
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 <    //===================================================================================
712 >  gStyle->SetTitleX(0.01);
713 >  gStyle->SetTitleY(0.99);
714 >  gStyle->SetTitleW(0.97);
715 >  gStyle->SetTitleH(0.1);
716 >
717      //    TimeBoxes        
718 <    //===================================================================================
719 <    DQM1->Clear();
720 <    DQM1->Divide(6,2) ;
721 <    for (int ins=1; ins<13;ins++){
722 <      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  
960    //===================================================================================
821      //    Hit Residuals        
962    //===================================================================================
822      DQM1->Clear();
823      DQM1->Divide(6,2) ;
824  
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 987 | 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 999 | 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);
867      
1006    //===================================================================================
868      //    Angle Phi LOCAL
1008    //===================================================================================
869      DQM1->Clear();
870      DQM1->Divide(6,2) ;
871  
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 1032 | 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 1049 | Line 911 | void DTDPGCreateAnalyzerSummary::createS
911  
912      createGifFile("PhiLocal",(iw-2),"",DQM1);
913  
1052    //===================================================================================
914      //    STA Digis              
1054    //===================================================================================
915      DQM1->Clear();
916      
917      stringstream hnameSTADigi; hnameSTADigi << "hHitsPosXYSA_" << Whname[iw];
1058    TH1F *hXYHisto=getHisto<TH1F>(hnameSTADigi.str());;
1059    
1060    hXYHisto->SetStats(0);
1061    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  
1067    //===================================================================================
933      //    STA Phi Hits    
1069    //===================================================================================
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  
1099    TLine * l;
1100    l = new TLine(-165, 0, -165, ymax); l->Draw();
1101    l = new TLine(-135, 0, -135, ymax); l->Draw();
1102    l = new TLine(-105, 0, -105, ymax); l->Draw();
1103    l = new TLine( -75, 0,  -75, ymax); l->Draw();
1104    l = new TLine( -45, 0,  -45, ymax); l->Draw();
1105    l = new TLine( -15, 0,  -15, ymax); l->Draw();
1106    l = new TLine(  15, 0,   15, ymax); l->Draw();
1107    l = new TLine(  45, 0,   45, ymax); l->Draw();
1108    l = new TLine(  75, 0,   75, ymax); l->Draw();
1109    l = new TLine( 105, 0,  105, ymax); l->Draw();
1110    l = new TLine( 135, 0,  135, ymax); l->Draw();
1111    l = new TLine( 165, 0,  165, ymax); l->Draw();
1112
1113    l = new TLine( -40, 0.8*ymax,  -20, 0.8*ymax); l->Draw();
1114    l->SetLineColor(1);
1115    l->Draw();
1116    TPaveLabel * box = new TPaveLabel(-10,0.8*ymax,5,0.85*ymax,"MB1");
1117    box->Draw();
1118
1119    l = new TLine( -40, 0.7*ymax,  -20, 0.7*ymax); l->Draw();
1120    l->SetLineColor(2);
1121    l->Draw();
1122    box = new TPaveLabel(-10,0.7*ymax,5,0.75*ymax,"MB2");
1123    box->Draw();
1124
1125    l = new TLine( -40, 0.6*ymax,  -20, 0.6*ymax); l->Draw();
1126    l->SetLineColor(3);
1127    l->Draw();
1128    box = new TPaveLabel(-10,0.6*ymax,5,0.65*ymax,"MB3");
1129    box->Draw();
1130    
1131    l = new TLine( -40, 0.5*ymax,  -20, 0.5*ymax); l->Draw();
1132    l->SetLineColor(4);
1133    l->Draw();
1134    box = new TPaveLabel(-10,0.5*ymax,5,0.55*ymax,"MB4");
1135    box->Draw();
1136    
1137    createGifFile("STAPhiHits",(iw-2),"",DQM6);
1138
1139
1140    //===================================================================================
1026      //    STA Hits    
1142    //===================================================================================
1027      DQM1->Clear();
1028      DQM1->Divide(6,2) ;
1029  
# Line 1147 | 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 1160 | 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  
1170    //===================================================================================
1061      //    Segment Hits    
1172    //===================================================================================
1062      DQM2->Clear();
1063      DQM2->Divide(6,2);
1064  
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 1196 | 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 1207 | 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 <    //===================================================================================
1107 >
1108      //    Segment Hits    
1218    //===================================================================================
1109      DQM1->Clear();
1110      DQM1->Divide(6,2);
1111      TH1F * hNsegsList[12];
# Line 1227 | 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      
1132      createGifFile("Segments",(iw-2),"",DQM1);
1133  
1241    //===================================================================================
1134      //    TMAX
1135 <    //===================================================================================
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);
# Line 1251 | 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 1277 | Line 1177 | void DTDPGCreateAnalyzerSummary::createS
1177          }
1178  
1179          hHisto[0]->SetStats(1);
1180 <        //hHisto[0]->Fit("gaus");  //CB va scommentato e wrappato!!!!
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 >        }
1189          hHisto[1]->SetLineColor(2);
1190          hHisto[1]->Draw("same");
1191        }// end loop on chambers
1192      }// end loop on sectors
1193  
1194 <    stringstream fileTMax; fileTMax << "TMax_r" << myRunNumber <<"_W" << (iw-2);
1195 <    createGifFile("TMax",(iw-2),"S1-S3",DQM11);
1196 <    createGifFile("TMax",(iw-2),"S4-S6",DQM11);
1197 <    createGifFile("TMax",(iw-2),"S7-S9",DQM11);
1198 <    createGifFile("TMax",(iw-2),"S10-S12",DQM11);
1199 <
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  
1293    //===================================================================================
1205      //    Phi-Trig Efficiency
1295    //===================================================================================
1206      TCanvas *Eff = new TCanvas("Eff", "",201,81,999,699);
1207      TH1F *hHisto[4];
1208      TH1F *hHistoTr[4];
# Line 1303 | Line 1213 | void DTDPGCreateAnalyzerSummary::createS
1213        hHisto[ic-1]= getHisto<TH1F>(hname1.str());
1214  
1215        stringstream hname2; hname2 << "heff" << ic <<"x";
1306      //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 1330 | Line 1239 | void DTDPGCreateAnalyzerSummary::createS
1239        else heffx[ic-1]->Draw("same");
1240      }
1241  
1242 <    ymax = 1.;
1243 <    l = new TLine(-165, 0, -165, ymax); l->Draw();
1244 <    l = new TLine(-135, 0, -135, ymax); l->Draw();
1245 <    l = new TLine(-105, 0, -105, ymax); l->Draw();
1246 <    l = new TLine( -75, 0,  -75, ymax); l->Draw();
1247 <    l = new TLine( -45, 0,  -45, ymax); l->Draw();
1248 <    l = new TLine( -15, 0,  -15, ymax); l->Draw();
1249 <    l = new TLine(  15, 0,   15, ymax); l->Draw();
1250 <    l = new TLine(  45, 0,   45, ymax); l->Draw();
1251 <    l = new TLine(  75, 0,   75, ymax); l->Draw();
1252 <    l = new TLine( 105, 0,  105, ymax); l->Draw();
1253 <    l = new TLine( 135, 0,  135, ymax); l->Draw();
1254 <    l = new TLine( 165, 0,  165, ymax); l->Draw();
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();
1247 >    l[3] = new TLine( -75, 0,  -75, ymax); l[3]->Draw();
1248 >    l[4] = new TLine( -45, 0,  -45, ymax); l[4]->Draw();
1249 >    l[5] = new TLine( -15, 0,  -15, ymax); l[5]->Draw();
1250 >    l[6] = new TLine(  15, 0,   15, ymax); l[6]->Draw();
1251 >    l[7] = new TLine(  45, 0,   45, ymax); l[7]->Draw();
1252 >    l[8] = new TLine(  75, 0,   75, ymax); l[8]->Draw();
1253 >    l[9] = new TLine( 105, 0,  105, ymax); l[9]->Draw();
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];
1260 >
1261 >    delete TB1;
1262 >    delete TB2;
1263 >    delete DQM1;
1264 >    delete DQM2;
1265 >    delete DQM1b;
1266 >    delete DQM2b;
1267 >    delete Digi1;
1268 >    delete Digi2;
1269 >    delete Digi3;
1270 >    delete DQM6;
1271      
1272 +    delete DQM11;
1273 +    delete DQM12;
1274 +    delete DQM13;
1275 +    delete DQM14;
1276 +
1277 +    delete Eff;
1278 +    delete ExtraS13S14;
1279 +
1280 + }// END loop in wheels
1281  
1350    //===================================================================================
1351    //    Segment Hits    
1352    //===================================================================================
1353    DQM1->Clear();
1354    DQM1->Divide(6,2) ;
1282      
1283 <    for (int ins=1; ins<13;ins++){
1284 <     TH1F *hHisto[4];
1358 <     DQM1->cd(ins);
1283 > }
1284 >  
1285  
1286 <     int nbmax=0;
1287 <     int nbmax0=0;
1286 > void DTDPGCreateAnalyzerSummary::createSummaryAllPlots() {
1287 >  string Whname[5]={"Wm2","Wm1","W0","W1","W2"};
1288  
1289 +  gStyle->SetTitleW(0.55);
1290 +  gStyle->SetTitleH(0.13);
1291 +  gStyle->SetTitleX(0.01);
1292 +  gStyle->SetTitleY(0.99);
1293 +  
1294 +  gStyle->SetOptStat(10);
1295 +  gStyle->SetStatY(0.97);
1296 +  gStyle->SetStatX(0.98);
1297 +  gStyle->SetStatW(0.35);
1298 +  gStyle->SetStatH(0.45);
1299  
1300 <     for(int ic=1;ic<5;ic++){
1301 <       stringstream hname; hname << "hTrigBits_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1302 <       hHisto[ic-1]= getHisto<TH1F>(hname.str());
1303 <       hHisto[ic-1]->SetLineColor(ic);
1304 <     }
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 <     first_to_paint = hHisto[0];
1316 <     nbmax=hHisto[0]->GetMaximum();
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 <     for(int ic=2;ic<5;ic++){
1374 <       nbmax0=hHisto[ic-1]->GetMaximum();
1375 <       if(nbmax0>nbmax){
1376 <         nbmax=nbmax0;
1377 <         first_to_paint=hHisto[ic-1];
1378 <       }
1379 <     }
1380 <     first_to_paint->GetXaxis()->SetLabelSize(0.08);
1381 <     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1382 <     first_to_paint->GetXaxis()->SetTitle("Quality");
1383 <     first_to_paint->GetXaxis()->SetTitleSize(0.09);
1384 <     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1385 <     first_to_paint->GetXaxis()->SetNdivisions(308);
1386 <     stringstream htitle; htitle << "Highest trig qual W" << (iw-2) << " S" << ins;
1387 <     first_to_paint->SetTitle(htitle.str().c_str());
1388 <    
1389 <     first_to_paint->Draw();
1390 <     for(int ic=1;ic<5;ic++)
1391 <       hHisto[ic-1]->Draw("same");
1392 <    
1393 <    }// end loop on sectors
1320 >  TH1F *DigiXSecMBSlLayer[5][14][4][3][4];
1321  
1322 <    createGifFile("TrigHighQual",(iw-2),"",DQM1);
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 <    //===================================================================================
1338 <    //   SC BX Summary    
1339 <    //===================================================================================
1340 <    TCanvas *BX = new TCanvas("BX", "",201,81,999,699);
1341 <    BX->Divide(6,2);
1342 <    for(int ins=1;ins<13;ins++){ // Loop in sectors
1343 <    
1344 <     int nbmax=0;
1345 <     int nbmax0=0;
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 <     TH1F *hHH[4];
1352 <     TH1F *hHL[4];
1353 <     BX->cd(ins);
1354 <     BX->cd(ins)->SetLogy();
1355 <     for(int ic=1;ic<5;ic++){ // Loop in chambers
1356 <    
1357 <       stringstream hname; hname << "hTrigBX_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1358 <       hHH[ic-1]= getHisto<TH1F>(hname.str()+"_qual6");
1359 <       hHL[ic-1]= getHisto<TH1F>(hname.str()+"_qual5");
1360 <
1361 <       hHH[ic-1]->Add(hHL[ic-1]);
1362 <       hHH[ic-1]->SetLineColor(ic);
1363 <       hHH[ic-1]->SetStats(0);
1364 <     } // end loop in chambers
1365 <    
1366 <     first_to_paint = hHH[0];
1367 <     nbmax=hHH[0]->GetMaximum();
1368 <     first_to_paint->Draw();
1369 <
1370 <     for(int ic=2;ic<5;ic++){
1371 <       nbmax0=hHH[ic-1]->GetMaximum();
1372 <       if(nbmax0>nbmax){
1373 <         nbmax=nbmax0;
1374 <         first_to_paint=hHH[ic-1];
1375 <       }
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 +
1392 + /*
1393 + for(int ic=0;ic<4;ic++)
1394 + {
1395 +   first_to_paint_MB[ic]=OccupMB[0][ic];
1396 +   float nbmax=0;
1397 +   nbmax=OccupMB[0][ic]->GetMaximum();
1398 +   for(int iw=0;iw<5;iw++)
1399 +   {
1400 +      float nbmax0=0;
1401 +      nbmax0=OccupMB[iw][ic]->GetMaximum();
1402 +
1403 +      if(nbmax0>nbmax)
1404 +      {
1405 +         nbmax=nbmax0; first_to_paint_MB[ic]=OccupMB[iw][ic];
1406 +      }
1407 +   }
1408 + }
1409 +
1410 + */
1411 +
1412 + float Ocmax[4]={0.,0.,0.,0};
1413 + for(int ic=0;ic<4;ic++)
1414 + {
1415 +   first_to_paint_MB[ic]=OccupMB[0][ic];
1416 +   float nbmin=9999999;
1417 +   //float nbmin00=OccupMB[0][ic]->GetMinimum();
1418 +   //if(nbmin00 > 0) nbmin=nbmin00;
1419 +   for(int iw=0;iw<5;iw++)
1420 +   {
1421 +      float nbmax0=0;
1422 +      //float nbmin0=99999999.;
1423 +      nbmax0=OccupMB[iw][ic]->GetMaximum();
1424 +      //nbmin0=OccupMB[iw][ic]->GetMinimum();
1425 +
1426 +      if(nbmax0>Ocmax[ic]) Ocmax[ic]=nbmax0;
1427 +      if(nbmax0>0 && nbmax0<nbmin)
1428 +      {
1429 +         nbmin=nbmax0; first_to_paint_MB[ic]=OccupMB[iw][ic];
1430 +      }
1431 +      //if(nbmin0>0 && nbmin0<nbmin)
1432 +     // {
1433 +      //  nbmin=nbmin0; first_to_paint_MB[ic]=OccupMB[iw][ic];
1434 +     // }
1435 +   }
1436 + }
1437 +
1438 +
1439 + for(int ic=1;ic<5;ic++)
1440 + {
1441 +   stringstream hname21; hname21 << "Total Occupancy  MB" << ic ;
1442 +   first_to_paint_MB[ic-1]->SetTitle(hname21.str().c_str());
1443 +
1444 +   first_to_paint_MB[ic-1]->GetXaxis()->SetLabelSize(0.09);
1445 +   first_to_paint_MB[ic-1]->GetXaxis()->SetTitleSize(0.09);
1446 +   first_to_paint_MB[ic-1]->GetXaxis()->SetTitleOffset(0.5);
1447 +   first_to_paint_MB[ic-1]->GetXaxis()->SetTitle("Sector   ");
1448 +   first_to_paint_MB[ic-1]->GetYaxis()->SetLabelSize(0.09);
1449 +   first_to_paint_MB[ic-1]->GetYaxis()->SetTitleSize(0.09);
1450 +   first_to_paint_MB[ic-1]->GetYaxis()->SetTitleOffset(0.5);
1451 +   first_to_paint_MB[ic-1]->GetYaxis()->SetTitle("Entries");
1452 +   first_to_paint_MB[ic-1]->SetStats(0);
1453 +   first_to_paint_MB[ic-1]->SetMaximum(Ocmax[ic-1]*1.25);
1454 + //   int nbb=first_to_paint_MB[ic-1]->GetNbinsX();
1455 + //   float ymin=9999999999999.;
1456 + //   for(int ib=1;ib<nbb;ib++)
1457 + //   {
1458 + //      float ymin0= first_to_paint_MB[ic-1]->GetBinContent(ib);
1459 + //      if(ymin0>0 && ymin0<ymin)ymin=ymin0;
1460 + //   }
1461 + //   first_to_paint_MB[ic-1]->SetMinimum(ymin*.20);
1462 + }
1463 +
1464 +  gStyle->SetTitleW(0.25);
1465 +  gStyle->SetTitleH(0.22);
1466 +  gStyle->SetTitleX(0.74);
1467 +  gStyle->SetTitleY(0.99);
1468  
1435     first_to_paint->GetXaxis()->SetLabelSize(0.08);
1436     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1437     first_to_paint->GetXaxis()->SetTitle("Slot");
1438     first_to_paint->GetXaxis()->SetTitleSize(0.09);
1439     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1440     first_to_paint->GetXaxis()->SetNdivisions(308);
1441     stringstream htitle; htitle << "BX for HH,HL W" << (iw-2) << " S" << ins;
1442     first_to_paint->SetTitle(htitle.str().c_str());
1443
1444     first_to_paint->Draw();
1445     for(int ic=1;ic<5;ic++)
1446       hHH[ic-1]->Draw("same");
1447    
1448    }// end Loop in sectors
1449    
1450    createGifFile("TrigBXhhhl",(iw-2),"",BX);
1469  
1470 <    // CB fai il delete dei vari canvases!
1470 > TCanvas *OccupanALL = new TCanvas("OccupanALL", "",201,81,999,950);
1471 > OccupanALL->Divide(1,4) ;
1472 > for(int ic=1;ic<5;ic++)
1473 > {
1474 >    OccupanALL->cd(ic)->SetLogy(1);
1475 >    OccupanALL->cd(ic)->SetFillColor(0);
1476 >    OccupanALL->cd(ic)->SetFrameFillColor(0);
1477 >    OccupanALL->cd(ic);
1478 >    first_to_paint_MB[ic-1]->Draw();
1479  
1480 < }// END loop in wheels
1481 <    
1482 < }
1483 <  
1480 >    for(int iw=0;iw<5;iw++)
1481 >    {
1482 >      OccupMB[iw][ic-1]->SetLineColor(iw+1);
1483 >      if(iw==4)
1484 >         OccupMB[iw][ic-1]->SetLineColor(6);
1485 >      OccupanALL->cd(ic);  OccupMB[iw][ic-1]->Draw("same");
1486 >    }
1487 > }
1488 > createGifFile("OccupancyAll","",OccupanALL,false);
1489  
1490 < void DTDPGCreateAnalyzerSummary::createSummaryAllPlots() {
1490 > delete OccupanALL;
1491  
1492 <  string Whname[5]={"Wm2","Wm1","W0","W1","W2"};
1493 <  
1492 >
1493 > // Occupancies/Sector
1494 >  for(int iw=0;iw<5;iw++){
1495 >    stringstream histoNameOccMB; histoNameOccMB << "Digi_" << Whname[iw];
1496 >    OccupWh[iw]= new TH1F(histoNameOccMB.str().c_str(),histoNameOccMB.str().c_str(),14, 0.,14.);
1497 >    for(int isec=1;isec<13;isec++){
1498 >     float totentr=0;
1499 >     for(int ich=1;ich<5;++ich){
1500 >      for(int isl=1;isl<4;isl++){
1501 >        for(int il=1;il<5;il++){
1502 >          if(DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1])
1503 >            totentr+=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetEntries();
1504 >        }
1505 >      }
1506 >     OccupWh[iw]->Fill(isec,totentr);
1507 >     }
1508 >   }
1509 >  }
1510 >
1511 > first_to_paint=OccupWh[0];
1512 >
1513 > /*
1514 > float nbmax=0;
1515 > nbmax=OccupWh[0]->GetMaximum();
1516 > for(int iw=1;iw<5;iw++)
1517 > {
1518 >   float nbmax0=0;
1519 >   nbmax0=OccupWh[iw]->GetMaximum();
1520 >   if(nbmax0>nbmax)
1521 >   {
1522 >      nbmax=nbmax0; first_to_paint=OccupWh[iw];
1523 >   }
1524 > }
1525 > */
1526 >
1527 > float OcmaxS=0;
1528 > float nbminS=9999999;
1529 > float nbminS00=OccupWh[0]->GetMinimum();
1530 > if(nbminS00 > 0) nbminS=nbminS00;
1531 > for(int iw=1;iw<5;iw++)
1532 > {
1533 >    float nbmax0=0;
1534 >    float nbmin0=99999999.;
1535 >    nbmax0=OccupWh[iw]->GetMaximum();
1536 >
1537 >    if(nbmax0>OcmaxS) OcmaxS=nbmax0;
1538 >    if(nbmin0>0 && nbmin0<nbminS)
1539 >    {
1540 >        nbminS=nbmin0; first_to_paint_MB[iw]=OccupWh[iw];
1541 >    }
1542 > }
1543 >
1544 >
1545 >
1546 > stringstream hname21; hname21 << "Total Occupancy ";
1547 > first_to_paint->SetTitle(hname21.str().c_str());
1548 >
1549 > first_to_paint->GetXaxis()->SetLabelSize(0.04);
1550 > first_to_paint->GetXaxis()->SetTitleSize(0.04);
1551 > // first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1552 > first_to_paint->GetXaxis()->SetTitle("Sector   ");
1553 > first_to_paint->GetYaxis()->SetLabelSize(0.04);
1554 > first_to_paint->GetYaxis()->SetTitleSize(0.04);
1555 > // first_to_paint->GetYaxis()->SetTitleOffset(0.5);
1556 > first_to_paint->GetYaxis()->SetTitle("Entries");
1557 > first_to_paint->SetStats(0);
1558 >
1559 >
1560 >  gStyle->SetTitleX(0.1);
1561 >  gStyle->SetTitleY(0.99);
1562 >  gStyle->SetTitleW(0.87);
1563 >  gStyle->SetTitleH(0.1);
1564 >
1565 >
1566 > TCanvas *OccupanSec = new TCanvas("OccupanSec", "",201,81,650,550);
1567 > OccupanSec->SetLogy(1) ;
1568 > first_to_paint->SetMaximum(OcmaxS*1.25);
1569 > float yminS=9999999999999.;
1570 > int nbbS=first_to_paint->GetNbinsX();
1571 > for(int ib=1;ib<nbbS;ib++)
1572 > {
1573 >   float ymin0= first_to_paint->GetBinContent(ib);
1574 >   if(ymin0>0 && ymin0<yminS)yminS=ymin0;
1575 >  }
1576 > first_to_paint->SetMinimum(yminS*.20);
1577 > first_to_paint->Draw();
1578 > for(int iw=0;iw<5;iw++)
1579 > {
1580 >   OccupWh[iw]->SetLineColor(iw+1);
1581 >   if(iw==4)OccupWh[iw]->SetLineColor(6);
1582 >   OccupWh[iw]->Draw("same");
1583 > }
1584 >
1585 > createGifFile("OccupancySec","",OccupanSec,false);
1586 > delete OccupanSec;
1587 >
1588 >  gStyle->SetTitleW(0.55);
1589 >  gStyle->SetTitleH(0.13);
1590    gStyle->SetTitleX(0.01);
1591    gStyle->SetTitleY(0.99);
1592    
1593    gStyle->SetOptStat(10);
1467  gStyle->SetStatY(0.97);
1594    gStyle->SetStatX(0.98);
1595 +  gStyle->SetStatY(0.97);
1596    gStyle->SetStatW(0.35);
1597 <  gStyle->SetStatH(0.45);
1597 >  gStyle->SetStatH(0.38);
1598  
1472  gStyle->SetPalette(1);   // set palette for 2D histos
1473  gStyle->SetTitleW(0.97);
1474  gStyle->SetTitleH(0.1);
1599  
1600 <  float BXSummary_mean=0.;
1601 <  float NBXSummary_mean=0.;
1602 <  TH1F * BXSummary[5][4];
1603 <  for(int iw=0;iw<5;iw++){ // Loop in wheels
1600 > TH1F *TBoxSec[5][12];
1601 > TH1F *TBoxMB[5][4];
1602 > TH1F *TBoxMBTop[5][4];
1603 > TH1F *TBoxMBBottom[5][4];
1604 > TH1F *TBoxMBVertical[5][4];
1605 >
1606 > whIt  = mySectors.begin();
1607 > whEnd = mySectors.end();
1608 > for(;whIt!=whEnd;++whIt) {
1609 >   int iw = (*whIt).first + 2;
1610 >  
1611 >   std::vector<int>::const_iterator secIt  = (*whIt).second.begin();
1612 >   std::vector<int>::const_iterator secEnd = (*whIt).second.end();
1613 >   for(;secIt!=secEnd;++secIt) {
1614 >      int isec = (*secIt);
1615 >    if(isec<13)  
1616      for(int ic=1;ic<5;ic++){
1617 +        stringstream hname; hname << "htime_" << Whname[iw] << "_S" << isec << "_MB" << ic;
1618 +        TH1F * theHisto=getHisto<TH1F>(hname.str());
1619  
1620 <      stringstream hname, htitle;
1621 <      hname  << "BX_mean_MB" << ic << "_W" << (iw-2);
1622 <      htitle << "BX MeanValue (HH,HL) MB" <<  ic << " W" << (iw-2);
1623 <      BXSummary[iw][ic-1]= new TH1F(hname.str().c_str(),htitle.str().c_str(),12,1.,13.);
1624 <      for(int is=1;is<13;is++){
1625 <        stringstream xlab; xlab << "S" << is;
1626 <        BXSummary[iw][ic-1]->GetXaxis()->SetBinLabel(is,xlab.str().c_str());
1620 >        if(isec==1)
1621 >        {
1622 >           stringstream hname2; hname2 << "htime_" << Whname[iw] << "_MB" << ic ;
1623 >           TBoxMB[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1624 >           TBoxMB[iw][ic-1]->SetTitle(hname2.str().c_str());
1625 >
1626 >           stringstream hname3; hname3 << "htime_" << Whname[iw] << "_MB" << ic << "_Vertical" ;
1627 >           TBoxMBVertical[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1628 >           TBoxMBVertical[iw][ic-1]->SetTitle(hname2.str().c_str());
1629 >        }
1630 >        if(isec==2)
1631 >        {
1632 >           stringstream hname2; hname2 << "htime_" << Whname[iw] << "_MB" << ic << "_Top"  ;
1633 >           TBoxMBTop[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1634 >           TBoxMBTop[iw][ic-1]->SetTitle(hname2.str().c_str());
1635 >        }
1636 >        if(isec==8)
1637 >        {
1638 >           stringstream hname2; hname2 << "htime_" << Whname[iw] << "_MB" << ic << "_Bottom"  ;
1639 >           TBoxMBBottom[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1640 >           TBoxMBBottom[iw][ic-1]->SetTitle(hname2.str().c_str());
1641 >        }
1642 >
1643 >        if(isec>2)TBoxMB[iw][ic-1]->Add(theHisto);   //
1644 >        if(isec>2 && isec<7)TBoxMBTop[iw][ic-1]->Add(theHisto);  
1645 >        if(isec>8)TBoxMBBottom[iw][ic-1]->Add(theHisto);  
1646 >        if(isec==7)TBoxMBVertical[iw][ic-1]->Add(theHisto);   //
1647 >
1648 >        if(ic==1)
1649 >        {
1650 >           stringstream hname2; hname2 << "timebox_" << Whname[iw] << "_S" << isec ;
1651 >           TBoxSec[iw][isec-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1652 >           TBoxSec[iw][isec-1]->SetTitle(hname2.str().c_str());
1653 >
1654 >        }
1655 >        if(ic>1)TBoxSec[iw][isec-1]->Add(theHisto);   //
1656 >
1657 >    }// end loop MB
1658 >   }// end loop Sector
1659 > }// end loop Wheel
1660 >
1661 > TH1F * first_to_paint_MB_typ[4][4];
1662 > for(int ic=0;ic<4;ic++)
1663 > {
1664 >   first_to_paint_MB_typ[ic][0]=TBoxMB[0][ic];
1665 >   first_to_paint_MB_typ[ic][1]=TBoxMBTop[0][ic];
1666 >   first_to_paint_MB_typ[ic][2]=TBoxMBBottom[0][ic];
1667 >   first_to_paint_MB_typ[ic][3]=TBoxMBVertical[0][ic];
1668 >   float nbmax[4]={0,0,0,0};
1669 >   nbmax[0]=TBoxMB[0][ic]->GetMaximum();
1670 >   nbmax[1]=TBoxMBTop[0][ic]->GetMaximum();
1671 >   nbmax[2]=TBoxMBBottom[0][ic]->GetMaximum();
1672 >   nbmax[3]=TBoxMBVertical[0][ic]->GetMaximum();
1673 >   for(int iw=1;iw<5;iw++)
1674 >   {
1675 >      float nbmax0[4]={0,0,0,0};
1676 >      nbmax0[0]=TBoxMB[iw][ic]->GetMaximum();
1677 >      nbmax0[1]=TBoxMBTop[iw][ic]->GetMaximum();
1678 >      nbmax0[2]=TBoxMBBottom[iw][ic]->GetMaximum();
1679 >      nbmax0[3]=TBoxMBVertical[iw][ic]->GetMaximum();
1680 >
1681 >      if(nbmax0[0]>nbmax[0])
1682 >      {
1683 >         nbmax[0]=nbmax0[0]; first_to_paint_MB_typ[ic][0]=TBoxMB[iw][ic];
1684 >      }
1685 >      if(nbmax0[1]>nbmax[1])
1686 >      {
1687 >         nbmax[1]=nbmax0[1]; first_to_paint_MB_typ[ic][1]=TBoxMBTop[iw][ic];
1688 >      }
1689 >      if(nbmax0[2]>nbmax[2])
1690 >      {
1691 >         nbmax[2]=nbmax0[2]; first_to_paint_MB_typ[ic][2]=TBoxMBBottom[iw][ic];
1692 >      }
1693 >      if(nbmax0[3]>nbmax[3])
1694 >      {
1695 >         nbmax[3]=nbmax0[3]; first_to_paint_MB_typ[ic][3]=TBoxMBVertical[iw][ic];
1696 >      }
1697 >
1698 >   }
1699 > }
1700 > for(int ic=1;ic<5;ic++)
1701 > {
1702 >   stringstream hname21; hname21 << "htime_MB" << ic ;
1703 >   stringstream hname22; hname22 << "htime_MB" << ic << "_Top"  ;
1704 >   stringstream hname23; hname23 << "htime_MB" << ic << "_Bottom"  ;
1705 >   stringstream hname24; hname24 << "htime_MB" << ic << "_Vertical"  ;
1706 >   first_to_paint_MB_typ[ic-1][0]->SetTitle(hname21.str().c_str());
1707 >   first_to_paint_MB_typ[ic-1][1]->SetTitle(hname22.str().c_str());
1708 >   first_to_paint_MB_typ[ic-1][2]->SetTitle(hname23.str().c_str());
1709 >   first_to_paint_MB_typ[ic-1][3]->SetTitle(hname24.str().c_str());
1710 >
1711 >   for(int ityp=0;ityp<4;ityp++)
1712 >   {
1713 >     first_to_paint_MB_typ[ic-1][ityp]->GetXaxis()->SetLabelSize(0.07);
1714 >     first_to_paint_MB_typ[ic-1][ityp]->GetYaxis()->SetLabelSize(0.05);
1715 >     first_to_paint_MB_typ[ic-1][ityp]->SetNdivisions(505);
1716 >   }
1717 > }
1718 >
1719 >
1720 > TCanvas *TBoxAll = new TCanvas("TBoxAll", "",201,81,999,950);
1721 > TBoxAll->Divide(4,4) ;
1722 > for(int ic=1;ic<5;ic++)
1723 > {
1724 >    first_to_paint_MB_typ[ic-1][0]->SetMinimum(0);
1725 >    first_to_paint_MB_typ[ic-1][1]->SetMinimum(0);
1726 >    first_to_paint_MB_typ[ic-1][2]->SetMinimum(0);
1727 >    first_to_paint_MB_typ[ic-1][3]->SetMinimum(0);
1728 >    TBoxAll->cd((ic-1)*4+1); first_to_paint_MB_typ[ic-1][0]->Draw();
1729 >    TBoxAll->cd((ic-1)*4+2); first_to_paint_MB_typ[ic-1][1]->Draw();
1730 >    TBoxAll->cd((ic-1)*4+3); first_to_paint_MB_typ[ic-1][2]->Draw();
1731 >    TBoxAll->cd((ic-1)*4+4); first_to_paint_MB_typ[ic-1][3]->Draw();
1732 >
1733 >    for(int iw=0;iw<5;iw++)
1734 >    {
1735 >      TBoxMB[iw][ic-1]->SetLineColor(iw+1);
1736 >      TBoxMBTop[iw][ic-1]->SetLineColor(iw+1);
1737 >      TBoxMBBottom[iw][ic-1]->SetLineColor(iw+1);
1738 >      TBoxMBVertical[iw][ic-1]->SetLineColor(iw+1);
1739 >      if(iw==4)
1740 >       {
1741 >         TBoxMB[iw][ic-1]->SetLineColor(6);
1742 >         TBoxMBTop[iw][ic-1]->SetLineColor(6);
1743 >         TBoxMBBottom[iw][ic-1]->SetLineColor(6);
1744 >         TBoxMBVertical[iw][ic-1]->SetLineColor(6);
1745 >       }
1746 >      TBoxAll->cd((ic-1)*4+1);  TBoxMB[iw][ic-1]->Draw("same");
1747 >      TBoxAll->cd((ic-1)*4+2);  TBoxMBTop[iw][ic-1]->Draw("same");
1748 >      TBoxAll->cd((ic-1)*4+3);  TBoxMBBottom[iw][ic-1]->Draw("same");
1749 >      TBoxAll->cd((ic-1)*4+4);  TBoxMBVertical[iw][ic-1]->Draw("same");
1750 >    }
1751 > }
1752 >
1753 > createGifFile("TimeBoxAll","",TBoxAll,false);
1754 > delete TBoxAll;
1755 >
1756 >
1757 > TCanvas *TBoxWh[5];
1758 > TBoxWh[0] = new TCanvas("TBoxWh-2", "",201,81,999,950);
1759 > TBoxWh[1] = new TCanvas("TBoxWh-1", "",201,81,999,950);
1760 > TBoxWh[2] = new TCanvas("TBoxWh0", "",201,81,999,950);
1761 > TBoxWh[3] = new TCanvas("TBoxWh+1", "",201,81,999,950);
1762 > TBoxWh[4] = new TCanvas("TBoxWh+2", "",201,81,999,950);
1763 > for(int iw=0;iw<5;iw++)
1764 > {
1765 >   TBoxWh[iw]->Divide(3,4) ;
1766 >   for(int isec=1;isec<13;isec++)
1767 >   {
1768 >      TBoxWh[iw]->cd(isec);
1769 >      TBoxWh[iw]->cd(isec)->SetFillColor(0);
1770 >      TBoxWh[iw]->cd(isec)->SetFrameFillColor(0);
1771 >      TBoxSec[iw][isec-1]->GetXaxis()->SetLabelSize(0.07);
1772 >      TBoxSec[iw][isec-1]->GetYaxis()->SetLabelSize(0.05);
1773 >      TBoxSec[iw][isec-1]->SetNdivisions(505);
1774 >      TBoxSec[iw][isec-1]->Draw();   //
1775 >   }
1776 > }
1777 >
1778 > for(int iw=0;iw<5;iw++)
1779 > {
1780 >    createGifFile("TimeBoxAll",(iw-2),"",TBoxWh[iw]);
1781 >    delete TBoxWh[iw];
1782 > }
1783 >
1784 >
1785 >  gStyle->SetOptStat(10);
1786 >  gStyle->SetStatX(0.4);
1787 >  gStyle->SetStatY(0.88);
1788 >  gStyle->SetStatW(0.29);
1789 >  gStyle->SetStatH(0.38);
1790 >
1791 >
1792 > TH1F *NHitsSec[5][12];
1793 > TH1F *NHitsMB[5][4];
1794 > TH1F *NHitsMBTop[5][4];
1795 > TH1F *NHitsMBBottom[5][4];
1796 > TH1F *NHitsMBVertical[5][4];
1797 > for(int iw=0;iw<5;iw++)
1798 > {
1799 >   for(int isec=0;isec<12;isec++)NHitsSec[iw][isec]=NULL;
1800 >   for(int ic=0;ic<5;ic++)
1801 >   {
1802 >    NHitsMB[iw][ic]=NULL;
1803 >    NHitsMBTop[iw][ic]=NULL;
1804 >    NHitsMBBottom[iw][ic]=NULL;
1805 >    NHitsMBVertical[iw][ic]=NULL;
1806 >   }
1807 > }
1808 >
1809 > whIt  = mySectors.begin();
1810 > whEnd = mySectors.end();
1811 > for(;whIt!=whEnd;++whIt) {
1812 >  int iw = (*whIt).first + 2;
1813 >  std::vector<int>::const_iterator secIt  = (*whIt).second.begin();
1814 >  std::vector<int>::const_iterator secEnd = (*whIt).second.end();
1815 >  for(;secIt!=secEnd;++secIt) {
1816 >    int isec = (*secIt);
1817 >    if(isec<13)
1818 >    for(int ic=1;ic<5;ic++){
1819 >      //for(int isl=1;isl<4;isl++){
1820 >        //stringstream hname; hname << "hNhits_" << Whname[iw] << "_S" << isec << "_MB" << ic << "_SL" << isl;
1821 >      {
1822 >        stringstream hname; hname << "hNhits_" << Whname[iw] << "_S" << isec << "_MB" << ic;
1823 >        TH1F * theHisto=getHisto<TH1F>(hname.str());
1824 >
1825 >        if(isec==1)
1826 >        {
1827 >           stringstream hname2; hname2 << "nHits_" << Whname[iw] << "_MB" << ic ;
1828 >           NHitsMB[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1829 >           NHitsMB[iw][ic-1]->SetTitle(hname2.str().c_str());
1830 >
1831 >           stringstream hname3; hname3 << "nHits_" << Whname[iw] << "_MB" << ic << "_Vertical";
1832 >           NHitsMBVertical[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1833 >           NHitsMBVertical[iw][ic-1]->SetTitle(hname3.str().c_str());
1834 >        }
1835 >        if(isec==2)
1836 >        {
1837 >           stringstream hname2; hname2 << "nHits_" << Whname[iw] << "_MB" << ic << "_Top"  ;
1838 >           NHitsMBTop[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1839 >           NHitsMBTop[iw][ic-1]->SetTitle(hname2.str().c_str());
1840 >        }
1841 >        if(isec==8)
1842 >        {
1843 >           stringstream hname2; hname2 << "nHits_" << Whname[iw] << "_MB" << ic << "_Bottom"  ;
1844 >           NHitsMBBottom[iw][ic-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1845 >           NHitsMBBottom[iw][ic-1]->SetTitle(hname2.str().c_str());
1846 >        }
1847 >
1848 >
1849 >        if(isec>2)NHitsMB[iw][ic-1]->Add(theHisto);   //
1850 >        if(isec>2 && isec<7)NHitsMBTop[iw][ic-1]->Add(theHisto);
1851 >        if(isec>8)NHitsMBBottom[iw][ic-1]->Add(theHisto);
1852 >        if(isec==7)NHitsMBVertical[iw][ic-1]->Add(theHisto);
1853 >
1854 >        if(ic==1)
1855 >        {
1856 >           stringstream hname2; hname2 << "nHits_" << Whname[iw] << "_S"  << isec ;
1857 >           NHitsSec[iw][isec-1]=(TH1F*)theHisto->Clone(hname.str().c_str());
1858 >           NHitsSec[iw][isec-1]->SetTitle(hname2.str().c_str());
1859 >
1860 >        }
1861 >        if(ic>1 && ic<4)NHitsSec[iw][isec-1]->Add(theHisto);  // To avoid mix with MB4
1862 >                                                              // that has not Theta SLs
1863        }
1864      }
1865    }
1866 <  
1866 > }
1867  
1868 <  //===================================================================================
1869 <  //   SC BX Summary    
1870 <  //===================================================================================
1871 <  for(int iw=0;iw<5;iw++){ // Loop in wheels
1872 <    for(int ins=1;ins<13;ins++){ // Loop in sectors
1873 <      
1874 <      TH1F *hHH[4];
1875 <      TH1F *hHL[4];
1876 <      for(int ic=1;ic<5;ic++){ // Loop in chambers
1877 <    
1878 <        stringstream hname; hname << "hTrigBX_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1879 <        hHH[ic-1]= getHisto<TH1F>(hname.str()+"_qual6");
1880 <        hHL[ic-1]= getHisto<TH1F>(hname.str()+"_qual5");
1881 <        
1882 <        hHH[ic-1]->Add(hHL[ic-1]);
1883 <        hHH[ic-1]->SetLineColor(ic);
1884 <        hHH[ic-1]->SetStats(0);
1885 <        
1886 <        // Compute average for BX summary plot
1887 <        int nb=hHH[ic-1]->GetNbinsX();
1888 <        int nbMax=hHH[ic-1]->GetMaximumBin();
1889 <        float xmean=0;
1890 <        float xtot0=0;
1891 <        for(int inb=nbMax-2;inb<nbMax+3;inb++){ // Takes Central BX+-2
1892 <          if(inb>1 && inb<nb){ //To avoid problems if it is on the "border"
1893 <            float yval=hHH[ic-1]->GetBinContent(inb);
1894 <            float xval=hHH[ic-1]->GetBinCenter(inb);
1895 <            xmean+=xval*yval;
1896 <            xtot0+=yval;
1897 <          }
1524 <        }
1525 <        if(xtot0>0){
1526 <          xmean=xmean/xtot0 ;
1527 <          BXSummary[iw][ic-1]->Fill(ins,xmean);
1528 <          BXSummary_mean+=xmean;
1529 <          NBXSummary_mean++;
1530 <        }
1868 > for(int ic=0;ic<4;ic++)
1869 > {
1870 >   first_to_paint_MB_typ[ic][0]=NHitsMB[0][ic];
1871 >   first_to_paint_MB_typ[ic][1]=NHitsMBTop[0][ic];
1872 >   first_to_paint_MB_typ[ic][2]=NHitsMBBottom[0][ic];
1873 >   first_to_paint_MB_typ[ic][3]=NHitsMBVertical[0][ic];
1874 >   float nbmax[4]={0,0,0,0};
1875 >   if(NHitsMB[0][ic])nbmax[0]=NHitsMB[0][ic]->GetMaximum();
1876 >   if(NHitsMBTop[0][ic])nbmax[1]=NHitsMBTop[0][ic]->GetMaximum();
1877 >   if(NHitsMBBottom[0][ic])nbmax[2]=NHitsMBBottom[0][ic]->GetMaximum();
1878 >   if(NHitsMBVertical[0][ic])nbmax[3]=NHitsMBVertical[0][ic]->GetMaximum();
1879 >   for(int iw=1;iw<5;iw++)
1880 >   {
1881 >      float nbmax0[4]={0,0,0,0};
1882 >      if(NHitsMB[iw][ic] !=NULL)nbmax0[0]=NHitsMB[iw][ic]->GetMaximum();
1883 >      if(NHitsMBTop[iw][ic] !=NULL)nbmax0[1]=NHitsMBTop[iw][ic]->GetMaximum();
1884 >      if(NHitsMBBottom[iw][ic] !=NULL)nbmax0[2]=NHitsMBBottom[iw][ic]->GetMaximum();
1885 >      if(NHitsMBVertical[iw][ic] !=NULL)nbmax0[3]=NHitsMBVertical[iw][ic]->GetMaximum();
1886 >
1887 >      if(nbmax0[0]>nbmax[0])
1888 >      {
1889 >         nbmax[0]=nbmax0[0]; first_to_paint_MB_typ[ic][0]=NHitsMB[iw][ic];
1890 >      }
1891 >      if(nbmax0[1]>nbmax[1])
1892 >      {
1893 >         nbmax[1]=nbmax0[1]; first_to_paint_MB_typ[ic][1]=NHitsMBTop[iw][ic];
1894 >      }
1895 >      if(nbmax0[2]>nbmax[2])
1896 >      {
1897 >         nbmax[2]=nbmax0[2]; first_to_paint_MB_typ[ic][2]=NHitsMBBottom[iw][ic];
1898        }
1899 <    }// end Loop in chambers
1900 <  }// END loop in wheels and sectors
1899 >      if(nbmax0[3]>nbmax[3])
1900 >      {
1901 >         nbmax[3]=nbmax0[3]; first_to_paint_MB_typ[ic][3]=NHitsMBVertical[iw][ic];
1902 >      }
1903 >   }
1904 > }
1905 >
1906 > for(int ic=1;ic<5;ic++)
1907 > {
1908 >   stringstream hname21; hname21 << "nHits_MB" << ic ;
1909 >   stringstream hname22; hname22 << "nHits_MB" << ic << "_Top"  ;
1910 >   stringstream hname23; hname23 << "nHits_MB" << ic << "_Bottom"  ;
1911 >   stringstream hname24; hname24 << "nHits_MB" << ic << "_Vertical"  ;
1912 >   if(first_to_paint_MB_typ[ic-1][0] != NULL) first_to_paint_MB_typ[ic-1][0]->SetTitle(hname21.str().c_str());
1913 >   if(first_to_paint_MB_typ[ic-1][1] != NULL) first_to_paint_MB_typ[ic-1][1]->SetTitle(hname22.str().c_str());
1914 >   if(first_to_paint_MB_typ[ic-1][2] != NULL) first_to_paint_MB_typ[ic-1][2]->SetTitle(hname23.str().c_str());
1915 >   if(first_to_paint_MB_typ[ic-1][3] != NULL) first_to_paint_MB_typ[ic-1][3]->SetTitle(hname24.str().c_str());
1916 >
1917 >   for(int ityp=0;ityp<4;ityp++)
1918 >   {
1919 >     if(first_to_paint_MB_typ[ic-1][ityp] != NULL)
1920 >     {
1921 >       first_to_paint_MB_typ[ic-1][ityp]->GetXaxis()->SetLabelSize(0.07);
1922 >       first_to_paint_MB_typ[ic-1][ityp]->GetYaxis()->SetLabelSize(0.05);
1923 >       first_to_paint_MB_typ[ic-1][ityp]->SetNdivisions(505);
1924 >     }
1925 >   }
1926 > }
1927 >
1928 > TCanvas *NHitsAll = new TCanvas("NHitsAll", "",201,81,999,950);
1929 > NHitsAll->Divide(4,4) ;
1930 > for(int ip=1;ip<17;ip++)
1931 > {
1932 >    NHitsAll->cd(ip)->SetFillColor(0) ;
1933 >    NHitsAll->cd(ip)->SetFrameFillColor(0) ;
1934 > }
1935 > for(int ic=1;ic<5;ic++)
1936 > {
1937 >    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();
1938 >    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();
1939 >    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();
1940 >    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();
1941 >
1942 >    for(int iw=0;iw<5;iw++)
1943 >    {
1944 >      if(NHitsMB[iw][ic-1] != NULL)NHitsMB[iw][ic-1]->SetLineColor(iw+1);
1945 >      if(NHitsMBTop[iw][ic-1] != NULL)NHitsMBTop[iw][ic-1]->SetLineColor(iw+1);
1946 >      if(NHitsMBBottom[iw][ic-1] != NULL)NHitsMBBottom[iw][ic-1]->SetLineColor(iw+1);
1947 >      if(NHitsMBVertical[iw][ic-1]!= NULL)NHitsMBVertical[iw][ic-1]->SetLineColor(iw+1);
1948 >      if(iw==4)
1949 >       {
1950 >         if(NHitsMB[iw][ic-1] != NULL)NHitsMB[iw][ic-1]->SetLineColor(6);
1951 >         if(NHitsMBTop[iw][ic-1] != NULL)NHitsMBTop[iw][ic-1]->SetLineColor(6);
1952 >         if(NHitsMBBottom[iw][ic-1] != NULL)NHitsMBBottom[iw][ic-1]->SetLineColor(6);
1953 >         if(NHitsMBVertical[iw][ic-1]!= NULL)NHitsMBVertical[iw][ic-1]->SetLineColor(6);
1954 >       }
1955 >      NHitsAll->cd((ic-1)*4+1);   if(NHitsMB[iw][ic-1] != NULL)NHitsMB[iw][ic-1]->Draw("same");
1956 >      NHitsAll->cd((ic-1)*4+2);   if(NHitsMBTop[iw][ic-1] != NULL)NHitsMBTop[iw][ic-1]->Draw("same");
1957 >      NHitsAll->cd((ic-1)*4+3);   if(NHitsMBBottom[iw][ic-1] != NULL)NHitsMBBottom[iw][ic-1]->Draw("same");
1958 >      NHitsAll->cd((ic-1)*4+4);   if(NHitsMBVertical[iw][ic-1]!= NULL)NHitsMBVertical[iw][ic-1]->Draw("same");
1959 >    }
1960 > }
1961  
1962 <  string titlename = "BX Average (HH,HL)";
1963 <  TCanvas *BXaverage = new TCanvas("BXAverage", "",201,81,999,699);
1964 <  BXaverage->SetTopMargin(0.42);
1965 <  BXaverage->SetBottomMargin(0.32);
1966 <  BXaverage->SetRightMargin(0.12);
1967 <  BXaverage->Divide(1,5,0.,0) ;
1962 > createGifFile("NHitsAll","",NHitsAll,false);
1963 > delete NHitsAll;
1964 >
1965 >
1966 > TCanvas *NHitsWh[5];
1967 > NHitsWh[0] = new TCanvas("NHitsWh-2", "",201,81,999,950);
1968 > NHitsWh[1] = new TCanvas("NHitsWh-1", "",201,81,999,950);
1969 > NHitsWh[2] = new TCanvas("NHitsWh0", "",201,81,999,950);
1970 > NHitsWh[3] = new TCanvas("NHitsWh+1", "",201,81,999,950);
1971 > NHitsWh[4] = new TCanvas("NHitsWh+2", "",201,81,999,950);
1972 > for(int iw=0;iw<5;iw++)
1973 > {
1974 >   NHitsWh[iw]->Divide(3,4) ;
1975 >   for(int isec=1;isec<13;isec++)
1976 >   {
1977 >      NHitsWh[iw]->cd(isec);
1978 >      NHitsWh[iw]->cd(isec)->SetFillColor(0);
1979 >      NHitsWh[iw]->cd(isec)->SetFrameFillColor(0);
1980 >      if(NHitsSec[iw][isec-1] != NULL)
1981 >      {
1982 >        NHitsSec[iw][isec-1]->GetXaxis()->SetLabelSize(0.07);
1983 >        NHitsSec[iw][isec-1]->GetYaxis()->SetLabelSize(0.05);
1984 >        NHitsSec[iw][isec-1]->SetNdivisions(505);
1985 >        NHitsSec[iw][isec-1]->Draw();   //
1986 >      }
1987 >   }
1988 > }
1989 >
1990 >
1991 > for(int iw=0;iw<5;iw++)
1992 > {
1993 >   createGifFile("NHitsSec",(iw-2),"",NHitsWh[iw]);
1994 >   delete NHitsWh[iw];
1995 > }
1996 >
1997 > TCanvas *NHitsWhAll;
1998 > NHitsWhAll = new TCanvas("NHitsWhAll", "",201,81,999,950);
1999 > NHitsWhAll->Divide(3,4) ;
2000 > for(int ins=1;ins<13;ins++)
2001 > {
2002 >   first_to_paint=NHitsSec[0][ins-1];
2003 >   float nbmax1=0;
2004 >   if(NHitsSec[0][ins-1]!=NULL)NHitsSec[0][ins-1]->GetMaximum();
2005 >   for(int iw=1;iw<5;iw++)
2006 >   {
2007 >      float nbmax2=0;
2008 >      if(NHitsSec[iw][ins-1] != NULL)nbmax2=NHitsSec[iw][ins-1]->GetMaximum();
2009 >      if(nbmax2>nbmax1)
2010 >      {
2011 >         nbmax1=nbmax2; first_to_paint=NHitsSec[iw][ins-1];
2012 >      }
2013 >    }
2014 >
2015 >    NHitsWhAll->cd(ins) ;
2016 >    NHitsWhAll->cd(ins)->SetFillColor(0) ;
2017 >    NHitsWhAll->cd(ins)->SetFrameFillColor(0) ;
2018 >    stringstream hname; hname << "nHits_S"  << ins ;
2019 >    if(first_to_paint != NULL)
2020 >    {
2021 >      first_to_paint->SetTitle(hname.str().c_str());
2022 >      first_to_paint->Draw();
2023 >      for(int iw=0;iw<5;iw++)
2024 >      {
2025 >        if(NHitsSec[iw][ins-1] != NULL)
2026 >        {
2027 >         NHitsSec[iw][ins-1]->SetLineColor(iw+1);
2028 >         if(iw==4) NHitsSec[iw][ins-1]->SetLineColor(6);
2029 >         NHitsSec[iw][ins-1]->Draw("same");
2030 >        }
2031 >      }
2032 >    }
2033 > }
2034 >
2035 > createGifFile("NHitsSec","",NHitsWhAll,false);
2036 >
2037 > delete NHitsWhAll;
2038 >
2039 > gStyle->SetStatY(0.99);
2040 > gStyle->SetStatX(0.98);
2041 > gStyle->SetStatW(0.40);
2042 > gStyle->SetStatH(0.25);
2043 >
2044 >
2045 > stringstream hnameSTA1; hnameSTA1 << "hrIPSA" ;
2046 > stringstream hnameSTA2; hnameSTA2 << "hzIPSA" ;
2047 > stringstream hnameSTA3; hnameSTA3 << "hrVszIPSA" ;
2048 >
2049 > TH1F * theHistoSTA1=NULL;
2050 > TH1F * theHistoSTA2=NULL;
2051 > TH2F * theHistoSTA3=NULL;
2052 >
2053 > theHistoSTA1=getHisto<TH1F>(hnameSTA1.str());
2054 > theHistoSTA2=getHisto<TH1F>(hnameSTA2.str());
2055 > theHistoSTA3=getHisto<TH2F>(hnameSTA3.str());
2056 >
2057 > TCanvas *STAatIP;
2058 > STAatIP = new TCanvas("STAatIP", "",201,81,999,400);
2059 > STAatIP->Divide(3,1) ;
2060 > for(int i=1;i<5;i++)
2061 > { STAatIP->cd(i)->SetFillColor(0);STAatIP->cd(i)->SetFrameFillColor(0); }
2062 > if(theHistoSTA1 != NULL){STAatIP->cd(1);theHistoSTA1->Draw(); }
2063 > else cout << " hrIPSA histo not found " << endl;
2064 > if(theHistoSTA2 != NULL){STAatIP->cd(2);theHistoSTA2->Draw(); }
2065 > else cout << " hzIPSA histo not found " << endl;
2066 > if(theHistoSTA3 != NULL){STAatIP->cd(3);theHistoSTA3->Draw("colz"); }
2067 > else cout << " hrvszIPSA histo not found " << endl;
2068 >
2069 > createGifFile("STATrack_at_IP","",STAatIP,false);
2070 > delete STAatIP;
2071 >
2072 >
2073 > gStyle->SetStatY(0.97);
2074 > gStyle->SetStatX(0.98);
2075 > gStyle->SetStatW(0.25);
2076 > gStyle->SetStatH(0.15);
2077 >
2078 >
2079 > TH1F * segphi=getHisto<TH1F>("segphi");
2080 > TH1F * segphivsz=getHisto<TH1F>("segphivsz");
2081 >
2082 > TH1F * segphiMB[4];
2083 > TH1F * segzMB[4];
2084 > for(int ic=1;ic<5;ic++)
2085 > {
2086 >   stringstream hname1; hname1 << "segphiMB" << ic ;
2087 >   stringstream hname2; hname2 << "segzMB" << ic ;
2088 >   segphiMB[ic-1]=getHisto<TH1F>(hname1.str());
2089 >   segzMB[ic-1]=getHisto<TH1F>(hname2.str());
2090 > }
2091 >
2092 > TCanvas *SegPhiZ;
2093 > SegPhiZ = new TCanvas("SegPhiZ", "",201,81,999,850);
2094 > SegPhiZ->Divide(2,2) ;
2095 > for(int i=1;i<5;i++)
2096 > { SegPhiZ->cd(i)->SetFillColor(0);SegPhiZ->cd(i)->SetFrameFillColor(0); }
2097 >
2098 > SegPhiZ->cd(1);segphi->Draw();
2099 > SegPhiZ->cd(2);segphivsz->Draw("colz");
2100 > first_to_paint=segphiMB[0];
2101 > int nbmaxPSeg=segphiMB[0]->GetMaximum();
2102 > for(int i=1;i<4;i++)
2103 > {
2104 >   int nbmax0=segphiMB[i]->GetMaximum();
2105 >   if(nbmax0>nbmaxPSeg){
2106 >      nbmaxPSeg=nbmax0;
2107 >      first_to_paint=segphiMB[i];
2108 >   }
2109 > }
2110 > first_to_paint->SetTitle("phi of segment position");
2111 > first_to_paint->SetMinimum(0);
2112 > SegPhiZ->cd(3);first_to_paint->Draw();
2113 > for(int i=0;i<4;i++)
2114 > {
2115 >  segphiMB[i]->SetLineColor(i+1);
2116 >  segphiMB[i]->Draw("same");
2117 > }
2118 > first_to_paint=segzMB[0];
2119 > first_to_paint->SetMinimum(0);
2120 > int nbmaxZSeg=segzMB[0]->GetMaximum();
2121 > for(int i=1;i<3;i++) // Not consider the MB4, not Theta Segment
2122 > {
2123 >   int nbmax0=segzMB[i]->GetMaximum();
2124 >   if(nbmax0>nbmaxZSeg){
2125 >      nbmaxZSeg=nbmax0;
2126 >      first_to_paint=segzMB[i];
2127 >   }
2128 > }
2129 > first_to_paint->SetTitle("z of segment position");
2130 > SegPhiZ->cd(4);first_to_paint->Draw();
2131 > for(int i=0;i<3;i++)  // Not consider the MB4, not Theta Segment
2132 > {
2133 >  segzMB[i]->SetLineColor(i+1);
2134 >  segzMB[i]->Draw("same");
2135 > }
2136 >
2137 >
2138 > createGifFile("SegmentPosition","",SegPhiZ,false);
2139 > delete SegPhiZ;
2140 >
2141 > TH1F * difPhi4_all=getHisto<TH1F>("DifPhi4_1");
2142 > TH1F * difPhi4_top=getHisto<TH1F>("DifPhi4_1_top");
2143 > TH1F * difPhi4_bot=getHisto<TH1F>("DifPhi4_1_bot");
2144 >
2145 > TCanvas *DifPhi4;
2146 > DifPhi4 = new TCanvas("DifPhi4", "",201,81,699,400);
2147 > DifPhi4->Divide(2,1) ;
2148 > for(int i=1;i<3;i++)
2149 > { DifPhi4->cd(i)->SetFillColor(0);DifPhi4->cd(i)->SetFrameFillColor(0); }
2150 > TPad *DifPhi4_2 = (TPad*) DifPhi4->GetListOfPrimitives()->FindObject("DifPhi4_2");
2151 >
2152 > DifPhi4->cd(1);difPhi4_all->Draw();
2153 > TPaveLabel * titleDifPhi41 = new TPaveLabel(0.05,0.92,0.7,0.99,"phi pos. in MB4-MB1","NDC");
2154 > titleDifPhi41->Draw();                                                                      
2155 >
2156 > difPhi4_top->SetTitle("Top Sectors"); difPhi4_bot->SetTitle("Bottom Sectors");
2157 > DifPhi4->cd(2)->SetFillColor(0);DifPhi4->cd(2)->SetFrameFillColor(0);
2158 > DifPhi4->cd(2);
2159 > gStyle->SetOptTitle(0);
2160 > double nphi4top=difPhi4_top->GetMaximum();
2161 > double nphi4bot=difPhi4_bot->GetMaximum();
2162 > if(nphi4bot>nphi4top)
2163 > { difPhi4_bot->Draw();difPhi4_top->Draw("same"); }
2164 > else
2165 >  {difPhi4_top->Draw();difPhi4_bot->Draw("same"); }
2166    
2167 <  TPaveLabel* title = new TPaveLabel(0.1,0.93,0.85,0.99,titlename.c_str());
2168 <  title->SetFillColor(0);
2169 <  title->SetTextColor(4);
2170 <  title->Draw();
2171 <
2172 <  int BXSummary_min=0;
2173 <  int BXSummary_max=0;
1549 <  if(NBXSummary_mean>0)BXSummary_min=-6+int(BXSummary_mean/NBXSummary_mean);
1550 <  if(NBXSummary_mean>0)BXSummary_max=6+int(BXSummary_mean/NBXSummary_mean);
1551 <  for(int iw=0;iw<5;iw++){
1552 <    BXaverage->cd(iw+1);
1553 <    BXaverage->cd(iw+1)->SetGrid();
1554 <    for(int ic=1;ic<5;ic++){
1555 <      BXSummary[iw][ic-1]->SetMaximum(BXSummary_max);
1556 <      BXSummary[iw][ic-1]->SetMinimum(BXSummary_min);
1557 <      BXSummary[iw][ic-1]->SetStats(0);
1558 <      BXSummary[iw][ic-1]->SetTitle(0);
1559 <      BXSummary[iw][ic-1]->SetLineWidth(2);
1560 <      BXSummary[iw][ic-1]->GetXaxis()->SetLabelSize(0.25);
1561 <      BXSummary[iw][ic-1]->GetYaxis()->SetLabelSize(0.2);
1562 <      if(iw==4)BXSummary[iw][ic-1]->GetYaxis()->SetLabelSize(0.15);
1563 <      BXSummary[iw][ic-1]->GetYaxis()->SetNdivisions(502);
1564 <      BXSummary[iw][ic-1]->SetLineColor(ic);
1565 <      if(ic==1)BXSummary[iw][ic-1]->Draw();
1566 <      else BXSummary[iw][ic-1]->Draw("same");
1567 <    }
1568 <    stringstream ptitle; ptitle << "Wheel " << (iw-2);
1569 <    TPaveLabel* WheelName = new TPaveLabel(1.00,0.70,1.12,0.90,ptitle.str().c_str(),"NDC");
1570 <    WheelName->Draw();
1571 <  }
2167 > DifPhi4_2->BuildLegend();
2168 > titleDifPhi41->Draw();
2169 >
2170 >
2171 > createGifFile("DifPhi14","",DifPhi4,false);
2172 >
2173 > delete DifPhi4;
2174  
2175 <  createGifFile("TrigBXhhhl_average","",BXaverage);
2176 <  delete BXaverage;
2175 > gStyle->SetOptTitle(1);
2176 >
2177 >
2178 > TCanvas *hSeg;
2179 > hSeg = new TCanvas("hSeg", "",201,81,999,850);
2180 > hSeg->Divide(2,2);
2181 > for(int i=1;i<4;i++)
2182 > { hSeg->cd(i)->SetFillColor(0);hSeg->cd(i)->SetFrameFillColor(0); }
2183 >
2184 > TH1F * hnSegDT=getHisto<TH1F>("hnSegDT");
2185 > TH1F * hnHSegDT=getHisto<TH1F>("hnHSegDT");
2186 > TH1F * hnSegMB1=getHisto<TH1F>("hnSegMB1");
2187 > TH1F * hnHSegMB1=getHisto<TH1F>("hnHSegMB1");
2188 >
2189 > hSeg->cd(1);hnSegDT->Draw();
2190 > hSeg->cd(2);hnHSegDT->Draw();
2191 > hSeg->cd(3);hnSegMB1->Draw();
2192 > hSeg->cd(4);hnHSegMB1->Draw();
2193 >
2194 > createGifFile("SegmentsAll","",hSeg,false);
2195 > delete hSeg;
2196  
2197   }
2198  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines