ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DTDPGAnalysis/src/DTDPGCreateSummary.cc
Revision: 1.3
Committed: Fri Dec 19 14:22:34 2008 UTC (16 years, 4 months ago) by battilan
Content type: text/plain
Branch: MAIN
Changes since 1.2: +36 -8 lines
Log Message:
Sigle Sector Summary processing

File Contents

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