ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DTDPGAnalysis/src/DTDPGCreateAnalyzerSummary.cc
Revision: 1.4
Committed: Thu Nov 6 14:33:23 2008 UTC (16 years, 6 months ago) by battilan
Content type: text/plain
Branch: MAIN
CVS Tags: V00-00-04, V00-00-03
Changes since 1.3: +10 -6 lines
Log Message:
fixed tmax plot bug and wrapped fit function

File Contents

# User Rev Content
1 battilan 1.1 /*
2     * See header file for a description of this class.
3     *
4 battilan 1.4 * $Date: 2008/11/03 12:56:44 $
5     * $Revision: 1.3 $
6 battilan 1.1 * \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     createGifFile("Digi",(iw-2),"_S1-S6",DQM1);
793     createGifFile("Digi",(iw-2),"_S7_S12",DQM2);
794    
795     if(Max>TotEntries){ // To cut noise cells and see better the
796     // occupancies on other cells
797     for(int is=0;is<12; is++){
798     if(is<6){DQM1b->cd(is+1); DQM1b->cd(is+1)->SetLogz();}
799     else {DQM2b->cd(is-5); DQM2b->cd(is-5)->SetLogz();}
800     hDigiXYList[is]->SetStats(0);
801     hDigiXYList[is]->SetMaximum(TotEntries);
802     hDigiXYList[is]->Draw("colz");
803     }
804    
805     createGifFile("Digi",(iw-2),"_S1-S6_b",DQM1b);
806     createGifFile("Digi",(iw-2),"_S7-S12_b",DQM2b);
807     }
808    
809     //===================================================================================
810     // Ocupancies per SL
811     //===================================================================================
812    
813     // Get histos to be plotted
814     int nbin;
815     float max, max1;
816     TPaveText *sid;
817     char sid1[50]; char answ;
818     TPaveText *labcont[50]; TText *cont[50];
819    
820     // Occupancies
821     TH2F *DigiXYS[5][14];
822     for(int isec=1;isec<15;isec++){
823     stringstream histoname; histoname << "hDigiXY_" << Whname[iw] << "_S" << isec;
824 battilan 1.2 DigiXYS[iw][isec-1]=getHisto<TH2F>(histoname.str());
825 battilan 1.1 }
826    
827     // Crea and fill individual layer occupancy plots from hDigiXY_S
828     TH1F *DigiXSecMBSl[5][14][4][3];
829     TH1F *DigiXSecMBSlLayer[5][14][4][3][4];
830     for(int isec=1;isec<15;isec++){
831     for(int ich=1;ich<5;ich++){
832     for(int isl=1;isl<4;isl++){
833     stringstream hnamesl; hnamesl << "Occup_" << Whname[iw] << "_S" << isec << "_MB" << ich <<" _SL" << isl;
834     stringstream htitlesl; htitlesl << "Occupancy " << Whname[iw] << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
835     DigiXSecMBSl[iw][isec-1][ich-1][isl-1]= new TH1F(hnamesl.str().c_str(),htitlesl.str().c_str(),100, 0.,100.);
836     for(int il=1;il<5;il++){
837     stringstream hnamel; hnamel << hnamesl.str() << "_L" << il;
838     stringstream htitlel; htitlel << htitlesl.str()<< " L" << il;
839     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]= new TH1F(hnamel.str().c_str(),htitlel.str().c_str(),100, 0.,100.);
840     }
841     }
842     }
843     }
844    
845     for(int isec=1;isec<15;isec++){
846     int nbx= DigiXYS[iw][isec-1]->GetNbinsX() ;
847     int nby= DigiXYS[iw][isec-1]->GetNbinsY() ;
848    
849     for(int ich=1;ich<5;ich++){
850     for(int isl=1;isl<4;isl++){
851     // Fill layer histos
852     for(int il=1;il<5;il++){
853     int iby=(ich-1)*20+(isl-1)*4+il+1;
854     float totentr=0;
855     for(int ibx=1;ibx<nbx;ibx++){
856     float yval=DigiXYS[iw][isec-1]->GetBinContent(ibx,iby);
857     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetBinContent(ibx,yval);
858     totentr+=yval;
859     }
860     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetEntries(totentr);
861     }
862     // Fill SL histos adding individual layer contents
863     for(int ibx=1;ibx<nbx;ibx++){
864     float yval=0;
865     for(int il=1;il<5;il++)
866     yval+=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetBinContent(ibx);
867    
868     DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->SetBinContent(ibx,yval);
869     }
870     }
871     }
872     }// end loop sector
873    
874     //===================================================================================
875     // DIGI's occupancies
876     //===================================================================================
877    
878     TCanvas *Digi1 = new TCanvas("Digi1", "",201,81,999,699);
879     TCanvas *Digi2 = new TCanvas("Digi2", "",201,81,999,699);
880     TCanvas *Digi3 = new TCanvas("Digi3", "",201,81,999,699);
881     Digi1->Divide(4,4); Digi2->Divide(4,4); Digi3->Divide(4,4);
882     for(int isec=1;isec<13;isec++){ // Loop on sectors
883     for(int ich=1;ich<5;ich++){
884     // look first for the maximum bin entries
885     first_to_paint=DigiXSecMBSl[iw][isec-1][ich-1][0];
886     float nbmax=DigiXSecMBSl[iw][isec-1][ich-1][0]->GetMaximum();
887     for(int isl=1;isl<4;isl++){
888     if(!(ich==4 && isl==2)){ // avoid ThetaMB4
889     float nbmax0=DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->GetMaximum();
890     if(nbmax0>nbmax){
891     first_to_paint=DigiXSecMBSl[iw][isec-1][ich-1][isl-1];
892     nbmax=nbmax0;
893     }
894     DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->SetLineColor(isl);
895     }
896     }
897     stringstream htitle; htitle << "Occupancy W" << (iw-2) << " S" << isec << " MB" << ich;
898     first_to_paint->SetTitle(htitle.str().c_str());
899     if(isec<5) {int icpos=(isec-1)*4+ich; Digi1->cd(icpos) ; Digi1->cd(icpos)->SetLogy();}
900     if(isec>4 && isec<9) {int icpos=(isec-5)*4+ich; Digi2->cd(icpos) ; Digi2->cd(icpos)->SetLogy();}
901     if(isec>8 && isec<13){int icpos=(isec-9)*4+ich; Digi3->cd(icpos) ; Digi3->cd(icpos)->SetLogy();}
902     first_to_paint->GetYaxis()->SetLabelSize(0.07);
903     first_to_paint->GetXaxis()->SetLabelSize(0.07);
904     first_to_paint->Draw();
905     for(int isl=1;isl<4;isl++){
906     if(!(ich==4 && isl==2)) // avoid ThetaMB4
907     DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->Draw("same");
908     }
909     }
910     }// End Loop on sectors
911     createGifFile("Occupancies_LogScale",(iw-2),"_S1-S4",Digi1);
912     createGifFile("Occupancies_LogScale",(iw-2),"_S5-S8",Digi2);
913     createGifFile("Occupancies_LogScale",(iw-2),"_S9-S12",Digi3);
914    
915     //===================================================================================
916     // TimeBoxes
917     //===================================================================================
918     DQM1->Clear();
919     DQM1->Divide(6,2) ;
920     for (int ins=1; ins<13;ins++){
921     TH1F *hHisto[4];
922     int nbmax=0;
923     int nbmax0=0;
924    
925     DQM1->cd(ins);
926     for(int ic=1;ic<5;ic++){
927     stringstream hname; hname << "htime_" << Whname[iw] << "_S" << ins << "_MB" << ic;
928 battilan 1.2 hHisto[ic-1]=getHisto<TH1F>(hname.str());
929 battilan 1.1 hHisto[ic-1]->SetLineColor(ic);
930     }
931    
932     first_to_paint = hHisto[0];
933     nbmax=hHisto[0]->GetMaximum();
934    
935     for(int ic=2;ic<5;ic++){
936     nbmax0=hHisto[ic-1]->GetMaximum();
937     if(nbmax0>nbmax){
938     nbmax=nbmax0;
939     first_to_paint=hHisto[ic-1];
940     }
941     }
942    
943     first_to_paint->GetXaxis()->SetLabelSize(0.08);
944     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
945     first_to_paint->GetXaxis()->SetTitle("cm");
946     first_to_paint->GetXaxis()->SetTitleSize(0.09);
947     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
948     first_to_paint->GetXaxis()->SetNdivisions(308);
949     char htit[240];
950     stringstream htitle; htitle << "TimeBox W" << iw-2 << " S" << ins;
951     first_to_paint->SetTitle(htitle.str().c_str());
952     first_to_paint->Draw();
953     for(int ic=1;ic<5;ic++)hHisto[ic-1]->Draw("same");
954    
955     }// end loop on sectors
956     stringstream fileTBox; fileTBox <<"TBox_r" << myRunNumber <<"_W" << (iw-2);
957     createGifFile("TBox",(iw-2),"",DQM1);
958    
959     //===================================================================================
960     // Hit Residuals
961     //===================================================================================
962     DQM1->Clear();
963     DQM1->Divide(6,2) ;
964    
965     for(int ins=1;ins<13; ins++){
966     TH1F *hHisto[4];
967     DQM1->cd(ins);
968    
969     int nbmax=0;
970     int nbmax0=0;
971    
972     for(int ic=1;ic<5;ic++){
973     stringstream hname; hname << "hResX_" << Whname[iw] << "_S" << ins << "_MB" << ic;
974 battilan 1.2 hHisto[ic-1]= getHisto<TH1F>(hname.str());
975 battilan 1.1 hHisto[ic-1]->SetLineColor(ic);
976     }
977    
978     first_to_paint = hHisto[0];
979     nbmax=hHisto[0]->GetMaximum();
980    
981     for(int ic=2;ic<5;ic++){
982     nbmax0=hHisto[ic-1]->GetMaximum();
983     if(nbmax0>nbmax){
984     nbmax=nbmax0;
985     first_to_paint=hHisto[ic-1];
986     }
987     }
988    
989     first_to_paint->GetXaxis()->SetLabelSize(0.08);
990     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
991     first_to_paint->GetXaxis()->SetTitle("cm");
992     first_to_paint->GetXaxis()->SetTitleSize(0.09);
993     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
994     first_to_paint->GetXaxis()->SetNdivisions(308);
995     stringstream htitle; htitle << "Hit residuals W" << (iw-2) << " S" << ins;
996     first_to_paint->SetTitle(htitle.str().c_str());
997    
998     first_to_paint->Draw();
999     for(int ic=1;ic<5;ic++)
1000     hHisto[ic-1]->Draw("same");
1001     }// end loop on sectors
1002    
1003     createGifFile("HitResiduals",(iw-2),"",DQM1);
1004    
1005     //===================================================================================
1006     // Angle Phi LOCAL
1007     //===================================================================================
1008     DQM1->Clear();
1009     DQM1->Divide(6,2) ;
1010    
1011     for (int ins=1; ins<13;ins++){
1012     TH1F *hPhi[4];
1013     DQM1->cd(ins);
1014     int nbmax=0;
1015     int nbmax0=0;
1016    
1017     for(int ic=1;ic<5;ic++){
1018     stringstream hname; hname << "hPhi_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1019 battilan 1.2 hPhi[ic-1]=getHisto<TH1F>(hname.str());
1020 battilan 1.1 hPhi[ic-1]->SetLineColor(ic);
1021     }
1022    
1023     first_to_paint = hPhi[0];
1024     nbmax=hPhi[0]->GetMaximum();
1025    
1026     for(int ic=2;ic<5;ic++){
1027     nbmax0=hPhi[ic-1]->GetMaximum();
1028     if(nbmax0>nbmax){
1029     nbmax=nbmax0;
1030     first_to_paint=hPhi[ic-1];
1031     }
1032     }
1033    
1034     first_to_paint->GetXaxis()->SetLabelSize(0.08);
1035     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1036     first_to_paint->GetXaxis()->SetTitle("deg");
1037     first_to_paint->GetXaxis()->SetTitleSize(0.09);
1038     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1039     first_to_paint->GetXaxis()->SetNdivisions(308);
1040     stringstream htitle; htitle << "Phi local W" << (iw-2) << " S" << ins;
1041     first_to_paint->SetTitle(htitle.str().c_str());
1042    
1043     first_to_paint->Draw();
1044     for(int ic=1;ic<5;ic++) hPhi[ic-1]->Draw( "same");
1045    
1046     }// end loop on sectors
1047    
1048    
1049     createGifFile("PhiLocal",(iw-2),"",DQM1);
1050    
1051     //===================================================================================
1052     // STA Digis
1053     //===================================================================================
1054     DQM1->Clear();
1055    
1056     stringstream hnameSTADigi; hnameSTADigi << "hHitsPosXYSA_" << Whname[iw];
1057 battilan 1.2 TH1F *hXYHisto=getHisto<TH1F>(hnameSTADigi.str());;
1058 battilan 1.1
1059     hXYHisto->SetStats(0);
1060     hXYHisto->Draw("colz");
1061    
1062    
1063     createGifFile("STADigi",(iw-2),"",DQM1);
1064    
1065    
1066     //===================================================================================
1067     // STA Phi Hits
1068     //===================================================================================
1069     TCanvas *DQM6 = new TCanvas("DQM6", "",301,81,999,699); // open a large canvas
1070 battilan 1.2 TH1F *hnHitDT= getHisto<TH1F>("hnHitDT");
1071 battilan 1.1 Float_t Nevents = hnHitDT->GetEntries();
1072     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Total nr. of triggers:" << Nevents << endl;
1073    
1074     TH1F *hPhiHisto[4];
1075     TH1F *heff[4];
1076    
1077     float ymax = 0.1;
1078     for(int ic=1;ic<5;ic++){
1079     stringstream hname1, hname2, htitle;
1080    
1081     hname1 << "hPhiHit_" << Whname[iw] << "_MB" << ic;
1082 battilan 1.2 hPhiHisto[ic-1]=getHisto<TH1F>(hname1.str());
1083 battilan 1.1
1084     hname2 << "heff" << ic;
1085     heff[ic-1] =(TH1F*) hPhiHisto[ic-1]->Clone(hname2.str().c_str());
1086     heff[ic-1]->Add(heff[ic-1],heff[ic-1],0.5/Nevents,0.5/Nevents);
1087    
1088     heff[ic-1]->SetMaximum(ymax);
1089     heff[ic-1]->SetStats(0);
1090     heff[ic-1]->SetLineColor(ic);
1091     htitle << "Phi of ass. hit, W" << (iw-2);
1092     heff[0]->SetTitle(htitle.str().c_str());
1093     if(ic==1)heff[ic-1]->Draw();
1094     else heff[ic-1]->Draw("same");
1095    
1096     }
1097    
1098     TLine * l;
1099     l = new TLine(-165, 0, -165, ymax); l->Draw();
1100     l = new TLine(-135, 0, -135, ymax); l->Draw();
1101     l = new TLine(-105, 0, -105, ymax); l->Draw();
1102     l = new TLine( -75, 0, -75, ymax); l->Draw();
1103     l = new TLine( -45, 0, -45, ymax); l->Draw();
1104     l = new TLine( -15, 0, -15, ymax); l->Draw();
1105     l = new TLine( 15, 0, 15, ymax); l->Draw();
1106     l = new TLine( 45, 0, 45, ymax); l->Draw();
1107     l = new TLine( 75, 0, 75, ymax); l->Draw();
1108     l = new TLine( 105, 0, 105, ymax); l->Draw();
1109     l = new TLine( 135, 0, 135, ymax); l->Draw();
1110     l = new TLine( 165, 0, 165, ymax); l->Draw();
1111    
1112     l = new TLine( -40, 0.8*ymax, -20, 0.8*ymax); l->Draw();
1113     l->SetLineColor(1);
1114     l->Draw();
1115     TPaveLabel * box = new TPaveLabel(-10,0.8*ymax,5,0.85*ymax,"MB1");
1116     box->Draw();
1117    
1118     l = new TLine( -40, 0.7*ymax, -20, 0.7*ymax); l->Draw();
1119     l->SetLineColor(2);
1120     l->Draw();
1121     box = new TPaveLabel(-10,0.7*ymax,5,0.75*ymax,"MB2");
1122     box->Draw();
1123    
1124     l = new TLine( -40, 0.6*ymax, -20, 0.6*ymax); l->Draw();
1125     l->SetLineColor(3);
1126     l->Draw();
1127     box = new TPaveLabel(-10,0.6*ymax,5,0.65*ymax,"MB3");
1128     box->Draw();
1129    
1130     l = new TLine( -40, 0.5*ymax, -20, 0.5*ymax); l->Draw();
1131     l->SetLineColor(4);
1132     l->Draw();
1133     box = new TPaveLabel(-10,0.5*ymax,5,0.55*ymax,"MB4");
1134     box->Draw();
1135    
1136     createGifFile("STAPhiHits",(iw-2),"",DQM6);
1137    
1138    
1139     //===================================================================================
1140     // STA Hits
1141     //===================================================================================
1142     DQM1->Clear();
1143     DQM1->Divide(6,2) ;
1144    
1145     TH1F *hNassList[12];
1146    
1147     for(int isec=1;isec<13;isec++){
1148     stringstream histoname; histoname << "hNhass_" << Whname[iw] << "_S" << isec;
1149 battilan 1.2 hNassList[isec-1]=getHisto<TH1F>(histoname.str());
1150 battilan 1.1 }
1151    
1152    
1153     for(int is=0;is<12;is++){
1154     hNassList[is]->GetXaxis()->SetNdivisions(308);
1155     hNassList[is]->GetXaxis()->SetLabelSize(0.08);
1156     hNassList[is]->GetXaxis()->SetLabelOffset(-0.025);
1157     hNassList[is]->GetXaxis()->SetTitle("# hits");
1158     hNassList[is]->GetXaxis()->SetTitleSize(0.01);
1159     hNassList[is]->GetXaxis()->SetTitleOffset(0.5);
1160    
1161     DQM1->cd(is+1);
1162     hNassList[is]->SetStats(1);
1163     hNassList[is]->Draw();
1164     }
1165    
1166     createGifFile("STAHits",(iw-2),"",DQM1);
1167    
1168    
1169     //===================================================================================
1170     // Segment Hits
1171     //===================================================================================
1172     DQM2->Clear();
1173     DQM2->Divide(6,2);
1174    
1175     TH1F *hNhits[12][4];
1176     for (int ins=1; ins<13;ins++){
1177     DQM2->cd(ins);
1178     int nbmax=0;
1179     int nbmax0=0;
1180    
1181     for(int ic=1;ic<5;ic++){
1182     stringstream hname; hname << "hNhits_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1183 battilan 1.2 hNhits[ins-1][ic-1]= getHisto<TH1F>(hname.str());
1184 battilan 1.1 hNhits[ins-1][ic-1]->SetLineColor(ic);
1185     }
1186    
1187     first_to_paint= hNhits[ins-1][0];
1188     nbmax=hNhits[ins-1][0]->GetMaximum();
1189    
1190     for(int ic=2;ic<5;ic++){
1191     nbmax0=hNhits[ins-1][ic-1]->GetMaximum();
1192     if(nbmax0>nbmax){
1193     nbmax=nbmax0;
1194     first_to_paint=hNhits[ins-1][ic-1];
1195     }
1196     }
1197    
1198     first_to_paint->GetXaxis()->SetLabelSize(0.08);
1199     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1200     first_to_paint->GetXaxis()->SetTitle("#hits");
1201     first_to_paint->GetXaxis()->SetTitleSize(0.09);
1202     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1203     first_to_paint->GetXaxis()->SetNdivisions(308);
1204     stringstream htitle; htitle << "# hits in seg W" << (iw-2) << " S" << ins;
1205     first_to_paint->SetTitle(htitle.str().c_str());
1206    
1207     first_to_paint->Draw();
1208     for(int ic=1;ic<5;ic++) hNhits[ins-1][ic-1]->Draw( "same");
1209    
1210     }// end loop on sectors
1211    
1212    
1213     createGifFile("SegHits",(iw-2),"",DQM2);
1214    
1215     //===================================================================================
1216     // Segment Hits
1217     //===================================================================================
1218     DQM1->Clear();
1219     DQM1->Divide(6,2);
1220     TH1F * hNsegsList[12];
1221     for(int is=0;is<12;is++){
1222     stringstream hname; hname << "hNsegs_" << Whname[iw] << "_S" <<is+1;
1223 battilan 1.2 hNsegsList[is]= getHisto<TH1F>(hname.str());
1224 battilan 1.1 hNsegsList[is]->GetXaxis()->SetTitle("# Segments");
1225     }
1226    
1227     for(int is=0;is<12;is++){
1228     DQM1->cd(is+1);
1229     hNsegsList[is]->GetXaxis()->SetNdivisions(308);
1230     hNsegsList[is]->GetXaxis()->SetLabelSize(0.08);
1231     hNsegsList[is]->GetXaxis()->SetLabelOffset(-0.025);
1232     hNsegsList[is]->GetXaxis()->SetTitleSize(0.09);
1233     hNsegsList[is]->GetXaxis()->SetTitleOffset(0.5);
1234     hNsegsList[is]->SetStats(1);
1235     hNsegsList[is]->Draw();
1236     }
1237    
1238     createGifFile("Segments",(iw-2),"",DQM1);
1239    
1240     //===================================================================================
1241     // TMAX
1242     //===================================================================================
1243    
1244     TCanvas *DQM11 = new TCanvas("DQM11", "1",101,81,999,699);
1245     TCanvas *DQM12 = new TCanvas("DQM12", "2",101,81,999,699);
1246     TCanvas *DQM13 = new TCanvas("DQM13", "3",101,81,999,699);
1247     TCanvas *DQM14 = new TCanvas("DQM14", "4",101,81,999,699);
1248     DQM11->Divide(4,3) ;
1249     DQM12->Divide(4,3) ;
1250     DQM13->Divide(4,3) ;
1251     DQM14->Divide(4,3) ;
1252    
1253     for (int ins=1; ins<13;ins++){
1254     TH1F *hHisto[2];
1255     for(int ic=1;ic<5;ic++){
1256    
1257     stringstream hname; hname << "htmax_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1258 battilan 1.2 hHisto[0]= getHisto<TH1F>(hname.str()+"_SL1");
1259     hHisto[1]= getHisto<TH1F>(hname.str()+"_SL3");
1260 battilan 1.1
1261     if(ins<4){
1262     int ipos=(ins-1)*4+ic;
1263     DQM11->cd(ipos);
1264     }
1265     if(ins>3 && ins<7){
1266     int ipos=(ins-4)*4+ic;
1267     DQM12->cd(ipos);
1268     }
1269     if(ins>6 && ins<10){
1270     int ipos=(ins-7)*4+ic;
1271     DQM13->cd(ipos);
1272     }
1273     if(ins>9){
1274     int ipos=(ins-10)*4+ic;
1275     DQM14->cd(ipos);
1276     }
1277    
1278     hHisto[0]->SetStats(1);
1279 battilan 1.3 hHisto[0]->Draw();
1280 battilan 1.4 try {
1281     hHisto[0]->Fit("gaus","Q");
1282     } catch(const cms::Exception&) {
1283     edm::LogError("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Error fitting " << hname.str() << "_SL1";
1284     }
1285 battilan 1.1 hHisto[1]->SetLineColor(2);
1286     hHisto[1]->Draw("same");
1287     }// end loop on chambers
1288     }// end loop on sectors
1289    
1290     createGifFile("TMax",(iw-2),"S1-S3",DQM11);
1291 battilan 1.4 createGifFile("TMax",(iw-2),"S4-S6",DQM12);
1292     createGifFile("TMax",(iw-2),"S7-S9",DQM13);
1293     createGifFile("TMax",(iw-2),"S10-S12",DQM14);
1294 battilan 1.1
1295    
1296     //===================================================================================
1297     // Phi-Trig Efficiency
1298     //===================================================================================
1299     TCanvas *Eff = new TCanvas("Eff", "",201,81,999,699);
1300     TH1F *hHisto[4];
1301     TH1F *hHistoTr[4];
1302     TH1F *heffx[4];
1303     for(int ic=1;ic<5;ic++)
1304     {
1305     stringstream hname1; hname1 << "hPhiGlob_" << Whname[iw] << "_MB" << ic;
1306 battilan 1.2 hHisto[ic-1]= getHisto<TH1F>(hname1.str());
1307 battilan 1.1
1308     stringstream hname2; hname2 << "heff" << ic <<"x";
1309     //heffx[ic-1]=hHisto[ic-1]->Clone(hname);
1310     heffx[ic-1] =(TH1F*) hHisto[ic-1]->Clone(hname2.str().c_str());
1311     heffx[ic-1]->SetLineColor(ic);
1312    
1313     stringstream hname3; hname3 << "hPhiTrigg_" << Whname[iw] << "_MB" << ic;
1314 battilan 1.2 hHistoTr[ic-1]= getHisto<TH1F>(hname3.str());
1315 battilan 1.1 heffx[ic-1]->Divide(hHistoTr[ic-1],hHisto[ic-1],1.0,1.0);
1316    
1317     for (int i = 0; i <= heffx[ic-1]->GetNbinsX()+1; i++ ) {
1318     Float_t tot = hHisto[ic-1]->GetBinContent(i) ;
1319     Float_t tot_e = hHisto[ic-1]->GetBinError(i);
1320     Float_t eff = heffx[ic-1]->GetBinContent(i) ;
1321     Float_t Err = 0.;
1322     if (tot > 0) Err = tot_e / tot * sqrt( eff* (1-eff) );
1323     // if (eff == 1. || isnan(Err) || !isfinite(Err) ) Err=1.e-3;
1324     heffx[ic-1]->SetBinError(i, Err);
1325     }
1326     heffx[ic-1]->SetStats(0);
1327     heffx[ic-1]->SetMaximum(1);
1328     stringstream htitle; htitle << "Phi-Trigger Eff W" << iw-2;
1329     heffx[0]->SetTitle(htitle.str().c_str());
1330     heffx[0]->SetMaximum(1.02);
1331    
1332     if(ic==1)heffx[ic-1]->Draw();
1333     else heffx[ic-1]->Draw("same");
1334     }
1335    
1336     ymax = 1.;
1337     l = new TLine(-165, 0, -165, ymax); l->Draw();
1338     l = new TLine(-135, 0, -135, ymax); l->Draw();
1339     l = new TLine(-105, 0, -105, ymax); l->Draw();
1340     l = new TLine( -75, 0, -75, ymax); l->Draw();
1341     l = new TLine( -45, 0, -45, ymax); l->Draw();
1342     l = new TLine( -15, 0, -15, ymax); l->Draw();
1343     l = new TLine( 15, 0, 15, ymax); l->Draw();
1344     l = new TLine( 45, 0, 45, ymax); l->Draw();
1345     l = new TLine( 75, 0, 75, ymax); l->Draw();
1346     l = new TLine( 105, 0, 105, ymax); l->Draw();
1347     l = new TLine( 135, 0, 135, ymax); l->Draw();
1348     l = new TLine( 165, 0, 165, ymax); l->Draw();
1349    
1350     createGifFile("TrigEff",(iw-2),"",Eff);
1351    
1352    
1353     //===================================================================================
1354     // Segment Hits
1355     //===================================================================================
1356     DQM1->Clear();
1357     DQM1->Divide(6,2) ;
1358    
1359     for (int ins=1; ins<13;ins++){
1360     TH1F *hHisto[4];
1361     DQM1->cd(ins);
1362    
1363     int nbmax=0;
1364     int nbmax0=0;
1365    
1366    
1367     for(int ic=1;ic<5;ic++){
1368     stringstream hname; hname << "hTrigBits_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1369 battilan 1.2 hHisto[ic-1]= getHisto<TH1F>(hname.str());
1370 battilan 1.1 hHisto[ic-1]->SetLineColor(ic);
1371     }
1372    
1373     first_to_paint = hHisto[0];
1374     nbmax=hHisto[0]->GetMaximum();
1375    
1376     for(int ic=2;ic<5;ic++){
1377     nbmax0=hHisto[ic-1]->GetMaximum();
1378     if(nbmax0>nbmax){
1379     nbmax=nbmax0;
1380     first_to_paint=hHisto[ic-1];
1381     }
1382     }
1383     first_to_paint->GetXaxis()->SetLabelSize(0.08);
1384     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1385     first_to_paint->GetXaxis()->SetTitle("Quality");
1386     first_to_paint->GetXaxis()->SetTitleSize(0.09);
1387     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1388     first_to_paint->GetXaxis()->SetNdivisions(308);
1389     stringstream htitle; htitle << "Highest trig qual W" << (iw-2) << " S" << ins;
1390     first_to_paint->SetTitle(htitle.str().c_str());
1391    
1392     first_to_paint->Draw();
1393     for(int ic=1;ic<5;ic++)
1394     hHisto[ic-1]->Draw("same");
1395    
1396     }// end loop on sectors
1397    
1398     createGifFile("TrigHighQual",(iw-2),"",DQM1);
1399    
1400    
1401     //===================================================================================
1402     // SC BX Summary
1403     //===================================================================================
1404     TCanvas *BX = new TCanvas("BX", "",201,81,999,699);
1405     BX->Divide(6,2);
1406     for(int ins=1;ins<13;ins++){ // Loop in sectors
1407    
1408     int nbmax=0;
1409     int nbmax0=0;
1410    
1411     TH1F *hHH[4];
1412     TH1F *hHL[4];
1413     BX->cd(ins);
1414     BX->cd(ins)->SetLogy();
1415     for(int ic=1;ic<5;ic++){ // Loop in chambers
1416    
1417     stringstream hname; hname << "hTrigBX_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1418 battilan 1.2 hHH[ic-1]= getHisto<TH1F>(hname.str()+"_qual6");
1419     hHL[ic-1]= getHisto<TH1F>(hname.str()+"_qual5");
1420 battilan 1.1
1421     hHH[ic-1]->Add(hHL[ic-1]);
1422     hHH[ic-1]->SetLineColor(ic);
1423     hHH[ic-1]->SetStats(0);
1424     } // end loop in chambers
1425    
1426     first_to_paint = hHH[0];
1427     nbmax=hHH[0]->GetMaximum();
1428     first_to_paint->Draw();
1429    
1430     for(int ic=2;ic<5;ic++){
1431     nbmax0=hHH[ic-1]->GetMaximum();
1432     if(nbmax0>nbmax){
1433     nbmax=nbmax0;
1434     first_to_paint=hHH[ic-1];
1435     }
1436     }
1437    
1438     first_to_paint->GetXaxis()->SetLabelSize(0.08);
1439     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1440     first_to_paint->GetXaxis()->SetTitle("Slot");
1441     first_to_paint->GetXaxis()->SetTitleSize(0.09);
1442     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1443     first_to_paint->GetXaxis()->SetNdivisions(308);
1444     stringstream htitle; htitle << "BX for HH,HL W" << (iw-2) << " S" << ins;
1445     first_to_paint->SetTitle(htitle.str().c_str());
1446    
1447     first_to_paint->Draw();
1448     for(int ic=1;ic<5;ic++)
1449     hHH[ic-1]->Draw("same");
1450    
1451     }// end Loop in sectors
1452    
1453     createGifFile("TrigBXhhhl",(iw-2),"",BX);
1454    
1455 battilan 1.3 delete DQM1;
1456     delete DQM2;
1457     delete DQM1b;
1458     delete DQM2b;
1459     delete Digi1;
1460     delete Digi2;
1461     delete Digi3;
1462     delete DQM6;
1463    
1464     delete DQM11;
1465     delete DQM12;
1466     delete DQM13;
1467     delete DQM14;
1468     delete Eff;
1469     delete BX;
1470 battilan 1.1
1471     }// END loop in wheels
1472    
1473     }
1474    
1475    
1476     void DTDPGCreateAnalyzerSummary::createSummaryAllPlots() {
1477    
1478     string Whname[5]={"Wm2","Wm1","W0","W1","W2"};
1479    
1480     gStyle->SetTitleX(0.01);
1481     gStyle->SetTitleY(0.99);
1482    
1483     gStyle->SetOptStat(10);
1484     gStyle->SetStatY(0.97);
1485     gStyle->SetStatX(0.98);
1486     gStyle->SetStatW(0.35);
1487     gStyle->SetStatH(0.45);
1488    
1489     gStyle->SetPalette(1); // set palette for 2D histos
1490     gStyle->SetTitleW(0.97);
1491     gStyle->SetTitleH(0.1);
1492    
1493     float BXSummary_mean=0.;
1494     float NBXSummary_mean=0.;
1495     TH1F * BXSummary[5][4];
1496     for(int iw=0;iw<5;iw++){ // Loop in wheels
1497     for(int ic=1;ic<5;ic++){
1498    
1499     stringstream hname, htitle;
1500     hname << "BX_mean_MB" << ic << "_W" << (iw-2);
1501     htitle << "BX MeanValue (HH,HL) MB" << ic << " W" << (iw-2);
1502     BXSummary[iw][ic-1]= new TH1F(hname.str().c_str(),htitle.str().c_str(),12,1.,13.);
1503     for(int is=1;is<13;is++){
1504     stringstream xlab; xlab << "S" << is;
1505     BXSummary[iw][ic-1]->GetXaxis()->SetBinLabel(is,xlab.str().c_str());
1506     }
1507     }
1508     }
1509    
1510    
1511     //===================================================================================
1512     // SC BX Summary
1513     //===================================================================================
1514     for(int iw=0;iw<5;iw++){ // Loop in wheels
1515     for(int ins=1;ins<13;ins++){ // Loop in sectors
1516    
1517     TH1F *hHH[4];
1518     TH1F *hHL[4];
1519     for(int ic=1;ic<5;ic++){ // Loop in chambers
1520    
1521     stringstream hname; hname << "hTrigBX_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1522 battilan 1.2 hHH[ic-1]= getHisto<TH1F>(hname.str()+"_qual6");
1523     hHL[ic-1]= getHisto<TH1F>(hname.str()+"_qual5");
1524 battilan 1.1
1525     hHH[ic-1]->Add(hHL[ic-1]);
1526     hHH[ic-1]->SetLineColor(ic);
1527     hHH[ic-1]->SetStats(0);
1528    
1529     // Compute average for BX summary plot
1530     int nb=hHH[ic-1]->GetNbinsX();
1531     int nbMax=hHH[ic-1]->GetMaximumBin();
1532     float xmean=0;
1533     float xtot0=0;
1534     for(int inb=nbMax-2;inb<nbMax+3;inb++){ // Takes Central BX+-2
1535     if(inb>1 && inb<nb){ //To avoid problems if it is on the "border"
1536     float yval=hHH[ic-1]->GetBinContent(inb);
1537     float xval=hHH[ic-1]->GetBinCenter(inb);
1538     xmean+=xval*yval;
1539     xtot0+=yval;
1540     }
1541     }
1542     if(xtot0>0){
1543     xmean=xmean/xtot0 ;
1544     BXSummary[iw][ic-1]->Fill(ins,xmean);
1545     BXSummary_mean+=xmean;
1546     NBXSummary_mean++;
1547     }
1548     }
1549     }// end Loop in chambers
1550     }// END loop in wheels and sectors
1551    
1552     string titlename = "BX Average (HH,HL)";
1553     TCanvas *BXaverage = new TCanvas("BXAverage", "",201,81,999,699);
1554     BXaverage->SetTopMargin(0.42);
1555     BXaverage->SetBottomMargin(0.32);
1556     BXaverage->SetRightMargin(0.12);
1557     BXaverage->Divide(1,5,0.,0) ;
1558    
1559     TPaveLabel* title = new TPaveLabel(0.1,0.93,0.85,0.99,titlename.c_str());
1560     title->SetFillColor(0);
1561     title->SetTextColor(4);
1562     title->Draw();
1563    
1564     int BXSummary_min=0;
1565     int BXSummary_max=0;
1566     if(NBXSummary_mean>0)BXSummary_min=-6+int(BXSummary_mean/NBXSummary_mean);
1567     if(NBXSummary_mean>0)BXSummary_max=6+int(BXSummary_mean/NBXSummary_mean);
1568     for(int iw=0;iw<5;iw++){
1569     BXaverage->cd(iw+1);
1570     BXaverage->cd(iw+1)->SetGrid();
1571     for(int ic=1;ic<5;ic++){
1572     BXSummary[iw][ic-1]->SetMaximum(BXSummary_max);
1573     BXSummary[iw][ic-1]->SetMinimum(BXSummary_min);
1574     BXSummary[iw][ic-1]->SetStats(0);
1575     BXSummary[iw][ic-1]->SetTitle(0);
1576     BXSummary[iw][ic-1]->SetLineWidth(2);
1577     BXSummary[iw][ic-1]->GetXaxis()->SetLabelSize(0.25);
1578     BXSummary[iw][ic-1]->GetYaxis()->SetLabelSize(0.2);
1579     if(iw==4)BXSummary[iw][ic-1]->GetYaxis()->SetLabelSize(0.15);
1580     BXSummary[iw][ic-1]->GetYaxis()->SetNdivisions(502);
1581     BXSummary[iw][ic-1]->SetLineColor(ic);
1582     if(ic==1)BXSummary[iw][ic-1]->Draw();
1583     else BXSummary[iw][ic-1]->Draw("same");
1584     }
1585     stringstream ptitle; ptitle << "Wheel " << (iw-2);
1586     TPaveLabel* WheelName = new TPaveLabel(1.00,0.70,1.12,0.90,ptitle.str().c_str(),"NDC");
1587     WheelName->Draw();
1588     }
1589    
1590     createGifFile("TrigBXhhhl_average","",BXaverage);
1591     delete BXaverage;
1592    
1593     }
1594    
1595