]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/muon/PlotMuonQA.C
Update (Francesco, Gian Michele)
[u/mrichter/AliRoot.git] / PWG3 / muon / PlotMuonQA.C
CommitLineData
93ce3c40 1//--------------------------------------------------------------------------
2// Macro for QA monitoring.
3//
4// In case it is not run with full aliroot, it needs the following libraries to compile:
5// - libSTEERBase.so
6// - libESD.so
7// - libAOD.so
8// - libANALYSIS.so
9// - libANALYSISalice.so
10// - libCORRFW.so
11// - libPWG3muon.so
12//
13// TString includePath = "-I${ALICE_ROOT}/PWG3/base/ "; gSystem->SetIncludePath(includePath.Data());
14//
15// The macro reads results of the QA task and produce monitoring plots.
16//
17// Author: Philippe Pillot - SUBATECH Nantes
18// Modified by Christophe Suire, Cynthia Hadjidakis - IPN Orsay
19//--------------------------------------------------------------------------
20
21#if !defined(__CINT__) || defined(__MAKECINT__)
22
23#include <Riostream.h>
24
25// ROOT includes
26#include "TEnv.h"
27#include "TMath.h"
28#include "TGrid.h"
29#include "TGridResult.h"
30#include "THashList.h"
31#include "TFile.h"
32#include "TH1.h"
33#include "TH2.h"
34#include "TSystem.h"
35#include "TStyle.h"
36#include "TCanvas.h"
37#include "TPad.h"
38#include "TLegend.h"
39
40// ALIROOT includes
41#include "AliCounterCollection.h"
42
43#endif
44
45
46// .x PlotMuonQA.C("alien:///alice/cern.ch/user/c/cynthia/muon/QA/pp/LHC10e/pass2_test/results",0,kFALSE)
47// .x PlotMuonQA.C("/Users/cynthia/Documents/alice/data/MuonQA/results",0,kFALSE)
48// .x PlotMuonQA.C("/Users/cynthia/Documents/alice/data/MuonQA/results","/Users/cynthia/Documents/alice/data/MuonQA/LHC10e/pass2/runlist_period3_test3_3runs.txt",kFALSE)
49//--------------------------------------------------------------------------
50void PlotMuonQA(const char* baseDir, const char* runList = 0x0, Bool_t selectPhysics = kFALSE)
51{
52 /// Macro for QA monitoring.
53 /// Example: baseDir = "alien:///alice/cern.ch/user/p/ppillot/pp7TeV/LHC10d/MuonQA/pass1/results/".
54 /// If runList != 0x0: only the given runs will be used. Otherwise use all runs found in baseDir.
55
56#if defined(__CINT__) && !defined(__MAKECINT__)
57 gSystem->Load("libTree");
58 gSystem->Load("libGeom");
59 gSystem->Load("libVMC");
60 gSystem->Load("libPhysics");
61 gSystem->Load("libSTEERBase");
62 gSystem->Load("libESD");
63 gSystem->Load("libAOD");
64 gSystem->Load("libANALYSIS");
65 gSystem->Load("libANALYSISalice");
66 gSystem->Load("libCORRFW");
67 gSystem->Load("libPWG3base");
68 gSystem->Load("libPWG3muon");
69#endif
70
71 // Cosmetics and configuration
72 gStyle->SetFillColor(10);
73 gStyle->SetPadGridX(kTRUE);
74 gStyle->SetPadGridY(kTRUE);
75 gStyle->SetPadRightMargin(0.01);
76
77 TString LHCPeriod = "LHC11a";
78
79
80 TString OutFileName = "QA_"; OutFileName += LHCPeriod;
81 TString OutFileNamePDF= OutFileName.Data(); OutFileNamePDF+= ".pdf";
82 TString OutFileNamePDF_open = OutFileNamePDF.Data(); OutFileNamePDF_open += "[";
83 TString OutFileNamePDF_close= OutFileNamePDF.Data(); OutFileNamePDF_close += "]";
84 TString OutFileNameROOT= OutFileName.Data(); OutFileNameROOT+= ".root";
85
86 Int_t PRINTSTAT = 1;
87
88 if (0){ // Equivalent to the fast read option
89 gEnv->SetValue("XNet.ConnectTimeout",10);
90 gEnv->SetValue("XNet.RequestTimeout",10);
91 gEnv->SetValue("XNet.MaxRedirectCount",2);
92 gEnv->SetValue("XNet.ReconnectTimeout",10);
93 gEnv->SetValue("XNet.FirstConnectMaxCnt",1);
94 }
95
96 TH1::AddDirectory(kFALSE);
97
98 TString alienBaseDir = baseDir;
99
100
101 if (alienBaseDir.Contains("alien:") && !TGrid::Connect("alien://")) {
102 Error("MergeQA","cannot connect to grid");
103 return;
104 }
105
106
107
108 //---------------------------------- //
109 // Run selection //
110 //---------------------------------- //
111
112
113 // list runs to be analyzed
114 TString selectRuns = "run:";
115 TObjArray runs;
116 runs.SetOwner();
117
118 if (runList) {
119 // only the ones in the runList
120 ifstream inFile(runList);
121 if (!inFile.is_open()) {
122 Error("PlotQA",Form("unable to open file %s", runList));
123 return;
124 }
125
126 TString currRun;
127 while (!inFile.eof()) {
128 currRun.ReadLine(inFile, kTRUE);
129 if (currRun.IsNull()) continue;
130 if (!currRun.IsDigit()) {
131 Error("PlotQA","invalid run number: %s", currRun.Data());
132 return;
133 }
134 runs.AddLast(new TObjString(Form("%09d", currRun.Atoi())));
135 selectRuns += Form("%s,",currRun.Data());
136 }
137 selectRuns.Remove(TString::kTrailing, ',');
138 inFile.close();
139
140 } else {
141 // all runs
142 runs.AddLast(new TObjString("*"));
143 }
144
145 // physics selection
146 TString select = selectPhysics ? "selected:yes" : "";
147
148
149 //---------------------------------- //
150 // plot global counter //
151 //---------------------------------- //
152
153 TFile *globalFile = TFile::Open(Form("%s/MergedAnalysisResults.root", baseDir));
154 if (!globalFile || ! globalFile->IsOpen()) {
155 Error("PlotQA", Form("failed to open file: %s/MergedAnalysisResults.root", baseDir));
156 return;
157 }
158 globalFile->Cd("MUON_QA");
159
160 // get counters
161 AliCounterCollection* eventCounters = static_cast<AliCounterCollection*>(globalFile->FindObjectAny("eventCounters"));
162 AliCounterCollection* trackCounters = static_cast<AliCounterCollection*>(globalFile->FindObjectAny("trackCounters"));
163 if (!runList) selectRuns += trackCounters->GetKeyWords("run");
164
165 //declare a default canvas c1
166 TString CanvasName = "c1";
167 TCanvas *c1 = new TCanvas(CanvasName.Data());
168 c1->cd();
169
170 // Histo trigger without Phys. Sel.
171 TH1* hAllTriggersNoPS = eventCounters->Draw("run",Form("trigger:CINT1B,CMUS1B,CSH1B/%s", selectRuns.Data()));
172 if(!hAllTriggersNoPS) return;
173 hAllTriggersNoPS->Sumw2();
174 TH1* hCINT1BNoPS = eventCounters->Draw("run",Form("trigger:CINT1B/%s", selectRuns.Data()));
175 if(!hCINT1BNoPS) return;
176 hCINT1BNoPS->Sumw2();
177 Int_t NumOfCINT1BNoPS = hCINT1BNoPS->Integral();
178 TH1* hCMUS1BNoPS = eventCounters->Draw("run",Form("trigger:CMUS1B/%s", selectRuns.Data()));
179 if(!hCMUS1BNoPS) return;
180 hCMUS1BNoPS->Sumw2();
181 Int_t NumOfCMUS1BNoPS = hCMUS1BNoPS->Integral();
182 TH1* hCSH1BNoPS = eventCounters->Draw("run",Form("trigger:CSH1B/%s", selectRuns.Data()));
183 Int_t NumOfCSH1BNoPS = 0;
184 if(!hCMUS1BNoPS) return;
185 hCSH1BNoPS->Sumw2();
186 NumOfCSH1BNoPS = hCSH1BNoPS->Integral();
187
188
189 // Histo trigger with Phys. Sel.
190 TH1* hAllTriggersWithPS = eventCounters->Draw("run",Form("trigger:CINT1B,CMUS1B,CSH1B/%s/selected:yes", selectRuns.Data()));
191 hAllTriggersWithPS->Sumw2();
192 TH1* hCINT1BWithPS = eventCounters->Draw("run",Form("trigger:CINT1B/%s/selected:yes", selectRuns.Data()));
193 hCINT1BWithPS->Sumw2();
194 Int_t NumOfCINT1BWithPS = hCINT1BWithPS->Integral();
195 TH1* hCMUS1BWithPS = eventCounters->Draw("run",Form("trigger:CMUS1B/%s/selected:yes", selectRuns.Data()));
196 hCMUS1BWithPS->Sumw2();
197 Int_t NumOfCMUS1BWithPS = hCMUS1BWithPS->Integral();
198 TH1* hCSH1BWithPS = eventCounters->Draw("run",Form("trigger:CSH1B/%s/selected:yes", selectRuns.Data()));
199 hCSH1BWithPS->Sumw2();
200 Int_t NumOfCSH1BWithPS = hCSH1BWithPS->Integral();
201
202 //Background estimator in CMUS1
203 TH1* hCMUS1ACNoPS = eventCounters->Draw("run",Form("trigger:CMUS1AC/%s", selectRuns.Data()));
204 hCMUS1ACNoPS->Sumw2();
205 TH1* hCMUS1ENoPS = eventCounters->Draw("run",Form("trigger:CMUS1E/%s", selectRuns.Data()));
206 Int_t NumOfCMUS1ENoPS = 0;
207 if(hCMUS1ENoPS){
208 hCMUS1ENoPS->Sumw2();
209 NumOfCMUS1ENoPS = hCMUS1ENoPS->Integral();
210 }
211
212 // Histo trigger : Phys. Sel. is selected or not depending on the macro arguments
213 TH1* hAllTriggers = eventCounters->Draw("run",Form("trigger:CINT1B,CMUS1B,CSH1B/%s/%s", selectRuns.Data(), select.Data()));
214 hAllTriggers->Sumw2();
215 TH1* hCINT1B = eventCounters->Draw("run",Form("trigger:CINT1B/%s/%s", selectRuns.Data(), select.Data()));
216 hCINT1B->Sumw2();
217 TH1* hCMUS1B = eventCounters->Draw("run",Form("trigger:CMUS1B/%s/%s", selectRuns.Data(), select.Data()));
218 hCMUS1B->Sumw2();
219 TH1* hCSH1B = eventCounters->Draw("run",Form("trigger:CSH1B/%s/%s", selectRuns.Data(), select.Data()));
220 hCSH1B->Sumw2();
221
222 // Histo tracking : Phys. Sel. is selected or not depending on the macro arguments
223 TH1* hTriggerCINT1B = trackCounters->Draw("run",Form("track:triggeronly/trigger:CINT1B/%s/%s", selectRuns.Data(), select.Data()));
224 hTriggerCINT1B->Sumw2();
225 TH1* hTrackerCINT1B = trackCounters->Draw("run",Form("track:trackeronly/trigger:CINT1B/%s/%s", selectRuns.Data(), select.Data()));
226 hTrackerCINT1B->Sumw2();
227 TH1* hMatchedCINT1B = trackCounters->Draw("run",Form("track:matched/trigger:CINT1B/%s/%s", selectRuns.Data(), select.Data()));
228 hMatchedCINT1B->Sumw2();
229 TH1* hTriggerCMUS1B = trackCounters->Draw("run",Form("track:triggeronly/trigger:CMUS1B/%s/%s", selectRuns.Data(), select.Data()));
230 hTriggerCMUS1B->Sumw2();
231 TH1* hTrackerCMUS1B = trackCounters->Draw("run",Form("track:trackeronly/trigger:CMUS1B/%s/%s", selectRuns.Data(), select.Data()));
232 hTrackerCMUS1B->Sumw2();
233 TH1* hMatchedCMUS1B = trackCounters->Draw("run",Form("track:matched/trigger:CMUS1B/%s/%s", selectRuns.Data(), select.Data()));
234 hMatchedCMUS1B->Sumw2();
235 TH1* hAllTracksCINT1B = trackCounters->Draw("run",Form("trigger:CINT1B/%s/%s", selectRuns.Data(), select.Data()));
236 hAllTracksCINT1B->Sumw2();
237 TH1* hAllTracksCMUS1B = trackCounters->Draw("run",Form("trigger:CMUS1B/%s/%s", selectRuns.Data(), select.Data()));
238 hAllTracksCMUS1B->Sumw2();
239
240 TH1* hMatchedLowPtCMUS1B = trackCounters->Draw("run",Form("track:matched/trigger:CMUS1B/%s/%s/pt:low", selectRuns.Data(), select.Data()));
241 hMatchedLowPtCMUS1B->Sumw2();
242 TH1* hMatchedHighPtCMUS1B = trackCounters->Draw("run",Form("track:matched/trigger:CMUS1B/%s/%s/pt:high", selectRuns.Data(), select.Data()));
243 hMatchedHighPtCMUS1B->Sumw2();
244
245 TH1 *hPosMatched = trackCounters->Draw("run",Form("track:matched/%s/charge:pos/%s",select.Data(),selectRuns.Data()));
246 hPosMatched->Sumw2();
247 TH1 *hNegMatched = trackCounters->Draw("run",Form("track:matched/%s/charge:neg/%s",select.Data(),selectRuns.Data()));
248 hNegMatched->Sumw2();
249 TH1 *hAllMatched= trackCounters->Draw("run",Form("track:matched/%s/%s",select.Data(),selectRuns.Data()));
250 hAllMatched->Sumw2();
251 // for CMUS1B only
252 TH1 *hPosMatchedCMUS1B = trackCounters->Draw("run",Form("track:matched/%s/charge:pos/trigger:CMUS1B/%s",select.Data(),selectRuns.Data()));
253 hPosMatchedCMUS1B->Sumw2();
254 TH1 *hNegMatchedCMUS1B= trackCounters->Draw("run",Form("track:matched/%s/charge:neg/trigger:CMUS1B/%s",select.Data(),selectRuns.Data()));
255 hNegMatchedCMUS1B->Sumw2();
256 TH1 *hAllMatchedCMUS1B= trackCounters->Draw("run",Form("track:matched/%s/trigger:CMUS1B/%s",select.Data(),selectRuns.Data()));
257 hAllMatchedCMUS1B->Sumw2();
258
259 //TH1* hAll = eventCounters->Draw("trigger","run","run:any");
260 //hAll->Draw();
261
262 //===================================================================================
263 // Put all plots in a ps file, easier to publish (Twiki)
264 //TPostScript QAps(OutFileName.Data(),4112);
265 //QAps.Range(26,19);
266 //c1->Print(PSopen.Data());
267 c1->Print(OutFileNamePDF_open.Data());
268
269 TFile *rootFileOut = TFile::Open(OutFileNameROOT.Data(),"RECREATE");
270
271 //===================================================================================
272 // new canvas with the relative content of each trigger w/ and w/o physics selection
273 TH1 *ratioCMUS1B = static_cast<TH1*>(hCMUS1BWithPS->Clone("ratioCMUS1B"));
274 ratioCMUS1B->Divide(hAllTriggersNoPS);
275 ratioCMUS1B->SetLineColor(kRed);
276 ratioCMUS1B->SetLineWidth(2);
277 TH1 *ratioCINT1B = static_cast<TH1*>(hCINT1BWithPS->Clone("ratioCINT1B"));
278 ratioCINT1B->Divide(hAllTriggersNoPS);
279 ratioCINT1B->SetLineColor(kBlue);
280 ratioCINT1B->SetLineWidth(2);
281 TH1 *ratioCSH1B = static_cast<TH1*>(hCSH1BWithPS->Clone("ratioCSH1B"));
282 ratioCSH1B->Divide(hAllTriggersNoPS);
283 ratioCSH1B->SetLineColor(kGreen);
284 ratioCSH1B->SetLineWidth(2);
285
286 TH1 *ratioCMUS1BNoPS = static_cast<TH1*>(hCMUS1BNoPS->Clone("ratioCMUS1BNoPS"));
287 ratioCMUS1BNoPS->Divide(hAllTriggersNoPS);
288 ratioCMUS1BNoPS->SetLineColor(kRed);
289 ratioCMUS1BNoPS->SetLineWidth(0);
290 ratioCMUS1BNoPS->SetLineStyle(2);
291 ratioCMUS1BNoPS->SetMarkerColor(kRed);
292 ratioCMUS1BNoPS->SetMarkerStyle(24);
293 ratioCMUS1BNoPS->SetMarkerSize(1);
294 TH1 *ratioCINT1BNoPS = static_cast<TH1*>(hCINT1BNoPS->Clone("ratioCINT1BNoPS"));
295 ratioCINT1BNoPS->Divide(hAllTriggersNoPS);
296 ratioCINT1BNoPS->SetLineColor(kBlue);
297 ratioCINT1BNoPS->SetLineWidth(0);
298 ratioCINT1BNoPS->SetLineStyle(2);
299 ratioCINT1BNoPS->SetMarkerColor(kBlue);
300 ratioCINT1BNoPS->SetMarkerStyle(25);
301 ratioCINT1BNoPS->SetMarkerSize(1);
302 TH1 *ratioCSH1BNoPS = static_cast<TH1*>(hCSH1BNoPS->Clone("ratioCSH1BNoPS"));
303 ratioCSH1BNoPS->Divide(hAllTriggersNoPS);
304 ratioCSH1BNoPS->SetLineColor(kGreen);
305 ratioCSH1BNoPS->SetLineWidth(0);
306 ratioCSH1BNoPS->SetLineStyle(2);
307 ratioCSH1BNoPS->SetMarkerColor(kGreen);
308 ratioCSH1BNoPS->SetMarkerStyle(26);
309 ratioCSH1BNoPS->SetMarkerSize(1);
310
311 CanvasName = LHCPeriod.Data() ;
312 CanvasName += "_RelativeTriggerContent";
313 TCanvas *cRelativeTriggerContent = new TCanvas(CanvasName.Data(),"cRelativeTriggerContent",1200,900);
314 cRelativeTriggerContent->SetTopMargin(0.05);
315 cRelativeTriggerContent->SetRightMargin(0.01);
316 cRelativeTriggerContent->SetGridy(1);
317 cRelativeTriggerContent->SetLogy(1);
318 cRelativeTriggerContent->cd();
319
320 ratioCMUS1B->SetMaximum(1.5);
321 ratioCMUS1B->SetMinimum(0.001);
322 ratioCMUS1B->SetTitle("");
323 ratioCMUS1B->SetLabelSize(0.02);
324 ratioCMUS1B->GetYaxis()->SetTitle("Relative trigger content w/ and w/o Phys. Sel.");
325
326 ratioCMUS1B->Draw();
327 ratioCINT1B->Draw("ESAME");
328 ratioCSH1B->Draw("ESAME");
329 ratioCINT1BNoPS->Draw("EPSAME");
330 ratioCMUS1BNoPS->Draw("EPSAME");
331 ratioCSH1BNoPS->Draw("EPSAME");
332
333 TLegend* legcRTC = new TLegend(0.2,0.15,0.50,0.40);
334 legcRTC->SetHeader("Physics Selection");
335 legcRTC->AddEntry(".","applied :","");
336 legcRTC->AddEntry(ratioCMUS1B,"CMUS1B","l");
337 legcRTC->AddEntry(ratioCINT1B,"CINT1B","l");
338 legcRTC->AddEntry(ratioCSH1B,"CSH1B","l");
339 legcRTC->AddEntry(".","not applied :","");
340 legcRTC->AddEntry(ratioCMUS1BNoPS,"CMUS1B","p");
341 legcRTC->AddEntry(ratioCINT1BNoPS,"CINT1B","p");
342 legcRTC->AddEntry(ratioCSH1BNoPS,"CSH1B","p");
343 legcRTC->Draw("same");
344
345 cRelativeTriggerContent->Print(OutFileNamePDF.Data());
346 cRelativeTriggerContent->Write();
347
348 //===================================================================================
349 // new canvas to estimate CMUS1B background percentage w/o physics selection
350 TH1 *ratioBckCMUS1BNoPS = static_cast<TH1*>(hCMUS1BNoPS->Clone("ratioBckCMUS1BNoPS"));
351 ratioBckCMUS1BNoPS->Add(hCMUS1ACNoPS,-1);
352 if(hCMUS1ENoPS) ratioBckCMUS1BNoPS->Add(hCMUS1ENoPS,2);
353 ratioBckCMUS1BNoPS->Divide(hCMUS1BNoPS);
354 ratioBckCMUS1BNoPS->SetLineColor(kRed);
355 ratioBckCMUS1BNoPS->SetLineWidth(2);
356
357 TH1 *ratioBckCMUS1BWithPS = static_cast<TH1*>(hCMUS1BWithPS->Clone("ratioBckCMUS1BWithPS"));
358 ratioBckCMUS1BWithPS->Divide(hCMUS1BNoPS);
359 ratioBckCMUS1BWithPS->SetLineColor(kBlue);
360 ratioBckCMUS1BWithPS->SetLineWidth(2);
361
362 CanvasName = LHCPeriod.Data() ;
363 CanvasName += "_BackgroundInCMUS1B";
364 TCanvas *cBackgroundInCMUS1B = new TCanvas(CanvasName.Data(),"cBackgroundInCMUS1B",1200,900);
365 cBackgroundInCMUS1B->SetTopMargin(0.05);
366 cBackgroundInCMUS1B->SetRightMargin(0.01);
367 cBackgroundInCMUS1B->SetGridy(1);
368 //cBackgroundInCMUS1B->SetLogy(1);
369 cBackgroundInCMUS1B->cd();
370
371 ratioBckCMUS1BNoPS->SetMaximum(1.2);
372 ratioBckCMUS1BNoPS->SetMinimum(0.1);
373 ratioBckCMUS1BNoPS->SetTitle("");
374 ratioBckCMUS1BNoPS->SetLabelSize(0.02);
375 ratioBckCMUS1BNoPS->GetYaxis()->SetTitle("Ratio");
376
377 ratioBckCMUS1BNoPS->Draw();
378 ratioBckCMUS1BWithPS->Draw("ESAME");
379
380 TLegend* legcBTS = new TLegend(0.2,0.25,0.50,0.40);
381 legcBTS->SetHeader("Background subtraction in CMUS1B: B-A-C+2E");
382 legcBTS->AddEntry(ratioBckCMUS1BNoPS,"Background substracted/All ","l");
383 legcBTS->AddEntry(ratioBckCMUS1BWithPS,"Physics Selected/All","l");
384 legcBTS->Draw("same");
385
386 cBackgroundInCMUS1B->Print(OutFileNamePDF.Data());
387 cBackgroundInCMUS1B->Write();
388
389 //===========================================
390 // Draw ratio of tracks over CINT1B versus run
391 TH1* hTrackerPerCINT1B= static_cast<TH1*>(hTrackerCINT1B->Clone("hTrackerPerCINT1B"));
392 hTrackerPerCINT1B->Divide(hCINT1B);
393 hTrackerPerCINT1B->SetLineWidth(2);
394 hTrackerPerCINT1B->SetLineColor(kRed);
395
396 TH1* hTriggerPerCINT1B= static_cast<TH1*>(hTriggerCINT1B->Clone("hTriggerPerCINT1B"));
397 hTriggerPerCINT1B->Divide(hCINT1B);
398 hTriggerPerCINT1B->SetLineWidth(2);
399 hTriggerPerCINT1B->SetLineColor(kBlue);
400
401 TH1* hMatchedPerCINT1B= static_cast<TH1*>(hMatchedCINT1B->Clone("hMatchedPerCINT1B"));
402 hMatchedPerCINT1B->Divide(hCINT1B);
403 hMatchedPerCINT1B->SetLineWidth(2);
404 hMatchedPerCINT1B->SetLineColor(kViolet);
405
406
407 TH1* hAllTracksPerCINT1B= static_cast<TH1*>(hAllTracksCINT1B->Clone("hAllTracksPerCINT1B"));
408 hAllTracksPerCINT1B->Divide(hCINT1B);
409 hAllTracksPerCINT1B->SetLineWidth(3);
410 hAllTracksPerCINT1B->SetLineColor(kBlack);
411
412 CanvasName = LHCPeriod.Data() ;
413 CanvasName += "_RatioTrackTypesCINT1B";
414 TCanvas *cRatioTrackTypesCINT1B = new TCanvas(CanvasName.Data(),"cRatioTrackTypesCINT1B",1200,900);
415 cRatioTrackTypesCINT1B->SetRightMargin(0.01);
416 cRatioTrackTypesCINT1B->SetGridy(1);
417 cRatioTrackTypesCINT1B->cd();
418
419 hAllTracksPerCINT1B->SetTitle("Ratio (Number of Tracks)/CINT1B");
420 hAllTracksPerCINT1B->SetMinimum(0.0001);
421 hAllTracksPerCINT1B->SetLabelSize(0.02);
422 hAllTracksPerCINT1B->Draw("E");
423
424 hTrackerPerCINT1B->Draw("Esame");
425 hMatchedPerCINT1B->Draw("Esame");
426 hTriggerPerCINT1B->Draw("Esame");
427
428 TLegend* legcTTCINT1B = new TLegend(0.70,0.5,0.90,0.70);
429 legcTTCINT1B->AddEntry(hAllTracksPerCINT1B,"All tracks","l");
430 legcTTCINT1B->AddEntry(hTrackerPerCINT1B,"Tracking (only) tracks","l");
431 legcTTCINT1B->AddEntry(hMatchedPerCINT1B,"Matched tracks","l");
432 legcTTCINT1B->AddEntry(hTriggerPerCINT1B,"Trigger (only) tracks","l");
433 legcTTCINT1B->Draw("same");
434
435 cRatioTrackTypesCINT1B->Print(OutFileNamePDF.Data());
436 cRatioTrackTypesCINT1B->Write();
437
438 //===========================================
439 // draw ratio of track (summed, i.e all trigger=(matched+trigger-only)) over CINT1B versus run
440 TCanvas* cTrackMultCINT1B = new TCanvas("cTrackMultCINT1B","cTrackMultCINT1B",1200,900);
441 // must be applied on the pads created by divide
442 cTrackMultCINT1B->Divide(1,2);
443 cTrackMultCINT1B->cd(1);
444 TH1* hSumTriggerOverCINT1B = static_cast<TH1*>(hTriggerCINT1B->Clone("hSumTriggerOverCINT1B"));
445 hSumTriggerOverCINT1B->Add(hMatchedCINT1B);
446 hSumTriggerOverCINT1B->Divide(hCINT1B);
447 hSumTriggerOverCINT1B->SetTitle("Sum of trigger tracks (matched+trigger-only) in CINT1B events / # CINT1B events");
448 //hSumTriggerOverCINT1B->LabelsOption("u");
449 hSumTriggerOverCINT1B->SetLabelSize(0.02);
450 hSumTriggerOverCINT1B->SetLineWidth(2);
451 hSumTriggerOverCINT1B->SetLineColor(kBlue);
452 hSumTriggerOverCINT1B->Draw("e");
453 cTrackMultCINT1B->cd(2);
454 TH1* hSumTrackerOverCINT1B = static_cast<TH1*>(hTrackerCINT1B->Clone("hSumTrackerOverCINT1B"));
455 hSumTrackerOverCINT1B->Add(hMatchedCINT1B);
456 hSumTrackerOverCINT1B->Divide(hCINT1B);
457 hSumTrackerOverCINT1B->SetTitle("Sum tracker tracks (matched+tracker-only) in CINT1B events / # CINT1B events");
458 //hSumTrackerOverCINT1B->LabelsOption("u");
459 hSumTrackerOverCINT1B->SetLabelSize(0.02);
460 hSumTrackerOverCINT1B->SetLineWidth(2);
461 hSumTrackerOverCINT1B->SetLineColor(kBlue);
462 hSumTrackerOverCINT1B->Draw("e");
463
464 cTrackMultCINT1B->Print(OutFileNamePDF.Data());
465 cTrackMultCINT1B->Write();
466
467 //===========================================
468 // draw mixed ratio of track over track versus run for CINT1B
469 TCanvas* cRatioTrackCINT1B = new TCanvas("cRatioTrackCINT1B","cRatioTrackCINT1B",1200,900);
470 cRatioTrackCINT1B->Divide(1,3);
471
472 cRatioTrackCINT1B->cd(1);
473 TH1* hTrackerOverTriggerCINT1B = static_cast<TH1*>(hTrackerCINT1B->Clone("hTrackerOverTriggerCINT1B"));
474 hTrackerOverTriggerCINT1B->Divide(hTriggerCINT1B);
475 hTrackerOverTriggerCINT1B->SetTitle("# tracker tracks / # trigger tracks in CINT1B");
476 //hTrackerOverTriggerCINT1B->LabelsOption("u");
477 hTrackerOverTriggerCINT1B->SetLabelSize(0.02);
478 hTrackerOverTriggerCINT1B->SetLineWidth(2);
479 hTrackerOverTriggerCINT1B->SetLineColor(kBlue);
480 hTrackerOverTriggerCINT1B->Draw("e");
481
482 cRatioTrackCINT1B->cd(2);
483 TH1* hMatchedOverTriggerCINT1B = static_cast<TH1*>(hMatchedCINT1B->Clone("hMatchedOverTriggerCINT1B"));
484 hMatchedOverTriggerCINT1B->Divide(hTriggerCINT1B);
485 hMatchedOverTriggerCINT1B->SetTitle("# matched tracks / # trigger tracks in CINT1B");
486 //hMatchedOverTriggerCINT1B->LabelsOption("u");
487 hMatchedOverTriggerCINT1B->SetLabelSize(0.02);
488 hMatchedOverTriggerCINT1B->SetLineWidth(2);
489 hMatchedOverTriggerCINT1B->SetLineColor(kBlue);
490 hMatchedOverTriggerCINT1B->Draw("e");
491
492 cRatioTrackCINT1B->cd(3);
493 TH1* hMatchedOverTrackerCINT1B = static_cast<TH1*>(hMatchedCINT1B->Clone("hMatchedOverTrackerCINT1B"));
494 hMatchedOverTrackerCINT1B->Divide(hTrackerCINT1B);
495 hMatchedOverTrackerCINT1B->SetTitle("# matched tracks / # tracker tracks in CINT1B");
496 //hMatchedOverTrackerCINT1B->LabelsOption("u");
497 hMatchedOverTrackerCINT1B->SetLabelSize(0.02);
498 hMatchedOverTrackerCINT1B->SetLineWidth(2);
499 hMatchedOverTrackerCINT1B->SetLineColor(kBlue);
500 hMatchedOverTrackerCINT1B->Draw("e");
501
502 cRatioTrackCINT1B->Print(OutFileNamePDF.Data());
503 cRatioTrackCINT1B->Write();
504
505 //===========================================
506 // Draw ratio of tracks over CMUS1B versus run
507 TH1* hTrackerPerCMUS1B= static_cast<TH1*>(hTrackerCMUS1B->Clone("hTrackerPerCMUS1B"));
508 hTrackerPerCMUS1B->Divide(hCMUS1B);
509 hTrackerPerCMUS1B->SetLineWidth(2);
510 hTrackerPerCMUS1B->SetLineColor(kRed);
511
512 TH1* hTriggerPerCMUS1B= static_cast<TH1*>(hTriggerCMUS1B->Clone("hTriggerPerCMUS1B"));
513 hTriggerPerCMUS1B->Divide(hCMUS1B);
514 hTriggerPerCMUS1B->SetLineWidth(2);
515 hTriggerPerCMUS1B->SetLineColor(kBlue);
516
517 TH1* hMatchedPerCMUS1B= static_cast<TH1*>(hMatchedCMUS1B->Clone("hMatchedPerCMUS1B"));
518 hMatchedPerCMUS1B->Divide(hCMUS1B);
519 hMatchedPerCMUS1B->SetLineWidth(2);
520 hMatchedPerCMUS1B->SetLineColor(kViolet);
521
522 TH1* hAllTracksPerCMUS1B= static_cast<TH1*>(hAllTracksCMUS1B->Clone("hAllTracksPerCMUS1B"));
523 hAllTracksPerCMUS1B->Divide(hCMUS1B);
524 hAllTracksPerCMUS1B->SetLineWidth(3);
525 hAllTracksPerCMUS1B->SetLineColor(kBlack);
526
527
528 CanvasName = LHCPeriod.Data() ;
529 CanvasName += "_RatioTrackTypesCMUS1B";
530 TCanvas *cRatioTrackTypesCMUS1B = new TCanvas(CanvasName.Data(),"cRatioTrackTypesCMUS1B",1200,900);
531 cRatioTrackTypesCMUS1B->SetRightMargin(0.01);
532 cRatioTrackTypesCMUS1B->SetGridy(1);
533 cRatioTrackTypesCMUS1B->cd();
534
535 hAllTracksPerCMUS1B->SetTitle("Ratio (Number of Tracks)/CMUS1B");
536 hAllTracksPerCMUS1B->SetMinimum(0.01);
537 hAllTracksPerCMUS1B->SetLabelSize(0.02);
538 hAllTracksPerCMUS1B->Draw("E");
539
540 hTrackerPerCMUS1B->Draw("Esame");
541 hMatchedPerCMUS1B->Draw("Esame");
542 hTriggerPerCMUS1B->Draw("Esame");
543
544 TLegend* legcTTCMUS1B = new TLegend(0.75,0.55,0.90,0.75);
545 legcTTCMUS1B->AddEntry(hAllTracksPerCMUS1B,"All tracks","l");
546 legcTTCMUS1B->AddEntry(hTrackerPerCMUS1B,"Tracking (only) tracks","l");
547 legcTTCMUS1B->AddEntry(hMatchedPerCMUS1B,"Matched tracks","l");
548 legcTTCMUS1B->AddEntry(hTriggerPerCMUS1B,"Trigger (only) tracks","l");
549 legcTTCMUS1B->Draw("same");
550
551 cRatioTrackTypesCMUS1B->Print(OutFileNamePDF.Data());
552 cRatioTrackTypesCMUS1B->Write();
553
554 //===========================================
555 // draw ratio of track (summed, i.e all trigger=(matched+trigger-only)) over CMUS1B versus run
556 TCanvas* cTrackMultCMUS1B = new TCanvas("cTrackMultCMUS1B","cTrackMultCMUS1B",1200,900);
557 cTrackMultCMUS1B->Divide(1,2);
558 cTrackMultCMUS1B->cd(1);
559 TH1* hSumTriggerOverCMUS1B = static_cast<TH1*>(hTriggerCMUS1B->Clone("hSumTriggerOverCMUS1B"));
560 hSumTriggerOverCMUS1B->Add(hMatchedCMUS1B);
561 hSumTriggerOverCMUS1B->Divide(hCMUS1B);
562 hSumTriggerOverCMUS1B->SetTitle("Sum of trigger tracks (matched+trigger-only) in CMUS1B events / # CMUS1B events");
563 //hSumTriggerOverCMUS1B->LabelsOption("u");
564 hSumTriggerOverCMUS1B->SetLabelSize(0.02);
565 hSumTriggerOverCMUS1B->SetLineWidth(2);
566 hSumTriggerOverCMUS1B->SetLineColor(kRed);
567 hSumTriggerOverCMUS1B->Draw("e");
568
569 cTrackMultCMUS1B->cd(2);
570 TH1* hSumTrackerOverCMUS1B = static_cast<TH1*>(hTrackerCMUS1B->Clone("hSumTrackerOverCMUS1B"));
571 hSumTrackerOverCMUS1B->Add(hMatchedCMUS1B);
572 hSumTrackerOverCMUS1B->Divide(hCMUS1B);
573 hSumTrackerOverCMUS1B->SetTitle("Sum of tracker tracks (matched+tracker-only) in CMUS1B events / # CMUS1B events");
574 //hSumTrackerOverCMUS1B->LabelsOption("u");
575 hSumTrackerOverCMUS1B->SetLabelSize(0.02);
576 hSumTrackerOverCMUS1B->SetLineWidth(2);
577 hSumTrackerOverCMUS1B->SetLineColor(kRed);
578 hSumTrackerOverCMUS1B->Draw("e");
579
580 cTrackMultCMUS1B->Print(OutFileNamePDF.Data());
581 cTrackMultCMUS1B->Write();
582
583 //===========================================
584 // draw mixed ratio of track over track versus run for CMUS1B
585 TCanvas* cRatioTrackCMUS1B = new TCanvas("cRatioTrackCMUS1B","cRatioTrackCMUS1B",1200,900);
586 cRatioTrackCMUS1B->Divide(1,3);
587
588 cRatioTrackCMUS1B->cd(1);
589 TH1* hTrackerOverTriggerCMUS1B = static_cast<TH1*>(hTrackerCMUS1B->Clone("hTrackerOverTriggerCMUS1B"));
590 hTrackerOverTriggerCMUS1B->Divide(hTriggerCMUS1B);
591 hTrackerOverTriggerCMUS1B->SetTitle("# tracker tracks / # trigger tracks in CMUS1B");
592 //hTrackerOverTriggerCMUS1B->LabelsOption("u");
593 hTrackerOverTriggerCMUS1B->SetLabelSize(0.02);
594 hTrackerOverTriggerCMUS1B->SetLineWidth(2);
595 hTrackerOverTriggerCMUS1B->SetLineColor(kRed);
596 hTrackerOverTriggerCMUS1B->Draw("e");
597
598 cRatioTrackCMUS1B->cd(2);
599 TH1* hMatchedOverTriggerCMUS1B = static_cast<TH1*>(hMatchedCMUS1B->Clone("hMatchedOverTriggerCMUS1B"));
600 hMatchedOverTriggerCMUS1B->Divide(hTriggerCMUS1B);
601 hMatchedOverTriggerCMUS1B->SetTitle("# matched tracks / # trigger tracks in CMUS1B");
602 //hMatchedOverTriggerCMUS1B->LabelsOption("u");
603 hMatchedOverTriggerCMUS1B->SetLabelSize(0.02);
604 hMatchedOverTriggerCMUS1B->SetLineWidth(2);
605 hMatchedOverTriggerCMUS1B->SetLineColor(kRed);
606 hMatchedOverTriggerCMUS1B->Draw("e");
607
608 cRatioTrackCMUS1B->cd(3);
609 TH1* hMatchedOverTrackerCMUS1B = static_cast<TH1*>(hMatchedCMUS1B->Clone("hMatchedOverTrackerCMUS1B"));
610 hMatchedOverTrackerCMUS1B->Divide(hTrackerCMUS1B);
611 hMatchedOverTrackerCMUS1B->SetTitle("# matched tracks / # tracker tracks in CMUS1B");
612 //hMatchedOverTrackerCMUS1B->LabelsOption("u");
613 hMatchedOverTrackerCMUS1B->SetLabelSize(0.02);
614 hMatchedOverTrackerCMUS1B->SetLineWidth(2);
615 hMatchedOverTrackerCMUS1B->SetLineColor(kRed);
616 hMatchedOverTrackerCMUS1B->Draw("e");
617
618 cRatioTrackCMUS1B->Print(OutFileNamePDF.Data());
619 cRatioTrackCMUS1B->Write();
620
621 //==================================================
622 // Draw matched tracks asymetry :
623 // for all triggers
624 TH1 *hDiffMatched= static_cast<TH1*>(hPosMatched->Clone("hDiffMatched"));
625 hDiffMatched->Add(hNegMatched,-1);
626 hDiffMatched->Sumw2();
627
628 TH1 *hAsymMatched= static_cast<TH1*>(hDiffMatched->Clone("hAsymMatched"));
629 hAsymMatched->Divide(hAllMatched);
630 hAsymMatched->SetTitle("Asymetry Matched tracks for Physics Selected events");
631 hAsymMatched->SetMarkerStyle(20);
632
633
634 TH1 *hDiffMatchedCMUS1B= static_cast<TH1*>(hPosMatchedCMUS1B->Clone("hDiffMatchedCMUS1B"));
635 hDiffMatchedCMUS1B->Add(hNegMatchedCMUS1B,-1);
636 hDiffMatchedCMUS1B->Sumw2();
637
638 TH1 *hAsymMatchedCMUS1B= static_cast<TH1*>(hDiffMatchedCMUS1B->Clone("hAsymMatchedCMUS1B"));
639 hAsymMatchedCMUS1B->Divide(hAllMatchedCMUS1B);
640 hAsymMatchedCMUS1B->SetLineColor(kRed);
641 hAsymMatchedCMUS1B->SetLineWidth(2);
642 hAsymMatchedCMUS1B->SetMinimum(-0.1);
643 hAsymMatchedCMUS1B->SetMaximum(0.1);
644 hAsymMatchedCMUS1B->SetLabelSize(0.02);
645 hAsymMatchedCMUS1B->SetTitle("Matched tracks asymetry in Physics Selected events for CMUS1B");
646
647 CanvasName = LHCPeriod.Data() ;
648 CanvasName += "_AsymMatched";
649 TCanvas *cAsymMatched = new TCanvas(CanvasName.Data(),"cAsymMatched",1200,900);
650 cAsymMatched->SetRightMargin(0.01);
651 cAsymMatched->SetGridy(1);
652 cAsymMatched->cd();
653 hAsymMatchedCMUS1B->GetYaxis()->SetTitle("Asymetry");
654 hAsymMatchedCMUS1B->Draw("EH");
655
656 cAsymMatched->Print(OutFileNamePDF.Data());
657 cAsymMatched->Write();
658
659
660 //==================================================
661 // Draw high pt tracks per CMUS1B
662 TH1* hMatchedLowPtPerCMUS1B = static_cast<TH1*> (hMatchedLowPtCMUS1B->Clone("hMatchedLowPtPerCMUS1B"));
663 hMatchedLowPtPerCMUS1B->Sumw2();
664 hMatchedLowPtPerCMUS1B->Divide(hCMUS1B);
665 hMatchedLowPtPerCMUS1B->SetLineWidth(2);
666 hMatchedLowPtPerCMUS1B->SetLineColor(kBlue);
667
668 TH1* hMatchedHighPtPerCMUS1B = static_cast<TH1*> (hMatchedHighPtCMUS1B->Clone("hMatchedHighPtPerCMUS1B"));
669 hMatchedHighPtPerCMUS1B->Sumw2();
670 hMatchedHighPtPerCMUS1B->Divide(hCMUS1B);
671 hMatchedHighPtPerCMUS1B->SetLineWidth(2);
672 hMatchedHighPtPerCMUS1B->SetLineColor(kRed);
673
674 CanvasName = LHCPeriod.Data() ;
675 CanvasName += "_HighPtMuons";
676 TCanvas *cHighPtMuons = new TCanvas(CanvasName.Data(),"cHighPtMuons",1200,900);
677 cHighPtMuons->SetTopMargin(0.05);
678 cHighPtMuons->SetRightMargin(0.01);
679 cHighPtMuons->SetGridy(1);
680 cHighPtMuons->cd();
681
682 hMatchedLowPtPerCMUS1B->SetTitle("");
683 hMatchedLowPtPerCMUS1B->GetYaxis()->SetTitle("Ratio per CMUS1B");
684 //hMatchedLowPtPerCMUS1B->SetMaximum(0.15);
685 hMatchedLowPtPerCMUS1B->SetMinimum(0.0001);
686 hMatchedLowPtPerCMUS1B->SetLabelSize(0.02);
687
688 hMatchedLowPtPerCMUS1B->Draw("E");
689 hMatchedHighPtPerCMUS1B->Draw("Esame");
690
691 TLegend* legcHPM = new TLegend(0.60,0.45,0.98,0.65);
692 legcHPM->SetHeader("Number of matched track per CMUS1B (include Vtx and R_{Abs} cuts) ");
693 legcHPM->AddEntry(hMatchedLowPtPerCMUS1B," p_{T} > 1 GeV/c ","l");
694 legcHPM->AddEntry(hMatchedHighPtPerCMUS1B," p_{T} > 2 GeV/c ","l");
695 legcHPM->Draw("same");
696
697 cHighPtMuons->Print(OutFileNamePDF.Data());
698 cHighPtMuons->Write();
699
700 // close merged file
701 globalFile->Close();
702
703 //--------------------------------------------- //
704 // monitor quantities run per run //
705 //--------------------------------------------- //
706
707 TH1F* hNClustersPerTrackVsRun_Mean = new TH1F("hNClustersPerTrackVsRun_Mean", "averaged number of associated clusters per track;run;<n_{clusters}>",10000,1,10000);
708 TH1F* hNClustersPerTrackVsRun_Sigma = new TH1F("hNClustersPerTrackVsRun_Sigma", "dispersion of the number of associated clusters per track;run;#sigma_{n_{clusters}}",10000,1,10000);
709 TH1F* hNChamberHitPerTrack_Mean = new TH1F("hNChamberHitPerTrack_Mean", "averaged number of chambers hit per track;run;<n_{chamber hit}>",10000,1,10000);
710 TH1F* hNChamberHitPerTrack_Sigma = new TH1F("hNChamberHitPerTrack_Sigma", "dispersion of the number of chambers hit per track;run;#sigma_{n_{chamber hit}}",10000,1,10000);
711 TH1F* hChi2_Mean = new TH1F("hChi2_Mean", "averaged normalized #chi^{2} distribution;run;<#chi^{2} / ndf>",10000,1,10000);
712 TH1F* hChi2_Sigma = new TH1F("hChi2_Sigma", "dispersion of normalized #chi^{2} distribution;run;#sigma_{#chi^{2} / ndf}",10000,1,10000);
713 TH1F* hNClustersInCh[10];
714 for (Int_t ich=0; ich<10; ich++) hNClustersInCh[ich] = new TH1F(Form("hNClustersInCh%d",ich+1), Form("averaged number of clusters in chamber %d per track;run;<n_{clusters}>",ich+1),10000,1,10000);
715 TH1F* hClusterHitMapXInCh[10];
716 for (Int_t ich=0; ich<10; ich++) hClusterHitMapXInCh[ich] = new TH1F(Form("hClusterHitMapXInCh%d",ich+1), Form("averaged cluster position distribution in chamber %d;X (cm)",ich+1),10000,1,10000);
717 TH1F* hClusterHitMapYInCh[10];
718 for (Int_t ich=0; ich<10; ich++) hClusterHitMapYInCh[ich] = new TH1F(Form("hClusterHitMapYInCh%d",ich+1), Form("averaged cluster position distribution in chamber %d;Y (cm)",ich+1),10000,1,10000);
719
720 Int_t ibin = 1;
721
722 // Are the runs stored locally or in alien?
723 Int_t isAlienFile = 0;
724 if(alienBaseDir.Contains("alien:")){
725 isAlienFile = 1;
726 alienBaseDir.ReplaceAll("alien://","");
727 }
728
729 // Loop over runs
730 for ( Int_t irun=0; irun<runs.GetEntriesFast(); irun++ ) {
731
732 TString run = ((TObjString*)runs.UncheckedAt(irun))->GetString();
733 cout << "processing run nr="<<run <<endl;
734 // get the file (or list of files) to be analyzed
735 TString command;
736 TGridResult *res = 0;
737 TObjString *objs = 0;
738
739 if(isAlienFile){
740 command = Form("find %s/ %s/AnalysisResults.root", alienBaseDir.Data(), run.Data());
741 res = gGrid->Command(command);
742 if (!res) {
743 Error("PlotQA",Form("no result for the command: %s",command.Data()));
744 return;
745 }
746 }
747 else{
748 res = new TGridResult();
749
750 if(runList){
751 objs = new TObjString(Form("%s/%s/AnalysisResults.root", alienBaseDir.Data(), run.Data()));
752 res->Add(objs);
753 }
754 else {
755 //loop over the directory to find the root files
756 void *dir = gSystem->OpenDirectory(alienBaseDir.Data());
757 TString sDirFilename;
758 Int_t iEntry=0, iFile=0;
759
760 while(kTRUE){
761 iEntry++;
762 const char* dirFilename = gSystem->GetDirEntry(dir);
763 if(!dirFilename) break;
764 sDirFilename = dirFilename;
765 if(!sDirFilename.IsDigit()) continue;
766 iFile++;
767 objs = new TObjString(Form("%s/%s/AnalysisResults.root", alienBaseDir.Data(), sDirFilename.Data()));
768 res->Add(objs);
769 }
770 }
771 }
772
773 // Loop over 'find' results and get next LFN
774 TIter nextmap(res);
775 TMap *map = 0;
776
777 //some checks
778 Int_t iLoop=0, iLoopMax=200;
779 while (kTRUE){
780
781 // get the current file url
782 if(isAlienFile){
783 map=(TMap*)nextmap();
784 if(!map) break;
785 objs = dynamic_cast<TObjString*>(map->GetValue("turl"));
786 }
787 else{
788 objs=(TObjString*)nextmap();
789 if(!objs) break;
790 }
791 //in case of infinite loop
792 iLoop++;
793 if(iLoop>iLoopMax) break;
794
795 if (!objs || !objs->GetString().Length()) {
796 Error("PlotQA","turl/obj not found for the run %s... SKIPPING", run.Data());
797 continue;
798 }
799
800 // open the outfile for this run
801 TFile *runFile = TFile::Open(objs->GetString());
802 if (!runFile || ! runFile->IsOpen()) {
803 Error("PlotQA", Form("failed to open file: %s", objs->GetName()));
804 continue;//return;
805 }
806 runFile->Cd("MUON_QA");
807
808 // get interesting histos
809 TObjArray* general1 = static_cast<TObjArray*>(runFile->FindObjectAny("general1"));
810 TObjArray* general2 = static_cast<TObjArray*>(runFile->FindObjectAny("general2"));
811 TObjArray* expert = static_cast<TObjArray*>(runFile->FindObjectAny("expert"));
812
813 if (!general1 || !general2 || !expert){
814 Error("PlotMUONQA", Form("All objects not here !!! ===> Skipping..."));
815 continue;
816 }
817 TH1* hNClustersPerTrack = static_cast<TH1*>(general1->FindObject("hNClustersPerTrack"));
818 TH1* hNChamberHitPerTrack = static_cast<TH1*>(general1->FindObject("hNChamberHitPerTrack"));
819 TH1* hChi2 = static_cast<TH1*>(general1->FindObject("hChi2"));
820 TH1* hNClustersPerCh = static_cast<TH1*>(general2->FindObject("hNClustersPerCh"));
821
822
823 TH2* hClusterHitMapInCh[10];
824 for(Int_t ich=0; ich<10; ich++) hClusterHitMapInCh[ich] = static_cast<TH2*>(expert->FindObject(Form("hClusterHitMapInCh%d",ich+1)));
825
826 // skip empty runs... not anymore ! cs !
827 if (!hNClustersPerCh) {
828 Warning("PlotQA", Form("File: %s has empty histograms !", objs->GetName()));
829 hNClustersPerTrackVsRun_Mean->SetBinContent(ibin, 0.);
830 hNClustersPerTrackVsRun_Mean->SetBinError(ibin, 1.);
831 hNClustersPerTrackVsRun_Sigma->SetBinContent(ibin, 0.);
832 hNClustersPerTrackVsRun_Sigma->SetBinError(ibin, 1.);
833 hNChamberHitPerTrack_Mean->SetBinContent(ibin, 0.);
834 hNChamberHitPerTrack_Mean->SetBinError(ibin, 1.);
835 hNChamberHitPerTrack_Sigma->SetBinContent(ibin, 0.);
836 hNChamberHitPerTrack_Sigma->SetBinError(ibin, 1.);
837 hChi2_Mean->SetBinContent(ibin, 0.);
838 hChi2_Mean->SetBinError(ibin, 1.);
839 hChi2_Sigma->SetBinContent(ibin, 0.);
840 hChi2_Sigma->SetBinError(ibin, 1.);
841 for (Int_t ich=0; ich<10; ich++) {
842 hNClustersInCh[ich]->SetBinContent(ibin,0.);
843 hNClustersInCh[ich]->SetBinError(ibin,1.);
844 hClusterHitMapXInCh[ich]->SetBinContent(ibin,0.);
845 hClusterHitMapXInCh[ich]->SetBinError(ibin,1.);
846 hClusterHitMapYInCh[ich]->SetBinContent(ibin,0.);
847 hClusterHitMapYInCh[ich]->SetBinError(ibin,1.);
848 }
849 //runFile->Close();
850 //continue;
851 }
852 else {
853 // fill monitoring plots
854 hNClustersPerTrackVsRun_Mean->SetBinContent(ibin, hNClustersPerTrack->GetMean());
855 hNClustersPerTrackVsRun_Mean->SetBinError(ibin, hNClustersPerTrack->GetMeanError());
856 hNClustersPerTrackVsRun_Sigma->SetBinContent(ibin, hNClustersPerTrack->GetRMS());
857 hNClustersPerTrackVsRun_Sigma->SetBinError(ibin, hNClustersPerTrack->GetRMSError());
858 hNChamberHitPerTrack_Mean->SetBinContent(ibin, hNChamberHitPerTrack->GetMean());
859 hNChamberHitPerTrack_Mean->SetBinError(ibin, hNChamberHitPerTrack->GetMeanError());
860 hNChamberHitPerTrack_Sigma->SetBinContent(ibin, hNChamberHitPerTrack->GetRMS());
861 hNChamberHitPerTrack_Sigma->SetBinError(ibin, hNChamberHitPerTrack->GetRMSError());
862 hChi2_Mean->SetBinContent(ibin, hChi2->GetMean());
863 hChi2_Mean->SetBinError(ibin, hChi2->GetMeanError());
864 hChi2_Sigma->SetBinContent(ibin, hChi2->GetRMS());
865 hChi2_Sigma->SetBinError(ibin, hChi2->GetRMSError());
866 for (Int_t ich=0; ich<10; ich++) {
867 hNClustersInCh[ich]->SetBinContent(ibin,hNClustersPerCh->GetBinContent(ich+1));
868 hNClustersInCh[ich]->SetBinError(ibin,hNClustersPerCh->GetBinError(ich+1));
869 hClusterHitMapXInCh[ich]->SetBinContent(ibin,hClusterHitMapInCh[ich]->GetMean(1));
870 hClusterHitMapXInCh[ich]->SetBinError(ibin,hClusterHitMapInCh[ich]->GetMeanError(1));
871 hClusterHitMapYInCh[ich]->SetBinContent(ibin,hClusterHitMapInCh[ich]->GetMean(2));
872 hClusterHitMapYInCh[ich]->SetBinError(ibin,hClusterHitMapInCh[ich]->GetMeanError(2));
873
874 }
875 }
876
877 // set labels
878 run = objs->GetString();
879 run.ReplaceAll(baseDir, "");
880 run.Remove(TString::kLeading, '/');
881 run.Remove(TString::kLeading, '0');
882 run.ReplaceAll("/AnalysisResults.root", "");
883 hNClustersPerTrackVsRun_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
884 hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());
885 hNChamberHitPerTrack_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
886 hNChamberHitPerTrack_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());
887 hChi2_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
888 hChi2_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());
889 for (Int_t ich=0; ich<10; ich++){
890 hNClustersInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
891 hClusterHitMapXInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
892 hClusterHitMapYInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
893 }
894
895 // close outfile for this run
896 runFile->Close();
897 ibin++;
898 }
899
900 delete res;
901 }
902
903 TString dirToGo = OutFileNameROOT.Data(); dirToGo+=":/";
904 gDirectory->Cd(dirToGo.Data());
905 //==================================================
906 //Display Mean and Sigma of the number of associated clusters to a track
907 TLegend *lNClusters = new TLegend(0.75,0.85,0.99,0.99);
908 lNClusters->AddEntry(hNClustersPerTrackVsRun_Mean,"clusters","PL");
909 lNClusters->AddEntry(hNChamberHitPerTrack_Mean,"chamber hit","PL");
910
911 TCanvas* cNClusters = new TCanvas("cNClusters","cNClusters",1200,900);
912 cNClusters->Divide(1,2);
913 cNClusters->cd(1);
914 //hNClustersPerTrackVsRun_Mean->SetMaximum(11);
915 hNClustersPerTrackVsRun_Mean->SetMinimum(7);
916 hNClustersPerTrackVsRun_Mean->SetStats(kFALSE);
917 hNClustersPerTrackVsRun_Mean->GetXaxis()->SetRange(1,ibin-1);
918 hNClustersPerTrackVsRun_Mean->GetXaxis()->SetNdivisions(1,kFALSE);
919 //hNClustersPerTrackVsRun_Mean->LabelsOption("u");
920 hNClustersPerTrackVsRun_Mean->SetLabelSize(0.02);
921 hNClustersPerTrackVsRun_Mean->SetTitle("averaged number of associated clusters or of the number of chamber hit per track");
922 hNClustersPerTrackVsRun_Mean->SetLineWidth(2);
923 hNClustersPerTrackVsRun_Mean->Draw("e");
924 hNChamberHitPerTrack_Mean->SetLineColor(kRed);
925 hNChamberHitPerTrack_Mean->SetLineWidth(2);
926 hNChamberHitPerTrack_Mean->Draw("esame");
927 lNClusters->Draw("same");
928
929 cNClusters->cd(2);
930 //hNClustersPerTrackVsRun_Sigma->SetMaximum(1.1);
931 hNClustersPerTrackVsRun_Sigma->SetMinimum(0.4);
932 hNClustersPerTrackVsRun_Sigma->SetStats(kFALSE);
933 hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetRange(1,ibin-1);
934 hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetNdivisions(1,kFALSE);
935 //hNClustersPerTrackVsRun_Sigma->LabelsOption("u");
936 hNClustersPerTrackVsRun_Sigma->SetLabelSize(0.02);
937 hNClustersPerTrackVsRun_Sigma->SetTitle("dispersion of the number of associated clusters or of the number of chamber hit per track");
938 hNClustersPerTrackVsRun_Sigma->SetLineWidth(2);
939 hNClustersPerTrackVsRun_Sigma->Draw("e");
940 hNChamberHitPerTrack_Sigma->SetLineWidth(2);
941 hNChamberHitPerTrack_Sigma->SetLineColor(kRed);
942 hNChamberHitPerTrack_Sigma->Draw("esame");
943 lNClusters->Draw("same");
944
945 cNClusters->Print(OutFileNamePDF.Data());
946 cNClusters->Write();
947
948
949 //==================================================
950 // Display average number of cluster per chamber
951 TLegend *lNClustersPerCh = new TLegend(0.92,0.45,0.99,0.99);
952 TCanvas* cNClustersPerCh = new TCanvas("cNClustersPerCh","cNClustersPerCh",1200,900);
953 cNClustersPerCh->cd();
954 cNClustersPerCh->SetRightMargin(0.1);
955 hNClustersInCh[0]->SetStats(kFALSE);
956 hNClustersInCh[0]->GetXaxis()->SetRange(1,ibin-1);
957 hNClustersInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
958 //hNClustersInCh[0]->LabelsOption("u");
959 hNClustersInCh[0]->SetLabelSize(0.02);
960 hNClustersInCh[0]->SetTitle("averaged number of clusters in chamber i per track");
961 hNClustersInCh[0]->SetMaximum(1.2);
962 hNClustersInCh[0]->SetMinimum(0.01);
963 for (Int_t ich=0; ich<10; ich++) {
964 hNClustersInCh[ich]->SetLineColor(ich+1+ich/9);
965 hNClustersInCh[ich]->SetLineWidth(2);
966 if (ich == 0) hNClustersInCh[ich]->Draw("e");
967 else hNClustersInCh[ich]->Draw("esame");
968 lNClustersPerCh->AddEntry(hNClustersInCh[ich],Form("ch%d",ich+1),"PL");
969 }
970 lNClustersPerCh->Draw("same");
971
972 cNClustersPerCh->Print(OutFileNamePDF.Data());
973 cNClustersPerCh->Write();
974
975 //==================================================
976 // Display average X and Y position of clusters per chamber
977 TLegend *lClusterHitMapPerCh = new TLegend(0.92,0.45,0.99,0.99);
978 TCanvas* cClusterHitMapPerCh = new TCanvas("cClusterHitMapPerCh","cClusterHitMapPerCh",1200,900);
979 cClusterHitMapPerCh->Divide(1,2);
980 cClusterHitMapPerCh->GetPad(1)->SetRightMargin(0.1);
981 cClusterHitMapPerCh->GetPad(2)->SetRightMargin(0.1);
982
983 cClusterHitMapPerCh->cd(1);
984 hClusterHitMapXInCh[0]->SetStats(kFALSE);
985 hClusterHitMapXInCh[0]->GetXaxis()->SetRange(1,ibin-1);
986 hClusterHitMapXInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
987 //hNClustersInCh[0]->LabelsOption("u");
988 hClusterHitMapXInCh[0]->SetLabelSize(0.02);
989 hClusterHitMapXInCh[0]->SetTitle("<X> of clusters - associated to a track - in chamber i");
990 hClusterHitMapXInCh[0]->SetMaximum(30);
991 hClusterHitMapXInCh[0]->SetMinimum(-30);
992 for (Int_t ich=0; ich<10; ich++) {
993 hClusterHitMapXInCh[ich]->SetLineColor(ich+1+ich/9);
994 hClusterHitMapXInCh[ich]->SetLineWidth(2);
995 if (ich == 0) hClusterHitMapXInCh[ich]->Draw("e");
996 else hClusterHitMapXInCh[ich]->Draw("esame");
997
998 lClusterHitMapPerCh->AddEntry(hClusterHitMapXInCh[ich],Form("ch%d",ich+1),"PL");
999 }
1000 lClusterHitMapPerCh->Draw("same");
1001
1002 cClusterHitMapPerCh->cd(2);
1003 hClusterHitMapYInCh[0]->SetStats(kFALSE);
1004 hClusterHitMapYInCh[0]->GetXaxis()->SetRange(1,ibin-1);
1005 hClusterHitMapYInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
1006 //hNClustersInCh[0]->LabelsOption("u");
1007 hClusterHitMapYInCh[0]->SetLabelSize(0.02);
1008 hClusterHitMapYInCh[0]->SetTitle("<Y> of clusters - associated to a track - in chamber i");
1009 hClusterHitMapYInCh[0]->SetMaximum(30);
1010 hClusterHitMapYInCh[0]->SetMinimum(-30);
1011 for (Int_t ich=0; ich<10; ich++) {
1012 hClusterHitMapYInCh[ich]->SetLineColor(ich+1+ich/9);
1013 hClusterHitMapYInCh[ich]->SetLineWidth(2);
1014 if (ich == 0) hClusterHitMapYInCh[ich]->Draw("e");
1015 else hClusterHitMapYInCh[ich]->Draw("esame");
1016 }
1017 lClusterHitMapPerCh->Draw("same");
1018
1019 cClusterHitMapPerCh->Print(OutFileNamePDF.Data());
1020 cClusterHitMapPerCh->Write();
1021
1022
1023 //==================================================
1024 // Display tracks ChiSquare
1025 TCanvas* cChi2 = new TCanvas("cChi2","cChi2",1200,900);
1026 cChi2->Divide(1,2);
1027 cChi2->cd(1);
1028 hChi2_Mean->SetStats(kFALSE);
1029 hChi2_Mean->GetXaxis()->SetRange(1,ibin-1);
1030 hChi2_Mean->GetXaxis()->SetNdivisions(1,kFALSE);
1031 //hChi2_Mean->LabelsOption("u");
1032 hChi2_Mean->SetLabelSize(0.02);
1033 hChi2_Mean->SetLineWidth(2);
1034 hChi2_Mean->Draw("e");
1035
1036 cChi2->cd(2);
1037 hChi2_Sigma->SetStats(kFALSE);
1038 hChi2_Sigma->GetXaxis()->SetRange(1,ibin-1);
1039 hChi2_Sigma->GetXaxis()->SetNdivisions(1,kFALSE);
1040 //hChi2_Sigma->LabelsOption("u");
1041 hChi2_Sigma->SetLabelSize(0.02);
1042 hChi2_Sigma->SetLineWidth(2);
1043 hChi2_Sigma->Draw("e");
1044
1045 cChi2->Print(OutFileNamePDF.Data());
1046 cChi2->Write();
1047
1048
1049 // close the PDF file
1050 c1->Print(OutFileNamePDF_close.Data());
1051 rootFileOut->Close();
1052
1053
1054 //====================================================
1055 if (PRINTSTAT){
1056 // set the format to print labels
1057 THashList* labels = hCMUS1B->GetXaxis()->GetLabels();
1058 TString format(Form("\n%%%ds %%9d",0));
1059 Int_t nRuns=0;
1060
1061 // print value for each label
1062 TObjString* label = 0x0;
1063 TIter nextLabel(labels);
1064 cout << "-------------------------------------------------" << endl;
1065 cout << "Run Number" << "\t Number of CMUS1B after Phys. Sel. " << endl ;
1066 while ((label = static_cast<TObjString*>(nextLabel()))) {
1067 nRuns++;
1068 Int_t bin = (Int_t) label->GetUniqueID();
1069 printf(format.Data(), label->String().Data(), (Int_t) hCMUS1B->GetBinContent(bin));
1070 }
1071 printf("\n========== Total #runs = %d ==============\n",nRuns);
1072 printf("\n\n");
1073
1074
1075 cout << "-------------------------------------------------" << endl;
1076 cout << "Total statistic" << endl;
1077 cout << " " << endl ;
1078 cout << "Number of NumOfCINT1B " << endl ;
1079 cout << "\t before selection " << NumOfCINT1BNoPS << "\t after selection " << NumOfCINT1BWithPS << " --> rejection = " << (Double_t) (NumOfCINT1BNoPS-NumOfCINT1BWithPS)/(NumOfCINT1BNoPS)*100. << "%" << endl ;
1080 cout << " " << endl ;
1081 cout << "Number of NumOfCMUS1B " << endl ;
1082 cout << "\t before selection " << NumOfCMUS1BNoPS << "\t after selection " << NumOfCMUS1BWithPS << " --> rejection = " << (Double_t) (NumOfCMUS1BNoPS-NumOfCMUS1BWithPS)/(NumOfCMUS1BNoPS)*100. << "%" << endl ;
1083 cout << " " << endl ;
1084 if (NumOfCSH1BNoPS>0){
1085 cout << "Number of NumOfCSH1B " << endl ;
1086 cout << "\t before selection " << NumOfCSH1BNoPS << "\t after selection " << NumOfCSH1BWithPS << " --> rejection = " << (Double_t) (NumOfCSH1BNoPS-NumOfCSH1BWithPS)/(NumOfCSH1BNoPS)*100. << "%" << endl ;
1087 cout << " " << endl ;
1088 }
1089 }
1090}