ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DTDPGAnalysis/src/DTDPGCreateSummary.cc
Revision: 1.7
Committed: Wed Jul 13 08:47:00 2011 UTC (13 years, 10 months ago) by marycruz
Content type: text/plain
Branch: MAIN
CVS Tags: V00-01-00
Changes since 1.6: +5 -4 lines
Log Message:
update to latest version of prompt offline analysis

File Contents

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