1 //--------------------------------------------------------------------------
2 // Macro for QA monitoring.
4 // In case it is not run with full aliroot, it needs the following libraries to compile:
9 // - libANALYSISalice.so
13 // TString includePath = "-I${ALICE_ROOT}/PWG3/base/ "; gSystem->SetIncludePath(includePath.Data());
15 // The macro reads results of the QA task and produce monitoring plots.
17 // Author: Philippe Pillot - SUBATECH Nantes
18 // Modified by Christophe Suire, Cynthia Hadjidakis - IPN Orsay
19 //--------------------------------------------------------------------------
21 #if !defined(__CINT__) || defined(__MAKECINT__)
23 #include <Riostream.h>
29 #include "TGridResult.h"
30 #include "THashList.h"
40 #include "TObjArray.h"
41 #include "TObjString.h"
44 #include "AliCounterCollection.h"
48 TString GetRunList(const char *runList, TObjArray *runs, TObjArray *runs2);
49 //Bool_t GetTriggerLists(const char *triggerList, TObjArray *triggersB=0, TObjArray *triggersAC=0, TObjArray *triggersE=0);
50 Bool_t GetTriggerLists(const char *triggerList, TString listFromContainer, TObjArray *triggersB=0, TObjArray *triggersAC=0, TObjArray *triggersE=0);
51 void SetCanvas(TCanvas *canvas, Int_t logy=1);
53 TH1* ProcessHisto( AliCounterCollection* counter, TString variable, TString selection, TString hName="", TString xName="", TString yName="", Int_t color=1);
54 TH2* ProcessHisto2D( AliCounterCollection* counter, TString hVariable, TString hVariable2, TString hSelection, TString hName);
56 TCanvas *ProcessCanvasTriggerContent(TObjArray *array, TH1 **histo, TH1 **histo2, TString canvasName);
57 TCanvas *ProcessCanvasRelativeTriggerContent(TObjArray *array, TH1 **histo, TString canvasName, Int_t *colorTab);
58 TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE, TH1 **hBNoPS, TH1 **hACNoPS,TH1 **hENoPS, TH1 **hBWithPS, TString canvasName, Int_t *colorInd);
59 TCanvas *ProcessCanvasTracksoverTrigger(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName);
60 TCanvas *ProcessCanvasTrackMultB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName);
61 TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName);
62 TCanvas *ProcessCanvasAsymMatched(TObjArray *triggersB, TH1 **hPosMatchedB, TH1 **hNegMatchedB, TH1 **hAllMatchedB, Int_t indTrigger, TString canvasName);
63 TCanvas *ProcessCanvasHighPtMuons(TObjArray *triggersB, TH1 **hB, TH1 **hMatchedLowPtB, TH1 **hAllMatchedHightPtB, Int_t indTrigger, TString canvasName);
64 Bool_t IsTrigger(TObjArray *array, Int_t index, TString name);
66 //--------------------------------------------------------------------------
67 void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * triggerList = 0x0, Bool_t selectPhysics = kFALSE, const char *LHCPeriod = "LHC11c", const char *QAFileName = "QAresults.root") {
69 /// Macro for QA monitoring.
70 /// Example: baseDir = "alien:///alice/cern.ch/user/p/ppillot/pp7TeV/LHC10d/MuonQA/pass1/results/".
71 /// If runList != 0x0: only the given runs will be used. Otherwise use all runs found in baseDir.
73 #if defined(__CINT__) && !defined(__MAKECINT__)
74 gSystem->Load("libTree");
75 gSystem->Load("libGeom");
76 gSystem->Load("libVMC");
77 gSystem->Load("libPhysics");
78 gSystem->Load("libSTEERBase");
79 gSystem->Load("libESD");
80 gSystem->Load("libAOD");
81 gSystem->Load("libANALYSIS");
82 gSystem->Load("libANALYSISalice");
83 gSystem->Load("libCORRFW");
84 gSystem->Load("libPWG3base");
85 gSystem->Load("libPWG3muon");
88 // Cosmetics and configuration
89 gStyle->SetFillColor(10);
90 gStyle->SetPadGridX(kTRUE);
91 gStyle->SetPadGridY(kTRUE);
92 gStyle->SetPadRightMargin(0.01);
94 Int_t colorInd[10]={1,4,2,3,6,7,12};
96 TString OutFileName = "QA_"; OutFileName += LHCPeriod;
97 TString OutFileNamePDF= OutFileName.Data(); OutFileNamePDF+= ".pdf";
98 TString OutFileNamePDF_open = OutFileNamePDF.Data(); OutFileNamePDF_open += "[";
99 TString OutFileNamePDF_close= OutFileNamePDF.Data(); OutFileNamePDF_close += "]";
100 TString OutFileNameROOT= OutFileName.Data(); OutFileNameROOT+= ".root";
104 if (0){ // Equivalent to the fast read option
105 gEnv->SetValue("XNet.ConnectTimeout",10);
106 gEnv->SetValue("XNet.RequestTimeout",10);
107 gEnv->SetValue("XNet.MaxRedirectCount",2);
108 gEnv->SetValue("XNet.ReconnectTimeout",10);
109 gEnv->SetValue("XNet.FirstConnectMaxCnt",1);
112 TH1::AddDirectory(kFALSE);
114 TString alienBaseDir = baseDir;
116 if (alienBaseDir.Contains("alien:") && !TGrid::Connect("alien://")) {
117 Error("MergeQA","cannot connect to grid");
122 //---------------------------------- //
124 //---------------------------------- //
126 TObjArray *runs = new TObjArray();
127 runs->SetOwner(kTRUE);
128 TObjArray *runs2 = new TObjArray();
129 runs2->SetOwner(kTRUE);
130 TString selectRuns = GetRunList(runList,runs,runs2);
133 TString select = selectPhysics ? "selected:yes" : "";
137 cout<<"//---------------------------------- //"<<endl;
138 cout<<"// Get global counter //"<<endl;
139 cout<<"//---------------------------------- //"<<endl;
141 TFile *globalFile = TFile::Open(Form("%s/%s", baseDir,QAFileName));
142 if (!globalFile || ! globalFile->IsOpen()) {
143 Error("PlotQA", "failed to open file: %s/%s", baseDir, QAFileName);
146 globalFile->Cd("MUON_QA");
151 AliCounterCollection* eventCounters = static_cast<AliCounterCollection*>(globalFile->FindObjectAny("eventCounters"));
152 AliCounterCollection* trackCounters = static_cast<AliCounterCollection*>(globalFile->FindObjectAny("trackCounters"));
153 if (!runList) selectRuns += trackCounters->GetKeyWords("run");
156 cout<<"//---------------------------------- //"<<endl;
157 cout<<"// Trigger selection //"<<endl;
158 cout<<"//---------------------------------- //"<<endl;
160 TObjArray *triggersB, *triggersAC, *triggersE;
161 triggersB = new TObjArray();
162 triggersB->SetOwner();
163 triggersAC = new TObjArray();
164 triggersAC->SetOwner();
165 triggersE = new TObjArray();
166 triggersE->SetOwner();
168 TString listFromContainer = eventCounters->GetKeyWords("trigger");
169 Bool_t success = GetTriggerLists(triggerList, listFromContainer, triggersB, triggersAC, triggersE);
173 cout<<"//---------------------------------- //"<<endl;
174 cout<<"// Trigger plots //"<<endl;
175 cout<<"//---------------------------------- //"<<endl;
177 //plot all trigger from event counters
178 TString CanvasName = "cAll";
179 TCanvas *cAll = new TCanvas(CanvasName.Data(),CanvasName.Data());
181 //TH2* hAll = (TH2*) ProcessHisto2D(eventCounters, "trigger", "run", Form("run:any/%s",select.Data()) , "");
182 TH2* hAll = (TH2*) ProcessHisto2D(eventCounters, "trigger", "run", "run:any" , "");
186 //declare a default canvas c1
188 TCanvas *c1 = new TCanvas(CanvasName.Data(),CanvasName.Data());
192 TH1* hBWithPS[10]={};
194 TH1* hTriggerB[10], *hTrackerB[10], *hMatchedB[10], *hAllTracksB[10], *hMatchedLowPtB[10], *hMatchedHighPtB[10];
195 TH1* hMatchedLowPtBNoPS[10], *hMatchedHighPtBNoPS[10];
196 TH1* hPosMatchedB[10], *hNegMatchedB[10], *hAllMatchedB[10];
197 TH1 *hACWithPS[10]={};
199 TH1 *hEWithPS[10]={};
202 if(triggersB->GetEntriesFast()>=10){
203 cout<<"Too many triggers"<<endl;
207 //Loop on trigger (last is all triggers, then for each defined trigger)
208 for(Int_t i = 0; i < triggersB->GetEntriesFast(); i++){
210 TString histoNameBase = "h_trig", histoName;
213 TString triggerName = ( (TObjString*) triggersB->At(i) )->GetString();
214 // Histo trigger without Phys. Sel.
215 selection = Form("trigger:%s/%s", triggerName.Data(), selectRuns.Data());
216 cout<<selection<<endl;
217 histoName = histoNameBase;
218 histoName += "BNoPS";
219 hBNoPS[i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName, "", "Trigger content w/o Phys. Sel.", colorInd[i]);
220 // Histo trigger with Phys. Sel.
221 selection = Form("trigger:%s/%s/selected:yes", triggerName.Data(), selectRuns.Data());
222 histoName = histoNameBase;
223 histoName += "BWithPS";
224 hBWithPS[i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName, "", "Trigger content w/ Phys. Sel.", colorInd[i]);
225 // Histo trigger : Phys. Sel. is selected or not depending on the macro arguments
226 selection = Form("trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
227 histoName = histoNameBase;
229 hB[i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
231 TString triggerNameAC = ( (TObjString*) triggersAC->At(i) )->GetString();
232 // Histo trigger without Phys. Sel. AC
233 histoName = histoNameBase;
234 histoName += "ACNoPS";
235 selection = Form("trigger:%s/%s", triggerNameAC.Data(), selectRuns.Data());
236 hACNoPS[i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
237 // Histo trigger with Phys. Sel. AC
238 selection = Form("trigger:%s/%s/selected:yes", triggerNameAC.Data(), selectRuns.Data());
239 histoName = histoNameBase;
240 histoName += "ACWithPS";
241 hACWithPS[i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
243 TString triggerNameE = ( (TObjString*) triggersE->At(i) )->GetString();
244 // Histo trigger without Phys. Sel. E
245 selection = Form("trigger:%s/%s", triggerNameE.Data(), selectRuns.Data());
246 histoName = histoNameBase;
247 histoName += "ENoPS";
248 hENoPS[i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
249 // Histo trigger with Phys. Sel. E
250 selection = Form("trigger:%s/%s/selected:yes", triggerNameE.Data(), selectRuns.Data());
251 histoName = histoNameBase;
252 histoName += "EWithPS";
253 hEWithPS[i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
255 // Histo tracking : Phys. Sel. is selected or not depending on the macro arguments
256 selection = Form("track:triggeronly/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
257 hTriggerB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
259 selection = Form("track:trackeronly/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
260 hTrackerB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
262 selection = Form("track:matched/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
263 hMatchedB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
265 selection = Form("trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
266 hAllTracksB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
268 selection = Form("track:matched/trigger:%s/%s/%s/pt:low/acc:in", triggerName.Data() ,selectRuns.Data(), select.Data());
269 hMatchedLowPtB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
271 selection = Form("track:matched/trigger:%s/%s/%s/pt:high/acc:in", triggerName.Data() ,selectRuns.Data(), select.Data());
272 hMatchedHighPtB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
274 selection = Form("track:matched/trigger:%s/%s/pt:low/acc:in", triggerName.Data() ,selectRuns.Data());
275 hMatchedLowPtBNoPS[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
277 selection = Form("track:matched/trigger:%s/%s/pt:high/acc:in", triggerName.Data() ,selectRuns.Data());
278 hMatchedHighPtBNoPS[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
280 selection = Form("track:matched/trigger:%s/%s/charge:pos/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
281 hPosMatchedB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
283 selection = Form("track:matched/trigger:%s/%s/charge:neg/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
284 hNegMatchedB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
286 selection = Form("track:matched/trigger:%s/%s/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
287 hAllMatchedB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
290 //if there is not B triggers just stop now
291 Int_t count_trigger=0;
292 for(Int_t i = 0; i < triggersB->GetEntriesFast(); i++){
293 count_trigger += hBNoPS[i]->GetEntries();
295 if(count_trigger<=0) return;
298 Int_t NumOfBNoPS[10];
299 Int_t NumOfBWithPS[10];
300 Int_t NumOfACNoPS[10];
301 Int_t NumOfENoPS[10];
302 Int_t NumOfACWithPS[10];
303 Int_t NumOfEWithPS[10];
305 for(Int_t i = 0; i < triggersB->GetEntriesFast(); i++){
306 NumOfBNoPS[i] = hBNoPS[i]->Integral();
307 NumOfBWithPS[i] = hBWithPS[i]->Integral();
308 NumOfACNoPS[i] = hACNoPS[i]->Integral();
309 NumOfENoPS[i] = hENoPS[i]->Integral();
310 NumOfACWithPS[i] = hACWithPS[i]->Integral();
311 NumOfEWithPS[i] = hEWithPS[i]->Integral();
315 cout<<"//==================================================================================="<<endl;
316 cout<<"// Put all plots in a ps file, easier to publish (Twiki)"<<endl;
317 cout<<"//==================================================================================="<<endl;
319 c1->Print(OutFileNamePDF_open.Data());
320 TFile *rootFileOut = TFile::Open(OutFileNameROOT.Data(),"RECREATE");
321 cAll->Print(OutFileNamePDF.Data());
325 cout<<"//==================================================================================="<<endl;
326 cout<<"// new canvas with the total number of trigger with and without Phys. Sel."<<endl;
327 cout<<"//==================================================================================="<<endl;
329 TCanvas *cTriggerContent = ProcessCanvasTriggerContent(triggersB, hBNoPS, hBWithPS, "TriggerContent");
330 cTriggerContent->Draw();
331 cTriggerContent->Print(OutFileNamePDF.Data());
332 cTriggerContent->Write();
334 cout<<"//==================================================================================="<<endl;
335 cout<<"// new canvas with the relative content of each trigger w/o physics selection"<<endl;
336 cout<<"//==================================================================================="<<endl;
338 TCanvas *cRelativeTriggerContent = ProcessCanvasRelativeTriggerContent(triggersB, hBNoPS, "RelativeTriggerContent", colorInd);
339 cRelativeTriggerContent->Draw();
340 cRelativeTriggerContent->Print(OutFileNamePDF.Data());
341 cRelativeTriggerContent->Write();
343 cout<<"//==================================================================================="<<endl;
344 cout<<"// new canvas with effect from physics selection for each trigger and background trigger "<<endl;
345 cout<<"//==================================================================================="<<endl;
347 TCanvas *cPhysSelCut = ProcessCanvasPhysSelCut(triggersB, triggersAC, triggersE, hBNoPS, hACNoPS, hENoPS, hBWithPS, "PhysSelCutOnCollTrigger", colorInd);
349 cPhysSelCut->Print(OutFileNamePDF.Data());
350 cPhysSelCut->Write();
352 cout<<"//==================================================================================="<<endl;
353 cout<<"// Ratio of tracks over trigger type (3 canvases) "<<endl;
354 cout<<"//==================================================================================="<<endl;
356 //Print a canvas per trigger type
357 TCanvas *cTracksoverTrigger[10];
358 TCanvas* cTrackMultB[10];
359 TCanvas* cRatioTrackB[10];
365 for(k = 0; k < triggersB->GetEntriesFast(); k++){
366 //skip sum of all triggers
367 if(k == (triggersB->GetEntriesFast()-1)) continue;
369 if( !IsTrigger(triggersB, k, "INT") && !IsTrigger(triggersB, k, "MUS" ) && !IsTrigger(triggersB, k, "ANY") && !IsTrigger(triggersB,k,"CMB") ) continue;
371 cTracksoverTrigger[k]= ProcessCanvasTracksoverTrigger(triggersB, hB, hTrackerB, hTriggerB, hMatchedB, hAllTracksB, k, "RatioTrackTypes");
372 cTracksoverTrigger[k]->Draw();
373 cTracksoverTrigger[k]->Print(OutFileNamePDF.Data());
374 cTracksoverTrigger[k]->Write();
376 cTrackMultB[k]= ProcessCanvasTrackMultB(triggersB, hB, hTrackerB, hTriggerB, hMatchedB, hAllTracksB, k, "TrackMult");
377 cTrackMultB[k]->Draw();
378 cTrackMultB[k]->Print(OutFileNamePDF.Data());
379 cTrackMultB[k]->Write();
381 cRatioTrackB[k]= ProcessCanvasRatioTrackB(triggersB, hB, hTrackerB, hTriggerB, hMatchedB, hAllTracksB, k, "RatioTrackB");
382 cRatioTrackB[k]->Draw();
383 cRatioTrackB[k]->Print(OutFileNamePDF.Data());
384 cRatioTrackB[k]->Write();
388 cout<<"//===================================================="<<endl;
389 cout<<"// Draw matched tracks asymmetry for mus type trigger "<<endl;
390 cout<<"//===================================================="<<endl;
392 //Print a canvas per trigger type
393 TCanvas *cAsymMatched[10];
396 for(k = 0; k < triggersB->GetEntriesFast(); k++){
397 //skip sum of all triggers
398 if(k == (triggersB->GetEntriesFast()-1)) continue;
400 if( !IsTrigger(triggersB, k, "MUS" ) ) continue;
402 cAsymMatched[k]= ProcessCanvasAsymMatched(triggersB, hPosMatchedB, hNegMatchedB, hAllMatchedB, k, "AsymMatched");
403 cAsymMatched[k]->Draw();
404 cAsymMatched[k]->Print(OutFileNamePDF.Data());
405 cAsymMatched[k]->Write();
408 cout<<"//=================================================="<<endl;
409 cout<<"// Draw high pt tracks per trigger"<<endl;
410 cout<<"//=================================================="<<endl;
412 //Print a canvas per trigger type
413 TCanvas *cHighPtMuons[10];
416 for(k = 0; k < triggersB->GetEntriesFast(); k++){
417 //skip sum of all triggers
418 if(k == (triggersB->GetEntriesFast()-1)) continue;
420 if( !IsTrigger(triggersB, k, "MUS" ) ) continue;
422 cHighPtMuons[k]= ProcessCanvasHighPtMuons(triggersB, hB, hMatchedLowPtB, hMatchedHighPtB, k, "HighPtMuons");
423 cHighPtMuons[k]->Draw();
424 cHighPtMuons[k]->Print(OutFileNamePDF.Data());
425 cHighPtMuons[k]->Write();
431 //===================================================================================
432 //Print out the number of trigger without and with Phys. Sel.
433 //===================================================================================
435 cout << endl << endl;
436 //====================================================
438 // set the format to print labels
439 THashList* labels = hBWithPS[kCMUS]->GetXaxis()->GetLabels();
440 TString format(Form("\n%%%ds %%9d",0));
443 // print value for each label
444 TObjString* label = 0x0;
445 TIter nextLabel(labels);
446 cout << "-------------------------------------------------" << endl;
447 cout << "Run Number" << "\t Number of "<< ( (TObjString*) triggersB->At(kCMUS) )->GetString()<<" after Phys. Sel. " << endl ;
448 while ((label = static_cast<TObjString*>(nextLabel()))) {
450 Int_t bin = (Int_t) label->GetUniqueID();
451 printf(format.Data(), label->String().Data(), (Int_t) hBWithPS[kCMUS]->GetBinContent(bin));
453 printf("\n========== Total #runs = %d ==============\n",nRuns);
457 cout << "-------------------------------------------------" << endl;
458 cout << "Total statistic" << endl;
459 cout << " " << endl ;
461 cout << "-------------------------------------------------------------------" << endl;
462 cout<<"Number of triggers w/o Phys. Sel./ w/ Phys. Sel (Phys. Sel. cut in %)"<<endl;
463 for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
464 TString triggerNameB = ( (TObjString*) triggersB->At(i) )->GetString();
465 TString triggerNameAC = ( (TObjString*) triggersAC->At(i) )->GetString();
466 TString triggerNameE = ( (TObjString*) triggersE->At(i) )->GetString();
468 Int_t cutinpercent = 0;
469 printf("%10s %30s %30s\n",triggerNameB.Data(),triggerNameAC.Data(),triggerNameE.Data());
470 if(NumOfBNoPS[i]) cutinpercent = (Int_t) ((Double_t)(NumOfBNoPS[i]-NumOfBWithPS[i])/(NumOfBNoPS[i])*100.);
471 printf("%5.2e / %.2e (%d%%)", (Double_t) NumOfBNoPS[i],(Double_t) NumOfBWithPS[i],cutinpercent);
473 if(NumOfACNoPS[i]) cutinpercent = (Int_t) ((Double_t)(NumOfACNoPS[i]-NumOfACWithPS[i])/(NumOfACNoPS[i])*100.);
474 printf("%15.2e / %.2e (%d%%)", (Double_t)NumOfACNoPS[i],(Double_t)NumOfACWithPS[i],cutinpercent);
476 if(NumOfENoPS[i]) cutinpercent = (Int_t) ((Double_t)(NumOfENoPS[i]-NumOfEWithPS[i])/(NumOfENoPS[i])*100.);
477 printf("%15.2e / %.2e (%d%%)\n", (Double_t)NumOfENoPS[i],(Double_t)NumOfEWithPS[i],cutinpercent);
487 //--------------------------------------------- //
488 // monitor quantities run per run //
489 //--------------------------------------------- //
490 TH1F* hTriggerCutVsRun[2], *hTriggerCutWidthVsRun[2];
491 for ( Int_t ihisto=0; ihisto<2; ++ihisto ) {
492 TString cutName = ( ihisto == 0 ) ? "Lpt" : "Hpt";
493 hTriggerCutVsRun[ihisto] = new TH1F(Form("hTriggerCutVsRun%s", cutName.Data()), Form("Trigger %s cut per run", cutName.Data()), 10000,1,10000);
494 hTriggerCutWidthVsRun[ihisto] = (TH1F*)hTriggerCutVsRun[ihisto]->Clone(Form("hTriggerCutWidthVsRun%s", cutName.Data()));
496 TF1* fitMatchTrig = new TF1("fitMatchTrig","[3] + [0] * ( 1. + TMath::Erf((x - [1]) / [2]))", 0.1, 6.);
497 TH1F* hNClustersPerTrackVsRun_Mean = new TH1F("hNClustersPerTrackVsRun_Mean", "averaged number of associated clusters per track;run;<n_{clusters}>",10000,1,10000);
498 TH1F* hNClustersPerTrackVsRun_Sigma = new TH1F("hNClustersPerTrackVsRun_Sigma", "dispersion of the number of associated clusters per track;run;#sigma_{n_{clusters}}",10000,1,10000);
499 TH1F* hNChamberHitPerTrack_Mean = new TH1F("hNChamberHitPerTrack_Mean", "averaged number of chambers hit per track;run;<n_{chamber hit}>",10000,1,10000);
500 TH1F* hNChamberHitPerTrack_Sigma = new TH1F("hNChamberHitPerTrack_Sigma", "dispersion of the number of chambers hit per track;run;#sigma_{n_{chamber hit}}",10000,1,10000);
501 TH1F* hChi2_Mean = new TH1F("hChi2_Mean", "averaged normalized #chi^{2} distribution;run;<#chi^{2} / ndf>",10000,1,10000);
502 TH1F* hChi2_Sigma = new TH1F("hChi2_Sigma", "dispersion of normalized #chi^{2} distribution;run;#sigma_{#chi^{2} / ndf}",10000,1,10000);
503 TH1F* hNClustersInCh[10];
504 for (Int_t ich=0; ich<10; ich++){
505 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);
507 TH1F* hClusterHitMapXInCh[10];
508 for (Int_t ich=0; ich<10; ich++){
509 hClusterHitMapXInCh[ich] = new TH1F(Form("hClusterHitMapXInCh%d",ich+1), Form("averaged cluster position distribution in chamber %d;X (cm)",ich+1),10000,1,10000);
511 TH1F* hClusterHitMapYInCh[10];
512 for (Int_t ich=0; ich<10; ich++){
513 hClusterHitMapYInCh[ich] = new TH1F(Form("hClusterHitMapYInCh%d",ich+1), Form("averaged cluster position distribution in chamber %d;Y (cm)",ich+1),10000,1,10000);
517 // Are the runs stored locally or in alien?
518 Int_t isAlienFile = 0;
519 if(alienBaseDir.Contains("alien:")){
521 alienBaseDir.ReplaceAll("alien://","");
523 cout<<"============================================================"<<endl;
524 cout<< "Monitoring quantities run per run: loop over "<<runs->GetEntriesFast()<<" runs."<<endl;
525 cout<<" directory = "<<alienBaseDir.Data()<<endl;
526 cout<<"============================================================"<<endl;
528 for ( Int_t irun=0; irun<runs->GetEntriesFast(); irun++ ) {
530 TString run = ((TObjString*)runs->UncheckedAt(irun))->GetString();
531 TString run2 = ((TObjString*)runs2->UncheckedAt(irun))->GetString();
532 // get the file (or list of files) to be analyzed
534 TGridResult *res = 0;
535 TObjString *objs = 0;
538 command = Form("find %s/ %s/%s", alienBaseDir.Data(), run.Data(), QAFileName);
539 res = gGrid->Command(command);
541 Error("PlotMUONQApp","no result for the command: %s",command.Data());
546 res = new TGridResult();
549 objs = new TObjString(Form("%s/%s/%s", alienBaseDir.Data(), run2.Data(), QAFileName));
553 //loop over the directory to find the root files
554 void *dir = gSystem->OpenDirectory(alienBaseDir.Data());
555 TString sDirFilename;
556 Int_t iEntry=0, iFile=0;
559 const char* dirFilename = gSystem->GetDirEntry(dir);
560 if(!dirFilename) break;
561 sDirFilename = dirFilename;
562 if(!sDirFilename.IsDigit()) continue;
564 objs = new TObjString(Form("%s/%s/%s", alienBaseDir.Data(), sDirFilename.Data(), QAFileName));
570 // Loop over 'find' results and get next LFN
575 Int_t iLoop=0, iLoopMax=200;
578 // get the current file url
580 map=(TMap*)nextmap();
582 objs = dynamic_cast<TObjString*>(map->GetValue("turl"));
585 objs=(TObjString*)nextmap();
588 //in case of infinite loop
590 if(iLoop>iLoopMax) break;
592 if (!objs || !objs->GetString().Length()) {
593 Error("PlotMUONQApp","turl/obj not found for the run %s... SKIPPING", run.Data());
597 // open the outfile for this run
598 TFile *runFile = TFile::Open(objs->GetString());
599 if (!runFile || ! runFile->IsOpen()) {
600 Error("PlotMUONQApp","failed to open file: %s", objs->GetName());
603 runFile->Cd("MUON_QA");
605 // get interesting histos
606 TObjArray* general1 = static_cast<TObjArray*>(runFile->FindObjectAny("general1"));
607 TObjArray* general2 = static_cast<TObjArray*>(runFile->FindObjectAny("general2"));
608 TObjArray* expert = static_cast<TObjArray*>(runFile->FindObjectAny("expert"));
610 if (!general1 || !general2 || !expert){
611 Error("PlotMUONQApp","All objects not here !!! ===> Skipping...for %s",objs->GetName());
615 TH1* hNClustersPerTrack = static_cast<TH1*>(general1->FindObject("hNClustersPerTrack"));
616 TH1* hNChamberHitPerTrack = static_cast<TH1*>(general1->FindObject("hNChamberHitPerTrack"));
617 TH1* hChi2 = static_cast<TH1*>(general1->FindObject("hChi2"));
618 TH1* hNClustersPerCh = static_cast<TH1*>(general2->FindObject("hNClustersPerCh"));
619 TH1* hPtDistrib = static_cast<TH1*>(general1->FindObject("hPt"));
620 TH1* hPtDistribLpt = static_cast<TH1*>(general1->FindObject("hPtMatchLpt"));
621 TH1* hPtDistribHpt = static_cast<TH1*>(general1->FindObject("hPtMatchHpt"));
622 if ( hPtDistrib && hPtDistribLpt && hPtDistribHpt ) {
623 if ( hPtDistrib->GetSumw2N() == 0 ) hPtDistrib->Sumw2();
624 TH1* histoMatch[2] = {hPtDistribLpt, hPtDistribHpt};
625 for ( Int_t ihisto=0; ihisto<2; ++ihisto ) {
626 if ( histoMatch[ihisto]->GetSumw2N() == 0 ) histoMatch[ihisto]->Sumw2();
627 if ( histoMatch[ihisto]->GetEntries() == 0 ) continue;
628 histoMatch[ihisto]->Divide(hPtDistrib);
629 Double_t minEff = 99999., maxEff = -1.;
630 Double_t ptMinFit = 0.1;
631 Double_t ptMaxFit = 6.;
632 Int_t ptBinLow = histoMatch[ihisto]->GetXaxis()->FindBin(ptMinFit);
633 Int_t ptBinHigh = histoMatch[ihisto]->GetXaxis()->FindBin(ptMaxFit);
634 for ( Int_t currBin=ptBinLow; currBin<=ptBinHigh; currBin++ ) {
635 Double_t currEff = histoMatch[ihisto]->GetBinContent(currBin);
636 Double_t currPt = histoMatch[ihisto]->GetXaxis()->GetBinCenter(currBin);
637 if ( currPt < 1.5 && minEff > currEff ) {
641 if ( currPt > 0.5 && maxEff < currEff ) {
645 } // loop on histo bins
646 fitMatchTrig->SetParameters(0.5, 0.5, 0.8, 0.2);
647 fitMatchTrig->SetParLimits(0,0.,1.);
648 fitMatchTrig->SetParLimits(1,0.,5.);
649 fitMatchTrig->SetParLimits(2,0.,5.);
650 fitMatchTrig->SetParLimits(3,0.,0.5);
651 histoMatch[ihisto]->Fit(fitMatchTrig,"RQ0","",ptMinFit,ptMaxFit);
652 Double_t ptCut = fitMatchTrig->GetParameter(1);
653 Double_t ptCutErr = fitMatchTrig->GetParError(1);
654 Double_t ptCutWidth = fitMatchTrig->GetParameter(2);
655 if ( ptCut < 0 || ptCut > 10. ) {
656 ptCut = ptCutErr = ptCutWidth = 0.;
658 hTriggerCutVsRun[ihisto]->SetBinContent(ibin, ptCut);
659 hTriggerCutVsRun[ihisto]->SetBinError(ibin, ptCutErr);
660 hTriggerCutWidthVsRun[ihisto]->SetBinContent(ibin, ptCut);
661 hTriggerCutWidthVsRun[ihisto]->SetBinError(ibin, ptCutWidth);
662 } // loop on match histos
664 TH2* hClusterHitMapInCh[10];
665 for(Int_t ich=0; ich<10; ich++) hClusterHitMapInCh[ich] = static_cast<TH2*>(expert->FindObject(Form("hClusterHitMapInCh%d",ich+1)));
667 // skip empty runs... not anymore ! cs !
668 if (!hNClustersPerCh) {
669 Warning("PlotMUONQApp","File: %s has empty histograms !", objs->GetName());
670 hNClustersPerTrackVsRun_Mean->SetBinContent(ibin, 0.);
671 hNClustersPerTrackVsRun_Mean->SetBinError(ibin, 1.);
672 hNClustersPerTrackVsRun_Sigma->SetBinContent(ibin, 0.);
673 hNClustersPerTrackVsRun_Sigma->SetBinError(ibin, 1.);
674 hNChamberHitPerTrack_Mean->SetBinContent(ibin, 0.);
675 hNChamberHitPerTrack_Mean->SetBinError(ibin, 1.);
676 hNChamberHitPerTrack_Sigma->SetBinContent(ibin, 0.);
677 hNChamberHitPerTrack_Sigma->SetBinError(ibin, 1.);
678 hChi2_Mean->SetBinContent(ibin, 0.);
679 hChi2_Mean->SetBinError(ibin, 1.);
680 hChi2_Sigma->SetBinContent(ibin, 0.);
681 hChi2_Sigma->SetBinError(ibin, 1.);
682 for (Int_t ich=0; ich<10; ich++) {
683 hNClustersInCh[ich]->SetBinContent(ibin,0.);
684 hNClustersInCh[ich]->SetBinError(ibin,1.);
685 hClusterHitMapXInCh[ich]->SetBinContent(ibin,0.);
686 hClusterHitMapXInCh[ich]->SetBinError(ibin,1.);
687 hClusterHitMapYInCh[ich]->SetBinContent(ibin,0.);
688 hClusterHitMapYInCh[ich]->SetBinError(ibin,1.);
694 // fill monitoring plots
695 hNClustersPerTrackVsRun_Mean->SetBinContent(ibin, hNClustersPerTrack->GetMean());
696 hNClustersPerTrackVsRun_Mean->SetBinError(ibin, hNClustersPerTrack->GetMeanError());
697 hNClustersPerTrackVsRun_Sigma->SetBinContent(ibin, hNClustersPerTrack->GetRMS());
698 hNClustersPerTrackVsRun_Sigma->SetBinError(ibin, hNClustersPerTrack->GetRMSError());
699 hNChamberHitPerTrack_Mean->SetBinContent(ibin, hNChamberHitPerTrack->GetMean());
700 hNChamberHitPerTrack_Mean->SetBinError(ibin, hNChamberHitPerTrack->GetMeanError());
701 hNChamberHitPerTrack_Sigma->SetBinContent(ibin, hNChamberHitPerTrack->GetRMS());
702 hNChamberHitPerTrack_Sigma->SetBinError(ibin, hNChamberHitPerTrack->GetRMSError());
703 hChi2_Mean->SetBinContent(ibin, hChi2->GetMean());
704 hChi2_Mean->SetBinError(ibin, hChi2->GetMeanError());
705 hChi2_Sigma->SetBinContent(ibin, hChi2->GetRMS());
706 hChi2_Sigma->SetBinError(ibin, hChi2->GetRMSError());
707 for (Int_t ich=0; ich<10; ich++) {
708 hNClustersInCh[ich]->SetBinContent(ibin,hNClustersPerCh->GetBinContent(ich+1));
709 hNClustersInCh[ich]->SetBinError(ibin,hNClustersPerCh->GetBinError(ich+1));
710 hClusterHitMapXInCh[ich]->SetBinContent(ibin,hClusterHitMapInCh[ich]->GetMean(1));
711 hClusterHitMapXInCh[ich]->SetBinError(ibin,hClusterHitMapInCh[ich]->GetMeanError(1));
712 hClusterHitMapYInCh[ich]->SetBinContent(ibin,hClusterHitMapInCh[ich]->GetMean(2));
713 hClusterHitMapYInCh[ich]->SetBinError(ibin,hClusterHitMapInCh[ich]->GetMeanError(2));
718 run = objs->GetString();
719 run.ReplaceAll(Form("/%s",QAFileName), "");
720 run.ReplaceAll(alienBaseDir, "");
721 run.Remove(TString::kLeading, '/');
722 run.Remove(TString::kLeading, '0');
723 hNClustersPerTrackVsRun_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
724 hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());
725 hNChamberHitPerTrack_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
726 hNChamberHitPerTrack_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());
727 hChi2_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
728 hChi2_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());
729 for (Int_t ich=0; ich<10; ich++){
730 hNClustersInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
731 hClusterHitMapXInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
732 hClusterHitMapYInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
735 // close outfile for this run
744 hNClustersPerTrackVsRun_Mean->LabelsOption("a");
745 hNClustersPerTrackVsRun_Sigma->LabelsOption("a");
746 hNChamberHitPerTrack_Mean->LabelsOption("a");
747 hNChamberHitPerTrack_Sigma->LabelsOption("a");
748 hChi2_Mean->LabelsOption("a");
749 hChi2_Sigma->LabelsOption("a");
751 for(Int_t ich=0; ich<10; ich++){
752 hNClustersInCh[ich]->LabelsOption("a");
753 hClusterHitMapXInCh[ich]->LabelsOption("a");
754 hClusterHitMapYInCh[ich]->LabelsOption("a");
757 TString dirToGo = OutFileNameROOT.Data(); dirToGo+=":/";
758 gDirectory->Cd(dirToGo.Data());
759 //==================================================
760 //Display Mean and Sigma of the number of associated clusters to a track
761 TLegend *lNClusters = new TLegend(0.75,0.85,0.99,0.99);
762 lNClusters->AddEntry(hNClustersPerTrackVsRun_Mean,"clusters","PL");
763 lNClusters->AddEntry(hNChamberHitPerTrack_Mean,"chamber hit","PL");
765 TCanvas* cNClusters = new TCanvas("cNClusters","cNClusters",1200,900);
766 cNClusters->Divide(1,2);
768 //hNClustersPerTrackVsRun_Mean->SetMaximum(11);
769 hNClustersPerTrackVsRun_Mean->SetMinimum(7);
770 hNClustersPerTrackVsRun_Mean->SetStats(kFALSE);
771 hNClustersPerTrackVsRun_Mean->GetXaxis()->SetRange(1,ibin-1);
772 hNClustersPerTrackVsRun_Mean->GetXaxis()->SetNdivisions(1,kFALSE);
773 //hNClustersPerTrackVsRun_Mean->LabelsOption("u");
774 hNClustersPerTrackVsRun_Mean->SetLabelSize(0.04);
775 hNClustersPerTrackVsRun_Mean->SetTitle("averaged number of associated clusters or of the number of chamber hit per track");
776 hNClustersPerTrackVsRun_Mean->SetLineWidth(2);
777 hNClustersPerTrackVsRun_Mean->Draw("e");
778 hNChamberHitPerTrack_Mean->SetLineColor(kRed);
779 hNChamberHitPerTrack_Mean->SetLineWidth(2);
780 hNChamberHitPerTrack_Mean->Draw("esame");
781 lNClusters->Draw("same");
784 //hNClustersPerTrackVsRun_Sigma->SetMaximum(1.1);
785 hNClustersPerTrackVsRun_Sigma->SetMinimum(0.4);
786 hNClustersPerTrackVsRun_Sigma->SetStats(kFALSE);
787 hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetRange(1,ibin-1);
788 hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetNdivisions(1,kFALSE);
789 //hNClustersPerTrackVsRun_Sigma->LabelsOption("u");
790 hNClustersPerTrackVsRun_Sigma->SetLabelSize(0.04);
791 hNClustersPerTrackVsRun_Sigma->SetTitle("dispersion of the number of associated clusters or of the number of chamber hit per track");
792 hNClustersPerTrackVsRun_Sigma->SetLineWidth(2);
793 hNClustersPerTrackVsRun_Sigma->Draw("e");
794 hNChamberHitPerTrack_Sigma->SetLineWidth(2);
795 hNChamberHitPerTrack_Sigma->SetLineColor(kRed);
796 hNChamberHitPerTrack_Sigma->Draw("esame");
797 lNClusters->Draw("same");
799 cNClusters->Print(OutFileNamePDF.Data());
803 //==================================================
804 // Display average number of cluster per chamber
805 TLegend *lNClustersPerCh = new TLegend(0.92,0.45,0.99,0.99);
806 TCanvas* cNClustersPerCh = new TCanvas("cNClustersPerCh","cNClustersPerCh",1200,900);
807 cNClustersPerCh->cd();
808 cNClustersPerCh->SetRightMargin(0.1);
809 hNClustersInCh[0]->SetStats(kFALSE);
810 hNClustersInCh[0]->GetXaxis()->SetRange(1,ibin-1);
811 hNClustersInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
812 //hNClustersInCh[0]->LabelsOption("u");
813 hNClustersInCh[0]->SetLabelSize(0.02);
814 hNClustersInCh[0]->SetTitle("averaged number of clusters in chamber i per track");
815 hNClustersInCh[0]->SetMaximum(1.2);
816 hNClustersInCh[0]->SetMinimum(0.01);
817 for (Int_t ich=0; ich<10; ich++) {
818 hNClustersInCh[ich]->SetLineColor(ich+1+ich/9);
819 hNClustersInCh[ich]->SetLineWidth(2);
820 if (ich == 0) hNClustersInCh[ich]->Draw("e");
821 else hNClustersInCh[ich]->Draw("esame");
822 lNClustersPerCh->AddEntry(hNClustersInCh[ich],Form("ch%d",ich+1),"PL");
824 lNClustersPerCh->Draw("same");
826 cNClustersPerCh->Print(OutFileNamePDF.Data());
827 cNClustersPerCh->Write();
829 //==================================================
830 // Display average X and Y position of clusters per chamber
831 TLegend *lClusterHitMapPerCh = new TLegend(0.92,0.45,0.99,0.99);
832 TCanvas* cClusterHitMapPerCh = new TCanvas("cClusterHitMapPerCh","cClusterHitMapPerCh",1200,900);
833 cClusterHitMapPerCh->Divide(1,2);
834 cClusterHitMapPerCh->GetPad(1)->SetRightMargin(0.1);
835 cClusterHitMapPerCh->GetPad(2)->SetRightMargin(0.1);
837 cClusterHitMapPerCh->cd(1);
838 hClusterHitMapXInCh[0]->SetStats(kFALSE);
839 hClusterHitMapXInCh[0]->GetXaxis()->SetRange(1,ibin-1);
840 hClusterHitMapXInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
841 //hNClustersInCh[0]->LabelsOption("u");
842 hClusterHitMapXInCh[0]->SetLabelSize(0.04);
843 hClusterHitMapXInCh[0]->SetTitle("<X> of clusters - associated to a track - in chamber i");
844 hClusterHitMapXInCh[0]->SetMaximum(30);
845 hClusterHitMapXInCh[0]->SetMinimum(-30);
846 for (Int_t ich=0; ich<10; ich++) {
847 hClusterHitMapXInCh[ich]->SetLineColor(ich+1+ich/9);
848 hClusterHitMapXInCh[ich]->SetLineWidth(2);
849 if (ich == 0) hClusterHitMapXInCh[ich]->Draw("e");
850 else hClusterHitMapXInCh[ich]->Draw("esame");
852 lClusterHitMapPerCh->AddEntry(hClusterHitMapXInCh[ich],Form("ch%d",ich+1),"PL");
854 lClusterHitMapPerCh->Draw("same");
856 cClusterHitMapPerCh->cd(2);
857 hClusterHitMapYInCh[0]->SetStats(kFALSE);
858 hClusterHitMapYInCh[0]->GetXaxis()->SetRange(1,ibin-1);
859 hClusterHitMapYInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
860 //hNClustersInCh[0]->LabelsOption("u");
861 hClusterHitMapYInCh[0]->SetLabelSize(0.04);
862 hClusterHitMapYInCh[0]->SetTitle("<Y> of clusters - associated to a track - in chamber i");
863 hClusterHitMapYInCh[0]->SetMaximum(30);
864 hClusterHitMapYInCh[0]->SetMinimum(-30);
865 for (Int_t ich=0; ich<10; ich++) {
866 hClusterHitMapYInCh[ich]->SetLineColor(ich+1+ich/9);
867 hClusterHitMapYInCh[ich]->SetLineWidth(2);
868 if (ich == 0) hClusterHitMapYInCh[ich]->Draw("e");
869 else hClusterHitMapYInCh[ich]->Draw("esame");
871 lClusterHitMapPerCh->Draw("same");
873 cClusterHitMapPerCh->Print(OutFileNamePDF.Data());
874 cClusterHitMapPerCh->Write();
877 //==================================================
878 // Display tracks ChiSquare
879 TCanvas* cChi2 = new TCanvas("cChi2","cChi2",1200,900);
882 hChi2_Mean->SetStats(kFALSE);
883 hChi2_Mean->GetXaxis()->SetRange(1,ibin-1);
884 hChi2_Mean->GetXaxis()->SetNdivisions(1,kFALSE);
885 //hChi2_Mean->LabelsOption("u");
886 hChi2_Mean->SetLabelSize(0.04);
887 hChi2_Mean->SetLineWidth(2);
888 hChi2_Mean->Draw("e");
891 hChi2_Sigma->SetStats(kFALSE);
892 hChi2_Sigma->GetXaxis()->SetRange(1,ibin-1);
893 hChi2_Sigma->GetXaxis()->SetNdivisions(1,kFALSE);
894 //hChi2_Sigma->LabelsOption("u");
895 hChi2_Sigma->SetLabelSize(0.04);
896 hChi2_Sigma->SetLineWidth(2);
897 hChi2_Sigma->Draw("e");
899 cChi2->Print(OutFileNamePDF.Data());
902 //==================================================
903 // Display track Lpt/Hpt
904 if ( hTriggerCutVsRun[0] && hTriggerCutVsRun[1] ) {
905 TCanvas* cLptHpt = new TCanvas("cLptHpt","cLptHpt",1200,900);
906 cLptHpt->Divide(1,2);
907 TLegend* legLptHpt = new TLegend(0.72,0.7,0.9,0.85);
908 legLptHpt->SetBorderSize(1);
909 for ( Int_t ihisto=0; ihisto<2; ++ihisto) {
910 cLptHpt->cd(ihisto+1);
911 TH1* currHistos[2] = {hTriggerCutVsRun[ihisto], hTriggerCutWidthVsRun[ihisto]};
912 for ( Int_t jhisto=0; jhisto<2; jhisto++ ) {
913 currHistos[jhisto]->GetXaxis()->SetRange(1,ibin-1);
914 currHistos[jhisto]->GetYaxis()->SetRangeUser(0.,5.);
915 currHistos[jhisto]->LabelsOption("a");
916 currHistos[jhisto]->SetStats(kFALSE);
917 currHistos[jhisto]->GetXaxis()->SetLabelSize(0.04);
918 currHistos[jhisto]->SetLineWidth(2);
920 hTriggerCutWidthVsRun[ihisto]->SetLineColor(2);
921 hTriggerCutWidthVsRun[ihisto]->SetMarkerColor(2);
922 hTriggerCutWidthVsRun[ihisto]->SetFillColor(2);
923 hTriggerCutWidthVsRun[ihisto]->SetFillStyle(3001);
924 hTriggerCutWidthVsRun[ihisto]->Draw("e2");
925 hTriggerCutVsRun[ihisto]->Draw("esame");
927 legLptHpt->AddEntry(hTriggerCutWidthVsRun[ihisto],"Fit width","f");
928 legLptHpt->AddEntry(hTriggerCutVsRun[ihisto],"pt cut from fit (stat error)","lp");
929 legLptHpt->Draw("same");
932 cLptHpt->Print(OutFileNamePDF.Data());
937 // close the PDF file
938 c1->Print(OutFileNamePDF_close.Data());
939 rootFileOut->Close();
953 void SetCanvas(TCanvas *canvas, Int_t logy){
956 canvas->SetTopMargin(0.05);
957 canvas->SetRightMargin(0.01);
959 canvas->SetLogy(logy);
964 Bool_t IsTrigger(TObjArray *array, Int_t index, TString name){
966 Bool_t process = kFALSE;
968 if( !array) return process;
970 TString triggerName = (( (TObjString*) array->At(index) )->GetString());
972 if( triggerName.Contains(name) ) process = kTRUE;
977 TCanvas *ProcessCanvasTriggerContent(TObjArray *array, TH1 **hBNoPS, TH1 **hBWithPS, TString canvasName){
979 if(!array || !hBNoPS || !hBWithPS) return 0x0;
983 TCanvas *cTriggerContent = new TCanvas(canvasName,cName,1200,900);
984 SetCanvas(cTriggerContent);
985 cTriggerContent->cd();
987 TLegend* legcTC = new TLegend(0.2,0.15,0.50,0.40);
988 legcTC->SetHeader("Physics Selection");
989 legcTC->AddEntry(".","applied :","");
991 for(Int_t i = 0; i < array->GetEntriesFast(); i++){
992 //skip the sum of all triggers
993 if( i== (array->GetEntriesFast()-1) ) continue;
994 hBNoPS[i]->SetLineStyle(2);
996 hBNoPS[i]->SetMinimum(1e-3);
998 hBWithPS[i]->Draw("same");
1001 hBNoPS[i]->Draw("same");
1002 hBWithPS[i]->Draw("same");
1004 legcTC->AddEntry(hBWithPS[i],(( (TObjString*) array->At(i) )->GetString()).Data(),"l");
1006 legcTC->AddEntry(".","not applied :","");
1008 for(Int_t i = 0; i < array->GetEntriesFast(); i++){
1009 legcTC->AddEntry(hBNoPS[i],(( (TObjString*) array->At(i) )->GetString()).Data(),"l");
1012 legcTC->Draw("same");
1014 return cTriggerContent;
1017 TCanvas *ProcessCanvasRelativeTriggerContent(TObjArray *triggersB, TH1 **histo, TString canvasName, Int_t *colorInd){
1019 if(!triggersB || !histo || !colorInd) return 0x0;
1021 TString cName = "c" ;
1022 cName += canvasName;
1023 TCanvas *cRelativeTriggerContent = new TCanvas(canvasName,cName,1200,900);
1024 SetCanvas(cRelativeTriggerContent);
1025 cRelativeTriggerContent->cd();
1028 TLegend* legcRTC = new TLegend(0.2,0.15,0.50,0.40);
1029 legcRTC->SetHeader("Physics Selection");
1031 TString hName, hTriggerName;
1032 Int_t indAllTrig = triggersB->GetEntriesFast()-1;
1033 cout<<indAllTrig<<endl;
1034 for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
1036 hName += ( (TObjString*) triggersB->At(i) )->GetString();
1037 ratio[i] = static_cast<TH1*> (histo[i]->Clone(hName));
1038 ratio[i]->Divide(histo[indAllTrig]);
1039 ratio[i]->SetLineWidth(2);
1040 ratio[i]->SetLineColor(colorInd[i]);
1042 ratio[i]->SetMaximum(1.5);
1043 ratio[i]->SetMinimum(0.001);
1044 ratio[i]->SetLabelSize(0.02);
1045 ratio[i]->GetYaxis()->SetTitle("Relative trigger content");
1046 ratio[i]->Draw("E");
1049 ratio[i]->Draw("ESAME");
1053 legcRTC->AddEntry(".","not applied :","");
1054 for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
1055 legcRTC->AddEntry(ratio[i],(( (TObjString*) triggersB->At(i) )->GetString()).Data(),"l");
1057 legcRTC->Draw("same");
1059 return cRelativeTriggerContent;
1062 TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE, TH1 **hBNoPS, TH1 **hACNoPS, TH1 **hENoPS, TH1 **hBWithPS, TString canvasName, Int_t *colorInd){
1064 if(!triggersB || !triggersE || !triggersAC || !hBNoPS || !hACNoPS || !hENoPS || !hBWithPS || !colorInd) return 0x0;
1066 TString cName = "c";
1067 cName += canvasName;
1068 TCanvas *c1 = new TCanvas(canvasName,cName,1200,900);
1072 TH1* ratioB[10], *ratioBNoPS[10];
1073 TH1* ratioACNoPS[10];
1074 TH1* ratioENoPS[10];
1075 TLegend* legcRTC = new TLegend(0.2,0.15,0.50,0.40);
1076 legcRTC->SetHeader("Physics Selection");
1079 for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
1081 hName += ( (TObjString*) triggersB->At(i) )->GetString();
1082 ratioB[i] = static_cast<TH1*> (hBWithPS[i]->Clone(hName));
1083 ratioB[i]->Divide(hBNoPS[i]);
1084 ratioB[i]->SetLineWidth(2);
1085 ratioB[i]->SetLineColor(colorInd[i]);
1086 hName = "ratioNoPS";
1087 hName += ( (TObjString*) triggersB->At(i) )->GetString();
1088 ratioBNoPS[i] = static_cast<TH1*> (hBNoPS[i]->Clone(hName));
1089 ratioBNoPS[i]->Divide(hBNoPS[i]);
1090 ratioBNoPS[i]->SetLineWidth(0);
1091 ratioBNoPS[i]->SetLineStyle(1);
1092 ratioBNoPS[i]->SetMarkerStyle(24+i);
1093 ratioBNoPS[i]->SetMarkerSize(1);
1094 ratioBNoPS[i]->SetLineColor(colorInd[i]);
1095 ratioBNoPS[i]->SetMarkerColor(colorInd[i]);
1097 hName = "ratioACNoPS";
1098 hName += ( (TObjString*) triggersAC->At(i) )->GetString();
1099 ratioACNoPS[i] = static_cast<TH1*> (hACNoPS[i]->Clone(hName));
1100 ratioACNoPS[i]->Divide(hBNoPS[i]);
1101 ratioACNoPS[i]->SetLineWidth(0);
1102 ratioACNoPS[i]->SetLineStyle(2);
1103 ratioACNoPS[i]->SetMarkerStyle(24+i);
1104 ratioACNoPS[i]->SetMarkerSize(1);
1105 ratioACNoPS[i]->SetLineColor(colorInd[i]);
1106 ratioACNoPS[i]->SetMarkerColor(colorInd[i]);
1109 hName = "ratioENoPS";
1110 hName += ( (TObjString*) triggersE->At(i) )->GetString();
1111 ratioENoPS[i] = static_cast<TH1*> (hENoPS[i]->Clone(hName));
1112 ratioENoPS[i]->Divide(hBNoPS[i]);
1113 ratioENoPS[i]->SetLineWidth(0);
1114 ratioENoPS[i]->SetLineStyle(3);
1115 ratioENoPS[i]->SetMarkerStyle(24+i);
1116 ratioENoPS[i]->SetMarkerSize(1);
1117 ratioENoPS[i]->SetLineColor(colorInd[i]);
1118 ratioENoPS[i]->SetMarkerColor(colorInd[i]);
1122 ratioB[i]->SetMaximum(1.5);
1123 ratioB[i]->SetMinimum(0.001);
1124 ratioB[i]->SetLabelSize(0.02);
1125 ratioB[i]->GetYaxis()->SetTitle("Relative trigger content w/ and w/o Phys. Sel.");
1126 ratioB[i]->Draw("E");
1127 //ratioBNoPS[i]->Draw("EPSAME");
1128 ratioACNoPS[i]->Draw("EPSAME");
1129 ratioENoPS[i]->Draw("EPSAME");
1132 ratioB[i]->Draw("ESAME");
1133 //ratioBNoPS[i]->Draw("EPSAME");
1134 ratioACNoPS[i]->Draw("EPSAME");
1135 ratioENoPS[i]->Draw("EPSAME");
1139 legcRTC->AddEntry(".","applied :","");
1140 for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
1141 legcRTC->AddEntry(ratioB[i],(( (TObjString*) triggersB->At(i) )->GetString()).Data(),"l");
1143 legcRTC->AddEntry(".","not applied :","");
1144 for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
1145 //legcRTC->AddEntry(ratioBNoPS[i],(( (TObjString*) triggersB->At(i) )->GetString()).Data(),"pl");
1146 legcRTC->AddEntry(ratioACNoPS[i],(( (TObjString*) triggersAC->At(i) )->GetString()).Data(),"pl");
1147 legcRTC->AddEntry(ratioENoPS[i],(( (TObjString*) triggersE->At(i) )->GetString()).Data(),"pl");
1149 legcRTC->Draw("same");
1156 TCanvas *ProcessCanvasTracksoverTrigger(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName){
1158 if(!triggersB || !hB || !hTrackerB || !hTriggerB || !hMatchedB || !hAllTracksB || indTrigger<0 ) return 0x0;
1160 TH1 *hTrackerPerB, *hTriggerPerB, *hMatchedPerB, *hAllTracksPerB;
1162 TString hName, hNameBase;
1163 hNameBase =( (TObjString*) triggersB->At(indTrigger) )->GetString();
1165 hName = "hTrackerPer";
1167 hTrackerPerB = static_cast<TH1*>(hTrackerB[indTrigger]->Clone(hName));
1168 hTrackerPerB->Divide(hB[indTrigger]);
1169 hTrackerPerB->SetLineWidth(2);
1170 hTrackerPerB->SetLineColor(kRed);
1172 hName = "hTriggerPer";
1174 hTriggerPerB = static_cast<TH1*>(hTriggerB[indTrigger]->Clone(hName));
1175 hTriggerPerB->Divide(hB[indTrigger]);
1176 hTriggerPerB->SetLineWidth(2);
1177 hTriggerPerB->SetLineColor(kBlue);
1179 hName = "hMatchedPer";
1181 hMatchedPerB = static_cast<TH1*>(hMatchedB[indTrigger]->Clone(hName));
1182 hMatchedPerB->Divide(hB[indTrigger]);
1183 hMatchedPerB->SetLineWidth(2);
1184 hMatchedPerB->SetLineColor(kViolet);
1186 hName = "hAllTracksPer";
1188 hAllTracksPerB = static_cast<TH1*>(hAllTracksB[indTrigger]->Clone(hName));
1189 hAllTracksPerB->Divide(hB[indTrigger]);
1190 hAllTracksPerB->SetLineWidth(3);
1191 hAllTracksPerB->SetLineColor(kBlack);
1192 hAllTracksPerB->SetTitle(Form("Ratio (Number of Tracks)/%s",hNameBase.Data()));
1193 hAllTracksPerB->SetMinimum(0.0001);
1194 hAllTracksPerB->SetLabelSize(0.02);
1197 TString cName = "c";
1198 cName += canvasName;
1199 hNameBase =( (TObjString*) triggersB->At(indTrigger) )->GetString();
1201 canvasName += indTrigger;
1202 TCanvas *cRatioTrackTypesB = new TCanvas(canvasName,cName,1200,900);
1203 SetCanvas(cRatioTrackTypesB,0);
1204 cRatioTrackTypesB->cd();
1206 TLegend* legcTTCINT1B;
1208 hAllTracksPerB->Draw("E");
1209 hTrackerPerB->Draw("Esame");
1210 hMatchedPerB->Draw("Esame");
1211 hTriggerPerB->Draw("Esame");
1213 legcTTCINT1B = new TLegend(0.70,0.5,0.90,0.70);
1214 legcTTCINT1B->AddEntry(hAllTracksPerB,"All tracks","l");
1215 legcTTCINT1B->AddEntry(hTrackerPerB,"Tracking (only) tracks","l");
1216 legcTTCINT1B->AddEntry(hMatchedPerB,"Matched tracks","l");
1217 legcTTCINT1B->AddEntry(hTriggerPerB,"Trigger (only) tracks","l");
1218 legcTTCINT1B->Draw("same");
1222 return cRatioTrackTypesB;
1227 TCanvas *ProcessCanvasTrackMultB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName){
1229 if(!triggersB || !hB || !hTrackerB || !hTriggerB || !hMatchedB || !hAllTracksB || indTrigger<0 ) return 0x0;
1231 TString cName = "c";
1232 cName += canvasName;
1233 TString hNameBase =( (TObjString*) triggersB->At(indTrigger) )->GetString();
1235 canvasName += indTrigger;
1236 TCanvas *cTrackMultB = new TCanvas(canvasName,cName,1200,900);
1237 SetCanvas(cTrackMultB,0);
1239 cTrackMultB->Divide(1,2);
1243 TH1* hSumTriggerOverB, *hSumTrackerOverB;
1247 hName = Form("hSumTriggerOver%s",hNameBase.Data());
1248 hSumTriggerOverB = static_cast<TH1*>(hTriggerB[indTrigger]->Clone(hName));
1249 hSumTriggerOverB->Add(hMatchedB[indTrigger]);
1250 hSumTriggerOverB->Divide(hB[indTrigger]);
1252 hName = Form("Sum of trigger tracks (matched+trigger-only) / # events in %s",hNameBase.Data());
1253 hSumTriggerOverB->SetTitle(hName);
1254 hSumTriggerOverB->SetLabelSize(0.02);
1255 hSumTriggerOverB->SetLineWidth(2);
1256 hSumTriggerOverB->SetLineColor(kBlue);
1257 hName = Form("hSumTrackerOver%s",hNameBase.Data());
1258 hSumTrackerOverB = static_cast<TH1*>(hTrackerB[indTrigger]->Clone(hName));
1259 hSumTrackerOverB->Add(hMatchedB[indTrigger]);
1260 hSumTrackerOverB->Divide(hB[indTrigger]);
1261 hName = Form("Sum of tracker tracks (matched+tracker-only) / # events in %s",hNameBase.Data());
1262 hSumTrackerOverB->SetTitle(hName);
1263 //hSumTrackerOverCINT1B->LabelsOption("u");
1264 hSumTrackerOverB->SetLabelSize(0.02);
1265 hSumTrackerOverB->SetLineWidth(2);
1266 hSumTrackerOverB->SetLineColor(kBlue);
1270 hSumTriggerOverB->Draw("e");
1272 hSumTrackerOverB->Draw("e");
1278 TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName){
1280 if(!triggersB || !hB || !hTrackerB || !hTriggerB || !hMatchedB || !hAllTracksB || indTrigger<0 ) return 0x0;
1282 TString cName = "c";
1283 cName += canvasName;
1284 TString hNameBase =( (TObjString*) triggersB->At(indTrigger) )->GetString();
1286 canvasName += indTrigger;
1287 TCanvas *cRatioTrackB = new TCanvas(canvasName,cName,1200,900);
1288 SetCanvas(cRatioTrackB,0);
1290 TH1* hTrackerOverTriggerB, *hMatchedOverTriggerB, *hMatchedOverTrackerB;
1292 TString hName = Form("hTrackerOverTrigger%s",hNameBase.Data());
1293 hTrackerOverTriggerB = static_cast<TH1*>(hTrackerB[indTrigger]->Clone(hName));
1294 hTrackerOverTriggerB->Divide(hTriggerB[indTrigger]);
1295 hName = Form("# tracker tracks / # trigger tracks in %s",hNameBase.Data());
1296 hTrackerOverTriggerB->SetTitle(hName);
1297 //hTrackerOverTriggerCINT1B->LabelsOption("u");
1298 hTrackerOverTriggerB->SetLabelSize(0.02);
1299 hTrackerOverTriggerB->SetLineWidth(2);
1300 hTrackerOverTriggerB->SetLineColor(kBlue);
1302 hName = Form("hMatchedOverTrigger%s",hNameBase.Data());
1303 hMatchedOverTriggerB = static_cast<TH1*>(hMatchedB[indTrigger]->Clone(hName));
1304 hMatchedOverTriggerB->Divide(hTriggerB[indTrigger]);
1306 hName = Form("# matched tracks / # trigger tracks in %s",hNameBase.Data());
1307 hMatchedOverTriggerB->SetTitle(hName);
1308 //hMatchedOverTriggerCINT1B->LabelsOption("u");
1309 hMatchedOverTriggerB->SetLabelSize(0.02);
1310 hMatchedOverTriggerB->SetLineWidth(2);
1311 hMatchedOverTriggerB->SetLineColor(kBlue);
1313 hName = Form("hMatchedOverTracker%s",hNameBase.Data());
1314 hMatchedOverTrackerB = static_cast<TH1*>(hMatchedB[indTrigger]->Clone(hName));
1315 hMatchedOverTrackerB->Divide(hTrackerB[indTrigger]);
1316 hName = Form("# matched tracks / # tracker tracks in %s",hNameBase.Data());
1317 hMatchedOverTrackerB->SetTitle(hName);
1318 //hMatchedOverTrackerCINT1B->LabelsOption("u");
1319 hMatchedOverTrackerB->SetLabelSize(0.02);
1320 hMatchedOverTrackerB->SetLineWidth(2);
1321 hMatchedOverTrackerB->SetLineColor(kBlue);
1324 cRatioTrackB->Divide(1,3);
1325 cRatioTrackB->cd(1);
1326 hTrackerOverTriggerB->Draw("e");
1327 cRatioTrackB->cd(2);
1328 hMatchedOverTriggerB->Draw("e");
1329 cRatioTrackB->cd(3);
1330 hMatchedOverTrackerB->Draw("e");
1332 return cRatioTrackB;
1336 TCanvas *ProcessCanvasAsymMatched(TObjArray *triggersB, TH1 **hPosMatchedB, TH1 **hNegMatchedB, TH1 **hAllMatchedB, Int_t indTrigger, TString canvasName){
1338 if(!triggersB || !hPosMatchedB || !hNegMatchedB || !hAllMatchedB || indTrigger<0 ) return 0x0;
1340 TString hName, hNameBase = (( (TObjString*) triggersB->At(indTrigger) )->GetString());
1342 TString cName = "c";
1343 cName += canvasName;
1345 canvasName += indTrigger;
1346 TCanvas *cAsymMatched = new TCanvas(canvasName.Data(),cName,1200,900);
1347 SetCanvas(cAsymMatched,0);
1351 TH1 *hDiffMatchedCMUS1B= static_cast<TH1*>(hPosMatchedB[indTrigger]->Clone("hDiffMatchedCMUS1B"));
1352 hDiffMatchedCMUS1B->Add(hNegMatchedB[indTrigger],-1);
1353 hDiffMatchedCMUS1B->Sumw2();
1355 TH1 *hAsymMatchedCMUS1B= static_cast<TH1*>(hDiffMatchedCMUS1B->Clone("hAsymMatchedCMUS1B"));
1356 hAsymMatchedCMUS1B->Divide(hAllMatchedB[indTrigger]);
1357 hAsymMatchedCMUS1B->SetLineColor(kRed);
1358 hAsymMatchedCMUS1B->SetLineWidth(2);
1359 hAsymMatchedCMUS1B->SetMinimum(-0.3);
1360 hAsymMatchedCMUS1B->SetMaximum(0.3);
1361 hAsymMatchedCMUS1B->SetLabelSize(0.02);
1362 hName = Form("Matched tracks asymmetry for %s with acc. cuts",hNameBase.Data());
1363 hAsymMatchedCMUS1B->SetTitle(hName);
1365 hAsymMatchedCMUS1B->GetYaxis()->SetTitle("Charged tracks asymmetry");
1366 hAsymMatchedCMUS1B->Draw("EH");
1368 return cAsymMatched;
1372 TCanvas *ProcessCanvasHighPtMuons(TObjArray *triggersB, TH1 **hB, TH1 **hMatchedLowPtB, TH1 **hMatchedHighPtB, Int_t indTrigger, TString canvasName){
1374 if(!triggersB || !hB || !hMatchedLowPtB || !hMatchedHighPtB || indTrigger<0 ) return 0x0;
1376 TString hName, hNameBase = (( (TObjString*) triggersB->At(indTrigger) )->GetString());
1378 TString cName = "c";
1379 cName += canvasName;
1381 canvasName += indTrigger;
1382 TCanvas *cHighPtMuons = new TCanvas(canvasName.Data(),cName,1200,900);
1383 SetCanvas(cHighPtMuons,0);
1388 TH1* hMatchedLowPtPerB, *hMatchedHighPtPerB;
1389 hName = Form("hMatchedLowPtPer%s ",hNameBase.Data());
1390 hMatchedLowPtPerB = static_cast<TH1*> (hMatchedLowPtB[indTrigger]->Clone(hName));
1391 hMatchedLowPtPerB->Sumw2();
1392 hMatchedLowPtPerB->Divide(hB[indTrigger]);
1393 hMatchedLowPtPerB->SetLineWidth(2);
1394 hMatchedLowPtPerB->SetLineColor(kBlue);
1395 hMatchedLowPtPerB->SetTitle("");
1396 hName = Form("Ratio per %s ",hNameBase.Data());
1397 hMatchedLowPtPerB->GetYaxis()->SetTitle(hName);
1398 //hMatchedLowPtPerB->SetMaximum(0.15);
1399 hMatchedLowPtPerB->SetMinimum(0.0001);
1400 hMatchedLowPtPerB->SetLabelSize(0.02);
1402 hName = Form("hMatchedHighPtPer%s ",hNameBase.Data());
1403 hMatchedHighPtPerB = static_cast<TH1*> (hMatchedHighPtB[indTrigger]->Clone(hName));
1404 hMatchedHighPtPerB->Sumw2();
1405 hMatchedHighPtPerB->Divide(hB[indTrigger]);
1406 hMatchedHighPtPerB->SetLineWidth(2);
1407 hMatchedHighPtPerB->SetLineColor(kRed);
1409 hMatchedLowPtPerB->Draw("E");
1410 hMatchedHighPtPerB->Draw("Esame");
1412 legcHPM = new TLegend(0.60,0.45,0.98,0.65);
1413 hName = Form("Number of matched track per %s (include Vtx and R_{Abs} cuts)",hNameBase.Data());
1414 legcHPM->SetHeader(hName);
1415 legcHPM->AddEntry(".","Physics selection applied :","");
1416 legcHPM->AddEntry(hMatchedLowPtPerB," p_{T} > 1 GeV/c ","l");
1417 legcHPM->AddEntry(hMatchedHighPtPerB," p_{T} > 2 GeV/c ","l");
1418 legcHPM->Draw("same");
1420 return cHighPtMuons;
1425 TH1* ProcessHisto( AliCounterCollection* counter, TString hVariable, TString hSelection, TString hName, TString xName, TString yName, Int_t color){
1429 if( !counter ) return h1;
1431 h1 = (TH1*) counter->Draw(hVariable,hSelection);
1432 if ( !h1 ) h1 = new TH1D(hName,"",10,0,10);
1435 h1->LabelsOption("a");
1436 if(hName.Sizeof()>1) h1->SetName(hName);
1437 if(xName.Sizeof()>1) h1->GetXaxis()->SetTitle(xName);
1438 if(yName.Sizeof()>1) h1->GetYaxis()->SetTitle(yName);
1439 if(color>0) h1->SetLineColor(color);
1446 TH2* ProcessHisto2D( AliCounterCollection* counter, TString hVariable, TString hVariable2, TString hSelection, TString hName){
1450 if( !counter ) return h1;
1451 Bool_t setName = kTRUE;
1453 if(hName.Sizeof()==1) setName = kFALSE;
1455 h1 = (TH2*) counter->Draw(hVariable,hVariable2,hSelection);
1456 if ( !h1 ) h1 = new TH2D(hName,"",10,0,10,10,0,10);
1459 h1->LabelsOption("a");
1460 if(setName) h1->SetName(hName);
1465 Bool_t GetTriggerLists(const char* triggerList, TString listFromContainer, TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE){
1467 //Get the trigger list from a file
1468 //The file should consist of a line for each trigger with the following layout:
1469 // triggernameB triggerNameAC triggerNameE
1470 // or triggernameB triggerNameA,triggerNameC triggerNameE
1471 // or triggernameB triggerNameACE notrigger
1472 //if filename is 0, then default trigger names (pp 2011) are used
1474 if( !triggersB || !triggersAC || !triggersE) return kFALSE;
1475 TObjArray* triggers[3] = {triggersB, triggersAC, triggersE};
1477 TString trigSuffix[3] = {"B", "AC", "E"};
1478 TString currTrigName = "";
1479 TObjArray* fullTriggerList[3];
1481 for ( Int_t ibeam=0; ibeam<3; ++ibeam ) {
1482 fullTriggerList[ibeam] = new TObjArray;
1483 fullTriggerList[ibeam]->SetOwner();
1486 // Build trigger list (from file or default)
1487 if ( triggerList ) {
1488 // only the ones in the triggerList
1489 ifstream inFile(triggerList);
1490 if (!inFile.is_open()) {
1491 Error("PlotMUONQApp","unable to open file %s", triggerList);
1495 while ( !inFile.eof() ) {
1496 Bool_t isGoodB = kTRUE;
1497 for ( Int_t ibeam=0; ibeam<3; ++ibeam ) {
1498 currTrigName.ReadToken( inFile );
1499 if ( ! isGoodB ) continue;
1500 if ( currTrigName.IsNull() || ! currTrigName.IsAscii() ) {
1505 currTrigName = "notrigger";
1507 fullTriggerList[ibeam]->AddLast(new TObjString(currTrigName));
1513 TString baseTrigName[4] = {"CINT7", "CMUSH7", "CMUL7", "CMUU7"};
1514 for ( Int_t ibase=0; ibase<4; ++ibase ) {
1515 for ( Int_t ibeam=0; ibeam<3; ++ibeam ) {
1516 // by default all triggers from new period in LHC11c
1517 currTrigName = baseTrigName[ibase] + trigSuffix[ibeam];
1518 fullTriggerList[ibeam]->AddLast(new TObjString(currTrigName));
1523 // Select only existing triggers in container
1525 TObjArray *triggersFromContainer = listFromContainer.Tokenize(",");
1526 TObjString* trigName = 0x0;
1528 TString selectAllTriggers[3] = {"", "", ""};
1529 for ( Int_t itrig=0; itrig<fullTriggerList[0]->GetEntries(); ++itrig ) {
1530 Bool_t isBadTrig = kFALSE;
1531 for ( Int_t ibeam=0; ibeam<3; ++ibeam ) {
1532 currTrigName = fullTriggerList[ibeam]->At(itrig)->GetName();
1534 //condition on trigger name from trigger list
1535 if ( currTrigName.Contains("notrigger") ){
1537 if ( ibeam == 0 ) break;
1540 //select only the existing triggers in the container
1541 //note that the trigger in the trigger file can be a list of different trigger
1542 if ( triggersFromContainer ) {
1543 TIter nextTrigger( triggersFromContainer );
1545 while ( ( trigName = static_cast<TObjString*>(nextTrigger()) ) ) {
1546 if ( currTrigName.Contains(trigName->GetString()) ){
1550 if ( isBadTrig == kTRUE ){
1551 if ( ibeam == 0 ) break;
1555 triggers[ibeam]->AddLast(new TObjString(currTrigName));
1556 if ( isBadTrig ) continue;
1557 if ( ! selectAllTriggers[ibeam].IsNull() ) selectAllTriggers[ibeam] += ",";
1558 selectAllTriggers[ibeam] += currTrigName;
1561 if(triggersFromContainer) delete triggersFromContainer;
1562 if(trigName) delete trigName;
1565 // Complete trigger list and print values
1566 cout<<" Nr of triggers read "<<triggers[0]->GetEntriesFast()<<endl;
1567 for ( Int_t ibeam=0; ibeam<3; ++ibeam ) {
1568 triggers[ibeam]->AddLast(new TObjString(selectAllTriggers[ibeam]));
1569 printf(" %s triggers:\n", trigSuffix[ibeam].Data());
1570 triggers[ibeam]->Print();
1571 delete fullTriggerList[ibeam];
1577 TString GetRunList(const char *runList, TObjArray *runs, TObjArray *runs2){
1579 // list of runs to be analyzed
1580 TString selectRuns = "run:";
1583 // only the ones in the runList
1584 ifstream inFile(runList);
1585 if (!inFile.is_open()) {
1586 Error("PlotMUONQApp","unable to open file %s", runList);
1591 while (!inFile.eof()) {
1592 currRun.ReadLine(inFile, kTRUE);
1593 if (currRun.IsNull()) continue;
1594 if (!currRun.IsDigit()) {
1595 Error("PlotMUONQApp","invalid run number: %s", currRun.Data());
1598 if(runs) runs->AddLast(new TObjString(Form("%09d", currRun.Atoi())));
1599 if(runs2) runs2->AddLast(new TObjString(Form("%d", currRun.Atoi())));
1600 selectRuns += Form("%s,",currRun.Data());
1602 selectRuns.Remove(TString::kTrailing, ',');
1607 if(runs) runs->AddLast(new TObjString("*"));
1608 if(runs2) runs2->AddLast(new TObjString("*"));