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