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