]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/muon/PlotMuonQA.C
Add new central and semicentral triggers (Cynthia)
[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
93f182e7 19// To be done:
20// - reorganize last part (reading and extracting info from run per run histos)
21// - warning and error messages
93ce3c40 22//--------------------------------------------------------------------------
23
24#if !defined(__CINT__) || defined(__MAKECINT__)
25
26#include <Riostream.h>
27
28// ROOT includes
29#include "TEnv.h"
30#include "TMath.h"
31#include "TGrid.h"
32#include "TGridResult.h"
33#include "THashList.h"
34#include "TFile.h"
35#include "TH1.h"
36#include "TH2.h"
005408df 37#include "TF1.h"
93ce3c40 38#include "TSystem.h"
39#include "TStyle.h"
40#include "TCanvas.h"
41#include "TPad.h"
42#include "TLegend.h"
b66f9801 43#include "TObjArray.h"
44#include "TObjString.h"
93ce3c40 45
46// ALIROOT includes
47#include "AliCounterCollection.h"
48
49#endif
50
005408df 51TString GetRunList(const char *runList, TObjArray *runs, TObjArray *runs2);
005408df 52Bool_t GetTriggerLists(const char *triggerList, TString listFromContainer, TObjArray *triggersB=0, TObjArray *triggersAC=0, TObjArray *triggersE=0);
53void SetCanvas(TCanvas *canvas, Int_t logy=1);
54
b69e18be 55TH1* ProcessHisto( AliCounterCollection* counter, TString variable, TString selection, TString hName="", TString xName="", TString yName="", Int_t color=1);
005408df 56TH2* ProcessHisto2D( AliCounterCollection* counter, TString hVariable, TString hVariable2, TString hSelection, TString hName);
57
58TCanvas *ProcessCanvasTriggerContent(TObjArray *array, TH1 **histo, TH1 **histo2, TString canvasName);
59TCanvas *ProcessCanvasRelativeTriggerContent(TObjArray *array, TH1 **histo, TString canvasName, Int_t *colorTab);
93f182e7 60TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE, TH1 **hBNoPS, TH1 **hACNoPS,TH1 **hENoPS, TH1 **hBWithPS, TString canvasName, Int_t *colorInd, Bool_t isHeavyIon = kFALSE);
61TCanvas *ProcessCanvasPhysSelCutCentrality(TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE, TH1 **hBNoPS, TH1 **hACNoPS, TH1 **hENoPS, TH1 **hBWithPS, Int_t k, TString canvasName, Int_t *colorInd, TString *legendHeader, Bool_t isHeavyIon = kFALSE);
62TCanvas *ProcessCanvasCentralityPercentile(TObjArray *triggersB, TH1 **hBNoPSCent, TH1 **hBWithPSCent, Int_t k, TString canvasName, Int_t *colorInd, TString *legendHeader);
63TCanvas *ProcessCanvasTracksoverTrigger(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName,TString legendHeader="");
64TCanvas *ProcessCanvasTrackMultB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName,TString legendHeader="");
65TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName,TString legendHeader="");
66TCanvas *ProcessCanvasAsymMatched(TObjArray *triggersB, TH1 **hPosMatchedB, TH1 **hNegMatchedB, TH1 **hAllMatchedB, Int_t indTrigger, TString canvasName,TString legendHeader="");
67TCanvas *ProcessCanvasHighPtMuons(TObjArray *triggersB, TH1 **hB, TH1 **hMatchedLowPtB, TH1 **hAllMatchedHightPtB, Int_t indTrigger, TString canvasName,TString legendHeader="");
005408df 68Bool_t IsTrigger(TObjArray *array, Int_t index, TString name);
2e7189d6 69Bool_t IsTriggerSelectedForMuonPhysics(TObjArray *array, Int_t index);
93f182e7 70Bool_t IsHeavyIonCollision(AliCounterCollection *eventCounters);
93ce3c40 71
93ce3c40 72//--------------------------------------------------------------------------
93f182e7 73void PlotMuonQA(const char* baseDir, const char* runList = 0x0, const char * triggerList = 0x0, Bool_t selectPhysics = kFALSE, const char *LHCPeriod = "LHC11c", const char *QAFileName = "QAresults.root") {
005408df 74
93ce3c40 75 /// Macro for QA monitoring.
76 /// Example: baseDir = "alien:///alice/cern.ch/user/p/ppillot/pp7TeV/LHC10d/MuonQA/pass1/results/".
77 /// If runList != 0x0: only the given runs will be used. Otherwise use all runs found in baseDir.
93f182e7 78 /// If triggerList !=0x0: only the given triggers are displayed. Otherwise use the default list of triggers (see GetTriggerLists)
79
93ce3c40 80#if defined(__CINT__) && !defined(__MAKECINT__)
81 gSystem->Load("libTree");
82 gSystem->Load("libGeom");
83 gSystem->Load("libVMC");
84 gSystem->Load("libPhysics");
85 gSystem->Load("libSTEERBase");
86 gSystem->Load("libESD");
87 gSystem->Load("libAOD");
88 gSystem->Load("libANALYSIS");
89 gSystem->Load("libANALYSISalice");
90 gSystem->Load("libCORRFW");
91 gSystem->Load("libPWG3base");
92 gSystem->Load("libPWG3muon");
93#endif
94
95 // Cosmetics and configuration
96 gStyle->SetFillColor(10);
97 gStyle->SetPadGridX(kTRUE);
98 gStyle->SetPadGridY(kTRUE);
99 gStyle->SetPadRightMargin(0.01);
100
005408df 101 Int_t colorInd[10]={1,4,2,3,6,7,12};
b66f9801 102
93ce3c40 103 TString OutFileName = "QA_"; OutFileName += LHCPeriod;
104 TString OutFileNamePDF= OutFileName.Data(); OutFileNamePDF+= ".pdf";
105 TString OutFileNamePDF_open = OutFileNamePDF.Data(); OutFileNamePDF_open += "[";
106 TString OutFileNamePDF_close= OutFileNamePDF.Data(); OutFileNamePDF_close += "]";
107 TString OutFileNameROOT= OutFileName.Data(); OutFileNameROOT+= ".root";
108
b66f9801 109 Int_t PRINTSTAT = 1;
005408df 110 Int_t kCMUS = 2;
93ce3c40 111 if (0){ // Equivalent to the fast read option
112 gEnv->SetValue("XNet.ConnectTimeout",10);
113 gEnv->SetValue("XNet.RequestTimeout",10);
114 gEnv->SetValue("XNet.MaxRedirectCount",2);
115 gEnv->SetValue("XNet.ReconnectTimeout",10);
116 gEnv->SetValue("XNet.FirstConnectMaxCnt",1);
117 }
118
119 TH1::AddDirectory(kFALSE);
120
121 TString alienBaseDir = baseDir;
122
93ce3c40 123 if (alienBaseDir.Contains("alien:") && !TGrid::Connect("alien://")) {
124 Error("MergeQA","cannot connect to grid");
125 return;
126 }
127
005408df 128
93f182e7 129 cout<<"//---------------------------------- //"<<endl;
130 cout<<"// Run selection //"<<endl;
131 cout<<"//---------------------------------- //"<<endl;
93ce3c40 132
005408df 133 TObjArray *runs = new TObjArray();
134 runs->SetOwner(kTRUE);
135 TObjArray *runs2 = new TObjArray();
136 runs2->SetOwner(kTRUE);
137 TString selectRuns = GetRunList(runList,runs,runs2);
93f182e7 138
93ce3c40 139 // physics selection
140 TString select = selectPhysics ? "selected:yes" : "";
93f182e7 141
b66f9801 142 cout<<"//---------------------------------- //"<<endl;
005408df 143 cout<<"// Get global counter //"<<endl;
b66f9801 144 cout<<"//---------------------------------- //"<<endl;
145
146 TFile *globalFile = TFile::Open(Form("%s/%s", baseDir,QAFileName));
93ce3c40 147 if (!globalFile || ! globalFile->IsOpen()) {
b66f9801 148 Error("PlotQA", "failed to open file: %s/%s", baseDir, QAFileName);
93ce3c40 149 return;
150 }
151 globalFile->Cd("MUON_QA");
152
b66f9801 153 TString selection;
154
93ce3c40 155 // get counters
156 AliCounterCollection* eventCounters = static_cast<AliCounterCollection*>(globalFile->FindObjectAny("eventCounters"));
157 AliCounterCollection* trackCounters = static_cast<AliCounterCollection*>(globalFile->FindObjectAny("trackCounters"));
158 if (!runList) selectRuns += trackCounters->GetKeyWords("run");
005408df 159
160
161 cout<<"//---------------------------------- //"<<endl;
162 cout<<"// Trigger selection //"<<endl;
163 cout<<"//---------------------------------- //"<<endl;
164
165 TObjArray *triggersB, *triggersAC, *triggersE;
166 triggersB = new TObjArray();
167 triggersB->SetOwner();
168 triggersAC = new TObjArray();
169 triggersAC->SetOwner();
170 triggersE = new TObjArray();
171 triggersE->SetOwner();
172
173 TString listFromContainer = eventCounters->GetKeyWords("trigger");
174 Bool_t success = GetTriggerLists(triggerList, listFromContainer, triggersB, triggersAC, triggersE);
175 if(!success) return;
93f182e7 176
177 cout<<"//---------------------------------- //"<<endl;
178 cout<<"// Set collision type ? //"<<endl;
179 cout<<"//---------------------------------- //"<<endl;
005408df 180
93f182e7 181 Bool_t isHeavyIon = kTRUE;
182 isHeavyIon = IsHeavyIonCollision(eventCounters);
183
005408df 184 cout<<"//---------------------------------- //"<<endl;
185 cout<<"// Trigger plots //"<<endl;
186 cout<<"//---------------------------------- //"<<endl;
187
93f182e7 188 //plot all trigger from event counters without any selection
005408df 189 TString CanvasName = "cAll";
190 TCanvas *cAll = new TCanvas(CanvasName.Data(),CanvasName.Data());
93f182e7 191 cAll->SetLeftMargin(0.18);
2e7189d6 192 cAll->SetRightMargin(0.18);
193 cAll->SetLogz(1);
005408df 194 cAll->cd();
195 //TH2* hAll = (TH2*) ProcessHisto2D(eventCounters, "trigger", "run", Form("run:any/%s",select.Data()) , "");
196 TH2* hAll = (TH2*) ProcessHisto2D(eventCounters, "trigger", "run", "run:any" , "");
93f182e7 197 for ( Int_t ibin=1; ibin<=hAll->GetYaxis()->GetNbins(); ++ibin ) {
198 TString currLabel = hAll->GetYaxis()->GetBinLabel(ibin);
199 TObjArray* labelArray = currLabel.Tokenize("-");
200 labelArray->SetOwner();
201 TString newLabel = labelArray->At(0)->GetName();
202 if ( labelArray->GetEntries() >= 2 ) newLabel = Form("%s-%s", newLabel.Data(), labelArray->At(1)->GetName());
203 hAll->GetYaxis()->SetBinLabel(ibin, newLabel.Data());
204 delete labelArray;
205 }
2e7189d6 206 hAll->Draw("COLZ");
005408df 207
208
93ce3c40 209 //declare a default canvas c1
005408df 210 CanvasName = "c1";
b66f9801 211 TCanvas *c1 = new TCanvas(CanvasName.Data(),CanvasName.Data());
93ce3c40 212 c1->cd();
005408df 213
93f182e7 214 //Add a dimension here: All collisions / M.B / low mult. / high mult.
215
216 //loop on centrality
217 Int_t centBin = 3;
218 Int_t const centBinMax = 4;
219 Int_t centBinMaxLoop = centBinMax;
220 if(!isHeavyIon) centBinMaxLoop = 1;
221 TString centBinName[centBinMax] = {"v0mult:any/","v0mult:low,int,high/","v0mult:low/","v0mult:high/"};
222 TString centLegendName[centBinMax] ={"All collisions","[0-80%] from V0 amplitude","low mult. [60-80%] from V0 amplitude","high mult. [0-10%] from V0 amplitude"};
223 TString centLegendNameShort[centBinMax] ={"All","[0-80%]","[60-80%]","[0-10%]"};
224 TString selectionCent;
2e7189d6 225
93f182e7 226 TH1* hBNoPS[centBinMax][10]={};
227 TH1* hBWithPS[centBinMax][10]={};
228 TH1* hB[centBinMax][10]={};
229 TH1* hTriggerB[centBinMax][10], *hTrackerB[centBinMax][10], *hMatchedB[centBinMax][10], *hAllTracksB[centBinMax][10], *hMatchedLowPtB[centBinMax][10], *hMatchedHighPtB[centBinMax][10];
230 TH1* hMatchedLowPtBNoPS[centBinMax][10], *hMatchedHighPtBNoPS[centBinMax][10];
231 TH1* hPosMatchedB[centBinMax][10], *hNegMatchedB[centBinMax][10], *hAllMatchedB[centBinMax][10];
232 TH1 *hACWithPS[centBinMax][10]={};
233 TH1 *hACNoPS[centBinMax][10]={};
234 TH1 *hEWithPS[centBinMax][10]={};
235 TH1 *hENoPS[centBinMax][10]={};
4916d740 236
005408df 237 if(triggersB->GetEntriesFast()>=10){
b69e18be 238 cout<<"Too many triggers = "<<triggersB->GetEntriesFast()<<endl;
b66f9801 239 return;
240 }
2e7189d6 241
93f182e7 242 //loop on centrality
243 for(centBin = 0; centBin < centBinMaxLoop; centBin++){
244 selectionCent = centBinName[centBin];
245
246 //Loop on trigger (last is all triggers, then for each defined trigger)
247 for(Int_t i = 0; i < triggersB->GetEntriesFast(); i++){
b66f9801 248
93f182e7 249 TString histoNameBase = "h_trig", histoName;
250 histoNameBase+= i+1;
b69e18be 251
93f182e7 252 TString triggerName = ( (TObjString*) triggersB->At(i) )->GetString();
253 if(triggerName.EqualTo(" ")) continue;
254 // Histo trigger without Phys. Sel.
255 selection = selectionCent; selection += Form("trigger:%s/%s", triggerName.Data(), selectRuns.Data());
b69e18be 256 // cout<<selection<<endl;
93f182e7 257 histoName = histoNameBase;
258 histoName += "BNoPS";
b69e18be 259 hBNoPS[centBin][i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName, "", "Trigger content w/o Phys. Sel.", colorInd[i]);
93f182e7 260 // Histo trigger with Phys. Sel.
261 selection = selectionCent; selection += Form("trigger:%s/%s/selected:yes", triggerName.Data(), selectRuns.Data());
262 histoName = histoNameBase;
263 histoName += "BWithPS";
b69e18be 264 hBWithPS[centBin][i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName, "", "Trigger content w/ Phys. Sel.", colorInd[i]);
93f182e7 265 // Histo trigger : Phys. Sel. is selected or not depending on the macro arguments
266 selection = selectionCent; selection += Form("trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
267 histoName = histoNameBase;
268 histoName += "B";
b69e18be 269 hB[centBin][i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
005408df 270
93f182e7 271 TString triggerNameAC = ( (TObjString*) triggersAC->At(i) )->GetString();
93f182e7 272 // Histo trigger without Phys. Sel. AC
273 histoName = histoNameBase;
274 histoName += "ACNoPS";
275 selection = selectionCent; selection += Form("trigger:%s/%s", triggerNameAC.Data(), selectRuns.Data());
b69e18be 276 hACNoPS[centBin][i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
93f182e7 277 // Histo trigger with Phys. Sel. AC
278 selection = selectionCent; selection += Form("trigger:%s/%s/selected:yes", triggerNameAC.Data(), selectRuns.Data());
279 histoName = histoNameBase;
280 histoName += "ACWithPS";
b69e18be 281 hACWithPS[centBin][i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
005408df 282
93f182e7 283 TString triggerNameE = ( (TObjString*) triggersE->At(i) )->GetString();
2e7189d6 284 // Histo trigger without Phys. Sel. E
93f182e7 285 selection = selectionCent; selection += Form("trigger:%s/%s", triggerNameE.Data(), selectRuns.Data());
286 histoName = histoNameBase;
287 histoName += "ENoPS";
b69e18be 288 hENoPS[centBin][i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
93f182e7 289 // Histo trigger with Phys. Sel. E
290 selection = selectionCent; selection += Form("trigger:%s/%s/selected:yes", triggerNameE.Data(), selectRuns.Data());
291 histoName = histoNameBase;
292 histoName += "EWithPS";
b69e18be 293 hEWithPS[centBin][i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
93f182e7 294
295 // Histo tracking : Phys. Sel. is selected or not depending on the macro arguments
296 selection = selectionCent; selection += Form("track:triggeronly/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
297 hTriggerB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
005408df 298
93f182e7 299 selection = selectionCent; selection += Form("track:trackeronly/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
300 hTrackerB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
005408df 301
93f182e7 302 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
303 hMatchedB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
005408df 304
93f182e7 305 selection = selectionCent; selection += Form("trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
306 hAllTracksB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
005408df 307
93f182e7 308 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s/pt:low/acc:in", triggerName.Data() ,selectRuns.Data(), select.Data());
309 hMatchedLowPtB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
005408df 310
93f182e7 311 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s/pt:high/acc:in", triggerName.Data() ,selectRuns.Data(), select.Data());
312 hMatchedHighPtB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
005408df 313
93f182e7 314 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/pt:low/acc:in", triggerName.Data() ,selectRuns.Data());
315 hMatchedLowPtBNoPS[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
005408df 316
93f182e7 317 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/pt:high/acc:in", triggerName.Data() ,selectRuns.Data());
318 hMatchedHighPtBNoPS[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
005408df 319
93f182e7 320 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/charge:pos/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
321 hPosMatchedB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
005408df 322
93f182e7 323 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/charge:neg/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
324 hNegMatchedB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
005408df 325
93f182e7 326 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
327 hAllMatchedB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
328 }
b66f9801 329 }
330
005408df 331 //if there is not B triggers just stop now
332 Int_t count_trigger=0;
93f182e7 333 centBin = 0;
005408df 334 for(Int_t i = 0; i < triggersB->GetEntriesFast(); i++){
93f182e7 335 count_trigger += hBNoPS[centBin][i]->GetEntries();
005408df 336 }
337 if(count_trigger<=0) return;
338
339
93f182e7 340 Int_t NumOfBNoPS[centBinMax][10];
341 Int_t NumOfBWithPS[centBinMax][10];
342 Int_t NumOfACNoPS[centBinMax][10];
343 Int_t NumOfENoPS[centBinMax][10];
344 Int_t NumOfACWithPS[centBinMax][10];
345 Int_t NumOfEWithPS[centBinMax][10];
346
347 for(centBin = 0; centBin < centBinMaxLoop; centBin++){
348 for(Int_t i = 0; i < triggersB->GetEntriesFast(); i++){
349 NumOfBNoPS[centBin][i] = hBNoPS[centBin][i]->Integral();
350 NumOfBWithPS[centBin][i] = hBWithPS[centBin][i]->Integral();
351 NumOfACNoPS[centBin][i] = hACNoPS[centBin][i]->Integral();
352 NumOfENoPS[centBin][i] = hENoPS[centBin][i]->Integral();
353 NumOfACWithPS[centBin][i] = hACWithPS[centBin][i]->Integral();
354 NumOfEWithPS[centBin][i] = hEWithPS[centBin][i]->Integral();
355 }
b66f9801 356 }
93f182e7 357 centBin = 0;
358
b66f9801 359 cout<<"//==================================================================================="<<endl;
360 cout<<"// Put all plots in a ps file, easier to publish (Twiki)"<<endl;
361 cout<<"//==================================================================================="<<endl;
362
93ce3c40 363 c1->Print(OutFileNamePDF_open.Data());
93ce3c40 364 TFile *rootFileOut = TFile::Open(OutFileNameROOT.Data(),"RECREATE");
005408df 365 cAll->Print(OutFileNamePDF.Data());
366 cAll->Write();
367
368
b66f9801 369 cout<<"//==================================================================================="<<endl;
005408df 370 cout<<"// new canvas with the total number of trigger with and without Phys. Sel."<<endl;
b66f9801 371 cout<<"//==================================================================================="<<endl;
005408df 372
93f182e7 373 TCanvas *cTriggerContent = ProcessCanvasTriggerContent(triggersB, hBNoPS[centBin], hBWithPS[centBin], "TriggerContent");
005408df 374 cTriggerContent->Draw();
b66f9801 375 cTriggerContent->Print(OutFileNamePDF.Data());
376 cTriggerContent->Write();
377
378 cout<<"//==================================================================================="<<endl;
005408df 379 cout<<"// new canvas with the relative content of each trigger w/o physics selection"<<endl;
b66f9801 380 cout<<"//==================================================================================="<<endl;
005408df 381
93f182e7 382 TCanvas *cRelativeTriggerContent = ProcessCanvasRelativeTriggerContent(triggersB, hBNoPS[centBin], "RelativeTriggerContent", colorInd);
005408df 383 cRelativeTriggerContent->Draw();
93ce3c40 384 cRelativeTriggerContent->Print(OutFileNamePDF.Data());
385 cRelativeTriggerContent->Write();
005408df 386
387 cout<<"//==================================================================================="<<endl;
388 cout<<"// new canvas with effect from physics selection for each trigger and background trigger "<<endl;
389 cout<<"//==================================================================================="<<endl;
390
93f182e7 391 TCanvas *cPhysSelCut = 0x0;
392 cPhysSelCut = ProcessCanvasPhysSelCut(triggersB, triggersAC, triggersE, hBNoPS[centBin], hACNoPS[centBin], hENoPS[centBin], hBWithPS[centBin], "PhysSelCutOnCollTrigger", colorInd,isHeavyIon);
005408df 393 cPhysSelCut->Draw();
394 cPhysSelCut->Print(OutFileNamePDF.Data());
395 cPhysSelCut->Write();
93f182e7 396
397 cout<<"//==================================================================================="<<endl;
398 cout<<"// new canvas with effect from physics selection for each trigger and centrality bin (only in PbPb) "<<endl;
399 cout<<"//==================================================================================="<<endl;
400
401 Int_t k=0;
402 TString canvasName;
403 TString triggerName;
404 TString legendHeader="";
405
406
407 if ( isHeavyIon ){
408 TCanvas *cPhysSelCutCentrality[10];
409
410 //loop over trigger
411 for(k = 0; k < triggersB->GetEntriesFast(); k++){
412 //skip sum of all triggers
413 if(k == (triggersB->GetEntriesFast()-1)) continue;
414 //skip some triggers
2e7189d6 415 if ( !IsTriggerSelectedForMuonPhysics(triggersB,k) ) continue;
93f182e7 416
417 canvasName = "PhysSel_trigger";
418 canvasName +=k;
419
420 TH1* hBNoPSCent[centBinMax-1]={hBNoPS[1][k],hBNoPS[2][k],hBNoPS[3][k]};
421 TH1* hACNoPSCent[centBinMax-1]={hACNoPS[1][k],hACNoPS[2][k],hACNoPS[3][k]};
422 TH1* hENoPSCent[centBinMax-1]={hENoPS[1][k],hENoPS[2][k],hENoPS[3][k]};
423 TH1* hBWithPSCent[centBinMax-1]={hBWithPS[1][k],hBWithPS[2][k],hBWithPS[3][k]};
424
425 cPhysSelCutCentrality[k] = ProcessCanvasPhysSelCutCentrality(triggersB, triggersAC, triggersE, hBNoPSCent, hACNoPSCent, hENoPSCent, hBWithPSCent, k, canvasName, colorInd, centLegendNameShort+1, isHeavyIon);
426 cPhysSelCutCentrality[k]->Draw();
427 cPhysSelCutCentrality[k]->Print(OutFileNamePDF.Data());
428 cPhysSelCutCentrality[k]->Write();
429
430 }
431 }
432
433
434 cout<<"//==================================================================================="<<endl;
435 cout<<"// new canvas for centrality percentile check (only in PbPb) "<<endl;
436 cout<<"//==================================================================================="<<endl;
437
438 if ( isHeavyIon ){
439 TCanvas *cCentralityCheck[10];
440
441 //loop over trigger
442 for(k = 0; k < triggersB->GetEntriesFast(); k++){
443 //skip sum of all triggers
444 if(k == (triggersB->GetEntriesFast()-1)) continue;
445 //skip some triggers
2e7189d6 446 if ( !IsTriggerSelectedForMuonPhysics(triggersB,k) ) continue;
447
93f182e7 448 canvasName = "CentralityCheck_trigger";
449 canvasName +=k;
450
451 TH1* hBNoPSCent[centBinMax-1]={hBNoPS[1][k],hBNoPS[2][k],hBNoPS[3][k]};
452 TH1* hBWithPSCent[centBinMax-1]={hBWithPS[1][k],hBWithPS[2][k],hBWithPS[3][k]};
453
454 cCentralityCheck[k] = ProcessCanvasCentralityPercentile(triggersB,hBNoPSCent,hBWithPSCent,k,canvasName,colorInd,centLegendNameShort+1 );
455
456 cCentralityCheck[k]->Draw();
457 cCentralityCheck[k]->Print(OutFileNamePDF.Data());
458 cCentralityCheck[k]->Write();
459
460 }
461 }
462
463
93ce3c40 464
005408df 465 cout<<"//==================================================================================="<<endl;
466 cout<<"// Ratio of tracks over trigger type (3 canvases) "<<endl;
467 cout<<"//==================================================================================="<<endl;
468
469 //Print a canvas per trigger type
93f182e7 470 TCanvas *cTracksoverTrigger[centBinMax][10];
471 TCanvas* cTrackMultB[centBinMax][10];
472 TCanvas* cRatioTrackB[centBinMax][10];
005408df 473
93f182e7 474
475
476 //loop on centrality bin
477 for ( centBin = 0; centBin < centBinMaxLoop; centBin++){
478 if ( isHeavyIon ) legendHeader = centLegendName[centBin];
479 //loop over trigger
480 for(k = 0; k < triggersB->GetEntriesFast(); k++){
481 //skip sum of all triggers
482 if(k == (triggersB->GetEntriesFast()-1)) continue;
483 //skip some triggers
2e7189d6 484 if ( !IsTriggerSelectedForMuonPhysics(triggersB,k) ) continue;
485
93f182e7 486 canvasName = "RatioTrackTypes_cent";
487 canvasName += centBin;
488 canvasName +="trigger";
489 canvasName +=k;
490 cTracksoverTrigger[centBin][k]= ProcessCanvasTracksoverTrigger(triggersB, hB[centBin], hTrackerB[centBin], hTriggerB[centBin], hMatchedB[centBin], hAllTracksB[centBin], k, canvasName,legendHeader);
491 cTracksoverTrigger[centBin][k]->Draw();
492 cTracksoverTrigger[centBin][k]->Print(OutFileNamePDF.Data());
493 cTracksoverTrigger[centBin][k]->Write();
494
495 canvasName = "TrackMult_cent";
496 canvasName += centBin;
497 canvasName +="trigger";
498 canvasName +=k;
499 cTrackMultB[centBin][k]= ProcessCanvasTrackMultB(triggersB, hB[centBin], hTrackerB[centBin], hTriggerB[centBin], hMatchedB[centBin], hAllTracksB[centBin], k, canvasName, legendHeader);
500 cTrackMultB[centBin][k]->Draw();
501 cTrackMultB[centBin][k]->Print(OutFileNamePDF.Data());
502 cTrackMultB[centBin][k]->Write();
503
504 canvasName = "RatioTrackB_cent";
505 canvasName += centBin;
506 canvasName +="trigger";
507 canvasName +=k;
508 cRatioTrackB[centBin][k]= ProcessCanvasRatioTrackB(triggersB, hB[centBin], hTrackerB[centBin], hTriggerB[centBin], hMatchedB[centBin], hAllTracksB[centBin], k, canvasName, legendHeader);
509 cRatioTrackB[centBin][k]->Draw();
510 cRatioTrackB[centBin][k]->Print(OutFileNamePDF.Data());
511 cRatioTrackB[centBin][k]->Write();
512 }
b66f9801 513 }
005408df 514
515 cout<<"//===================================================="<<endl;
516 cout<<"// Draw matched tracks asymmetry for mus type trigger "<<endl;
517 cout<<"//===================================================="<<endl;
518
519 //Print a canvas per trigger type
93f182e7 520 TCanvas *cAsymMatched[centBinMax][10];
521
522 //Loop on centrality
523 for ( centBin = 0; centBin < centBinMaxLoop; centBin++){
524 if ( isHeavyIon ) legendHeader = centLegendName[centBin];
525 //loop over trigger
526 for(k = 0; k < triggersB->GetEntriesFast(); k++){
527 //skip sum of all triggers
528 if(k == (triggersB->GetEntriesFast()-1)) continue;
529 //skip some triggers
2e7189d6 530 if ( !IsTriggerSelectedForMuonPhysics(triggersB,k) ) continue;
531
532 canvasName = "AsymMatched";
533 canvasName += centBin;
534 canvasName +="trigger";
535 canvasName +=k;
536 cAsymMatched[centBin][k]= ProcessCanvasAsymMatched(triggersB, hPosMatchedB[centBin], hNegMatchedB[centBin], hAllMatchedB[centBin], k, canvasName,legendHeader);
93f182e7 537 cAsymMatched[centBin][k]->Draw();
538 cAsymMatched[centBin][k]->Print(OutFileNamePDF.Data());
539 cAsymMatched[centBin][k]->Write();
540 }
005408df 541 }
b66f9801 542 cout<<"//=================================================="<<endl;
543 cout<<"// Draw high pt tracks per trigger"<<endl;
005408df 544 cout<<"//=================================================="<<endl;
545
546 //Print a canvas per trigger type
93f182e7 547 TCanvas *cHighPtMuons[3][10];
548
549 //Loop on centrality
550 for ( centBin = 0; centBin < centBinMaxLoop; centBin++){
551 if ( isHeavyIon ) legendHeader = centLegendName[centBin];
552 //loop over trigger
553 for(k = 0; k < triggersB->GetEntriesFast(); k++){
554 //skip sum of all triggers
555 if(k == (triggersB->GetEntriesFast()-1)) continue;
556 //skip some triggers
2e7189d6 557 if ( !IsTriggerSelectedForMuonPhysics(triggersB,k) ) continue;
005408df 558
2e7189d6 559 canvasName = "HighPtMuons";
560 canvasName += centBin;
561 canvasName +="trigger";
562 canvasName +=k;
93f182e7 563
564 cHighPtMuons[centBin][k]= ProcessCanvasHighPtMuons(triggersB, hB[centBin], hMatchedLowPtB[centBin], hMatchedHighPtB[centBin], k, canvasName,legendHeader);
565 cHighPtMuons[centBin][k]->Draw();
566 cHighPtMuons[centBin][k]->Print(OutFileNamePDF.Data());
567 cHighPtMuons[centBin][k]->Write();
568 }
b66f9801 569 }
005408df 570
b66f9801 571 // close merged file
93ce3c40 572 globalFile->Close();
b66f9801 573
b66f9801 574 //===================================================================================
575 //Print out the number of trigger without and with Phys. Sel.
576 //===================================================================================
577
93f182e7 578 centBin = 0;
b66f9801 579 cout << endl << endl;
580 //====================================================
581 if (PRINTSTAT){
93f182e7 582 if ( triggersB->At(kCMUS) ) {
b66f9801 583
93f182e7 584 // set the format to print labels
585 THashList* labels = hBWithPS[centBin][kCMUS]->GetXaxis()->GetLabels();
586 TString format(Form("\n%%%ds %%9d",0));
587 Int_t nRuns=0;
b66f9801 588
93f182e7 589 // print value for each label
590 TObjString* label = 0x0;
591 TIter nextLabel(labels);
592 cout << "-------------------------------------------------" << endl;
593 cout << "Run Number" << "\t Number of "<< ( (TObjString*) triggersB->At(kCMUS) )->GetString()<<" after Phys. Sel. " << endl ;
594 while ((label = static_cast<TObjString*>(nextLabel()))) {
595 nRuns++;
596 Int_t bin = (Int_t) label->GetUniqueID();
597 printf(format.Data(), label->String().Data(), (Int_t) hBWithPS[centBin][kCMUS]->GetBinContent(bin));
598 }
599 printf("\n========== Total #runs = %d ==============\n",nRuns);
600 printf("\n\n");
b66f9801 601
b66f9801 602
93f182e7 603 cout << "-------------------------------------------------" << endl;
604 cout << "Total statistic" << endl;
605 cout << " " << endl ;
606
607 cout << "-------------------------------------------------------------------" << endl;
608 cout<<"Number of triggers w/o Phys. Sel./ w/ Phys. Sel (Phys. Sel. cut in %)"<<endl;
609 for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
610 TString triggerNameB = ( (TObjString*) triggersB->At(i) )->GetString();
611 TString triggerNameAC = ( (TObjString*) triggersAC->At(i) )->GetString();
612 TString triggerNameE = ( (TObjString*) triggersE->At(i) )->GetString();
005408df 613
93f182e7 614 Int_t cutinpercent = 0;
615 printf("%10s %30s %30s\n",triggerNameB.Data(),triggerNameAC.Data(),triggerNameE.Data());
616 if(NumOfBNoPS[centBin][i]) cutinpercent = (Int_t) ((Double_t)(NumOfBNoPS[centBin][i]-NumOfBWithPS[centBin][i])/(NumOfBNoPS[centBin][i])*100.);
617 printf("%5.2e / %.2e (%d%%)", (Double_t) NumOfBNoPS[centBin][i],(Double_t) NumOfBWithPS[centBin][i],cutinpercent);
618 cutinpercent = 0;
619 if(NumOfACNoPS[centBin][i]) cutinpercent = (Int_t) ((Double_t)(NumOfACNoPS[centBin][i]-NumOfACWithPS[centBin][i])/(NumOfACNoPS[centBin][i])*100.);
620 printf("%15.2e / %.2e (%d%%)", (Double_t)NumOfACNoPS[centBin][i],(Double_t)NumOfACWithPS[centBin][i],cutinpercent);
621 cutinpercent = 0;
622 if(NumOfENoPS[centBin][i]) cutinpercent = (Int_t) ((Double_t)(NumOfENoPS[centBin][i]-NumOfEWithPS[centBin][i])/(NumOfENoPS[centBin][i])*100.);
623 printf("%15.2e / %.2e (%d%%)\n", (Double_t)NumOfENoPS[centBin][i],(Double_t)NumOfEWithPS[centBin][i],cutinpercent);
005408df 624
93f182e7 625 }
626 }
b66f9801 627 }
628
629
630 //return;
005408df 631
b66f9801 632
93ce3c40 633 //--------------------------------------------- //
634 // monitor quantities run per run //
635 //--------------------------------------------- //
b8e17107 636 TH1F* hTriggerCutVsRun[2], *hTriggerCutWidthVsRun[2];
637 for ( Int_t ihisto=0; ihisto<2; ++ihisto ) {
638 TString cutName = ( ihisto == 0 ) ? "Lpt" : "Hpt";
639 hTriggerCutVsRun[ihisto] = new TH1F(Form("hTriggerCutVsRun%s", cutName.Data()), Form("Trigger %s cut per run", cutName.Data()), 10000,1,10000);
640 hTriggerCutWidthVsRun[ihisto] = (TH1F*)hTriggerCutVsRun[ihisto]->Clone(Form("hTriggerCutWidthVsRun%s", cutName.Data()));
641 }
005408df 642 TF1* fitMatchTrig = new TF1("fitMatchTrig","[3] + [0] * ( 1. + TMath::Erf((x - [1]) / [2]))", 0.1, 6.);
93ce3c40 643 TH1F* hNClustersPerTrackVsRun_Mean = new TH1F("hNClustersPerTrackVsRun_Mean", "averaged number of associated clusters per track;run;<n_{clusters}>",10000,1,10000);
644 TH1F* hNClustersPerTrackVsRun_Sigma = new TH1F("hNClustersPerTrackVsRun_Sigma", "dispersion of the number of associated clusters per track;run;#sigma_{n_{clusters}}",10000,1,10000);
645 TH1F* hNChamberHitPerTrack_Mean = new TH1F("hNChamberHitPerTrack_Mean", "averaged number of chambers hit per track;run;<n_{chamber hit}>",10000,1,10000);
646 TH1F* hNChamberHitPerTrack_Sigma = new TH1F("hNChamberHitPerTrack_Sigma", "dispersion of the number of chambers hit per track;run;#sigma_{n_{chamber hit}}",10000,1,10000);
647 TH1F* hChi2_Mean = new TH1F("hChi2_Mean", "averaged normalized #chi^{2} distribution;run;<#chi^{2} / ndf>",10000,1,10000);
648 TH1F* hChi2_Sigma = new TH1F("hChi2_Sigma", "dispersion of normalized #chi^{2} distribution;run;#sigma_{#chi^{2} / ndf}",10000,1,10000);
649 TH1F* hNClustersInCh[10];
4916d740 650 for (Int_t ich=0; ich<10; ich++){
651 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);
652 }
93ce3c40 653 TH1F* hClusterHitMapXInCh[10];
4916d740 654 for (Int_t ich=0; ich<10; ich++){
655 hClusterHitMapXInCh[ich] = new TH1F(Form("hClusterHitMapXInCh%d",ich+1), Form("averaged cluster position distribution in chamber %d;X (cm)",ich+1),10000,1,10000);
656 }
93ce3c40 657 TH1F* hClusterHitMapYInCh[10];
4916d740 658 for (Int_t ich=0; ich<10; ich++){
659 hClusterHitMapYInCh[ich] = new TH1F(Form("hClusterHitMapYInCh%d",ich+1), Form("averaged cluster position distribution in chamber %d;Y (cm)",ich+1),10000,1,10000);
660 }
93ce3c40 661 Int_t ibin = 1;
662
663 // Are the runs stored locally or in alien?
664 Int_t isAlienFile = 0;
665 if(alienBaseDir.Contains("alien:")){
666 isAlienFile = 1;
667 alienBaseDir.ReplaceAll("alien://","");
668 }
b66f9801 669 cout<<"============================================================"<<endl;
005408df 670 cout<< "Monitoring quantities run per run: loop over "<<runs->GetEntriesFast()<<" runs."<<endl;
b66f9801 671 cout<<" directory = "<<alienBaseDir.Data()<<endl;
672 cout<<"============================================================"<<endl;
93ce3c40 673 // Loop over runs
005408df 674 for ( Int_t irun=0; irun<runs->GetEntriesFast(); irun++ ) {
93ce3c40 675
005408df 676 TString run = ((TObjString*)runs->UncheckedAt(irun))->GetString();
677 TString run2 = ((TObjString*)runs2->UncheckedAt(irun))->GetString();
93ce3c40 678 // get the file (or list of files) to be analyzed
679 TString command;
680 TGridResult *res = 0;
681 TObjString *objs = 0;
682
683 if(isAlienFile){
b66f9801 684 command = Form("find %s/ %s/%s", alienBaseDir.Data(), run.Data(), QAFileName);
93ce3c40 685 res = gGrid->Command(command);
686 if (!res) {
93f182e7 687 Error("PlotMuonQA","no result for the command: %s",command.Data());
93ce3c40 688 return;
689 }
690 }
691 else{
692 res = new TGridResult();
693
694 if(runList){
b66f9801 695 objs = new TObjString(Form("%s/%s/%s", alienBaseDir.Data(), run2.Data(), QAFileName));
93ce3c40 696 res->Add(objs);
697 }
698 else {
699 //loop over the directory to find the root files
700 void *dir = gSystem->OpenDirectory(alienBaseDir.Data());
701 TString sDirFilename;
702 Int_t iEntry=0, iFile=0;
93ce3c40 703 while(kTRUE){
704 iEntry++;
705 const char* dirFilename = gSystem->GetDirEntry(dir);
706 if(!dirFilename) break;
707 sDirFilename = dirFilename;
708 if(!sDirFilename.IsDigit()) continue;
709 iFile++;
b66f9801 710 objs = new TObjString(Form("%s/%s/%s", alienBaseDir.Data(), sDirFilename.Data(), QAFileName));
93ce3c40 711 res->Add(objs);
712 }
713 }
714 }
715
716 // Loop over 'find' results and get next LFN
717 TIter nextmap(res);
718 TMap *map = 0;
719
720 //some checks
721 Int_t iLoop=0, iLoopMax=200;
722 while (kTRUE){
723
724 // get the current file url
725 if(isAlienFile){
726 map=(TMap*)nextmap();
727 if(!map) break;
728 objs = dynamic_cast<TObjString*>(map->GetValue("turl"));
729 }
730 else{
731 objs=(TObjString*)nextmap();
732 if(!objs) break;
733 }
734 //in case of infinite loop
735 iLoop++;
736 if(iLoop>iLoopMax) break;
737
738 if (!objs || !objs->GetString().Length()) {
93f182e7 739 Error("PlotMuonQA","turl/obj not found for the run %s... SKIPPING", run.Data());
93ce3c40 740 continue;
741 }
742
b69e18be 743 run = objs->GetString();
744 run.ReplaceAll(Form("/%s",QAFileName), "");
745 run.ReplaceAll(alienBaseDir, "");
746 run.Remove(TString::kLeading, '/');
747 run.Remove(TString::kLeading, '0');
748
2e7189d6 749 if ( ! selectRuns.Contains(run.Data()) ) continue;
b69e18be 750
93ce3c40 751 // open the outfile for this run
752 TFile *runFile = TFile::Open(objs->GetString());
753 if (!runFile || ! runFile->IsOpen()) {
93f182e7 754 Error("PlotMuonQA","failed to open file: %s", objs->GetName());
93ce3c40 755 continue;//return;
756 }
757 runFile->Cd("MUON_QA");
758
759 // get interesting histos
760 TObjArray* general1 = static_cast<TObjArray*>(runFile->FindObjectAny("general1"));
4916d740 761 TObjArray* general2 = static_cast<TObjArray*>(runFile->FindObjectAny("general2"));
93ce3c40 762 TObjArray* expert = static_cast<TObjArray*>(runFile->FindObjectAny("expert"));
b66f9801 763
4916d740 764 if (!general1 || !general2 || !expert){
93f182e7 765 Error("PlotMuonQA","All objects not here !!! ===> Skipping...for %s",objs->GetName());
4916d740 766 continue;
767 }
b69e18be 768
4916d740 769 TH1* hNClustersPerTrack = static_cast<TH1*>(general1->FindObject("hNClustersPerTrack"));
93ce3c40 770 TH1* hNChamberHitPerTrack = static_cast<TH1*>(general1->FindObject("hNChamberHitPerTrack"));
771 TH1* hChi2 = static_cast<TH1*>(general1->FindObject("hChi2"));
4916d740 772 TH1* hNClustersPerCh = static_cast<TH1*>(general2->FindObject("hNClustersPerCh"));
b8e17107 773 TH1* hPtDistrib = static_cast<TH1*>(general1->FindObject("hPt"));
774 TH1* hPtDistribLpt = static_cast<TH1*>(general1->FindObject("hPtMatchLpt"));
775 TH1* hPtDistribHpt = static_cast<TH1*>(general1->FindObject("hPtMatchHpt"));
776 if ( hPtDistrib && hPtDistribLpt && hPtDistribHpt ) {
777 if ( hPtDistrib->GetSumw2N() == 0 ) hPtDistrib->Sumw2();
778 TH1* histoMatch[2] = {hPtDistribLpt, hPtDistribHpt};
779 for ( Int_t ihisto=0; ihisto<2; ++ihisto ) {
780 if ( histoMatch[ihisto]->GetSumw2N() == 0 ) histoMatch[ihisto]->Sumw2();
781 if ( histoMatch[ihisto]->GetEntries() == 0 ) continue;
782 histoMatch[ihisto]->Divide(hPtDistrib);
783 Double_t minEff = 99999., maxEff = -1.;
784 Double_t ptMinFit = 0.1;
785 Double_t ptMaxFit = 6.;
786 Int_t ptBinLow = histoMatch[ihisto]->GetXaxis()->FindBin(ptMinFit);
787 Int_t ptBinHigh = histoMatch[ihisto]->GetXaxis()->FindBin(ptMaxFit);
788 for ( Int_t currBin=ptBinLow; currBin<=ptBinHigh; currBin++ ) {
789 Double_t currEff = histoMatch[ihisto]->GetBinContent(currBin);
790 Double_t currPt = histoMatch[ihisto]->GetXaxis()->GetBinCenter(currBin);
791 if ( currPt < 1.5 && minEff > currEff ) {
792 ptMinFit = currPt;
793 minEff = currEff;
794 }
795 if ( currPt > 0.5 && maxEff < currEff ) {
796 ptMaxFit = currPt;
797 maxEff = currEff;
798 }
799 } // loop on histo bins
800 fitMatchTrig->SetParameters(0.5, 0.5, 0.8, 0.2);
801 fitMatchTrig->SetParLimits(0,0.,1.);
802 fitMatchTrig->SetParLimits(1,0.,5.);
803 fitMatchTrig->SetParLimits(2,0.,5.);
804 fitMatchTrig->SetParLimits(3,0.,0.5);
805 histoMatch[ihisto]->Fit(fitMatchTrig,"RQ0","",ptMinFit,ptMaxFit);
806 Double_t ptCut = fitMatchTrig->GetParameter(1);
807 Double_t ptCutErr = fitMatchTrig->GetParError(1);
808 Double_t ptCutWidth = fitMatchTrig->GetParameter(2);
809 if ( ptCut < 0 || ptCut > 10. ) {
810 ptCut = ptCutErr = ptCutWidth = 0.;
811 }
812 hTriggerCutVsRun[ihisto]->SetBinContent(ibin, ptCut);
813 hTriggerCutVsRun[ihisto]->SetBinError(ibin, ptCutErr);
814 hTriggerCutWidthVsRun[ihisto]->SetBinContent(ibin, ptCut);
815 hTriggerCutWidthVsRun[ihisto]->SetBinError(ibin, ptCutWidth);
816 } // loop on match histos
005408df 817 }
93ce3c40 818 TH2* hClusterHitMapInCh[10];
819 for(Int_t ich=0; ich<10; ich++) hClusterHitMapInCh[ich] = static_cast<TH2*>(expert->FindObject(Form("hClusterHitMapInCh%d",ich+1)));
820
821 // skip empty runs... not anymore ! cs !
822 if (!hNClustersPerCh) {
93f182e7 823 Warning("PlotMUONQA","File: %s has empty histograms !", objs->GetName());
93ce3c40 824 hNClustersPerTrackVsRun_Mean->SetBinContent(ibin, 0.);
825 hNClustersPerTrackVsRun_Mean->SetBinError(ibin, 1.);
826 hNClustersPerTrackVsRun_Sigma->SetBinContent(ibin, 0.);
827 hNClustersPerTrackVsRun_Sigma->SetBinError(ibin, 1.);
828 hNChamberHitPerTrack_Mean->SetBinContent(ibin, 0.);
829 hNChamberHitPerTrack_Mean->SetBinError(ibin, 1.);
830 hNChamberHitPerTrack_Sigma->SetBinContent(ibin, 0.);
831 hNChamberHitPerTrack_Sigma->SetBinError(ibin, 1.);
832 hChi2_Mean->SetBinContent(ibin, 0.);
833 hChi2_Mean->SetBinError(ibin, 1.);
834 hChi2_Sigma->SetBinContent(ibin, 0.);
835 hChi2_Sigma->SetBinError(ibin, 1.);
836 for (Int_t ich=0; ich<10; ich++) {
837 hNClustersInCh[ich]->SetBinContent(ibin,0.);
838 hNClustersInCh[ich]->SetBinError(ibin,1.);
839 hClusterHitMapXInCh[ich]->SetBinContent(ibin,0.);
840 hClusterHitMapXInCh[ich]->SetBinError(ibin,1.);
841 hClusterHitMapYInCh[ich]->SetBinContent(ibin,0.);
842 hClusterHitMapYInCh[ich]->SetBinError(ibin,1.);
843 }
844 //runFile->Close();
845 //continue;
846 }
847 else {
848 // fill monitoring plots
849 hNClustersPerTrackVsRun_Mean->SetBinContent(ibin, hNClustersPerTrack->GetMean());
850 hNClustersPerTrackVsRun_Mean->SetBinError(ibin, hNClustersPerTrack->GetMeanError());
851 hNClustersPerTrackVsRun_Sigma->SetBinContent(ibin, hNClustersPerTrack->GetRMS());
852 hNClustersPerTrackVsRun_Sigma->SetBinError(ibin, hNClustersPerTrack->GetRMSError());
853 hNChamberHitPerTrack_Mean->SetBinContent(ibin, hNChamberHitPerTrack->GetMean());
854 hNChamberHitPerTrack_Mean->SetBinError(ibin, hNChamberHitPerTrack->GetMeanError());
855 hNChamberHitPerTrack_Sigma->SetBinContent(ibin, hNChamberHitPerTrack->GetRMS());
856 hNChamberHitPerTrack_Sigma->SetBinError(ibin, hNChamberHitPerTrack->GetRMSError());
857 hChi2_Mean->SetBinContent(ibin, hChi2->GetMean());
858 hChi2_Mean->SetBinError(ibin, hChi2->GetMeanError());
859 hChi2_Sigma->SetBinContent(ibin, hChi2->GetRMS());
860 hChi2_Sigma->SetBinError(ibin, hChi2->GetRMSError());
861 for (Int_t ich=0; ich<10; ich++) {
862 hNClustersInCh[ich]->SetBinContent(ibin,hNClustersPerCh->GetBinContent(ich+1));
863 hNClustersInCh[ich]->SetBinError(ibin,hNClustersPerCh->GetBinError(ich+1));
864 hClusterHitMapXInCh[ich]->SetBinContent(ibin,hClusterHitMapInCh[ich]->GetMean(1));
865 hClusterHitMapXInCh[ich]->SetBinError(ibin,hClusterHitMapInCh[ich]->GetMeanError(1));
866 hClusterHitMapYInCh[ich]->SetBinContent(ibin,hClusterHitMapInCh[ich]->GetMean(2));
4916d740 867 hClusterHitMapYInCh[ich]->SetBinError(ibin,hClusterHitMapInCh[ich]->GetMeanError(2));
93ce3c40 868 }
869 }
870
871 // set labels
93f182e7 872 for ( Int_t ihisto=0; ihisto<2; ++ihisto ) {
873 hTriggerCutVsRun[ihisto]->GetXaxis()->SetBinLabel(ibin,run.Data());
874 hTriggerCutWidthVsRun[ihisto]->GetXaxis()->SetBinLabel(ibin,run.Data());
875 }
93ce3c40 876 hNClustersPerTrackVsRun_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
877 hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());
878 hNChamberHitPerTrack_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
879 hNChamberHitPerTrack_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());
880 hChi2_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
881 hChi2_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());
882 for (Int_t ich=0; ich<10; ich++){
883 hNClustersInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
884 hClusterHitMapXInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
885 hClusterHitMapYInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
886 }
005408df 887
93ce3c40 888 // close outfile for this run
889 runFile->Close();
890 ibin++;
891 }
892
893 delete res;
894 }
895
4916d740 896 //sort label
897 hNClustersPerTrackVsRun_Mean->LabelsOption("a");
898 hNClustersPerTrackVsRun_Sigma->LabelsOption("a");
899 hNChamberHitPerTrack_Mean->LabelsOption("a");
900 hNChamberHitPerTrack_Sigma->LabelsOption("a");
901 hChi2_Mean->LabelsOption("a");
902 hChi2_Sigma->LabelsOption("a");
903
904 for(Int_t ich=0; ich<10; ich++){
905 hNClustersInCh[ich]->LabelsOption("a");
906 hClusterHitMapXInCh[ich]->LabelsOption("a");
907 hClusterHitMapYInCh[ich]->LabelsOption("a");
005408df 908 }
4916d740 909
93ce3c40 910 TString dirToGo = OutFileNameROOT.Data(); dirToGo+=":/";
911 gDirectory->Cd(dirToGo.Data());
912 //==================================================
913 //Display Mean and Sigma of the number of associated clusters to a track
914 TLegend *lNClusters = new TLegend(0.75,0.85,0.99,0.99);
915 lNClusters->AddEntry(hNClustersPerTrackVsRun_Mean,"clusters","PL");
916 lNClusters->AddEntry(hNChamberHitPerTrack_Mean,"chamber hit","PL");
917
918 TCanvas* cNClusters = new TCanvas("cNClusters","cNClusters",1200,900);
919 cNClusters->Divide(1,2);
920 cNClusters->cd(1);
921 //hNClustersPerTrackVsRun_Mean->SetMaximum(11);
922 hNClustersPerTrackVsRun_Mean->SetMinimum(7);
923 hNClustersPerTrackVsRun_Mean->SetStats(kFALSE);
924 hNClustersPerTrackVsRun_Mean->GetXaxis()->SetRange(1,ibin-1);
925 hNClustersPerTrackVsRun_Mean->GetXaxis()->SetNdivisions(1,kFALSE);
926 //hNClustersPerTrackVsRun_Mean->LabelsOption("u");
4916d740 927 hNClustersPerTrackVsRun_Mean->SetLabelSize(0.04);
93ce3c40 928 hNClustersPerTrackVsRun_Mean->SetTitle("averaged number of associated clusters or of the number of chamber hit per track");
929 hNClustersPerTrackVsRun_Mean->SetLineWidth(2);
930 hNClustersPerTrackVsRun_Mean->Draw("e");
931 hNChamberHitPerTrack_Mean->SetLineColor(kRed);
932 hNChamberHitPerTrack_Mean->SetLineWidth(2);
933 hNChamberHitPerTrack_Mean->Draw("esame");
934 lNClusters->Draw("same");
935
936 cNClusters->cd(2);
937 //hNClustersPerTrackVsRun_Sigma->SetMaximum(1.1);
938 hNClustersPerTrackVsRun_Sigma->SetMinimum(0.4);
939 hNClustersPerTrackVsRun_Sigma->SetStats(kFALSE);
940 hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetRange(1,ibin-1);
941 hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetNdivisions(1,kFALSE);
942 //hNClustersPerTrackVsRun_Sigma->LabelsOption("u");
4916d740 943 hNClustersPerTrackVsRun_Sigma->SetLabelSize(0.04);
93ce3c40 944 hNClustersPerTrackVsRun_Sigma->SetTitle("dispersion of the number of associated clusters or of the number of chamber hit per track");
945 hNClustersPerTrackVsRun_Sigma->SetLineWidth(2);
946 hNClustersPerTrackVsRun_Sigma->Draw("e");
947 hNChamberHitPerTrack_Sigma->SetLineWidth(2);
948 hNChamberHitPerTrack_Sigma->SetLineColor(kRed);
949 hNChamberHitPerTrack_Sigma->Draw("esame");
950 lNClusters->Draw("same");
951
952 cNClusters->Print(OutFileNamePDF.Data());
953 cNClusters->Write();
954
955
956 //==================================================
957 // Display average number of cluster per chamber
958 TLegend *lNClustersPerCh = new TLegend(0.92,0.45,0.99,0.99);
959 TCanvas* cNClustersPerCh = new TCanvas("cNClustersPerCh","cNClustersPerCh",1200,900);
960 cNClustersPerCh->cd();
961 cNClustersPerCh->SetRightMargin(0.1);
962 hNClustersInCh[0]->SetStats(kFALSE);
963 hNClustersInCh[0]->GetXaxis()->SetRange(1,ibin-1);
964 hNClustersInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
965 //hNClustersInCh[0]->LabelsOption("u");
b66f9801 966 hNClustersInCh[0]->SetLabelSize(0.02);
93ce3c40 967 hNClustersInCh[0]->SetTitle("averaged number of clusters in chamber i per track");
968 hNClustersInCh[0]->SetMaximum(1.2);
969 hNClustersInCh[0]->SetMinimum(0.01);
970 for (Int_t ich=0; ich<10; ich++) {
971 hNClustersInCh[ich]->SetLineColor(ich+1+ich/9);
972 hNClustersInCh[ich]->SetLineWidth(2);
973 if (ich == 0) hNClustersInCh[ich]->Draw("e");
974 else hNClustersInCh[ich]->Draw("esame");
975 lNClustersPerCh->AddEntry(hNClustersInCh[ich],Form("ch%d",ich+1),"PL");
976 }
977 lNClustersPerCh->Draw("same");
978
979 cNClustersPerCh->Print(OutFileNamePDF.Data());
980 cNClustersPerCh->Write();
981
982 //==================================================
983 // Display average X and Y position of clusters per chamber
984 TLegend *lClusterHitMapPerCh = new TLegend(0.92,0.45,0.99,0.99);
985 TCanvas* cClusterHitMapPerCh = new TCanvas("cClusterHitMapPerCh","cClusterHitMapPerCh",1200,900);
986 cClusterHitMapPerCh->Divide(1,2);
987 cClusterHitMapPerCh->GetPad(1)->SetRightMargin(0.1);
988 cClusterHitMapPerCh->GetPad(2)->SetRightMargin(0.1);
989
990 cClusterHitMapPerCh->cd(1);
991 hClusterHitMapXInCh[0]->SetStats(kFALSE);
992 hClusterHitMapXInCh[0]->GetXaxis()->SetRange(1,ibin-1);
993 hClusterHitMapXInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
994 //hNClustersInCh[0]->LabelsOption("u");
4916d740 995 hClusterHitMapXInCh[0]->SetLabelSize(0.04);
93ce3c40 996 hClusterHitMapXInCh[0]->SetTitle("<X> of clusters - associated to a track - in chamber i");
997 hClusterHitMapXInCh[0]->SetMaximum(30);
998 hClusterHitMapXInCh[0]->SetMinimum(-30);
999 for (Int_t ich=0; ich<10; ich++) {
1000 hClusterHitMapXInCh[ich]->SetLineColor(ich+1+ich/9);
1001 hClusterHitMapXInCh[ich]->SetLineWidth(2);
1002 if (ich == 0) hClusterHitMapXInCh[ich]->Draw("e");
1003 else hClusterHitMapXInCh[ich]->Draw("esame");
1004
1005 lClusterHitMapPerCh->AddEntry(hClusterHitMapXInCh[ich],Form("ch%d",ich+1),"PL");
1006 }
1007 lClusterHitMapPerCh->Draw("same");
1008
1009 cClusterHitMapPerCh->cd(2);
1010 hClusterHitMapYInCh[0]->SetStats(kFALSE);
1011 hClusterHitMapYInCh[0]->GetXaxis()->SetRange(1,ibin-1);
1012 hClusterHitMapYInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
1013 //hNClustersInCh[0]->LabelsOption("u");
4916d740 1014 hClusterHitMapYInCh[0]->SetLabelSize(0.04);
93ce3c40 1015 hClusterHitMapYInCh[0]->SetTitle("<Y> of clusters - associated to a track - in chamber i");
1016 hClusterHitMapYInCh[0]->SetMaximum(30);
1017 hClusterHitMapYInCh[0]->SetMinimum(-30);
1018 for (Int_t ich=0; ich<10; ich++) {
1019 hClusterHitMapYInCh[ich]->SetLineColor(ich+1+ich/9);
1020 hClusterHitMapYInCh[ich]->SetLineWidth(2);
1021 if (ich == 0) hClusterHitMapYInCh[ich]->Draw("e");
1022 else hClusterHitMapYInCh[ich]->Draw("esame");
1023 }
1024 lClusterHitMapPerCh->Draw("same");
1025
1026 cClusterHitMapPerCh->Print(OutFileNamePDF.Data());
1027 cClusterHitMapPerCh->Write();
1028
1029
1030 //==================================================
1031 // Display tracks ChiSquare
1032 TCanvas* cChi2 = new TCanvas("cChi2","cChi2",1200,900);
1033 cChi2->Divide(1,2);
1034 cChi2->cd(1);
1035 hChi2_Mean->SetStats(kFALSE);
1036 hChi2_Mean->GetXaxis()->SetRange(1,ibin-1);
1037 hChi2_Mean->GetXaxis()->SetNdivisions(1,kFALSE);
1038 //hChi2_Mean->LabelsOption("u");
4916d740 1039 hChi2_Mean->SetLabelSize(0.04);
93ce3c40 1040 hChi2_Mean->SetLineWidth(2);
1041 hChi2_Mean->Draw("e");
1042
1043 cChi2->cd(2);
1044 hChi2_Sigma->SetStats(kFALSE);
1045 hChi2_Sigma->GetXaxis()->SetRange(1,ibin-1);
1046 hChi2_Sigma->GetXaxis()->SetNdivisions(1,kFALSE);
1047 //hChi2_Sigma->LabelsOption("u");
4916d740 1048 hChi2_Sigma->SetLabelSize(0.04);
93ce3c40 1049 hChi2_Sigma->SetLineWidth(2);
1050 hChi2_Sigma->Draw("e");
1051
1052 cChi2->Print(OutFileNamePDF.Data());
1053 cChi2->Write();
005408df 1054
b8e17107 1055 //==================================================
1056 // Display track Lpt/Hpt
1057 if ( hTriggerCutVsRun[0] && hTriggerCutVsRun[1] ) {
1058 TCanvas* cLptHpt = new TCanvas("cLptHpt","cLptHpt",1200,900);
1059 cLptHpt->Divide(1,2);
1060 TLegend* legLptHpt = new TLegend(0.72,0.7,0.9,0.85);
1061 legLptHpt->SetBorderSize(1);
1062 for ( Int_t ihisto=0; ihisto<2; ++ihisto) {
1063 cLptHpt->cd(ihisto+1);
1064 TH1* currHistos[2] = {hTriggerCutVsRun[ihisto], hTriggerCutWidthVsRun[ihisto]};
1065 for ( Int_t jhisto=0; jhisto<2; jhisto++ ) {
1066 currHistos[jhisto]->GetXaxis()->SetRange(1,ibin-1);
1067 currHistos[jhisto]->GetYaxis()->SetRangeUser(0.,5.);
1068 currHistos[jhisto]->LabelsOption("a");
1069 currHistos[jhisto]->SetStats(kFALSE);
1070 currHistos[jhisto]->GetXaxis()->SetLabelSize(0.04);
1071 currHistos[jhisto]->SetLineWidth(2);
1072 }
1073 hTriggerCutWidthVsRun[ihisto]->SetLineColor(2);
1074 hTriggerCutWidthVsRun[ihisto]->SetMarkerColor(2);
1075 hTriggerCutWidthVsRun[ihisto]->SetFillColor(2);
1076 hTriggerCutWidthVsRun[ihisto]->SetFillStyle(3001);
1077 hTriggerCutWidthVsRun[ihisto]->Draw("e2");
1078 hTriggerCutVsRun[ihisto]->Draw("esame");
1079 if ( ihisto == 0 ) {
1080 legLptHpt->AddEntry(hTriggerCutWidthVsRun[ihisto],"Fit width","f");
1081 legLptHpt->AddEntry(hTriggerCutVsRun[ihisto],"pt cut from fit (stat error)","lp");
1082 legLptHpt->Draw("same");
1083 }
1084 }
1085 cLptHpt->Print(OutFileNamePDF.Data());
1086 cLptHpt->Write();
1087 }
005408df 1088
1089
93ce3c40 1090 // close the PDF file
1091 c1->Print(OutFileNamePDF_close.Data());
1092 rootFileOut->Close();
005408df 1093
1094
1095
1096 delete runs;
1097 delete runs2;
1098 delete triggersB;
1099 delete triggersAC;
1100 delete triggersE;
1101
b66f9801 1102 return;
93ce3c40 1103
93ce3c40 1104}
005408df 1105
1106void SetCanvas(TCanvas *canvas, Int_t logy){
1107
1108 if(!canvas) return;
1109 canvas->SetTopMargin(0.05);
1110 canvas->SetRightMargin(0.01);
1111 canvas->SetGridy(1);
1112 canvas->SetLogy(logy);
1113
1114 return;
1115}
1116
1117Bool_t IsTrigger(TObjArray *array, Int_t index, TString name){
1118
1119 Bool_t process = kFALSE;
1120
1121 if( !array) return process;
1122
1123 TString triggerName = (( (TObjString*) array->At(index) )->GetString());
1124
1125 if( triggerName.Contains(name) ) process = kTRUE;
1126
1127 return process;
1128}
1129
2e7189d6 1130Bool_t IsTriggerSelectedForMuonPhysics(TObjArray *triggersB, Int_t k){
1131
1132 if ( !triggersB ) return kFALSE;
1133 Bool_t selected;
1134 selected = (IsTrigger(triggersB,k,"CMB") || IsTrigger(triggersB, k, "CPBI") || IsTrigger(triggersB, k, "CVHN") || IsTrigger(triggersB, k, "CVLN") || IsTrigger(triggersB, k, "CCENT") || IsTrigger(triggersB, k, "CSEMI") );
1135
1136 return selected;
1137}
1138
1139
93f182e7 1140Bool_t IsHeavyIonCollision(AliCounterCollection *eventCounters){
1141
1142 if(!eventCounters) return kFALSE;
1143
1144 Double_t sum = eventCounters->GetSum("v0mult:low,int,high");
1145 Bool_t result = kTRUE;
1146 if(sum<=0) result = kFALSE;
1147
1148 cout<<" Collision type is set to ";
1149 if( result == kFALSE) cout<<"p-p"<<endl;
1150 else cout<<"heavy-ion"<<endl;
1151
1152 return result;
1153}
1154
005408df 1155TCanvas *ProcessCanvasTriggerContent(TObjArray *array, TH1 **hBNoPS, TH1 **hBWithPS, TString canvasName){
1156
1157 if(!array || !hBNoPS || !hBWithPS) return 0x0;
b66f9801 1158
005408df 1159 TString cName = "c";
1160 cName += canvasName;
1161 TCanvas *cTriggerContent = new TCanvas(canvasName,cName,1200,900);
1162 SetCanvas(cTriggerContent);
1163 cTriggerContent->cd();
1164
1165 TLegend* legcTC = new TLegend(0.2,0.15,0.50,0.40);
1166 legcTC->SetHeader("Physics Selection");
1167 legcTC->AddEntry(".","applied :","");
b66f9801 1168
005408df 1169 for(Int_t i = 0; i < array->GetEntriesFast(); i++){
1170 //skip the sum of all triggers
93f182e7 1171 if( i == (array->GetEntriesFast()-1) ) continue;
005408df 1172 hBNoPS[i]->SetLineStyle(2);
1173 if(i==0){
1174 hBNoPS[i]->SetMinimum(1e-3);
1175 hBNoPS[i]->Draw();
1176 hBWithPS[i]->Draw("same");
1177 }
1178 else{
1179 hBNoPS[i]->Draw("same");
1180 hBWithPS[i]->Draw("same");
1181 }
1182 legcTC->AddEntry(hBWithPS[i],(( (TObjString*) array->At(i) )->GetString()).Data(),"l");
1183 }
1184 legcTC->AddEntry(".","not applied :","");
1185
1186 for(Int_t i = 0; i < array->GetEntriesFast(); i++){
1187 legcTC->AddEntry(hBNoPS[i],(( (TObjString*) array->At(i) )->GetString()).Data(),"l");
1188 }
1189
1190 legcTC->Draw("same");
1191
1192 return cTriggerContent;
1193}
1194
1195TCanvas *ProcessCanvasRelativeTriggerContent(TObjArray *triggersB, TH1 **histo, TString canvasName, Int_t *colorInd){
1196
1197 if(!triggersB || !histo || !colorInd) return 0x0;
1198
1199 TString cName = "c" ;
1200 cName += canvasName;
1201 TCanvas *cRelativeTriggerContent = new TCanvas(canvasName,cName,1200,900);
1202 SetCanvas(cRelativeTriggerContent);
1203 cRelativeTriggerContent->cd();
1204
1205 TH1* ratio[10];
1206 TLegend* legcRTC = new TLegend(0.2,0.15,0.50,0.40);
1207 legcRTC->SetHeader("Physics Selection");
1208
1209 TString hName, hTriggerName;
1210 Int_t indAllTrig = triggersB->GetEntriesFast()-1;
2e7189d6 1211
005408df 1212 for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
1213 hName = "ratio";
1214 hName += ( (TObjString*) triggersB->At(i) )->GetString();
1215 ratio[i] = static_cast<TH1*> (histo[i]->Clone(hName));
1216 ratio[i]->Divide(histo[indAllTrig]);
1217 ratio[i]->SetLineWidth(2);
1218 ratio[i]->SetLineColor(colorInd[i]);
1219 if(i==0){
1220 ratio[i]->SetMaximum(1.5);
1221 ratio[i]->SetMinimum(0.001);
1222 ratio[i]->SetLabelSize(0.02);
1223 ratio[i]->GetYaxis()->SetTitle("Relative trigger content");
1224 ratio[i]->Draw("E");
1225 }
1226 else{
1227 ratio[i]->Draw("ESAME");
1228 }
1229 }
1230
1231 legcRTC->AddEntry(".","not applied :","");
1232 for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
1233 legcRTC->AddEntry(ratio[i],(( (TObjString*) triggersB->At(i) )->GetString()).Data(),"l");
1234 }
1235 legcRTC->Draw("same");
1236
1237 return cRelativeTriggerContent;
1238}
1239
93f182e7 1240TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE, TH1 **hBNoPS, TH1 **hACNoPS, TH1 **hENoPS, TH1 **hBWithPS, TString canvasName, Int_t *colorInd, Bool_t isHeavyIon){
005408df 1241
1242 if(!triggersB || !triggersE || !triggersAC || !hBNoPS || !hACNoPS || !hENoPS || !hBWithPS || !colorInd) return 0x0;
1243
93f182e7 1244 //Multiplicative factor for A,C and E triggers
1245 Float_t scale = 3; //3 for pp - 10 for PbPb
1246 if(isHeavyIon) scale = 10;
1247
005408df 1248 TString cName = "c";
1249 cName += canvasName;
1250 TCanvas *c1 = new TCanvas(canvasName,cName,1200,900);
1251 SetCanvas(c1);
1252 c1->cd();
1253
1254 TH1* ratioB[10], *ratioBNoPS[10];
1255 TH1* ratioACNoPS[10];
1256 TH1* ratioENoPS[10];
1257 TLegend* legcRTC = new TLegend(0.2,0.15,0.50,0.40);
1258 legcRTC->SetHeader("Physics Selection");
1259
1260 TString hName;
1261 for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
93f182e7 1262
1263 //scale A, C and E triggers
1264 hACNoPS[i]->Scale(scale);
1265 hENoPS[i]->Scale(scale);
1266
005408df 1267 hName = "ratio";
1268 hName += ( (TObjString*) triggersB->At(i) )->GetString();
1269 ratioB[i] = static_cast<TH1*> (hBWithPS[i]->Clone(hName));
1270 ratioB[i]->Divide(hBNoPS[i]);
1271 ratioB[i]->SetLineWidth(2);
1272 ratioB[i]->SetLineColor(colorInd[i]);
1273 hName = "ratioNoPS";
1274 hName += ( (TObjString*) triggersB->At(i) )->GetString();
1275 ratioBNoPS[i] = static_cast<TH1*> (hBNoPS[i]->Clone(hName));
1276 ratioBNoPS[i]->Divide(hBNoPS[i]);
1277 ratioBNoPS[i]->SetLineWidth(0);
1278 ratioBNoPS[i]->SetLineStyle(1);
1279 ratioBNoPS[i]->SetMarkerStyle(24+i);
1280 ratioBNoPS[i]->SetMarkerSize(1);
1281 ratioBNoPS[i]->SetLineColor(colorInd[i]);
1282 ratioBNoPS[i]->SetMarkerColor(colorInd[i]);
1283
1284 hName = "ratioACNoPS";
1285 hName += ( (TObjString*) triggersAC->At(i) )->GetString();
1286 ratioACNoPS[i] = static_cast<TH1*> (hACNoPS[i]->Clone(hName));
b69e18be 1287 if ( ratioACNoPS[i]->GetEntries() > 0 ) ratioACNoPS[i]->Divide(hBNoPS[i]);
005408df 1288 ratioACNoPS[i]->SetLineWidth(0);
1289 ratioACNoPS[i]->SetLineStyle(2);
1290 ratioACNoPS[i]->SetMarkerStyle(24+i);
1291 ratioACNoPS[i]->SetMarkerSize(1);
1292 ratioACNoPS[i]->SetLineColor(colorInd[i]);
1293 ratioACNoPS[i]->SetMarkerColor(colorInd[i]);
1294
1295
1296 hName = "ratioENoPS";
1297 hName += ( (TObjString*) triggersE->At(i) )->GetString();
1298 ratioENoPS[i] = static_cast<TH1*> (hENoPS[i]->Clone(hName));
2e7189d6 1299 if ( ratioENoPS[i]->GetEntries() > 0 ) ratioENoPS[i]->Divide(hBNoPS[i]);
005408df 1300 ratioENoPS[i]->SetLineWidth(0);
1301 ratioENoPS[i]->SetLineStyle(3);
1302 ratioENoPS[i]->SetMarkerStyle(24+i);
1303 ratioENoPS[i]->SetMarkerSize(1);
1304 ratioENoPS[i]->SetLineColor(colorInd[i]);
1305 ratioENoPS[i]->SetMarkerColor(colorInd[i]);
1306
1307
1308 if(i==0){
1309 ratioB[i]->SetMaximum(1.5);
93f182e7 1310 ratioB[i]->SetMinimum(0.05);
005408df 1311 ratioB[i]->SetLabelSize(0.02);
93f182e7 1312 ratioB[i]->GetYaxis()->SetTitle("Accepted / All from Phys. Sel.");
1313 ratioB[i]->SetTitle("Phys. Sel. for all selected triggers");
005408df 1314 ratioB[i]->Draw("E");
1315 //ratioBNoPS[i]->Draw("EPSAME");
1316 ratioACNoPS[i]->Draw("EPSAME");
1317 ratioENoPS[i]->Draw("EPSAME");
1318 }
1319 else{
1320 ratioB[i]->Draw("ESAME");
1321 //ratioBNoPS[i]->Draw("EPSAME");
1322 ratioACNoPS[i]->Draw("EPSAME");
1323 ratioENoPS[i]->Draw("EPSAME");
1324 }
1325 }
1326
1327 legcRTC->AddEntry(".","applied :","");
1328 for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
1329 legcRTC->AddEntry(ratioB[i],(( (TObjString*) triggersB->At(i) )->GetString()).Data(),"l");
1330 }
1331 legcRTC->AddEntry(".","not applied :","");
1332 for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
1333 //legcRTC->AddEntry(ratioBNoPS[i],(( (TObjString*) triggersB->At(i) )->GetString()).Data(),"pl");
93f182e7 1334 TString textLegend = ( (TObjString*) triggersAC->At(i) )->GetString();
1335 if( textLegend.CompareTo(" ") ){
1336 textLegend += " x";
1337 textLegend += scale;
1338 legcRTC->AddEntry(ratioACNoPS[i],textLegend.Data(),"pl");
1339 }
1340 textLegend = ( (TObjString*) triggersE->At(i) )->GetString();
1341 if( textLegend.CompareTo(" ") ){
1342 //cout<<"trigger="<<textLegend.Data()<<"-"<<endl;
1343 textLegend += " x";
1344 textLegend += scale;
1345 legcRTC->AddEntry(ratioENoPS[i],textLegend.Data(),"pl");
1346 }
1347 }
1348 legcRTC->Draw("same");
1349
1350
1351 return c1;
1352}
1353
1354TCanvas *ProcessCanvasPhysSelCutCentrality(TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE, TH1 **hBNoPSCent, TH1 **hACNoPSCent, TH1 **hENoPSCent, TH1 **hBWithPSCent, Int_t k, TString canvasName, Int_t *colorInd, TString *legendHeader, Bool_t isHeavyIon){
1355
1356 if(!triggersB || !triggersE || !triggersAC || !hBNoPSCent || !hACNoPSCent || !hENoPSCent || !hBWithPSCent || !colorInd || !legendHeader) return 0x0;
1357
1358 //Multiplicative factor for A,C and E triggers
1359 Float_t scale = 3; //3 for pp - 10 for PbPb
1360 if(isHeavyIon) scale = 10;
1361
1362 TString cName = "c";
1363 cName += canvasName;
1364 TCanvas *c1 = new TCanvas(canvasName,cName,1200,900);
1365 SetCanvas(c1);
1366 c1->cd();
1367
1368 Int_t const centBinMax =3;
1369 TH1* ratioB[centBinMax], *ratioBNoPS[centBinMax];
1370 TH1* ratioACNoPS[centBinMax];
1371 TH1* ratioENoPS[centBinMax];
1372 TLegend* legcRTC = new TLegend(0.2,0.15,0.50,0.40);
1373 legcRTC->SetHeader("Physics Selection");
1374
1375 TString hName;
1376
1377 Float_t yMin = 0.05, yMax = 2;
1378
1379 for(Int_t centBin = 0; centBin < centBinMax; centBin++){
1380 //scale A, C and E triggers
1381 hACNoPSCent[centBin]->Scale(scale);
1382 hENoPSCent[centBin]->Scale(scale);
1383
1384 hName = "ratio";
1385 hName += ( (TObjString*) triggersB->At(k) )->GetString();
1386 ratioB[centBin] = static_cast<TH1*> (hBWithPSCent[centBin]->Clone(hName));
1387 ratioB[centBin]->Divide(hBNoPSCent[centBin]);
1388 ratioB[centBin]->SetLineWidth(2);
1389 ratioB[centBin]->SetLineColor(colorInd[centBin]);
1390 hName = "ratioNoPS";
1391 hName += ( (TObjString*) triggersB->At(k) )->GetString();
1392 ratioBNoPS[centBin] = static_cast<TH1*> (hBNoPSCent[centBin]->Clone(hName));
1393 ratioBNoPS[centBin]->Divide(hBNoPSCent[centBin]);
1394 ratioBNoPS[centBin]->SetLineWidth(0);
1395 ratioBNoPS[centBin]->SetLineStyle(1);
1396 ratioBNoPS[centBin]->SetMarkerStyle(24+centBin);
1397 ratioBNoPS[centBin]->SetMarkerSize(1);
1398 ratioBNoPS[centBin]->SetLineColor(colorInd[centBin]);
1399 ratioBNoPS[centBin]->SetMarkerColor(colorInd[centBin]);
1400
1401 hName = "ratioACNoPS";
1402 hName += ( (TObjString*) triggersAC->At(k) )->GetString();
1403 ratioACNoPS[centBin] = static_cast<TH1*> (hACNoPSCent[centBin]->Clone(hName));
b69e18be 1404 if ( ratioACNoPS[centBin]->GetEntries() > 0 ) ratioACNoPS[centBin]->Divide(hBNoPSCent[centBin]);
93f182e7 1405 ratioACNoPS[centBin]->SetLineWidth(0);
1406 ratioACNoPS[centBin]->SetLineStyle(2);
1407 ratioACNoPS[centBin]->SetMarkerStyle(24+centBin);
1408 ratioACNoPS[centBin]->SetMarkerSize(1);
1409 ratioACNoPS[centBin]->SetLineColor(colorInd[centBin]);
1410 ratioACNoPS[centBin]->SetMarkerColor(colorInd[centBin]);
1411
1412
1413 hName = "ratioENoPS";
1414 hName += ( (TObjString*) triggersE->At(k) )->GetString();
1415 ratioENoPS[centBin] = static_cast<TH1*> (hENoPSCent[centBin]->Clone(hName));
b69e18be 1416 if ( ratioENoPS[centBin]->GetEntries() > 0 ) ratioENoPS[centBin]->Divide(hBNoPSCent[centBin]);
93f182e7 1417 ratioENoPS[centBin]->SetLineWidth(0);
1418 ratioENoPS[centBin]->SetLineStyle(3);
1419 ratioENoPS[centBin]->SetMarkerStyle(24+centBin);
1420 ratioENoPS[centBin]->SetMarkerSize(1);
1421 ratioENoPS[centBin]->SetLineColor(colorInd[centBin]);
1422 ratioENoPS[centBin]->SetMarkerColor(colorInd[centBin]);
1423
1424
1425 if(centBin==0){
1426 ratioB[centBin]->SetMaximum(yMax);
1427 ratioB[centBin]->SetMinimum(yMin);
1428 ratioB[centBin]->SetLabelSize(0.02);
1429 ratioB[centBin]->GetYaxis()->SetTitle("Accepted / All from Phys. Sel.");
1430 ratioB[centBin]->SetTitle(Form("Phys. Sel. for %s - Multiplicity from V0 amplitude",(( (TObjString*) triggersB->At(k) )->GetString()).Data() ));
1431 ratioB[centBin]->Draw("E");
1432 //ratioBNoPS[centBin]->Draw("EPSAME");
1433 ratioACNoPS[centBin]->Draw("EPSAME");
1434 ratioENoPS[centBin]->Draw("EPSAME");
1435 }
1436 else{
1437 ratioB[centBin]->Draw("ESAME");
1438 //ratioBNoPS[centBin]->Draw("EPSAME");
1439 ratioACNoPS[centBin]->Draw("EPSAME");
1440 ratioENoPS[centBin]->Draw("EPSAME");
1441 }
1442 }
1443
1444 legcRTC->AddEntry(".","applied :","");
1445 for(Int_t centBin = 0; centBin < centBinMax; centBin++){
1446 legcRTC->AddEntry(ratioB[centBin],(legendHeader[centBin]).Data(),"l");
1447 }
1448 legcRTC->AddEntry(".","not applied :","");
1449 for(Int_t centBin = 0; centBin < centBinMax; centBin++){
1450 TString textLegend = ( (TObjString*) triggersAC->At(k) )->GetString();
1451 if( textLegend.CompareTo(" ") && ratioACNoPS[centBin]->GetMaximum() > yMin ){
1452 textLegend += " x";
1453 textLegend += scale;
1454 legcRTC->AddEntry(ratioACNoPS[centBin],textLegend.Data(),"pl");
1455 }
1456 textLegend = ( (TObjString*) triggersE->At(k) )->GetString();
1457 if( textLegend.CompareTo(" ") && ratioENoPS[centBin]->GetMaximum() > yMin){
1458 //cout<<"trigger="<<textLegend.Data()<<"-"<<endl;
1459 textLegend += " x";
1460 textLegend += scale;
1461 legcRTC->AddEntry(ratioENoPS[centBin],textLegend.Data(),"pl");
1462 }
005408df 1463 }
1464 legcRTC->Draw("same");
1465
1466
1467 return c1;
1468}
1469
93f182e7 1470TCanvas *ProcessCanvasCentralityPercentile(TObjArray *triggersB, TH1 **hBNoPSCent, TH1 **hBWithPSCent, Int_t k, TString canvasName, Int_t *colorInd, TString *legendHeader){
1471
1472 if(!triggersB || !hBNoPSCent || !hBWithPSCent || !colorInd || !legendHeader) return 0x0;
1473
1474 TString cName = "c";
1475 cName += canvasName;
1476 TCanvas *c1 = new TCanvas(canvasName,cName,1200,900);
1477 SetCanvas(c1,0);
1478 c1->cd();
1479
1480 Int_t const centBinMax =2;
1481 TH1* ratioB[centBinMax], *ratioBNoPS[centBinMax];
1482 TLegend* legcRTC = new TLegend(0.2,0.15,0.50,0.40);
1483 legcRTC->SetHeader("Physics Selection");
1484
1485 TString hName;
1486
1487 Float_t yMin = 0., yMax = 0.3;
1488
1489 for(Int_t centBin = 0; centBin < centBinMax; centBin++){
1490
1491 hName = "ratio";
1492 hName += ( (TObjString*) triggersB->At(k) )->GetString();
1493 ratioB[centBin] = static_cast<TH1*> (hBWithPSCent[centBin+1]->Clone(hName));
1494 ratioB[centBin]->Divide(hBWithPSCent[0]);
1495 ratioB[centBin]->Scale(0.8);
1496 ratioB[centBin]->SetLineWidth(2);
1497 ratioB[centBin]->SetLineColor(colorInd[centBin+1]);
1498 hName = "ratioNoPS";
1499 hName += ( (TObjString*) triggersB->At(k) )->GetString();
1500 ratioBNoPS[centBin] = static_cast<TH1*> (hBNoPSCent[centBin+1]->Clone(hName));
1501 ratioBNoPS[centBin]->Divide(hBNoPSCent[0]);
1502 ratioBNoPS[centBin]->Scale(0.8);
1503 ratioBNoPS[centBin]->SetLineWidth(0);
1504 ratioBNoPS[centBin]->SetLineStyle(1);
1505 ratioBNoPS[centBin]->SetMarkerStyle(24+centBin+1);
1506 ratioBNoPS[centBin]->SetMarkerSize(1);
1507 ratioBNoPS[centBin]->SetLineColor(colorInd[centBin+1]);
1508 ratioBNoPS[centBin]->SetMarkerColor(colorInd[centBin+1]);
1509
1510 if(centBin==0){
1511 ratioB[centBin]->SetMaximum(yMax);
1512 ratioB[centBin]->SetMinimum(yMin);
1513 ratioB[centBin]->SetLabelSize(0.02);
1514 ratioB[centBin]->GetYaxis()->SetTitle("Centrality percentile check");
1515 ratioB[centBin]->SetTitle(Form("Centrality percentile check for %s - Multiplicity from V0 amplitude",(( (TObjString*) triggersB->At(k) )->GetString()).Data() ));
1516 ratioB[centBin]->Draw("E");
1517 ratioBNoPS[centBin]->Draw("EPSAME");
1518 }
1519 else{
1520 ratioB[centBin]->Draw("ESAME");
1521 ratioBNoPS[centBin]->Draw("EPSAME");
1522 }
1523 }
1524
1525 legcRTC->AddEntry(".","applied :","");
1526 for(Int_t centBin = 0; centBin < centBinMax; centBin++){
1527 legcRTC->AddEntry(ratioB[centBin],(legendHeader[centBin+1]).Data(),"l");
1528 }
1529 legcRTC->AddEntry(".","not applied :","");
1530 for(Int_t centBin = 0; centBin < centBinMax; centBin++){
1531 legcRTC->AddEntry(ratioBNoPS[centBin],(legendHeader[centBin+1]).Data(),"l");
1532 }
1533 legcRTC->Draw("same");
1534
1535
1536 return c1;
1537}
005408df 1538
93f182e7 1539TCanvas *ProcessCanvasTracksoverTrigger(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName, TString legendHeader){
005408df 1540
1541 if(!triggersB || !hB || !hTrackerB || !hTriggerB || !hMatchedB || !hAllTracksB || indTrigger<0 ) return 0x0;
1542
1543 TH1 *hTrackerPerB, *hTriggerPerB, *hMatchedPerB, *hAllTracksPerB;
1544
1545 TString hName, hNameBase;
1546 hNameBase =( (TObjString*) triggersB->At(indTrigger) )->GetString();
1547
1548 hName = "hTrackerPer";
1549 hName += hNameBase;
1550 hTrackerPerB = static_cast<TH1*>(hTrackerB[indTrigger]->Clone(hName));
b69e18be 1551 if ( hTrackerPerB->GetEntries() > 0 ) hTrackerPerB->Divide(hB[indTrigger]);
005408df 1552 hTrackerPerB->SetLineWidth(2);
1553 hTrackerPerB->SetLineColor(kRed);
1554
1555 hName = "hTriggerPer";
1556 hName += hNameBase;
1557 hTriggerPerB = static_cast<TH1*>(hTriggerB[indTrigger]->Clone(hName));
b69e18be 1558 if ( hTriggerPerB->GetEntries() > 0 ) hTriggerPerB->Divide(hB[indTrigger]);
005408df 1559 hTriggerPerB->SetLineWidth(2);
1560 hTriggerPerB->SetLineColor(kBlue);
1561
1562 hName = "hMatchedPer";
1563 hName += hNameBase;
1564 hMatchedPerB = static_cast<TH1*>(hMatchedB[indTrigger]->Clone(hName));
b69e18be 1565 if ( hMatchedPerB->GetEntries() > 0 ) hMatchedPerB->Divide(hB[indTrigger]);
005408df 1566 hMatchedPerB->SetLineWidth(2);
1567 hMatchedPerB->SetLineColor(kViolet);
1568
1569 hName = "hAllTracksPer";
1570 hName += hNameBase;
1571 hAllTracksPerB = static_cast<TH1*>(hAllTracksB[indTrigger]->Clone(hName));
b69e18be 1572 if ( hAllTracksPerB->GetEntries() > 0 ) hAllTracksPerB->Divide(hB[indTrigger]);
005408df 1573 hAllTracksPerB->SetLineWidth(3);
1574 hAllTracksPerB->SetLineColor(kBlack);
93f182e7 1575 hAllTracksPerB->SetTitle(Form("Number of Tracks /%s for %s",hNameBase.Data(),legendHeader.Data()));
005408df 1576 hAllTracksPerB->SetMinimum(0.0001);
1577 hAllTracksPerB->SetLabelSize(0.02);
1578
1579
1580 TString cName = "c";
1581 cName += canvasName;
1582 hNameBase =( (TObjString*) triggersB->At(indTrigger) )->GetString();
1583 cName += hNameBase;
1584 canvasName += indTrigger;
1585 TCanvas *cRatioTrackTypesB = new TCanvas(canvasName,cName,1200,900);
1586 SetCanvas(cRatioTrackTypesB,0);
1587 cRatioTrackTypesB->cd();
1588
1589 TLegend* legcTTCINT1B;
1590
1591 hAllTracksPerB->Draw("E");
1592 hTrackerPerB->Draw("Esame");
1593 hMatchedPerB->Draw("Esame");
1594 hTriggerPerB->Draw("Esame");
1595
1596 legcTTCINT1B = new TLegend(0.70,0.5,0.90,0.70);
1597 legcTTCINT1B->AddEntry(hAllTracksPerB,"All tracks","l");
1598 legcTTCINT1B->AddEntry(hTrackerPerB,"Tracking (only) tracks","l");
1599 legcTTCINT1B->AddEntry(hMatchedPerB,"Matched tracks","l");
1600 legcTTCINT1B->AddEntry(hTriggerPerB,"Trigger (only) tracks","l");
1601 legcTTCINT1B->Draw("same");
1602
1603
1604
1605 return cRatioTrackTypesB;
1606
1607}
1608
1609
93f182e7 1610TCanvas *ProcessCanvasTrackMultB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName,TString legendHeader){
005408df 1611
1612 if(!triggersB || !hB || !hTrackerB || !hTriggerB || !hMatchedB || !hAllTracksB || indTrigger<0 ) return 0x0;
1613
1614 TString cName = "c";
1615 cName += canvasName;
1616 TString hNameBase =( (TObjString*) triggersB->At(indTrigger) )->GetString();
1617 cName += hNameBase;
1618 canvasName += indTrigger;
1619 TCanvas *cTrackMultB = new TCanvas(canvasName,cName,1200,900);
1620 SetCanvas(cTrackMultB,0);
1621
1622 cTrackMultB->Divide(1,2);
1623 cTrackMultB->cd(1);
1624
1625
1626 TH1* hSumTriggerOverB, *hSumTrackerOverB;
1627
1628 TString hName;
1629
1630 hName = Form("hSumTriggerOver%s",hNameBase.Data());
1631 hSumTriggerOverB = static_cast<TH1*>(hTriggerB[indTrigger]->Clone(hName));
1632 hSumTriggerOverB->Add(hMatchedB[indTrigger]);
1633 hSumTriggerOverB->Divide(hB[indTrigger]);
1634
93f182e7 1635 hName = Form("Sum of trigger tracks (matched+trigger-only) / # events in %s for %s",hNameBase.Data(),legendHeader.Data());
005408df 1636 hSumTriggerOverB->SetTitle(hName);
1637 hSumTriggerOverB->SetLabelSize(0.02);
1638 hSumTriggerOverB->SetLineWidth(2);
1639 hSumTriggerOverB->SetLineColor(kBlue);
1640 hName = Form("hSumTrackerOver%s",hNameBase.Data());
1641 hSumTrackerOverB = static_cast<TH1*>(hTrackerB[indTrigger]->Clone(hName));
1642 hSumTrackerOverB->Add(hMatchedB[indTrigger]);
1643 hSumTrackerOverB->Divide(hB[indTrigger]);
93f182e7 1644 hName = Form("Sum of tracker tracks (matched+tracker-only) / # events in %s for %s",hNameBase.Data(),legendHeader.Data());
005408df 1645 hSumTrackerOverB->SetTitle(hName);
1646 //hSumTrackerOverCINT1B->LabelsOption("u");
1647 hSumTrackerOverB->SetLabelSize(0.02);
1648 hSumTrackerOverB->SetLineWidth(2);
1649 hSumTrackerOverB->SetLineColor(kBlue);
1650
1651
1652
1653 hSumTriggerOverB->Draw("e");
1654 cTrackMultB->cd(2);
1655 hSumTrackerOverB->Draw("e");
1656
1657 return cTrackMultB;
1658
1659}
1660
93f182e7 1661TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName,TString legendHeader){
005408df 1662
1663 if(!triggersB || !hB || !hTrackerB || !hTriggerB || !hMatchedB || !hAllTracksB || indTrigger<0 ) return 0x0;
1664
1665 TString cName = "c";
1666 cName += canvasName;
1667 TString hNameBase =( (TObjString*) triggersB->At(indTrigger) )->GetString();
1668 cName += hNameBase;
1669 canvasName += indTrigger;
1670 TCanvas *cRatioTrackB = new TCanvas(canvasName,cName,1200,900);
1671 SetCanvas(cRatioTrackB,0);
1672
1673 TH1* hTrackerOverTriggerB, *hMatchedOverTriggerB, *hMatchedOverTrackerB;
1674
1675 TString hName = Form("hTrackerOverTrigger%s",hNameBase.Data());
1676 hTrackerOverTriggerB = static_cast<TH1*>(hTrackerB[indTrigger]->Clone(hName));
1677 hTrackerOverTriggerB->Divide(hTriggerB[indTrigger]);
93f182e7 1678 hName = Form("# tracker tracks / # trigger tracks in %s for %s",hNameBase.Data(),legendHeader.Data());
005408df 1679 hTrackerOverTriggerB->SetTitle(hName);
1680 //hTrackerOverTriggerCINT1B->LabelsOption("u");
1681 hTrackerOverTriggerB->SetLabelSize(0.02);
1682 hTrackerOverTriggerB->SetLineWidth(2);
1683 hTrackerOverTriggerB->SetLineColor(kBlue);
1684
1685 hName = Form("hMatchedOverTrigger%s",hNameBase.Data());
1686 hMatchedOverTriggerB = static_cast<TH1*>(hMatchedB[indTrigger]->Clone(hName));
1687 hMatchedOverTriggerB->Divide(hTriggerB[indTrigger]);
1688
93f182e7 1689 hName = Form("# matched tracks / # trigger tracks in %s for %s",hNameBase.Data(),legendHeader.Data());
005408df 1690 hMatchedOverTriggerB->SetTitle(hName);
1691 //hMatchedOverTriggerCINT1B->LabelsOption("u");
1692 hMatchedOverTriggerB->SetLabelSize(0.02);
1693 hMatchedOverTriggerB->SetLineWidth(2);
1694 hMatchedOverTriggerB->SetLineColor(kBlue);
1695
1696 hName = Form("hMatchedOverTracker%s",hNameBase.Data());
1697 hMatchedOverTrackerB = static_cast<TH1*>(hMatchedB[indTrigger]->Clone(hName));
1698 hMatchedOverTrackerB->Divide(hTrackerB[indTrigger]);
93f182e7 1699 hName = Form("# matched tracks / # tracker tracks in %s for %s",hNameBase.Data(),legendHeader.Data());
005408df 1700 hMatchedOverTrackerB->SetTitle(hName);
1701 //hMatchedOverTrackerCINT1B->LabelsOption("u");
1702 hMatchedOverTrackerB->SetLabelSize(0.02);
1703 hMatchedOverTrackerB->SetLineWidth(2);
1704 hMatchedOverTrackerB->SetLineColor(kBlue);
1705
1706
1707 cRatioTrackB->Divide(1,3);
1708 cRatioTrackB->cd(1);
1709 hTrackerOverTriggerB->Draw("e");
1710 cRatioTrackB->cd(2);
1711 hMatchedOverTriggerB->Draw("e");
1712 cRatioTrackB->cd(3);
1713 hMatchedOverTrackerB->Draw("e");
1714
1715 return cRatioTrackB;
1716
1717}
1718
93f182e7 1719TCanvas *ProcessCanvasAsymMatched(TObjArray *triggersB, TH1 **hPosMatchedB, TH1 **hNegMatchedB, TH1 **hAllMatchedB, Int_t indTrigger, TString canvasName,TString legendHeader){
005408df 1720
1721 if(!triggersB || !hPosMatchedB || !hNegMatchedB || !hAllMatchedB || indTrigger<0 ) return 0x0;
1722
1723 TString hName, hNameBase = (( (TObjString*) triggersB->At(indTrigger) )->GetString());
1724
1725 TString cName = "c";
1726 cName += canvasName;
1727 cName += hNameBase;
1728 canvasName += indTrigger;
1729 TCanvas *cAsymMatched = new TCanvas(canvasName.Data(),cName,1200,900);
1730 SetCanvas(cAsymMatched,0);
1731 cAsymMatched->cd();
1732
1733
1734 TH1 *hDiffMatchedCMUS1B= static_cast<TH1*>(hPosMatchedB[indTrigger]->Clone("hDiffMatchedCMUS1B"));
1735 hDiffMatchedCMUS1B->Add(hNegMatchedB[indTrigger],-1);
1736 hDiffMatchedCMUS1B->Sumw2();
1737
1738 TH1 *hAsymMatchedCMUS1B= static_cast<TH1*>(hDiffMatchedCMUS1B->Clone("hAsymMatchedCMUS1B"));
1739 hAsymMatchedCMUS1B->Divide(hAllMatchedB[indTrigger]);
1740 hAsymMatchedCMUS1B->SetLineColor(kRed);
1741 hAsymMatchedCMUS1B->SetLineWidth(2);
1742 hAsymMatchedCMUS1B->SetMinimum(-0.3);
1743 hAsymMatchedCMUS1B->SetMaximum(0.3);
1744 hAsymMatchedCMUS1B->SetLabelSize(0.02);
93f182e7 1745 hName = Form("Matched tracks charge asymmetry for %s with acc. cuts for %s",hNameBase.Data(),legendHeader.Data());
005408df 1746 hAsymMatchedCMUS1B->SetTitle(hName);
1747
1748 hAsymMatchedCMUS1B->GetYaxis()->SetTitle("Charged tracks asymmetry");
1749 hAsymMatchedCMUS1B->Draw("EH");
1750
1751 return cAsymMatched;
1752
1753}
1754
93f182e7 1755TCanvas *ProcessCanvasHighPtMuons(TObjArray *triggersB, TH1 **hB, TH1 **hMatchedLowPtB, TH1 **hMatchedHighPtB, Int_t indTrigger, TString canvasName, TString legendHeader){
005408df 1756
1757 if(!triggersB || !hB || !hMatchedLowPtB || !hMatchedHighPtB || indTrigger<0 ) return 0x0;
1758
1759 TString hName, hNameBase = (( (TObjString*) triggersB->At(indTrigger) )->GetString());
1760
1761 TString cName = "c";
1762 cName += canvasName;
1763 cName += hNameBase;
1764 canvasName += indTrigger;
1765 TCanvas *cHighPtMuons = new TCanvas(canvasName.Data(),cName,1200,900);
1766 SetCanvas(cHighPtMuons,0);
1767 cHighPtMuons->cd();
1768
1769 TLegend* legcHPM;
1770
1771 TH1* hMatchedLowPtPerB, *hMatchedHighPtPerB;
1772 hName = Form("hMatchedLowPtPer%s ",hNameBase.Data());
1773 hMatchedLowPtPerB = static_cast<TH1*> (hMatchedLowPtB[indTrigger]->Clone(hName));
1774 hMatchedLowPtPerB->Sumw2();
1775 hMatchedLowPtPerB->Divide(hB[indTrigger]);
1776 hMatchedLowPtPerB->SetLineWidth(2);
1777 hMatchedLowPtPerB->SetLineColor(kBlue);
1778 hMatchedLowPtPerB->SetTitle("");
1779 hName = Form("Ratio per %s ",hNameBase.Data());
1780 hMatchedLowPtPerB->GetYaxis()->SetTitle(hName);
1781 //hMatchedLowPtPerB->SetMaximum(0.15);
1782 hMatchedLowPtPerB->SetMinimum(0.0001);
1783 hMatchedLowPtPerB->SetLabelSize(0.02);
1784
1785 hName = Form("hMatchedHighPtPer%s ",hNameBase.Data());
1786 hMatchedHighPtPerB = static_cast<TH1*> (hMatchedHighPtB[indTrigger]->Clone(hName));
1787 hMatchedHighPtPerB->Sumw2();
1788 hMatchedHighPtPerB->Divide(hB[indTrigger]);
1789 hMatchedHighPtPerB->SetLineWidth(2);
1790 hMatchedHighPtPerB->SetLineColor(kRed);
1791
93f182e7 1792 hName = Form("Number of matched track per %s (include Vtx and R_{Abs} cuts) for %s",hNameBase.Data(),legendHeader.Data());
1793 hMatchedLowPtPerB->SetTitle(hName);
005408df 1794 hMatchedLowPtPerB->Draw("E");
1795 hMatchedHighPtPerB->Draw("Esame");
1796
1797 legcHPM = new TLegend(0.60,0.45,0.98,0.65);
93f182e7 1798 //legcHPM->SetHeader(hName);
005408df 1799 legcHPM->AddEntry(".","Physics selection applied :","");
1800 legcHPM->AddEntry(hMatchedLowPtPerB," p_{T} > 1 GeV/c ","l");
1801 legcHPM->AddEntry(hMatchedHighPtPerB," p_{T} > 2 GeV/c ","l");
1802 legcHPM->Draw("same");
1803
1804 return cHighPtMuons;
1805
1806
1807}
1808
b69e18be 1809TH1* ProcessHisto( AliCounterCollection* counter, TString hVariable, TString hSelection, TString hName, TString xName, TString yName, Int_t color){
005408df 1810
1811
1812 TH1* h1 = 0x0;
1813 if( !counter ) return h1;
93f182e7 1814
2e7189d6 1815 //cout<<"ProcessHisto selection "<<hSelection<<endl;
b69e18be 1816
1817 if ( !hSelection.Contains("trigger: /") && !hSelection.Contains("trigger:/") ) h1 = (TH1*) counter->Draw(hVariable,hSelection);
005408df 1818 if ( !h1 ) h1 = new TH1D(hName,"",10,0,10);
1819 else {
1820 h1->Sumw2();
1821 h1->LabelsOption("a");
1822 if(hName.Sizeof()>1) h1->SetName(hName);
1823 if(xName.Sizeof()>1) h1->GetXaxis()->SetTitle(xName);
1824 if(yName.Sizeof()>1) h1->GetYaxis()->SetTitle(yName);
1825 if(color>0) h1->SetLineColor(color);
1826
1827 }
1828
1829 return h1;
1830}
1831
1832TH2* ProcessHisto2D( AliCounterCollection* counter, TString hVariable, TString hVariable2, TString hSelection, TString hName){
1833
1834
1835 TH2* h1 = 0x0;
1836 if( !counter ) return h1;
1837 Bool_t setName = kTRUE;
1838
1839 if(hName.Sizeof()==1) setName = kFALSE;
1840
1841 h1 = (TH2*) counter->Draw(hVariable,hVariable2,hSelection);
1842 if ( !h1 ) h1 = new TH2D(hName,"",10,0,10,10,0,10);
1843 else {
1844 h1->Sumw2();
1845 h1->LabelsOption("a");
1846 if(setName) h1->SetName(hName);
1847 }
1848
1849 return h1;
1850}
93f182e7 1851
005408df 1852Bool_t GetTriggerLists(const char* triggerList, TString listFromContainer, TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE){
1853
1854 //Get the trigger list from a file
1855 //The file should consist of a line for each trigger with the following layout:
93f182e7 1856 // triggernameB triggerNameAC triggerNameE
1857 // or triggernameB triggerNameA,triggerNameC triggerNameE
1858 // or triggernameB triggerNameACE notrigger
005408df 1859 //if filename is 0, then default trigger names (pp 2011) are used
1860
1861 if( !triggersB || !triggersAC || !triggersE) return kFALSE;
1862 TObjArray* triggers[3] = {triggersB, triggersAC, triggersE};
1863
1864 TString trigSuffix[3] = {"B", "AC", "E"};
1865 TString currTrigName = "";
1866 TObjArray* fullTriggerList[3];
1867
1868 for ( Int_t ibeam=0; ibeam<3; ++ibeam ) {
1869 fullTriggerList[ibeam] = new TObjArray;
1870 fullTriggerList[ibeam]->SetOwner();
1871 }
1872
1873 // Build trigger list (from file or default)
1874 if ( triggerList ) {
1875 // only the ones in the triggerList
1876 ifstream inFile(triggerList);
1877 if (!inFile.is_open()) {
93f182e7 1878 Error("PlotMuonQA","unable to open file %s", triggerList);
005408df 1879 return kFALSE;
1880 }
1881
1882 while ( !inFile.eof() ) {
1883 Bool_t isGoodB = kTRUE;
1884 for ( Int_t ibeam=0; ibeam<3; ++ibeam ) {
1885 currTrigName.ReadToken( inFile );
1886 if ( ! isGoodB ) continue;
1887 if ( currTrigName.IsNull() || ! currTrigName.IsAscii() ) {
1888 if ( ibeam == 0 ) {
1889 isGoodB = kFALSE;
1890 continue;
1891 }
1892 currTrigName = "notrigger";
1893 }
1894 fullTriggerList[ibeam]->AddLast(new TObjString(currTrigName));
1895 }
1896 }
1897 inFile.close();
1898 }
1899 else {
1900 TString baseTrigName[4] = {"CINT7", "CMUSH7", "CMUL7", "CMUU7"};
1901 for ( Int_t ibase=0; ibase<4; ++ibase ) {
1902 for ( Int_t ibeam=0; ibeam<3; ++ibeam ) {
1903 // by default all triggers from new period in LHC11c
1904 currTrigName = baseTrigName[ibase] + trigSuffix[ibeam];
1905 fullTriggerList[ibeam]->AddLast(new TObjString(currTrigName));
1906 }
1907 }
1908 }
1909 //
1910 // Select only existing triggers in container
1911 //
1912 TObjArray *triggersFromContainer = listFromContainer.Tokenize(",");
1913 TObjString* trigName = 0x0;
1914
1915 TString selectAllTriggers[3] = {"", "", ""};
1916 for ( Int_t itrig=0; itrig<fullTriggerList[0]->GetEntries(); ++itrig ) {
1917 Bool_t isBadTrig = kFALSE;
1918 for ( Int_t ibeam=0; ibeam<3; ++ibeam ) {
1919 currTrigName = fullTriggerList[ibeam]->At(itrig)->GetName();
1920
1921 //condition on trigger name from trigger list
1922 if ( currTrigName.Contains("notrigger") ){
1923 isBadTrig = kTRUE;
1924 if ( ibeam == 0 ) break;
1925 currTrigName = " ";
1926 }
1927 //select only the existing triggers in the container
1928 //note that the trigger in the trigger file can be a list of different trigger
1929 if ( triggersFromContainer ) {
1930 TIter nextTrigger( triggersFromContainer );
1931 isBadTrig = kTRUE;
1932 while ( ( trigName = static_cast<TObjString*>(nextTrigger()) ) ) {
1933 if ( currTrigName.Contains(trigName->GetString()) ){
2e7189d6 1934 isBadTrig = kFALSE;
005408df 1935 }
1936 }
1937 if ( isBadTrig == kTRUE ){
1938 if ( ibeam == 0 ) break;
1939 currTrigName = " ";
1940 }
1941 }
1942 triggers[ibeam]->AddLast(new TObjString(currTrigName));
1943 if ( isBadTrig ) continue;
1944 if ( ! selectAllTriggers[ibeam].IsNull() ) selectAllTriggers[ibeam] += ",";
1945 selectAllTriggers[ibeam] += currTrigName;
1946 }
1947 }
1948 if(triggersFromContainer) delete triggersFromContainer;
1949 if(trigName) delete trigName;
1950
1951
1952 // Complete trigger list and print values
1953 cout<<" Nr of triggers read "<<triggers[0]->GetEntriesFast()<<endl;
1954 for ( Int_t ibeam=0; ibeam<3; ++ibeam ) {
1955 triggers[ibeam]->AddLast(new TObjString(selectAllTriggers[ibeam]));
1956 printf(" %s triggers:\n", trigSuffix[ibeam].Data());
1957 triggers[ibeam]->Print();
1958 delete fullTriggerList[ibeam];
1959 }
1960
1961 return kTRUE;
1962}
1963
1964TString GetRunList(const char *runList, TObjArray *runs, TObjArray *runs2){
1965
1966 // list of runs to be analyzed
1967 TString selectRuns = "run:";
1968
1969 if(runList) {
1970 // only the ones in the runList
1971 ifstream inFile(runList);
1972 if (!inFile.is_open()) {
93f182e7 1973 Error("PlotMuonQA","unable to open file %s", runList);
005408df 1974 return selectRuns;
1975 }
1976
1977 TString currRun;
1978 while (!inFile.eof()) {
1979 currRun.ReadLine(inFile, kTRUE);
1980 if (currRun.IsNull()) continue;
1981 if (!currRun.IsDigit()) {
93f182e7 1982 Error("PlotMuonQA","invalid run number: %s", currRun.Data());
005408df 1983 return selectRuns;
1984 }
1985 if(runs) runs->AddLast(new TObjString(Form("%09d", currRun.Atoi())));
1986 if(runs2) runs2->AddLast(new TObjString(Form("%d", currRun.Atoi())));
1987 selectRuns += Form("%s,",currRun.Data());
1988 }
1989 selectRuns.Remove(TString::kTrailing, ',');
1990 inFile.close();
1991
1992 } else {
1993 // all runs
1994 if(runs) runs->AddLast(new TObjString("*"));
1995 if(runs2) runs2->AddLast(new TObjString("*"));
1996 }
1997
2e7189d6 1998 printf("selected runs from runlist %s: %s\n",runList, selectRuns.Data());
93f182e7 1999
005408df 2000 return selectRuns;
2001}