1 //--------------------------------------------------------------------------
2 // Macro for QA monitoring.
4 // In case it is not run with full aliroot, it needs the following libraries to compile:
9 // - libANALYSISalice.so
13 // TString includePath = "-I${ALICE_ROOT}/PWGmuon "; gSystem->SetIncludePath(includePath.Data());
15 // The macro reads results of the QA task and produce monitoring plots.
17 // Authors: Cynthia Hadjidakis - IPN Orsay
18 // QA histos from counters (event, track) and run per run histos
20 // - reorganize last part (reading and extracting info from run per run histos)
21 // - remove trigger selection when muon QA task modified (now a selection is done one triggers' name)
23 //--------------------------------------------------------------------------
25 #if !defined(__CINT__) || defined(__MAKECINT__)
27 #include <Riostream.h>
32 #include "TGridResult.h"
33 #include "THashList.h"
43 #include "TObjArray.h"
44 #include "TObjString.h"
45 #include "TFileMerger.h"
47 #include "AliCounterCollection.h"
50 Int_t GetRunNumber(TString);
51 TString GetRunList(const char *runList, TObjArray *runs);
52 Bool_t MergeOutputs(const char*,const char*);
53 Bool_t GetTriggerLists(const char *triggerList, TString listFromContainer, TObjArray *triggersB=0, TObjArray *triggersShortName=0);
54 void SetCanvas(TCanvas *canvas, Int_t logy=1);
55 TH1* ProcessHisto( AliCounterCollection* counter, TString variable, TString selection, TString hName="", TString xName="", TString yName="", Int_t color=1);
56 TH2* ProcessHisto2D( AliCounterCollection* counter, TString hVariable, TString hVariable2, TString hSelection, TString hName);
57 Int_t GetIndex(TObjArray *triggersB, Int_t trigNr, Int_t centNr);
58 TCanvas *ProcessCanvasAllTrigger(AliCounterCollection *counter, TString canvasName);
59 TCanvas *ProcessCanvasTriggerContent(TObjArray *trigName, TObjArray trigNoPS, TObjArray trigWithPS, TString canvasName);
60 TCanvas *ProcessCanvasRelativeTriggerContent(TObjArray *array, TObjArray trigNoPS, TString canvasName);
61 TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray trigNoPS, TObjArray trigWithPS, TString canvasName);
62 TCanvas *ProcessCanvasPhysSelCutCentrality(TObjArray *triggersB, TObjArray trigNoPS, TObjArray trigBWithPS, Int_t trigNr, TString canvasName, TString *legendHeader);
63 TCanvas *ProcessCanvasCentralityPercentile(TObjArray *triggersB, TObjArray trigNoPS, TObjArray trigWithPS, Int_t trigNr, TString canvasName, TString *legendHeader);
64 TCanvas *ProcessCanvasTracksoverTrigger(TObjArray *triggersB, TObjArray trigSel, TObjArray trackTracker, TObjArray trackTrigger, TObjArray trackMatched, TObjArray trackAll, Int_t trigNr, Int_t centNr, TString canvasName,TString legendHeader="");
65 TCanvas *ProcessCanvasTrackMultB(TObjArray *triggersB, TObjArray trigSel, TObjArray trackTracker, TObjArray trackTrigger, TObjArray trackMatched, Int_t trigNr, Int_t centNr, TString canvasName,TString legendHeader="");
66 TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TObjArray trigSel, TObjArray trackTracker, TObjArray trackTrigger, TObjArray trackMatched, Int_t trigNr, Int_t centNr, TString canvasName,TString legendHeader="");
67 TCanvas *ProcessCanvasAsymMatched(TObjArray *triggersB, TObjArray trackPosMatched, TObjArray trackNegMatched, TObjArray trackhAllMatched, Int_t trigNr, Int_t centNr, TString canvasName,TString legendHeader="");
68 TCanvas *ProcessCanvasHighPtMuons(TObjArray *triggersB, TObjArray trigSel, TObjArray trackMatchedLowPt, TObjArray trackAllMatchedHightPt, Int_t trigNr, Int_t centNr, TString canvasName,TString legendHeader="");
69 TCanvas *ProcessCanvasBeamGasMatched(TObjArray *triggersB, TObjArray trackBeamGasMatched, TObjArray trackBeamGasMatchedHighPt, TObjArray trackAllMatched, TObjArray trackMatchedHighPt, Int_t trigNr, Int_t centNr, TString canvasName,TString legendHeader="");
70 Bool_t IsHeavyIonCollision(AliCounterCollection *eventCounters);
73 const Int_t kCentBinMax = 4;
74 TString kCentBinName[kCentBinMax] = {"v0mult:any/","v0mult:low,int,high/","v0mult:low/","v0mult:high/"};
75 TString kCentLegendName[kCentBinMax] ={"all collisions","[0-80%] from V0 amplitude","low mult. [60-80%] from V0 amplitude","high mult. [0-10%] from V0 amplitude"};
76 TString kCentLegendNameShort[kCentBinMax] ={"all","[0-80%]","[60-80%]","[0-10%]"};
78 //--------------------------------------------------------------------------
79 void 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") {
81 /// Macro for QA monitoring.
82 /// Example: baseDir = "alien:///alice/cern.ch/user/p/ppillot/pp7TeV/LHC10d/MuonQA/pass1/results/".
83 /// If runList != 0x0: only the given runs will be used. Otherwise use all runs found in baseDir.
84 /// If triggerList !=0x0: only the given triggers are displayed. Otherwise use the default list of triggers (see GetTriggerLists)
86 #if defined(__CINT__) && !defined(__MAKECINT__)
87 gSystem->Load("libTree");
88 gSystem->Load("libGeom");
89 gSystem->Load("libVMC");
90 gSystem->Load("libPhysics");
91 gSystem->Load("libSTEERBase");
92 gSystem->Load("libESD");
93 gSystem->Load("libAOD");
94 gSystem->Load("libANALYSIS");
95 gSystem->Load("libANALYSISalice");
96 gSystem->Load("libCORRFW");
97 gSystem->Load("libPWGHFbase");
98 gSystem->Load("libPWGmuon");
101 // Cosmetics and configuration
102 gStyle->SetFillColor(10);
103 gStyle->SetPadGridX(kTRUE);
104 gStyle->SetPadGridY(kTRUE);
105 gStyle->SetPadRightMargin(0.01);
107 TString OutFileName = "QA_"; OutFileName += LHCPeriod;
108 TString OutFileNamePDF= OutFileName.Data(); OutFileNamePDF+= ".pdf";
109 TString OutFileNamePDF_open = OutFileNamePDF.Data(); OutFileNamePDF_open += "[";
110 TString OutFileNamePDF_close= OutFileNamePDF.Data(); OutFileNamePDF_close += "]";
111 TString OutFileNameROOT= OutFileName.Data(); OutFileNameROOT+= ".root";
116 if (0){ // Equivalent to the fast read option
117 gEnv->SetValue("XNet.ConnectTimeout",10);
118 gEnv->SetValue("XNet.RequestTimeout",10);
119 gEnv->SetValue("XNet.MaxRedirectCount",2);
120 gEnv->SetValue("XNet.ReconnectTimeout",10);
121 gEnv->SetValue("XNet.FirstConnectMaxCnt",1);
124 TH1::AddDirectory(kFALSE);
126 TString alienBaseDir = baseDir;
128 if (alienBaseDir.Contains("alien:") && !TGrid::Connect("alien://")) {
129 Error("MergeQA","cannot connect to grid");
133 cout<<"//---------------------------------- //"<<endl;
134 cout<<"// Run selection //"<<endl;
135 cout<<"//---------------------------------- //"<<endl;
137 TObjArray *runs = new TObjArray();
138 runs->SetOwner(kTRUE);
139 TString selectRuns = GetRunList(runList,runs);
142 TString select = selectPhysics ? "selected:yes" : "";
144 cout<<"//---------------------------------- //"<<endl;
145 cout<<"// Get global counter //"<<endl;
146 cout<<"//---------------------------------- //"<<endl;
148 TString mergedFilename = Form("%s/%s", baseDir,QAFileName);
149 if (runList) MergeOutputs(runList, mergedFilename);
151 TFile *globalFile = TFile::Open(mergedFilename.Data());
152 if (!globalFile || ! globalFile->IsOpen()) {
153 Error("PlotQA", "failed to open file: %s", mergedFilename.Data());
156 globalFile->Cd("MUON_QA");
161 AliCounterCollection* eventCounters = static_cast<AliCounterCollection*>(globalFile->FindObjectAny("eventCounters"));
162 AliCounterCollection* trackCounters = static_cast<AliCounterCollection*>(globalFile->FindObjectAny("trackCounters"));
164 // run list from counters
165 if (!runList) selectRuns += trackCounters->GetKeyWords("run");
167 cout<<"//---------------------------------- //"<<endl;
168 cout<<"// Trigger selection //"<<endl;
169 cout<<"//---------------------------------- //"<<endl;
171 TObjArray *triggersB, *triggersShortName;
172 triggersB = new TObjArray();
173 triggersB->SetOwner();
174 triggersShortName = new TObjArray();
175 triggersShortName->SetOwner();
177 TString listFromContainer = eventCounters->GetKeyWords("trigger");
178 Bool_t success = GetTriggerLists(triggerList, listFromContainer, triggersB, triggersShortName);
181 cout<<"//---------------------------------- //"<<endl;
182 cout<<"// Set collision type ? //"<<endl;
183 cout<<"//---------------------------------- //"<<endl;
185 Bool_t isHeavyIon = kTRUE;
186 isHeavyIon = IsHeavyIonCollision(eventCounters);
188 cout<<"//---------------------------------- //"<<endl;
189 cout<<"// Trigger plots //"<<endl;
190 cout<<"//---------------------------------- //"<<endl;
192 //plot all trigger from event counters without any selection
193 TString CanvasName = "AllTriggers";
194 TCanvas *cAll = ProcessCanvasAllTrigger(eventCounters, CanvasName);
196 cout<<"//---------------------------------- //"<<endl;
197 cout<<"// Processing event counters //"<<endl;
198 cout<<"//---------------------------------- //"<<endl;
200 //declare a default canvas c1
202 TCanvas *c1 = new TCanvas(CanvasName.Data(),CanvasName.Data());
205 Int_t nCentBin = ( isHeavyIon ) ? kCentBinMax : 1;
206 TString selectionCent;
208 Int_t *colorTab = new Int_t[triggersB->GetEntriesFast()];
209 Int_t const colorNrFirst = 8;
210 Int_t colorIndex = 0;
211 Int_t colorTabFirst[colorNrFirst] = {kGray+2,kRed,kBlue,kGreen,kOrange,kCyan,kMagenta,kYellow};
212 for ( Int_t i = 0; i < triggersB->GetEntriesFast(); i++ ) {
213 colorTab[i] = colorTabFirst[i] + colorIndex;
214 if ( i%colorNrFirst == 0 ) colorIndex++;
216 TArrayI *colorInd = new TArrayI( triggersB->GetEntriesFast() );
218 for ( Int_t i = 0; i < triggersB->GetEntriesFast(); i++ ) colorInd->AddAt(colorTab[i],i);
220 Int_t nTrig = triggersB->GetEntriesFast();
222 TObjArray trigNoPS(nTrig*nCentBin);
223 TObjArray trigWithPS(nTrig*nCentBin);
224 TObjArray trigWithPST0Flag(nTrig*nCentBin);
225 TObjArray trigWithPST0SPDFlag(nTrig*nCentBin);
228 TObjArray trackTrigger(nTrig*nCentBin);
229 TObjArray trackTracker(nTrig*nCentBin);
230 TObjArray trackMatched(nTrig*nCentBin);
231 TObjArray trackAll(nTrig*nCentBin);
233 TObjArray trackAllMatched(nTrig*nCentBin); //matched tracks + additional geometrical cut
234 TObjArray trackMatchedLowPt(nTrig*nCentBin);
235 TObjArray trackMatchedHighPt(nTrig*nCentBin);
237 TObjArray trackPosMatched(nTrig*nCentBin);
238 TObjArray trackNegMatched(nTrig*nCentBin);
240 TObjArray trackBeamGasMatched(nTrig*nCentBin);
241 TObjArray trackBeamGasMatchedHighPt(nTrig*nCentBin);
243 cout<<Form("Processing for %d triggers...",triggersB->GetEntriesFast()-1)<<endl;
246 for ( Int_t iCentBin = 0; iCentBin < nCentBin; iCentBin++){
247 selectionCent = kCentBinName[iCentBin];
249 //Loop on trigger (last is all triggers)
250 for(Int_t iTrig = 0; iTrig < triggersB->GetEntriesFast(); iTrig++){
252 TString histoNameBase = "h_trig", histoName;
253 histoNameBase+= iTrig+1;
255 Int_t index = GetIndex(triggersB,iTrig,iCentBin);
259 TString triggerName = ( (TObjString*) triggersB->At(iTrig) )->GetString();
260 if(triggerName.EqualTo(" ")) continue;
261 // Histo trigger without Phys. Sel.
262 selection = selectionCent; selection += Form("trigger:%s/%s", triggerName.Data(), selectRuns.Data());
263 // cout<<selection<<endl;
264 histoName = histoNameBase;
265 histoName += "BNoPS";
266 histo = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName, "", "Trigger content w/o Phys. Sel.", colorInd->At(iTrig));
267 trigNoPS.AddAt(histo,index);
268 // Histo trigger with Phys. Sel.
269 selection = selectionCent; selection += Form("trigger:%s/%s/selected:yes", triggerName.Data(), selectRuns.Data());
270 histoName = histoNameBase;
271 histoName += "BWithPS";
272 histo = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName, "", "Trigger content w/ Phys. Sel.", colorInd->At(iTrig));
273 trigWithPS.AddAt(histo,index);
274 // Histo trigger with Phys. Sel. and T0 pile up not flagged
275 selection = selectionCent; selection += Form("trigger:%s/%s/selected:yes/t0pileup:no", triggerName.Data(), selectRuns.Data());
276 histoName = histoNameBase;
277 histoName += "BWithPST0Flag";
278 histo = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName, "", "Trigger content w/ Phys. Sel. and no pile up from T0 flag", colorInd->At(iTrig));
279 trigWithPST0Flag.AddAt(histo,index);
280 // Histo trigger with Phys. Sel. and T0 + SPD pile up not flagged
281 selection = selectionCent; selection += Form("trigger:%s/%s/selected:yes/t0pileup:no/spdpileup:no", triggerName.Data(), selectRuns.Data());
282 histoName = histoNameBase;
283 histoName += "BWithPST0SPDFlag";
284 histo = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName, "", "Trigger content w/ Phys. Sel. and no pile up from T0 and SPD flag", colorInd->At(iTrig));
285 trigWithPST0SPDFlag.AddAt(histo,index);
287 // Histo tracking : Phys. Sel. is selected or not depending on the macro arguments
288 selection = selectionCent; selection += Form("track:triggeronly/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
289 histo = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
290 trackTrigger.AddAt(histo,index);
292 selection = selectionCent; selection += Form("track:trackeronly/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
293 histo = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
294 trackTracker.AddAt(histo,index);
296 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
297 histo = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
298 trackMatched.AddAt(histo,index);
300 selection = selectionCent; selection += Form("trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
301 histo = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
302 trackAll.AddAt(histo,index);
304 //for the following, only integrated over centrality
305 if ( iCentBin > 0 ) continue;
307 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s/pt:low/acc:in", triggerName.Data() ,selectRuns.Data(), select.Data());
308 histo = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
309 trackMatchedLowPt.AddAt(histo,index);
311 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s/pt:high/acc:in", triggerName.Data() ,selectRuns.Data(), select.Data());
312 histo = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
313 trackMatchedHighPt.AddAt(histo,index);
315 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/charge:pos/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
316 histo = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
317 trackPosMatched.AddAt(histo,index);
319 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/charge:neg/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
320 histo = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
321 trackNegMatched.AddAt(histo,index);
323 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
324 histo = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
325 trackAllMatched.AddAt(histo,index);
327 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s/acc:in/tagTrack:beamGas",triggerName.Data(), select.Data(),selectRuns.Data());
328 histo = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
329 trackBeamGasMatched.AddAt(histo,index);
331 selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s/acc:in/tagTrack:beamGas/pt:high",triggerName.Data(), select.Data(),selectRuns.Data());
332 histo = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
333 trackBeamGasMatchedHighPt.AddAt(histo,index);
337 if ( selectPhysics) trigSel = trigWithPS;
338 else trigSel = trigNoPS;
340 //if there is not Beam triggers just stop now
341 Int_t count_trigger=0;
342 for(Int_t iTrig = 0; iTrig < triggersB->GetEntriesFast(); iTrig++){
344 Int_t index = GetIndex(triggersB,iTrig,centBinNr);
345 count_trigger += (static_cast<TH1*>(trigNoPS.At(index)))->GetEntries();
347 if(count_trigger<=0) return;
349 Int_t *NumOfBNoPS = new Int_t[nCentBin*nTrig];
350 Int_t *NumOfBWithPS = new Int_t[nCentBin*nTrig];
352 for ( Int_t iCentBin = 0; iCentBin < nCentBin; iCentBin++){
353 for ( Int_t iTrig = 0; iTrig < nTrig; iTrig++){
354 Int_t index = GetIndex(triggersB,iTrig,iCentBin);
355 NumOfBNoPS[index] = (static_cast<TH1*>(trigNoPS.At(index)))->Integral();
356 NumOfBWithPS[index] = (static_cast<TH1*>(trigWithPS.At(index)))->Integral();
360 cout<<"//==================================================================================="<<endl;
361 cout<<"// Put all plots in a ps file, easier to publish (Twiki)"<<endl;
362 cout<<"//==================================================================================="<<endl;
364 c1->Print(OutFileNamePDF_open.Data());
365 TFile *rootFileOut = TFile::Open(OutFileNameROOT.Data(),"RECREATE");
367 TDirectoryFile *dirGlobal = new TDirectoryFile("Global","Global","",(TDirectory*)rootFileOut->GetMotherDir());
368 cout<<"dirGlobal mother "<<(dirGlobal->GetMotherDir())->GetName()<<endl;
369 //An array of TDirectoryFile
370 TObjArray *dirTrigger = new TObjArray();
371 dirTrigger->SetOwner();
372 TObjArray *dirCent = new TObjArray();
374 for ( Int_t i = 0; i < triggersB->GetEntriesFast()-1 ; i++) {
375 TString currTrigName = ( (TObjString*) triggersShortName->At(i) )->GetString();
376 TDirectoryFile *dirFile = new TDirectoryFile( currTrigName.Data(),currTrigName.Data(),"",(TDirectory*)rootFileOut->GetMotherDir() );
377 dirTrigger->AddLast( dirFile );
378 for( Int_t j = 0; j < nCentBin; j++) {
379 TString centName = kCentLegendNameShort[j];
380 TDirectoryFile *dirFileCent = new TDirectoryFile( centName.Data(),centName.Data(),"",dirFile );
381 dirCent->AddLast( dirFileCent );
385 cAll->Print(OutFileNamePDF.Data());
389 cout<<"//==================================================================================="<<endl;
390 cout<<"// new canvas with the total number of trigger with and without Phys. Sel."<<endl;
391 cout<<"//==================================================================================="<<endl;
393 TCanvas *cTriggerContent = ProcessCanvasTriggerContent(triggersB, trigNoPS, trigWithPS, "TriggerContent");
394 cTriggerContent->Print(OutFileNamePDF.Data());
396 cTriggerContent->Write();
397 cTriggerContent->Close();
399 cout<<"//==================================================================================="<<endl;
400 cout<<"// new canvas with the relative content of each trigger w/o physics selection"<<endl;
401 cout<<"//==================================================================================="<<endl;
403 TCanvas *cRelativeTriggerContent = ProcessCanvasRelativeTriggerContent(triggersB, trigNoPS, "RelativeTriggerContent");
404 cRelativeTriggerContent->Print(OutFileNamePDF.Data());
406 cRelativeTriggerContent->Write();
407 cRelativeTriggerContent->Close();
410 cout<<"//==================================================================================="<<endl;
411 cout<<"// new canvas with effect from physics selection for each trigger "<<endl;
412 cout<<"//==================================================================================="<<endl;
414 TCanvas *cPhysSelCut = 0x0;
415 cPhysSelCut = ProcessCanvasPhysSelCut(triggersB, trigNoPS, trigWithPS, "PhysSelCutOnCollTrigger");
416 cPhysSelCut->Print(OutFileNamePDF.Data());
418 cPhysSelCut->Write();
419 cPhysSelCut->Close();
422 cout<<"//==================================================================================="<<endl;
423 cout<<"// new canvas with effect from T0 pile-up flag for each trigger "<<endl;
424 cout<<"//==================================================================================="<<endl;
426 TCanvas *cPhysSelCutT0Flag = 0x0;
427 cPhysSelCutT0Flag = ProcessCanvasPhysSelCut(triggersB, trigNoPS, trigWithPST0Flag, "PhysSelCutOnCollTriggerT0Flag");
428 cPhysSelCutT0Flag->Print(OutFileNamePDF.Data());
430 cPhysSelCutT0Flag->Write();
431 cPhysSelCutT0Flag->Close();
435 cout<<"//==================================================================================="<<endl;
436 cout<<"// new canvas with effect from T0 + SPD pile-up flag for each trigger "<<endl;
437 cout<<"//==================================================================================="<<endl;
439 TCanvas *cPhysSelCutT0SPDFlag = 0x0;
440 cPhysSelCutT0SPDFlag = ProcessCanvasPhysSelCut(triggersB, trigNoPS, trigWithPST0SPDFlag, "PhysSelCutOnCollTriggerT0SPDFlag");
441 cPhysSelCutT0SPDFlag->Print(OutFileNamePDF.Data());
443 cPhysSelCutT0SPDFlag->Write();
444 cPhysSelCutT0SPDFlag->Close();
449 TString legendHeader="";
453 cout<<"//==================================================================================="<<endl;
454 cout<<"// new canvas with effect from physics selection for each trigger and centrality bin (only in heavy-ion) "<<endl;
455 cout<<"//==================================================================================="<<endl;
457 TCanvas *cPhysSelCutCentrality;
460 for( Int_t iTrig = 0; iTrig < triggersB->GetEntriesFast(); iTrig++){
461 //skip sum of all triggers
462 if(iTrig == (triggersB->GetEntriesFast()-1)) continue;
464 canvasName = "PhysSel_trigger";
465 canvasName += ( (TObjString*) triggersShortName->At(iTrig) )->GetString();
467 cPhysSelCutCentrality = ProcessCanvasPhysSelCutCentrality(triggersB, trigNoPS, trigWithPS, iTrig, canvasName, kCentLegendNameShort+1);
468 cPhysSelCutCentrality->Print(OutFileNamePDF.Data());
469 ( (TDirectoryFile*) dirTrigger->At(iTrig) )->cd();
470 cPhysSelCutCentrality->Write();
471 cPhysSelCutCentrality->Close();
477 cout<<"//==================================================================================="<<endl;
478 cout<<"// new canvas for centrality percentile check (only in PbPb) "<<endl;
479 cout<<"//==================================================================================="<<endl;
481 TCanvas *cCentralityCheck;
484 for ( Int_t iTrig = 0; iTrig < triggersB->GetEntriesFast(); iTrig++){
485 //skip sum of all triggers
486 if ( iTrig == (triggersB->GetEntriesFast()-1) ) continue;
488 canvasName = "CentralityCheck_trigger";
489 canvasName += ( (TObjString*) triggersShortName->At(iTrig) )->GetString();
491 cCentralityCheck = ProcessCanvasCentralityPercentile(triggersB,trigNoPS,trigWithPS,iTrig,canvasName,kCentLegendNameShort);
493 cCentralityCheck->Print(OutFileNamePDF.Data());
494 ( (TDirectoryFile*) dirTrigger->At(iTrig) )->cd();
495 cCentralityCheck->Write();
496 cCentralityCheck->Close();
502 cout<<"//==================================================================================="<<endl;
503 cout<<"// Ratio of tracks over trigger type (2 canvases) "<<endl;
504 cout<<"//==================================================================================="<<endl;
506 //Print a canvas per trigger type
507 TCanvas *cTracksoverTrigger;
508 TCanvas* cTrackMultB;
510 //loop over centrality bins
511 for ( Int_t iCentBin = 0; iCentBin < nCentBin; iCentBin++){
513 legendHeader = "for ";
514 legendHeader += kCentLegendName[iCentBin];
516 else legendHeader ="";
518 for(Int_t iTrig = 0; iTrig < triggersB->GetEntriesFast(); iTrig++){
519 //skip sum of all triggers
520 if( iTrig == (triggersB->GetEntriesFast()-1) ) continue;
522 ( (TDirectoryFile*) dirCent->At( iTrig*nCentBin+iCentBin ) )->cd();
524 canvasName = "RatioTrackTypes_cent";
525 canvasName += iCentBin;
526 canvasName +="trigger";
527 canvasName += ( (TObjString*) triggersShortName->At(iTrig) )->GetString();
528 cTracksoverTrigger = ProcessCanvasTracksoverTrigger(triggersB, trigSel, trackTracker, trackTrigger, trackMatched, trackAll, iTrig, iCentBin, canvasName,legendHeader);
529 cTracksoverTrigger->Print(OutFileNamePDF.Data());
530 cTracksoverTrigger->Write();
531 cTracksoverTrigger->Close();
533 canvasName = "TrackMult_cent";
534 canvasName += iCentBin;
535 canvasName +="trigger";
536 canvasName +=( (TObjString*) triggersShortName->At(iTrig) )->GetString();
537 cTrackMultB= ProcessCanvasTrackMultB(triggersB, trigSel, trackTracker, trackTrigger, trackMatched, iTrig, iCentBin, canvasName, legendHeader);
538 cTrackMultB->Print(OutFileNamePDF.Data());
539 cTrackMultB->Write();
540 cTrackMultB->Close();
545 cout<<"//===================================================="<<endl;
546 cout<<"// Draw matched tracks asymmetry for each trigger "<<endl;
547 cout<<"//===================================================="<<endl;
549 //Print a canvas per trigger type
550 TCanvas *cAsymMatched;
552 legendHeader = "for all collisions";
553 for ( Int_t iTrig = 0; iTrig < triggersB->GetEntriesFast(); iTrig++){
554 //skip sum of all triggers
555 if ( iTrig == (triggersB->GetEntriesFast()-1) ) continue;
557 ( (TDirectoryFile*) dirTrigger->At( iTrig ) )->cd();
559 canvasName = "AsymMatched";
560 canvasName +="trigger";
561 canvasName +=( (TObjString*) triggersShortName->At(iTrig) )->GetString();
563 cAsymMatched = ProcessCanvasAsymMatched(triggersB, trackPosMatched, trackNegMatched, trackAllMatched, iTrig, iCentBin, canvasName,legendHeader);
564 cAsymMatched->Print(OutFileNamePDF.Data());
565 cAsymMatched->Write();
566 cAsymMatched->Close();
571 cout<<"//===================================================================="<<endl;
572 cout<<"// Draw beam gas contribution to matched tracks for each trigger "<<endl;
573 cout<<"//===================================================================="<<endl;
575 //Print a canvas per trigger type
576 TCanvas *cBeamGasMatched;
579 for ( Int_t iTrig = 0; iTrig < triggersB->GetEntriesFast(); iTrig++){
580 //skip sum of all triggers
581 if ( iTrig == (triggersB->GetEntriesFast()-1)) continue;
583 ( (TDirectoryFile*) dirTrigger->At(iTrig) )->cd();
584 canvasName = "BeamGasMatched";
585 canvasName +="trigger";
586 canvasName +=( (TObjString*) triggersShortName->At(iTrig) )->GetString();
588 cBeamGasMatched= ProcessCanvasBeamGasMatched(triggersB, trackBeamGasMatched, trackBeamGasMatchedHighPt, trackAllMatched, trackMatchedHighPt, iTrig, iCentBin, canvasName,legendHeader);
589 cBeamGasMatched->Print(OutFileNamePDF.Data());
590 cBeamGasMatched->Write();
591 cBeamGasMatched->Close();
595 cout<<"//=================================================="<<endl;
596 cout<<"// Draw high pt tracks per trigger"<<endl;
597 cout<<"//=================================================="<<endl;
599 //Print a canvas per trigger type
600 TCanvas *cHighPtMuons;
601 legendHeader = "for all collisions";
603 for ( Int_t iTrig = 0; iTrig < triggersB->GetEntriesFast(); iTrig++){
604 //skip sum of all triggers
605 if( iTrig == (triggersB->GetEntriesFast()-1)) continue;
607 ( (TDirectoryFile*) dirTrigger->At( iTrig ) )->cd();
609 canvasName = "HighPtMuons";
610 canvasName +="trigger";
611 canvasName +=( (TObjString*) triggersShortName->At(iTrig) )->GetString();
614 cHighPtMuons = ProcessCanvasHighPtMuons(triggersB, trigSel, trackMatchedLowPt, trackMatchedHighPt, iTrig, iCentBin, canvasName,legendHeader);
615 cHighPtMuons->Print(OutFileNamePDF.Data());
616 cHighPtMuons->Write();
617 cHighPtMuons->Close();
624 //===================================================================================
625 //Print out the number of trigger without and with Phys. Sel.
626 //===================================================================================
628 cout << endl << endl;
629 //====================================================
631 if ( triggersB->At(kCMUS) ) {
633 // set the format to print labels
635 THashList* labels = (static_cast<TH1*>(trigWithPS.At(triggersB->GetEntriesFast()*centBinNr+kCMUS)))->GetXaxis()->GetLabels();
636 TString format(Form("\n%%%ds %%9d",0));
639 // print value for each label
640 TObjString* label = 0x0;
641 TIter nextLabel(labels);
642 cout << "-------------------------------------------------" << endl;
643 cout << "Run Number" << "\t Number of "<< ( (TObjString*) triggersB->At(kCMUS) )->GetString()<<" after Phys. Sel. " << endl ;
644 while ((label = static_cast<TObjString*>(nextLabel()))) {
646 Int_t bin = (Int_t) label->GetUniqueID();
647 printf(format.Data(), label->String().Data(), (Int_t) (static_cast<TH1*>(trigWithPS.At(triggersB->GetEntriesFast()*centBinNr+kCMUS)))->GetBinContent(bin));
649 printf("\n========== Total #runs = %d ==============\n",nRuns);
653 cout << "-------------------------------------------------" << endl;
654 cout << "Total statistic" << endl;
655 cout << " " << endl ;
657 cout << "-------------------------------------------------------------------" << endl;
658 cout<<"Number of triggers w/o Phys. Sel./ w/ Phys. Sel (Phys. Sel. cut in %)"<<endl;
659 for(Int_t iTrig = 0; iTrig < triggersB->GetEntriesFast()-1; iTrig++){
660 TString triggerNameB = ( (TObjString*) triggersB->At(iTrig) )->GetString();
662 Int_t cutinpercent = 0;
663 printf("%10s\t",triggerNameB.Data());
664 Int_t index = GetIndex(triggersB,iTrig,centBinNr);
665 if(NumOfBNoPS[index]) cutinpercent = (Int_t) ((Double_t)(NumOfBNoPS[index]-NumOfBWithPS[index])/(NumOfBNoPS[index])*100.);
666 printf("%5.2e / %.2e (%d%%)\n", (Double_t) NumOfBNoPS[index],(Double_t) NumOfBWithPS[index],cutinpercent);
676 //--------------------------------------------- //
677 // monitor quantities run per run //
678 //--------------------------------------------- //
681 //const Int_t kNHistos = 100;
682 //TObjArray outHist(kNHistos);
684 Int_t const nMuonTriggerCase = 7;
685 TH1F *hMuonTrigger[nMuonTriggerCase];
686 TString muonTriggerName[nMuonTriggerCase] = {"Unlike-only","Like-only","Hpt-only","Unlike&Like","Unlike&Hpt","Like&Hpt","Unlike&Like&Hpt"};
687 for ( Int_t i = 0; i < nMuonTriggerCase; i++ ) {
688 hMuonTrigger[i] = new TH1F(Form("hMuonTrigger_%s", muonTriggerName[i].Data()),Form("Trigger %s per run",muonTriggerName[i].Data()),10000,1,10000);
691 TH1F* hTriggerCutVsRun[2], *hTriggerCutWidthVsRun[2];
692 for ( Int_t ihisto=0; ihisto<2; ++ihisto ) {
693 TString cutName = ( ihisto == 0 ) ? "Lpt" : "Hpt";
694 hTriggerCutVsRun[ihisto] = new TH1F(Form("hTriggerCutVsRun%s", cutName.Data()), Form("Trigger %s cut per run", cutName.Data()), 10000,1,10000);
695 hTriggerCutWidthVsRun[ihisto] = (TH1F*)hTriggerCutVsRun[ihisto]->Clone(Form("hTriggerCutWidthVsRun%s", cutName.Data()));
697 TF1* fitMatchTrig = new TF1("fitMatchTrig","[3] + [0] * ( 1. + TMath::Erf((x - [1]) / [2] / TMath::Sqrt(2.)))", 0.1, 6.);
698 TH1F* hNClustersPerTrackVsRun_Mean = new TH1F("hNClustersPerTrackVsRun_Mean", "averaged number of associated clusters per track;run;<n_{clusters}>",10000,1,10000);
699 TH1F* hNClustersPerTrackVsRun_Sigma = new TH1F("hNClustersPerTrackVsRun_Sigma", "dispersion of the number of associated clusters per track;run;#sigma_{n_{clusters}}",10000,1,10000);
700 TH1F* hNChamberHitPerTrack_Mean = new TH1F("hNChamberHitPerTrack_Mean", "averaged number of chambers hit per track;run;<n_{chamber hit}>",10000,1,10000);
701 TH1F* hNChamberHitPerTrack_Sigma = new TH1F("hNChamberHitPerTrack_Sigma", "dispersion of the number of chambers hit per track;run;#sigma_{n_{chamber hit}}",10000,1,10000);
702 TH1F* hChi2_Mean = new TH1F("hChi2_Mean", "averaged normalized #chi^{2} distribution;run;<#chi^{2} / ndf>",10000,1,10000);
703 TH1F* hChi2_Sigma = new TH1F("hChi2_Sigma", "dispersion of normalized #chi^{2} distribution;run;#sigma_{#chi^{2} / ndf}",10000,1,10000);
704 TH1F* hNClustersInCh[10];
705 for (Int_t ich=0; ich<10; ich++){
706 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);
708 TH1F* hClusterChargeMeanInCh[10], *hClusterChargeSigmaInCh[10];
709 for (Int_t ich=0; ich<10; ich++){
710 hClusterChargeMeanInCh[ich] = new TH1F(Form("hClusterChargeMeanInCh%d",ich+1), Form("averaged cluster charge -mean- per track in chamber %d",ich+1),10000,1,10000);
711 hClusterChargeSigmaInCh[ich] = new TH1F(Form("hClusterChargeSigmaInCh%d",ich+1), Form("averaged cluster charge -sigma- per track in chamber %d",ich+1),10000,1,10000);
713 TH1F* hClusterSizeMeanInCh[10], *hClusterSizeSigmaInCh[10];
714 for (Int_t ich=0; ich<10; ich++){
715 hClusterSizeMeanInCh[ich] = new TH1F(Form("hClusterSizeMeanInCh%d",ich+1), Form("averaged cluster size -mean- per track in chamber %d",ich+1),10000,1,10000);
716 hClusterSizeSigmaInCh[ich] = new TH1F(Form("hClusterSizeSigmaInCh%d",ich+1), Form("averaged cluster size -sigma- per track in chamber %d",ich+1),10000,1,10000);
719 TH1F* hClusterHitMapXInCh[10];
720 for (Int_t ich=0; ich<10; ich++){
721 hClusterHitMapXInCh[ich] = new TH1F(Form("hClusterHitMapXInCh%d",ich+1), Form("averaged cluster position distribution in chamber %d;X (cm)",ich+1),10000,1,10000);
723 TH1F* hClusterHitMapYInCh[10];
724 for (Int_t ich=0; ich<10; ich++){
725 hClusterHitMapYInCh[ich] = new TH1F(Form("hClusterHitMapYInCh%d",ich+1), Form("averaged cluster position distribution in chamber %d;Y (cm)",ich+1),10000,1,10000);
731 // Are the runs stored locally or in alien?
732 Int_t isAlienFile = 0;
733 if(alienBaseDir.Contains("alien:")){
735 alienBaseDir.ReplaceAll("alien://","");
738 cout<<"============================================================"<<endl;
739 cout<< "Monitoring quantities run per run: loop over "<<runs->GetEntriesFast()<<" runs."<<endl;
740 cout<<" directory = "<<alienBaseDir.Data()<<endl;
741 cout<<"============================================================"<<endl;
744 for ( Int_t irun=0; irun<runs->GetEntriesFast(); irun++ ) {
746 TString run = ((TObjString*)runs->UncheckedAt(irun))->GetString();
748 // get the file (or list of files) to be analyzed
750 TGridResult *res = 0;
753 command = Form("find %s/ %s/%s", alienBaseDir.Data(), run.Data(), QAFileName);
754 res = gGrid->Command(command);
756 Error("PlotMuonQA","no result for the command: %s",command.Data());
761 res = new TGridResult();
763 command = Form("find %s/*%s/ -name %s | xargs", alienBaseDir.Data(), run.Data(), QAFileName);
764 TString foundFiles = gSystem->GetFromPipe(command.Data());
765 TObjArray* arr = foundFiles.Tokenize(" ");
767 for ( Int_t iarr=0; iarr<arr->GetEntries(); iarr++ ) {
768 res->Add(new TObjString(arr->At(iarr)->GetName()));
773 // Loop over 'find' results and get next LFN
775 TObjString *objs = 0;
776 TObject* currObj = 0x0;
777 Bool_t searchRunNr = kFALSE;
778 if ( !isAlienFile && run.Contains("*") ) searchRunNr = kTRUE;
781 while ( ( currObj = nextmap() ) ){
783 // get the current file url
785 objs = static_cast<TObjString*>(static_cast<TMap*>(currObj)->GetValue("turl"));
788 objs=static_cast<TObjString*>(currObj);
791 if (objs->GetString().IsNull()) {
792 Error("PlotMuonQA","turl/obj not found for the run %s... SKIPPING", run.Data());
797 Int_t runNr = GetRunNumber(objs->GetString());
798 if (runNr > 0) run = Form("%i",runNr);
801 if ( run.IsDigit() && ! selectRuns.Contains(Form("%i",run.Atoi())) ) continue;
803 // open the outfile for this run
804 TFile *runFile = TFile::Open(objs->GetString());
805 if (!runFile || ! runFile->IsOpen()) {
806 Error("PlotMuonQA","failed to open file: %s", objs->GetName());
809 runFile->Cd("MUON_QA");
811 // get interesting histos
812 TObjArray* general1 = static_cast<TObjArray*>(runFile->FindObjectAny("general1"));
813 TObjArray* general2 = static_cast<TObjArray*>(runFile->FindObjectAny("general2"));
814 TObjArray* expert = static_cast<TObjArray*>(runFile->FindObjectAny("expert"));
816 if (!general1 || !general2 || !expert){
817 Error("PlotMuonQA","All objects not here !!! ===> Skipping...for %s",objs->GetName());
821 TH1* hNClustersPerTrack = static_cast<TH1*>(general1->FindObject("hNClustersPerTrack"));
822 TH1* hNChamberHitPerTrack = static_cast<TH1*>(general1->FindObject("hNChamberHitPerTrack"));
823 TH1* hChi2 = static_cast<TH1*>(general1->FindObject("hChi2"));
824 TH1* hNClustersPerCh = static_cast<TH1*>(general2->FindObject("hNClustersPerCh"));
825 TH1 *hClusterChargePerChMean =static_cast<TH1*>(general2->FindObject("hClusterChargePerChMean"));
826 TH1 *hClusterChargePerChSigma =static_cast<TH1*>(general2->FindObject("hClusterChargePerChSigma"));
827 TH1 *hClusterSizePerChMean =static_cast<TH1*>(general2->FindObject("hClusterSizePerChMean"));
828 TH1 *hClusterSizePerChSigma =static_cast<TH1*>(general2->FindObject("hClusterSizePerChSigma"));
829 TH1* hMuonTriggers = static_cast<TH1*>(general1->FindObject("hMuonTriggers"));
830 for (Int_t ihisto=0; ihisto<nMuonTriggerCase; ihisto++){
832 if ( hMuonTriggers ) val = hMuonTriggers->GetBinContent(ihisto+2);
833 if ( hMuonTrigger[ihisto]->GetSumw2N() == 0 ) hMuonTrigger[ihisto]->Sumw2();
834 hMuonTrigger[ihisto]->SetBinContent(ibin,val);
835 hMuonTrigger[ihisto]->SetBinError(ibin,TMath::Sqrt(val));
836 hMuonTrigger[ihisto]->GetXaxis()->SetBinLabel(ibin,run.Data());
838 TH1* hPtDistrib = static_cast<TH1*>(general1->FindObject("hPt"));
839 TH1* hPtDistribLpt = static_cast<TH1*>(general1->FindObject("hPtMatchLpt"));
840 TH1* hPtDistribHpt = static_cast<TH1*>(general1->FindObject("hPtMatchHpt"));
841 if ( hPtDistrib && hPtDistribLpt && hPtDistribHpt ) {
842 if ( hPtDistrib->GetSumw2N() == 0 ) hPtDistrib->Sumw2();
843 TH1* histoMatch[2] = {hPtDistribLpt, hPtDistribHpt};
844 for ( Int_t ihisto=0; ihisto<2; ++ihisto ) {
845 if ( histoMatch[ihisto]->GetSumw2N() == 0 ) histoMatch[ihisto]->Sumw2();
846 if ( histoMatch[ihisto]->GetEntries() == 0 ) continue;
847 histoMatch[ihisto]->Divide(hPtDistrib);
848 Double_t minEff = 99999., maxEff = -1.;
849 Double_t ptMinFit = 0.1;
850 Double_t ptMaxFit = 6.;
851 Int_t ptBinLow = histoMatch[ihisto]->GetXaxis()->FindBin(ptMinFit);
852 Int_t ptBinHigh = histoMatch[ihisto]->GetXaxis()->FindBin(ptMaxFit);
853 for ( Int_t currBin=ptBinLow; currBin<=ptBinHigh; currBin++ ) {
854 Double_t currEff = histoMatch[ihisto]->GetBinContent(currBin);
855 Double_t currPt = histoMatch[ihisto]->GetXaxis()->GetBinCenter(currBin);
856 if ( currPt < 1.5 && minEff > currEff ) {
860 if ( currPt > 0.5 && maxEff < currEff ) {
864 } // loop on histo bins
865 fitMatchTrig->SetParameters(0.5, 0.5, 0.8, 0.2);
866 fitMatchTrig->SetParLimits(0,0.,1.);
867 fitMatchTrig->SetParLimits(1,0.,5.);
868 fitMatchTrig->SetParLimits(2,0.,5.);
869 fitMatchTrig->SetParLimits(3,0.,0.5);
870 histoMatch[ihisto]->Fit(fitMatchTrig,"RQ0","",ptMinFit,ptMaxFit);
871 Double_t ptCut = fitMatchTrig->GetParameter(1);
872 Double_t ptCutErr = fitMatchTrig->GetParError(1);
873 Double_t ptCutWidth = fitMatchTrig->GetParameter(2);
874 if ( ptCut < 0 || ptCut > 10. ) {
875 ptCut = ptCutErr = ptCutWidth = 0.;
877 hTriggerCutVsRun[ihisto]->SetBinContent(ibin, ptCut);
878 hTriggerCutVsRun[ihisto]->SetBinError(ibin, ptCutErr);
879 hTriggerCutWidthVsRun[ihisto]->SetBinContent(ibin, ptCut);
880 hTriggerCutWidthVsRun[ihisto]->SetBinError(ibin, ptCutWidth);
881 } // loop on match histos
883 TH2* hClusterHitMapInCh[10];
884 for(Int_t ich=0; ich<10; ich++) hClusterHitMapInCh[ich] = static_cast<TH2*>(expert->FindObject(Form("hClusterHitMapInCh%d",ich+1)));
886 if (!hNClustersPerCh) {
887 Warning("PlotMUONQA","File: %s has empty histograms !", objs->GetName());
888 hNClustersPerTrackVsRun_Mean->SetBinContent(ibin, 0.);
889 hNClustersPerTrackVsRun_Mean->SetBinError(ibin, 1.);
890 hNClustersPerTrackVsRun_Sigma->SetBinContent(ibin, 0.);
891 hNClustersPerTrackVsRun_Sigma->SetBinError(ibin, 1.);
892 hNChamberHitPerTrack_Mean->SetBinContent(ibin, 0.);
893 hNChamberHitPerTrack_Mean->SetBinError(ibin, 1.);
894 hNChamberHitPerTrack_Sigma->SetBinContent(ibin, 0.);
895 hNChamberHitPerTrack_Sigma->SetBinError(ibin, 1.);
896 hChi2_Mean->SetBinContent(ibin, 0.);
897 hChi2_Mean->SetBinError(ibin, 1.);
898 hChi2_Sigma->SetBinContent(ibin, 0.);
899 hChi2_Sigma->SetBinError(ibin, 1.);
900 for (Int_t ich=0; ich<10; ich++) {
901 hNClustersInCh[ich]->SetBinContent(ibin,0.);
902 hNClustersInCh[ich]->SetBinError(ibin,1.);
903 hClusterHitMapXInCh[ich]->SetBinContent(ibin,0.);
904 hClusterHitMapXInCh[ich]->SetBinError(ibin,1.);
905 hClusterHitMapYInCh[ich]->SetBinContent(ibin,0.);
906 hClusterHitMapYInCh[ich]->SetBinError(ibin,1.);
912 // fill monitoring plots
913 hNClustersPerTrackVsRun_Mean->SetBinContent(ibin, hNClustersPerTrack->GetMean());
914 hNClustersPerTrackVsRun_Mean->SetBinError(ibin, hNClustersPerTrack->GetMeanError());
915 hNClustersPerTrackVsRun_Sigma->SetBinContent(ibin, hNClustersPerTrack->GetRMS());
916 hNClustersPerTrackVsRun_Sigma->SetBinError(ibin, hNClustersPerTrack->GetRMSError());
917 hNChamberHitPerTrack_Mean->SetBinContent(ibin, hNChamberHitPerTrack->GetMean());
918 hNChamberHitPerTrack_Mean->SetBinError(ibin, hNChamberHitPerTrack->GetMeanError());
919 hNChamberHitPerTrack_Sigma->SetBinContent(ibin, hNChamberHitPerTrack->GetRMS());
920 hNChamberHitPerTrack_Sigma->SetBinError(ibin, hNChamberHitPerTrack->GetRMSError());
921 hChi2_Mean->SetBinContent(ibin, hChi2->GetMean());
922 hChi2_Mean->SetBinError(ibin, hChi2->GetMeanError());
923 hChi2_Sigma->SetBinContent(ibin, hChi2->GetRMS());
924 hChi2_Sigma->SetBinError(ibin, hChi2->GetRMSError());
925 for (Int_t ich=0; ich<10; ich++) {
926 hNClustersInCh[ich]->SetBinContent(ibin,hNClustersPerCh->GetBinContent(ich+1));
927 hNClustersInCh[ich]->SetBinError(ibin,hNClustersPerCh->GetBinError(ich+1));
928 hClusterChargeMeanInCh[ich]->SetBinContent(ibin,hClusterChargePerChMean->GetBinContent(ich+1));
929 hClusterChargeMeanInCh[ich]->SetBinError(ibin,hClusterChargePerChMean->GetBinError(ich+1));
930 hClusterChargeSigmaInCh[ich]->SetBinContent(ibin,hClusterChargePerChSigma->GetBinContent(ich+1));
931 hClusterChargeSigmaInCh[ich]->SetBinError(ibin,hClusterChargePerChSigma->GetBinError(ich+1));
932 hClusterSizeMeanInCh[ich]->SetBinContent(ibin,hClusterSizePerChMean->GetBinContent(ich+1));
933 hClusterSizeMeanInCh[ich]->SetBinError(ibin,hClusterSizePerChMean->GetBinError(ich+1));
934 hClusterSizeSigmaInCh[ich]->SetBinContent(ibin,hClusterSizePerChSigma->GetBinContent(ich+1));
935 hClusterSizeSigmaInCh[ich]->SetBinError(ibin,hClusterSizePerChSigma->GetBinError(ich+1));
936 hNClustersInCh[ich]->SetBinContent(ibin,hNClustersPerCh->GetBinContent(ich+1));
937 hNClustersInCh[ich]->SetBinError(ibin,hNClustersPerCh->GetBinError(ich+1));
938 hClusterHitMapXInCh[ich]->SetBinContent(ibin,hClusterHitMapInCh[ich]->GetMean(1));
939 hClusterHitMapXInCh[ich]->SetBinError(ibin,hClusterHitMapInCh[ich]->GetMeanError(1));
940 hClusterHitMapYInCh[ich]->SetBinContent(ibin,hClusterHitMapInCh[ich]->GetMean(2));
941 hClusterHitMapYInCh[ich]->SetBinError(ibin,hClusterHitMapInCh[ich]->GetMeanError(2));
946 for ( Int_t ihisto=0; ihisto<2; ++ihisto ) {
947 hTriggerCutVsRun[ihisto]->GetXaxis()->SetBinLabel(ibin,run.Data());
948 hTriggerCutWidthVsRun[ihisto]->GetXaxis()->SetBinLabel(ibin,run.Data());
950 hNClustersPerTrackVsRun_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
951 hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());
952 hNChamberHitPerTrack_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
953 hNChamberHitPerTrack_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());
954 hChi2_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
955 hChi2_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());
956 for (Int_t ich=0; ich<10; ich++){
957 hNClustersInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
958 hClusterChargeMeanInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
959 hClusterChargeSigmaInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
960 hClusterSizeMeanInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
961 hClusterSizeSigmaInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
962 hClusterHitMapXInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
963 hClusterHitMapYInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());
966 // close outfile for this run
972 }//end loop over runs
975 hNClustersPerTrackVsRun_Mean->LabelsOption("a");
976 hNClustersPerTrackVsRun_Sigma->LabelsOption("a");
977 hNChamberHitPerTrack_Mean->LabelsOption("a");
978 hNChamberHitPerTrack_Sigma->LabelsOption("a");
979 hChi2_Mean->LabelsOption("a");
980 hChi2_Sigma->LabelsOption("a");
982 for(Int_t ich=0; ich<10; ich++){
983 hNClustersInCh[ich]->LabelsOption("a");
984 hClusterChargeMeanInCh[ich]->LabelsOption("a");
985 hClusterChargeSigmaInCh[ich]->LabelsOption("a");
986 hClusterSizeMeanInCh[ich]->LabelsOption("a");
987 hClusterSizeSigmaInCh[ich]->LabelsOption("a");
988 hClusterHitMapXInCh[ich]->LabelsOption("a");
989 hClusterHitMapYInCh[ich]->LabelsOption("a");
992 TString dirToGo = OutFileNameROOT.Data(); dirToGo+=":/";
993 gDirectory->Cd(dirToGo.Data());
994 cout<<"=================================================="<<endl;
995 cout<<"Display Mean and Sigma of the number of associated clusters to a track "<<endl;
996 cout<<"=================================================="<<endl;
997 TLegend *lNClusters = new TLegend(0.75,0.85,0.99,0.99);
998 lNClusters->AddEntry(hNClustersPerTrackVsRun_Mean,"clusters","PL");
999 lNClusters->AddEntry(hNChamberHitPerTrack_Mean,"chamber hit","PL");
1001 TCanvas* cNClusters = new TCanvas("cNClusters","cNClusters",1200,900);
1002 cNClusters->Divide(1,2);
1004 //hNClustersPerTrackVsRun_Mean->SetMaximum(11);
1005 hNClustersPerTrackVsRun_Mean->SetMinimum(7);
1006 hNClustersPerTrackVsRun_Mean->SetStats(kFALSE);
1007 hNClustersPerTrackVsRun_Mean->GetXaxis()->SetRange(1,ibin-1);
1008 hNClustersPerTrackVsRun_Mean->GetXaxis()->SetNdivisions(1,kFALSE);
1009 //hNClustersPerTrackVsRun_Mean->LabelsOption("u");
1010 hNClustersPerTrackVsRun_Mean->SetLabelSize(0.04);
1011 hNClustersPerTrackVsRun_Mean->SetTitle("averaged number of associated clusters or of the number of chamber hit per track");
1012 hNClustersPerTrackVsRun_Mean->SetLineWidth(2);
1013 hNClustersPerTrackVsRun_Mean->Draw("e");
1014 hNChamberHitPerTrack_Mean->SetLineColor(kRed);
1015 hNChamberHitPerTrack_Mean->SetLineWidth(2);
1016 hNChamberHitPerTrack_Mean->Draw("esame");
1017 lNClusters->Draw("same");
1020 //hNClustersPerTrackVsRun_Sigma->SetMaximum(1.1);
1021 hNClustersPerTrackVsRun_Sigma->SetMinimum(0.4);
1022 hNClustersPerTrackVsRun_Sigma->SetStats(kFALSE);
1023 hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetRange(1,ibin-1);
1024 hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetNdivisions(1,kFALSE);
1025 //hNClustersPerTrackVsRun_Sigma->LabelsOption("u");
1026 hNClustersPerTrackVsRun_Sigma->SetLabelSize(0.04);
1027 hNClustersPerTrackVsRun_Sigma->SetTitle("dispersion of the number of associated clusters or of the number of chamber hit per track");
1028 hNClustersPerTrackVsRun_Sigma->SetLineWidth(2);
1029 hNClustersPerTrackVsRun_Sigma->Draw("e");
1030 hNChamberHitPerTrack_Sigma->SetLineWidth(2);
1031 hNChamberHitPerTrack_Sigma->SetLineColor(kRed);
1032 hNChamberHitPerTrack_Sigma->Draw("esame");
1033 lNClusters->Draw("same");
1035 cNClusters->Print(OutFileNamePDF.Data());
1037 cNClusters->Write();
1039 cout<<"=================================================="<<endl;
1040 cout<<" Display average number of cluster per chamber "<<endl;
1041 cout<<"=================================================="<<endl;
1043 TLegend *lNClustersPerCh = new TLegend(0.92,0.45,0.99,0.99);
1044 TCanvas* cNClustersPerCh = new TCanvas("cNClustersPerCh","cNClustersPerCh",1200,900);
1045 cNClustersPerCh->cd();
1046 cNClustersPerCh->SetRightMargin(0.1);
1047 hNClustersInCh[0]->SetStats(kFALSE);
1048 hNClustersInCh[0]->GetXaxis()->SetRange(1,ibin-1);
1049 hNClustersInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
1050 //hNClustersInCh[0]->LabelsOption("u");
1051 hNClustersInCh[0]->SetLabelSize(0.02);
1052 hNClustersInCh[0]->SetTitle("averaged number of clusters in chamber i per track");
1053 hNClustersInCh[0]->SetMaximum(1.2);
1054 hNClustersInCh[0]->SetMinimum(0.01);
1055 for (Int_t ich=0; ich<10; ich++) {
1056 hNClustersInCh[ich]->SetLineColor(ich+1+ich/9);
1057 hNClustersInCh[ich]->SetLineWidth(2);
1058 if (ich == 0) hNClustersInCh[ich]->Draw("e");
1059 else hNClustersInCh[ich]->Draw("esame");
1060 lNClustersPerCh->AddEntry(hNClustersInCh[ich],Form("ch%d",ich+1),"PL");
1062 lNClustersPerCh->Draw("same");
1064 cNClustersPerCh->Print(OutFileNamePDF.Data());
1066 cNClustersPerCh->Write();
1068 cout<<"=================================================="<<endl;
1069 cout<<" Display average cluster charge per chamber "<<endl;
1070 cout<<"=================================================="<<endl;
1072 TLegend *lClusterChargePerCh = new TLegend(0.92,0.45,0.99,0.99);
1073 TCanvas* cClusterChargePerCh = new TCanvas("cClustersChargePerCh","cClustersChargePerCh",1200,900);
1074 cClusterChargePerCh->SetRightMargin(0.1);
1075 cClusterChargePerCh->Divide(1,2);
1077 cClusterChargePerCh->cd(1);
1078 hClusterChargeMeanInCh[0]->SetStats(kFALSE);
1079 hClusterChargeMeanInCh[0]->GetXaxis()->SetRange(1,ibin-1);
1080 hClusterChargeMeanInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
1081 //hClusterChargeInCh[0]->LabelsOption("u");
1082 hClusterChargeMeanInCh[0]->SetLabelSize(0.04);
1083 hClusterChargeMeanInCh[0]->SetTitle("Cluster charge mean (fC) per track in chamber i");
1084 hClusterChargeMeanInCh[0]->SetMaximum(150);
1085 hClusterChargeMeanInCh[0]->SetMinimum(30);
1086 for (Int_t ich=0; ich<10; ich++) {
1087 hClusterChargeMeanInCh[ich]->SetLineColor(ich+1+ich/9);
1088 hClusterChargeMeanInCh[ich]->SetLineWidth(2);
1089 if (ich == 0) hClusterChargeMeanInCh[ich]->Draw("e");
1090 else hClusterChargeMeanInCh[ich]->Draw("esame");
1091 lClusterChargePerCh->AddEntry(hClusterChargeMeanInCh[ich],Form("ch%d",ich+1),"PL");
1093 lClusterChargePerCh->Draw("same");
1095 cClusterChargePerCh->cd(2);
1096 hClusterChargeSigmaInCh[0]->SetStats(kFALSE);
1097 hClusterChargeSigmaInCh[0]->GetXaxis()->SetRange(1,ibin-1);
1098 hClusterChargeSigmaInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
1099 //hClusterChargeInCh[0]->LabelsOption("u");
1100 hClusterChargeSigmaInCh[0]->SetLabelSize(0.04);
1101 hClusterChargeSigmaInCh[0]->SetTitle("Cluster charge sigma per track in chamber i");
1102 hClusterChargeSigmaInCh[0]->SetMaximum(250);
1103 hClusterChargeSigmaInCh[0]->SetMinimum(50);
1104 for (Int_t ich=0; ich<10; ich++) {
1105 hClusterChargeSigmaInCh[ich]->SetLineColor(ich+1+ich/9);
1106 hClusterChargeSigmaInCh[ich]->SetLineWidth(2);
1107 if (ich == 0) hClusterChargeSigmaInCh[ich]->Draw("e");
1108 else hClusterChargeSigmaInCh[ich]->Draw("esame");
1110 lClusterChargePerCh->Draw("same");
1112 cClusterChargePerCh->Print(OutFileNamePDF.Data());
1114 cClusterChargePerCh->Write();
1116 cout<<"=================================================="<<endl;
1117 cout<<" Display average cluster size per chamber "<<endl;
1118 cout<<"=================================================="<<endl;
1120 TLegend *lClusterSizePerCh = new TLegend(0.92,0.45,0.99,0.99);
1121 TCanvas* cClusterSizePerCh = new TCanvas("cClustersSizePerCh","cClustersSizePerCh",1200,900);
1122 cClusterSizePerCh->SetRightMargin(0.1);
1123 cClusterSizePerCh->Divide(1,2);
1125 cClusterSizePerCh->cd(1);
1126 hClusterSizeMeanInCh[0]->SetStats(kFALSE);
1127 hClusterSizeMeanInCh[0]->GetXaxis()->SetRange(1,ibin-1);
1128 hClusterSizeMeanInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
1130 hClusterSizeMeanInCh[0]->SetLabelSize(0.04);
1131 hClusterSizeMeanInCh[0]->SetTitle("Cluster size mean (npads) per track in chamber i");
1132 hClusterSizeMeanInCh[0]->SetMaximum(18);
1133 hClusterSizeMeanInCh[0]->SetMinimum(0);
1134 for (Int_t ich=0; ich<10; ich++) {
1135 hClusterSizeMeanInCh[ich]->SetLineColor(ich+1+ich/9);
1136 hClusterSizeMeanInCh[ich]->SetLineWidth(2);
1137 if (ich == 0) hClusterSizeMeanInCh[ich]->Draw("e");
1138 else hClusterSizeMeanInCh[ich]->Draw("esame");
1139 lClusterSizePerCh->AddEntry(hClusterSizeMeanInCh[ich],Form("ch%d",ich+1),"PL");
1141 lClusterSizePerCh->Draw("same");
1143 cClusterSizePerCh->cd(2);
1144 hClusterSizeSigmaInCh[0]->SetStats(kFALSE);
1145 hClusterSizeSigmaInCh[0]->GetXaxis()->SetRange(1,ibin-1);
1146 hClusterSizeSigmaInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
1148 hClusterSizeSigmaInCh[0]->SetLabelSize(0.04);
1149 hClusterSizeSigmaInCh[0]->SetTitle("Cluster size sigma (npads) per track in chamber i");
1150 hClusterSizeSigmaInCh[0]->SetMaximum(7);
1151 hClusterSizeSigmaInCh[0]->SetMinimum(0);
1152 for (Int_t ich=0; ich<10; ich++) {
1153 hClusterSizeSigmaInCh[ich]->SetLineColor(ich+1+ich/9);
1154 hClusterSizeSigmaInCh[ich]->SetLineWidth(2);
1155 if (ich == 0) hClusterSizeSigmaInCh[ich]->Draw("e");
1156 else hClusterSizeSigmaInCh[ich]->Draw("esame");
1158 lClusterSizePerCh->Draw("same");
1160 cClusterSizePerCh->Print(OutFileNamePDF.Data());
1162 cClusterSizePerCh->Write();
1165 cout<<"=================================================="<<endl;
1166 cout<<"Display average X and Y position of clusters per chamber"<<endl;
1167 cout<<"=================================================="<<endl;
1168 TLegend *lClusterHitMapPerCh = new TLegend(0.92,0.45,0.99,0.99);
1169 TCanvas* cClusterHitMapPerCh = new TCanvas("cClusterHitMapPerCh","cClusterHitMapPerCh",1200,900);
1170 cClusterHitMapPerCh->Divide(1,2);
1171 cClusterHitMapPerCh->GetPad(1)->SetRightMargin(0.1);
1172 cClusterHitMapPerCh->GetPad(2)->SetRightMargin(0.1);
1174 cClusterHitMapPerCh->cd(1);
1175 hClusterHitMapXInCh[0]->SetStats(kFALSE);
1176 hClusterHitMapXInCh[0]->GetXaxis()->SetRange(1,ibin-1);
1177 hClusterHitMapXInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
1178 //hNClustersInCh[0]->LabelsOption("u");
1179 hClusterHitMapXInCh[0]->SetLabelSize(0.04);
1180 hClusterHitMapXInCh[0]->SetTitle("<X> of clusters - associated to a track - in chamber i");
1181 hClusterHitMapXInCh[0]->SetMaximum(30);
1182 hClusterHitMapXInCh[0]->SetMinimum(-30);
1183 for (Int_t ich=0; ich<10; ich++) {
1184 hClusterHitMapXInCh[ich]->SetLineColor(ich+1+ich/9);
1185 hClusterHitMapXInCh[ich]->SetLineWidth(2);
1186 if (ich == 0) hClusterHitMapXInCh[ich]->Draw("e");
1187 else hClusterHitMapXInCh[ich]->Draw("esame");
1189 lClusterHitMapPerCh->AddEntry(hClusterHitMapXInCh[ich],Form("ch%d",ich+1),"PL");
1191 lClusterHitMapPerCh->Draw("same");
1193 cClusterHitMapPerCh->cd(2);
1194 hClusterHitMapYInCh[0]->SetStats(kFALSE);
1195 hClusterHitMapYInCh[0]->GetXaxis()->SetRange(1,ibin-1);
1196 hClusterHitMapYInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);
1197 //hNClustersInCh[0]->LabelsOption("u");
1198 hClusterHitMapYInCh[0]->SetLabelSize(0.04);
1199 hClusterHitMapYInCh[0]->SetTitle("<Y> of clusters - associated to a track - in chamber i");
1200 hClusterHitMapYInCh[0]->SetMaximum(30);
1201 hClusterHitMapYInCh[0]->SetMinimum(-30);
1202 for (Int_t ich=0; ich<10; ich++) {
1203 hClusterHitMapYInCh[ich]->SetLineColor(ich+1+ich/9);
1204 hClusterHitMapYInCh[ich]->SetLineWidth(2);
1205 if (ich == 0) hClusterHitMapYInCh[ich]->Draw("e");
1206 else hClusterHitMapYInCh[ich]->Draw("esame");
1208 lClusterHitMapPerCh->Draw("same");
1210 cClusterHitMapPerCh->Print(OutFileNamePDF.Data());
1212 cClusterHitMapPerCh->Write();
1215 cout<<"=================================================="<<endl;
1216 cout<<" Display tracks ChiSquare "<<endl;
1217 cout<<"=================================================="<<endl;
1218 TCanvas* cChi2 = new TCanvas("cChi2","cChi2",1200,900);
1221 hChi2_Mean->SetStats(kFALSE);
1222 hChi2_Mean->GetXaxis()->SetRange(1,ibin-1);
1223 hChi2_Mean->GetXaxis()->SetNdivisions(1,kFALSE);
1224 //hChi2_Mean->LabelsOption("u");
1225 hChi2_Mean->SetLabelSize(0.04);
1226 hChi2_Mean->SetLineWidth(2);
1227 hChi2_Mean->Draw("e");
1230 hChi2_Sigma->SetStats(kFALSE);
1231 hChi2_Sigma->GetXaxis()->SetRange(1,ibin-1);
1232 hChi2_Sigma->GetXaxis()->SetNdivisions(1,kFALSE);
1233 //hChi2_Sigma->LabelsOption("u");
1234 hChi2_Sigma->SetLabelSize(0.04);
1235 hChi2_Sigma->SetLineWidth(2);
1236 hChi2_Sigma->Draw("e");
1238 cChi2->Print(OutFileNamePDF.Data());
1242 cout<<"=================================================="<<endl;
1243 cout<<" Display track Lpt/Hpt "<<endl;
1244 cout<<"=================================================="<<endl;
1246 if ( hTriggerCutVsRun[0] && hTriggerCutVsRun[1] ) {
1247 TCanvas* cLptHpt = new TCanvas("cLptHpt","cLptHpt",1200,900);
1248 cLptHpt->Divide(1,2);
1249 TLegend* legLptHpt = new TLegend(0.72,0.7,0.9,0.85);
1250 legLptHpt->SetBorderSize(1);
1251 for ( Int_t ihisto=0; ihisto<2; ++ihisto) {
1252 cLptHpt->cd(ihisto+1);
1253 TH1* currHistos[2] = {hTriggerCutVsRun[ihisto], hTriggerCutWidthVsRun[ihisto]};
1254 for ( Int_t jhisto=0; jhisto<2; jhisto++ ) {
1255 currHistos[jhisto]->GetXaxis()->SetRange(1,ibin-1);
1256 currHistos[jhisto]->GetYaxis()->SetRangeUser(0.,5.);
1257 currHistos[jhisto]->LabelsOption("a");
1258 currHistos[jhisto]->SetStats(kFALSE);
1259 currHistos[jhisto]->GetXaxis()->SetLabelSize(0.04);
1260 currHistos[jhisto]->SetLineWidth(2);
1262 hTriggerCutWidthVsRun[ihisto]->SetLineColor(2);
1263 hTriggerCutWidthVsRun[ihisto]->SetMarkerColor(2);
1264 hTriggerCutWidthVsRun[ihisto]->SetFillColor(2);
1265 hTriggerCutWidthVsRun[ihisto]->SetFillStyle(3001);
1266 hTriggerCutWidthVsRun[ihisto]->Draw("e2");
1267 hTriggerCutVsRun[ihisto]->Draw("esame");
1268 if ( ihisto == 0 ) {
1269 legLptHpt->AddEntry(hTriggerCutWidthVsRun[ihisto],"Fit width","f");
1270 legLptHpt->AddEntry(hTriggerCutVsRun[ihisto],"pt cut from fit (stat error)","lp");
1271 legLptHpt->Draw("same");
1274 cLptHpt->Print(OutFileNamePDF.Data());
1280 cout<<"=================================================="<<endl;
1281 cout<<" Display muon trigger "<<endl;
1282 cout<<"=================================================="<<endl;
1284 TCanvas* cMuonTriggerUnlikeLike = new TCanvas("cMuonTriggerUnlikeLike","cMuonTriggerUnlikeLike",1200,900);
1285 TCanvas* cMuonTriggerHpt = new TCanvas("cMuonTriggerHpt","cMuonTriggerHpt",1200,900);
1286 cMuonTriggerHpt->Divide(1,2);
1288 Int_t const ntrig = 3;
1289 Int_t const nhist = 3;
1290 TH1F *hRelMuonTrigger[ntrig], *hTot;
1292 //3 configurations (3x3 histos for 3 canvases)
1293 Int_t conf[ntrig][nhist]={{0,1,3},{0,2,4},{1,2,5}};
1294 TString sconf[ntrig][nhist]={{"hTriggerUnlikeOnly","hTriggerLikeOnly","hTriggerUnlikeAndLike"},{"hTriggerUnlikeOnly","hTriggerHptOnly","hTriggerUnlikeAndHpt"},{"hTriggerLikeOnly","hTriggerHptOnly","hTriggerLikeAndHpt"}};
1297 for ( Int_t i=0; i < ntrig; i++ ) {
1298 for ( Int_t j=0; j < nhist; j++ ) {
1299 sname = sconf[i][j]; sname +=(i+1);
1300 hMuonTrigger[conf[i][j]]->GetXaxis()->SetRange(1,ibin-1);
1301 hRelMuonTrigger[j] = (TH1F*)hMuonTrigger[conf[i][j]]->Clone(sname);
1302 hRelMuonTrigger[j]->SetLineColor(j+1);
1303 hRelMuonTrigger[j]->SetStats(kFALSE);
1304 hRelMuonTrigger[j]->GetXaxis()->SetNdivisions(1,kFALSE);
1305 hRelMuonTrigger[j]->LabelsOption("a");
1306 hRelMuonTrigger[j]->SetLabelSize(0.02);
1307 //hRelMuonTrigger[j]->GetXaxis()->SetLabelSize(0.04);
1308 hRelMuonTrigger[j]->SetLineWidth(2);
1309 hRelMuonTrigger[j]->SetTitle("");
1314 hTot = (TH1F*) hRelMuonTrigger[0]->Clone(sname);
1315 hTot->Add(hRelMuonTrigger[1]);
1316 hTot->Add(hRelMuonTrigger[2],-1);
1317 hRelMuonTrigger[0]->Add(hRelMuonTrigger[2],-1);
1318 hRelMuonTrigger[1]->Add(hRelMuonTrigger[2],-1);
1320 for(Int_t j=0; j < nhist; j++) hRelMuonTrigger[j]->Divide(hTot);
1322 if(i==0) cMuonTriggerUnlikeLike->cd();
1323 else cMuonTriggerHpt->cd(i);
1325 if (i==0) hRelMuonTrigger[i]->SetTitle("Relative muon triggers content");
1326 TLegend *leg = new TLegend(0.72,0.7,0.9,0.85);
1327 leg->SetBorderSize(1);
1329 for(Int_t j=0; j<nhist; j++){
1331 hRelMuonTrigger[j]->SetMaximum(1);
1332 hRelMuonTrigger[j]->SetMinimum(0);
1333 hRelMuonTrigger[j]->Draw("e");
1335 else hRelMuonTrigger[j]->Draw("esame");
1336 sname = sconf[i][j];
1337 leg->AddEntry(hRelMuonTrigger[j],sname,"l");
1341 cMuonTriggerUnlikeLike->Print(OutFileNamePDF.Data());
1343 cMuonTriggerUnlikeLike->Write();
1344 cMuonTriggerHpt->Print(OutFileNamePDF.Data());
1345 cMuonTriggerHpt->Write();
1347 // close the PDF file
1348 c1->Print(OutFileNamePDF_close.Data());
1350 //Note: closing the file delete all related TDirectoryFile (dirCent and dirTrigger)
1351 rootFileOut->Close();
1362 void SetCanvas(TCanvas *canvas, Int_t logy){
1365 canvas->SetTopMargin(0.05);
1366 canvas->SetRightMargin(0.01);
1367 canvas->SetGridy(1);
1368 canvas->SetLogy(logy);
1373 Bool_t IsHeavyIonCollision(AliCounterCollection *eventCounters){
1375 if(!eventCounters) return kFALSE;
1377 Double_t sum = eventCounters->GetSum("v0mult:low,int,high");
1378 Bool_t result = kTRUE;
1379 if(sum<=0) result = kFALSE;
1381 cout<<" Collision type is set to ";
1382 if( result == kFALSE) cout<<"p-p"<<endl;
1383 else cout<<"heavy-ion"<<endl;
1388 TCanvas *ProcessCanvasAllTrigger( AliCounterCollection *eventCounters, TString canvasName) {
1390 if ( !eventCounters ) return 0;
1392 TString cName = Form("c%s",canvasName.Data());
1393 TCanvas *cAll = new TCanvas(canvasName.Data(),canvasName.Data());
1394 cAll->SetLeftMargin(0.18);
1395 cAll->SetRightMargin(0.18);
1399 TH2* hAll = (TH2*) ProcessHisto2D(eventCounters, "trigger", "run", "run:any" , "");
1400 for ( Int_t ibin=1; ibin <= hAll->GetYaxis()->GetNbins(); ++ibin ) {
1401 TString currLabel = hAll->GetYaxis()->GetBinLabel(ibin);
1402 TObjArray* labelArray = currLabel.Tokenize("-");
1403 labelArray->SetOwner();
1404 //cout<<currLabel<<endl;
1405 TString newLabel = labelArray->At(0)->GetName();
1406 if ( labelArray->GetEntries() >= 2 ) newLabel = Form("%s-%s", newLabel.Data(), labelArray->At(1)->GetName());
1407 hAll->GetYaxis()->SetBinLabel(ibin, newLabel.Data());
1415 TCanvas *ProcessCanvasTriggerContent(TObjArray *array, TObjArray trigNoPS, TObjArray trigWithPS, TString canvasName){
1417 if(!array) return 0x0;
1419 TString cName = "c";
1420 cName += canvasName;
1421 TCanvas *cTriggerContent = new TCanvas(canvasName,cName,1200,900);
1422 SetCanvas(cTriggerContent);
1423 cTriggerContent->cd();
1425 TLegend* legcTC = new TLegend(0.2,0.15,0.50,0.40);
1426 legcTC->SetHeader("Physics Selection");
1427 legcTC->AddEntry(".","applied :","");
1429 for(Int_t iTrig = 0; iTrig < array->GetEntriesFast(); iTrig++){
1430 //skip the sum of all triggers
1431 if( iTrig == (array->GetEntriesFast()-1) ) continue;
1432 TH1* hNoPS = static_cast<TH1*>(trigNoPS.At(iTrig));
1433 TH1* hWithPS = static_cast<TH1*>(trigWithPS.At(iTrig));
1434 if (!hNoPS ||!hWithPS) continue;
1435 hNoPS->SetLineStyle(2);
1437 hNoPS->SetMinimum(1e-3);
1439 hWithPS->Draw("same");
1442 hNoPS->Draw("same");
1443 hWithPS->Draw("same");
1445 legcTC->AddEntry(hWithPS,(( (TObjString*) array->At(iTrig) )->GetString()).Data(),"l");
1447 legcTC->AddEntry(".","not applied :","");
1449 for(Int_t iTrig = 0; iTrig < array->GetEntriesFast(); iTrig++){
1450 if( iTrig == (array->GetEntriesFast()-1) ) continue;
1451 TH1* hNoPS = static_cast<TH1*>(trigNoPS.At(iTrig));
1452 if(hNoPS) legcTC->AddEntry(hNoPS,(( (TObjString*) array->At(iTrig) )->GetString()).Data(),"l");
1455 legcTC->Draw("same");
1457 return cTriggerContent;
1460 TCanvas *ProcessCanvasRelativeTriggerContent(TObjArray *triggersB, TObjArray trigNoPS, TString canvasName){
1462 if(!triggersB) return 0x0;
1464 TString cName = "c" ;
1465 cName += canvasName;
1466 TCanvas *cRelativeTriggerContent = new TCanvas(canvasName,cName,1200,900);
1467 SetCanvas(cRelativeTriggerContent);
1468 cRelativeTriggerContent->cd();
1470 TObjArray relTrigNoPS(triggersB->GetEntriesFast());
1471 TLegend* legcRTC = new TLegend(0.2,0.15,0.50,0.40);
1473 TString hName, hTriggerName;
1474 Int_t indAllTrig = triggersB->GetEntriesFast()-1;
1475 TH1* hAllTrig = static_cast<TH1*> (trigNoPS.At(indAllTrig));
1476 if(!hAllTrig) return 0;
1478 for(Int_t iTrig = 0; iTrig < triggersB->GetEntriesFast()-1; iTrig++){
1480 hName += ( (TObjString*) triggersB->At(iTrig) )->GetString();
1481 TH1* histo = static_cast<TH1*> (trigNoPS.At(iTrig));
1482 if(!histo) continue;
1483 TH1* hRatio = (TH1*) histo->Clone(hName);
1484 hRatio->Divide(hAllTrig);
1485 hRatio->SetLineStyle(1);
1487 hRatio->SetMaximum(1.5);
1488 hRatio->SetMinimum(0.001);
1489 hRatio->SetLabelSize(0.04);
1490 hRatio->GetYaxis()->SetTitle("Relative trigger content");
1494 hRatio->Draw("ESAME");
1496 relTrigNoPS.AddAt(hRatio,iTrig);
1499 legcRTC->SetHeader("Physics Selection not applied");
1500 for(Int_t iTrig = 0; iTrig < triggersB->GetEntriesFast()-1; iTrig++){
1501 TH1* hRatio = static_cast<TH1*>(relTrigNoPS.At(iTrig));
1502 if (!hRatio) continue;
1503 legcRTC->AddEntry(hRatio,(( (TObjString*) triggersB->At(iTrig) )->GetString()).Data(),"l");
1505 legcRTC->Draw("same");
1507 return cRelativeTriggerContent;
1510 TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray trigNoPS, TObjArray trigWithPS, TString canvasName){
1512 if(!triggersB) return 0x0;
1514 TString cName = "c";
1515 cName += canvasName;
1516 TCanvas *c1 = new TCanvas(canvasName,cName,1200,900);
1520 TObjArray trigRatio(triggersB->GetEntriesFast());
1521 TLegend* legcRTC = new TLegend(0.2,0.15,0.50,0.40);
1522 TString header = "Physics Selection Cut on selected triggers:";
1523 if (canvasName.Contains("T0Flag")) header += " and T0 pile-up event selection";
1524 if (canvasName.Contains("T0SPDFlag")) header += " and T0, SPD pile-up event selection";
1525 legcRTC->SetHeader(header.Data());
1528 for(Int_t iTrig = 0; iTrig < triggersB->GetEntriesFast()-1; iTrig++){
1531 hName += ( (TObjString*) triggersB->At(iTrig) )->GetString();
1532 TH1 * hWithPS = (TH1*) (static_cast<TH1*> (trigWithPS.At(iTrig)));
1533 TH1 * hNoPS = (TH1*) (static_cast<TH1*> (trigNoPS.At(iTrig)));
1534 if (!hNoPS || !hWithPS) continue;
1535 TH1 *hRatio = (TH1*) hWithPS->Clone(hName);
1536 hRatio->Divide(hNoPS);
1537 hName = "ratioNoPS";
1538 hName += ( (TObjString*) triggersB->At(iTrig) )->GetString();
1541 hRatio->SetMaximum(1.5);
1542 hRatio->SetMinimum(0.05);
1543 hRatio->SetLabelSize(0.02);
1544 hRatio->GetYaxis()->SetTitle("Accepted / All from Phys. Sel.");
1545 hRatio->SetTitle("Physics Selection Cut");
1549 hRatio->Draw("ESAME");
1551 trigRatio.AddAt(hRatio,iTrig);
1554 for(Int_t iTrig = 0; iTrig < triggersB->GetEntriesFast()-1; iTrig++){
1555 TH1 * histo = static_cast<TH1*> (trigRatio.At(iTrig));
1556 if (!histo) continue;
1557 legcRTC->AddEntry(histo,(( (TObjString*) triggersB->At(iTrig) )->GetString()).Data(),"l");
1559 legcRTC->Draw("same");
1564 TCanvas *ProcessCanvasPhysSelCutCentrality(TObjArray *triggersB, TObjArray trigNoPS, TObjArray trigWithPS, Int_t trigNr, TString canvasName, TString *legendHeader){
1566 if(!triggersB || !legendHeader) return 0x0;
1568 TString cName = "c";
1569 cName += canvasName;
1570 TCanvas *c1 = new TCanvas(canvasName,cName,1200,900);
1574 Int_t const centBinMaxi = kCentBinMax - 1;
1575 TObjArray trigWithPSRatio(centBinMaxi);
1576 TLegend* legcRTC = new TLegend(0.2,0.15,0.50,0.40);
1577 legcRTC->SetHeader("V0 amplitude bins:");
1578 Int_t colorTab[3] = {kBlack,kRed,kBlue};
1579 TArrayI colorInd(centBinMaxi);
1580 for (Int_t i = 0; i < centBinMaxi; i++ ) {
1581 if(i<3) colorInd.AddAt(colorTab[i],i);
1582 else colorInd.AddAt(colorTab[2]+i-2,i);
1587 Float_t yMin = 0.05, yMax = 2;
1589 for(Int_t iCentBin = 0; iCentBin < centBinMaxi; iCentBin++){
1591 Int_t index = GetIndex(triggersB,trigNr,iCentBin);
1592 TH1 *hWithPS = static_cast<TH1*> (trigWithPS.At(index));
1593 TH1 *hNoPS = static_cast<TH1*> (trigNoPS.At(index));
1594 if (!hNoPS || !hWithPS) continue;
1597 hName += ( (TObjString*) triggersB->At(trigNr) )->GetString();
1598 TH1 *hRatio = (TH1*) hWithPS->Clone(hName);
1599 hRatio->Divide(hNoPS);
1600 hRatio->SetLineColor(colorInd.At(iCentBin));
1601 if ( iCentBin == 0 ) {
1602 hRatio->SetMaximum(yMax);
1603 hRatio->SetMinimum(yMin);
1604 hRatio->SetLabelSize(0.02);
1605 hRatio->GetYaxis()->SetTitle("Accepted / All from Phys. Sel.");
1606 TString sTitle = "for ", sTitle2 = (( (TObjString*) triggersB->At(trigNr) )->GetString()).Data();
1607 if ( !sTitle2.IsNull() ) sTitle += sTitle2;
1609 hRatio->SetTitle(Form("Phys. Sel. %s - Multiplicity from V0 amplitude",sTitle.Data()));
1613 hRatio->Draw("ESAME");
1615 trigWithPSRatio.AddAt(hRatio,iCentBin);
1618 for ( Int_t centBin = 0; centBin < centBinMaxi; centBin++ ){
1619 TH1 *hRatio = static_cast<TH1*> (trigWithPSRatio.At(centBin));
1620 if ( !hRatio ) continue;
1621 legcRTC->AddEntry(hRatio,(legendHeader[centBin]).Data(),"l");
1623 legcRTC->Draw("same");
1629 TCanvas *ProcessCanvasCentralityPercentile(TObjArray *triggersB, TObjArray trigNoPS, TObjArray trigWithPS, Int_t trigNr, TString canvasName, TString *legendHeader){
1631 if(!triggersB || !legendHeader) return 0x0;
1633 TString cName = "c";
1634 cName += canvasName;
1635 TCanvas *c1 = new TCanvas(canvasName,cName,1200,900);
1639 Int_t const centBinMaxi = 2;
1640 TObjArray trigRatio(centBinMaxi), trigRatioNoPS(centBinMaxi);
1641 TLegend* legcRTC = new TLegend(0.2,0.15,0.50,0.40);
1642 legcRTC->SetHeader("Physics Selection");
1644 Int_t colorTab[2] = {kRed,kBlue};
1645 TArrayI colorInd(centBinMaxi);
1646 for (Int_t i = 0; i < centBinMaxi; i++ ) {
1647 if(i<2) colorInd.AddAt(colorTab[i],i);
1648 else colorInd.AddAt(colorTab[1]+i-1,i);
1653 Float_t yMin = 0., yMax = 0.3;
1655 //process centrality bin 0-10% (centBin=3) and 60-80% (centBin=3) and compare it to 0-80% (centBin=1)
1656 Int_t centBinMin = 2;
1657 TH1 *hWithPSAll = static_cast<TH1*> (trigWithPS.At(1*triggersB->GetEntriesFast()+trigNr));
1658 TH1 *hNoPSAll = static_cast<TH1*> (trigNoPS.At(1*triggersB->GetEntriesFast()+trigNr));
1659 if (!hNoPSAll || !hWithPSAll) return 0;
1661 for ( Int_t centBin = centBinMin; centBin < centBinMaxi+centBinMin; centBin++){
1663 if ( centBin > kCentBinMax ) continue;
1665 Int_t index = GetIndex(triggersB,trigNr,centBin);
1666 TH1 *hWithPS = static_cast<TH1*> (trigWithPS.At(index));
1667 TH1 *hNoPS = static_cast<TH1*> (trigNoPS.At(index));
1668 if (!hNoPS || !hWithPS) continue;
1671 hName += ( (TObjString*) triggersB->At(trigNr) )->GetString();
1672 TH1 *hRatio = (TH1*) hWithPS->Clone(hName);
1673 hRatio->Divide(hWithPSAll);
1675 hRatio->SetLineColor(colorInd.At(centBin-centBinMin));
1676 hName = "ratioNoPS";
1677 hName += ( (TObjString*) triggersB->At(trigNr) )->GetString();
1678 TH1 *hRatioNoPS = (TH1*) (hNoPS->Clone(hName));
1679 hRatioNoPS->Divide(hNoPSAll);
1680 hRatioNoPS->Scale(0.8);
1681 hRatioNoPS->SetLineStyle(2);
1682 hRatioNoPS->SetLineColor(colorInd.At(centBin-centBinMin));
1684 if ( centBin == centBinMin ){
1685 hRatio->SetMaximum(yMax);
1686 hRatio->SetMinimum(yMin);
1687 hRatio->SetLabelSize(0.02);
1688 hRatio->GetYaxis()->SetTitle("Centrality percentile check");
1689 TString sTitle = "for ", sTitle2 = (( (TObjString*) triggersB->At(trigNr) )->GetString()).Data();
1690 if ( !sTitle2.IsNull() ) sTitle += sTitle2;
1692 hRatio->SetTitle(Form("Centrality percentile check %s - Multiplicity from V0 amplitude",sTitle.Data()));
1694 hRatioNoPS->Draw("EPSAME");
1697 hRatio->Draw("ESAME");
1698 hRatioNoPS->Draw("EPSAME");
1700 trigRatio.AddAt(hRatio,centBin-centBinMin);
1701 trigRatioNoPS.AddAt(hRatioNoPS,centBin-centBinMin);
1704 legcRTC->AddEntry(".","applied :","");
1705 for(Int_t centBin = centBinMin; centBin < centBinMaxi+centBinMin; centBin++){
1706 TH1 *hRatio = static_cast<TH1*> (trigRatio.At(centBin-centBinMin));
1707 if (!hRatio) continue;
1708 legcRTC->AddEntry(hRatio,(legendHeader[centBin]).Data(),"l");
1710 legcRTC->AddEntry(".","not applied :","");
1711 for(Int_t centBin = centBinMin; centBin < centBinMaxi+centBinMin; centBin++){
1712 TH1 *hRatioNoPS = static_cast<TH1*> (trigRatioNoPS.At(centBin-centBinMin));
1713 if (!hRatioNoPS) continue;
1714 legcRTC->AddEntry(hRatioNoPS,(legendHeader[centBin]).Data(),"l");
1716 legcRTC->Draw("same");
1722 TCanvas *ProcessCanvasTracksoverTrigger(TObjArray *triggersB, TObjArray trigSel, TObjArray trackTracker, TObjArray trackTrigger, TObjArray trackMatched, TObjArray trackAll, Int_t trigNr, Int_t centNr, TString canvasName,TString legendHeader){
1724 if(!triggersB || trigNr<0 || centNr<0 ) return 0x0;
1726 Int_t index = GetIndex(triggersB,trigNr,centNr);
1728 TH1 *hTrackerPerB, *hTriggerPerB, *hMatchedPerB, *hAllTracksPerB, *hTrigSel, *histo;
1730 TString hName, hNameBase;
1731 hNameBase =( (TObjString*) triggersB->At(trigNr) )->GetString();
1733 hTrigSel = static_cast<TH1*> (trigSel.At(index));
1734 if (!hTrigSel) return 0;
1736 hName = Form("hTrackerPer%s",hNameBase.Data());
1737 histo = static_cast<TH1*> (trackTracker.At(index));
1738 if (!histo) return 0;
1739 hTrackerPerB = (TH1*) histo->Clone(hName);
1740 if ( hTrackerPerB->GetEntries() ) hTrackerPerB->Divide(hTrigSel);
1741 hTrackerPerB->SetLineColor(kRed);
1743 hName = Form("hTriggerPer%s",hNameBase.Data());
1744 histo = static_cast<TH1*> (trackTrigger.At(index));
1745 if (!histo) return 0;
1746 hTriggerPerB = (TH1*) histo->Clone(hName);
1747 if ( hTriggerPerB->GetEntries() > 0 ) hTriggerPerB->Divide(hTrigSel);
1748 hTriggerPerB->SetLineColor(kBlue);
1750 hName = Form("hMatchedPer%s",hNameBase.Data());
1751 histo = static_cast<TH1*> (trackMatched.At(index));
1752 if (!histo) return 0;
1753 hMatchedPerB = (TH1*) histo->Clone(hName);
1754 if ( hMatchedPerB->GetEntries() > 0 ) hMatchedPerB->Divide(hTrigSel);
1755 hMatchedPerB->SetLineColor(kViolet);
1757 hName = Form("hAllTracksPer%s",hNameBase.Data());
1758 histo = static_cast<TH1*> (trackAll.At(index));
1759 if (!histo) return 0;
1760 hAllTracksPerB = (TH1*) histo->Clone(hName);
1761 if ( hAllTracksPerB->GetEntries() > 0 ) hAllTracksPerB->Divide(hTrigSel);
1762 hAllTracksPerB->SetLineWidth(3);
1763 hAllTracksPerB->SetLineColor(kBlack);
1764 hAllTracksPerB->SetTitle(Form("Number of Tracks /%s %s",hNameBase.Data(),legendHeader.Data()));
1765 hAllTracksPerB->SetMinimum(0.0001);
1766 hAllTracksPerB->SetLabelSize(0.02);
1768 TString cName = "c";
1769 cName += canvasName;
1770 hNameBase = ( (TObjString*) triggersB->At(trigNr) )->GetString();
1772 TCanvas *cRatioTrackTypesB = new TCanvas(canvasName,cName,1200,900);
1773 SetCanvas(cRatioTrackTypesB,0);
1774 cRatioTrackTypesB->cd();
1776 TLegend* legcTTCINT1B;
1778 hAllTracksPerB->Draw("E");
1779 hTrackerPerB->Draw("Esame");
1780 hMatchedPerB->Draw("Esame");
1781 hTriggerPerB->Draw("Esame");
1783 legcTTCINT1B = new TLegend(0.70,0.5,0.90,0.70);
1784 legcTTCINT1B->AddEntry(hAllTracksPerB,"All tracks","l");
1785 legcTTCINT1B->AddEntry(hTrackerPerB,"Tracking (only) tracks","l");
1786 legcTTCINT1B->AddEntry(hMatchedPerB,"Matched tracks","l");
1787 legcTTCINT1B->AddEntry(hTriggerPerB,"Trigger (only) tracks","l");
1788 legcTTCINT1B->Draw("same");
1790 return cRatioTrackTypesB;
1794 TCanvas *ProcessCanvasTrackMultB(TObjArray *triggersB, TObjArray trigSel, TObjArray trackTracker, TObjArray trackTrigger, TObjArray trackMatched, Int_t trigNr, Int_t centNr, TString canvasName,TString legendHeader){
1796 if( !triggersB || centNr < 0 || trigNr < 0 ) return 0x0;
1798 Int_t index = GetIndex(triggersB,trigNr,centNr);
1799 TString hNameBase = ( (TObjString*) triggersB->At(trigNr) )->GetString();
1801 TString cName = Form("c%s%s",canvasName.Data(),hNameBase.Data());
1802 TCanvas *cTrackMultB = new TCanvas(canvasName,cName,1200,900);
1803 SetCanvas(cTrackMultB,0);
1804 cTrackMultB->Divide(1,2);
1807 TH1* hSumTriggerOverB, *hSumTrackerOverB, *hTrigSel, *hTracker, *hTrigger, *hMatched;
1810 hTrigSel = static_cast<TH1*> (trigSel.At(index));
1811 if (!hTrigSel) return 0;
1812 hTracker = static_cast<TH1*> (trackTracker.At(index));
1813 if (!hTracker) return 0;
1814 hTrigger = static_cast<TH1*> (trackTrigger.At(index));
1815 if (!hTrigger) return 0;
1816 hMatched = static_cast<TH1*> (trackMatched.At(index));
1817 if (!hMatched) return 0;
1819 hName = Form("hSumTriggerOver%s",hNameBase.Data());
1820 hSumTriggerOverB = (TH1*) hTrigger->Clone(hName);
1821 hSumTriggerOverB->Add(hMatched);
1822 hSumTriggerOverB->Divide(hTrigSel);
1823 hName = Form("Sum of trigger tracks (matched + trigger-only) / # events in %s %s",hNameBase.Data(),legendHeader.Data());
1824 hSumTriggerOverB->SetTitle(hName);
1825 hSumTriggerOverB->SetLabelSize(0.04);
1826 hSumTriggerOverB->SetLineColor(kBlue);
1828 hName = Form("hSumTrackerOver%s",hNameBase.Data());
1829 hSumTrackerOverB = (TH1*) hTracker->Clone(hName);
1830 hSumTrackerOverB->Add(hMatched);
1831 hSumTrackerOverB->Divide(hTrigSel);
1832 hName = Form("Sum of tracker tracks (matched + tracker-only) / # events in %s %s",hNameBase.Data(),legendHeader.Data());
1833 hSumTrackerOverB->SetTitle(hName);
1834 //hSumTrackerOverCINT1B->LabelsOption("u");
1835 hSumTrackerOverB->SetLabelSize(0.04);
1836 hSumTrackerOverB->SetLineColor(kBlue);
1838 hSumTriggerOverB->Draw("e");
1840 hSumTrackerOverB->Draw("e");
1846 TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TObjArray trigSel, TObjArray trackTracker, TObjArray trackTrigger, TObjArray trackMatched, Int_t trigNr, Int_t centNr, TString canvasName,TString legendHeader) {
1848 if(!triggersB || trigNr < 0 || centNr < 0 ) return 0x0;
1850 Int_t index = GetIndex(triggersB,trigNr,centNr);
1851 TString hNameBase =( (TObjString*) triggersB->At(trigNr) )->GetString();
1853 TString cName = Form("c%s%s",canvasName.Data(),hNameBase.Data());
1854 TCanvas *cRatioTrackB = new TCanvas(canvasName,cName,1200,900);
1855 SetCanvas(cRatioTrackB,0);
1857 TH1* hTrackerOverTriggerB, *hMatchedOverTriggerB, *hMatchedOverTrackerB, *hTrigSel, *hTracker, *hTrigger, *hMatched;
1858 hTrigSel = static_cast<TH1*> (trigSel.At(index));
1859 if (!hTrigSel) return 0;
1860 hTracker = static_cast<TH1*> (trackTracker.At(index));
1861 if (!hTracker) return 0;
1862 hTrigger = static_cast<TH1*> (trackTrigger.At(index));
1863 if (!hTrigger) return 0;
1864 hMatched = static_cast<TH1*> (trackMatched.At(index));
1865 if (!hMatched) return 0;
1867 TString hName = Form("hTrackerOverTrigger%s",hNameBase.Data());
1868 hTrackerOverTriggerB = (TH1*) hTracker->Clone(hName);
1869 hTrackerOverTriggerB->Divide(hTrigger);
1870 hName = Form("# tracker tracks / # trigger tracks in %s %s",hNameBase.Data(),legendHeader.Data());
1871 hTrackerOverTriggerB->SetTitle(hName);
1872 //hTrackerOverTriggerCINT1B->LabelsOption("u");
1873 hTrackerOverTriggerB->SetLabelSize(0.02);
1874 hTrackerOverTriggerB->SetLineColor(kBlue);
1876 hName = Form("hMatchedOverTrigger%s",hNameBase.Data());
1877 hMatchedOverTriggerB = (TH1*) hMatched->Clone(hName);
1878 hMatchedOverTriggerB->Divide(hTrigger);
1879 hName = Form("# matched tracks / # trigger tracks in %s %s",hNameBase.Data(),legendHeader.Data());
1880 hMatchedOverTriggerB->SetTitle(hName);
1881 //hMatchedOverTriggerCINT1B->LabelsOption("u");
1882 hMatchedOverTriggerB->SetLabelSize(0.02);
1883 hMatchedOverTriggerB->SetLineColor(kBlue);
1885 hName = Form("hMatchedOverTracker%s",hNameBase.Data());
1886 hMatchedOverTrackerB = (TH1*) hMatched->Clone(hName);
1887 hMatchedOverTrackerB->Divide(hTracker);
1888 hName = Form("# matched tracks / # tracker tracks in %s %s",hNameBase.Data(),legendHeader.Data());
1889 hMatchedOverTrackerB->SetTitle(hName);
1890 //hMatchedOverTrackerCINT1B->LabelsOption("u");
1891 hMatchedOverTrackerB->SetLabelSize(0.02);
1892 hMatchedOverTrackerB->SetLineColor(kBlue);
1894 cRatioTrackB->Divide(1,3);
1895 cRatioTrackB->cd(1);
1896 hTrackerOverTriggerB->Draw("e");
1897 cRatioTrackB->cd(2);
1898 hMatchedOverTriggerB->Draw("e");
1899 cRatioTrackB->cd(3);
1900 hMatchedOverTrackerB->Draw("e");
1902 return cRatioTrackB;
1905 TCanvas *ProcessCanvasAsymMatched(TObjArray *triggersB, TObjArray trackPosMatched, TObjArray trackNegMatched, TObjArray trackAllMatched, Int_t trigNr, Int_t centNr, TString canvasName,TString legendHeader) {
1907 if(!triggersB || trigNr < 0 || centNr < 0 ) return 0x0;
1909 Int_t index = GetIndex(triggersB,trigNr,centNr);
1910 TString hName, hNameBase = (( (TObjString*) triggersB->At(trigNr) )->GetString());
1912 TString cName = Form("c%s%s",canvasName.Data(),hNameBase.Data());
1913 TCanvas *cAsymMatched = new TCanvas(canvasName.Data(),cName,1200,900);
1914 SetCanvas(cAsymMatched,0);
1917 TH1* hPosMatched, *hNegMatched, *hAllMatched;
1919 hPosMatched = static_cast<TH1*> (trackPosMatched.At(index));
1920 if (!hPosMatched) return 0;
1921 hNegMatched = static_cast<TH1*> (trackNegMatched.At(index));
1922 if (!hNegMatched) return 0;
1923 hAllMatched = static_cast<TH1*> (trackAllMatched.At(index));
1924 if (!hAllMatched) return 0;
1926 hName = Form("hAsyMatchedFor%s",hNameBase.Data());
1927 TH1 *hAsymMatched = (TH1*) hPosMatched->Clone(hName);
1928 hAsymMatched->Add(hNegMatched,-1);
1929 hAsymMatched->Divide(hAllMatched);
1930 hAsymMatched->SetLineColor(kRed);
1931 hAsymMatched->SetMinimum(-0.3);
1932 hAsymMatched->SetMaximum(0.3);
1933 hAsymMatched->SetLabelSize(0.02);
1934 hName = Form("Matched tracks charge asymmetry for %s with acc. cuts %s",hNameBase.Data(),legendHeader.Data());
1935 hAsymMatched->SetTitle(hName);
1936 hAsymMatched->GetYaxis()->SetTitle("Charged tracks asymmetry");
1937 hAsymMatched->Draw("EH");
1939 return cAsymMatched;
1943 TCanvas *ProcessCanvasHighPtMuons(TObjArray *triggersB, TObjArray trigSel, TObjArray trackMatchedLowPt, TObjArray trackAllMatchedHighPt, Int_t trigNr, Int_t centNr, TString canvasName,TString legendHeader) {
1945 if ( !triggersB || trigNr < 0 || centNr < 0 ) return 0x0;
1947 Int_t index = GetIndex(triggersB,trigNr,centNr);
1948 TString hName, hNameBase = (( (TObjString*) triggersB->At(trigNr) )->GetString());
1950 TString cName = Form("c%s%s",canvasName.Data(),hNameBase.Data());
1951 TCanvas *cHighPtMuons = new TCanvas(canvasName.Data(),cName,1200,900);
1952 SetCanvas(cHighPtMuons,0);
1956 TH1* hRelMatchedLowPt, *hRelMatchedHighPt, *hTrigSel, *hMatchedLowPt, *hAllMatchedHighPt;
1957 hTrigSel = static_cast<TH1*> (trigSel.At(index));
1958 if (!hTrigSel) return 0;
1959 hMatchedLowPt = static_cast<TH1*> (trackMatchedLowPt.At(index));
1960 if (!hMatchedLowPt) return 0;
1961 hAllMatchedHighPt = static_cast<TH1*> (trackAllMatchedHighPt.At(index));
1962 if (!hAllMatchedHighPt) return 0;
1964 hName = Form("hMatchedLowPtPer%s ",hNameBase.Data());
1965 hRelMatchedLowPt = (TH1*) hMatchedLowPt->Clone(hName);
1966 hRelMatchedLowPt->Divide(hTrigSel);
1967 hRelMatchedLowPt->SetLineColor(kBlue);
1968 hRelMatchedLowPt->SetTitle("");
1969 hName = Form("Ratio per %s ",hNameBase.Data());
1970 hRelMatchedLowPt->GetYaxis()->SetTitle(hName);
1971 hRelMatchedLowPt->SetMinimum(0.0001);
1972 hRelMatchedLowPt->SetLabelSize(0.02);
1974 hName = Form("hMatchedHighPtPer%s ",hNameBase.Data());
1975 hRelMatchedHighPt = (TH1*) hAllMatchedHighPt->Clone(hName);
1976 hRelMatchedHighPt->Divide(hTrigSel);
1977 hRelMatchedHighPt->SetLineColor(kRed);
1979 hName = Form("Number of matched track per %s (include Vtx and R_{Abs} cuts) %s",hNameBase.Data(),legendHeader.Data());
1980 hRelMatchedLowPt->SetTitle(hName);
1981 hRelMatchedLowPt->Draw("E");
1982 hRelMatchedHighPt->Draw("Esame");
1984 legcHPM = new TLegend(0.60,0.45,0.98,0.65);
1985 //legcHPM->SetHeader(hName);
1986 legcHPM->AddEntry(".","Physics selection applied :","");
1987 legcHPM->AddEntry(hRelMatchedLowPt," p_{T} > 1 GeV/c ","l");
1988 legcHPM->AddEntry(hRelMatchedHighPt," p_{T} > 2 GeV/c ","l");
1989 legcHPM->Draw("same");
1991 return cHighPtMuons;
1994 TCanvas *ProcessCanvasBeamGasMatched ( TObjArray *triggersB, TObjArray trackBeamGasMatched, TObjArray trackBeamGasMatchedHighPt, TObjArray trackAllMatched, TObjArray trackMatchedHighPt, Int_t trigNr, Int_t centNr, TString canvasName,TString legendHeader) {
1996 if(!triggersB || trigNr < 0 || centNr < 0 ) return 0x0;
1998 Int_t index = GetIndex(triggersB,trigNr,centNr);
1999 TString hName, hNameBase = (( (TObjString*) triggersB->At(trigNr) )->GetString());
2001 TString cName = Form("c%s%s",canvasName.Data(),hNameBase.Data());
2002 TCanvas *cBeamGasMatched = new TCanvas(canvasName.Data(),cName,1200,900);
2003 SetCanvas(cBeamGasMatched,0);
2004 cBeamGasMatched->cd();
2006 TH1* hBeamGasMatched, *hBeamGasMatchedHighPt, *hAllMatched, *hMatchedHighPt;
2008 hBeamGasMatched = static_cast<TH1*> (trackBeamGasMatched.At(index));
2009 if (!hBeamGasMatched) return 0;
2010 hBeamGasMatchedHighPt = static_cast<TH1*> (trackBeamGasMatchedHighPt.At(index));
2011 if (!hBeamGasMatchedHighPt) return 0;
2012 hAllMatched = static_cast<TH1*> (trackAllMatched.At(index));
2013 if (!hAllMatched) return 0;
2014 hMatchedHighPt = static_cast<TH1*> (trackMatchedHighPt.At(index));
2015 if (!hMatchedHighPt) return 0;
2017 hName = Form("hBeamGasMatchedPer%s ",hNameBase.Data());
2018 TH1 *hRelBeamGasMatched = (TH1*) hBeamGasMatched->Clone(hName);
2019 hRelBeamGasMatched->Divide(hAllMatched);
2020 hRelBeamGasMatched->SetLineColor(kBlack);
2021 hRelBeamGasMatched->SetMinimum(0.0);
2022 hRelBeamGasMatched->SetMaximum(1.1);
2023 hRelBeamGasMatched->SetLabelSize(0.02);
2025 hName = Form("hBeamGasMatchedHightPtPer%s ",hNameBase.Data());
2026 TH1 *hRelBeamGasMatchedHighPt = (TH1*) hBeamGasMatchedHighPt->Clone(hName);
2027 hRelBeamGasMatchedHighPt->Divide(hMatchedHighPt);
2028 hRelBeamGasMatchedHighPt->SetLineColor(kRed);
2030 hName = Form("Identified beam-gas tracks (pxDCA cuts) in matched tracks for %s",hNameBase.Data());
2031 if(!legendHeader.IsNull()) hName += Form(" %s",legendHeader.Data());
2032 hRelBeamGasMatched->SetTitle(hName);
2033 hRelBeamGasMatched->GetYaxis()->SetTitle("Relative beam-gas tracks");
2034 hRelBeamGasMatched->Draw("EH");
2035 hRelBeamGasMatchedHighPt->Draw("EHsame");
2037 TLegend *leg = new TLegend(0.60,0.45,0.98,0.65);
2038 leg->AddEntry(".","Physics selection applied :","");
2039 leg->AddEntry(hRelBeamGasMatched," All p_{T}","l");
2040 leg->AddEntry(hRelBeamGasMatchedHighPt," p_{T} > 2 GeV/c ","l");
2043 return cBeamGasMatched;
2046 Int_t GetIndex( TObjArray *triggers, Int_t trigNr, Int_t centNr ) {
2048 return ( centNr * triggers->GetEntriesFast() + trigNr );
2051 TH1* ProcessHisto( AliCounterCollection* counter, TString hVariable, TString hSelection, TString hName, TString xName, TString yName, Int_t color){
2055 if( !counter ) return h1;
2057 //cout<<"ProcessHisto selection "<<hSelection<<endl;
2059 if ( !hSelection.Contains("trigger: /") && !hSelection.Contains("trigger:/") ) h1 = (TH1*) counter->Draw(hVariable,hSelection);
2060 //cout<<"ProcessHisto selection2 "<<h1<<endl;
2061 if ( !h1 ) h1 = new TH1D(hName,"",10,0,10);
2063 if ( h1->GetSumw2N() == 0 ) h1->Sumw2();
2064 h1->LabelsOption("a");
2065 if(hName.Sizeof()>1) h1->SetName(hName);
2066 if(xName.Sizeof()>1) h1->GetXaxis()->SetTitle(xName);
2067 if(yName.Sizeof()>1) h1->GetYaxis()->SetTitle(yName);
2068 if(color>0) h1->SetLineColor(color);
2069 h1->SetLineWidth(2);
2076 TH2* ProcessHisto2D( AliCounterCollection* counter, TString hVariable, TString hVariable2, TString hSelection, TString hName){
2080 if( !counter ) return h1;
2081 Bool_t setName = kTRUE;
2083 if(hName.Sizeof()==1) setName = kFALSE;
2085 h1 = (TH2*) counter->Draw(hVariable,hVariable2,hSelection);
2086 if ( !h1 ) h1 = new TH2D(hName,"",10,0,10,10,0,10);
2088 if ( h1->GetSumw2N() == 0 ) h1->Sumw2();
2089 h1->LabelsOption("a");
2090 if(setName) h1->SetName(hName);
2096 Bool_t GetTriggerLists(const char* triggerList, TString listFromContainer, TObjArray *triggersB, TObjArray *triggersShortName){
2098 //Get the trigger list from a file
2099 //The file should consist of a line for each trigger with the following layout:
2101 // or MUONUNLIKE triggernameB
2102 // or NOSHOW triggernameB
2103 //if filename is 0, then all the triggers stored are used
2104 if( !triggersB || !triggersShortName) return kFALSE;
2105 Int_t const nColumn = 2;
2106 TObjArray* triggers[nColumn] = {triggersShortName, triggersB};
2108 TString trigSuffix[nColumn] = {"","B"};
2109 TString currTrigName = "";
2110 TObjArray* fullTriggerList[nColumn];
2112 for ( Int_t ibeam=0; ibeam<nColumn; ++ibeam ) {
2113 fullTriggerList[ibeam] = new TObjArray();
2114 fullTriggerList[ibeam]->SetOwner();
2117 // Build trigger list (from file or use all trigger stored)
2118 if ( triggerList ) {
2119 // only the ones in the triggerList
2120 ifstream inFile(triggerList);
2121 if (!inFile.is_open()) {
2122 Error("PlotMuonQA","unable to open file %s", triggerList);
2126 while ( !inFile.eof() ) {
2127 Bool_t isGoodB = kTRUE;
2128 for ( Int_t ibeam=0; ibeam<nColumn; ++ibeam ) {
2129 currTrigName.ReadToken( inFile );
2130 if ( ! isGoodB ) continue;
2131 if ( currTrigName.IsNull() || ! currTrigName.IsAscii() ) {
2132 if ( ibeam==0 || ibeam == 1 ) {
2136 currTrigName = "notrigger";
2138 fullTriggerList[ibeam]->AddLast(new TObjString(currTrigName));
2144 TObjArray *triggersInContainer = listFromContainer.Tokenize(",");
2145 for ( Int_t iTrig = 0; iTrig < triggersInContainer->GetEntriesFast(); iTrig++ ) {
2146 currTrigName = triggersInContainer->At(iTrig)->GetName();
2147 Bool_t keep = kFALSE;
2148 if ( ( currTrigName.Contains("-B-") || currTrigName.Contains("-ABCE-") ) && ( ! ((TString) currTrigName(0)).CompareTo("C") ) && !currTrigName.Contains("WU") && !currTrigName.Contains("UP") && !currTrigName.Contains("SPI") && !currTrigName.Contains("PHI") && !currTrigName.Contains("EMC") && !currTrigName.Contains("ZED") && !currTrigName.Contains("TRUE") && !currTrigName.Contains("SHM") && !currTrigName.Contains("TPC") && !currTrigName.Contains("BEAM") && !currTrigName.Contains("1A") && !currTrigName.Contains("1C")) keep = kTRUE;//cyn: to be removed once the trigger filtering is carried out in the analysis task
2149 if (!keep) continue;
2150 for (Int_t ibeam = 0; ibeam < nColumn; ibeam++) {
2151 fullTriggerList[ibeam]->AddLast( new TObjString(currTrigName) );
2154 if ( triggersInContainer ) delete triggersInContainer;
2158 // Select only existing triggers in container
2160 TObjArray *triggersFromContainer = listFromContainer.Tokenize(",");
2161 TObjString* trigName = 0x0;
2163 TString selectAllTriggers[nColumn];
2164 for ( Int_t ibeam=0; ibeam<nColumn; ++ibeam ) selectAllTriggers[ibeam]= "";
2166 for ( Int_t itrig=0; itrig<fullTriggerList[0]->GetEntries(); ++itrig ) {
2167 Bool_t isBadTrig = kFALSE;
2168 for ( Int_t ibeam=0; ibeam<nColumn; ++ibeam ) {
2169 currTrigName = fullTriggerList[ibeam]->At(itrig)->GetName();
2170 //condition on trigger name from trigger list
2171 if ( ibeam == 0 && currTrigName.Contains("NOSHOW") ) {
2174 //select only the existing triggers in the container
2175 //note that the trigger in the trigger file can be a list of different trigger
2176 if ( ibeam > 0 && triggersFromContainer ) {
2177 TIter nextTrigger( triggersFromContainer );
2179 while ( ( trigName = static_cast<TObjString*>(nextTrigger()) ) ) {
2180 if ( currTrigName.Contains(trigName->GetString()) ){
2184 if ( isBadTrig == kTRUE ){
2186 if ( triggers[0]->GetLast() != (triggers[0]->LowerBound()-1) ) triggers[0]->RemoveAt(triggers[0]->GetLast());
2192 triggers[ibeam]->AddLast(new TObjString(currTrigName));
2193 if ( isBadTrig ) continue;
2194 if ( ! selectAllTriggers[ibeam].IsNull() ) selectAllTriggers[ibeam] += ",";
2195 selectAllTriggers[ibeam] += currTrigName;
2198 if(triggersFromContainer) delete triggersFromContainer;
2199 if(trigName) delete trigName;
2202 // Complete trigger list and print values
2203 cout<<" Nr of triggers read "<<triggers[0]->GetEntriesFast()<<endl;
2204 for ( Int_t ibeam=0; ibeam<nColumn; ++ibeam ) {
2205 triggers[ibeam]->AddLast(new TObjString(selectAllTriggers[ibeam]));
2206 printf(" %s triggers:\n", trigSuffix[ibeam].Data());
2207 triggers[ibeam]->Print();
2208 delete fullTriggerList[ibeam];
2214 Int_t GetRunNumber(TString filePath)
2216 /// Get run number from file path
2217 TObjArray* array = filePath.Tokenize("/");
2219 TString auxString = "";
2221 for ( Int_t ientry=0; ientry<array->GetEntries(); ientry++ ) {
2222 auxString = array->At(ientry)->GetName();
2223 if ( auxString.IsDigit() && auxString.Length()>=6 && auxString.Length()<=9 ) {
2224 runNum = auxString.Atoi();
2231 array = auxString.Tokenize("_");
2233 auxString = array->Last()->GetName();
2234 auxString.ReplaceAll(".root","");
2235 if ( auxString.IsDigit() ) runNum = auxString.Atoi();
2242 TString GetRunList(const char *runList, TObjArray *runs){
2244 // list of runs to be analyzed
2245 TString selectRuns = "run:";
2248 // only the ones in the runList
2249 ifstream inFile(runList);
2250 if (!inFile.is_open()) {
2251 Error("PlotMuonQA","unable to open file %s", runList);
2256 while (!inFile.eof()) {
2257 currLine.ReadLine(inFile);
2258 if ( currLine.IsNull() ) continue;
2259 Int_t currRun = GetRunNumber(currLine);
2261 Warning("PlotMuonQA","invalid run number: %s", currLine.Data());
2264 if(runs) runs->AddLast(new TObjString(Form("%d", currRun)));
2265 selectRuns += Form("%i,",currRun);
2267 selectRuns.Remove(TString::kTrailing, ',');
2272 cout<<"runList is not set"<<endl;
2273 if(runs) runs->AddLast(new TObjString("*"));
2276 printf("selected runs from runlist %s: %s\n",runList, selectRuns.Data());
2281 Bool_t MergeOutputs(const char* inputList,const char* outFilename)
2283 ifstream inFile(inputList);
2284 if ( ! inFile.is_open()) {
2285 printf("Error: cannot find inputList %s\n", inputList);
2288 TString currLine = "";
2289 TFileMerger fileMerger;
2290 Int_t mergeType = ( TFileMerger::kRegular | TFileMerger::kAll | TFileMerger::kOnlyListed );
2291 fileMerger.AddObjectNames("MUON_QA");
2292 while ( ! inFile.eof() ) {
2293 currLine.ReadLine(inFile);
2294 if ( ! currLine.EndsWith(".root") ) continue;
2295 fileMerger.AddFile(currLine.Data());
2298 if ( fileMerger.GetMergeList()->GetEntries() == 0 ) return kFALSE;
2299 fileMerger.OutputFile(outFilename,kTRUE,1); // needed when merging single files for specific directories
2300 fileMerger.PartialMerge(mergeType);