ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DTDPGAnalysis/src/DTDPGCreateAnalyzerSummary.cc
Revision: 1.7
Committed: Mon May 3 14:38:28 2010 UTC (15 years ago) by pellicci
Content type: text/plain
Branch: MAIN
CVS Tags: V00-00-14, V00-00-13, V00-00-12, V00-00-11, V00-00-10, V00-00-09, V00-00-08, V00-00-07
Changes since 1.6: +15 -15 lines
Log Message:
compilation fixes for 3_6

File Contents

# User Rev Content
1 battilan 1.1 /*
2     * See header file for a description of this class.
3     *
4 pellicci 1.7 * $Date: 2008/12/19 16:36:40 $
5     * $Revision: 1.6 $
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 cerminar 1.6 #include "UserCode/DTDPGAnalysis/src/DTROUtility.h"
16 battilan 1.1
17     // Framework
18     #include <FWCore/Framework/interface/Event.h>
19     #include <FWCore/Framework/interface/EventSetup.h>
20    
21     // Geometry
22     #include "Geometry/Records/interface/MuonGeometryRecord.h"
23     #include "Geometry/DTGeometry/interface/DTGeometry.h"
24     #include "Geometry/DTGeometry/interface/DTLayer.h"
25     #include "Geometry/DTGeometry/interface/DTTopology.h"
26    
27     #include "FWCore/MessageLogger/interface/MessageLogger.h"
28    
29     #include <iostream>
30     #include <string>
31     #include <sstream>
32     #include <iomanip>
33     #include <math.h>
34    
35     #include "TH1F.h"
36     #include "TF1.h"
37     #include "TH2F.h"
38     #include "TCanvas.h"
39     #include "TGraph.h"
40     #include "TPostScript.h"
41     #include "TPaveLabel.h"
42     #include "TPaveText.h"
43     #include "TProfile.h"
44     #include "TStyle.h"
45     #include "TFolder.h"
46     #include "boost/filesystem.hpp"
47    
48     using namespace edm;
49     using namespace std;
50     using namespace boost::filesystem;
51    
52     DTDPGCreateAnalyzerSummary::DTDPGCreateAnalyzerSummary(const edm::ParameterSet& ps) : myFile(0){
53    
54     LogVerbatim("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Constructor";
55    
56     myParameters = ps;
57     myRunNumber = ps.getUntrackedParameter<int>("runNumber",0);
58    
59     }
60    
61     DTDPGCreateAnalyzerSummary::~DTDPGCreateAnalyzerSummary(){
62    
63     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Destructor ";
64    
65     }
66    
67    
68     void DTDPGCreateAnalyzerSummary::beginJob(const edm::EventSetup& context){
69    
70     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: BeginJob";
71    
72     }
73    
74     void DTDPGCreateAnalyzerSummary::analyze(const edm::Event& e, const edm::EventSetup& context){
75    
76     }
77    
78    
79     void DTDPGCreateAnalyzerSummary::endJob(){
80    
81     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: endJob";
82    
83     myFile = new TFile(myParameters.getUntrackedParameter<string>("rootFileName", "DTEfficiencyTest.root").c_str(), "READ");
84    
85     char cMainFolder[30];sprintf(cMainFolder,"DQMData/Run %d", myRunNumber);
86     TFolder * mfolder=(TFolder*)myFile->Get(cMainFolder);
87     if(!mfolder) {
88     throw cms::Exception("DTDPGCreateAnalyzerSummaryError") << "[DTDPGCreateAnalyzerSummary]: Folder = " << cMainFolder << " does not exist!!! Check the run number" << endl;
89     }
90    
91     myMainFolder.append(cMainFolder);
92     myMainFolder.append("/DT/Run summary/DTOfflineAnalyzer/");
93    
94 cerminar 1.6 string mainFold;
95     mainFold.append(cMainFolder);
96     mainFold.append("/DT/Run summary/");
97     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Creating summaries!";
98    
99     DTROUtility roUtil(myFile,mainFold);
100     mySectors = roUtil.getSectorMap();
101 battilan 1.1
102 battilan 1.5 if (myParameters.getUntrackedParameter<bool>("SummaryHistos", false)) { createSummaryPlots(); }
103 battilan 1.1 if (myParameters.getUntrackedParameter<bool>("SummaryWheelHistos", false)) { createSummaryWheelPlots(); }
104     if (myParameters.getUntrackedParameter<bool>("SummaryAllHistos", false)) { createSummaryAllPlots(); }
105    
106 battilan 1.2 if(myFile) {
107     myFile->Close();
108     delete myFile;
109     }
110    
111 battilan 1.1 }
112    
113     void DTDPGCreateAnalyzerSummary::createGifFile(string fileName, int wh, int sec, string tag, TCanvas *canvas) {
114    
115     stringstream gifBase;
116     gifBase << "Run" << myRunNumber << "/Wheel" << showpos << wh << "/Sect" << noshowpos << setfill('0')<< setw(2) << sec;
117     try {
118     create_directories(gifBase.str());
119     } catch(const std::exception & ex) {
120     throw cms::Exception("DTDPGCreateAnalyzerSummaryError")<< "[DTDPGCreateAnalyzerSummary]: Excepiton " << ex.what() << " thrown creating " << gifBase.str() << " directory" << endl;
121     }
122    
123     stringstream gifTag; gifTag << "_r" << myRunNumber << "_W" << wh <<"_S" << sec;
124     string gifFile = gifBase.str() + "/" + fileName + gifTag.str() + tag + ".gif";
125     canvas->Update();
126     canvas->Print(gifFile.c_str());
127    
128     }
129    
130     void DTDPGCreateAnalyzerSummary::createGifFile(string fileName, int wh, string tag, TCanvas *canvas) {
131    
132     stringstream gifBase;
133     gifBase << "Run" << myRunNumber << "/Wheel" << showpos << wh << noshowpos;
134     try {
135     create_directories(gifBase.str());
136     } catch(const std::exception & ex) {
137     throw cms::Exception("DTDPGCreateAnalyzerSummaryError")<< "[DTDPGCreateAnalyzerSummary]: Excepiton " << ex.what() << " thrown creating " << gifBase.str() << " directory" << endl;
138     }
139    
140     stringstream gifTag; gifTag << "_r" << myRunNumber << "_W" << wh;
141     string gifFile = gifBase.str() + "/" + fileName + gifTag.str() + tag + ".gif";
142     canvas->Update();
143     canvas->Print(gifFile.c_str());
144    
145     }
146     void DTDPGCreateAnalyzerSummary::createGifFile(string fileName, string tag, TCanvas *canvas) {
147    
148     stringstream gifBase;
149     gifBase << "Run" << myRunNumber;
150     try {
151     create_directories(gifBase.str());
152     } catch(const std::exception & ex) {
153     throw cms::Exception("DTDPGCreateAnalyzerSummaryError")<< "[DTDPGCreateAnalyzerSummary]: Excepiton " << ex.what() << " thrown creating " << gifBase.str() << " directory" << endl;
154     }
155    
156     stringstream runTag; runTag << "_r" << myRunNumber;
157    
158     string gifFile = gifBase.str() + "/" + fileName + runTag.str() + tag + ".gif";
159     canvas->Update();
160     canvas->Print(gifFile.c_str());
161    
162     }
163    
164    
165 battilan 1.5 void DTDPGCreateAnalyzerSummary::createSummaryPlots() {
166 battilan 1.1
167     string Whname[5]={"Wm2","Wm1","W0","W1","W2"};
168    
169     gStyle->SetTitleW(0.55);
170     gStyle->SetTitleH(0.13);
171     gStyle->SetTitleX(0.01);
172     gStyle->SetTitleY(0.99);
173    
174     gStyle->SetOptStat(10);
175     gStyle->SetStatY(0.97);
176     gStyle->SetStatX(0.98);
177     gStyle->SetStatW(0.35);
178     gStyle->SetStatH(0.45);
179    
180    
181     // Get histos to be plotted
182     // char histoname[240];
183     // char htit[240]; // ???
184     TH1F * first_to_paint;
185     string SLname[3]={"Phi1","Theta","Phi2"};
186    
187     int nbin;
188     float max, max1;
189    
190     TH2F *DigiXYS[5][14];
191 battilan 1.5 TH1F *DigiXSecMBSlLayer[5][14][4][3][4];
192     TH1F *TBoxSecMBSlLayer[5][14][4][3][4];
193     TH1F *Correlated_trig_Bx[5][14][4][3];
194     TH1F *hTrg_effnum_SecMB[5][14][4];
195     TH1F *hTrg_effdenum_SecMB[5][14][4];
196     TH1F *hPhiHL_SecMB[5][14][4];
197     TH1F *TriggerMatrix[5][15];
198     TH1F * TriggerInclusive[5];
199    
200     std::map<int,std::vector<int> >::const_iterator whIt = mySectors.begin();
201     std::map<int,std::vector<int> >::const_iterator whEnd = mySectors.end();
202     for(;whIt!=whEnd;++whIt) {
203     int iw = (*whIt).first + 2;
204     std::vector<int>::const_iterator secIt = (*whIt).second.begin();
205     std::vector<int>::const_iterator secEnd = (*whIt).second.end();
206     for(;secIt!=secEnd;++secIt) {
207     int isec = (*secIt);
208    
209     // Occupancies
210     stringstream histoNameOcc; histoNameOcc << "hDigiXY_" << Whname[iw] << "_S" << isec;
211     DigiXYS[iw][isec-1]=getHisto<TH2F>(histoNameOcc.str());
212     for(int ich=1;ich<5;++ich){
213     for(int isl=1;isl<4;++isl){
214     for(int il=1;il<5;++il){
215     // Create and fill individual layer occupancy plots from hDigiXY_S
216     stringstream histoNameOccup; histoNameOccup << "Occup_" << Whname[iw] << "_S" << isec << "_MB" << ich << "_SL" << isl << "_L" <<il;
217     stringstream histoTitleOccup; histoTitleOccup << "Occupancy " << Whname[iw] << " S" << isec << " MB" << ich << " SL" << SLname[isl-1] << "L" << il;
218     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]= new TH1F(histoNameOccup.str().c_str(),histoTitleOccup.str().c_str(),100, 0.,100.);
219     // TBoxes
220     stringstream histoNameTBox; histoNameTBox << "htime_" << Whname[iw] << "_S" << isec << "_MB" << ich << "_SL" << isl << "_L" << il;
221     TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]=getHisto<TH1F>(histoNameTBox.str());
222     }
223     }
224     // Correlated Triggers
225     for(int iq=4;iq<7;iq++){
226     stringstream histoNameTrQual; histoNameTrQual << "hTrigBX_" << Whname[iw] << "_S" << isec << "_MB" << ich << "_qual" << iq;
227     Correlated_trig_Bx[iw][isec-1][ich-1][iq-4]=getHisto<TH1F>(histoNameTrQual.str());
228     }
229     // Trig Eff
230     stringstream htag; htag << "_" << Whname[iw] << "_S" << isec << "_MB" << ich;
231     stringstream heffden; heffden << "hTrg_effdenum" << htag.str();
232     hTrg_effdenum_SecMB[iw][isec-1][ich-1]=getHisto<TH1F>(heffden.str());
233     stringstream heffnum; heffnum << "hTrg_effnum" << htag.str();
234     hTrg_effnum_SecMB[iw][isec-1][ich-1]=getHisto<TH1F>(heffnum.str());
235     stringstream phihl; phihl << "hPhiHL" << htag.str();
236     hPhiHL_SecMB[iw][isec-1][ich-1]=getHisto<TH1F>(phihl.str());
237 battilan 1.1
238 battilan 1.5 }
239 battilan 1.1
240 battilan 1.5 int nbx= DigiXYS[iw][isec-1]->GetNbinsX() ;
241 battilan 1.1
242 battilan 1.5 for(int ich=1;ich<5;ich++){
243     for(int isl=1;isl<4;isl++){
244     for(int il=1;il<5;il++){
245     int iby=(ich-1)*20+(isl-1)*4+il+1;
246     float totentr=0;
247     for(int ibx=1;ibx<nbx;ibx++){
248     float yval=DigiXYS[iw][isec-1]->GetBinContent(ibx,iby);
249     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetBinContent(ibx,yval);
250     totentr+=yval;
251     }
252     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetEntries(totentr);
253     }
254     }
255     }
256 battilan 1.1
257 battilan 1.5 // Trigger matrix
258     stringstream histoNameTrMatrix; histoNameTrMatrix << "TriggerMatrix" << Whname[iw] << "_S" << isec;
259     TriggerMatrix[iw][isec-1]=getHisto<TH1F>(histoNameTrMatrix.str());
260 battilan 1.1
261 battilan 1.5 }
262     // Trigger Inclusive
263     stringstream histoNameTrInclusive; histoNameTrInclusive << "TriggerInclusive" << Whname[iw];
264     TriggerInclusive[iw]=getHisto<TH1F>(histoNameTrInclusive.str());
265     for (int isec=1;isec<13;++isec) {
266     for (int ibin=1; ibin<5; ibin++) {
267     stringstream hlabel; hlabel << "S" << isec << "MB" << ibin;
268     TriggerInclusive[iw]->GetXaxis()->SetBinLabel((isec-1)*5+ibin,hlabel.str().c_str());
269     }
270     TriggerInclusive[iw]->GetXaxis()->SetBinLabel(isec*5," ");
271     }
272     }
273 battilan 1.1
274 battilan 1.5 whIt = mySectors.begin();
275     whEnd = mySectors.end();
276     for(;whIt!=whEnd;++whIt) {
277     int iw = (*whIt).first + 2;
278     std::vector<int>::const_iterator secIt = (*whIt).second.begin();
279     std::vector<int>::const_iterator secEnd = (*whIt).second.end();
280     for(;secIt!=secEnd;++secIt) {
281     int isec = (*secIt);
282    
283     //===================================================================================
284     // DIGI's occupancies
285     //===================================================================================
286     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing DIGI's occupancies per layer in 1 single page per Sector wh "
287     << (iw-2) << " sec " << isec << endl;
288 battilan 1.1
289 battilan 1.5 TCanvas *Digi = new TCanvas("Digi", "",201,81,999,699);
290     Digi->Divide(3,4) ;
291 battilan 1.1
292 battilan 1.5 for(int ich=1;ich<5;ich++){
293     for(int isl=1;isl<4;isl++){
294     bool dodraw=1;
295     if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
296     if(dodraw){
297     // look first for the maximum bin entries
298     first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
299     float nbmax=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
300     for(int il=2;il<5;il++){
301     float nbmax0=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
302     if(nbmax0>nbmax){
303     first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
304     nbmax=nbmax0;
305     }
306     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
307     }
308     stringstream htitle; htitle << "Occupancy W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
309     first_to_paint->SetTitle(htitle.str().c_str());
310     int icpos=(ich-1)*3+isl;
311     Digi->cd(icpos) ;
312     Digi->cd(icpos)->SetLogy();
313     first_to_paint->GetYaxis()->SetLabelSize(0.07);
314     first_to_paint->GetXaxis()->SetLabelSize(0.07);
315     first_to_paint->Draw();
316     for(int il=1;il<5;il++){
317     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
318     }
319     }
320     }
321     }
322     createGifFile("Occupancies_LogScale",iw-2,isec,"",Digi);
323     delete Digi;
324 battilan 1.1
325 battilan 1.5 //===================================================================================
326     // DIGI's occupancies
327     // now print 1 page per SL
328     //===================================================================================
329     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing DIGI's occupancies per layer in 1 single page per SL wh "
330     << (iw-2) << " sec " << isec << endl;
331     int ichmin=1; if (isec==13|| isec==14)ichmin=4;
332     for(int ich=ichmin;ich<5;ich++){
333     for(int isl=1;isl<4;isl++){
334     TCanvas *DigiSL = new TCanvas("DigiSL", "",201,81,999,699);
335     bool dodraw=1;
336     if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
337     if(dodraw){
338     // look first for the maximum bin entries
339     first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
340     float nbmax=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
341     for(int il=2;il<5;il++){
342     float nbmax0=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
343     if(nbmax0>nbmax){
344     first_to_paint=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
345     nbmax=nbmax0;
346     }
347     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
348     }
349     stringstream htitle; htitle << "Occupancy W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
350     first_to_paint->SetTitle(htitle.str().c_str());
351     //int icpos=(ich-1)*3+isl;
352     first_to_paint->GetYaxis()->SetLabelSize(0.05);
353     first_to_paint->GetXaxis()->SetLabelSize(0.05);
354     first_to_paint->Draw();
355     for(int il=1;il<5;il++){
356     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
357     }
358 battilan 1.1
359 battilan 1.5 stringstream fileTag; fileTag << "_MB" << ich << "_SL" << SLname[isl-1];
360     createGifFile("Occupancies",(iw-2),isec,fileTag.str(),DigiSL);
361     delete DigiSL;
362     }
363 battilan 1.1
364 battilan 1.5 }//end Loop Superlayers
365     }//end Loop chambers
366 battilan 1.1
367 battilan 1.5 //====================================================================================
368     // Time boxes: all in 1 single page (Layer granularity)
369     //===================================================================================
370     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing Time boxes per layer in 1 single page per Sector wh "
371     << (iw-2) << " sec " << isec << endl;
372     TCanvas *Tboxes = new TCanvas("Tboxes", "",201,81,999,699);
373     Tboxes->Divide(3,4) ;
374 battilan 1.1
375 battilan 1.5 for(int ich=1;ich<5;ich++){
376     for(int isl=1;isl<4;isl++){
377     bool dodraw=1;
378     if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
379     if(dodraw){
380     // look first for the maximum bin entries
381     first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
382     float nbmax=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
383     for(int il=2;il<5;il++){
384     float nbmax0=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
385     if(nbmax0>nbmax){
386     first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
387     nbmax=nbmax0;
388     }
389     TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
390     }
391     stringstream htitle; htitle << "TimeBox W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
392     first_to_paint->SetTitle(htitle.str().c_str());
393     int icpos=(ich-1)*3+isl;
394     Tboxes->cd(icpos) ;
395     first_to_paint->GetYaxis()->SetLabelSize(0.07);
396     first_to_paint->GetXaxis()->SetLabelSize(0.07);
397     first_to_paint->Draw();
398     for(int il=1;il<5;il++){
399     TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
400     }
401     }
402     }
403     }
404 battilan 1.1
405 battilan 1.5 createGifFile("Tboxes",(iw-2),isec,"",Tboxes);
406     delete Tboxes;
407 battilan 1.1
408 battilan 1.5 //===================================================================================
409     // Time boxes: 1 page per SL
410     //===================================================================================
411     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing Time boxes per layer in 1 single page per SL wh "
412     << (iw-2) << " sec " << isec << endl;
413     ichmin=1; if (isec==13|| isec==14)ichmin=4;
414     for(int ich=ichmin;ich<5;ich++){
415     for(int isl=1;isl<4;isl++){
416     TCanvas *TboxSL = new TCanvas("TboxSL", "",201,81,999,699);
417 battilan 1.1
418 battilan 1.5 bool dodraw=1;
419     if(ich==4 && isl==2)dodraw=0; // avoid ThetaMB4
420     if(dodraw){
421     // look first for the maximum bin entries
422     first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0];
423     float nbmax=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][0]->GetMaximum();
424     for(int il=2;il<5;il++){
425     float nbmax0=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetMaximum();
426     if(nbmax0>nbmax){
427     first_to_paint=TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1];
428     nbmax=nbmax0;
429     }
430     TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetLineColor(il);
431     }
432     stringstream htitle; htitle << "TimeBox W" << (iw-2) << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
433     first_to_paint->SetTitle(htitle.str().c_str());
434     first_to_paint->GetYaxis()->SetLabelSize(0.04);
435     first_to_paint->GetXaxis()->SetLabelSize(0.04);
436     first_to_paint->Draw();
437     for(int il=1;il<5;il++){
438     TBoxSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->Draw("same");
439     }
440 battilan 1.1
441 battilan 1.5 stringstream fileTag; fileTag << "_MB" << ich << "_SL" << SLname[isl-1];
442     createGifFile("Tboxes",(iw-2),isec,fileTag.str(),TboxSL);
443     delete TboxSL;
444     }
445     }//end loop SL
446     }//end loop chambers
447    
448     }
449     }//end Loop on sectors/wheels
450 battilan 1.1
451    
452 battilan 1.5 //===================================================================================
453     // Trigger Stuff
454     //===================================================================================
455 battilan 1.1
456 battilan 1.5 TH1F *heffTrgSecMB[5][14][4];
457 pellicci 1.7 string labTriggerMatrix[]={"no trig"," ","MB1","MB2","MB3","MB4"," ","1 & 2","1 & 3","1 & 4","2 & 3","2 & 4",
458 battilan 1.5 "3 & 4"," ","1 & 2 & 3","1 & 2 & 4","1 & 3 & 4","2 & 3 & 4"," ","1 & 2 & 3 & 4"};
459    
460     whIt = mySectors.begin();
461     whEnd = mySectors.end();
462     for(;whIt!=whEnd;++whIt) {
463     int iw = (*whIt).first + 2;
464     std::vector<int>::const_iterator secIt = (*whIt).second.begin();
465     std::vector<int>::const_iterator secEnd = (*whIt).second.end();
466     for(;secIt!=secEnd;++secIt) {
467     int isec = (*secIt);
468     if(isec <13){
469    
470     //===================================================================================
471     // BX profiles:
472     //===================================================================================
473     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing single chamber BX profiles per Sector wh"
474     << (iw-2) << " sec " << isec << endl;
475     TCanvas *Trigg = new TCanvas("Trigg", "",201,81,999,699);
476     Trigg->Divide(2,2) ;
477     for(int ich=1;ich<5;ich++){
478     Trigg->cd(ich) ;
479     Trigg->cd(ich)->SetLogy();
480     Correlated_trig_Bx[iw][isec-1][ich-1][2]->GetXaxis()->SetTitle("BX id");
481     stringstream htitle; htitle << "llHlHH_trig_bxMB"<< ich;
482     Correlated_trig_Bx[iw][isec-1][ich-1][2]->SetTitle(htitle.str().c_str());
483     Correlated_trig_Bx[iw][isec-1][ich-1][2]->GetXaxis()->SetTitleSize(0.05);
484     Correlated_trig_Bx[iw][isec-1][ich-1][2]->GetXaxis()->SetLabelSize(0.05);
485     Correlated_trig_Bx[iw][isec-1][ich-1][2]->GetXaxis()->SetLabelSize(0.05);
486     Correlated_trig_Bx[iw][isec-1][ich-1][2]->Draw();
487     Correlated_trig_Bx[iw][isec-1][ich-1][1]->SetLineColor(2);
488     Correlated_trig_Bx[iw][isec-1][ich-1][1]->Draw("same");
489     Correlated_trig_Bx[iw][isec-1][ich-1][0]->SetLineColor(3);
490     Correlated_trig_Bx[iw][isec-1][ich-1][0]->Draw("same");
491     }// end loop on chambers
492    
493     createGifFile("Trigger_Summary",(iw-2),isec,"",Trigg);
494     delete Trigg;
495    
496     //===================================================================================
497     // Trigger: HH&HL efficiencies
498     //===================================================================================
499     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing HH&HL efficiencies wh "
500     << (iw-2) << " sec " << isec << endl;
501     TCanvas *EffTrg = new TCanvas("EffTrg", "",201,81,999,699);
502     EffTrg->Divide(2,4); // divide canvas in 2 columns, 4 raws
503    
504     for(int ich=1;ich<5;ich++){
505     stringstream histoname; histoname << "heffTrgSec" << isec << "MB" << ich;
506     heffTrgSecMB[iw][isec-1][ich-1] =(TH1F*)hTrg_effnum_SecMB[iw][isec-1][ich-1]->Clone(histoname.str().c_str());
507     heffTrgSecMB[iw][isec-1][ich-1]->Divide(hTrg_effnum_SecMB[iw][isec-1][ich-1]
508     ,hTrg_effdenum_SecMB[iw][isec-1][ich-1],1.0,1.0);
509     heffTrgSecMB[iw][isec-1][ich-1]->SetMaximum(1.1);
510     heffTrgSecMB[iw][isec-1][ich-1]->SetMinimum(0.);
511     heffTrgSecMB[iw][isec-1][ich-1]->GetXaxis()->SetLabelSize(0.05);
512     heffTrgSecMB[iw][isec-1][ich-1]->GetYaxis()->SetLabelSize(0.05);
513     for (int i = 0; i <= hTrg_effdenum_SecMB[iw][isec-1][ich-1]->GetNbinsX()+1; i++ ) {
514     Float_t tot = hTrg_effdenum_SecMB[iw][isec-1][ich-1]->GetBinContent(i) ;
515     Float_t tot_e = hTrg_effdenum_SecMB[iw][isec-1][ich-1]->GetBinError(i);
516     Float_t eff = heffTrgSecMB[iw][isec-1][ich-1]->GetBinContent(i) ;
517     Float_t Err = 0.;
518     if (tot > 0) Err = tot_e / tot * sqrt( eff* (1-eff) );
519     // if (eff == 1. || isnan(Err) || !isfinite(Err) ) Err=1.e-3;
520     heffTrgSecMB[iw][isec-1][ich-1]->SetBinError(i, Err);
521     }
522 battilan 1.1
523 battilan 1.5 EffTrg->cd((ich-1)*2+1);
524     heffTrgSecMB[iw][isec-1][ich-1]->Draw();
525     EffTrg->cd((ich-1)*2+2);
526     hPhiHL_SecMB[iw][isec-1][ich-1]->Draw();
527     }
528 battilan 1.1
529 battilan 1.5 createGifFile("TriggEff_HH&HL",(iw-2),isec,"",EffTrg);
530     delete EffTrg;
531 battilan 1.1
532 battilan 1.5 //===================================================================================
533     // Trigger: TriggerMatrix
534     //===================================================================================
535     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Drawing TriggerMatrix wh "
536     << (iw-2) << " sec " << isec << endl;
537 battilan 1.1
538 pellicci 1.7 for (int ibin=1; ibin<21; ibin++) TriggerMatrix[iw][isec-1]->GetXaxis()->SetBinLabel(ibin,(labTriggerMatrix[ibin-1]).c_str());
539 battilan 1.5 nbin = TriggerMatrix[iw][isec-1]->GetXaxis()->GetNbins();
540     max = 0;
541     TCanvas *Trigmatri = new TCanvas("TriggerMatrix", "",201,81,999,699);
542     Trigmatri->SetBottomMargin(0.12);
543    
544     for (int ibin=1; ibin<nbin+1; ibin++)
545     max = (max > TriggerMatrix[iw][isec-1]->GetBinContent(ibin) ) ? max : TriggerMatrix[iw][isec-1]->GetBinContent(ibin) ;
546     max1=max*1.3;
547    
548     TriggerMatrix[iw][isec-1]->GetXaxis()->SetLabelOffset(0.043);
549     // TriggerMatrix[iw][isec-1]->GetXaxis()->SetLabelOffset(-0.01);
550     // TriggerMatrix[iw][isec-1]->LabelsOption("v");
551     // TriggerMatrix[iw][isec-1]->GetXaxis()->SetLabelSize(0.04);
552    
553     TriggerMatrix[iw][isec-1]->SetMaximum(max1);
554     TriggerMatrix[iw][isec-1]->Draw();
555    
556     //sid = new TPaveText (-0.5,max1-(max1-max)/2,5,max1);
557     //sprintf (sid1,"YB%i, Sector %u, run %u",wheel, isec, run);
558     //sid->AddText(sid1);
559     //sid->Draw();
560    
561     TPaveText* labcont[50];
562     memset(labcont,0,50*sizeof(TPaveText*));
563     TText* cont[50];
564     memset(cont,0,50*sizeof(TText*));
565    
566     for (int ibin=1; ibin<nbin+1; ibin++) {
567     if (ibin == 2 || ibin == 7 || ibin == 14 || ibin == 19) continue;
568     float x1 = TriggerMatrix[iw][isec-1]->GetBinCenter(ibin) - TriggerMatrix[iw][isec-1]->GetBinWidth(ibin)/2;
569     float x2 = TriggerMatrix[iw][isec-1]->GetBinCenter(ibin) + TriggerMatrix[iw][isec-1]->GetBinWidth(ibin)/2;
570     float y1 = max + (max1-max)/8;
571     float y2 = max1 - (max1-max)/2;
572     labcont[ibin-1] = new TPaveText (x1,y1,x2,y2);
573 battilan 1.1
574 battilan 1.5 char contbin[6];
575     sprintf (contbin,"%u",int(TriggerMatrix[iw][isec-1]->GetBinContent(ibin)));
576     // labcont[ibin-1]->AddText(cont[ibin-1]);
577    
578     cont[ibin-1] = labcont[ibin-1]->AddText (contbin);
579     // isme.SetTextAngle(90.);
580     cont[ibin-1]->SetTextSize(0.02);
581     labcont[ibin-1]->Draw();
582     }
583 battilan 1.1
584 battilan 1.5 createGifFile("TriggerMatrix",(iw-2),isec,"",Trigmatri);
585     delete Trigmatri;
586     for (int i=0;i<50;++i) {
587     if (labcont[i]) delete labcont[i];
588     }
589    
590     //===================================================================================
591     // Trigger: TriggerInclusive SECTOR BY SECTOR
592     //===================================================================================
593 battilan 1.1
594     TCanvas *TrigmatriSec = new TCanvas("TriggerInclusive[iw]", "",201,81,999,699);
595     TrigmatriSec->SetBottomMargin(0.12);
596    
597     int ibin_init=(isec-1)*5+1;
598     int xpos_init=(isec-1)*5+1;
599    
600     max = 0;
601     for (int ibin=ibin_init; ibin<ibin_init+5; ibin++)
602     max = (max > TriggerInclusive[iw]->GetBinContent(ibin) ) ? max : TriggerInclusive[iw]->GetBinContent(ibin) ;
603     max1=max*1.3;
604    
605     TriggerInclusive[iw]->GetXaxis()->SetRange(xpos_init,xpos_init+4);
606     TriggerInclusive[iw]->GetXaxis()->SetLabelSize(0.07);
607     TriggerInclusive[iw]->SetMaximum(max1);
608     TriggerInclusive[iw]->Draw();
609    
610 battilan 1.5 memset(labcont,0,50*sizeof(TPaveText*));
611     memset(cont,0,50*sizeof(TText*));
612 battilan 1.1 for (int ibin=ibin_init; ibin<ibin_init+4; ibin++) {
613    
614     float x1 = TriggerInclusive[iw]->GetBinCenter(ibin) - TriggerInclusive[iw]->GetBinWidth(ibin)/2;
615     float x2 = TriggerInclusive[iw]->GetBinCenter(ibin) + TriggerInclusive[iw]->GetBinWidth(ibin)/2;
616     float y1 = max + (max1-max)/8;
617     float y2 = max1 - (max1-max)/2;
618     labcont[ibin-1] = new TPaveText (x1,y1,x2,y2);
619    
620     char contbin[6];
621     sprintf (contbin,"%u",int(TriggerInclusive[iw]->GetBinContent(ibin)));
622     // labcont[ibin-1]->AddText(cont[ibin-1]);
623    
624     cont[ibin-1] = labcont[ibin-1]->AddText (contbin);
625     // isme.SetTextAngle(90.);
626     cont[ibin-1]->SetTextSize(0.04);
627     labcont[ibin-1]->Draw();
628    
629     }
630    
631     createGifFile("TriggerInclusive",(iw-2),isec,"",TrigmatriSec);
632     delete TrigmatriSec;
633 battilan 1.5 for (int i=0;i<50;++i) {
634     if (labcont[i]) delete labcont[i];
635     }
636    
637    
638     }// if on isec < 13
639     }// end loop on sectors
640    
641     //===================================================================================
642     // Trigger: TriggerInclusive FULL WHEEL
643     //===================================================================================
644     TCanvas *Trigmatri = new TCanvas("TriggerMatrix", "",201,81,999,699);
645     Trigmatri->SetBottomMargin(0.12);
646    
647     nbin = TriggerInclusive[iw]->GetXaxis()->GetNbins();
648     TriggerInclusive[iw]->GetXaxis()->SetRange(1,nbin);
649    
650     max = 0;
651    
652     for (int ibin=1; ibin<nbin+1; ibin++)
653     max = (max > TriggerInclusive[iw]->GetBinContent(ibin) ) ? max : TriggerInclusive[iw]->GetBinContent(ibin) ;
654     max1=max*1.3;
655     TriggerInclusive[iw]->SetMaximum(max1);
656     TriggerInclusive[iw]->GetXaxis()->SetLabelSize(0.035);
657     TriggerInclusive[iw]->Draw();
658    
659     TPaveText* sid = new TPaveText (0,max1-(max1-max)/2,2,max1);
660 battilan 1.1
661 battilan 1.5 stringstream chname; chname << "YB," << (iw-2) <<",";
662     sid->AddText(chname.str().c_str());
663     sid->Draw();
664    
665     createGifFile("TriggerInclusive",(iw-2),"",Trigmatri);
666     delete Trigmatri;
667     delete sid;
668    
669     }// end loop on wheels
670    
671 battilan 1.1 }
672    
673     void DTDPGCreateAnalyzerSummary::createSummaryWheelPlots() {
674    
675     string Whname[5]={"Wm2","Wm1","W0","W1","W2"};
676     string SLname[3]={"Phi1","Theta","Phi2"};
677    
678 battilan 1.2 TH1F *historun = getHisto<TH1F>("RunInfo_RunNumbers");
679 battilan 1.1 float TotEntries = historun->GetEntries();
680    
681     gStyle->SetTitleX(0.01);
682     gStyle->SetTitleY(0.99);
683    
684     gStyle->SetOptStat(10);
685     gStyle->SetStatY(0.97);
686     gStyle->SetStatX(0.98);
687     gStyle->SetStatW(0.35);
688     gStyle->SetStatH(0.45);
689    
690     gStyle->SetPalette(1); // set palette for 2D histos
691     gStyle->SetTitleW(0.97);
692     gStyle->SetTitleH(0.1);
693    
694     TH1F * first_to_paint;
695    
696 pellicci 1.7 //float BXSummary_mean=0.;
697     //float NBXSummary_mean=0.;
698 battilan 1.1 TH1F *BXSummary[5][4];
699     for(int iw=0;iw<5;iw++){ // Loop in wheels
700     for(int ic=1;ic<5;ic++){
701     stringstream hname; hname << "BX_mean_MB" << ic << "_W" << (iw-2);
702     stringstream htitle; htitle << "BX MeanValue (HH,HL) MB" << ic << " W" << (iw-2);
703     BXSummary[iw][ic-1]= new TH1F(hname.str().c_str(),htitle.str().c_str(),12,1.,13.);
704     for(int is=1;is<13;is++){
705     stringstream xlab; xlab << "S" << is;
706     BXSummary[iw][ic-1]->GetXaxis()->SetBinLabel(is,xlab.str().c_str());
707     }
708     }
709     }
710    
711    
712    
713 battilan 1.2 for(int iw=0;iw<5;iw++){ // Loop in wheels
714 battilan 1.1
715     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Processing Wheel " << iw-2 << endl;
716     // Digi scatter plots
717     TCanvas *DQM1 = new TCanvas("DQM1", "",201,81,999,699);
718     DQM1->Divide(2,3) ;
719     TCanvas *DQM1b = new TCanvas("DQM1b", "",201,81,999,699);
720     DQM1b->Divide(2,3) ;
721     TCanvas *DQM2 = new TCanvas("DQM2", "",201,81,999,699);
722     DQM2->Divide(2,3) ;
723     TCanvas *DQM2b = new TCanvas("DQM2b", "",201,81,999,699);
724     DQM2b->Divide(2,3) ;
725    
726     TH2F *hDigiXYList[14];
727    
728     for(int isec=1;isec<13;isec++){
729     stringstream histoname; histoname << "hDigiXY_" << Whname[iw] << "_S" << isec;
730 battilan 1.2 hDigiXYList[isec-1]= getHisto<TH2F>(histoname.str());
731 battilan 1.1 }
732    
733     float Max=2000;
734     float Max0[12];
735 pellicci 1.7 //float MaxMean=0;
736 battilan 1.1 float MaxMean0=0;
737     float MaxRMS0=0;
738 pellicci 1.7 //float MaxRMS=0;
739 battilan 1.1 int Ns=0;
740     for(int is=0;is<12; is++){
741     Max0[is]=0;
742     Max0[is]=hDigiXYList[is]->GetMaximum();
743     if(Max0[is]>Max)Max=Max0[is];
744     if(Max0[is]>0){ MaxMean0+=Max0[is]; MaxRMS0+=Max0[is]*Max0[is];Ns++;}
745     }
746    
747     for(int is=0;is<12; is++){
748     if(is<6){DQM1->cd(is+1); DQM1->cd(is+1)->SetLogz();}
749     else {DQM2->cd(is-5); DQM2->cd(is-5)->SetLogz();}
750     hDigiXYList[is]->SetStats(0);
751     hDigiXYList[is]->SetMaximum(Max);
752     hDigiXYList[is]->Draw("colz");
753     }
754    
755     createGifFile("Digi",(iw-2),"_S1-S6",DQM1);
756     createGifFile("Digi",(iw-2),"_S7_S12",DQM2);
757    
758     if(Max>TotEntries){ // To cut noise cells and see better the
759     // occupancies on other cells
760     for(int is=0;is<12; is++){
761     if(is<6){DQM1b->cd(is+1); DQM1b->cd(is+1)->SetLogz();}
762     else {DQM2b->cd(is-5); DQM2b->cd(is-5)->SetLogz();}
763     hDigiXYList[is]->SetStats(0);
764     hDigiXYList[is]->SetMaximum(TotEntries);
765     hDigiXYList[is]->Draw("colz");
766     }
767    
768     createGifFile("Digi",(iw-2),"_S1-S6_b",DQM1b);
769     createGifFile("Digi",(iw-2),"_S7-S12_b",DQM2b);
770     }
771    
772 battilan 1.5 // Ocupancies per SL
773 battilan 1.1 // Get histos to be plotted
774 pellicci 1.7 //int nbin;
775     //float max, max1;
776     //TPaveText *sid;
777     //char sid1[50]; char answ;
778     //TPaveText *labcont[50]; TText *cont[50];
779 battilan 1.1
780     // Occupancies
781     TH2F *DigiXYS[5][14];
782     for(int isec=1;isec<15;isec++){
783     stringstream histoname; histoname << "hDigiXY_" << Whname[iw] << "_S" << isec;
784 battilan 1.2 DigiXYS[iw][isec-1]=getHisto<TH2F>(histoname.str());
785 battilan 1.1 }
786    
787     // Crea and fill individual layer occupancy plots from hDigiXY_S
788     TH1F *DigiXSecMBSl[5][14][4][3];
789     TH1F *DigiXSecMBSlLayer[5][14][4][3][4];
790     for(int isec=1;isec<15;isec++){
791     for(int ich=1;ich<5;ich++){
792     for(int isl=1;isl<4;isl++){
793     stringstream hnamesl; hnamesl << "Occup_" << Whname[iw] << "_S" << isec << "_MB" << ich <<" _SL" << isl;
794     stringstream htitlesl; htitlesl << "Occupancy " << Whname[iw] << " S" << isec << " MB" << ich << " SL" << SLname[isl-1];
795     DigiXSecMBSl[iw][isec-1][ich-1][isl-1]= new TH1F(hnamesl.str().c_str(),htitlesl.str().c_str(),100, 0.,100.);
796     for(int il=1;il<5;il++){
797     stringstream hnamel; hnamel << hnamesl.str() << "_L" << il;
798     stringstream htitlel; htitlel << htitlesl.str()<< " L" << il;
799     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]= new TH1F(hnamel.str().c_str(),htitlel.str().c_str(),100, 0.,100.);
800     }
801     }
802     }
803     }
804    
805     for(int isec=1;isec<15;isec++){
806     int nbx= DigiXYS[iw][isec-1]->GetNbinsX() ;
807 pellicci 1.7 //int nby= DigiXYS[iw][isec-1]->GetNbinsY() ;
808 battilan 1.1
809     for(int ich=1;ich<5;ich++){
810     for(int isl=1;isl<4;isl++){
811     // Fill layer histos
812     for(int il=1;il<5;il++){
813     int iby=(ich-1)*20+(isl-1)*4+il+1;
814     float totentr=0;
815     for(int ibx=1;ibx<nbx;ibx++){
816     float yval=DigiXYS[iw][isec-1]->GetBinContent(ibx,iby);
817     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetBinContent(ibx,yval);
818     totentr+=yval;
819     }
820     DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->SetEntries(totentr);
821     }
822     // Fill SL histos adding individual layer contents
823     for(int ibx=1;ibx<nbx;ibx++){
824     float yval=0;
825     for(int il=1;il<5;il++)
826     yval+=DigiXSecMBSlLayer[iw][isec-1][ich-1][isl-1][il-1]->GetBinContent(ibx);
827    
828     DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->SetBinContent(ibx,yval);
829     }
830     }
831     }
832     }// end loop sector
833    
834     // DIGI's occupancies
835    
836     TCanvas *Digi1 = new TCanvas("Digi1", "",201,81,999,699);
837     TCanvas *Digi2 = new TCanvas("Digi2", "",201,81,999,699);
838     TCanvas *Digi3 = new TCanvas("Digi3", "",201,81,999,699);
839     Digi1->Divide(4,4); Digi2->Divide(4,4); Digi3->Divide(4,4);
840     for(int isec=1;isec<13;isec++){ // Loop on sectors
841     for(int ich=1;ich<5;ich++){
842     // look first for the maximum bin entries
843     first_to_paint=DigiXSecMBSl[iw][isec-1][ich-1][0];
844     float nbmax=DigiXSecMBSl[iw][isec-1][ich-1][0]->GetMaximum();
845     for(int isl=1;isl<4;isl++){
846     if(!(ich==4 && isl==2)){ // avoid ThetaMB4
847     float nbmax0=DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->GetMaximum();
848     if(nbmax0>nbmax){
849     first_to_paint=DigiXSecMBSl[iw][isec-1][ich-1][isl-1];
850     nbmax=nbmax0;
851     }
852     DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->SetLineColor(isl);
853     }
854     }
855     stringstream htitle; htitle << "Occupancy W" << (iw-2) << " S" << isec << " MB" << ich;
856     first_to_paint->SetTitle(htitle.str().c_str());
857     if(isec<5) {int icpos=(isec-1)*4+ich; Digi1->cd(icpos) ; Digi1->cd(icpos)->SetLogy();}
858     if(isec>4 && isec<9) {int icpos=(isec-5)*4+ich; Digi2->cd(icpos) ; Digi2->cd(icpos)->SetLogy();}
859     if(isec>8 && isec<13){int icpos=(isec-9)*4+ich; Digi3->cd(icpos) ; Digi3->cd(icpos)->SetLogy();}
860     first_to_paint->GetYaxis()->SetLabelSize(0.07);
861     first_to_paint->GetXaxis()->SetLabelSize(0.07);
862     first_to_paint->Draw();
863     for(int isl=1;isl<4;isl++){
864     if(!(ich==4 && isl==2)) // avoid ThetaMB4
865     DigiXSecMBSl[iw][isec-1][ich-1][isl-1]->Draw("same");
866     }
867     }
868     }// End Loop on sectors
869     createGifFile("Occupancies_LogScale",(iw-2),"_S1-S4",Digi1);
870     createGifFile("Occupancies_LogScale",(iw-2),"_S5-S8",Digi2);
871     createGifFile("Occupancies_LogScale",(iw-2),"_S9-S12",Digi3);
872    
873     // TimeBoxes
874     DQM1->Clear();
875     DQM1->Divide(6,2) ;
876     for (int ins=1; ins<13;ins++){
877     TH1F *hHisto[4];
878     int nbmax=0;
879     int nbmax0=0;
880    
881     DQM1->cd(ins);
882     for(int ic=1;ic<5;ic++){
883     stringstream hname; hname << "htime_" << Whname[iw] << "_S" << ins << "_MB" << ic;
884 battilan 1.2 hHisto[ic-1]=getHisto<TH1F>(hname.str());
885 battilan 1.1 hHisto[ic-1]->SetLineColor(ic);
886     }
887    
888     first_to_paint = hHisto[0];
889     nbmax=hHisto[0]->GetMaximum();
890    
891     for(int ic=2;ic<5;ic++){
892     nbmax0=hHisto[ic-1]->GetMaximum();
893     if(nbmax0>nbmax){
894     nbmax=nbmax0;
895     first_to_paint=hHisto[ic-1];
896     }
897     }
898    
899     first_to_paint->GetXaxis()->SetLabelSize(0.08);
900     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
901     first_to_paint->GetXaxis()->SetTitle("cm");
902     first_to_paint->GetXaxis()->SetTitleSize(0.09);
903     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
904     first_to_paint->GetXaxis()->SetNdivisions(308);
905 pellicci 1.7 //char htit[240];
906 battilan 1.1 stringstream htitle; htitle << "TimeBox W" << iw-2 << " S" << ins;
907     first_to_paint->SetTitle(htitle.str().c_str());
908     first_to_paint->Draw();
909     for(int ic=1;ic<5;ic++)hHisto[ic-1]->Draw("same");
910    
911     }// end loop on sectors
912     stringstream fileTBox; fileTBox <<"TBox_r" << myRunNumber <<"_W" << (iw-2);
913     createGifFile("TBox",(iw-2),"",DQM1);
914    
915     // Hit Residuals
916     DQM1->Clear();
917     DQM1->Divide(6,2) ;
918    
919     for(int ins=1;ins<13; ins++){
920     TH1F *hHisto[4];
921     DQM1->cd(ins);
922    
923     int nbmax=0;
924     int nbmax0=0;
925    
926     for(int ic=1;ic<5;ic++){
927     stringstream hname; hname << "hResX_" << 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     stringstream htitle; htitle << "Hit residuals W" << (iw-2) << " S" << ins;
950     first_to_paint->SetTitle(htitle.str().c_str());
951    
952     first_to_paint->Draw();
953     for(int ic=1;ic<5;ic++)
954     hHisto[ic-1]->Draw("same");
955     }// end loop on sectors
956    
957     createGifFile("HitResiduals",(iw-2),"",DQM1);
958    
959     // Angle Phi LOCAL
960     DQM1->Clear();
961     DQM1->Divide(6,2) ;
962    
963     for (int ins=1; ins<13;ins++){
964     TH1F *hPhi[4];
965     DQM1->cd(ins);
966     int nbmax=0;
967     int nbmax0=0;
968    
969     for(int ic=1;ic<5;ic++){
970     stringstream hname; hname << "hPhi_" << Whname[iw] << "_S" << ins << "_MB" << ic;
971 battilan 1.2 hPhi[ic-1]=getHisto<TH1F>(hname.str());
972 battilan 1.1 hPhi[ic-1]->SetLineColor(ic);
973     }
974    
975     first_to_paint = hPhi[0];
976     nbmax=hPhi[0]->GetMaximum();
977    
978     for(int ic=2;ic<5;ic++){
979     nbmax0=hPhi[ic-1]->GetMaximum();
980     if(nbmax0>nbmax){
981     nbmax=nbmax0;
982     first_to_paint=hPhi[ic-1];
983     }
984     }
985    
986     first_to_paint->GetXaxis()->SetLabelSize(0.08);
987     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
988     first_to_paint->GetXaxis()->SetTitle("deg");
989     first_to_paint->GetXaxis()->SetTitleSize(0.09);
990     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
991     first_to_paint->GetXaxis()->SetNdivisions(308);
992     stringstream htitle; htitle << "Phi local W" << (iw-2) << " S" << ins;
993     first_to_paint->SetTitle(htitle.str().c_str());
994    
995     first_to_paint->Draw();
996     for(int ic=1;ic<5;ic++) hPhi[ic-1]->Draw( "same");
997    
998     }// end loop on sectors
999    
1000    
1001     createGifFile("PhiLocal",(iw-2),"",DQM1);
1002    
1003     // STA Digis
1004     DQM1->Clear();
1005    
1006     stringstream hnameSTADigi; hnameSTADigi << "hHitsPosXYSA_" << Whname[iw];
1007 battilan 1.2 TH1F *hXYHisto=getHisto<TH1F>(hnameSTADigi.str());;
1008 battilan 1.1
1009     hXYHisto->SetStats(0);
1010     hXYHisto->Draw("colz");
1011    
1012    
1013     createGifFile("STADigi",(iw-2),"",DQM1);
1014    
1015    
1016     // STA Phi Hits
1017     TCanvas *DQM6 = new TCanvas("DQM6", "",301,81,999,699); // open a large canvas
1018 battilan 1.2 TH1F *hnHitDT= getHisto<TH1F>("hnHitDT");
1019 battilan 1.1 Float_t Nevents = hnHitDT->GetEntries();
1020     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Total nr. of triggers:" << Nevents << endl;
1021    
1022     TH1F *hPhiHisto[4];
1023     TH1F *heff[4];
1024    
1025     float ymax = 0.1;
1026     for(int ic=1;ic<5;ic++){
1027     stringstream hname1, hname2, htitle;
1028    
1029     hname1 << "hPhiHit_" << Whname[iw] << "_MB" << ic;
1030 battilan 1.2 hPhiHisto[ic-1]=getHisto<TH1F>(hname1.str());
1031 battilan 1.1
1032     hname2 << "heff" << ic;
1033     heff[ic-1] =(TH1F*) hPhiHisto[ic-1]->Clone(hname2.str().c_str());
1034     heff[ic-1]->Add(heff[ic-1],heff[ic-1],0.5/Nevents,0.5/Nevents);
1035    
1036     heff[ic-1]->SetMaximum(ymax);
1037     heff[ic-1]->SetStats(0);
1038     heff[ic-1]->SetLineColor(ic);
1039     htitle << "Phi of ass. hit, W" << (iw-2);
1040     heff[0]->SetTitle(htitle.str().c_str());
1041     if(ic==1)heff[ic-1]->Draw();
1042     else heff[ic-1]->Draw("same");
1043    
1044     }
1045    
1046 battilan 1.5 TLine *l[16];
1047     l[0] = new TLine(-165, 0, -165, ymax); l[0]->Draw();
1048     l[1] = new TLine(-135, 0, -135, ymax); l[1]->Draw();
1049     l[2] = new TLine(-105, 0, -105, ymax); l[2]->Draw();
1050     l[3] = new TLine( -75, 0, -75, ymax); l[3]->Draw();
1051     l[4] = new TLine( -45, 0, -45, ymax); l[4]->Draw();
1052     l[5] = new TLine( -15, 0, -15, ymax); l[5]->Draw();
1053     l[6] = new TLine( 15, 0, 15, ymax); l[6]->Draw();
1054     l[7] = new TLine( 45, 0, 45, ymax); l[7]->Draw();
1055     l[8] = new TLine( 75, 0, 75, ymax); l[8]->Draw();
1056     l[9] = new TLine( 105, 0, 105, ymax); l[9]->Draw();
1057     l[10] = new TLine( 135, 0, 135, ymax); l[10]->Draw();
1058     l[11] = new TLine( 165, 0, 165, ymax); l[11]->Draw();
1059    
1060     l[12] = new TLine( -40, 0.8*ymax, -20, 0.8*ymax); //l->Draw();
1061     l[12]->SetLineColor(1);
1062     l[12]->Draw();
1063     TPaveLabel * box [4];
1064     box[0] = new TPaveLabel(-10,0.8*ymax,5,0.85*ymax,"MB1");
1065     box[0]->Draw();
1066    
1067     l[13] = new TLine( -40, 0.7*ymax, -20, 0.7*ymax); //l->Draw();
1068     l[13]->SetLineColor(2);
1069     l[13]->Draw();
1070     box[1] = new TPaveLabel(-10,0.7*ymax,5,0.75*ymax,"MB2");
1071     box[1]->Draw();
1072    
1073     l[14] = new TLine( -40, 0.6*ymax, -20, 0.6*ymax); //l->Draw();
1074     l[14]->SetLineColor(3);
1075     l[14]->Draw();
1076     box[2] = new TPaveLabel(-10,0.6*ymax,5,0.65*ymax,"MB3");
1077     box[2]->Draw();
1078 battilan 1.1
1079 battilan 1.5 l[15] = new TLine( -40, 0.5*ymax, -20, 0.5*ymax); //l->Draw();
1080     l[15]->SetLineColor(4);
1081     l[15]->Draw();
1082     box[3] = new TPaveLabel(-10,0.5*ymax,5,0.55*ymax,"MB4");
1083     box[3]->Draw();
1084 battilan 1.1
1085     createGifFile("STAPhiHits",(iw-2),"",DQM6);
1086    
1087 battilan 1.5 for (int i=0;i<16;++i) delete l[i];
1088     for (int i=0;i<4;++i) delete box[i];
1089 battilan 1.1
1090     // STA Hits
1091     DQM1->Clear();
1092     DQM1->Divide(6,2) ;
1093    
1094     TH1F *hNassList[12];
1095    
1096     for(int isec=1;isec<13;isec++){
1097     stringstream histoname; histoname << "hNhass_" << Whname[iw] << "_S" << isec;
1098 battilan 1.2 hNassList[isec-1]=getHisto<TH1F>(histoname.str());
1099 battilan 1.1 }
1100    
1101    
1102     for(int is=0;is<12;is++){
1103     hNassList[is]->GetXaxis()->SetNdivisions(308);
1104     hNassList[is]->GetXaxis()->SetLabelSize(0.08);
1105     hNassList[is]->GetXaxis()->SetLabelOffset(-0.025);
1106     hNassList[is]->GetXaxis()->SetTitle("# hits");
1107     hNassList[is]->GetXaxis()->SetTitleSize(0.01);
1108     hNassList[is]->GetXaxis()->SetTitleOffset(0.5);
1109    
1110     DQM1->cd(is+1);
1111     hNassList[is]->SetStats(1);
1112     hNassList[is]->Draw();
1113     }
1114    
1115     createGifFile("STAHits",(iw-2),"",DQM1);
1116    
1117    
1118     // Segment Hits
1119     DQM2->Clear();
1120     DQM2->Divide(6,2);
1121    
1122     TH1F *hNhits[12][4];
1123     for (int ins=1; ins<13;ins++){
1124     DQM2->cd(ins);
1125     int nbmax=0;
1126     int nbmax0=0;
1127    
1128     for(int ic=1;ic<5;ic++){
1129     stringstream hname; hname << "hNhits_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1130 battilan 1.2 hNhits[ins-1][ic-1]= getHisto<TH1F>(hname.str());
1131 battilan 1.1 hNhits[ins-1][ic-1]->SetLineColor(ic);
1132     }
1133    
1134     first_to_paint= hNhits[ins-1][0];
1135     nbmax=hNhits[ins-1][0]->GetMaximum();
1136    
1137     for(int ic=2;ic<5;ic++){
1138     nbmax0=hNhits[ins-1][ic-1]->GetMaximum();
1139     if(nbmax0>nbmax){
1140     nbmax=nbmax0;
1141     first_to_paint=hNhits[ins-1][ic-1];
1142     }
1143     }
1144    
1145     first_to_paint->GetXaxis()->SetLabelSize(0.08);
1146     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1147     first_to_paint->GetXaxis()->SetTitle("#hits");
1148     first_to_paint->GetXaxis()->SetTitleSize(0.09);
1149     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1150     first_to_paint->GetXaxis()->SetNdivisions(308);
1151     stringstream htitle; htitle << "# hits in seg W" << (iw-2) << " S" << ins;
1152     first_to_paint->SetTitle(htitle.str().c_str());
1153    
1154     first_to_paint->Draw();
1155     for(int ic=1;ic<5;ic++) hNhits[ins-1][ic-1]->Draw( "same");
1156    
1157     }// end loop on sectors
1158    
1159    
1160     createGifFile("SegHits",(iw-2),"",DQM2);
1161    
1162     // Segment Hits
1163     DQM1->Clear();
1164     DQM1->Divide(6,2);
1165     TH1F * hNsegsList[12];
1166     for(int is=0;is<12;is++){
1167     stringstream hname; hname << "hNsegs_" << Whname[iw] << "_S" <<is+1;
1168 battilan 1.2 hNsegsList[is]= getHisto<TH1F>(hname.str());
1169 battilan 1.1 hNsegsList[is]->GetXaxis()->SetTitle("# Segments");
1170     }
1171    
1172     for(int is=0;is<12;is++){
1173     DQM1->cd(is+1);
1174     hNsegsList[is]->GetXaxis()->SetNdivisions(308);
1175     hNsegsList[is]->GetXaxis()->SetLabelSize(0.08);
1176     hNsegsList[is]->GetXaxis()->SetLabelOffset(-0.025);
1177     hNsegsList[is]->GetXaxis()->SetTitleSize(0.09);
1178     hNsegsList[is]->GetXaxis()->SetTitleOffset(0.5);
1179     hNsegsList[is]->SetStats(1);
1180     hNsegsList[is]->Draw();
1181     }
1182    
1183     createGifFile("Segments",(iw-2),"",DQM1);
1184    
1185     // TMAX
1186 battilan 1.5
1187 battilan 1.1 TCanvas *DQM11 = new TCanvas("DQM11", "1",101,81,999,699);
1188     TCanvas *DQM12 = new TCanvas("DQM12", "2",101,81,999,699);
1189     TCanvas *DQM13 = new TCanvas("DQM13", "3",101,81,999,699);
1190     TCanvas *DQM14 = new TCanvas("DQM14", "4",101,81,999,699);
1191     DQM11->Divide(4,3) ;
1192     DQM12->Divide(4,3) ;
1193     DQM13->Divide(4,3) ;
1194     DQM14->Divide(4,3) ;
1195    
1196     for (int ins=1; ins<13;ins++){
1197     TH1F *hHisto[2];
1198     for(int ic=1;ic<5;ic++){
1199    
1200     stringstream hname; hname << "htmax_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1201 battilan 1.2 hHisto[0]= getHisto<TH1F>(hname.str()+"_SL1");
1202     hHisto[1]= getHisto<TH1F>(hname.str()+"_SL3");
1203 battilan 1.1
1204     if(ins<4){
1205     int ipos=(ins-1)*4+ic;
1206     DQM11->cd(ipos);
1207     }
1208     if(ins>3 && ins<7){
1209     int ipos=(ins-4)*4+ic;
1210     DQM12->cd(ipos);
1211     }
1212     if(ins>6 && ins<10){
1213     int ipos=(ins-7)*4+ic;
1214     DQM13->cd(ipos);
1215     }
1216     if(ins>9){
1217     int ipos=(ins-10)*4+ic;
1218     DQM14->cd(ipos);
1219     }
1220    
1221     hHisto[0]->SetStats(1);
1222 battilan 1.3 hHisto[0]->Draw();
1223 battilan 1.4 try {
1224     hHisto[0]->Fit("gaus","Q");
1225     } catch(const cms::Exception&) {
1226     edm::LogError("DTDPGSummary") << "[DTDPGCreateAnalyzerSummary]: Error fitting " << hname.str() << "_SL1";
1227     }
1228 battilan 1.1 hHisto[1]->SetLineColor(2);
1229     hHisto[1]->Draw("same");
1230     }// end loop on chambers
1231     }// end loop on sectors
1232    
1233     createGifFile("TMax",(iw-2),"S1-S3",DQM11);
1234 battilan 1.4 createGifFile("TMax",(iw-2),"S4-S6",DQM12);
1235     createGifFile("TMax",(iw-2),"S7-S9",DQM13);
1236     createGifFile("TMax",(iw-2),"S10-S12",DQM14);
1237 battilan 1.1
1238    
1239     // Phi-Trig Efficiency
1240     TCanvas *Eff = new TCanvas("Eff", "",201,81,999,699);
1241     TH1F *hHisto[4];
1242     TH1F *hHistoTr[4];
1243     TH1F *heffx[4];
1244     for(int ic=1;ic<5;ic++)
1245     {
1246     stringstream hname1; hname1 << "hPhiGlob_" << Whname[iw] << "_MB" << ic;
1247 battilan 1.2 hHisto[ic-1]= getHisto<TH1F>(hname1.str());
1248 battilan 1.1
1249     stringstream hname2; hname2 << "heff" << ic <<"x";
1250     //heffx[ic-1]=hHisto[ic-1]->Clone(hname);
1251     heffx[ic-1] =(TH1F*) hHisto[ic-1]->Clone(hname2.str().c_str());
1252     heffx[ic-1]->SetLineColor(ic);
1253    
1254     stringstream hname3; hname3 << "hPhiTrigg_" << Whname[iw] << "_MB" << ic;
1255 battilan 1.2 hHistoTr[ic-1]= getHisto<TH1F>(hname3.str());
1256 battilan 1.1 heffx[ic-1]->Divide(hHistoTr[ic-1],hHisto[ic-1],1.0,1.0);
1257    
1258     for (int i = 0; i <= heffx[ic-1]->GetNbinsX()+1; i++ ) {
1259     Float_t tot = hHisto[ic-1]->GetBinContent(i) ;
1260     Float_t tot_e = hHisto[ic-1]->GetBinError(i);
1261     Float_t eff = heffx[ic-1]->GetBinContent(i) ;
1262     Float_t Err = 0.;
1263     if (tot > 0) Err = tot_e / tot * sqrt( eff* (1-eff) );
1264     // if (eff == 1. || isnan(Err) || !isfinite(Err) ) Err=1.e-3;
1265     heffx[ic-1]->SetBinError(i, Err);
1266     }
1267     heffx[ic-1]->SetStats(0);
1268     heffx[ic-1]->SetMaximum(1);
1269     stringstream htitle; htitle << "Phi-Trigger Eff W" << iw-2;
1270     heffx[0]->SetTitle(htitle.str().c_str());
1271     heffx[0]->SetMaximum(1.02);
1272    
1273     if(ic==1)heffx[ic-1]->Draw();
1274     else heffx[ic-1]->Draw("same");
1275     }
1276    
1277     ymax = 1.;
1278 battilan 1.5 l[0] = new TLine(-165, 0, -165, ymax); l[0]->Draw();
1279     l[1] = new TLine(-135, 0, -135, ymax); l[1]->Draw();
1280     l[2] = new TLine(-105, 0, -105, ymax); l[2]->Draw();
1281     l[3] = new TLine( -75, 0, -75, ymax); l[3]->Draw();
1282     l[4] = new TLine( -45, 0, -45, ymax); l[4]->Draw();
1283     l[5] = new TLine( -15, 0, -15, ymax); l[5]->Draw();
1284     l[6] = new TLine( 15, 0, 15, ymax); l[6]->Draw();
1285     l[7] = new TLine( 45, 0, 45, ymax); l[7]->Draw();
1286     l[8] = new TLine( 75, 0, 75, ymax); l[8]->Draw();
1287     l[9] = new TLine( 105, 0, 105, ymax); l[9]->Draw();
1288     l[10] = new TLine( 135, 0, 135, ymax); l[10]->Draw();
1289     l[11] = new TLine( 165, 0, 165, ymax); l[11]->Draw();
1290 battilan 1.1
1291     createGifFile("TrigEff",(iw-2),"",Eff);
1292 battilan 1.5
1293     for (int i=0;i<12;++i) delete l[i];
1294 battilan 1.1
1295     // Segment Hits
1296     DQM1->Clear();
1297     DQM1->Divide(6,2) ;
1298    
1299     for (int ins=1; ins<13;ins++){
1300     TH1F *hHisto[4];
1301     DQM1->cd(ins);
1302    
1303     int nbmax=0;
1304     int nbmax0=0;
1305    
1306    
1307     for(int ic=1;ic<5;ic++){
1308     stringstream hname; hname << "hTrigBits_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1309 battilan 1.2 hHisto[ic-1]= getHisto<TH1F>(hname.str());
1310 battilan 1.1 hHisto[ic-1]->SetLineColor(ic);
1311     }
1312    
1313     first_to_paint = hHisto[0];
1314     nbmax=hHisto[0]->GetMaximum();
1315    
1316     for(int ic=2;ic<5;ic++){
1317     nbmax0=hHisto[ic-1]->GetMaximum();
1318     if(nbmax0>nbmax){
1319     nbmax=nbmax0;
1320     first_to_paint=hHisto[ic-1];
1321     }
1322     }
1323     first_to_paint->GetXaxis()->SetLabelSize(0.08);
1324     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1325     first_to_paint->GetXaxis()->SetTitle("Quality");
1326     first_to_paint->GetXaxis()->SetTitleSize(0.09);
1327     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1328     first_to_paint->GetXaxis()->SetNdivisions(308);
1329     stringstream htitle; htitle << "Highest trig qual W" << (iw-2) << " S" << ins;
1330     first_to_paint->SetTitle(htitle.str().c_str());
1331    
1332     first_to_paint->Draw();
1333     for(int ic=1;ic<5;ic++)
1334     hHisto[ic-1]->Draw("same");
1335    
1336     }// end loop on sectors
1337    
1338     createGifFile("TrigHighQual",(iw-2),"",DQM1);
1339    
1340    
1341 battilan 1.5 // SC BX Summary
1342 battilan 1.1 TCanvas *BX = new TCanvas("BX", "",201,81,999,699);
1343     BX->Divide(6,2);
1344     for(int ins=1;ins<13;ins++){ // Loop in sectors
1345    
1346     int nbmax=0;
1347     int nbmax0=0;
1348    
1349     TH1F *hHH[4];
1350     TH1F *hHL[4];
1351     BX->cd(ins);
1352     BX->cd(ins)->SetLogy();
1353     for(int ic=1;ic<5;ic++){ // Loop in chambers
1354    
1355     stringstream hname; hname << "hTrigBX_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1356 battilan 1.2 hHH[ic-1]= getHisto<TH1F>(hname.str()+"_qual6");
1357     hHL[ic-1]= getHisto<TH1F>(hname.str()+"_qual5");
1358 battilan 1.1
1359     hHH[ic-1]->Add(hHL[ic-1]);
1360     hHH[ic-1]->SetLineColor(ic);
1361     hHH[ic-1]->SetStats(0);
1362     } // end loop in chambers
1363    
1364     first_to_paint = hHH[0];
1365     nbmax=hHH[0]->GetMaximum();
1366     first_to_paint->Draw();
1367    
1368     for(int ic=2;ic<5;ic++){
1369     nbmax0=hHH[ic-1]->GetMaximum();
1370     if(nbmax0>nbmax){
1371     nbmax=nbmax0;
1372     first_to_paint=hHH[ic-1];
1373     }
1374     }
1375    
1376     first_to_paint->GetXaxis()->SetLabelSize(0.08);
1377     first_to_paint->GetXaxis()->SetLabelOffset(-0.025);
1378     first_to_paint->GetXaxis()->SetTitle("Slot");
1379     first_to_paint->GetXaxis()->SetTitleSize(0.09);
1380     first_to_paint->GetXaxis()->SetTitleOffset(0.5);
1381     first_to_paint->GetXaxis()->SetNdivisions(308);
1382     stringstream htitle; htitle << "BX for HH,HL W" << (iw-2) << " S" << ins;
1383     first_to_paint->SetTitle(htitle.str().c_str());
1384    
1385     first_to_paint->Draw();
1386     for(int ic=1;ic<5;ic++)
1387     hHH[ic-1]->Draw("same");
1388    
1389     }// end Loop in sectors
1390    
1391     createGifFile("TrigBXhhhl",(iw-2),"",BX);
1392    
1393 battilan 1.3 delete DQM1;
1394     delete DQM2;
1395     delete DQM1b;
1396     delete DQM2b;
1397     delete Digi1;
1398     delete Digi2;
1399     delete Digi3;
1400     delete DQM6;
1401    
1402     delete DQM11;
1403     delete DQM12;
1404     delete DQM13;
1405     delete DQM14;
1406     delete Eff;
1407     delete BX;
1408 battilan 1.1
1409     }// END loop in wheels
1410    
1411     }
1412    
1413    
1414     void DTDPGCreateAnalyzerSummary::createSummaryAllPlots() {
1415 battilan 1.5
1416 battilan 1.1 string Whname[5]={"Wm2","Wm1","W0","W1","W2"};
1417    
1418     gStyle->SetTitleX(0.01);
1419     gStyle->SetTitleY(0.99);
1420    
1421     gStyle->SetOptStat(10);
1422     gStyle->SetStatY(0.97);
1423     gStyle->SetStatX(0.98);
1424     gStyle->SetStatW(0.35);
1425     gStyle->SetStatH(0.45);
1426 battilan 1.5
1427 battilan 1.1 gStyle->SetPalette(1); // set palette for 2D histos
1428     gStyle->SetTitleW(0.97);
1429     gStyle->SetTitleH(0.1);
1430 battilan 1.5
1431 battilan 1.1 float BXSummary_mean=0.;
1432     float NBXSummary_mean=0.;
1433     TH1F * BXSummary[5][4];
1434     for(int iw=0;iw<5;iw++){ // Loop in wheels
1435     for(int ic=1;ic<5;ic++){
1436 battilan 1.5
1437 battilan 1.1 stringstream hname, htitle;
1438     hname << "BX_mean_MB" << ic << "_W" << (iw-2);
1439     htitle << "BX MeanValue (HH,HL) MB" << ic << " W" << (iw-2);
1440     BXSummary[iw][ic-1]= new TH1F(hname.str().c_str(),htitle.str().c_str(),12,1.,13.);
1441     for(int is=1;is<13;is++){
1442     stringstream xlab; xlab << "S" << is;
1443     BXSummary[iw][ic-1]->GetXaxis()->SetBinLabel(is,xlab.str().c_str());
1444     }
1445     }
1446     }
1447    
1448 battilan 1.5
1449 battilan 1.1 // SC BX Summary
1450     for(int iw=0;iw<5;iw++){ // Loop in wheels
1451     for(int ins=1;ins<13;ins++){ // Loop in sectors
1452 battilan 1.5
1453 battilan 1.1 TH1F *hHH[4];
1454     TH1F *hHL[4];
1455     for(int ic=1;ic<5;ic++){ // Loop in chambers
1456 battilan 1.5
1457 battilan 1.1 stringstream hname; hname << "hTrigBX_" << Whname[iw] << "_S" << ins << "_MB" << ic;
1458 battilan 1.2 hHH[ic-1]= getHisto<TH1F>(hname.str()+"_qual6");
1459     hHL[ic-1]= getHisto<TH1F>(hname.str()+"_qual5");
1460 battilan 1.5
1461 battilan 1.1 hHH[ic-1]->Add(hHL[ic-1]);
1462     hHH[ic-1]->SetLineColor(ic);
1463     hHH[ic-1]->SetStats(0);
1464 battilan 1.5
1465 battilan 1.1 // Compute average for BX summary plot
1466     int nb=hHH[ic-1]->GetNbinsX();
1467     int nbMax=hHH[ic-1]->GetMaximumBin();
1468     float xmean=0;
1469     float xtot0=0;
1470     for(int inb=nbMax-2;inb<nbMax+3;inb++){ // Takes Central BX+-2
1471     if(inb>1 && inb<nb){ //To avoid problems if it is on the "border"
1472     float yval=hHH[ic-1]->GetBinContent(inb);
1473     float xval=hHH[ic-1]->GetBinCenter(inb);
1474     xmean+=xval*yval;
1475     xtot0+=yval;
1476     }
1477     }
1478     if(xtot0>0){
1479     xmean=xmean/xtot0 ;
1480     BXSummary[iw][ic-1]->Fill(ins,xmean);
1481     BXSummary_mean+=xmean;
1482     NBXSummary_mean++;
1483     }
1484     }
1485     }// end Loop in chambers
1486     }// END loop in wheels and sectors
1487    
1488     string titlename = "BX Average (HH,HL)";
1489     TCanvas *BXaverage = new TCanvas("BXAverage", "",201,81,999,699);
1490     BXaverage->SetTopMargin(0.42);
1491     BXaverage->SetBottomMargin(0.32);
1492     BXaverage->SetRightMargin(0.12);
1493     BXaverage->Divide(1,5,0.,0) ;
1494    
1495     TPaveLabel* title = new TPaveLabel(0.1,0.93,0.85,0.99,titlename.c_str());
1496     title->SetFillColor(0);
1497     title->SetTextColor(4);
1498     title->Draw();
1499 battilan 1.5 TPaveLabel* wheelName[5];
1500     memset(wheelName,0,5*sizeof(TPaveLabel*));
1501 battilan 1.1
1502     int BXSummary_min=0;
1503     int BXSummary_max=0;
1504     if(NBXSummary_mean>0)BXSummary_min=-6+int(BXSummary_mean/NBXSummary_mean);
1505     if(NBXSummary_mean>0)BXSummary_max=6+int(BXSummary_mean/NBXSummary_mean);
1506     for(int iw=0;iw<5;iw++){
1507     BXaverage->cd(iw+1);
1508     BXaverage->cd(iw+1)->SetGrid();
1509     for(int ic=1;ic<5;ic++){
1510     BXSummary[iw][ic-1]->SetMaximum(BXSummary_max);
1511     BXSummary[iw][ic-1]->SetMinimum(BXSummary_min);
1512     BXSummary[iw][ic-1]->SetStats(0);
1513     BXSummary[iw][ic-1]->SetTitle(0);
1514     BXSummary[iw][ic-1]->SetLineWidth(2);
1515     BXSummary[iw][ic-1]->GetXaxis()->SetLabelSize(0.25);
1516     BXSummary[iw][ic-1]->GetYaxis()->SetLabelSize(0.2);
1517     if(iw==4)BXSummary[iw][ic-1]->GetYaxis()->SetLabelSize(0.15);
1518     BXSummary[iw][ic-1]->GetYaxis()->SetNdivisions(502);
1519     BXSummary[iw][ic-1]->SetLineColor(ic);
1520     if(ic==1)BXSummary[iw][ic-1]->Draw();
1521     else BXSummary[iw][ic-1]->Draw("same");
1522     }
1523     stringstream ptitle; ptitle << "Wheel " << (iw-2);
1524 battilan 1.5 wheelName[iw] = new TPaveLabel(1.00,0.70,1.12,0.90,ptitle.str().c_str(),"NDC");
1525     wheelName[iw]->Draw();
1526 battilan 1.1 }
1527    
1528     createGifFile("TrigBXhhhl_average","",BXaverage);
1529     delete BXaverage;
1530 battilan 1.5 delete title;
1531     for (int i=0;i<5;++i) {
1532     if (wheelName[i]) {
1533     delete wheelName[i];
1534     }
1535     }
1536 battilan 1.1
1537     }
1538    
1539