ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DTDPGAnalysis/src/DTDPGCreateSummary.cc
Revision: 1.9
Committed: Thu Jul 4 17:16:16 2013 UTC (11 years, 10 months ago) by marycruz
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +33 -3 lines
Log Message:
Update last version of PromptOffline

File Contents

# User Rev Content
1 battilan 1.5 /*
2 battilan 1.1 * See header file for a description of this class.
3     *
4 pellicci 1.8 * $Date: 2011/07/13 08:47:00 $
5     * $Revision: 1.7 $
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/DTDPGCreateSummary.h>
15 cerminar 1.4 #include "UserCode/DTDPGAnalysis/src/DTROUtility.h"
16 battilan 1.1
17     // Framework
18     #include <FWCore/Utilities/interface/Exception.h>
19     #include <FWCore/Framework/interface/Event.h>
20     #include <FWCore/Framework/interface/EventSetup.h>
21    
22     // Geometry
23     #include "Geometry/Records/interface/MuonGeometryRecord.h"
24     #include "Geometry/DTGeometry/interface/DTGeometry.h"
25     #include "Geometry/DTGeometry/interface/DTLayer.h"
26     #include "Geometry/DTGeometry/interface/DTTopology.h"
27    
28     #include "FWCore/MessageLogger/interface/MessageLogger.h"
29    
30     #include <iostream>
31     #include <string>
32     #include <sstream>
33     #include <iomanip>
34     #include <math.h>
35    
36     #include "TH1F.h"
37     #include "TF1.h"
38     #include "TH2F.h"
39     #include "TCanvas.h"
40     #include "TGraph.h"
41     #include "TFile.h"
42     #include "TPostScript.h"
43     #include "TProfile.h"
44     #include "TStyle.h"
45     #include "TFolder.h"
46 battilan 1.5 #include "TText.h"
47 battilan 1.1 #include "boost/filesystem.hpp"
48    
49     using namespace edm;
50     using namespace std;
51     using namespace boost::filesystem;
52    
53     DTDPGCreateSummary::DTDPGCreateSummary(const edm::ParameterSet& ps) : myFile(0){
54    
55     LogVerbatim("DTDPGSummary") << "[DTDPGCreateSummary]: Constructor";
56    
57     myParameters = ps;
58     myRunNumber = ps.getUntrackedParameter<int>("runNumber",0);
59    
60     // TCanvas c1("c1","",600,780);
61     myCanvas = new TCanvas("c1", "",201,81,999,699);
62 battilan 1.5 myCanvas->SetFillColor(0);
63 battilan 1.1
64     gStyle->SetPalette(1);
65 battilan 1.5 gStyle->SetStatColor(0);
66 battilan 1.1 gStyle->SetStatX(0.99);
67     gStyle->SetStatW(0.29);
68     gStyle->SetStatY(0.98);
69     gStyle->SetStatH(0.30);
70     gStyle->SetTitleH(0.1);
71     gStyle->SetTitleW(0.97);
72    
73 battilan 1.5
74 marycruz 1.9 gStyle->SetTitleFillColor(10);
75 battilan 1.1 }
76    
77     DTDPGCreateSummary::~DTDPGCreateSummary(){
78    
79     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateSummary]: Destructor ";
80    
81     }
82    
83    
84 battilan 1.5 void DTDPGCreateSummary::beginJob(){
85 battilan 1.1
86     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateSummary]: BeginJob";
87 battilan 1.5 }
88    
89    
90     void DTDPGCreateSummary::beginRun(const edm::Run& run,const edm::EventSetup& context){
91    
92     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateSummary]: BeginRun";
93 battilan 1.1 context.get<MuonGeometryRecord>().get(myMuonGeom);
94    
95     }
96    
97     void DTDPGCreateSummary::analyze(const edm::Event& e, const edm::EventSetup& context){
98    
99     }
100    
101    
102     void DTDPGCreateSummary::endJob(){
103    
104     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateSummary]: endJob";
105    
106     myFile = new TFile(myParameters.getUntrackedParameter<string>("rootFileName", "DTEfficiencyTest.root").c_str(), "READ");
107    
108     char cMainFolder[30];sprintf(cMainFolder,"DQMData/Run %d", myRunNumber);
109     TFolder * mfolder=(TFolder*)myFile->Get(cMainFolder);
110     if(!mfolder) {
111     throw cms::Exception("DTDPGCreateSummaryError") << "[DTDPGCreateSummary]: Folder = " << cMainFolder << " does not exist!!! Check the run number" << endl;
112     }
113    
114     myMainFolder.append(cMainFolder);
115     myMainFolder.append("/DT/Run summary/");
116 cerminar 1.4
117     DTROUtility roUtil(myFile,myMainFolder);
118     map<int,std::vector<int> > mySectors = roUtil.getSectorMap();
119    
120 battilan 1.1
121     edm::LogVerbatim ("DTDPGSummary") << "[DTDPGCreateSummary]: Creating summaries!";
122 battilan 1.3
123     std::map<int,std::vector<int> >::const_iterator whIt = mySectors.begin();
124     std::map<int,std::vector<int> >::const_iterator whEnd = mySectors.end();
125     for(;whIt!=whEnd;++whIt) {
126     int wh = (*whIt).first;
127     std::vector<int>::const_iterator secIt = (*whIt).second.begin();
128     std::vector<int>::const_iterator secEnd = (*whIt).second.end();
129     for(;secIt!=secEnd;++secIt) {
130     int sec = (*secIt);
131 battilan 1.1 if (myParameters.getUntrackedParameter<bool>("DataIntegrityHistos", false)) { createDataIntegrityPlots(wh,sec); }
132     if (myParameters.getUntrackedParameter<bool>("DigiHistos", false)) { createDigiPlots(wh,sec); }
133     if (myParameters.getUntrackedParameter<bool>("RecoHistos", false)) { createRecoPlots(wh,sec); }
134     if (myParameters.getUntrackedParameter<bool>("ResoHistos", false)) { createResoPlots(wh,sec); }
135     if (myParameters.getUntrackedParameter<bool>("EfficiencyHistos", false)) { createEfficiencyPlots(wh,sec); }
136     if (myParameters.getUntrackedParameter<bool>("TestPulsesHistos", false)) { createTestPulsePlots(wh,sec); }
137     if (myParameters.getUntrackedParameter<bool>("TriggerHistos", false) && sec<=12) { createTriggerPlots(wh,sec); }
138     }
139     }
140    
141 battilan 1.2 delete myCanvas;
142    
143     if(myFile) {
144     myFile->Close();
145     delete myFile;
146     }
147    
148 battilan 1.1 }
149    
150     void DTDPGCreateSummary::createGifFile(string fileName, int wh, int sec) {
151    
152     stringstream gifBase, gifTag;
153     gifBase << "Run" << myRunNumber << "/Wheel" << showpos << wh << "/Sect" << noshowpos << setfill('0')<< setw(2) << sec;
154     try {
155     create_directories(gifBase.str());
156     } catch(const std::exception & ex) {
157     throw cms::Exception("DTDPGCreateSummaryError")<< "[DTDPGCreateSummary]: Excepiton " << ex.what() << " thrown creating " << gifBase.str() << " directory" << endl;
158     }
159    
160     gifTag << "_r" << myRunNumber << "_W" << wh << "_S" << sec;
161     string gifFile = gifBase.str() + "/" + fileName + gifTag.str() + ".gif";
162     myCanvas->Update();
163     myCanvas->Print(gifFile.c_str());
164    
165     }
166    
167    
168    
169     void DTDPGCreateSummary::createDataIntegrityPlots(int wh, int sec) {
170    
171 marycruz 1.9 gStyle->SetTitleBorderSize(2);
172    
173 battilan 1.1 myCanvas->Clear();
174     myCanvas->Divide(2,2);
175 battilan 1.5 stringstream dduID;
176 marycruz 1.7 //if(sec<7)dduID << wheelToDDU(wh); // For 10 DDUs
177     //else dduID << wheelToDDU(wh)+5; // For 10 DDUs
178     dduID << wheelToDDU(wh); // For 5 DDUs
179 battilan 1.1 stringstream ROSID; ROSID << sec; // fix ROS id for ROS Error histogram U.G. 28/8/07
180    
181     string histoName = myMainFolder + "00-DataIntegrity/FED" + dduID.str() + "/FED" + dduID.str() + "_TTSValues";
182     TH1F *histoTSSVal = (TH1F*) myFile -> Get(histoName.c_str());
183     myCanvas->cd(1);
184     if(histoTSSVal) {
185     histoTSSVal->SetStats( 0 ); // no statistics
186     histoTSSVal->GetXaxis()->SetBinLabel(1,"disc.");
187     histoTSSVal->GetXaxis()->SetBinLabel(2,"overfl");
188     histoTSSVal->GetXaxis()->SetBinLabel(3,"out sync");
189     histoTSSVal->GetXaxis()->SetBinLabel(4,"busy");
190     histoTSSVal->GetXaxis()->SetBinLabel(5,"ready");
191     histoTSSVal->GetXaxis()->SetBinLabel(6,"error");
192     histoTSSVal->GetXaxis()->SetBinLabel(7,"disc.");
193     //histo1->Draw("colz"); // draw with colour palette
194 battilan 1.5 histoTSSVal->GetYaxis()->SetLabelSize(0.04);
195     histoTSSVal->GetXaxis()->SetLabelSize(0.05);
196 battilan 1.1 histoTSSVal->Draw();
197     }
198    
199     histoName = myMainFolder + "00-DataIntegrity/FED" + dduID.str() + "/FED" + dduID.str() + "_ROSStatus";
200     TH1F *histoROSStatus = (TH1F*) myFile -> Get(histoName.c_str());
201     myCanvas->cd(2);
202     if(histoROSStatus) {
203     histoROSStatus->SetStats( 0 );
204 battilan 1.5
205     histoROSStatus->GetXaxis()->SetBinLabel(1,"#splitline{ch.}{enable}");
206     histoROSStatus->GetXaxis()->SetBinLabel(2,"#splitline{time}{out}");
207     histoROSStatus->GetXaxis()->SetBinLabel(3,"#splitline{trailer}{lost}");
208     histoROSStatus->GetXaxis()->SetBinLabel(4,"#splitline{fiber}{lost}");
209     histoROSStatus->GetXaxis()->SetBinLabel(5,"#splitline{prop.}{err.}");
210     histoROSStatus->GetXaxis()->SetBinLabel(6,"#splitline{patt.}{err.}");
211     histoROSStatus->GetXaxis()->SetBinLabel(7,"#splitline{sign.}{lost}");
212     histoROSStatus->GetXaxis()->SetBinLabel(8,"#splitline{ROS }{err.}");
213     histoROSStatus->GetXaxis()->SetBinLabel(9,"#splitline{ROS }{in ev.}");
214     histoROSStatus->GetXaxis()->SetBinLabel(10,"#splitline{Miss }{ev.}");
215     histoROSStatus->GetXaxis()->SetBinLabel(11,"#splitline{Ev ID}{Miss}");
216     histoROSStatus->GetXaxis()->SetBinLabel(12,"#splitline{BX}{Miss}");
217     histoROSStatus->LabelsOption("h","X");
218     histoROSStatus->GetYaxis()->SetLabelSize(0.05);
219     histoROSStatus->GetXaxis()->SetLabelSize(0.06);
220    
221 battilan 1.1 histoROSStatus->Draw("colz");
222     }
223    
224     histoName = myMainFolder + "00-DataIntegrity"+ "/FED" + dduID.str() + "_ROSSummary";
225     TH1F *histoROSSummary = (TH1F*) myFile -> Get(histoName.c_str());
226     myCanvas->cd(3);
227     if(histoROSSummary) {
228     histoROSSummary->SetStats( 0 );
229 battilan 1.5
230 battilan 1.1 histoROSSummary->GetXaxis()->SetBinLabel(1,"#splitline{Link}{TimeOut}");
231     histoROSSummary->GetXaxis()->SetBinLabel(2,"#splitline{Ev.Id.}{Mis.}");
232     histoROSSummary->GetXaxis()->SetBinLabel(3,"#splitline{FIFO}{#splitline{almost}{full}}");
233     histoROSSummary->GetXaxis()->SetBinLabel(4,"#splitline{FIFO}{full}");
234     histoROSSummary->GetXaxis()->SetBinLabel(5,"#splitline{Ceros}{Timeout}");
235     histoROSSummary->GetXaxis()->SetBinLabel(6,"#splitline{Max.}{wds}");
236     histoROSSummary->GetXaxis()->SetBinLabel(7,"#splitline{L1A}{FF}");
237 battilan 1.5 histoROSSummary->GetXaxis()->SetBinLabel(8,"#splitline{TDC}{#splitline{parity}{err.}}");
238    
239 battilan 1.1 histoROSSummary->GetXaxis()->SetBinLabel(9,"#splitline{BX ID}{Mis.}");
240     histoROSSummary->GetXaxis()->SetBinLabel(10,"TXP");
241 battilan 1.5
242     histoROSSummary->GetXaxis()->SetBinLabel(11,"#splitline{L1A}{#splitline{almost}{full}}");
243     histoROSSummary->GetXaxis()->SetBinLabel(12,"#splitline{Ch}{blocked}");
244     histoROSSummary->GetXaxis()->SetBinLabel(13,"#splitline{Ev.}{#splitline{Id.}{Mis.}}");
245    
246     histoROSSummary->GetXaxis()->SetBinLabel(14,"#splitline{CEROS}{blocked}");
247     histoROSSummary->GetXaxis()->SetBinLabel(15,"#splitline{TDC}{Fatal}");
248     histoROSSummary->GetXaxis()->SetBinLabel(16,"#splitline{TDC}{#splitline{FIFO}{Ov.}}");
249     histoROSSummary->GetXaxis()->SetBinLabel(17,"#splitline{L1}{#splitline{Buffer}{Ov.}}");
250     histoROSSummary->GetXaxis()->SetBinLabel(18,"#splitline{L1A}{#splitline{FIFO}{Ov.}}");
251     histoROSSummary->GetXaxis()->SetBinLabel(19,"#splitline{TDC}{#splitline{hit}{err.}}");
252     histoROSSummary->GetXaxis()->SetBinLabel(20,"#splitline{TDC}{#splitline{hit}{rej.}}");
253 battilan 1.1 histoROSSummary->LabelsOption("h","X");
254 battilan 1.5
255 battilan 1.1 histoROSSummary->Draw("colz");
256     }
257    
258     histoName = myMainFolder + "00-DataIntegrity/FED" + dduID.str() + "/ROS" + ROSID.str() + "/FED" + dduID.str() + "_ROS" + ROSID.str() + "_ROSError";
259     TH1F *histoROSError = (TH1F*) myFile -> Get(histoName.c_str());
260     myCanvas->cd(4);
261 battilan 1.5 myCanvas->cd(4)->SetBottomMargin(0.15);
262 battilan 1.1 if(histoROSError) {
263     histoROSError->SetStats( 0 );
264     histoROSError->GetXaxis()->SetBinLabel(1,"#splitline{Link}{TimeOut}");
265     histoROSError->GetXaxis()->SetBinLabel(2,"#splitline{Ev.Id.}{Mis.}");
266     histoROSError->GetXaxis()->SetBinLabel(3,"#splitline{FIFO}{#splitline{almost}{full}}");
267     histoROSError->GetXaxis()->SetBinLabel(4,"#splitline{FIFO}{full}");
268 battilan 1.5 histoROSError->GetXaxis()->SetBinLabel(5,"#splitline{CEROS}{timeout}");
269 battilan 1.1 histoROSError->GetXaxis()->SetBinLabel(6,"#splitline{Max.}{wds}");
270 battilan 1.5 histoROSError->GetXaxis()->SetBinLabel(7,"#splitline{TDC}{#splitline{parity}{err}}");
271     histoROSError->GetXaxis()->SetBinLabel(8,"#splitline{BX ID}{Mis.}");
272     histoROSError->GetXaxis()->SetBinLabel(9,"#splitline{Ch}{blocked}");
273     histoROSError->GetXaxis()->SetBinLabel(10,"#splitline{Ev ID}{Mis.}");
274     histoROSError->GetXaxis()->SetBinLabel(11,"#splitline{CEROS}{blocked}");
275     histoROSError->GetXaxis()->SetBinLabel(12,"#splitline{TDC}{Fatal}");
276     histoROSError->GetXaxis()->SetBinLabel(13,"#splitline{TDC}{#splitline{FIFO}{Ov.}}");
277     histoROSError->GetXaxis()->SetBinLabel(14,"#splitline{L1}{#splitline{Buffer}{Ov.}}");
278     histoROSError->GetXaxis()->SetBinLabel(15,"#splitline{TDCL1A}{#splitline{FIFO}{Ov.}}");
279     histoROSError->GetXaxis()->SetBinLabel(16,"#splitline{TDC}{#splitline{hit}{err.}}");
280     histoROSError->GetXaxis()->SetBinLabel(17,"#splitline{TDC}{#splitline{hit}{rej.}}");
281 battilan 1.1 histoROSError->LabelsOption("h","X");
282     histoROSError->Draw("colz");
283     }
284     createGifFile("DataIntegrity",wh,sec);
285    
286     // Event Length
287 battilan 1.5 gStyle->SetStatW(0.29);
288     gStyle->SetOptTitle(0);
289 battilan 1.1 if(sec !=14 && sec !=13){
290     myCanvas->Clear();
291     myCanvas->Divide(2,2);
292    
293     histoName = myMainFolder + "00-DataIntegrity/FED" + dduID.str() + "/FED" + dduID.str() + "_EventLenght";
294     TH1F *histoEL = (TH1F*) myFile -> Get(histoName.c_str());
295     if(histoEL) {
296     myCanvas->cd(1);
297     gStyle->SetOptStat(111111);
298     histoEL->Draw();
299     myCanvas->cd(2)->SetLogy(1);
300     histoEL->Draw();
301     }
302    
303     histoName = myMainFolder + "00-DataIntegrity/FED" + dduID.str() + "/ROS" + ROSID.str() + "/FED" + dduID.str() + "_ROS" + ROSID.str() + "_ROSEventLenght";
304     TH1F *histoROSEL = (TH1F*) myFile -> Get(histoName.c_str());
305     if(histoROSEL) {
306     myCanvas->cd(3);
307     histoROSEL->Draw();
308     myCanvas->cd(4)->SetLogy(1);
309     histoROSEL->Draw();
310     }
311    
312     createGifFile("EventLength",wh,sec);
313    
314     }
315    
316     }
317    
318    
319     void DTDPGCreateSummary::createDigiPlots(int wh, int sec) {
320 marycruz 1.9 gStyle->SetStatX(0.99);
321     gStyle->SetStatW(0.29);
322     //gStyle->SetStatY(0.98);
323     gStyle->SetStatY(0.89);
324     gStyle->SetStatH(0.30);
325     gStyle->SetTitleH(0.1);
326     gStyle->SetTitleW(0.97);
327     gStyle->SetTitleBorderSize(2);
328    
329 battilan 1.1
330 battilan 1.5
331     gStyle->SetOptTitle();
332 battilan 1.1 gStyle->SetOptStat();
333     myCanvas->Clear();
334     myCanvas->Divide(3,4);
335     stringstream wheel; wheel << wh;
336     stringstream sector; sector << sec;
337     string digiFolder = myMainFolder + "01-Digi/Wheel" + wheel.str();
338    
339     // TimeBox Histos
340     vector<DTChamber*>::const_iterator chDigiIt = myMuonGeom->chambers().begin();
341     vector<DTChamber*>::const_iterator chDigiEnd = myMuonGeom->chambers().end();
342    
343     for (; chDigiIt != chDigiEnd; ++chDigiIt) {
344     DTChamberId ch = (*chDigiIt)->id();
345     if (ch.sector() == sec && ch.wheel()==wh) {
346     stringstream station; station << ch.station();
347    
348     vector<const DTSuperLayer*>::const_iterator slIt = (*chDigiIt)->superLayers().begin();
349     vector<const DTSuperLayer*>::const_iterator slEnd = (*chDigiIt)->superLayers().end();
350    
351     for(; slIt != slEnd; ++slIt) {
352     DTSuperLayerId sl = (*slIt)->id();
353     vector<const DTLayer*>::const_iterator lIt = (*slIt)->layers().begin();
354     vector<const DTLayer*>::const_iterator lEnd = (*slIt)->layers().end();
355     stringstream superLayer; superLayer << sl.superlayer();
356    
357 battilan 1.5 string histoName = digiFolder + "/Sector" + sector.str() + "/Station" + station.str() +"/TimeBox_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str()+ "_SL" + superLayer.str();
358 battilan 1.1 TH1F *histoTimeBox = (TH1F*) myFile->Get(histoName.c_str());
359 battilan 1.5
360 battilan 1.1 if(histoTimeBox){
361     int pad = (ch.station() - 1)*3 + sl.superlayer();
362     myCanvas->cd(pad);
363     gStyle->SetStatW(0.19);
364     gStyle->SetOptStat(10);
365     histoTimeBox->GetXaxis()->SetLabelSize(0.08);
366     histoTimeBox->Draw();
367     }
368     }
369     }
370     }
371    
372     createGifFile("Timeboxes_filtered",wh,sec);
373    
374     // Occupancy in Time Histos
375     gStyle->SetOptStat();
376     gStyle->SetStatW(0.29);
377     myCanvas->Clear();
378     myCanvas->Divide(3,4);
379 battilan 1.3 TH1F *layerOccupancy[3][4];
380     memset(layerOccupancy,0,12*sizeof(TH1F*));
381 battilan 1.1
382     chDigiIt = myMuonGeom->chambers().begin();
383     chDigiEnd = myMuonGeom->chambers().end();
384     for (; chDigiIt != chDigiEnd; ++chDigiIt) {
385     DTChamberId ch = (*chDigiIt)->id();
386     if (ch.sector() == sec && ch.wheel() == wh ) {
387     stringstream station; station << ch.station();
388 marycruz 1.9 //bool found = false; // Not being used and in 62X gives erors for being set but not used
389 battilan 1.5
390     string histoNameOccupancy = digiFolder + "/Sector" + sector.str() + "/Station" + station.str() + "/OccupancyInTimeHits_perCh_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
391 battilan 1.1 TH2F *histoOccupancy = (TH2F*) myFile -> Get(histoNameOccupancy.c_str());
392     if(histoOccupancy){
393 marycruz 1.9 //found = true; // Not being used and in 62X gives erors for being set but not used
394 battilan 1.1
395     vector<const DTSuperLayer*>::const_iterator slIt = (*chDigiIt)->superLayers().begin();
396     vector<const DTSuperLayer*>::const_iterator slEnd = (*chDigiIt)->superLayers().end();
397    
398     for(; slIt != slEnd; ++slIt) {
399     DTSuperLayerId sl = (*slIt)->id();
400     vector<const DTLayer*>::const_iterator lIt = (*slIt)->layers().begin();
401     vector<const DTLayer*>::const_iterator lEnd = (*slIt)->layers().end();
402     stringstream superLayer; superLayer << sl.superlayer();
403    
404     for(; lIt != lEnd; ++lIt) {
405     DTLayerId layerId = (*lIt)->id();
406    
407     // Create the new 1D histos
408     stringstream layer; layer << layerId.layer();
409     string histoTitleLayer= "In time occupancy: Station " + station.str() + "/SL" + superLayer.str();
410     string histoNameLayer = "Occupancy_MB" + station.str() + "SL" + superLayer.str() + "L" + layer.str();
411     layerOccupancy[sl.superlayer()-1][layerId.layer()-1]= new TH1F(histoNameLayer.c_str(),histoTitleLayer.c_str(),100, 0.,100.);
412    
413     // Fill the 1D Histos
414 battilan 1.5 int iby=(sl.superlayer()-1)*4+layerId.layer();
415 battilan 1.1 int nbx= histoOccupancy->GetNbinsX() ;
416     float totentr=0;
417     for(int ibx=1;ibx<nbx;ibx++) {
418     float yval=histoOccupancy->GetBinContent(ibx,iby);
419     layerOccupancy[sl.superlayer()-1][layerId.layer()-1]->SetBinContent(ibx,yval);
420     totentr+=yval;
421     }
422     layerOccupancy[sl.superlayer()-1][layerId.layer()-1]->SetEntries(totentr);
423    
424     //Draw the histos
425     int Nstation = ch.station();
426     if (Nstation > 10) Nstation = 4;
427     int pad = (Nstation-1)*3 + sl.superlayer() ;
428     myCanvas->cd(pad);
429     layerOccupancy[sl.superlayer()-1][layerId.layer()-1]->SetMinimum(0.);
430     layerOccupancy[sl.superlayer()-1][layerId.layer()-1]->SetStats(0);
431     layerOccupancy[sl.superlayer()-1][layerId.layer()-1]->GetXaxis()->SetLabelSize(0.08);
432     layerOccupancy[sl.superlayer()-1][layerId.layer()-1]->GetYaxis()->SetLabelSize(0.06);
433     layerOccupancy[sl.superlayer()-1][layerId.layer()-1]->SetLineColor( layerId.layer() );
434     if( layerId.layer() == 1 ) layerOccupancy[sl.superlayer()-1][layerId.layer()-1]->Draw();
435     else layerOccupancy[sl.superlayer()-1][layerId.layer()-1]->Draw("same");
436     }
437     }
438     }
439     }
440     }
441    
442     createGifFile("Occupancies",wh,sec);
443 battilan 1.3
444     for (int i=0;i<3;++i) {
445     for (int j=0;j<4;++j) {
446     if (layerOccupancy[i][j]) {
447     delete layerOccupancy[i][j];
448     }
449     }
450     }
451 battilan 1.1
452     }
453    
454    
455     void DTDPGCreateSummary::createTriggerPlots(int wh, int sec) {
456    
457     stringstream wheel; wheel << wh;
458     stringstream sector; sector << sec;
459    
460     std::vector<std::string> trigHwSources;
461     trigHwSources.push_back("DCC");
462     trigHwSources.push_back("DDU");
463    
464     vector<string>::const_iterator hwSrcIt = trigHwSources.begin();
465     vector<string>::const_iterator hwSrcEnd = trigHwSources.end();
466    
467     for (; hwSrcIt != hwSrcEnd; ++hwSrcIt) {
468     // Trigger quality (Phi & Theta)
469     myCanvas->Clear();
470     myCanvas->Divide(2,4);
471    
472     vector<DTChamber*>::const_iterator chTriggerIt = myMuonGeom->chambers().begin();
473     vector<DTChamber*>::const_iterator chTriggerEnd = myMuonGeom->chambers().end();
474     string triggerFolder;
475     if ((*hwSrcIt)=="DCC") {
476 battilan 1.5 triggerFolder = myMainFolder + "03-LocalTrigger-DCC/Wheel" + wheel.str();
477 battilan 1.1 }
478     else {
479 battilan 1.5 triggerFolder = myMainFolder + "04-LocalTrigger-DDU/Wheel" + wheel.str();
480 battilan 1.1 }
481    
482     for (; chTriggerIt != chTriggerEnd; ++chTriggerIt) {
483     DTChamberId ch = (*chTriggerIt)->id();
484     if (ch.sector() == sec && ch.wheel() == wh ) {
485     stringstream station; station << ch.station();
486     string histoNameBXQual = triggerFolder + "/Sector" + sector.str() + "/Station" + station.str() + "/LocalTriggerPhi/" + (*hwSrcIt) + "_BXvsQual_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
487     TH1F *histoBXQual = (TH1F*) myFile -> Get(histoNameBXQual.c_str());
488     if(histoBXQual){
489     myCanvas->cd( 2*ch.station() - 1 );
490     histoBXQual->GetXaxis()->SetTitle("Quality Flag, Phi trigger");
491     histoBXQual->GetYaxis()->SetTitle("BX id .");
492     histoBXQual->GetYaxis()->SetTitleSize(0.1);
493     histoBXQual->GetYaxis()->SetTitleOffset(0.4);
494     histoBXQual->GetYaxis()->SetRangeUser(-9.0,50.1);
495     histoBXQual->GetXaxis()->SetTitleSize(0.07);
496     histoBXQual->SetStats( 0 );
497 battilan 1.5 histoBXQual->SetFillColor( 0 );
498 battilan 1.1 histoBXQual->GetXaxis()->SetLabelSize(0.08);
499     histoBXQual->GetYaxis()->SetLabelSize(0.08);
500     histoBXQual->Draw("colz");
501     }
502     histoNameBXQual = triggerFolder + "/Sector" + sector.str() + "/Station" + station.str() + "/LocalTriggerTheta/" + (*hwSrcIt)+ "_ThetaBXvsQual_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
503     TH1F *histoBXQualTh = (TH1F*) myFile -> Get(histoNameBXQual.c_str());
504     if(histoBXQualTh){
505     myCanvas->cd( 2*(ch.station()-1) + 2 );
506     histoBXQualTh->GetXaxis()->SetTitle("Quality Flag, Theta trigger");
507     histoBXQualTh->GetYaxis()->SetTitle("BX id .");
508     histoBXQualTh->GetYaxis()->SetTitleSize(0.1);
509     histoBXQualTh->GetYaxis()->SetTitleOffset(0.4);
510     histoBXQualTh->GetXaxis()->SetTitleSize(0.07);
511     histoBXQualTh->SetStats( 0 );
512 battilan 1.5 histoBXQualTh->SetFillColor( 0 );
513 battilan 1.1 histoBXQualTh->GetXaxis()->SetLabelSize(0.08);
514     histoBXQualTh->GetYaxis()->SetLabelSize(0.08);
515     histoBXQualTh->Draw("colz");
516     }
517     }
518     }
519    
520     createGifFile("TriggQuality"+(*hwSrcIt),wh,sec);
521    
522    
523 battilan 1.5 // Trig efficiency 2d plots
524 battilan 1.1 myCanvas->Clear();
525 battilan 1.5 myCanvas->Divide(3,4);
526     string histo2DTag[3] = {"TrigEffPosvsAnglePhi","TrigEffPosvsAngleHHHLPhi","TrackPosvsAngle"};
527 battilan 1.1
528     chTriggerIt = myMuonGeom->chambers().begin();
529     chTriggerEnd = myMuonGeom->chambers().end();
530     for (; chTriggerIt != chTriggerEnd; ++chTriggerIt) {
531     DTChamberId ch = (*chTriggerIt)->id();
532    
533     if (ch.sector() == sec && ch.wheel() == wh ) {
534     stringstream station; station << ch.station();
535    
536 battilan 1.5 for (int i=0;i<3;++i){
537 battilan 1.1 string histoName2DEff = triggerFolder + "/Sector" + sector.str() + "/Station" + station.str() + "/Segment/"+ (*hwSrcIt) + "_" + histo2DTag[i] + "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
538     TH2F *histo2DEff = (TH2F*) myFile -> Get(histoName2DEff.c_str());
539     if(histo2DEff){
540 battilan 1.5 myCanvas->cd((ch.station()*3)-2+i);
541     histo2DEff->SetFillColor( 0 );
542     //histo2DEff->SetStats( 0 );
543     bool printStats = i==2;
544     histo2DEff->SetStats( printStats );
545 battilan 1.1 histo2DEff->GetXaxis()->SetTitle("angle [deg]");
546     histo2DEff->GetYaxis()->SetTitle("position [cm] .");
547     histo2DEff->GetYaxis()->SetTitleSize(0.08);
548     histo2DEff->GetYaxis()->SetTitleOffset(0.6);
549     histo2DEff->GetYaxis()->SetLabelSize(0.08);
550     histo2DEff->GetXaxis()->SetTitleSize(0.075);
551     histo2DEff->GetXaxis()->SetLabelSize(0.075);
552     histo2DEff->GetXaxis()->SetTitleOffset(0.75);
553     histo2DEff->SetMinimum(0.);
554     histo2DEff->SetMaximum(1.);
555 battilan 1.5 //const char* option = i ? "box" : "colz";
556     const char* option = i==2 ? "box" : "colz";
557 battilan 1.1 histo2DEff->Draw(option);
558     }
559     }
560     }
561     }
562    
563     createGifFile("TriggEfficiencyPosvsAngle"+(*hwSrcIt),wh,sec);
564     }
565    
566     // DCC Only Plots
567 battilan 1.5 string triggerFolder = myMainFolder + "03-LocalTrigger-DCC/Wheel" + wheel.str();
568 battilan 1.1
569     // Trigger LUTs
570     myCanvas->Clear();
571 battilan 1.5 if (sec==4 || sec==10) {
572     myCanvas->Divide(2,5);
573     } else {
574     myCanvas->Divide(2,4);
575     }
576 battilan 1.1 vector<DTChamber*>::const_iterator chTriggerIt = myMuonGeom->chambers().begin();
577     vector<DTChamber*>::const_iterator chTriggerEnd = myMuonGeom->chambers().end();
578     for (; chTriggerIt != chTriggerEnd; ++chTriggerIt) {
579     DTChamberId ch = (*chTriggerIt)->id();
580 battilan 1.5 int scsec = ch.sector()>12 ? (ch.sector()==13 ? 4 : 10) : ch.sector();
581     if ( (scsec == sec && ch.wheel() == wh)) {
582     int istat = ch.sector()>12 ? 5 : ch.station();
583 battilan 1.1 stringstream station; station << ch.station();
584 battilan 1.5 stringstream chsector; chsector << ch.sector();
585     string histoNameLut = triggerFolder + "/Sector" + chsector.str() + "/Station" + station.str() + "/Segment/DCC_PhitkvsPhitrig_W" + wheel.str() + "_Sec" + chsector.str() + "_St" + station.str();
586 battilan 1.1 TH2F *histoLut = (TH2F*) myFile -> Get(histoNameLut.c_str());
587     if(histoLut){
588 battilan 1.5 myCanvas->cd( 2*istat - 1 );
589     histoLut->SetFillColor(0);
590 battilan 1.1 histoLut->GetXaxis()->SetTitle("Trigger local position [cm]");
591     histoLut->GetYaxis()->SetTitle("Segment local position [cm]");
592     histoLut->SetStats( 0 );
593     histoLut->GetXaxis()->SetLabelSize(0.08);
594     histoLut->GetYaxis()->SetLabelSize(0.08);
595     histoLut->Draw("box");
596     }
597    
598 battilan 1.5 histoNameLut = triggerFolder + "/Sector" + chsector.str() + "/Station" + station.str() + "/Segment/DCC_PhibtkvsPhibtrig_W" + wheel.str() + "_Sec" + chsector.str() + "_St" + station.str();
599 battilan 1.1 histoLut = (TH2F*) myFile -> Get(histoNameLut.c_str());
600 battilan 1.5 if(histoLut && istat!=3){
601     myCanvas->cd( 2*istat );
602     histoLut->SetFillColor(0);
603     histoLut->GetXaxis()->SetTitle("Trigger local direction [deg]");
604     histoLut->GetYaxis()->SetTitle("Segment local direction [deg]");
605 battilan 1.1 histoLut->SetStats( 0 );
606     histoLut->GetXaxis()->SetLabelSize(0.08);
607     histoLut->GetYaxis()->SetLabelSize(0.08);
608     histoLut->Draw("box");
609     }
610     }
611     }
612    
613     createGifFile("TriggLUTsDCC",wh,sec);
614    
615 battilan 1.5 // Trigger LUTs Residuals
616     myCanvas->Clear();
617     if (sec==4 || sec==10) {
618     myCanvas->Divide(2,5);
619     } else {
620     myCanvas->Divide(2,4);
621     }
622    
623     gStyle->SetOptFit(1);
624    
625     chTriggerIt = myMuonGeom->chambers().begin();
626     gStyle->SetStatW(0.15);
627     chTriggerEnd = myMuonGeom->chambers().end();
628     for (; chTriggerIt != chTriggerEnd; ++chTriggerIt) {
629     DTChamberId ch = (*chTriggerIt)->id();
630     int scsec = ch.sector()>12 ? (ch.sector()==13 ? 4 : 10) : ch.sector();
631     if (scsec == sec && ch.wheel() == wh ) {
632     int istat = ch.sector()>12 ? 5 : ch.station();
633     stringstream station; station << ch.station();
634     stringstream chsector; chsector << ch.sector();
635     string histoNameLutRes = triggerFolder + "/Sector" + chsector.str() + "/Station" + station.str() + "/Segment/DCC_PhiResidual_W" + wheel.str() + "_Sec" + chsector.str() + "_St" + station.str();
636     TH1F *histoLutRes = (TH1F*) myFile -> Get(histoNameLutRes.c_str());
637     if(histoLutRes){
638     myCanvas->cd( 2*istat - 1 );
639     gStyle->SetOptStat(1111);
640     histoLutRes->SetFillColor(0);
641     histoLutRes->GetXaxis()->SetTitle("Trigger - Segment local position [cm]");
642     histoLutRes->GetXaxis()->SetLabelSize(0.08);
643     histoLutRes->GetYaxis()->SetLabelSize(0.08);
644     histoLutRes->Draw();
645     }
646    
647     histoNameLutRes = triggerFolder + "/Sector" + chsector.str() + "/Station" + station.str() + "/Segment/DCC_PhibResidual_W" + wheel.str() + "_Sec" + chsector.str() + "_St" + station.str();
648     histoLutRes = (TH1F*) myFile->Get(histoNameLutRes.c_str());
649     if(histoLutRes && istat!=3){
650     myCanvas->cd( 2*istat );
651     histoLutRes->SetFillColor(0);
652     histoLutRes->GetXaxis()->SetTitle("Trigger - Segment local direction [deg]");
653     histoLutRes->GetXaxis()->SetLabelSize(0.08);
654     histoLutRes->GetYaxis()->SetLabelSize(0.08);
655     histoLutRes->Draw();
656     }
657     }
658     }
659    
660     createGifFile("TriggLUTsResidualDCC",wh,sec);
661     gStyle->SetOptFit(0);
662    
663    
664 battilan 1.1 // Quality vs Hits
665     myCanvas->Clear();
666     myCanvas->Divide(2,2);
667    
668     chTriggerIt = myMuonGeom->chambers().begin();
669     chTriggerEnd = myMuonGeom->chambers().end();
670     for (; chTriggerIt != chTriggerEnd; ++chTriggerIt) {
671     DTChamberId ch = (*chTriggerIt)->id();
672     if (ch.sector() == sec && ch.wheel() == wh ) {
673     stringstream wheel; wheel << ch.wheel();
674     stringstream station; station << ch.station();
675     stringstream sector; sector << ch.sector();
676    
677     string histoNameHits = triggerFolder + "/Sector" + sector.str() + "/Station" + station.str() + "/Segment/DCC_HitstkvsQualtrig_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
678     TH2F *histoHits = (TH2F*) myFile -> Get(histoNameHits.c_str());
679     if(histoHits){
680     myCanvas->cd( ch.station() );
681 battilan 1.5 histoHits->GetXaxis()->SetTitle("Phi trigger quality");
682 battilan 1.1 histoHits->GetYaxis()->SetTitle("Hits associated to phi segment");
683 battilan 1.5 histoHits->SetFillColor( 0 );
684     histoHits->SetStats(0);
685 battilan 1.1 histoHits->Draw("box");
686     }
687     }
688     }
689    
690     createGifFile("TriggQualvsHitsDCC",wh,sec);
691    
692     }
693    
694    
695     void DTDPGCreateSummary::createRecoPlots(int wh, int sec) {
696 marycruz 1.9 gStyle->SetStatX(0.99);
697     gStyle->SetStatW(0.29);
698     //gStyle->SetStatY(0.98);
699     gStyle->SetStatY(0.89);
700     gStyle->SetStatH(0.30);
701     gStyle->SetTitleH(0.1);
702     gStyle->SetTitleW(0.97);
703     gStyle->SetTitleBorderSize(2);
704 battilan 1.1
705     myCanvas->Clear();
706 battilan 1.5 myCanvas->Divide(2,2);
707 battilan 1.1 stringstream wheel; wheel << wh;
708     stringstream sector; sector << sec;
709     string recoFolder = myMainFolder + "02-Segments/Wheel" + wheel.str();
710    
711     vector<DTChamber*>::const_iterator chRecoIt = myMuonGeom->chambers().begin();
712     vector<DTChamber*>::const_iterator chRecoEnd = myMuonGeom->chambers().end();
713    
714     for (; chRecoIt != chRecoEnd; ++chRecoIt) {
715     DTChamberId ch = (*chRecoIt)->id();
716     if (ch.sector() == sec && ch.wheel() == wh ) {
717     stringstream station; station << ch.station();
718     string histoName4DSeg;
719     if(ch.station() < 4)
720 battilan 1.5 histoName4DSeg = recoFolder + "/Sector" + sector.str() + "/Station" + station.str() + "/h4DSegmXvsYInCham_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
721 battilan 1.1 if(ch.station() == 4)
722 battilan 1.5 histoName4DSeg = recoFolder + "/Sector" + sector.str() + "/Station" + station.str() + "/h4DSegmXInCham_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
723 battilan 1.6 //TProfile *histo4DSeg = (TProfile*) myFile -> Get(histoName4DSeg.c_str()); // CB fix here it is not a profile
724 battilan 1.5 histoName4DSeg = recoFolder + "/Sector" + sector.str() + "/Station" + station.str() + "/h4DSegmNHits_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
725 battilan 1.1 TH1F *histo4DSegNHits = (TH1F*) myFile -> Get(histoName4DSeg.c_str());
726     if(histo4DSegNHits){
727 battilan 1.5 int pad = ch.station();
728 battilan 1.1 myCanvas->cd(pad);
729     histo4DSegNHits->GetXaxis()->SetLabelSize(0.08);
730     histo4DSegNHits->GetYaxis()->SetLabelSize(0.07);
731     histo4DSegNHits->Draw();
732 battilan 1.5
733     TText L1;
734     L1.SetTextSize(0.1);
735     L1.SetTextColor(4);
736     char MBstation[10];
737     sprintf(MBstation,"MB%d", ch.station());
738     L1.DrawText(14.0,0.02,MBstation);
739    
740    
741 battilan 1.1 }
742     }
743     }
744    
745     createGifFile("RecoSegments",wh,sec);
746    
747     }
748    
749    
750    
751    
752     void DTDPGCreateSummary::createResoPlots(int wh, int sec) {
753    
754 marycruz 1.9 gStyle->SetStatX(0.99);
755     gStyle->SetStatW(0.29);
756     //gStyle->SetStatY(0.98);
757     gStyle->SetStatY(0.89);
758     gStyle->SetStatH(0.30);
759     gStyle->SetTitleH(0.1);
760     gStyle->SetTitleW(0.97);
761     gStyle->SetTitleBorderSize(2);
762    
763 battilan 1.1 myCanvas->Clear();
764     myCanvas->Divide(3,4);
765     stringstream wheel; wheel << wh;
766     stringstream sector; sector << sec;
767     string resoFolder = myMainFolder + "02-Segments/Wheel" + wheel.str();
768     vector<DTChamber*>::const_iterator chResoIt = myMuonGeom->chambers().begin();
769     vector<DTChamber*>::const_iterator chResoEnd = myMuonGeom->chambers().end();
770    
771     for (; chResoIt != chResoEnd; ++chResoIt) {
772     DTChamberId ch = (*chResoIt)->id();
773     if (ch.sector() == sec && ch.wheel() == wh ) {
774     stringstream station; station << ch.station();
775     vector<const DTSuperLayer*>::const_iterator slIt = (*chResoIt)->superLayers().begin();
776     vector<const DTSuperLayer*>::const_iterator slEnd = (*chResoIt)->superLayers().end();
777    
778     for(; slIt != slEnd; ++slIt) {
779     DTSuperLayerId sl = (*slIt)->id();
780     stringstream superLayer; superLayer << sl.superlayer();
781    
782 battilan 1.5 string histoNameResDist = resoFolder + "/Sector" + sector.str() + "/Station" + station.str() + "/hResDist_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() + "_SL" + superLayer.str();
783 battilan 1.1 TH1F *histoResDist = (TH1F*) myFile -> Get(histoNameResDist.c_str());
784     if(histoResDist){
785     int pad = (ch.station() - 1)*3 + sl.superlayer();
786     myCanvas->cd(pad);
787     histoResDist->GetXaxis()->SetTitle(" Hit residuals (cm) ");
788     // histo->FitPanel(1);
789     // histo->Fit("f1","R");
790     // g1 = new TF1("g1","gaus",-0.15,0.15);
791     // histo->Fit("gaus");
792     histoResDist->GetXaxis()->SetLabelSize(0.08);
793     histoResDist->GetYaxis()->SetLabelSize(0.07);
794     histoResDist->Draw();
795     }
796     }
797     }
798     }
799    
800     createGifFile("HitResiduals",wh,sec);
801    
802     }
803    
804    
805     void DTDPGCreateSummary::createEfficiencyPlots(int wh, int sec) {
806    
807     stringstream wheel; wheel << wh;
808     stringstream sector; sector << sec;
809    
810 battilan 1.5 string efficiencyFolder = myMainFolder + "DTEfficiencyTask/Wheel" + wheel.str() ;
811 battilan 1.1 vector<DTChamber*>::const_iterator chEffIt = myMuonGeom->chambers().begin();
812     vector<DTChamber*>::const_iterator chEffEnd = myMuonGeom->chambers().end();
813    
814 marycruz 1.9 gStyle->SetTitleBorderSize(2);
815    
816 battilan 1.1 for (; chEffIt != chEffEnd; ++chEffIt) {
817     myCanvas->Clear();
818     myCanvas->Divide(4,3);
819     DTChamberId ch = (*chEffIt)->id();
820     if (ch.sector() == sec && ch.wheel() == wh ) {
821     stringstream station; station << ch.station();
822     bool found = false;
823    
824     vector<const DTSuperLayer*>::const_iterator slIt = (*chEffIt)->superLayers().begin();
825     vector<const DTSuperLayer*>::const_iterator slEnd = (*chEffIt)->superLayers().end();
826    
827     for(; slIt != slEnd; ++slIt) {
828     DTSuperLayerId sl = (*slIt)->id();
829     if( !(ch.station() == 4 && sl.superlayer() ==2)) {
830     vector<const DTLayer*>::const_iterator lIt = (*slIt)->layers().begin();
831     vector<const DTLayer*>::const_iterator lEnd = (*slIt)->layers().end();
832     stringstream superLayer; superLayer << sl.superlayer();
833     for(; lIt != lEnd; ++lIt) {
834     DTLayerId layerId = (*lIt)->id();
835     stringstream layer; layer << layerId.layer();
836    
837 battilan 1.5 string histoName1 = efficiencyFolder + "/Station" + station.str() + "/Sector" + sector.str()
838     + "/SuperLayer" + superLayer.str() + "/hRecSegmOccupancy_W" + wheel.str() + "_St" + station.str()
839     + "_Sec" + sector.str() + "_SL" + superLayer.str()+ "_L" + layer.str();
840     string histoName2 = efficiencyFolder + "/Station" + station.str() + "/Sector" + sector.str()
841     + "/SuperLayer" + superLayer.str() + "/hEffUnassOccupancy_W" + wheel.str() + "_St" + station.str()
842     + "_Sec" + sector.str() + "_SL" + superLayer.str()+ "_L" + layer.str();
843     TH1F *histoAll = (TH1F*) myFile -> Get(histoName1.c_str());
844     TH1F *histoEff = NULL ;
845     if(myFile -> Get(histoName2.c_str()))
846     histoEff = (TH1F*) myFile -> Get(histoName2.c_str())->Clone("histoEff");
847    
848    
849 battilan 1.1 if(histoEff){
850     found = true;
851 battilan 1.5
852     int nb1=histoAll->GetNbinsX();
853     int nb2=histoEff->GetNbinsX();
854     if(nb1 != nb2){ throw cms::Exception("DTDPGCreateSummaryError") << "[DTDPGCreateSummary]: ERROR : mistmach on number of bins" << endl;}
855     for(int ibin=1;ibin<nb1;ibin++)
856     {
857     float xpos1=histoEff->GetBinContent(ibin);
858     float xpos2=histoAll->GetBinContent(ibin);
859     if(xpos2>0)histoEff->SetBinContent(ibin,xpos1/xpos2);
860     else histoEff->SetBinContent(ibin,0.);
861     }
862    
863 battilan 1.1 int pad = (sl.superlayer() - 1)*4 + layerId.layer();
864     myCanvas->cd(pad);
865     histoEff->SetMinimum(0.);
866     histoEff->SetMaximum(1.1);
867     histoEff->GetXaxis()->SetLabelSize(0.07);
868     histoEff->GetYaxis()->SetLabelSize(0.07);
869     histoEff->SetStats(0);
870     histoEff->Draw();
871     // Look for DeadCells > Eff<2% to avoid some noise entries
872     TH1F *histoDead=(TH1F*)histoEff->Clone();
873    
874     string histoName = myMainFolder + "DTEfficiencyTask/Wheel" + wheel.str() + "/Station" + station.str()
875     + "/Sector" + sector.str() + "/SuperLayer" + superLayer.str()
876     + "/hRecSegmOccupancy_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() + "_SL" + superLayer.str() + "_L"
877     + layer.str();
878     // To check that there are tracks passing for cells and avoid not existing cells
879     TH1F *histoCheck = (TH1F*) myFile -> Get(histoName.c_str());
880     int nb=histoEff->GetNbinsX();
881     for(int ib=1;ib<nb+1;ib++)
882     {
883     if(histoEff->GetBinContent(ib)<0.02 && histoCheck->GetBinContent(ib)>3)
884     histoDead->SetBinContent(ib,1.3);
885     else
886     histoDead->SetBinContent(ib,0.0);
887    
888     }
889     histoDead->SetFillColor(5);
890     histoDead->Draw("histsame");
891     histoEff->Draw("same");
892     }
893     }
894     }
895     }
896     if(found){
897     stringstream name; name << "Cell_efficiency_MB" << ch.station();
898     createGifFile(name.str(),wh,sec);
899     }
900     }
901     }
902    
903     // Segment reconstruction efficiency vs X
904     efficiencyFolder = myMainFolder + "01-DTChamberEfficiency/Wheel" + wheel.str();
905     myCanvas->Clear();
906     myCanvas->Divide(2,4);
907    
908     chEffIt = myMuonGeom->chambers().begin();
909     chEffEnd = myMuonGeom->chambers().end();
910     for (; chEffIt != chEffEnd; ++chEffIt) {
911     DTChamberId ch = (*chEffIt)->id();
912     if (ch.sector() == sec && ch.wheel() == wh ) {
913     stringstream station; station << ch.station();
914     string histoName = efficiencyFolder + "/Sector" + sector.str() + "/Station" + station.str() + "/xEfficiency_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
915     TH1F *histoEffX = (TH1F*) myFile -> Get(histoName.c_str());
916     if(histoEffX){
917     myCanvas->cd( (ch.station()-1)*2 +1 );
918     string histoTitle= "Segment reco eff.vs X: Station " + station.str();
919     histoEffX->SetTitle(histoTitle.c_str());
920     histoEffX->GetXaxis()->SetTitle(" X position in chamber (cm) ");
921     histoEffX->GetXaxis()->SetLabelSize(0.08);
922     histoEffX->GetYaxis()->SetLabelSize(0.08);
923     histoEffX->Draw();
924     }
925     }
926     }
927    
928     // Segment reco efficiency vs Y
929     chEffIt = myMuonGeom->chambers().begin();
930     chEffEnd = myMuonGeom->chambers().end();
931     for (; chEffIt != chEffEnd; ++chEffIt) {
932     DTChamberId ch = (*chEffIt)->id();
933     if (ch.sector() == sec && ch.wheel() == wh ) {
934     stringstream station; station << ch.station();
935     string histoNameEffY = efficiencyFolder + "/Sector" + sector.str() + "/Station" + station.str() + "/yEfficiency_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
936     TH1F *histoEffY = (TH1F*) myFile -> Get(histoNameEffY.c_str());
937     if(histoEffY){
938     myCanvas->cd( (ch.station()-1)*2 +2 );
939     string histoTitle= "Segment reco eff.vs Y: Station " + station.str();
940     histoEffY->SetTitle(histoTitle.c_str());
941     histoEffY->GetXaxis()->SetTitle(" Y position in chamber (cm) ");
942     gStyle->SetOptStat(10);
943     histoEffY->GetXaxis()->SetLabelSize(0.08);
944     histoEffY->GetYaxis()->SetLabelSize(0.08);
945     histoEffY->Draw();
946     }
947     }
948     }
949    
950     createGifFile("SegmentEfficiency",wh,sec);
951    
952     }
953    
954    
955     void DTDPGCreateSummary::createTestPulsePlots(int wh, int sec) {
956    
957     gStyle->SetOptStat();
958     myCanvas->Clear();
959     myCanvas->Divide(4,3);
960     stringstream wheel; wheel << wh;
961     stringstream sector; sector << sec;
962    
963     vector<DTChamber*>::const_iterator chTPIt = myMuonGeom->chambers().begin();
964     vector<DTChamber*>::const_iterator chTPEnd = myMuonGeom->chambers().end();
965     for (; chTPIt != chTPEnd; ++chTPIt) {
966     DTChamberId ch = (*chTPIt)->id();
967     if (ch.sector() == sec && ch.wheel() == wh ) {
968     stringstream station; station << ch.station();
969     bool found = false;
970     vector<const DTSuperLayer*>::const_iterator slIt = (*chTPIt)->superLayers().begin();
971     vector<const DTSuperLayer*>::const_iterator slEnd = (*chTPIt)->superLayers().end();
972     // Loop over the SLs
973     for(; slIt != slEnd; ++slIt) {
974     DTSuperLayerId sl = (*slIt)->id();
975     vector<const DTLayer*>::const_iterator lIt = (*slIt)->layers().begin();
976     vector<const DTLayer*>::const_iterator lEnd = (*slIt)->layers().end();
977     stringstream superLayer; superLayer << sl.superlayer();
978     // Loop over the Ls
979     for(; lIt != lEnd; ++lIt) {
980     DTLayerId layerId = (*lIt)->id();
981     stringstream layer; layer << layerId.layer();
982     string testPulsesFolder = myMainFolder + "DTTestPulsesTask/Wheel" + wheel.str();
983     string histoName = testPulsesFolder + "/Station" + station.str() + "/Sector" + sector.str() + "/SuperLayer" + superLayer.str() + "/TPProfile/TestPulses2D_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() + "_SL" + superLayer.str() + "_L" + layer.str();
984 battilan 1.3 TProfile *histoTP = (TProfile*) myFile->Get(histoName.c_str()); // CB fix here
985 battilan 1.1 if(histoTP){
986     found = true;
987     int pad = (sl.superlayer() - 1)*4 + layerId.layer();
988     myCanvas->cd(pad);
989     histoTP->Draw();
990     }
991     }
992     }
993     if(found){
994     myCanvas->Update();
995     }
996     }
997     }
998     }
999