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

File Contents

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