ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DTDPGAnalysis/src/DTDPGCreateAnalyzerSummary.cc
Revision: 1.2
Committed: Mon Nov 3 11:06:39 2008 UTC (16 years, 6 months ago) by battilan
Content type: text/plain
Branch: MAIN
Changes since 1.1: +47 -38 lines
Log Message:
added labels and new cfg

File Contents

# User Rev Content
1 battilan 1.1 /*
2     * See header file for a description of this class.
3     *
4 battilan 1.2 * $Date: 2008/11/02 20:43:11 $
5 battilan 1.1 * $Revision: 1.1 $
6     * \author G. Mila - INFN Torino
7     * revised U.G. 2007/07/24
8     * Modified M.C Fouz. 2008/04/22
9     * Updated for version 200
10     * include the run & sector number on gif files
11     */
12    
13    
14     #include <UserCode/DTDPGAnalysis/src/DTDPGCreateAnalyzerSummary.h>
15    
16     // Framework
17     #include <FWCore/Framework/interface/Event.h>
18     #include <FWCore/Framework/interface/EventSetup.h>
19    
20     // Geometry
21     #include "Geometry/Records/interface/MuonGeometryRecord.h"
22     #include "Geometry/DTGeometry/interface/DTGeometry.h"
23     #include "Geometry/DTGeometry/interface/DTLayer.h"
24     #include "Geometry/DTGeometry/interface/DTTopology.h"
25    
26     #include "FWCore/MessageLogger/interface/MessageLogger.h"
27    
28     #include <iostream>
29     #include <string>
30     #include <sstream>
31     #include <iomanip>
32     #include <math.h>
33    
34     #include "TH1F.h"
35     #include "TF1.h"
36     #include "TH2F.h"
37     #include "TCanvas.h"
38     #include "TGraph.h"
39     #include "TPostScript.h"
40     #include "TPaveLabel.h"
41     #include "TPaveText.h"
42     #include "TProfile.h"
43     #include "TStyle.h"
44     #include "TFolder.h"
45     #include "boost/filesystem.hpp"
46    
47     using namespace edm;
48     using namespace std;
49     using namespace boost::filesystem;
50    
51     DTDPGCreateAnalyzerSummary::DTDPGCreateAnalyzerSummary(const edm::ParameterSet& ps) : myFile(0){
52    
53     LogVerbatim("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Constructor";
54    
55     myParameters = ps;
56     myRunNumber = ps.getUntrackedParameter<int>("runNumber",0);
57    
58     }
59    
60     DTDPGCreateAnalyzerSummary::~DTDPGCreateAnalyzerSummary(){
61    
62     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Destructor ";
63    
64     }
65    
66    
67     void DTDPGCreateAnalyzerSummary::beginJob(const edm::EventSetup& context){
68    
69     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: BeginJob";
70    
71     }
72    
73     void DTDPGCreateAnalyzerSummary::analyze(const edm::Event& e, const edm::EventSetup& context){
74    
75     }
76    
77    
78     void DTDPGCreateAnalyzerSummary::endJob(){
79    
80     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: endJob";
81    
82     myFile = new TFile(myParameters.getUntrackedParameter<string>("rootFileName", "DTEfficiencyTest.root").c_str(), "READ");
83    
84     char cMainFolder[30];sprintf(cMainFolder,"DQMData/Run %d", myRunNumber);
85     TFolder * mfolder=(TFolder*)myFile->Get(cMainFolder);
86     if(!mfolder) {
87     throw cms::Exception("DTDPGCreateAnalyzerSummaryError") << "[DTDPGCreateAnalyzerSummary]: Folder = " << cMainFolder << " does not exist!!! Check the run number" << endl;
88     }
89    
90     myMainFolder.append(cMainFolder);
91     myMainFolder.append("/DT/Run summary/DTOfflineAnalyzer/");
92    
93    
94     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Creating summaries!";
95    
96     if (myParameters.getUntrackedParameter<bool>("FullWheelHistos", false)) { createFullWheelPlots(); }
97     if (myParameters.getUntrackedParameter<bool>("SummaryWheelHistos", false)) { createSummaryWheelPlots(); }
98     if (myParameters.getUntrackedParameter<bool>("SummaryAllHistos", false)) { createSummaryAllPlots(); }
99    
100 battilan 1.2 if(myFile) {
101     myFile->Close();
102     delete myFile;
103     }
104    
105 battilan 1.1 }
106    
107     void DTDPGCreateAnalyzerSummary::createGifFile(string fileName, int wh, int sec, string tag, TCanvas *canvas) {
108    
109     stringstream gifBase;
110     gifBase << "Run" << myRunNumber << "/Wheel" << showpos << wh << "/Sect" << noshowpos << setfill('0')<< setw(2) << sec;
111     try {
112     create_directories(gifBase.str());
113     } catch(const std::exception & ex) {
114     throw cms::Exception("DTDPGCreateAnalyzerSummaryError")<< "[DTDPGCreateAnalyzerSummary]: Excepiton " << ex.what() << " thrown creating " << gifBase.str() << " directory" << endl;
115     }
116    
117     stringstream gifTag; gifTag << "_r" << myRunNumber << "_W" << wh <<"_S" << sec;
118     string gifFile = gifBase.str() + "/" + fileName + gifTag.str() + tag + ".gif";
119     canvas->Update();
120     canvas->Print(gifFile.c_str());
121    
122     }
123    
124     void DTDPGCreateAnalyzerSummary::createGifFile(string fileName, int wh, string tag, TCanvas *canvas) {
125    
126     stringstream gifBase;
127     gifBase << "Run" << myRunNumber << "/Wheel" << showpos << wh << noshowpos;
128     try {
129     create_directories(gifBase.str());
130     } catch(const std::exception & ex) {
131     throw cms::Exception("DTDPGCreateAnalyzerSummaryError")<< "[DTDPGCreateAnalyzerSummary]: Excepiton " << ex.what() << " thrown creating " << gifBase.str() << " directory" << endl;
132     }
133    
134     stringstream gifTag; gifTag << "_r" << myRunNumber << "_W" << wh;
135     string gifFile = gifBase.str() + "/" + fileName + gifTag.str() + tag + ".gif";
136     canvas->Update();
137     canvas->Print(gifFile.c_str());
138    
139     }
140     void DTDPGCreateAnalyzerSummary::createGifFile(string fileName, string tag, TCanvas *canvas) {
141    
142     stringstream gifBase;
143     gifBase << "Run" << myRunNumber;
144     try {
145     create_directories(gifBase.str());
146     } catch(const std::exception & ex) {
147     throw cms::Exception("DTDPGCreateAnalyzerSummaryError")<< "[DTDPGCreateAnalyzerSummary]: Excepiton " << ex.what() << " thrown creating " << gifBase.str() << " directory" << endl;
148     }
149    
150     stringstream runTag; runTag << "_r" << myRunNumber;
151    
152     string gifFile = gifBase.str() + "/" + fileName + runTag.str() + tag + ".gif";
153     canvas->Update();
154     canvas->Print(gifFile.c_str());
155    
156     }
157    
158    
159     void DTDPGCreateAnalyzerSummary::createFullWheelPlots() {
160    
161     string Whname[5]={"Wm2","Wm1","W0","W1","W2"};
162    
163     gStyle->SetTitleW(0.55);
164     gStyle->SetTitleH(0.13);
165     gStyle->SetTitleX(0.01);
166     gStyle->SetTitleY(0.99);
167    
168     gStyle->SetOptStat(10);
169     gStyle->SetStatY(0.97);
170     gStyle->SetStatX(0.98);
171     gStyle->SetStatW(0.35);
172     gStyle->SetStatH(0.45);
173    
174    
175     // Get histos to be plotted
176     // char histoname[240];
177     // char htit[240]; // ???
178     TH1F * first_to_paint;
179     string SLname[3]={"Phi1","Theta","Phi2"};
180    
181     int nbin;
182     float max, max1;
183     TPaveText* sid;
184     TPaveText* labcont[50]; TText* cont[50];
185    
186    
187     // Occupancies
188     TH2F *DigiXYS[5][14];
189     for(int iw=0;iw<5;++iw) {
190     for(int isec=1;isec<15;isec++) {
191     stringstream histoname; histoname << "hDigiXY_" << Whname[iw] << "_S" << isec;
192 battilan 1.2 DigiXYS[iw][isec-1]=getHisto<TH2F>(histoname.str());
193 battilan 1.1 }
194     }
195    
196     // Crea and fill individual layer occupancy plots from hDigiXY_S
197     TH1F * DigiXSecMBSlLayer[5][14][4][3][4];
198     for(int iw=0;iw<5;++iw){
199     for(int isec=1;isec<15;++isec){
200     for(int ich=1;ich<5;++ich){
201     for(int isl=1;isl<4;++isl){
202     for(int il=1;il<5;++il){
203     stringstream histoname; histoname << "Occup_" << Whname[iw] << "_S" << isec << "_MB" << ich << "_SL" << isl << "_L" <<il;
204     stringstream histotitle; histotitle << "Occupancy " << Whname[iw] << " S" << isec << " MB" << ich << " SL" << SLname[isl-1] << "L" << il;
205     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]= new TH1F(histoname.str().c_str(),histotitle.str().c_str(),100, 0.,100.);
206     }
207     }
208     }
209     }
210     }
211    
212     for(int iw=0;iw<5;iw++){
213     for(int isec=1;isec<15;isec++){
214    
215     int nbx= DigiXYS[iw][isec-1]->GetNbinsX() ;
216     //int nby= DigiXYS[iw][isec-1]->GetNbinsY() ;
217    
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     int iby=(ich-1)*20+(isl-1)*4+il+1;
222     float totentr=0;
223     for(int ibx=1;ibx<nbx;ibx++){
224     float yval=DigiXYS[iw][isec-1]->GetBinContent(ibx,iby);
225     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetBinContent(ibx,yval);
226     totentr+=yval;
227     }
228     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetEntries(totentr);
229     }
230     }
231     }
232     }
233     }// end loop sector
234    
235     // 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 battilan 1.2 TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]=getHisto<TH1F>(histoname.str());
244 battilan 1.1 }
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 battilan 1.2 Correlated_trig_Bx[iw][isec-1][ich-1][iq-4]=getHisto<TH1F>(histoname.str());
257 battilan 1.1 }
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 battilan 1.2 hTrg_effdenum_SecMB[iw][isec-1][ich-1]=getHisto<TH1F>(heffden.str());
271 battilan 1.1 stringstream heffnum; heffnum << "hTrg_effnum" << htag.str();
272 battilan 1.2 hTrg_effnum_SecMB[iw][isec-1][ich-1]=getHisto<TH1F>(heffnum.str());
273 battilan 1.1 stringstream phihl; phihl << "hPhiHL" << htag.str();
274 battilan 1.2 hPhiHL_SecMB[iw][isec-1][ich-1]=getHisto<TH1F>(phihl.str());
275 battilan 1.1 }
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 battilan 1.2 TriggerMatrix[iw][isec-1]=getHisto<TH1F>(histoname.str());
284 battilan 1.1 }
285     }
286    
287     TH1F * TriggerInclusive[5];
288     for(int iw=0;iw<5;iw++){
289     stringstream histoname; histoname << "TriggerInclusive" << Whname[iw];
290 battilan 1.2 TriggerInclusive[iw]=getHisto<TH1F>(histoname.str());
291 battilan 1.1 }
292    
293     //===================================================================================
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
300    
301     TCanvas *Digi = new TCanvas("Digi", "",201,81,999,699);
302     Digi->Divide(3,4) ;
303    
304     for(int ich=1;ich<5;ich++){
305     for(int isl=1;isl<4;isl++){
306     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     }
334    
335     createGifFile("Occupancies_LogScale",iw-2,isec,"",Digi);
336     delete Digi;
337     }
338     }// End Loop on sectors
339    
340    
341     //===================================================================================
342     // DIGI's occupancies
343     // now print 1 page per SL
344     //===================================================================================
345    
346     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing DIGI's occupancies per layer in 1 single page per SL" << endl;
347     for(int iw=0;iw<5;iw++){ //Loop on wheels
348     for(int isec=1;isec<15;isec++){ // Loop on sectors
349    
350     int ichmin=1; if (isec==13|| isec==14)ichmin=4;
351     for(int ich=ichmin;ich<5;ich++){
352     for(int isl=1;isl<4;isl++){
353     TCanvas *DigiSL = new TCanvas("DigiSL", "",201,81,999,699);
354     bool dodraw=1;
355     if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
356     if(dodraw){
357     // look first for the maximum bin entries
358     first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
359     float nbmax=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
360     for(int il=2;il<5;il++){
361     float nbmax0=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
362     if(nbmax0>nbmax){
363     first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
364     nbmax=nbmax0;
365     }
366     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
367     }
368     stringstream htitle; htitle << "Occupancy W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
369     first_to_paint->SetTitle(htitle.str().c_str());
370     //int icpos=(ich-1)*3+isl;
371     first_to_paint->GetYaxis()->SetLabelSize(0.05);
372     first_to_paint->GetXaxis()->SetLabelSize(0.05);
373     first_to_paint->Draw();
374     for(int il=1;il<5;il++){
375     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
376     }
377    
378     stringstream fileTag; fileTag << "_MB" << ich << "_SL" << SLname[isl-1];
379     createGifFile("Occupancies",(iw-2),isec,fileTag.str(),DigiSL);
380     delete DigiSL;
381     }
382    
383     }//end Loop Superlayers
384     }//end Loop chambers
385     }// End Loop on sectors
386     }// End Loop on wheels
387    
388    
389     //====================================================================================
390     // Time boxes: all in 1 single page (Layer granularity)
391     //===================================================================================
392    
393     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing Time boxes per layer in 1 single page per Sector" << endl;
394     //for(int isec=1;isec<15;isec++) // Loop on sectors
395     for(int iw=0;iw<5;iw++){ //Loop on wheels
396     for(int isec=1;isec<15;isec++){ // Loop on sectors
397    
398     TCanvas *Tboxes = new TCanvas("Tboxes", "",201,81,999,699);
399     Tboxes->Divide(3,4) ;
400    
401     for(int ich=1;ich<5;ich++){
402     for(int isl=1;isl<4;isl++){
403     bool dodraw=1;
404     if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
405     if(dodraw){
406     // look first for the maximum bin entries
407     first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
408     float nbmax=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
409     for(int il=2;il<5;il++){
410     float nbmax0=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
411     if(nbmax0>nbmax){
412     first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
413     nbmax=nbmax0;
414     }
415     TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
416     }
417     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     }
430    
431     createGifFile("Tboxes",(iw-2),isec,"",Tboxes);
432     delete Tboxes;
433     }// End Loop on sectors
434     }// End Loop on wheels
435    
436    
437     //===================================================================================
438     // Time boxes: 1 page per SL
439     //===================================================================================
440    
441     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing Time boxes per layer in 1 single page per SL" << endl;
442     for(int iw=0;iw<5;iw++){ //Loop on wheels
443     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);
449    
450     bool dodraw=1;
451     if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
452     if(dodraw){
453     // look first for the maximum bin entries
454     first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
455     float nbmax=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
456     for(int il=2;il<5;il++){
457     float nbmax0=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
458     if(nbmax0>nbmax){
459     first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
460     nbmax=nbmax0;
461     }
462     TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
463     }
464     stringstream htitle; htitle << "TimeBox W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
465     first_to_paint->SetTitle(htitle.str().c_str());
466     first_to_paint->GetYaxis()->SetLabelSize(0.04);
467     first_to_paint->GetXaxis()->SetLabelSize(0.04);
468     first_to_paint->Draw();
469     for(int il=1;il<5;il++){
470     TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
471     }
472    
473     stringstream fileTag; fileTag << "_MB" << ich << "_SL" << SLname[isl-1];
474     createGifFile("Tboxes",(iw-2),isec,fileTag.str(),TboxSL);
475     delete TboxSL;
476     }
477     }//end loop SL
478     }//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 battilan 1.2
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 battilan 1.1 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 battilan 1.2 for (int ibin=1; ibin<21; ibin++) TriggerMatrix[iw][isec-1]->GetXaxis()->SetBinLabel(ibin,labTriggerMatrix[ibin-1]);
572 battilan 1.1 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 battilan 1.2 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 battilan 1.1 TCanvas *Trigmatri = new TCanvas("TriggerMatrix", "",201,81,999,699);
635     Trigmatri->SetBottomMargin(0.12);
636    
637     nbin = TriggerInclusive[iw]->GetXaxis()->GetNbins();
638     max = 0;
639    
640     for (int ibin=1; ibin<nbin+1; ibin++)
641     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     }
698    
699     createGifFile("TriggerInclusive",(iw-2),isec,"",TrigmatriSec);
700     delete TrigmatriSec;
701     }
702     }// End loop on sectors
703     }// End loop on wheels
704    
705     }
706    
707    
708     void DTDPGCreateAnalyzerSummary::createSummaryWheelPlots() {
709    
710     string Whname[5]={"Wm2","Wm1","W0","W1","W2"};
711     string SLname[3]={"Phi1","Theta","Phi2"};
712    
713 battilan 1.2 TH1F *historun = getHisto<TH1F>("RunInfo_RunNumbers");
714 battilan 1.1 float TotEntries = historun->GetEntries();
715    
716     gStyle->SetTitleX(0.01);
717     gStyle->SetTitleY(0.99);
718    
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    
725     gStyle->SetPalette(1); // set palette for 2D histos
726     gStyle->SetTitleW(0.97);
727     gStyle->SetTitleH(0.1);
728    
729     TH1F * first_to_paint;
730    
731     float BXSummary_mean=0.;
732     float NBXSummary_mean=0.;
733     TH1F *BXSummary[5][4];
734     for(int iw=0;iw<5;iw++){ // Loop in wheels
735     for(int ic=1;ic<5;ic++){
736     stringstream hname; hname << "BX_mean_MB" << ic << "_W" << (iw-2);
737     stringstream htitle; htitle << "BX MeanValue (HH,HL) MB" << ic << " W" << (iw-2);
738     BXSummary[iw][ic-1]= new TH1F(hname.str().c_str(),htitle.str().c_str(),12,1.,13.);
739     for(int is=1;is<13;is++){
740     stringstream xlab; xlab << "S" << is;
741     BXSummary[iw][ic-1]->GetXaxis()->SetBinLabel(is,xlab.str().c_str());
742     }
743     }
744     }
745    
746    
747    
748 battilan 1.2 for(int iw=0;iw<5;iw++){ // Loop in wheels
749 battilan 1.1
750     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Processing Wheel " << iw-2 << endl;
751     //===================================================================================
752     // Digi scatter plots
753     //===================================================================================
754     TCanvas *DQM1 = new TCanvas("DQM1", "",201,81,999,699);
755     DQM1->Divide(2,3) ;
756     TCanvas *DQM1b = new TCanvas("DQM1b", "",201,81,999,699);
757     DQM1b->Divide(2,3) ;
758     TCanvas *DQM2 = new TCanvas("DQM2", "",201,81,999,699);
759     DQM2->Divide(2,3) ;
760     TCanvas *DQM2b = new TCanvas("DQM2b", "",201,81,999,699);
761     DQM2b->Divide(2,3) ;
762    
763     TH2F *hDigiXYList[14];
764    
765     for(int isec=1;isec<13;isec++){
766     stringstream histoname; histoname << "hDigiXY_" << Whname[iw] << "_S" << isec;
767 battilan 1.2 hDigiXYList[isec-1]= getHisto<TH2F>(histoname.str());
768 battilan 1.1 }
769    
770     float Max=2000;
771     float Max0[12];
772     float MaxMean=0;
773     float MaxMean0=0;
774     float MaxRMS0=0;
775     float MaxRMS=0;
776     int Ns=0;
777     for(int is=0;is<12; is++){
778     Max0[is]=0;
779     Max0[is]=hDigiXYList[is]->GetMaximum();
780     if(Max0[is]>Max)Max=Max0[is];
781     if(Max0[is]>0){ MaxMean0+=Max0[is]; MaxRMS0+=Max0[is]*Max0[is];Ns++;}
782     }
783    
784     for(int is=0;is<12; is++){
785     if(is<6){DQM1->cd(is+1); DQM1->cd(is+1)->SetLogz();}
786     else {DQM2->cd(is-5); DQM2->cd(is-5)->SetLogz();}
787     hDigiXYList[is]->SetStats(0);
788     hDigiXYList[is]->SetMaximum(Max);
789     hDigiXYList[is]->Draw("colz");
790     }
791    
792     stringstream fileDigi; fileDigi <<"Digi_r" << myRunNumber <<"_W" << (iw-2);
793     createGifFile("Digi",(iw-2),"_S1-S6",DQM1);
794     createGifFile("Digi",(iw-2),"_S7_S12",DQM2);
795    
796     if(Max>TotEntries){ // To cut noise cells and see better the
797     // occupancies on other cells
798     for(int is=0;is<12; is++){
799     if(is<6){DQM1b->cd(is+1); DQM1b->cd(is+1)->SetLogz();}
800     else {DQM2b->cd(is-5); DQM2b->cd(is-5)->SetLogz();}
801     hDigiXYList[is]->SetStats(0);
802     hDigiXYList[is]->SetMaximum(TotEntries);
803     hDigiXYList[is]->Draw("colz");
804     }
805    
806     createGifFile("Digi",(iw-2),"_S1-S6_b",DQM1b);
807     createGifFile("Digi",(iw-2),"_S7-S12_b",DQM2b);
808     }
809    
810     //===================================================================================
811     // Ocupancies per SL
812     //===================================================================================
813    
814     // Get histos to be plotted
815     int nbin;
816     float max, max1;
817     TPaveText *sid;
818     char sid1[50]; char answ;
819     TPaveText *labcont[50]; TText *cont[50];
820    
821     // Occupancies
822     TH2F *DigiXYS[5][14];
823     for(int isec=1;isec<15;isec++){
824     stringstream histoname; histoname << "hDigiXY_" << Whname[iw] << "_S" << isec;
825 battilan 1.2 DigiXYS[iw][isec-1]=getHisto<TH2F>(histoname.str());
826 battilan 1.1 }
827    
828     // Crea and fill individual layer occupancy plots from hDigiXY_S
829     TH1F *DigiXSecMBSl[5][14][4][3];
830     TH1F *DigiXSecMBSlLayer[5][14][4][3][4];
831     for(int isec=1;isec<15;isec++){
832     for(int ich=1;ich<5;ich++){
833     for(int isl=1;isl<4;isl++){
834     stringstream hnamesl; hnamesl << "Occup_" << Whname[iw] << "_S" << isec << "_MB" << ich <<" _SL" << isl;
835     stringstream htitlesl; htitlesl << "Occupancy " << Whname[iw] << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
836     DigiXSecMBSl[iw][isec-1][ich-1][isl-1]= new TH1F(hnamesl.str().c_str(),htitlesl.str().c_str(),100, 0.,100.);
837     for(int il=1;il<5;il++){
838     stringstream hnamel; hnamel << hnamesl.str() << "_L" << il;
839     stringstream htitlel; htitlel << htitlesl.str()<< " L" << il;
840     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]= new TH1F(hnamel.str().c_str(),htitlel.str().c_str(),100, 0.,100.);
841     }
842     }
843     }
844     }
845    
846     for(int isec=1;isec<15;isec++){
847     int nbx= DigiXYS[iw][isec-1]->GetNbinsX() ;
848     int nby= DigiXYS[iw][isec-1]->GetNbinsY() ;
849    
850     for(int ich=1;ich<5;ich++){
851     for(int isl=1;isl<4;isl++){
852     // Fill layer histos
853     for(int il=1;il<5;il++){
854     int iby=(ich-1)*20+(isl-1)*4+il+1;
855     float totentr=0;
856     for(int ibx=1;ibx<nbx;ibx++){
857     float yval=DigiXYS[iw][isec-1]->GetBinContent(ibx,iby);
858     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetBinContent(ibx,yval);
859     totentr+=yval;
860     }
861     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetEntries(totentr);
862     }
863     // Fill SL histos adding individual layer contents
864     for(int ibx=1;ibx<nbx;ibx++){
865     float yval=0;
866     for(int il=1;il<5;il++)
867     yval+=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetBinContent(ibx);
868    
869     DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->SetBinContent(ibx,yval);
870     }
871     }
872     }
873     }// end loop sector
874    
875     //===================================================================================
876     // DIGI's occupancies
877     //===================================================================================
878    
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);
883     for(int isec=1;isec<13;isec++){ // Loop on sectors
884     for(int ich=1;ich<5;ich++){
885     // look first for the maximum bin entries
886     first_to_paint=DigiXSecMBSl[iw][isec-1][ich-1][0];
887     float nbmax=DigiXSecMBSl[iw][isec-1][ich-1][0]->GetMaximum();
888     for(int isl=1;isl<4;isl++){
889     if(!(ich==4 && isl==2)){ // avoid ThetaMB4
890     float nbmax0=DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->GetMaximum();
891     if(nbmax0>nbmax){
892     first_to_paint=DigiXSecMBSl[iw][isec-1][ich-1][isl-1];
893     nbmax=nbmax0;
894     }
895     DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->SetLineColor(isl);
896     }
897     }
898     stringstream htitle; htitle << "Occupancy W" << (iw-2) << " S" << isec << " MB" << ich;
899     first_to_paint->SetTitle(htitle.str().c_str());
900     if(isec<5) {int icpos=(isec-1)*4+ich; Digi1->cd(icpos) ; Digi1->cd(icpos)->SetLogy();}
901     if(isec>4 && isec<9) {int icpos=(isec-5)*4+ich; Digi2->cd(icpos) ; Digi2->cd(icpos)->SetLogy();}
902     if(isec>8 && isec<13){int icpos=(isec-9)*4+ich; Digi3->cd(icpos) ; Digi3->cd(icpos)->SetLogy();}
903     first_to_paint->GetYaxis()->SetLabelSize(0.07);
904     first_to_paint->GetXaxis()->SetLabelSize(0.07);
905     first_to_paint->Draw();
906     for(int isl=1;isl<4;isl++){
907     if(!(ich==4 && isl==2)) // avoid ThetaMB4
908     DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->Draw("same");
909     }
910     }
911     }// End Loop on sectors
912     createGifFile("Occupancies_LogScale",(iw-2),"_S1-S4",Digi1);
913     createGifFile("Occupancies_LogScale",(iw-2),"_S5-S8",Digi2);
914     createGifFile("Occupancies_LogScale",(iw-2),"_S9-S12",Digi3);
915    
916     //===================================================================================
917     // TimeBoxes
918     //===================================================================================
919     DQM1->Clear();
920     DQM1->Divide(6,2) ;
921     for (int ins=1; ins<13;ins++){
922     TH1F *hHisto[4];
923     int nbmax=0;
924     int nbmax0=0;
925    
926     DQM1->cd(ins);
927     for(int ic=1;ic<5;ic++){
928     stringstream hname; hname << "htime_" << Whname[iw] << "_S" << ins << "_MB" << ic;
929 battilan 1.2 hHisto[ic-1]=getHisto<TH1F>(hname.str());
930 battilan 1.1 hHisto[ic-1]->SetLineColor(ic);
931     }
932    
933     first_to_paint = hHisto[0];
934     nbmax=hHisto[0]->GetMaximum();
935    
936     for(int ic=2;ic<5;ic++){
937     nbmax0=hHisto[ic-1]->GetMaximum();
938     if(nbmax0>nbmax){
939     nbmax=nbmax0;
940     first_to_paint=hHisto[ic-1];
941     }
942     }
943    
944     first_to_paint->GetXaxis()->SetLabelSize(0.08);
945     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
946     first_to_paint->GetXaxis()->SetTitle("cm");
947     first_to_paint->GetXaxis()->SetTitleSize(0.09);
948     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
949     first_to_paint->GetXaxis()->SetNdivisions(308);
950     char htit[240];
951     stringstream htitle; htitle << "TimeBox W" << iw-2 << " S" << ins;
952     first_to_paint->SetTitle(htitle.str().c_str());
953     first_to_paint->Draw();
954     for(int ic=1;ic<5;ic++)hHisto[ic-1]->Draw("same");
955    
956     }// end loop on sectors
957     stringstream fileTBox; fileTBox <<"TBox_r" << myRunNumber <<"_W" << (iw-2);
958     createGifFile("TBox",(iw-2),"",DQM1);
959    
960     //===================================================================================
961     // Hit Residuals
962     //===================================================================================
963     DQM1->Clear();
964     DQM1->Divide(6,2) ;
965    
966     for(int ins=1;ins<13; ins++){
967     TH1F *hHisto[4];
968     DQM1->cd(ins);
969    
970     int nbmax=0;
971     int nbmax0=0;
972    
973     for(int ic=1;ic<5;ic++){
974     stringstream hname; hname << "hResX_" << Whname[iw] << "_S" << ins << "_MB" << ic;
975 battilan 1.2 hHisto[ic-1]= getHisto<TH1F>(hname.str());
976 battilan 1.1 hHisto[ic-1]->SetLineColor(ic);
977     }
978    
979     first_to_paint = hHisto[0];
980     nbmax=hHisto[0]->GetMaximum();
981    
982     for(int ic=2;ic<5;ic++){
983     nbmax0=hHisto[ic-1]->GetMaximum();
984     if(nbmax0>nbmax){
985     nbmax=nbmax0;
986     first_to_paint=hHisto[ic-1];
987     }
988     }
989    
990     first_to_paint->GetXaxis()->SetLabelSize(0.08);
991     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
992     first_to_paint->GetXaxis()->SetTitle("cm");
993     first_to_paint->GetXaxis()->SetTitleSize(0.09);
994     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
995     first_to_paint->GetXaxis()->SetNdivisions(308);
996     stringstream htitle; htitle << "Hit residuals W" << (iw-2) << " S" << ins;
997     first_to_paint->SetTitle(htitle.str().c_str());
998    
999     first_to_paint->Draw();
1000     for(int ic=1;ic<5;ic++)
1001     hHisto[ic-1]->Draw("same");
1002     }// end loop on sectors
1003    
1004     createGifFile("HitResiduals",(iw-2),"",DQM1);
1005    
1006     //===================================================================================
1007     // Angle Phi LOCAL
1008     //===================================================================================
1009     DQM1->Clear();
1010     DQM1->Divide(6,2) ;
1011    
1012     for (int ins=1; ins<13;ins++){
1013     TH1F *hPhi[4];
1014     DQM1->cd(ins);
1015     int nbmax=0;
1016     int nbmax0=0;
1017    
1018     for(int ic=1;ic<5;ic++){
1019     stringstream hname; hname << "hPhi_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1020 battilan 1.2 hPhi[ic-1]=getHisto<TH1F>(hname.str());
1021 battilan 1.1 hPhi[ic-1]->SetLineColor(ic);
1022     }
1023    
1024     first_to_paint = hPhi[0];
1025     nbmax=hPhi[0]->GetMaximum();
1026    
1027     for(int ic=2;ic<5;ic++){
1028     nbmax0=hPhi[ic-1]->GetMaximum();
1029     if(nbmax0>nbmax){
1030     nbmax=nbmax0;
1031     first_to_paint=hPhi[ic-1];
1032     }
1033     }
1034    
1035     first_to_paint->GetXaxis()->SetLabelSize(0.08);
1036     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1037     first_to_paint->GetXaxis()->SetTitle("deg");
1038     first_to_paint->GetXaxis()->SetTitleSize(0.09);
1039     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1040     first_to_paint->GetXaxis()->SetNdivisions(308);
1041     stringstream htitle; htitle << "Phi local W" << (iw-2) << " S" << ins;
1042     first_to_paint->SetTitle(htitle.str().c_str());
1043    
1044     first_to_paint->Draw();
1045     for(int ic=1;ic<5;ic++) hPhi[ic-1]->Draw( "same");
1046    
1047     }// end loop on sectors
1048    
1049    
1050     createGifFile("PhiLocal",(iw-2),"",DQM1);
1051    
1052     //===================================================================================
1053     // STA Digis
1054     //===================================================================================
1055     DQM1->Clear();
1056    
1057     stringstream hnameSTADigi; hnameSTADigi << "hHitsPosXYSA_" << Whname[iw];
1058 battilan 1.2 TH1F *hXYHisto=getHisto<TH1F>(hnameSTADigi.str());;
1059 battilan 1.1
1060     hXYHisto->SetStats(0);
1061     hXYHisto->Draw("colz");
1062    
1063    
1064     createGifFile("STADigi",(iw-2),"",DQM1);
1065    
1066    
1067     //===================================================================================
1068     // STA Phi Hits
1069     //===================================================================================
1070     TCanvas *DQM6 = new TCanvas("DQM6", "",301,81,999,699); // open a large canvas
1071 battilan 1.2 TH1F *hnHitDT= getHisto<TH1F>("hnHitDT");
1072 battilan 1.1 Float_t Nevents = hnHitDT->GetEntries();
1073     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Total nr. of triggers:" << Nevents << endl;
1074    
1075     TH1F *hPhiHisto[4];
1076     TH1F *heff[4];
1077    
1078     float ymax = 0.1;
1079     for(int ic=1;ic<5;ic++){
1080     stringstream hname1, hname2, htitle;
1081    
1082     hname1 << "hPhiHit_" << Whname[iw] << "_MB" << ic;
1083 battilan 1.2 hPhiHisto[ic-1]=getHisto<TH1F>(hname1.str());
1084 battilan 1.1
1085     hname2 << "heff" << ic;
1086     heff[ic-1] =(TH1F*) hPhiHisto[ic-1]->Clone(hname2.str().c_str());
1087     heff[ic-1]->Add(heff[ic-1],heff[ic-1],0.5/Nevents,0.5/Nevents);
1088    
1089     heff[ic-1]->SetMaximum(ymax);
1090     heff[ic-1]->SetStats(0);
1091     heff[ic-1]->SetLineColor(ic);
1092     htitle << "Phi of ass. hit, W" << (iw-2);
1093     heff[0]->SetTitle(htitle.str().c_str());
1094     if(ic==1)heff[ic-1]->Draw();
1095     else heff[ic-1]->Draw("same");
1096    
1097     }
1098    
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     //===================================================================================
1141     // STA Hits
1142     //===================================================================================
1143     DQM1->Clear();
1144     DQM1->Divide(6,2) ;
1145    
1146     TH1F *hNassList[12];
1147    
1148     for(int isec=1;isec<13;isec++){
1149     stringstream histoname; histoname << "hNhass_" << Whname[iw] << "_S" << isec;
1150 battilan 1.2 hNassList[isec-1]=getHisto<TH1F>(histoname.str());
1151 battilan 1.1 }
1152    
1153    
1154     for(int is=0;is<12;is++){
1155     hNassList[is]->GetXaxis()->SetNdivisions(308);
1156     hNassList[is]->GetXaxis()->SetLabelSize(0.08);
1157     hNassList[is]->GetXaxis()->SetLabelOffset(-0.025);
1158     hNassList[is]->GetXaxis()->SetTitle("# hits");
1159     hNassList[is]->GetXaxis()->SetTitleSize(0.01);
1160     hNassList[is]->GetXaxis()->SetTitleOffset(0.5);
1161    
1162     DQM1->cd(is+1);
1163     hNassList[is]->SetStats(1);
1164     hNassList[is]->Draw();
1165     }
1166    
1167     createGifFile("STAHits",(iw-2),"",DQM1);
1168    
1169    
1170     //===================================================================================
1171     // Segment Hits
1172     //===================================================================================
1173     DQM2->Clear();
1174     DQM2->Divide(6,2);
1175    
1176     TH1F *hNhits[12][4];
1177     for (int ins=1; ins<13;ins++){
1178     DQM2->cd(ins);
1179     int nbmax=0;
1180     int nbmax0=0;
1181    
1182     for(int ic=1;ic<5;ic++){
1183     stringstream hname; hname << "hNhits_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1184 battilan 1.2 hNhits[ins-1][ic-1]= getHisto<TH1F>(hname.str());
1185 battilan 1.1 hNhits[ins-1][ic-1]->SetLineColor(ic);
1186     }
1187    
1188     first_to_paint= hNhits[ins-1][0];
1189     nbmax=hNhits[ins-1][0]->GetMaximum();
1190    
1191     for(int ic=2;ic<5;ic++){
1192     nbmax0=hNhits[ins-1][ic-1]->GetMaximum();
1193     if(nbmax0>nbmax){
1194     nbmax=nbmax0;
1195     first_to_paint=hNhits[ins-1][ic-1];
1196     }
1197     }
1198    
1199     first_to_paint->GetXaxis()->SetLabelSize(0.08);
1200     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1201     first_to_paint->GetXaxis()->SetTitle("#hits");
1202     first_to_paint->GetXaxis()->SetTitleSize(0.09);
1203     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1204     first_to_paint->GetXaxis()->SetNdivisions(308);
1205     stringstream htitle; htitle << "# hits in seg W" << (iw-2) << " S" << ins;
1206     first_to_paint->SetTitle(htitle.str().c_str());
1207    
1208     first_to_paint->Draw();
1209     for(int ic=1;ic<5;ic++) hNhits[ins-1][ic-1]->Draw( "same");
1210    
1211     }// end loop on sectors
1212    
1213    
1214     createGifFile("SegHits",(iw-2),"",DQM2);
1215    
1216     //===================================================================================
1217     // Segment Hits
1218     //===================================================================================
1219     DQM1->Clear();
1220     DQM1->Divide(6,2);
1221     TH1F * hNsegsList[12];
1222     for(int is=0;is<12;is++){
1223     stringstream hname; hname << "hNsegs_" << Whname[iw] << "_S" <<is+1;
1224 battilan 1.2 hNsegsList[is]= getHisto<TH1F>(hname.str());
1225 battilan 1.1 hNsegsList[is]->GetXaxis()->SetTitle("# Segments");
1226     }
1227    
1228     for(int is=0;is<12;is++){
1229     DQM1->cd(is+1);
1230     hNsegsList[is]->GetXaxis()->SetNdivisions(308);
1231     hNsegsList[is]->GetXaxis()->SetLabelSize(0.08);
1232     hNsegsList[is]->GetXaxis()->SetLabelOffset(-0.025);
1233     hNsegsList[is]->GetXaxis()->SetTitleSize(0.09);
1234     hNsegsList[is]->GetXaxis()->SetTitleOffset(0.5);
1235     hNsegsList[is]->SetStats(1);
1236     hNsegsList[is]->Draw();
1237     }
1238    
1239     createGifFile("Segments",(iw-2),"",DQM1);
1240    
1241     //===================================================================================
1242     // TMAX
1243     //===================================================================================
1244    
1245     TCanvas *DQM11 = new TCanvas("DQM11", "1",101,81,999,699);
1246     TCanvas *DQM12 = new TCanvas("DQM12", "2",101,81,999,699);
1247     TCanvas *DQM13 = new TCanvas("DQM13", "3",101,81,999,699);
1248     TCanvas *DQM14 = new TCanvas("DQM14", "4",101,81,999,699);
1249     DQM11->Divide(4,3) ;
1250     DQM12->Divide(4,3) ;
1251     DQM13->Divide(4,3) ;
1252     DQM14->Divide(4,3) ;
1253    
1254     for (int ins=1; ins<13;ins++){
1255     TH1F *hHisto[2];
1256     for(int ic=1;ic<5;ic++){
1257    
1258     stringstream hname; hname << "htmax_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1259 battilan 1.2 hHisto[0]= getHisto<TH1F>(hname.str()+"_SL1");
1260     hHisto[1]= getHisto<TH1F>(hname.str()+"_SL3");
1261 battilan 1.1
1262     if(ins<4){
1263     int ipos=(ins-1)*4+ic;
1264     DQM11->cd(ipos);
1265     }
1266     if(ins>3 && ins<7){
1267     int ipos=(ins-4)*4+ic;
1268     DQM12->cd(ipos);
1269     }
1270     if(ins>6 && ins<10){
1271     int ipos=(ins-7)*4+ic;
1272     DQM13->cd(ipos);
1273     }
1274     if(ins>9){
1275     int ipos=(ins-10)*4+ic;
1276     DQM14->cd(ipos);
1277     }
1278    
1279     hHisto[0]->SetStats(1);
1280     //hHisto[0]->Fit("gaus"); //CB va scommentato e wrappato!!!!
1281     hHisto[1]->SetLineColor(2);
1282     hHisto[1]->Draw("same");
1283     }// end loop on chambers
1284     }// end loop on sectors
1285    
1286     stringstream fileTMax; fileTMax << "TMax_r" << myRunNumber <<"_W" << (iw-2);
1287     createGifFile("TMax",(iw-2),"S1-S3",DQM11);
1288     createGifFile("TMax",(iw-2),"S4-S6",DQM11);
1289     createGifFile("TMax",(iw-2),"S7-S9",DQM11);
1290     createGifFile("TMax",(iw-2),"S10-S12",DQM11);
1291    
1292    
1293     //===================================================================================
1294     // Phi-Trig Efficiency
1295     //===================================================================================
1296     TCanvas *Eff = new TCanvas("Eff", "",201,81,999,699);
1297     TH1F *hHisto[4];
1298     TH1F *hHistoTr[4];
1299     TH1F *heffx[4];
1300     for(int ic=1;ic<5;ic++)
1301     {
1302     stringstream hname1; hname1 << "hPhiGlob_" << Whname[iw] << "_MB" << ic;
1303 battilan 1.2 hHisto[ic-1]= getHisto<TH1F>(hname1.str());
1304 battilan 1.1
1305     stringstream hname2; hname2 << "heff" << ic <<"x";
1306     //heffx[ic-1]=hHisto[ic-1]->Clone(hname);
1307     heffx[ic-1] =(TH1F*) hHisto[ic-1]->Clone(hname2.str().c_str());
1308     heffx[ic-1]->SetLineColor(ic);
1309    
1310     stringstream hname3; hname3 << "hPhiTrigg_" << Whname[iw] << "_MB" << ic;
1311 battilan 1.2 hHistoTr[ic-1]= getHisto<TH1F>(hname3.str());
1312 battilan 1.1 heffx[ic-1]->Divide(hHistoTr[ic-1],hHisto[ic-1],1.0,1.0);
1313    
1314     for (int i = 0; i <= heffx[ic-1]->GetNbinsX()+1; i++ ) {
1315     Float_t tot = hHisto[ic-1]->GetBinContent(i) ;
1316     Float_t tot_e = hHisto[ic-1]->GetBinError(i);
1317     Float_t eff = heffx[ic-1]->GetBinContent(i) ;
1318     Float_t Err = 0.;
1319     if (tot > 0) Err = tot_e / tot * sqrt( eff* (1-eff) );
1320     // if (eff == 1. || isnan(Err) || !isfinite(Err) ) Err=1.e-3;
1321     heffx[ic-1]->SetBinError(i, Err);
1322     }
1323     heffx[ic-1]->SetStats(0);
1324     heffx[ic-1]->SetMaximum(1);
1325     stringstream htitle; htitle << "Phi-Trigger Eff W" << iw-2;
1326     heffx[0]->SetTitle(htitle.str().c_str());
1327     heffx[0]->SetMaximum(1.02);
1328    
1329     if(ic==1)heffx[ic-1]->Draw();
1330     else heffx[ic-1]->Draw("same");
1331     }
1332    
1333     ymax = 1.;
1334     l = new TLine(-165, 0, -165, ymax); l->Draw();
1335     l = new TLine(-135, 0, -135, ymax); l->Draw();
1336     l = new TLine(-105, 0, -105, ymax); l->Draw();
1337     l = new TLine( -75, 0, -75, ymax); l->Draw();
1338     l = new TLine( -45, 0, -45, ymax); l->Draw();
1339     l = new TLine( -15, 0, -15, ymax); l->Draw();
1340     l = new TLine( 15, 0, 15, ymax); l->Draw();
1341     l = new TLine( 45, 0, 45, ymax); l->Draw();
1342     l = new TLine( 75, 0, 75, ymax); l->Draw();
1343     l = new TLine( 105, 0, 105, ymax); l->Draw();
1344     l = new TLine( 135, 0, 135, ymax); l->Draw();
1345     l = new TLine( 165, 0, 165, ymax); l->Draw();
1346    
1347     createGifFile("TrigEff",(iw-2),"",Eff);
1348    
1349    
1350     //===================================================================================
1351     // Segment Hits
1352     //===================================================================================
1353     DQM1->Clear();
1354     DQM1->Divide(6,2) ;
1355    
1356     for (int ins=1; ins<13;ins++){
1357     TH1F *hHisto[4];
1358     DQM1->cd(ins);
1359    
1360     int nbmax=0;
1361     int nbmax0=0;
1362    
1363    
1364     for(int ic=1;ic<5;ic++){
1365     stringstream hname; hname << "hTrigBits_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1366 battilan 1.2 hHisto[ic-1]= getHisto<TH1F>(hname.str());
1367 battilan 1.1 hHisto[ic-1]->SetLineColor(ic);
1368     }
1369    
1370     first_to_paint = hHisto[0];
1371     nbmax=hHisto[0]->GetMaximum();
1372    
1373     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
1394    
1395     createGifFile("TrigHighQual",(iw-2),"",DQM1);
1396    
1397    
1398     //===================================================================================
1399     // SC BX Summary
1400     //===================================================================================
1401     TCanvas *BX = new TCanvas("BX", "",201,81,999,699);
1402     BX->Divide(6,2);
1403     for(int ins=1;ins<13;ins++){ // Loop in sectors
1404    
1405     int nbmax=0;
1406     int nbmax0=0;
1407    
1408     TH1F *hHH[4];
1409     TH1F *hHL[4];
1410     BX->cd(ins);
1411     BX->cd(ins)->SetLogy();
1412     for(int ic=1;ic<5;ic++){ // Loop in chambers
1413    
1414     stringstream hname; hname << "hTrigBX_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1415 battilan 1.2 hHH[ic-1]= getHisto<TH1F>(hname.str()+"_qual6");
1416     hHL[ic-1]= getHisto<TH1F>(hname.str()+"_qual5");
1417 battilan 1.1
1418     hHH[ic-1]->Add(hHL[ic-1]);
1419     hHH[ic-1]->SetLineColor(ic);
1420     hHH[ic-1]->SetStats(0);
1421     } // end loop in chambers
1422    
1423     first_to_paint = hHH[0];
1424     nbmax=hHH[0]->GetMaximum();
1425     first_to_paint->Draw();
1426    
1427     for(int ic=2;ic<5;ic++){
1428     nbmax0=hHH[ic-1]->GetMaximum();
1429     if(nbmax0>nbmax){
1430     nbmax=nbmax0;
1431     first_to_paint=hHH[ic-1];
1432     }
1433     }
1434    
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);
1451    
1452     // CB fai il delete dei vari canvases!
1453    
1454     }// END loop in wheels
1455    
1456     }
1457    
1458    
1459     void DTDPGCreateAnalyzerSummary::createSummaryAllPlots() {
1460    
1461     string Whname[5]={"Wm2","Wm1","W0","W1","W2"};
1462    
1463     gStyle->SetTitleX(0.01);
1464     gStyle->SetTitleY(0.99);
1465    
1466     gStyle->SetOptStat(10);
1467     gStyle->SetStatY(0.97);
1468     gStyle->SetStatX(0.98);
1469     gStyle->SetStatW(0.35);
1470     gStyle->SetStatH(0.45);
1471    
1472     gStyle->SetPalette(1); // set palette for 2D histos
1473     gStyle->SetTitleW(0.97);
1474     gStyle->SetTitleH(0.1);
1475    
1476     float BXSummary_mean=0.;
1477     float NBXSummary_mean=0.;
1478     TH1F * BXSummary[5][4];
1479     for(int iw=0;iw<5;iw++){ // Loop in wheels
1480     for(int ic=1;ic<5;ic++){
1481    
1482     stringstream hname, htitle;
1483     hname << "BX_mean_MB" << ic << "_W" << (iw-2);
1484     htitle << "BX MeanValue (HH,HL) MB" << ic << " W" << (iw-2);
1485     BXSummary[iw][ic-1]= new TH1F(hname.str().c_str(),htitle.str().c_str(),12,1.,13.);
1486     for(int is=1;is<13;is++){
1487     stringstream xlab; xlab << "S" << is;
1488     BXSummary[iw][ic-1]->GetXaxis()->SetBinLabel(is,xlab.str().c_str());
1489     }
1490     }
1491     }
1492    
1493    
1494     //===================================================================================
1495     // SC BX Summary
1496     //===================================================================================
1497     for(int iw=0;iw<5;iw++){ // Loop in wheels
1498     for(int ins=1;ins<13;ins++){ // Loop in sectors
1499    
1500     TH1F *hHH[4];
1501     TH1F *hHL[4];
1502     for(int ic=1;ic<5;ic++){ // Loop in chambers
1503    
1504     stringstream hname; hname << "hTrigBX_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1505 battilan 1.2 hHH[ic-1]= getHisto<TH1F>(hname.str()+"_qual6");
1506     hHL[ic-1]= getHisto<TH1F>(hname.str()+"_qual5");
1507 battilan 1.1
1508     hHH[ic-1]->Add(hHL[ic-1]);
1509     hHH[ic-1]->SetLineColor(ic);
1510     hHH[ic-1]->SetStats(0);
1511    
1512     // Compute average for BX summary plot
1513     int nb=hHH[ic-1]->GetNbinsX();
1514     int nbMax=hHH[ic-1]->GetMaximumBin();
1515     float xmean=0;
1516     float xtot0=0;
1517     for(int inb=nbMax-2;inb<nbMax+3;inb++){ // Takes Central BX+-2
1518     if(inb>1 && inb<nb){ //To avoid problems if it is on the "border"
1519     float yval=hHH[ic-1]->GetBinContent(inb);
1520     float xval=hHH[ic-1]->GetBinCenter(inb);
1521     xmean+=xval*yval;
1522     xtot0+=yval;
1523     }
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     }
1531     }
1532     }// end Loop in chambers
1533     }// END loop in wheels and sectors
1534    
1535     string titlename = "BX Average (HH,HL)";
1536     TCanvas *BXaverage = new TCanvas("BXAverage", "",201,81,999,699);
1537     BXaverage->SetTopMargin(0.42);
1538     BXaverage->SetBottomMargin(0.32);
1539     BXaverage->SetRightMargin(0.12);
1540     BXaverage->Divide(1,5,0.,0) ;
1541    
1542     TPaveLabel* title = new TPaveLabel(0.1,0.93,0.85,0.99,titlename.c_str());
1543     title->SetFillColor(0);
1544     title->SetTextColor(4);
1545     title->Draw();
1546    
1547     int BXSummary_min=0;
1548     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     }
1572    
1573     createGifFile("TrigBXhhhl_average","",BXaverage);
1574     delete BXaverage;
1575    
1576     }
1577    
1578