Trending QA plots for Muon Tracking both for p-p and PbPb
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Nov 2011 18:28:21 +0000 (18:28 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Nov 2011 18:28:21 +0000 (18:28 +0000)
 (Cynthia)

PWG3/muon/PlotMuonQA.C [moved from PWG3/muon/PlotMuonQApp.C with 62% similarity]
PWG3/muon/PlotMuonQAPbPb.C [deleted file]

similarity index 62%
rename from PWG3/muon/PlotMuonQApp.C
rename to PWG3/muon/PlotMuonQA.C
index 2767abe..11489d7 100644 (file)
@@ -16,6 +16,9 @@
 //
 // Author: Philippe Pillot - SUBATECH Nantes
 // Modified by Christophe Suire, Cynthia Hadjidakis - IPN Orsay
+// To be done:
+// - reorganize last part (reading and extracting info from run per run histos)
+// - warning and error messages
 //--------------------------------------------------------------------------
 
 #if !defined(__CINT__) || defined(__MAKECINT__)
 #endif
 
 TString GetRunList(const char *runList, TObjArray *runs, TObjArray *runs2);
-//Bool_t GetTriggerLists(const char *triggerList, TObjArray *triggersB=0, TObjArray *triggersAC=0, TObjArray *triggersE=0);
 Bool_t GetTriggerLists(const char *triggerList, TString listFromContainer, TObjArray *triggersB=0, TObjArray *triggersAC=0, TObjArray *triggersE=0);
 void SetCanvas(TCanvas *canvas, Int_t logy=1);
 
-TH1* ProcessHisto( AliCounterCollection* counter, TString variable, TString selection, TString hName="", TString xName="", TString yName="", Int_t color=1);
+TH1* ProcessHisto( AliCounterCollection* counter, TString variable, TString selection, TString hName="", TString xName="", TString yName="", Int_t color=1, Bool_t empty = kFALSE);
 TH2* ProcessHisto2D( AliCounterCollection* counter, TString hVariable, TString hVariable2, TString hSelection, TString hName);
 
 TCanvas *ProcessCanvasTriggerContent(TObjArray *array, TH1 **histo, TH1 **histo2, TString canvasName);
 TCanvas *ProcessCanvasRelativeTriggerContent(TObjArray *array, TH1 **histo, TString canvasName, Int_t *colorTab);
-TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE, TH1 **hBNoPS, TH1 **hACNoPS,TH1 **hENoPS, TH1 **hBWithPS, TString canvasName, Int_t *colorInd);
-TCanvas *ProcessCanvasTracksoverTrigger(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName);
-TCanvas *ProcessCanvasTrackMultB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName);
-TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName);
-TCanvas *ProcessCanvasAsymMatched(TObjArray *triggersB, TH1 **hPosMatchedB, TH1 **hNegMatchedB, TH1 **hAllMatchedB, Int_t indTrigger, TString canvasName);
-TCanvas *ProcessCanvasHighPtMuons(TObjArray *triggersB, TH1 **hB, TH1 **hMatchedLowPtB, TH1 **hAllMatchedHightPtB, Int_t indTrigger, TString canvasName);
+TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE, TH1 **hBNoPS, TH1 **hACNoPS,TH1 **hENoPS, TH1 **hBWithPS, TString canvasName, Int_t *colorInd, Bool_t isHeavyIon = kFALSE);
+TCanvas *ProcessCanvasPhysSelCutCentrality(TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE, TH1 **hBNoPS, TH1 **hACNoPS, TH1 **hENoPS, TH1 **hBWithPS, Int_t k, TString canvasName, Int_t *colorInd, TString *legendHeader, Bool_t isHeavyIon = kFALSE);
+TCanvas *ProcessCanvasCentralityPercentile(TObjArray *triggersB, TH1 **hBNoPSCent, TH1 **hBWithPSCent, Int_t k, TString canvasName, Int_t *colorInd, TString *legendHeader);
+TCanvas *ProcessCanvasTracksoverTrigger(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName,TString legendHeader="");
+TCanvas *ProcessCanvasTrackMultB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName,TString legendHeader="");
+TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName,TString legendHeader="");
+TCanvas *ProcessCanvasAsymMatched(TObjArray *triggersB, TH1 **hPosMatchedB, TH1 **hNegMatchedB, TH1 **hAllMatchedB, Int_t indTrigger, TString canvasName,TString legendHeader="");
+TCanvas *ProcessCanvasHighPtMuons(TObjArray *triggersB, TH1 **hB, TH1 **hMatchedLowPtB, TH1 **hAllMatchedHightPtB, Int_t indTrigger, TString canvasName,TString legendHeader="");
 Bool_t IsTrigger(TObjArray *array, Int_t index, TString name);
+Bool_t IsHeavyIonCollision(AliCounterCollection *eventCounters);
 
 //--------------------------------------------------------------------------
-void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * triggerList = 0x0, Bool_t selectPhysics = kFALSE, const char *LHCPeriod = "LHC11c", const char *QAFileName = "QAresults.root") {
+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") {
        
   /// Macro for QA monitoring.
   /// Example: baseDir = "alien:///alice/cern.ch/user/p/ppillot/pp7TeV/LHC10d/MuonQA/pass1/results/".
   /// If runList != 0x0: only the given runs will be used. Otherwise use all runs found in baseDir.
-  
+  /// If triggerList !=0x0: only the given triggers are displayed. Otherwise use the default list of triggers (see GetTriggerLists)
+       
 #if defined(__CINT__) && !defined(__MAKECINT__)
   gSystem->Load("libTree");
   gSystem->Load("libGeom");
@@ -119,21 +125,19 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
   }
   
 
-  //---------------------------------- //
-  //          Run selection            //
-  //---------------------------------- //
+  cout<<"//---------------------------------- //"<<endl;
+  cout<<"//          Run selection            //"<<endl;
+  cout<<"//---------------------------------- //"<<endl;
   
   TObjArray *runs = new TObjArray();
   runs->SetOwner(kTRUE);
   TObjArray *runs2 = new TObjArray();
   runs2->SetOwner(kTRUE);
   TString selectRuns = GetRunList(runList,runs,runs2);
-               
+       
   // physics selection
   TString select = selectPhysics ? "selected:yes" : "";
-  
-
-       
+       
   cout<<"//---------------------------------- //"<<endl;
   cout<<"//        Get global counter        //"<<endl;
   cout<<"//---------------------------------- //"<<endl;
@@ -168,18 +172,34 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
   TString listFromContainer = eventCounters->GetKeyWords("trigger");
   Bool_t success = GetTriggerLists(triggerList, listFromContainer, triggersB, triggersAC, triggersE);
   if(!success) return;
-  
+       
+  cout<<"//---------------------------------- //"<<endl;
+  cout<<"//      Set collision type ?          //"<<endl;
+  cout<<"//---------------------------------- //"<<endl;
 
+  Bool_t isHeavyIon = kTRUE;
+  isHeavyIon = IsHeavyIonCollision(eventCounters);
+       
   cout<<"//---------------------------------- //"<<endl;
   cout<<"//        Trigger plots              //"<<endl;
   cout<<"//---------------------------------- //"<<endl;
        
-  //plot all trigger from event counters
+  //plot all trigger from event counters without any selection
   TString CanvasName = "cAll";
   TCanvas *cAll = new TCanvas(CanvasName.Data(),CanvasName.Data());
+  cAll->SetLeftMargin(0.18);
   cAll->cd();
   //TH2* hAll = (TH2*) ProcessHisto2D(eventCounters, "trigger", "run", Form("run:any/%s",select.Data()) , "");
   TH2* hAll = (TH2*) ProcessHisto2D(eventCounters, "trigger", "run", "run:any" , "");
+  for ( Int_t ibin=1; ibin<=hAll->GetYaxis()->GetNbins(); ++ibin ) {
+    TString currLabel = hAll->GetYaxis()->GetBinLabel(ibin);
+    TObjArray* labelArray = currLabel.Tokenize("-");
+    labelArray->SetOwner();
+    TString newLabel = labelArray->At(0)->GetName();
+    if ( labelArray->GetEntries() >= 2 ) newLabel = Form("%s-%s", newLabel.Data(), labelArray->At(1)->GetName());
+    hAll->GetYaxis()->SetBinLabel(ibin, newLabel.Data());
+    delete labelArray;
+  }
   hAll->Draw("TEXT");
 
        
@@ -188,130 +208,161 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
   TCanvas *c1 = new TCanvas(CanvasName.Data(),CanvasName.Data());
   c1->cd();
 
-  TH1* hBNoPS[10]={}; 
-  TH1* hBWithPS[10]={};
-  TH1* hB[10]={};
-  TH1* hTriggerB[10], *hTrackerB[10], *hMatchedB[10], *hAllTracksB[10], *hMatchedLowPtB[10], *hMatchedHighPtB[10];
-  TH1* hMatchedLowPtBNoPS[10], *hMatchedHighPtBNoPS[10];
-  TH1* hPosMatchedB[10], *hNegMatchedB[10], *hAllMatchedB[10];
-  TH1 *hACWithPS[10]={}; 
-  TH1 *hACNoPS[10]={};
-  TH1 *hEWithPS[10]={};
-  TH1 *hENoPS[10]={};
+  //Add a dimension here: All collisions / M.B / low mult. / high mult.
+       
+  //loop on centrality
+  Int_t centBin = 3;
+  Int_t const centBinMax = 4;
+  Int_t centBinMaxLoop = centBinMax;
+  if(!isHeavyIon) centBinMaxLoop = 1;
+  TString centBinName[centBinMax] = {"v0mult:any/","v0mult:low,int,high/","v0mult:low/","v0mult:high/"};
+  TString centLegendName[centBinMax] ={"All collisions","[0-80%] from V0 amplitude","low mult. [60-80%] from V0 amplitude","high mult. [0-10%] from V0 amplitude"};
+  TString centLegendNameShort[centBinMax] ={"All","[0-80%]","[60-80%]","[0-10%]"};
+  TString selectionCent;
+       
+       
+  TH1* hBNoPS[centBinMax][10]={}; 
+  TH1* hBWithPS[centBinMax][10]={};
+  TH1* hB[centBinMax][10]={};
+  TH1* hTriggerB[centBinMax][10], *hTrackerB[centBinMax][10], *hMatchedB[centBinMax][10], *hAllTracksB[centBinMax][10], *hMatchedLowPtB[centBinMax][10], *hMatchedHighPtB[centBinMax][10];
+  TH1* hMatchedLowPtBNoPS[centBinMax][10], *hMatchedHighPtBNoPS[centBinMax][10];
+  TH1* hPosMatchedB[centBinMax][10], *hNegMatchedB[centBinMax][10], *hAllMatchedB[centBinMax][10];
+  TH1 *hACWithPS[centBinMax][10]={}; 
+  TH1 *hACNoPS[centBinMax][10]={};
+  TH1 *hEWithPS[centBinMax][10]={};
+  TH1 *hENoPS[centBinMax][10]={};
   
   if(triggersB->GetEntriesFast()>=10){
     cout<<"Too many triggers"<<endl;
     return;
   }
        
-  //Loop on trigger (last is all triggers, then for each defined trigger)
-  for(Int_t i = 0; i < triggersB->GetEntriesFast(); i++){
+
+       
+  //loop on centrality
+  for(centBin = 0; centBin < centBinMaxLoop; centBin++){
+    selectionCent = centBinName[centBin];
+               
+    //Loop on trigger (last is all triggers, then for each defined trigger)
+    for(Int_t i = 0; i < triggersB->GetEntriesFast(); i++){
     
-    TString histoNameBase = "h_trig", histoName;
-    histoNameBase+= i+1;
+      TString histoNameBase = "h_trig", histoName;
+      histoNameBase+= i+1;
+      Bool_t empty = kFALSE;
                
-    TString triggerName = ( (TObjString*) triggersB->At(i) )->GetString();
-    // Histo trigger without Phys. Sel. 
-    selection = Form("trigger:%s/%s", triggerName.Data(), selectRuns.Data());          
-    cout<<selection<<endl;
-    histoName = histoNameBase;
-    histoName += "BNoPS";
-    hBNoPS[i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName, "", "Trigger content w/o Phys. Sel.", colorInd[i]);
-    // Histo trigger with Phys. Sel. 
-    selection = Form("trigger:%s/%s/selected:yes", triggerName.Data(), selectRuns.Data());
-    histoName = histoNameBase;
-    histoName += "BWithPS";
-    hBWithPS[i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName, "", "Trigger content w/ Phys. Sel.", colorInd[i]);
-    // Histo trigger : Phys. Sel.  is selected or not depending on the macro arguments
-    selection = Form("trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
-    histoName = histoNameBase;
-    histoName += "B";
-    hB[i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
+      TString triggerName = ( (TObjString*) triggersB->At(i) )->GetString();
+      if(triggerName.EqualTo(" ")) continue;
+      // Histo trigger without Phys. Sel. 
+      selection = selectionCent; selection += Form("trigger:%s/%s", triggerName.Data(), selectRuns.Data());            
+      cout<<selection<<endl;
+      histoName = histoNameBase;
+      histoName += "BNoPS";
+      hBNoPS[centBin][i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName, "", "Trigger content w/o Phys. Sel.", colorInd[i],empty);
+      // Histo trigger with Phys. Sel. 
+      selection = selectionCent; selection += Form("trigger:%s/%s/selected:yes", triggerName.Data(), selectRuns.Data());
+      histoName = histoNameBase;
+      histoName += "BWithPS";
+      hBWithPS[centBin][i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName, "", "Trigger content w/ Phys. Sel.", colorInd[i],empty);
+      // Histo trigger : Phys. Sel.  is selected or not depending on the macro arguments
+      selection = selectionCent; selection += Form("trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
+      histoName = histoNameBase;
+      histoName += "B";
+      hB[centBin][i] = (TH1*) ProcessHisto(eventCounters, "run", selection, histoName,empty);
                
-    TString triggerNameAC = ( (TObjString*) triggersAC->At(i) )->GetString();
-    // Histo trigger without Phys. Sel. AC
-    histoName = histoNameBase;
-    histoName += "ACNoPS";
-    selection = Form("trigger:%s/%s", triggerNameAC.Data(), selectRuns.Data());
-    hACNoPS[i] =  (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
-    // Histo trigger with Phys. Sel. AC
-    selection = Form("trigger:%s/%s/selected:yes", triggerNameAC.Data(), selectRuns.Data());
-    histoName = histoNameBase;
-    histoName += "ACWithPS";
-    hACWithPS[i] =  (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
+      TString triggerNameAC = ( (TObjString*) triggersAC->At(i) )->GetString();
+      if(triggerNameAC.EqualTo(" ")) empty = kTRUE;
+      //if(empty == kTRUE) cout<< "test B="<<triggerName<<" AC="<<triggerNameAC<<" empty="<<empty<<endl;       
+      // Histo trigger without Phys. Sel. AC
+      histoName = histoNameBase;
+      histoName += "ACNoPS";
+      selection = selectionCent; selection += Form("trigger:%s/%s", triggerNameAC.Data(), selectRuns.Data());
+      hACNoPS[centBin][i] =  (TH1*) ProcessHisto(eventCounters, "run", selection, histoName,empty);
+      // Histo trigger with Phys. Sel. AC
+      selection = selectionCent; selection += Form("trigger:%s/%s/selected:yes", triggerNameAC.Data(), selectRuns.Data());
+      histoName = histoNameBase;
+      histoName += "ACWithPS";
+      hACWithPS[centBin][i] =  (TH1*) ProcessHisto(eventCounters, "run", selection, histoName,empty);
     
-    TString triggerNameE = ( (TObjString*) triggersE->At(i) )->GetString();
-    // Histo trigger without Phys. Sel. E
-    selection = Form("trigger:%s/%s", triggerNameE.Data(), selectRuns.Data());
-    histoName = histoNameBase;
-    histoName += "ENoPS";
-    hENoPS[i] =  (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
-    // Histo trigger with Phys. Sel. E
-    selection = Form("trigger:%s/%s/selected:yes", triggerNameE.Data(), selectRuns.Data());
-    histoName = histoNameBase;
-    histoName += "EWithPS";
-    hEWithPS[i] =  (TH1*) ProcessHisto(eventCounters, "run", selection, histoName);
-
-    // Histo tracking : Phys. Sel.  is selected or not depending on the macro arguments
-    selection = Form("track:triggeronly/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
-    hTriggerB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
+      TString triggerNameE = ( (TObjString*) triggersE->At(i) )->GetString();
+      if(triggerNameE.EqualTo(" ")) empty = kTRUE;
+      //if(empty == kTRUE) cout<< "test B="<<triggerName<<" E="<<triggerNameE<<" "<<empty<<endl;       
+
+      // Histo trigger without Phys. Sel. E
+      selection = selectionCent; selection += Form("trigger:%s/%s", triggerNameE.Data(), selectRuns.Data());
+      histoName = histoNameBase;
+      histoName += "ENoPS";
+      hENoPS[centBin][i] =  (TH1*) ProcessHisto(eventCounters, "run", selection, histoName,empty);
+      // Histo trigger with Phys. Sel. E
+      selection = selectionCent; selection += Form("trigger:%s/%s/selected:yes", triggerNameE.Data(), selectRuns.Data());
+      histoName = histoNameBase;
+      histoName += "EWithPS";
+      hEWithPS[centBin][i] =  (TH1*) ProcessHisto(eventCounters, "run", selection, histoName,empty);
+
+      // Histo tracking : Phys. Sel.  is selected or not depending on the macro arguments
+      selection = selectionCent; selection += Form("track:triggeronly/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
+      hTriggerB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
                
-    selection = Form("track:trackeronly/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
-    hTrackerB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
+      selection = selectionCent; selection += Form("track:trackeronly/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
+      hTrackerB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
                
-    selection = Form("track:matched/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
-    hMatchedB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
+      selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
+      hMatchedB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
                
-    selection = Form("trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
-    hAllTracksB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
+      selection = selectionCent; selection += Form("trigger:%s/%s/%s", triggerName.Data(), selectRuns.Data(), select.Data());
+      hAllTracksB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
                
-    selection = Form("track:matched/trigger:%s/%s/%s/pt:low/acc:in", triggerName.Data() ,selectRuns.Data(), select.Data());
-    hMatchedLowPtB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
+      selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s/pt:low/acc:in", triggerName.Data() ,selectRuns.Data(), select.Data());
+      hMatchedLowPtB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
                
-    selection = Form("track:matched/trigger:%s/%s/%s/pt:high/acc:in", triggerName.Data() ,selectRuns.Data(), select.Data());
-    hMatchedHighPtB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
+      selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s/pt:high/acc:in", triggerName.Data() ,selectRuns.Data(), select.Data());
+      hMatchedHighPtB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
                
-    selection = Form("track:matched/trigger:%s/%s/pt:low/acc:in", triggerName.Data() ,selectRuns.Data());
-    hMatchedLowPtBNoPS[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
+      selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/pt:low/acc:in", triggerName.Data() ,selectRuns.Data());
+      hMatchedLowPtBNoPS[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
                
-    selection = Form("track:matched/trigger:%s/%s/pt:high/acc:in", triggerName.Data() ,selectRuns.Data());
-    hMatchedHighPtBNoPS[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
+      selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/pt:high/acc:in", triggerName.Data() ,selectRuns.Data());
+      hMatchedHighPtBNoPS[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
                
-    selection = Form("track:matched/trigger:%s/%s/charge:pos/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
-    hPosMatchedB[i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
+      selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/charge:pos/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
+      hPosMatchedB[centBin][i] = (TH1*) ProcessHisto(trackCounters, "run", selection, "");
     
-    selection = Form("track:matched/trigger:%s/%s/charge:neg/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
-    hNegMatchedB[i] =  (TH1*) ProcessHisto(trackCounters, "run", selection, "");
+      selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/charge:neg/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
+      hNegMatchedB[centBin][i] =  (TH1*) ProcessHisto(trackCounters, "run", selection, "");
                
-    selection = Form("track:matched/trigger:%s/%s/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
-    hAllMatchedB[i] =  (TH1*) ProcessHisto(trackCounters, "run", selection, "");
+      selection = selectionCent; selection += Form("track:matched/trigger:%s/%s/%s/acc:in",triggerName.Data(), select.Data(),selectRuns.Data());
+      hAllMatchedB[centBin][i] =  (TH1*) ProcessHisto(trackCounters, "run", selection, "");
+    }
   }
        
   //if there is not B triggers just stop now
   Int_t count_trigger=0;
+  centBin = 0;
   for(Int_t i = 0; i < triggersB->GetEntriesFast(); i++){
-    count_trigger += hBNoPS[i]->GetEntries();
+    count_trigger += hBNoPS[centBin][i]->GetEntries();
   }
   if(count_trigger<=0) return;
        
        
-  Int_t NumOfBNoPS[10];
-  Int_t NumOfBWithPS[10];
-  Int_t NumOfACNoPS[10];
-  Int_t NumOfENoPS[10];
-  Int_t NumOfACWithPS[10];
-  Int_t NumOfEWithPS[10];
-       
-  for(Int_t i = 0; i < triggersB->GetEntriesFast(); i++){
-    NumOfBNoPS[i] = hBNoPS[i]->Integral();
-    NumOfBWithPS[i] = hBWithPS[i]->Integral();
-    NumOfACNoPS[i] = hACNoPS[i]->Integral();
-    NumOfENoPS[i] = hENoPS[i]->Integral();
-    NumOfACWithPS[i] = hACWithPS[i]->Integral();
-    NumOfEWithPS[i] = hEWithPS[i]->Integral();
+  Int_t NumOfBNoPS[centBinMax][10];
+  Int_t NumOfBWithPS[centBinMax][10];
+  Int_t NumOfACNoPS[centBinMax][10];
+  Int_t NumOfENoPS[centBinMax][10];
+  Int_t NumOfACWithPS[centBinMax][10];
+  Int_t NumOfEWithPS[centBinMax][10];
+       
+  for(centBin = 0; centBin < centBinMaxLoop; centBin++){
+    for(Int_t i = 0; i < triggersB->GetEntriesFast(); i++){
+      NumOfBNoPS[centBin][i] = hBNoPS[centBin][i]->Integral();
+      NumOfBWithPS[centBin][i] = hBWithPS[centBin][i]->Integral();
+      NumOfACNoPS[centBin][i] = hACNoPS[centBin][i]->Integral();
+      NumOfENoPS[centBin][i] = hENoPS[centBin][i]->Integral();
+      NumOfACWithPS[centBin][i] = hACWithPS[centBin][i]->Integral();
+      NumOfEWithPS[centBin][i] = hEWithPS[centBin][i]->Integral();
+    }
   }
-       
 
+  centBin = 0;
+       
   cout<<"//==================================================================================="<<endl;
   cout<<"// Put all plots in a ps file, easier to publish (Twiki)"<<endl;
   cout<<"//==================================================================================="<<endl;
@@ -326,7 +377,7 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
   cout<<"// new canvas with the total number of trigger with and without Phys. Sel."<<endl;
   cout<<"//==================================================================================="<<endl;
        
-  TCanvas *cTriggerContent = ProcessCanvasTriggerContent(triggersB, hBNoPS, hBWithPS, "TriggerContent");
+  TCanvas *cTriggerContent = ProcessCanvasTriggerContent(triggersB, hBNoPS[centBin], hBWithPS[centBin], "TriggerContent");
   cTriggerContent->Draw(); 
   cTriggerContent->Print(OutFileNamePDF.Data());
   cTriggerContent->Write();
@@ -335,7 +386,7 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
   cout<<"// new canvas with the relative content of each trigger w/o physics selection"<<endl;
   cout<<"//==================================================================================="<<endl;
        
-  TCanvas *cRelativeTriggerContent = ProcessCanvasRelativeTriggerContent(triggersB, hBNoPS, "RelativeTriggerContent", colorInd);
+  TCanvas *cRelativeTriggerContent = ProcessCanvasRelativeTriggerContent(triggersB, hBNoPS[centBin], "RelativeTriggerContent", colorInd);
   cRelativeTriggerContent->Draw();
   cRelativeTriggerContent->Print(OutFileNamePDF.Data());
   cRelativeTriggerContent->Write();
@@ -344,85 +395,184 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
   cout<<"// new canvas with effect from physics selection for each trigger and background trigger "<<endl;
   cout<<"//==================================================================================="<<endl;
        
-  TCanvas *cPhysSelCut = ProcessCanvasPhysSelCut(triggersB, triggersAC, triggersE, hBNoPS, hACNoPS, hENoPS, hBWithPS, "PhysSelCutOnCollTrigger", colorInd);
+  TCanvas *cPhysSelCut = 0x0;
+  cPhysSelCut = ProcessCanvasPhysSelCut(triggersB, triggersAC, triggersE, hBNoPS[centBin], hACNoPS[centBin], hENoPS[centBin], hBWithPS[centBin], "PhysSelCutOnCollTrigger", colorInd,isHeavyIon);
   cPhysSelCut->Draw();
   cPhysSelCut->Print(OutFileNamePDF.Data());
   cPhysSelCut->Write();
+       
+  cout<<"//==================================================================================="<<endl;
+  cout<<"// new canvas with effect from physics selection for each trigger and centrality bin (only in PbPb) "<<endl;
+  cout<<"//==================================================================================="<<endl;
+               
+  Int_t k=0;
+  TString canvasName;
+  TString triggerName; 
+  TString legendHeader="";
+       
+       
+  if ( isHeavyIon ){
+    TCanvas *cPhysSelCutCentrality[10];
+       
+    //loop over trigger
+    for(k = 0; k < triggersB->GetEntriesFast(); k++){
+      //skip sum of all triggers
+      if(k == (triggersB->GetEntriesFast()-1)) continue;
+      //skip some triggers
+      if( !IsTrigger(triggersB,k,"CMB")&&!IsTrigger(triggersB, k, "CPBI") ) continue;
+
+      canvasName = "PhysSel_trigger";
+      canvasName +=k;
+               
+      TH1* hBNoPSCent[centBinMax-1]={hBNoPS[1][k],hBNoPS[2][k],hBNoPS[3][k]}; 
+      TH1* hACNoPSCent[centBinMax-1]={hACNoPS[1][k],hACNoPS[2][k],hACNoPS[3][k]}; 
+      TH1* hENoPSCent[centBinMax-1]={hENoPS[1][k],hENoPS[2][k],hENoPS[3][k]}; 
+      TH1* hBWithPSCent[centBinMax-1]={hBWithPS[1][k],hBWithPS[2][k],hBWithPS[3][k]}; 
+               
+      cPhysSelCutCentrality[k] = ProcessCanvasPhysSelCutCentrality(triggersB, triggersAC, triggersE, hBNoPSCent, hACNoPSCent, hENoPSCent, hBWithPSCent, k, canvasName, colorInd, centLegendNameShort+1, isHeavyIon);
+      cPhysSelCutCentrality[k]->Draw();
+      cPhysSelCutCentrality[k]->Print(OutFileNamePDF.Data());
+      cPhysSelCutCentrality[k]->Write();
+               
+    }
+  }
+       
+       
+  cout<<"//==================================================================================="<<endl;
+  cout<<"// new canvas for centrality percentile check (only in PbPb) "<<endl;
+  cout<<"//==================================================================================="<<endl;
+       
+  if ( isHeavyIon ){
+    TCanvas *cCentralityCheck[10];
+               
+    //loop over trigger
+    for(k = 0; k < triggersB->GetEntriesFast(); k++){
+      //skip sum of all triggers
+      if(k == (triggersB->GetEntriesFast()-1)) continue;
+      //skip some triggers
+      if( !IsTrigger(triggersB,k,"CMB")&&!IsTrigger(triggersB, k, "CPBI") ) continue;
+                       
+      canvasName = "CentralityCheck_trigger";
+      canvasName +=k;
+                       
+      TH1* hBNoPSCent[centBinMax-1]={hBNoPS[1][k],hBNoPS[2][k],hBNoPS[3][k]}; 
+      TH1* hBWithPSCent[centBinMax-1]={hBWithPS[1][k],hBWithPS[2][k],hBWithPS[3][k]}; 
+                       
+      cCentralityCheck[k] =    ProcessCanvasCentralityPercentile(triggersB,hBNoPSCent,hBWithPSCent,k,canvasName,colorInd,centLegendNameShort+1 );
+
+      cCentralityCheck[k]->Draw();
+      cCentralityCheck[k]->Print(OutFileNamePDF.Data());
+      cCentralityCheck[k]->Write();
+                       
+    }
+  }
+       
+       
 
   cout<<"//==================================================================================="<<endl;
   cout<<"// Ratio of tracks over trigger type (3 canvases) "<<endl;
   cout<<"//==================================================================================="<<endl;
 
   //Print a canvas per trigger type
-  TCanvas *cTracksoverTrigger[10];
-  TCanvas* cTrackMultB[10];
-  TCanvas* cRatioTrackB[10];
+  TCanvas *cTracksoverTrigger[centBinMax][10];
+  TCanvas* cTrackMultB[centBinMax][10];
+  TCanvas* cRatioTrackB[centBinMax][10];
        
-  //loop over trigger
-  Int_t k=0;
-  TString canvasName;
-  TString triggerName;
-  for(k = 0; k < triggersB->GetEntriesFast(); k++){
-    //skip sum of all triggers
-    if(k == (triggersB->GetEntriesFast()-1)) continue;
-    //skip some triggers
-    if( !IsTrigger(triggersB, k, "INT") && !IsTrigger(triggersB, k, "MUS" ) && !IsTrigger(triggersB, k, "ANY") && !IsTrigger(triggersB,k,"CMB") ) continue;
+
+       
+  //loop on centrality bin
+  for ( centBin = 0; centBin < centBinMaxLoop; centBin++){
+    if ( isHeavyIon ) legendHeader = centLegendName[centBin];
+    //loop over trigger
+    for(k = 0; k < triggersB->GetEntriesFast(); k++){
+      //skip sum of all triggers
+      if(k == (triggersB->GetEntriesFast()-1)) continue;
+      //skip some triggers
+      if( !IsTrigger(triggersB, k, "INT") && !IsTrigger(triggersB, k, "MUS" ) && !IsTrigger(triggersB, k, "ANY") && !IsTrigger(triggersB,k,"CMB")&&!IsTrigger(triggersB, k, "CPBI") ) continue;
                
-    cTracksoverTrigger[k]= ProcessCanvasTracksoverTrigger(triggersB, hB, hTrackerB, hTriggerB, hMatchedB, hAllTracksB, k, "RatioTrackTypes");
-    cTracksoverTrigger[k]->Draw();
-    cTracksoverTrigger[k]->Print(OutFileNamePDF.Data());
-    cTracksoverTrigger[k]->Write();
-
-    cTrackMultB[k]= ProcessCanvasTrackMultB(triggersB, hB, hTrackerB, hTriggerB, hMatchedB, hAllTracksB, k, "TrackMult");
-    cTrackMultB[k]->Draw();
-    cTrackMultB[k]->Print(OutFileNamePDF.Data());
-    cTrackMultB[k]->Write();
-       
-    cRatioTrackB[k]= ProcessCanvasRatioTrackB(triggersB, hB, hTrackerB, hTriggerB, hMatchedB, hAllTracksB, k, "RatioTrackB");
-    cRatioTrackB[k]->Draw();
-    cRatioTrackB[k]->Print(OutFileNamePDF.Data());
-    cRatioTrackB[k]->Write();
+      canvasName = "RatioTrackTypes_cent";
+      canvasName += centBin;
+      canvasName +="trigger";
+      canvasName +=k;
+      cTracksoverTrigger[centBin][k]= ProcessCanvasTracksoverTrigger(triggersB, hB[centBin], hTrackerB[centBin], hTriggerB[centBin], hMatchedB[centBin], hAllTracksB[centBin], k, canvasName,legendHeader);
+      cTracksoverTrigger[centBin][k]->Draw();
+      cTracksoverTrigger[centBin][k]->Print(OutFileNamePDF.Data());
+      cTracksoverTrigger[centBin][k]->Write();
+
+      canvasName = "TrackMult_cent";
+      canvasName += centBin;
+      canvasName +="trigger";
+      canvasName +=k;          
+      cTrackMultB[centBin][k]= ProcessCanvasTrackMultB(triggersB, hB[centBin], hTrackerB[centBin], hTriggerB[centBin], hMatchedB[centBin], hAllTracksB[centBin], k, canvasName, legendHeader);
+      cTrackMultB[centBin][k]->Draw();
+      cTrackMultB[centBin][k]->Print(OutFileNamePDF.Data());
+      cTrackMultB[centBin][k]->Write();
+       
+      canvasName = "RatioTrackB_cent";
+      canvasName += centBin;
+      canvasName +="trigger";
+      canvasName +=k;          
+      cRatioTrackB[centBin][k]= ProcessCanvasRatioTrackB(triggersB, hB[centBin], hTrackerB[centBin], hTriggerB[centBin], hMatchedB[centBin], hAllTracksB[centBin], k, canvasName, legendHeader);
+      cRatioTrackB[centBin][k]->Draw();
+      cRatioTrackB[centBin][k]->Print(OutFileNamePDF.Data());
+      cRatioTrackB[centBin][k]->Write();
+    }
   }
-       
 
   cout<<"//===================================================="<<endl;
   cout<<"// Draw matched tracks asymmetry for mus type trigger "<<endl;
   cout<<"//===================================================="<<endl;
        
   //Print a canvas per trigger type
-  TCanvas *cAsymMatched[10];
-       
-  //loop over trigger
-  for(k = 0; k < triggersB->GetEntriesFast(); k++){
-    //skip sum of all triggers
-    if(k == (triggersB->GetEntriesFast()-1)) continue;
-    //skip some triggers
-    if( !IsTrigger(triggersB, k, "MUS" ) ) continue;
-               
-    cAsymMatched[k]= ProcessCanvasAsymMatched(triggersB, hPosMatchedB, hNegMatchedB, hAllMatchedB, k, "AsymMatched");
-    cAsymMatched[k]->Draw();
-    cAsymMatched[k]->Print(OutFileNamePDF.Data());
-    cAsymMatched[k]->Write();
+  TCanvas *cAsymMatched[centBinMax][10];
+
+  //Loop on centrality
+  for ( centBin = 0; centBin < centBinMaxLoop; centBin++){
+    if ( isHeavyIon ) legendHeader = centLegendName[centBin];
+    //loop over trigger
+    for(k = 0; k < triggersB->GetEntriesFast(); k++){
+      //skip sum of all triggers
+      if(k == (triggersB->GetEntriesFast()-1)) continue;
+      //skip some triggers
+      if( !(IsTrigger(triggersB, k, "INT") || IsTrigger(triggersB, k, "MUS" ) || IsTrigger(triggersB,k,"CMB")|| IsTrigger(triggersB, k, "CPBI")) ) continue;
+
+                       canvasName = "AsymMatched";
+                       canvasName += centBin;
+                       canvasName +="trigger";
+                       canvasName +=k;
+                       cAsymMatched[centBin][k]= ProcessCanvasAsymMatched(triggersB, hPosMatchedB[centBin], hNegMatchedB[centBin], hAllMatchedB[centBin], k, canvasName,legendHeader);
+      cAsymMatched[centBin][k]->Draw();
+      cAsymMatched[centBin][k]->Print(OutFileNamePDF.Data());
+      cAsymMatched[centBin][k]->Write();
+    }
   }
-       
   cout<<"//=================================================="<<endl;
   cout<<"// Draw high pt tracks per trigger"<<endl;
   cout<<"//=================================================="<<endl;
 
   //Print a canvas per trigger type
-  TCanvas *cHighPtMuons[10];
-       
-  //loop over trigger
-  for(k = 0; k < triggersB->GetEntriesFast(); k++){
-    //skip sum of all triggers
-    if(k == (triggersB->GetEntriesFast()-1)) continue;
-    //skip some triggers
-    if( !IsTrigger(triggersB, k, "MUS" ) ) continue;
+  TCanvas *cHighPtMuons[3][10];
+       
+  //Loop on centrality
+  for ( centBin = 0; centBin < centBinMaxLoop; centBin++){
+    if ( isHeavyIon ) legendHeader = centLegendName[centBin];
+    //loop over trigger
+    for(k = 0; k < triggersB->GetEntriesFast(); k++){
+      //skip sum of all triggers
+      if(k == (triggersB->GetEntriesFast()-1)) continue;
+      //skip some triggers
+      if( !(IsTrigger(triggersB, k, "INT") || IsTrigger(triggersB, k, "MUS" ) || IsTrigger(triggersB,k,"CMB")|| IsTrigger(triggersB, k, "CPBI")) ) continue;
                
-    cHighPtMuons[k]= ProcessCanvasHighPtMuons(triggersB, hB, hMatchedLowPtB, hMatchedHighPtB, k, "HighPtMuons");
-    cHighPtMuons[k]->Draw();
-    cHighPtMuons[k]->Print(OutFileNamePDF.Data());
-    cHighPtMuons[k]->Write();
+                       canvasName = "HighPtMuons";
+                       canvasName += centBin;
+                       canvasName +="trigger";
+                       canvasName +=k;
+                       
+      cHighPtMuons[centBin][k]= ProcessCanvasHighPtMuons(triggersB, hB[centBin], hMatchedLowPtB[centBin], hMatchedHighPtB[centBin], k, canvasName,legendHeader);
+      cHighPtMuons[centBin][k]->Draw();
+      cHighPtMuons[centBin][k]->Print(OutFileNamePDF.Data());
+      cHighPtMuons[centBin][k]->Write();
+    }
   }
        
   // close merged file 
@@ -432,52 +582,55 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
   //Print out the number of trigger without and with Phys. Sel.
   //===================================================================================
   
+  centBin = 0;
   cout << endl << endl;
   //====================================================
   if (PRINTSTAT){
-    // set the format to print labels
-    THashList* labels = hBWithPS[kCMUS]->GetXaxis()->GetLabels();
-    TString format(Form("\n%%%ds %%9d",0));
-    Int_t nRuns=0;
+    if ( triggersB->At(kCMUS) ) { 
     
-    // print value for each label
-    TObjString* label = 0x0;
-    TIter nextLabel(labels);
-    cout << "-------------------------------------------------" << endl;
-    cout << "Run Number" << "\t Number of "<< ( (TObjString*) triggersB->At(kCMUS) )->GetString()<<" after Phys. Sel. " << endl ;  
-    while ((label = static_cast<TObjString*>(nextLabel()))) {
-      nRuns++;
-      Int_t bin = (Int_t) label->GetUniqueID();
-      printf(format.Data(), label->String().Data(), (Int_t) hBWithPS[kCMUS]->GetBinContent(bin));
-    }
-    printf("\n========== Total #runs = %d ==============\n",nRuns);
-    printf("\n\n");
+      // set the format to print labels
+      THashList* labels = hBWithPS[centBin][kCMUS]->GetXaxis()->GetLabels();
+      TString format(Form("\n%%%ds %%9d",0));
+      Int_t nRuns=0;
     
+      // print value for each label
+      TObjString* label = 0x0;
+      TIter nextLabel(labels);
+      cout << "-------------------------------------------------" << endl;
+      cout << "Run Number" << "\t Number of "<< ( (TObjString*) triggersB->At(kCMUS) )->GetString()<<" after Phys. Sel. " << endl ;  
+      while ((label = static_cast<TObjString*>(nextLabel()))) {
+       nRuns++;
+       Int_t bin = (Int_t) label->GetUniqueID();
+       printf(format.Data(), label->String().Data(), (Int_t) hBWithPS[centBin][kCMUS]->GetBinContent(bin));
+      }
+      printf("\n========== Total #runs = %d ==============\n",nRuns);
+      printf("\n\n");
     
-    cout << "-------------------------------------------------" << endl;
-    cout << "Total statistic" << endl; 
-    cout << " " << endl ; 
     
-    cout << "-------------------------------------------------------------------" << endl;
-    cout<<"Number of triggers w/o Phys. Sel./ w/ Phys. Sel (Phys. Sel. cut in %)"<<endl;
-    for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
-      TString triggerNameB = ( (TObjString*) triggersB->At(i) )->GetString();
-      TString triggerNameAC = ( (TObjString*) triggersAC->At(i) )->GetString();
-      TString triggerNameE = ( (TObjString*) triggersE->At(i) )->GetString();
+      cout << "-------------------------------------------------" << endl;
+      cout << "Total statistic" << endl; 
+      cout << " " << endl ; 
+    
+      cout << "-------------------------------------------------------------------" << endl;
+      cout<<"Number of triggers w/o Phys. Sel./ w/ Phys. Sel (Phys. Sel. cut in %)"<<endl;
+      for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
+       TString triggerNameB = ( (TObjString*) triggersB->At(i) )->GetString();
+       TString triggerNameAC = ( (TObjString*) triggersAC->At(i) )->GetString();
+       TString triggerNameE = ( (TObjString*) triggersE->At(i) )->GetString();
                        
-      Int_t    cutinpercent    =       0;
-      printf("%10s %30s %30s\n",triggerNameB.Data(),triggerNameAC.Data(),triggerNameE.Data());
-      if(NumOfBNoPS[i]) cutinpercent = (Int_t) ((Double_t)(NumOfBNoPS[i]-NumOfBWithPS[i])/(NumOfBNoPS[i])*100.);
-      printf("%5.2e / %.2e (%d%%)", (Double_t) NumOfBNoPS[i],(Double_t) NumOfBWithPS[i],cutinpercent);
-      cutinpercent = 0;
-      if(NumOfACNoPS[i]) cutinpercent = (Int_t) ((Double_t)(NumOfACNoPS[i]-NumOfACWithPS[i])/(NumOfACNoPS[i])*100.);
-      printf("%15.2e / %.2e (%d%%)", (Double_t)NumOfACNoPS[i],(Double_t)NumOfACWithPS[i],cutinpercent);
-      cutinpercent = 0;
-      if(NumOfENoPS[i]) cutinpercent = (Int_t) ((Double_t)(NumOfENoPS[i]-NumOfEWithPS[i])/(NumOfENoPS[i])*100.);
-      printf("%15.2e  / %.2e (%d%%)\n", (Double_t)NumOfENoPS[i],(Double_t)NumOfEWithPS[i],cutinpercent);
+       Int_t   cutinpercent    =       0;
+       printf("%10s %30s %30s\n",triggerNameB.Data(),triggerNameAC.Data(),triggerNameE.Data());
+       if(NumOfBNoPS[centBin][i]) cutinpercent = (Int_t) ((Double_t)(NumOfBNoPS[centBin][i]-NumOfBWithPS[centBin][i])/(NumOfBNoPS[centBin][i])*100.);
+       printf("%5.2e / %.2e (%d%%)", (Double_t) NumOfBNoPS[centBin][i],(Double_t) NumOfBWithPS[centBin][i],cutinpercent);
+       cutinpercent = 0;
+       if(NumOfACNoPS[centBin][i]) cutinpercent = (Int_t) ((Double_t)(NumOfACNoPS[centBin][i]-NumOfACWithPS[centBin][i])/(NumOfACNoPS[centBin][i])*100.);
+       printf("%15.2e / %.2e (%d%%)", (Double_t)NumOfACNoPS[centBin][i],(Double_t)NumOfACWithPS[centBin][i],cutinpercent);
+       cutinpercent = 0;
+       if(NumOfENoPS[centBin][i]) cutinpercent = (Int_t) ((Double_t)(NumOfENoPS[centBin][i]-NumOfEWithPS[centBin][i])/(NumOfENoPS[centBin][i])*100.);
+       printf("%15.2e  / %.2e (%d%%)\n", (Double_t)NumOfENoPS[centBin][i],(Double_t)NumOfEWithPS[centBin][i],cutinpercent);
 
-    }
-    
+      }
+    } 
   }
   
   
@@ -538,7 +691,7 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
       command = Form("find %s/ %s/%s", alienBaseDir.Data(), run.Data(), QAFileName);
       res = gGrid->Command(command);
       if (!res) {
-       Error("PlotMUONQApp","no result for the command: %s",command.Data());
+       Error("PlotMuonQA","no result for the command: %s",command.Data());
        return;
       }
     }
@@ -590,14 +743,14 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
       if(iLoop>iLoopMax) break;
       
       if (!objs || !objs->GetString().Length()) {
-       Error("PlotMUONQApp","turl/obj not found for the run %s... SKIPPING", run.Data());
+       Error("PlotMuonQA","turl/obj not found for the run %s... SKIPPING", run.Data());
        continue;
       }
       
       // open the outfile for this run
       TFile *runFile = TFile::Open(objs->GetString());
       if (!runFile || ! runFile->IsOpen()) {
-       Error("PlotMUONQApp","failed to open file: %s", objs->GetName());
+       Error("PlotMuonQA","failed to open file: %s", objs->GetName());
        continue;//return;
       }
       runFile->Cd("MUON_QA");
@@ -608,7 +761,7 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
       TObjArray* expert = static_cast<TObjArray*>(runFile->FindObjectAny("expert"));
       
       if (!general1 || !general2 || !expert){
-       Error("PlotMUONQApp","All objects not here !!! ===> Skipping...for %s",objs->GetName());                
+       Error("PlotMuonQA","All objects not here !!! ===> Skipping...for %s",objs->GetName());          
        continue;
       }
       
@@ -666,7 +819,7 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
       
       // skip empty runs... not anymore ! cs !
       if (!hNClustersPerCh) {
-       Warning("PlotMUONQApp","File: %s has empty histograms !", objs->GetName());
+       Warning("PlotMUONQA","File: %s has empty histograms !", objs->GetName());
        hNClustersPerTrackVsRun_Mean->SetBinContent(ibin, 0.);
        hNClustersPerTrackVsRun_Mean->SetBinError(ibin, 1.);
        hNClustersPerTrackVsRun_Sigma->SetBinContent(ibin, 0.);
@@ -720,6 +873,10 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
       run.ReplaceAll(alienBaseDir, "");
       run.Remove(TString::kLeading, '/');
       run.Remove(TString::kLeading, '0');
+      for ( Int_t ihisto=0; ihisto<2; ++ihisto ) {
+        hTriggerCutVsRun[ihisto]->GetXaxis()->SetBinLabel(ibin,run.Data());
+        hTriggerCutWidthVsRun[ihisto]->GetXaxis()->SetBinLabel(ibin,run.Data());
+      }
       hNClustersPerTrackVsRun_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
       hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());
       hNChamberHitPerTrack_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());
@@ -974,6 +1131,21 @@ Bool_t IsTrigger(TObjArray *array, Int_t index, TString name){
   return process;
 }
 
+Bool_t IsHeavyIonCollision(AliCounterCollection *eventCounters){
+       
+  if(!eventCounters) return kFALSE;
+       
+  Double_t sum = eventCounters->GetSum("v0mult:low,int,high");
+  Bool_t result =              kTRUE;
+  if(sum<=0) result = kFALSE;
+       
+  cout<<" Collision type is set to ";
+  if( result == kFALSE) cout<<"p-p"<<endl;
+  else cout<<"heavy-ion"<<endl;
+       
+  return result;
+}
+
 TCanvas *ProcessCanvasTriggerContent(TObjArray *array, TH1 **hBNoPS, TH1 **hBWithPS, TString canvasName){
  
   if(!array || !hBNoPS || !hBWithPS) return 0x0;
@@ -990,7 +1162,7 @@ TCanvas *ProcessCanvasTriggerContent(TObjArray *array, TH1 **hBNoPS, TH1 **hBWit
  
   for(Int_t i = 0; i < array->GetEntriesFast(); i++){
     //skip the sum of all triggers
-    if( i== (array->GetEntriesFast()-1) ) continue;
+    if( i == (array->GetEntriesFast()-1) ) continue;
     hBNoPS[i]->SetLineStyle(2);
     if(i==0){
       hBNoPS[i]->SetMinimum(1e-3);
@@ -1059,10 +1231,14 @@ TCanvas *ProcessCanvasRelativeTriggerContent(TObjArray *triggersB, TH1 **histo,
   return cRelativeTriggerContent;
 }
 
-TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE, TH1 **hBNoPS, TH1 **hACNoPS, TH1 **hENoPS, TH1 **hBWithPS, TString canvasName, Int_t *colorInd){
+TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE, TH1 **hBNoPS, TH1 **hACNoPS, TH1 **hENoPS, TH1 **hBWithPS, TString canvasName, Int_t *colorInd, Bool_t isHeavyIon){
        
   if(!triggersB || !triggersE || !triggersAC || !hBNoPS || !hACNoPS || !hENoPS || !hBWithPS || !colorInd) return 0x0;
        
+  //Multiplicative factor for A,C and E triggers
+  Float_t scale = 3; //3 for pp - 10 for PbPb
+  if(isHeavyIon) scale = 10;
+       
   TString cName = "c";
   cName += canvasName;
   TCanvas *c1 = new TCanvas(canvasName,cName,1200,900);
@@ -1077,6 +1253,11 @@ TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray *triggersAC, TO
         
   TString hName;
   for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
+               
+    //scale A, C and E triggers
+    hACNoPS[i]->Scale(scale);
+    hENoPS[i]->Scale(scale);
+               
     hName = "ratio";
     hName += ( (TObjString*) triggersB->At(i) )->GetString();
     ratioB[i] = static_cast<TH1*> (hBWithPS[i]->Clone(hName));
@@ -1120,9 +1301,10 @@ TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray *triggersAC, TO
         
     if(i==0){
       ratioB[i]->SetMaximum(1.5);
-      ratioB[i]->SetMinimum(0.001);
+      ratioB[i]->SetMinimum(0.05);
       ratioB[i]->SetLabelSize(0.02);
-      ratioB[i]->GetYaxis()->SetTitle("Relative trigger content w/ and w/o Phys. Sel."); 
+      ratioB[i]->GetYaxis()->SetTitle("Accepted / All from Phys. Sel."); 
+      ratioB[i]->SetTitle("Phys. Sel. for all selected triggers"); 
       ratioB[i]->Draw("E");
       //ratioBNoPS[i]->Draw("EPSAME");
       ratioACNoPS[i]->Draw("EPSAME");
@@ -1143,8 +1325,135 @@ TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray *triggersAC, TO
   legcRTC->AddEntry(".","not applied :","");
   for(Int_t i = 0; i < triggersB->GetEntriesFast()-1; i++){
     //legcRTC->AddEntry(ratioBNoPS[i],(( (TObjString*) triggersB->At(i) )->GetString()).Data(),"pl");
-    legcRTC->AddEntry(ratioACNoPS[i],(( (TObjString*) triggersAC->At(i) )->GetString()).Data(),"pl");
-    legcRTC->AddEntry(ratioENoPS[i],(( (TObjString*) triggersE->At(i) )->GetString()).Data(),"pl");
+    TString textLegend = ( (TObjString*) triggersAC->At(i) )->GetString();
+    if( textLegend.CompareTo(" ") ){
+      textLegend += " x";
+      textLegend += scale;
+      legcRTC->AddEntry(ratioACNoPS[i],textLegend.Data(),"pl");
+    }
+    textLegend = ( (TObjString*) triggersE->At(i) )->GetString();
+    if( textLegend.CompareTo(" ") ){
+      //cout<<"trigger="<<textLegend.Data()<<"-"<<endl;
+      textLegend += " x";
+      textLegend += scale;
+      legcRTC->AddEntry(ratioENoPS[i],textLegend.Data(),"pl");
+    }
+  }
+  legcRTC->Draw("same");
+       
+       
+  return c1;
+}      
+
+TCanvas *ProcessCanvasPhysSelCutCentrality(TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE, TH1 **hBNoPSCent, TH1 **hACNoPSCent, TH1 **hENoPSCent, TH1 **hBWithPSCent, Int_t k, TString canvasName, Int_t *colorInd, TString *legendHeader, Bool_t isHeavyIon){
+       
+  if(!triggersB || !triggersE || !triggersAC || !hBNoPSCent || !hACNoPSCent || !hENoPSCent || !hBWithPSCent || !colorInd || !legendHeader) return 0x0;
+       
+  //Multiplicative factor for A,C and E triggers
+  Float_t scale = 3; //3 for pp - 10 for PbPb
+  if(isHeavyIon) scale = 10;
+       
+  TString cName = "c";
+  cName += canvasName;
+  TCanvas *c1 = new TCanvas(canvasName,cName,1200,900);
+  SetCanvas(c1);
+  c1->cd();
+       
+  Int_t const centBinMax =3;
+  TH1* ratioB[centBinMax], *ratioBNoPS[centBinMax];
+  TH1* ratioACNoPS[centBinMax];
+  TH1* ratioENoPS[centBinMax];
+  TLegend* legcRTC = new TLegend(0.2,0.15,0.50,0.40);
+  legcRTC->SetHeader("Physics Selection");
+       
+  TString hName;
+       
+  Float_t yMin = 0.05, yMax = 2;
+       
+  for(Int_t centBin = 0; centBin < centBinMax; centBin++){
+    //scale A, C and E triggers
+    hACNoPSCent[centBin]->Scale(scale);
+    hENoPSCent[centBin]->Scale(scale);
+               
+    hName = "ratio";
+    hName += ( (TObjString*) triggersB->At(k) )->GetString();
+    ratioB[centBin] = static_cast<TH1*> (hBWithPSCent[centBin]->Clone(hName));
+    ratioB[centBin]->Divide(hBNoPSCent[centBin]);
+    ratioB[centBin]->SetLineWidth(2);
+    ratioB[centBin]->SetLineColor(colorInd[centBin]);
+    hName = "ratioNoPS";
+    hName += ( (TObjString*) triggersB->At(k) )->GetString();
+    ratioBNoPS[centBin] = static_cast<TH1*> (hBNoPSCent[centBin]->Clone(hName));
+    ratioBNoPS[centBin]->Divide(hBNoPSCent[centBin]);
+    ratioBNoPS[centBin]->SetLineWidth(0);
+    ratioBNoPS[centBin]->SetLineStyle(1);
+    ratioBNoPS[centBin]->SetMarkerStyle(24+centBin);
+    ratioBNoPS[centBin]->SetMarkerSize(1);
+    ratioBNoPS[centBin]->SetLineColor(colorInd[centBin]);
+    ratioBNoPS[centBin]->SetMarkerColor(colorInd[centBin]);
+               
+    hName = "ratioACNoPS";
+    hName += ( (TObjString*) triggersAC->At(k) )->GetString();
+    ratioACNoPS[centBin] = static_cast<TH1*> (hACNoPSCent[centBin]->Clone(hName));
+    ratioACNoPS[centBin]->Divide(hBNoPSCent[centBin]);
+    ratioACNoPS[centBin]->SetLineWidth(0);
+    ratioACNoPS[centBin]->SetLineStyle(2);
+    ratioACNoPS[centBin]->SetMarkerStyle(24+centBin);
+    ratioACNoPS[centBin]->SetMarkerSize(1);
+    ratioACNoPS[centBin]->SetLineColor(colorInd[centBin]);
+    ratioACNoPS[centBin]->SetMarkerColor(colorInd[centBin]);
+               
+               
+    hName = "ratioENoPS";
+    hName += ( (TObjString*) triggersE->At(k) )->GetString();
+    ratioENoPS[centBin] = static_cast<TH1*> (hENoPSCent[centBin]->Clone(hName));
+    ratioENoPS[centBin]->Divide(hBNoPSCent[centBin]);
+    ratioENoPS[centBin]->SetLineWidth(0);
+    ratioENoPS[centBin]->SetLineStyle(3);
+    ratioENoPS[centBin]->SetMarkerStyle(24+centBin);
+    ratioENoPS[centBin]->SetMarkerSize(1);
+    ratioENoPS[centBin]->SetLineColor(colorInd[centBin]);
+    ratioENoPS[centBin]->SetMarkerColor(colorInd[centBin]);
+               
+               
+    if(centBin==0){
+      ratioB[centBin]->SetMaximum(yMax);
+      ratioB[centBin]->SetMinimum(yMin);
+      ratioB[centBin]->SetLabelSize(0.02);
+      ratioB[centBin]->GetYaxis()->SetTitle("Accepted / All from Phys. Sel."); 
+      ratioB[centBin]->SetTitle(Form("Phys. Sel. for %s - Multiplicity from V0 amplitude",(( (TObjString*) triggersB->At(k) )->GetString()).Data()  ));
+      ratioB[centBin]->Draw("E");
+      //ratioBNoPS[centBin]->Draw("EPSAME");
+      ratioACNoPS[centBin]->Draw("EPSAME");
+      ratioENoPS[centBin]->Draw("EPSAME");
+    }
+    else{
+      ratioB[centBin]->Draw("ESAME");
+      //ratioBNoPS[centBin]->Draw("EPSAME");
+      ratioACNoPS[centBin]->Draw("EPSAME");
+      ratioENoPS[centBin]->Draw("EPSAME");
+    }
+  }
+       
+  legcRTC->AddEntry(".","applied :","");
+  for(Int_t centBin = 0; centBin < centBinMax; centBin++){
+    legcRTC->AddEntry(ratioB[centBin],(legendHeader[centBin]).Data(),"l");
+  }
+  legcRTC->AddEntry(".","not applied :","");
+  for(Int_t centBin = 0; centBin < centBinMax; centBin++){
+    TString textLegend = ( (TObjString*) triggersAC->At(k) )->GetString();
+    if( textLegend.CompareTo(" ") && ratioACNoPS[centBin]->GetMaximum() > yMin ){
+      textLegend += " x";
+      textLegend += scale;
+      legcRTC->AddEntry(ratioACNoPS[centBin],textLegend.Data(),"pl");
+    }
+    textLegend = ( (TObjString*) triggersE->At(k) )->GetString();
+    if( textLegend.CompareTo(" ") && ratioENoPS[centBin]->GetMaximum() > yMin){
+      //cout<<"trigger="<<textLegend.Data()<<"-"<<endl;
+      textLegend += " x";
+      textLegend += scale;
+      legcRTC->AddEntry(ratioENoPS[centBin],textLegend.Data(),"pl");
+    }
   }
   legcRTC->Draw("same");
        
@@ -1152,8 +1461,76 @@ TCanvas *ProcessCanvasPhysSelCut(TObjArray *triggersB, TObjArray *triggersAC, TO
   return c1;
 }      
 
+TCanvas *ProcessCanvasCentralityPercentile(TObjArray *triggersB, TH1 **hBNoPSCent, TH1 **hBWithPSCent, Int_t k, TString canvasName, Int_t *colorInd, TString *legendHeader){
+       
+  if(!triggersB || !hBNoPSCent || !hBWithPSCent || !colorInd || !legendHeader) return 0x0;
+               
+  TString cName = "c";
+  cName += canvasName;
+  TCanvas *c1 = new TCanvas(canvasName,cName,1200,900);
+  SetCanvas(c1,0);
+  c1->cd();
+       
+  Int_t const centBinMax =2;
+  TH1* ratioB[centBinMax], *ratioBNoPS[centBinMax];
+  TLegend* legcRTC = new TLegend(0.2,0.15,0.50,0.40);
+  legcRTC->SetHeader("Physics Selection");
+       
+  TString hName;
+       
+  Float_t yMin = 0., yMax = 0.3;
+       
+  for(Int_t centBin = 0; centBin < centBinMax; centBin++){
+                       
+    hName = "ratio";
+    hName += ( (TObjString*) triggersB->At(k) )->GetString();
+    ratioB[centBin] = static_cast<TH1*> (hBWithPSCent[centBin+1]->Clone(hName));
+    ratioB[centBin]->Divide(hBWithPSCent[0]);
+    ratioB[centBin]->Scale(0.8);
+    ratioB[centBin]->SetLineWidth(2);
+    ratioB[centBin]->SetLineColor(colorInd[centBin+1]);
+    hName = "ratioNoPS";
+    hName += ( (TObjString*) triggersB->At(k) )->GetString();
+    ratioBNoPS[centBin] = static_cast<TH1*> (hBNoPSCent[centBin+1]->Clone(hName));
+    ratioBNoPS[centBin]->Divide(hBNoPSCent[0]);
+    ratioBNoPS[centBin]->Scale(0.8);
+    ratioBNoPS[centBin]->SetLineWidth(0);
+    ratioBNoPS[centBin]->SetLineStyle(1);
+    ratioBNoPS[centBin]->SetMarkerStyle(24+centBin+1);
+    ratioBNoPS[centBin]->SetMarkerSize(1);
+    ratioBNoPS[centBin]->SetLineColor(colorInd[centBin+1]);
+    ratioBNoPS[centBin]->SetMarkerColor(colorInd[centBin+1]);
+               
+    if(centBin==0){
+      ratioB[centBin]->SetMaximum(yMax);
+      ratioB[centBin]->SetMinimum(yMin);
+      ratioB[centBin]->SetLabelSize(0.02);
+      ratioB[centBin]->GetYaxis()->SetTitle("Centrality percentile check"); 
+      ratioB[centBin]->SetTitle(Form("Centrality percentile check for %s - Multiplicity from V0 amplitude",(( (TObjString*) triggersB->At(k) )->GetString()).Data()  ));
+      ratioB[centBin]->Draw("E");
+      ratioBNoPS[centBin]->Draw("EPSAME");
+    }
+    else{
+      ratioB[centBin]->Draw("ESAME");
+      ratioBNoPS[centBin]->Draw("EPSAME");
+    }
+  }
+       
+  legcRTC->AddEntry(".","applied :","");
+  for(Int_t centBin = 0; centBin < centBinMax; centBin++){
+    legcRTC->AddEntry(ratioB[centBin],(legendHeader[centBin+1]).Data(),"l");
+  }
+  legcRTC->AddEntry(".","not applied :","");
+  for(Int_t centBin = 0; centBin < centBinMax; centBin++){
+    legcRTC->AddEntry(ratioBNoPS[centBin],(legendHeader[centBin+1]).Data(),"l");
+  }
+  legcRTC->Draw("same");
+       
+       
+  return c1;
+}      
 
-TCanvas *ProcessCanvasTracksoverTrigger(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName){
+TCanvas *ProcessCanvasTracksoverTrigger(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName, TString legendHeader){
         
   if(!triggersB || !hB || !hTrackerB || !hTriggerB || !hMatchedB || !hAllTracksB || indTrigger<0 ) return 0x0;
        
@@ -1189,7 +1566,7 @@ TCanvas *ProcessCanvasTracksoverTrigger(TObjArray *triggersB, TH1 **hB, TH1 **hT
   hAllTracksPerB->Divide(hB[indTrigger]);
   hAllTracksPerB->SetLineWidth(3);
   hAllTracksPerB->SetLineColor(kBlack);
-  hAllTracksPerB->SetTitle(Form("Ratio (Number of Tracks)/%s",hNameBase.Data()));
+  hAllTracksPerB->SetTitle(Form("Number of Tracks /%s for %s",hNameBase.Data(),legendHeader.Data()));
   hAllTracksPerB->SetMinimum(0.0001);
   hAllTracksPerB->SetLabelSize(0.02);
        
@@ -1224,7 +1601,7 @@ TCanvas *ProcessCanvasTracksoverTrigger(TObjArray *triggersB, TH1 **hB, TH1 **hT
 }
 
 
-TCanvas *ProcessCanvasTrackMultB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName){
+TCanvas *ProcessCanvasTrackMultB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName,TString legendHeader){
        
   if(!triggersB || !hB || !hTrackerB || !hTriggerB || !hMatchedB || !hAllTracksB || indTrigger<0 ) return 0x0;
        
@@ -1249,7 +1626,7 @@ TCanvas *ProcessCanvasTrackMultB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB
   hSumTriggerOverB->Add(hMatchedB[indTrigger]);
   hSumTriggerOverB->Divide(hB[indTrigger]);
     
-  hName = Form("Sum of trigger tracks (matched+trigger-only) / # events in %s",hNameBase.Data());
+  hName = Form("Sum of trigger tracks (matched+trigger-only) / # events in %s for %s",hNameBase.Data(),legendHeader.Data());
   hSumTriggerOverB->SetTitle(hName);
   hSumTriggerOverB->SetLabelSize(0.02);
   hSumTriggerOverB->SetLineWidth(2);
@@ -1258,7 +1635,7 @@ TCanvas *ProcessCanvasTrackMultB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB
   hSumTrackerOverB = static_cast<TH1*>(hTrackerB[indTrigger]->Clone(hName));
   hSumTrackerOverB->Add(hMatchedB[indTrigger]);
   hSumTrackerOverB->Divide(hB[indTrigger]);
-  hName = Form("Sum of tracker tracks (matched+tracker-only) / # events in %s",hNameBase.Data());
+  hName = Form("Sum of tracker tracks (matched+tracker-only) / # events in %s for %s",hNameBase.Data(),legendHeader.Data());
   hSumTrackerOverB->SetTitle(hName);
   //hSumTrackerOverCINT1B->LabelsOption("u");
   hSumTrackerOverB->SetLabelSize(0.02);
@@ -1275,7 +1652,7 @@ TCanvas *ProcessCanvasTrackMultB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB
        
 }
 
-TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName){
+TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TH1 **hB, TH1 **hTrackerB, TH1 **hTriggerB, TH1 **hMatchedB, TH1 **hAllTracksB, Int_t indTrigger, TString canvasName,TString legendHeader){
        
   if(!triggersB || !hB || !hTrackerB || !hTriggerB || !hMatchedB || !hAllTracksB || indTrigger<0 ) return 0x0;
        
@@ -1292,7 +1669,7 @@ TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TH1 **hB, TH1 **hTracker
   TString hName = Form("hTrackerOverTrigger%s",hNameBase.Data());
   hTrackerOverTriggerB = static_cast<TH1*>(hTrackerB[indTrigger]->Clone(hName));
   hTrackerOverTriggerB->Divide(hTriggerB[indTrigger]);
-  hName = Form("# tracker tracks / # trigger tracks in %s",hNameBase.Data());
+  hName = Form("# tracker tracks / # trigger tracks in %s for %s",hNameBase.Data(),legendHeader.Data());
   hTrackerOverTriggerB->SetTitle(hName);
   //hTrackerOverTriggerCINT1B->LabelsOption("u");
   hTrackerOverTriggerB->SetLabelSize(0.02);
@@ -1303,7 +1680,7 @@ TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TH1 **hB, TH1 **hTracker
   hMatchedOverTriggerB = static_cast<TH1*>(hMatchedB[indTrigger]->Clone(hName));
   hMatchedOverTriggerB->Divide(hTriggerB[indTrigger]);
    
-  hName = Form("# matched tracks / # trigger tracks in %s",hNameBase.Data());
+  hName = Form("# matched tracks / # trigger tracks in %s for %s",hNameBase.Data(),legendHeader.Data());
   hMatchedOverTriggerB->SetTitle(hName);
   //hMatchedOverTriggerCINT1B->LabelsOption("u");
   hMatchedOverTriggerB->SetLabelSize(0.02);
@@ -1313,7 +1690,7 @@ TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TH1 **hB, TH1 **hTracker
   hName = Form("hMatchedOverTracker%s",hNameBase.Data());
   hMatchedOverTrackerB = static_cast<TH1*>(hMatchedB[indTrigger]->Clone(hName));
   hMatchedOverTrackerB->Divide(hTrackerB[indTrigger]);
-  hName = Form("# matched tracks / # tracker tracks in %s",hNameBase.Data());
+  hName = Form("# matched tracks / # tracker tracks in %s for %s",hNameBase.Data(),legendHeader.Data());
   hMatchedOverTrackerB->SetTitle(hName);
   //hMatchedOverTrackerCINT1B->LabelsOption("u");
   hMatchedOverTrackerB->SetLabelSize(0.02);
@@ -1333,7 +1710,7 @@ TCanvas *ProcessCanvasRatioTrackB(TObjArray *triggersB, TH1 **hB, TH1 **hTracker
        
 }
 
-TCanvas *ProcessCanvasAsymMatched(TObjArray *triggersB, TH1 **hPosMatchedB, TH1 **hNegMatchedB, TH1 **hAllMatchedB, Int_t indTrigger, TString canvasName){
+TCanvas *ProcessCanvasAsymMatched(TObjArray *triggersB, TH1 **hPosMatchedB, TH1 **hNegMatchedB, TH1 **hAllMatchedB, Int_t indTrigger, TString canvasName,TString legendHeader){
        
   if(!triggersB || !hPosMatchedB || !hNegMatchedB || !hAllMatchedB || indTrigger<0 ) return 0x0;
 
@@ -1359,7 +1736,7 @@ TCanvas *ProcessCanvasAsymMatched(TObjArray *triggersB, TH1 **hPosMatchedB, TH1
   hAsymMatchedCMUS1B->SetMinimum(-0.3);
   hAsymMatchedCMUS1B->SetMaximum(0.3);
   hAsymMatchedCMUS1B->SetLabelSize(0.02);
-  hName = Form("Matched tracks asymmetry for %s with acc. cuts",hNameBase.Data());
+  hName = Form("Matched tracks charge asymmetry for %s with acc. cuts for %s",hNameBase.Data(),legendHeader.Data());
   hAsymMatchedCMUS1B->SetTitle(hName);
         
   hAsymMatchedCMUS1B->GetYaxis()->SetTitle("Charged tracks asymmetry");  
@@ -1369,7 +1746,7 @@ TCanvas *ProcessCanvasAsymMatched(TObjArray *triggersB, TH1 **hPosMatchedB, TH1
        
 }
 
-TCanvas *ProcessCanvasHighPtMuons(TObjArray *triggersB, TH1 **hB, TH1 **hMatchedLowPtB, TH1 **hMatchedHighPtB, Int_t indTrigger, TString canvasName){
+TCanvas *ProcessCanvasHighPtMuons(TObjArray *triggersB, TH1 **hB, TH1 **hMatchedLowPtB, TH1 **hMatchedHighPtB, Int_t indTrigger, TString canvasName, TString legendHeader){
        
   if(!triggersB || !hB || !hMatchedLowPtB || !hMatchedHighPtB || indTrigger<0 ) return 0x0;
        
@@ -1406,12 +1783,13 @@ TCanvas *ProcessCanvasHighPtMuons(TObjArray *triggersB, TH1 **hB, TH1 **hMatched
   hMatchedHighPtPerB->SetLineWidth(2);
   hMatchedHighPtPerB->SetLineColor(kRed);
                 
+  hName = Form("Number of matched track per %s (include Vtx and R_{Abs} cuts) for %s",hNameBase.Data(),legendHeader.Data());
+  hMatchedLowPtPerB->SetTitle(hName);
   hMatchedLowPtPerB->Draw("E");
   hMatchedHighPtPerB->Draw("Esame");
         
   legcHPM = new TLegend(0.60,0.45,0.98,0.65);
-  hName = Form("Number of matched track per %s (include Vtx and R_{Abs} cuts)",hNameBase.Data());
-  legcHPM->SetHeader(hName);
+  //legcHPM->SetHeader(hName);
   legcHPM->AddEntry(".","Physics selection applied :","");     
   legcHPM->AddEntry(hMatchedLowPtPerB," p_{T} > 1 GeV/c ","l");
   legcHPM->AddEntry(hMatchedHighPtPerB," p_{T} >  2 GeV/c ","l");
@@ -1422,13 +1800,13 @@ TCanvas *ProcessCanvasHighPtMuons(TObjArray *triggersB, TH1 **hB, TH1 **hMatched
        
 }
 
-TH1* ProcessHisto( AliCounterCollection* counter, TString hVariable, TString hSelection, TString hName, TString xName, TString yName, Int_t color){
+TH1* ProcessHisto( AliCounterCollection* counter, TString hVariable, TString hSelection, TString hName, TString xName, TString yName, Int_t color, Bool_t empty ){
   
   
   TH1* h1 = 0x0;
   if( !counter ) return h1;
-  
-  h1 = (TH1*) counter->Draw(hVariable,hSelection);
+
+  if ( empty==kFALSE ) h1 = (TH1*) counter->Draw(hVariable,hSelection);
   if ( !h1 ) h1 = new TH1D(hName,"",10,0,10);
   else {
     h1->Sumw2();
@@ -1462,13 +1840,14 @@ TH2* ProcessHisto2D( AliCounterCollection* counter, TString hVariable, TString h
   
   return h1;
 }
+
 Bool_t GetTriggerLists(const char* triggerList, TString listFromContainer, TObjArray *triggersB, TObjArray *triggersAC, TObjArray *triggersE){
        
   //Get the trigger list from a file
   //The file should consist of a line for each trigger with the following layout:
-       //        triggernameB triggerNameAC triggerNameE
-       //     or triggernameB triggerNameA,triggerNameC triggerNameE
-       //     or triggernameB triggerNameACE notrigger
+  //        triggernameB triggerNameAC triggerNameE
+  //     or triggernameB triggerNameA,triggerNameC triggerNameE
+  //     or triggernameB triggerNameACE notrigger
   //if filename is 0, then default trigger names (pp 2011) are used
        
   if( !triggersB || !triggersAC || !triggersE) return kFALSE;
@@ -1488,7 +1867,7 @@ Bool_t GetTriggerLists(const char* triggerList, TString listFromContainer, TObjA
     // only the ones in the triggerList
     ifstream inFile(triggerList);
     if (!inFile.is_open()) {
-      Error("PlotMUONQApp","unable to open file %s", triggerList);
+      Error("PlotMuonQA","unable to open file %s", triggerList);
       return kFALSE;
     }
     
@@ -1583,7 +1962,7 @@ TString GetRunList(const char *runList, TObjArray *runs, TObjArray *runs2){
     // only the ones in the runList
     ifstream inFile(runList);
     if (!inFile.is_open()) {
-      Error("PlotMUONQApp","unable to open file %s", runList);
+      Error("PlotMuonQA","unable to open file %s", runList);
       return selectRuns;
     }
     
@@ -1592,7 +1971,7 @@ TString GetRunList(const char *runList, TObjArray *runs, TObjArray *runs2){
       currRun.ReadLine(inFile, kTRUE);
       if (currRun.IsNull()) continue;
       if (!currRun.IsDigit()) {
-       Error("PlotMUONQApp","invalid run number: %s", currRun.Data());
+       Error("PlotMuonQA","invalid run number: %s", currRun.Data());
        return selectRuns;
       }
       if(runs) runs->AddLast(new TObjString(Form("%09d", currRun.Atoi())));
@@ -1608,5 +1987,7 @@ TString GetRunList(const char *runList, TObjArray *runs, TObjArray *runs2){
     if(runs2) runs2->AddLast(new TObjString("*"));
   }
   
+       printf("selected runs from runlist %s: %s\n",runList, selectRuns.Data());
+       
   return selectRuns;
 }
diff --git a/PWG3/muon/PlotMuonQAPbPb.C b/PWG3/muon/PlotMuonQAPbPb.C
deleted file mode 100644 (file)
index dc41a3d..0000000
+++ /dev/null
@@ -1,1572 +0,0 @@
-//--------------------------------------------------------------------------\r
-// Macro for QA monitoring.\r
-//\r
-// In case it is not run with full aliroot, it needs the following libraries to compile:\r
-//  - libSTEERBase.so\r
-//  - libESD.so\r
-//  - libAOD.so\r
-//  - libANALYSIS.so\r
-//  - libANALYSISalice.so\r
-//  - libCORRFW.so\r
-//  - libPWG3muon.so\r
-//\r
-// The macro reads results of the QA task and produce monitoring plots.\r
-//\r
-// Author: Philippe Pillot - SUBATECH Nantes, Christophe Suire - IPN Orsay \r
-// and Cynthia Hadjidakis - IPN Orsay\r
-//--------------------------------------------------------------------------\r
-\r
-#if !defined(__CINT__) || defined(__MAKECINT__)\r
-\r
-#include <Riostream.h>\r
-\r
-// ROOT includes\r
-#include "TMath.h"\r
-#include "TGrid.h"\r
-#include "TFile.h"\r
-#include "TH1.h"\r
-#include "TSystem.h"\r
-#include "TStyle.h"\r
-#include "TCanvas.h"\r
-#include "TPad.h"\r
-\r
-// ALIROOT includes\r
-#include "../PWG3/base/AliCounterCollection.h"\r
-\r
-#endif\r
-\r
-//--------------------------------------------------------------------------\r
-void PlotMuonQAPbPb(const char* baseDir, const char* runList = 0x0, Bool_t selectPhysics = kFALSE)\r
-{\r
-  /// Macro for QA monitoring.\r
-  /// Examples: \r
-  /// baseDir = "alien:///alice/cern.ch/user/p/ppillot/pp7TeV/LHC10d/MuonQA/pass1/results"\r
-  /// baseDir = "results"\r
-  /// If runList != 0x0: only the given runs will be used. Otherwise use all runs found in baseDir.\r
-  /// Usage (local/grid)\r
-  /// .x PlotMuonQAPbPb.C("alien:///alice/cern.ch/user/s/suire/QAP2LHC10h/output",0,kTRUE)\r
-  \r
-\r
-  #if defined(__CINT__) && !defined(__MAKECINT__)\r
-  gSystem->Load("libTree");\r
-  gSystem->Load("libGeom");\r
-  gSystem->Load("libVMC");\r
-  gSystem->Load("libPhysics");\r
-  gSystem->Load("libSTEERBase");\r
-  gSystem->Load("libESD");\r
-  gSystem->Load("libAOD");\r
-  gSystem->Load("libANALYSIS");\r
-  gSystem->Load("libANALYSISalice");\r
-  gSystem->Load("libCORRFW");\r
-  gSystem->Load("libPWG3base");\r
-  gSystem->Load("libPWG3muon");\r
-  #endif\r
-  \r
-  // Cosmetics and configuration\r
-  gStyle->SetFillColor(10);\r
-  gStyle->SetPadGridX(kTRUE);\r
-  gStyle->SetPadGridY(kTRUE);\r
-  gStyle->SetPadRightMargin(0.01);\r
-\r
-  TString LHCPeriod = "LHC10hpass2"; \r
-\r
-  TString OutFileName = "muonQA_";  OutFileName += LHCPeriod;\r
-  TString OutFileNamePDF=  OutFileName.Data();  OutFileNamePDF+= ".pdf";\r
-  TString OutFileNamePDF_open = OutFileNamePDF.Data(); OutFileNamePDF_open += "[";  \r
-  TString OutFileNamePDF_close= OutFileNamePDF.Data(); OutFileNamePDF_close += "]";  \r
-  TString OutFileNameROOT=  OutFileName.Data();  OutFileNameROOT+= ".root";\r
-\r
-  //TString QAFileName = "QAresults.root";\r
-  TString QAFileName = "AnalysisResults.root";\r
-  TString MergedQAFileName = "Merged"; MergedQAFileName+= QAFileName.Data();\r
-\r
-  Int_t PRINTSTAT = 1; \r
-\r
-  Int_t ALIENFASTREAD = 0 ; \r
-\r
-  if (ALIENFASTREAD){ // Equivalent to the fast read option\r
-    gEnv->SetValue("XNet.ConnectTimeout",10);\r
-    gEnv->SetValue("XNet.RequestTimeout",10);\r
-    gEnv->SetValue("XNet.MaxRedirectCount",2);\r
-    gEnv->SetValue("XNet.ReconnectTimeout",10);\r
-    gEnv->SetValue("XNet.FirstConnectMaxCnt",1);\r
-  }\r
-\r
-  TH1::AddDirectory(kFALSE);\r
-  \r
-  TString alienBaseDir = baseDir;\r
-  \r
-  if (alienBaseDir.Contains("alien:") && !TGrid::Connect("alien://")) {\r
-      Error("PlotMuonQA","cannot connect to grid");\r
-      return;\r
-  }\r
-  \r
-  Float_t LabelSize = 0.03; \r
-  \r
-    \r
-  //---------------------------------- //\r
-  //          Run selection            //\r
-  //---------------------------------- //\r
-  \r
-\r
-  // list runs to be analyzed\r
-  TString selectRuns = "run:";\r
-  TObjArray runs;\r
-  runs.SetOwner();\r
-  if (runList) {\r
-    \r
-    // only the ones in the runList\r
-    ifstream inFile(runList);\r
-    if (!inFile.is_open()) {\r
-      Error("PlotMuonQAPbPb",Form("unable to open file %s", runList));\r
-      return;\r
-    }\r
-    \r
-    TString currRun;\r
-    while (!inFile.eof()) {\r
-      currRun.ReadLine(inFile, kTRUE);\r
-      if (currRun.IsNull()) continue;\r
-      if (!currRun.IsDigit()) {\r
-       Error("PlotMuonQAPbPb","invalid run number: %s", currRun.Data());\r
-       return;\r
-      }\r
-      runs.AddLast(new TObjString(Form("%09d", currRun.Atoi())));\r
-      selectRuns += Form("%s,",currRun.Data());\r
-    }\r
-    selectRuns.Remove(TString::kTrailing, ',');\r
-    \r
-    inFile.close();\r
-    \r
-  } else {\r
-    \r
-    // all runs\r
-    runs.AddLast(new TObjString("*"));\r
-    \r
-  }\r
-  \r
-  // physics selection\r
-  TString select = selectPhysics ? "selected:yes" : "";\r
-  \r
-  \r
-  //---------------------------------- //\r
-  //        plot global counter        //\r
-  //---------------------------------- //\r
-  \r
-  TFile *globalFile = TFile::Open(Form("%s/%s", baseDir,MergedQAFileName.Data()));\r
-  if (!globalFile || ! globalFile->IsOpen()) {\r
-    Error("PlotQA", Form("failed to open file: %s/%s", baseDir,MergedQAFileName.Data()));\r
-    return;\r
-  }\r
-  globalFile->Cd("MUON_QA");\r
-  \r
-\r
-\r
-  // get counters\r
-  AliCounterCollection* eventCounters = static_cast<AliCounterCollection*>(globalFile->FindObjectAny("eventCounters"));\r
-  AliCounterCollection* trackCounters = static_cast<AliCounterCollection*>(globalFile->FindObjectAny("trackCounters"));\r
-  if (!runList) selectRuns += trackCounters->GetKeyWords("run");\r
-\r
-\r
-  //declare a default canvas c1 \r
-  TString CanvasName = "c1";\r
-  TCanvas *c1 = new TCanvas(CanvasName.Data());\r
-  c1->cd();\r
-\r
-  //TString allTriggers = "trigger:CMBAC-B,CMBS2A-B,CMBS2C-B,CMBACS2-B,C0SMH-B";\r
-  //TString minBiasTrigers = "trigger:CMBAC-B,CMBS2A-B,CMBS2C-B,CMBACS2-B";\r
-  TString allTriggers = "trigger:any"; //"trigger:CMBAC-B,CMBS2A-B,CMBS2C-B,C0SMH-B";\r
-  TString minBiasTrigers = "trigger:any"; //CMBAC-B,CMBS2A-B,CMBS2C-B";\r
-  TString bckTriggers = "trigger:CMBACS2-A,CMBACS2-C,CMBS2A-A,CMBS2A-C,CMBS2C-A,CMBS2C-C,CMBAC-A,CMBAC-A,C0SMH-A,C0SMH-C";\r
-\r
-  // Histo trigger without Phys. Sel. \r
-  TH1* hAllTriggersNoPS = eventCounters->Draw("run",Form("%s/%s",allTriggers.Data(), selectRuns.Data()));\r
-  hAllTriggersNoPS->Sumw2();\r
-  Int_t NumOfAllTriggersNoPS = hAllTriggersNoPS->Integral();\r
-  TH1* hAllTriggerslowNoPS = eventCounters->Draw("run",Form("v0mult:low/%s/%s",allTriggers.Data(), selectRuns.Data()));\r
-  hAllTriggerslowNoPS->Sumw2();\r
-  TH1* hAllTriggershighNoPS = eventCounters->Draw("run",Form("v0mult:high/%s/%s",allTriggers.Data(), selectRuns.Data()));\r
-  hAllTriggershighNoPS->Sumw2();\r
-  TH1* hMBBNoPS = eventCounters->Draw("run",Form("v0mult:low,int,high/%s/%s",minBiasTrigers.Data(), selectRuns.Data()));\r
-  hMBBNoPS->Sumw2();\r
-  Int_t NumOfMBBNoPS = hMBBNoPS->Integral();\r
-  TH1* hMBBlowNoPS = eventCounters->Draw("run",Form("v0mult:low/%s/%s",minBiasTrigers.Data(), selectRuns.Data()));\r
-  hMBBlowNoPS->Sumw2();\r
-  Int_t NumOfMBBlowNoPS = hMBBlowNoPS->Integral();\r
-  TH1* hMBBhighNoPS = eventCounters->Draw("run",Form("v0mult:high/%s/%s",minBiasTrigers.Data(), selectRuns.Data()));\r
-  hMBBhighNoPS->Sumw2();\r
-  Int_t NumOfMBBhighNoPS = hMBBhighNoPS->Integral();\r
-  //TH1* hCMUS1BNoPS = eventCounters->Draw("run",Form("trigger:CMUS1B/%s", selectRuns.Data()));\r
-  //hCMUS1BNoPS->Sumw2();\r
-  //Int_t NumOfCMUS1BNoPS = hCMUS1BNoPS->Integral();\r
-  //TH1* hCSH1BNoPS = eventCounters->Draw("run",Form("trigger:CSH1B/%s", selectRuns.Data()));\r
-  //hCSH1BNoPS->Sumw2();\r
-  //Int_t NumOfCSH1BNoPS = hCSH1BNoPS->Integral();\r
-\r
-  TH1* hBckTriggersNoPS = eventCounters->Draw("run",Form("v0mult:low,int,high/%s/%s",bckTriggers.Data(), selectRuns.Data()));\r
-  hBckTriggersNoPS->Sumw2();                                 \r
-                                             \r
-\r
-  // Histo trigger with Phys. Sel. \r
-  TH1* hAllTriggersWithPS = eventCounters->Draw("run",Form("%s/%s/selected:yes",allTriggers.Data(), selectRuns.Data()));\r
-  hAllTriggersWithPS->Sumw2();\r
-  Int_t  NumOfAllTriggersWithPS = hAllTriggersWithPS->Integral();\r
-  TH1* hAllTriggersLowWithPS = eventCounters->Draw("run",Form("v0mult:low/%s/%s/selected:yes",allTriggers.Data(), selectRuns.Data()));\r
-  hAllTriggersWithPS->Sumw2();\r
-  TH1* hAllTriggersHighWithPS = eventCounters->Draw("run",Form("v0mult:high/%s/%s/selected:yes",allTriggers.Data(), selectRuns.Data()));\r
-  hAllTriggersWithPS->Sumw2();\r
-  TH1* hMBBWithPS = eventCounters->Draw("run",Form("v0mult:low,int,high/%s/%s/selected:yes",minBiasTrigers.Data(), selectRuns.Data()));\r
-  hMBBWithPS->Sumw2();\r
-  Int_t NumOfMBBWithPS = hMBBWithPS->Integral();\r
-  TH1* hMBBlowWithPS = eventCounters->Draw("run",Form("v0mult:low/%s/%s/selected:yes",minBiasTrigers.Data(), selectRuns.Data()));\r
-  hMBBlowWithPS->Sumw2();\r
-  Int_t NumOfMBBlowWithPS = hMBBlowWithPS->Integral();\r
-  TH1* hMBBhighWithPS = eventCounters->Draw("run",Form("v0mult:high/%s/%s/selected:yes",minBiasTrigers.Data(), selectRuns.Data()));\r
-  hMBBhighWithPS->Sumw2();\r
-  Int_t NumOfMBBhighWithPS = hMBBhighWithPS->Integral();\r
-  \r
-  // Histo trigger : Phys. Sel.  is selected or not depending on the macro arguments\r
-  TH1* hAllTriggers = eventCounters->Draw("run",Form("%s/%s/%s",allTriggers.Data(), selectRuns.Data(), select.Data()));\r
-  hAllTriggers->Sumw2();\r
-  TH1* hMBB = eventCounters->Draw("run",Form("v0mult:low,int,high/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hMBB->Sumw2();\r
-  TH1* hMBBlow = eventCounters->Draw("run",Form("v0mult:low/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hMBBlow->Sumw2();\r
-  TH1* hMBBhigh = eventCounters->Draw("run",Form("v0mult:high/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hMBBhigh->Sumw2();\r
-\r
-  // Histo tracking : Phys. Sel.  is selected or not depending on the macro arguments\r
-  TH1* hAllTracksMBB = trackCounters->Draw("run",Form("v0mult:low,int,high/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hAllTracksMBB->Sumw2();\r
-  TH1* hTriggerMBB = trackCounters->Draw("run",Form("v0mult:low,int,high/track:triggeronly/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hTriggerMBB->Sumw2();\r
-  TH1* hTrackerMBB = trackCounters->Draw("run",Form("v0mult:low,int,high/track:trackeronly/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hTrackerMBB->Sumw2();\r
-  TH1* hMatchedMBB = trackCounters->Draw("run",Form("v0mult:low,int,high/track:matched/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hMatchedMBB->Sumw2();\r
-  TH1* hAllTracksMBBlow = trackCounters->Draw("run",Form("v0mult:low/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hAllTracksMBBlow->Sumw2();\r
-  TH1* hTriggerMBBlow = trackCounters->Draw("run",Form("v0mult:low/track:triggeronly/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hTriggerMBBlow->Sumw2();\r
-  TH1* hTrackerMBBlow = trackCounters->Draw("run",Form("v0mult:low/track:trackeronly/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hTrackerMBBlow->Sumw2();\r
-  TH1* hMatchedMBBlow = trackCounters->Draw("run",Form("v0mult:low/track:matched/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hMatchedMBBlow->Sumw2();\r
-  TH1* hAllTracksMBBhigh = trackCounters->Draw("run",Form("v0mult:high/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hAllTracksMBBhigh->Sumw2();\r
-  TH1* hTriggerMBBhigh = trackCounters->Draw("run",Form("v0mult:high/track:triggeronly/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hTriggerMBBhigh->Sumw2();\r
-  TH1* hTrackerMBBhigh = trackCounters->Draw("run",Form("v0mult:high/track:trackeronly/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hTrackerMBBhigh->Sumw2();\r
-  TH1* hMatchedMBBhigh = trackCounters->Draw("run",Form("v0mult:high/track:matched/%s/%s/%s",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hMatchedMBBhigh->Sumw2();\r
-  \r
-  TH1* hMatchedLowPtMBB = trackCounters->Draw("run",Form("v0mult:low,int,high/track:matched/acc:in/%s/%s/%s/pt:low",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hMatchedLowPtMBB->Sumw2();\r
-  TH1* hMatchedHighPtMBB = trackCounters->Draw("run",Form("v0mult:low,int,high/track:matched/acc:in/%s/%s/%s/pt:high",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hMatchedHighPtMBB->Sumw2();\r
-  TH1* hMatchedLowPtMBBlow = trackCounters->Draw("run",Form("v0mult:low/track:matched/acc:in/%s/%s/%s/pt:low",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hMatchedLowPtMBBlow->Sumw2();\r
-  TH1* hMatchedHighPtMBBlow = trackCounters->Draw("run",Form("v0mult:low/track:matched/acc:in/%s/%s/%s/pt:high",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hMatchedHighPtMBBlow->Sumw2();\r
-  TH1* hMatchedLowPtMBBhigh = trackCounters->Draw("run",Form("v0mult:high/track:matched/acc:in/%s/%s/%s/pt:low",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hMatchedLowPtMBBhigh->Sumw2();\r
-  TH1* hMatchedHighPtMBBhigh = trackCounters->Draw("run",Form("v0mult:high/track:matched/acc:in/%s/%s/%s/pt:high",minBiasTrigers.Data(), selectRuns.Data(), select.Data()));\r
-  hMatchedHighPtMBBhigh->Sumw2();\r
-  \r
-  \r
-  // for MBB only, low and high mult\r
-  TH1 *hPosMatchedMBBlow =  trackCounters->Draw("run",Form("v0mult:low/track:matched/charge:pos/acc:in/%s/%s/%s",minBiasTrigers.Data(),select.Data(),selectRuns.Data()));\r
-  hPosMatchedMBBlow->Sumw2();\r
-  TH1 *hNegMatchedMBBlow=  trackCounters->Draw("run",Form("v0mult:low/track:matched/charge:neg/acc:in/%s/%s/%s",minBiasTrigers.Data(),select.Data(),selectRuns.Data())); \r
-  hNegMatchedMBBlow->Sumw2();\r
-  TH1 *hAllMatchedMBBlow=  trackCounters->Draw("run",Form("v0mult:low/track:matched/acc:in/%s/%s/%s",minBiasTrigers.Data(),select.Data(),selectRuns.Data())); \r
-  hAllMatchedMBBlow->Sumw2();\r
-  TH1 *hPosMatchedMBBhigh =  trackCounters->Draw("run",Form("v0mult:high/track:matched/charge:pos/acc:in/%s/%s/%s",minBiasTrigers.Data(),select.Data(),selectRuns.Data()));\r
-  hPosMatchedMBBhigh->Sumw2();\r
-  TH1 *hNegMatchedMBBhigh=  trackCounters->Draw("run",Form("v0mult:high/track:matched/charge:neg/acc:in/%s/%s/%s",minBiasTrigers.Data(),select.Data(),selectRuns.Data())); \r
-  hNegMatchedMBBhigh->Sumw2();\r
-  TH1 *hAllMatchedMBBhigh=  trackCounters->Draw("run",Form("v0mult:high/track:matched/acc:in/%s/%s/%s",minBiasTrigers.Data(),select.Data(),selectRuns.Data())); \r
-  hAllMatchedMBBhigh->Sumw2();\r
-  \r
-\r
-  TH1* hAll = eventCounters->Draw("trigger","run","run:any/selected:yes");\r
-  hAll->Draw("TEXT");\r
-  \r
-\r
-  //===================================================================================\r
-  // Put all plots in a pdf file, easier to publish (Twiki)\r
-  c1->Print(OutFileNamePDF_open.Data());\r
-\r
-  TFile *rootFileOut = TFile::Open(OutFileNameROOT.Data(),"RECREATE");\r
-  \r
-  //===================================================================================\r
-  // new canvas of the statistic wrt trigger w/  physics selection\r
-  CanvasName =  LHCPeriod.Data() ; \r
-  CanvasName += "_StatByTrigger"; \r
-  TCanvas *cStatByTrigger = new TCanvas(CanvasName.Data(),"cStatByTrigger",1200,900);\r
-  cStatByTrigger->SetTopMargin(0.05);\r
-  cStatByTrigger->SetRightMargin(0.01);\r
-  cStatByTrigger->SetGridy(1);\r
-  cStatByTrigger->SetLogy(1);\r
-  cStatByTrigger->cd();\r
-\r
-  //hAllTriggersWithPS->SetLabelSize(LabelSize);\r
-  //hAllTriggersWithPS->SetTitle("Statistic per trigger  w/  Phys. Sel."); \r
-  hAllTriggersWithPS->SetTitle(""); \r
-  hAllTriggersWithPS->SetLineWidth(2);\r
-  hAllTriggersWithPS->SetMinimum(10);\r
-  hAllTriggersWithPS->SetLabelSize(LabelSize);\r
-\r
-  hAllTriggersWithPS->Draw("E");\r
-  hMBBWithPS->SetLineWidth(2);\r
-  hMBBWithPS->SetLineColor(kBlue);\r
-  hMBBWithPS->Draw("ESAME");\r
-  hMBBlowWithPS->SetMarkerStyle(27);\r
-  hMBBlowWithPS->SetMarkerSize(2);\r
-  hMBBlowWithPS->SetMarkerColor(kBlue);\r
-  hMBBlowWithPS->SetLineColor(kBlue);\r
-  hMBBlowWithPS->Draw("ESAME");\r
-  hMBBhighWithPS->SetMarkerStyle(24);\r
-  hMBBhighWithPS->SetMarkerSize(2);\r
-  hMBBhighWithPS->SetMarkerColor(kBlue);\r
-  hMBBhighWithPS->SetLineColor(kBlue);\r
-  hMBBhighWithPS->Draw("ESAME");\r
-\r
-\r
-  TLegend* legcSBT = new TLegend(0.12,0.15,0.42,0.3);\r
-  legcSBT->SetHeader("Trigger Statistic w/ Phys. Sel.");\r
-  legcSBT->AddEntry(hAllTriggersWithPS,"All collisions triggers","l");\r
-  legcSBT->AddEntry(hMBBWithPS,"Min Bias [0-80]% from V0 amplitude","l");\r
-  legcSBT->AddEntry(hMBBlowWithPS,"MB low multiplicity events [60-80]%","p"); \r
-  legcSBT->AddEntry(hMBBhighWithPS,"MB high multiplicity events [0-10]%","p"); \r
-  legcSBT->Draw("same");\r
-\r
-  cStatByTrigger->Print(OutFileNamePDF.Data());\r
-  cStatByTrigger->Write();\r
-\r
-\r
-  //===================================================================================\r
-  // new canvas with the relative content of each trigger w/ and w/o  physics selection\r
-  TH1 *ratioMBB = static_cast<TH1*>(hMBBWithPS->Clone("ratioMBB"));\r
-  ratioMBB->Divide(hMBBNoPS);\r
-  ratioMBB->SetLineColor(kBlack);\r
-  ratioMBB->SetLineWidth(2);\r
-  TH1 *ratioMBBlow = static_cast<TH1*>(hMBBlowWithPS->Clone("ratioMBBlow"));\r
-  ratioMBBlow->Divide(hMBBlowNoPS);\r
-  ratioMBBlow->SetLineColor(kBlue);\r
-  ratioMBBlow->SetLineWidth(2);\r
-  ratioMBBlow->SetMarkerSize(0);\r
-  ratioMBBlow->SetMarkerColor(kBlue);\r
-  TH1 *ratioMBBhigh = static_cast<TH1*>(hMBBhighWithPS->Clone("ratioMBBhigh"));\r
-  ratioMBBhigh->Divide(hMBBhighNoPS);\r
-  ratioMBBhigh->SetLineColor(kRed);\r
-  ratioMBBhigh->SetLineWidth(2);\r
-  ratioMBBhigh->SetMarkerSize(0);\r
-  ratioMBBhigh->SetMarkerColor(kRed);\r
-\r
-\r
-  TH1 *ratioMBBNoPS = static_cast<TH1*>(hMBBNoPS->Clone("ratioMBBNoPS"));\r
-  ratioMBBNoPS->Divide(hMBBNoPS);\r
-  ratioMBBNoPS->SetLineColor(kBlack);\r
-  ratioMBBNoPS->SetLineWidth(0);\r
-  ratioMBBNoPS->SetLineStyle(2);\r
-  ratioMBBNoPS->SetMarkerColor(kBlack);\r
-  ratioMBBNoPS->SetMarkerStyle(24);\r
-  ratioMBBNoPS->SetMarkerSize(1);\r
-  TH1 *ratioMBBlowNoPS = static_cast<TH1*>(hMBBlowNoPS->Clone("ratioMBBlowNoPS"));\r
-  ratioMBBlowNoPS->Divide(hMBBlowNoPS);\r
-  ratioMBBlowNoPS->SetLineColor(kBlue);\r
-  ratioMBBlowNoPS->SetLineWidth(0);\r
-  ratioMBBlowNoPS->SetLineStyle(2);\r
-  ratioMBBlowNoPS->SetMarkerColor(kBlue);\r
-  ratioMBBlowNoPS->SetMarkerStyle(24);\r
-  ratioMBBlowNoPS->SetMarkerSize(1);\r
-  TH1 *ratioMBBhighNoPS = static_cast<TH1*>(hMBBhighNoPS->Clone("ratioMBBhighNoPS"));\r
-  ratioMBBhighNoPS->Divide(hMBBhighNoPS);\r
-  ratioMBBhighNoPS->SetLineColor(kRed);\r
-  ratioMBBhighNoPS->SetLineWidth(0);\r
-  ratioMBBhighNoPS->SetLineStyle(2);\r
-  ratioMBBhighNoPS->SetMarkerColor(kRed);\r
-  ratioMBBhighNoPS->SetMarkerStyle(24);\r
-  ratioMBBhighNoPS->SetMarkerSize(1);\r
-  \r
-\r
-  TH1 *ratioBck = static_cast<TH1*>(hBckTriggersNoPS->Clone("ratioBck"));\r
-  ratioBck->Divide(hMBBNoPS);\r
-  ratioBck->SetLineColor(kBlack);\r
-  ratioBck->SetLineWidth(3);\r
-  ratioBck->SetLineStyle(3);\r
-  ratioBck->Scale(10);\r
-\r
-  CanvasName =  LHCPeriod.Data() ; \r
-  CanvasName += "_RelativeTriggerContent"; \r
-  TCanvas *cRelativeTriggerContent = new TCanvas(CanvasName.Data(),"cRelativeTriggerContent",1200,900);\r
-  cRelativeTriggerContent->SetTopMargin(0.05);\r
-  cRelativeTriggerContent->SetRightMargin(0.01);\r
-  cRelativeTriggerContent->SetGridy(1);\r
-  //cRelativeTriggerContent->SetLogy(1);\r
-  cRelativeTriggerContent->cd();\r
-\r
-  ratioMBB->SetMaximum(1.0);\r
-  ratioMBB->SetMinimum(0.05);\r
-  ratioMBB->SetTitle("");\r
-  ratioMBB->SetLabelSize(LabelSize);\r
-  ratioMBB->LabelsOption("v");\r
-  ratioMBB->GetYaxis()->SetTitle("Relative trigger content w/ and w/o Phys. Sel."); \r
-\r
-  ratioMBB->Draw("E");\r
-  ratioMBBlow->Draw("ESAME");\r
-  ratioMBBhigh->Draw("ESAME");\r
-  ratioMBBNoPS->Draw("EPSAME");\r
-  ratioMBBlowNoPS->Draw("EPSAME");\r
-  ratioMBBhighNoPS->Draw("EPSAME");\r
-  ratioBck->Draw("EPSAME");\r
-\r
-  TLegend* legcRTC = new TLegend(0.4,0.25,0.70,0.45);\r
-  legcRTC->SetHeader("Physics Selection");\r
-  legcRTC->AddEntry(".","applied :","");\r
-  legcRTC->AddEntry(ratioMBB,"MBB","l");\r
-  legcRTC->AddEntry(ratioMBBlow,"MBB low mult.","l");\r
-  legcRTC->AddEntry(ratioMBBhigh,"MBB high mult.","l");\r
-  legcRTC->AddEntry(".","not applied :","");\r
-  legcRTC->AddEntry(ratioMBBNoPS,"MBB","p");\r
-  legcRTC->AddEntry(ratioMBBlowNoPS,"MBB low mult.","p");\r
-  legcRTC->AddEntry(ratioMBBhighNoPS,"MBB high mult.","p");\r
-  legcRTC->AddEntry(ratioBck,"Background (x10)","l");\r
-  legcRTC->Draw("same");\r
-  \r
-  cRelativeTriggerContent->Print(OutFileNamePDF.Data());\r
-  cRelativeTriggerContent->Write();\r
-\r
-\r
-  //===================================================================================\r
-  // new canvas with the relative ratio of multiplicity bin after physic selection\r
-  TH1 *relratioMBBlow = static_cast<TH1*>(hMBBlowWithPS->Clone("relratioMBBlow"));\r
-  relratioMBBlow->Divide(hMBBWithPS);\r
-  relratioMBBlow->SetLineColor(kBlue);\r
-  relratioMBBlow->SetLineWidth(2);\r
-  relratioMBBlow->SetMarkerSize(0);\r
-  TH1 *relratioMBBhigh = static_cast<TH1*>(hMBBhighWithPS->Clone("relratioMBBhigh"));\r
-  relratioMBBhigh->Divide(hMBBWithPS);\r
-  relratioMBBhigh->SetLineColor(kRed);\r
-  relratioMBBhigh->SetLineWidth(2);\r
-  relratioMBBhigh->SetMarkerSize(0);\r
-\r
-\r
-  TH1 *relratioMBBlowNoPS = static_cast<TH1*>(hMBBlowNoPS->Clone("relratioMBBlowNoPS"));\r
-  relratioMBBlowNoPS->Divide(hMBBNoPS);\r
-  relratioMBBlowNoPS->SetLineColor(kBlue);\r
-  relratioMBBlowNoPS->SetLineWidth(0);\r
-  relratioMBBlowNoPS->SetLineStyle(2);\r
-  relratioMBBlowNoPS->SetMarkerColor(kBlue);\r
-  relratioMBBlowNoPS->SetMarkerStyle(24);\r
-  relratioMBBlowNoPS->SetMarkerSize(1);\r
-  TH1 *relratioMBBhighNoPS = static_cast<TH1*>(hMBBhighNoPS->Clone("relratioMBBhighNoPS"));\r
-  relratioMBBhighNoPS->Divide(hMBBNoPS);\r
-  relratioMBBhighNoPS->SetLineColor(kRed);\r
-  relratioMBBhighNoPS->SetLineWidth(0);\r
-  relratioMBBhighNoPS->SetLineStyle(2);\r
-  relratioMBBhighNoPS->SetMarkerColor(kRed);\r
-  relratioMBBhighNoPS->SetMarkerStyle(24);\r
-  relratioMBBhighNoPS->SetMarkerSize(1);\r
-  \r
-  CanvasName =  LHCPeriod.Data() ; \r
-  CanvasName += "_CentralityPercentileCheck"; \r
-  TCanvas *cCentralityPercentileCheck = new TCanvas(CanvasName.Data(),"CentralityPercentileCheck",1200,900);\r
-  cCentralityPercentileCheck->SetTopMargin(0.05);\r
-  cCentralityPercentileCheck->SetRightMargin(0.01);\r
-  cCentralityPercentileCheck->SetGridy(1);\r
-  //cCentralityPercentileCheck->SetLogy(1);\r
-  cCentralityPercentileCheck->cd();\r
-\r
-  relratioMBBlow->Scale(0.8);\r
-  relratioMBBhigh->Scale(0.8);\r
-  relratioMBBlowNoPS->Scale(0.8);\r
-  relratioMBBhighNoPS->Scale(0.8);\r
-\r
-  relratioMBBlow->SetMaximum(0.3);\r
-  relratioMBBlow->SetMinimum(0.01);\r
-  relratioMBBlow->SetTitle("");\r
-  relratioMBBlow->SetLabelSize(LabelSize);\r
-  relratioMBBlow->GetYaxis()->SetTitle("Centrality percentile check"); \r
-\r
-  relratioMBBlow->Draw();\r
-  relratioMBBhigh->Draw("ESAME");\r
-  relratioMBBlowNoPS->Draw("EPSAME");\r
-  relratioMBBhighNoPS->Draw("EPSAME");\r
-\r
-  TLegend* legcCPC = new TLegend(0.12,0.15,0.42,0.30);\r
-  legcCPC->SetHeader("Physics Selection");\r
-  legcCPC->AddEntry(".","applied :","");\r
-  legcCPC->AddEntry(relratioMBBlow,"MBB low mult.","l");\r
-  legcCPC->AddEntry(relratioMBBhigh,"MBB high mult.","l");\r
-  legcCPC->AddEntry(".","not applied :","");\r
-  legcCPC->AddEntry(relratioMBBlowNoPS,"MBB low mult.","p");\r
-  legcCPC->AddEntry(relratioMBBhighNoPS,"MBB high mult.","p");\r
-  legcCPC->Draw("same");\r
-  \r
-  cCentralityPercentileCheck->Print(OutFileNamePDF.Data());\r
-  cCentralityPercentileCheck->Write();\r
-\r
-\r
-  //====================================================\r
-  // Draw ratio of tracks over MBB versus run \r
-  TH1* hTrackerPerMBB= static_cast<TH1*>(hTrackerMBB->Clone("hTrackerPerMBB"));\r
-  hTrackerPerMBB->Divide(hMBB);\r
-  hTrackerPerMBB->SetLineWidth(2);\r
-  hTrackerPerMBB->SetLineColor(kRed);\r
-\r
-  TH1* hTriggerPerMBB= static_cast<TH1*>(hTriggerMBB->Clone("hTriggerPerMBB"));\r
-  hTriggerPerMBB->Divide(hMBB);\r
-  hTriggerPerMBB->SetLineWidth(2);\r
-  hTriggerPerMBB->SetLineColor(kBlue);\r
-\r
-\r
-  TH1* hMatchedPerMBB= static_cast<TH1*>(hMatchedMBB->Clone("hMatchedPerMBB"));\r
-  hMatchedPerMBB->Divide(hMBB);\r
-  hMatchedPerMBB->SetLineWidth(2);\r
-  hMatchedPerMBB->SetLineColor(kViolet);\r
-\r
-\r
-  TH1* hAllTracksPerMBB= static_cast<TH1*>(hAllTracksMBB->Clone("hAllTracksPerMBB"));\r
-  hAllTracksPerMBB->Divide(hMBB);\r
-  hAllTracksPerMBB->SetLineWidth(3);\r
-  hAllTracksPerMBB->SetLineColor(kBlack);\r
-\r
-\r
-  CanvasName =  LHCPeriod.Data() ; \r
-  CanvasName += "_RatioTrackTypesMBB"; \r
-  TCanvas *cRatioTrackTypesMBB = new TCanvas(CanvasName.Data(),"cRatioTrackTypesMBB",1200,900);\r
-  cRatioTrackTypesMBB->SetRightMargin(0.01);\r
-  cRatioTrackTypesMBB->SetGridy(1);\r
-  //cRatioTrackTypesMBB->SetLogy(1);\r
-  cRatioTrackTypesMBB->cd();\r
-\r
-  hAllTracksPerMBB->SetTitle("Ratio (Number of Tracks)/MBB for [0-80]% centrality");\r
-  hAllTracksPerMBB->SetMaximum(4);\r
-  hAllTracksPerMBB->SetMinimum(0.1);\r
-  hAllTracksPerMBB->SetLabelSize(LabelSize);\r
-  hAllTracksPerMBB->Draw("E");\r
-\r
-  hTrackerPerMBB->Draw("Esame");\r
-  hMatchedPerMBB->Draw("Esame");\r
-  hTriggerPerMBB->Draw("Esame");\r
-\r
-  TLegend* legcTTMBB = new TLegend(0.15,0.50,0.35,0.70);\r
-  legcTTMBB->AddEntry(hAllTracksPerMBB,"All tracks","l");\r
-  legcTTMBB->AddEntry(hTrackerPerMBB,"Tracking (only) tracks","l");\r
-  legcTTMBB->AddEntry(hMatchedPerMBB,"Matched tracks","l");\r
-  legcTTMBB->AddEntry(hTriggerPerMBB,"Trigger (only) tracks","l");\r
-  legcTTMBB->Draw("same");\r
-\r
-  cRatioTrackTypesMBB->Print(OutFileNamePDF.Data());\r
-  cRatioTrackTypesMBB->Write();\r
-\r
-  //==========================================================================\r
-  // Draw ratio of tracks over MBB versus runs and low and high multiplicities \r
-\r
-  TH1* hTrackerPerMBBlow= static_cast<TH1*>(hTrackerMBBlow->Clone("hTrackerPerMBBlow"));\r
-  hTrackerPerMBBlow->Divide(hMBBlow);\r
-  hTrackerPerMBBlow->SetLineWidth(2);\r
-  hTrackerPerMBBlow->SetLineStyle(2);\r
-  hTrackerPerMBBlow->SetLineColor(kRed);\r
-  hTrackerPerMBBlow->SetMarkerColor(kRed);\r
-  hTrackerPerMBBlow->SetMarkerSize(2);\r
-  hTrackerPerMBBlow->SetMarkerStyle(27);\r
-  TH1* hTrackerPerMBBhigh= static_cast<TH1*>(hTrackerMBBhigh->Clone("hTrackerPerMBBhigh"));\r
-  hTrackerPerMBBhigh->Divide(hMBBhigh);\r
-  hTrackerPerMBBhigh->SetLineWidth(2);\r
-  hTrackerPerMBBhigh->SetLineStyle(2);\r
-  hTrackerPerMBBhigh->SetLineColor(kRed);\r
-  hTrackerPerMBBhigh->SetMarkerColor(kRed);\r
-  hTrackerPerMBBhigh->SetMarkerSize(2);\r
-  hTrackerPerMBBhigh->SetMarkerStyle(24);\r
-\r
-\r
-  TH1* hTriggerPerMBBlow= static_cast<TH1*>(hTriggerMBBlow->Clone("hTriggerPerMBBlow"));\r
-  hTriggerPerMBBlow->Divide(hMBBlow);\r
-  hTriggerPerMBBlow->SetLineWidth(2);\r
-  hTriggerPerMBBlow->SetLineStyle(2);\r
-  hTriggerPerMBBlow->SetLineColor(kBlue);\r
-  hTriggerPerMBBlow->SetMarkerColor(kBlue);\r
-  hTriggerPerMBBlow->SetMarkerSize(2);\r
-  hTriggerPerMBBlow->SetMarkerStyle(27);\r
-  TH1* hTriggerPerMBBhigh= static_cast<TH1*>(hTriggerMBBhigh->Clone("hTriggerPerMBBhigh"));\r
-  hTriggerPerMBBhigh->Divide(hMBBhigh);\r
-  hTriggerPerMBBhigh->SetLineWidth(2);\r
-  hTriggerPerMBBhigh->SetLineStyle(2);\r
-  hTriggerPerMBBhigh->SetLineColor(kBlue);\r
-  hTriggerPerMBBhigh->SetMarkerColor(kBlue);\r
-  hTriggerPerMBBhigh->SetMarkerSize(2);\r
-  hTriggerPerMBBhigh->SetMarkerStyle(24);\r
-\r
-\r
-  TH1* hMatchedPerMBBlow= static_cast<TH1*>(hMatchedMBBlow->Clone("hMatchedPerMBBlow"));\r
-  hMatchedPerMBBlow->Divide(hMBBlow);\r
-  hMatchedPerMBBlow->SetLineWidth(2);\r
-  hMatchedPerMBBlow->SetLineStyle(2);\r
-  hMatchedPerMBBlow->SetLineColor(kViolet);\r
-  hMatchedPerMBBlow->SetMarkerColor(kViolet);\r
-  hMatchedPerMBBlow->SetMarkerSize(2);\r
-  hMatchedPerMBBlow->SetMarkerStyle(27);\r
-  TH1* hMatchedPerMBBhigh= static_cast<TH1*>(hMatchedMBBhigh->Clone("hMatchedPerMBBhigh"));\r
-  hMatchedPerMBBhigh->Divide(hMBBhigh);\r
-  hMatchedPerMBBhigh->SetLineWidth(2);\r
-  hMatchedPerMBBhigh->SetLineStyle(2);\r
-  hMatchedPerMBBhigh->SetLineColor(kViolet);\r
-  hMatchedPerMBBhigh->SetMarkerColor(kViolet);\r
-  hMatchedPerMBBhigh->SetMarkerSize(2);\r
-  hMatchedPerMBBhigh->SetMarkerStyle(24);\r
-\r
-\r
-  TH1* hAllTracksPerMBBlow= static_cast<TH1*>(hAllTracksMBBlow->Clone("hAllTracksPerMBBlow"));\r
-  hAllTracksPerMBBlow->Divide(hMBBlow);\r
-  hAllTracksPerMBBlow->SetLineWidth(2);\r
-  hAllTracksPerMBBlow->SetLineStyle(2);\r
-  hAllTracksPerMBBlow->SetLineColor(kBlack);\r
-  hAllTracksPerMBBlow->SetMarkerColor(kBlack);\r
-  hAllTracksPerMBBlow->SetMarkerSize(2);\r
-  hAllTracksPerMBBlow->SetMarkerStyle(27);\r
-  TH1* hAllTracksPerMBBhigh= static_cast<TH1*>(hAllTracksMBBhigh->Clone("hAllTracksPerMBBhigh"));\r
-  hAllTracksPerMBBhigh->Divide(hMBBhigh);\r
-  hAllTracksPerMBBhigh->SetLineWidth(2);\r
-  hAllTracksPerMBBhigh->SetLineStyle(2);\r
-  hAllTracksPerMBBhigh->SetLineColor(kBlack);\r
-  hAllTracksPerMBBhigh->SetMarkerColor(kBlack);\r
-  hAllTracksPerMBBhigh->SetMarkerSize(2);\r
-  hAllTracksPerMBBhigh->SetMarkerStyle(24);\r
-\r
-\r
-  CanvasName =  LHCPeriod.Data() ; \r
-  CanvasName += "_RatioTrackTypesMBBVsMult"; \r
-  TCanvas *cRatioTrackTypesMBBVsMult = new TCanvas(CanvasName.Data(),"cRatioTrackTypesMBBVsMult",1200,900);\r
-  cRatioTrackTypesMBBVsMult->SetRightMargin(0.01);\r
-  cRatioTrackTypesMBBVsMult->SetGridy(1);\r
-  //cRatioTrackTypesMBBVsMult->SetLogy(1);\r
-\r
-\r
-  cRatioTrackTypesMBBVsMult->Divide(1,2);\r
-\r
-\r
-  cRatioTrackTypesMBBVsMult->cd(1);\r
-\r
-  hAllTracksPerMBBlow->SetTitle("Ratio (Number of Tracks)/MBB low mult");\r
-  hAllTracksPerMBBlow->SetMaximum(0.30);\r
-  hAllTracksPerMBBlow->SetMinimum(0.001);\r
-  hAllTracksPerMBBlow->SetLabelSize(LabelSize);\r
-  hAllTracksPerMBBlow->Draw("E");\r
-  hTrackerPerMBBlow->Draw("Esame");\r
-  hTriggerPerMBBlow->Draw("Esame");\r
-  hMatchedPerMBBlow->Draw("Esame");\r
-\r
-  TLegend* legcTTMBBlow = new TLegend(0.40,0.8,0.60,1.);\r
-  legcTTMBBlow->AddEntry(hAllTracksPerMBBlow,"All tracks","p");\r
-  legcTTMBBlow->AddEntry(hTrackerPerMBBlow,"Tracking (only) tracks","p");\r
-  legcTTMBBlow->AddEntry(hMatchedPerMBBlow,"Matched tracks","p");\r
-  legcTTMBBlow->AddEntry(hTriggerPerMBBlow,"Trigger (only) tracks","p");\r
-  legcTTMBBlow->Draw("same");\r
\r
-\r
-  cRatioTrackTypesMBBVsMult->cd(2);\r
-  hAllTracksPerMBBhigh->SetTitle("Ratio (Number of Tracks)/MBB high mult");\r
-  hAllTracksPerMBBhigh->SetMaximum(15);\r
-  hAllTracksPerMBBhigh->SetMinimum(0.01);\r
-  hAllTracksPerMBBhigh->SetLabelSize(LabelSize);\r
-  hAllTracksPerMBBhigh->Draw("E");\r
-  hTrackerPerMBBhigh->Draw("Esame");\r
-  hTriggerPerMBBhigh->Draw("Esame");\r
-  hMatchedPerMBBhigh->Draw("Esame");\r
-\r
-\r
-\r
-  TLegend* legcTTMBBhigh = new TLegend(0.40,0.8,0.60,1.);\r
-  legcTTMBBhigh->AddEntry(hAllTracksPerMBBhigh,"All tracks","p");\r
-  legcTTMBBhigh->AddEntry(hTrackerPerMBBhigh,"Tracking (only) tracks","p");\r
-  legcTTMBBhigh->AddEntry(hMatchedPerMBBhigh,"Matched tracks","p");\r
-  legcTTMBBhigh->AddEntry(hTriggerPerMBBhigh,"Trigger (only) tracks","p");\r
-  legcTTMBBhigh->Draw("same");\r
-    \r
-\r
-  //   cRatioTrackTypesMBBVsMult->cd();\r
-  //   TPaveText pt1(0.2,0.2,0.7,0.9);\r
-  //   TText* t1=pt1.AddText("All tracks (tracking-only + trigger-only + matched)");\r
-  //   t1->SetTextColor(kBlack);\r
-  //   pt1.Draw();\r
-  //   break;\r
-\r
-  cRatioTrackTypesMBBVsMult->Print(OutFileNamePDF.Data());\r
-  cRatioTrackTypesMBBVsMult->Write();\r
-\r
-\r
-  //===========================================\r
-  // draw ratio of track (summed, i.e all trigger=(matched+trigger-only)) for MB  versus run for low mult\r
-  CanvasName =  LHCPeriod.Data() ; \r
-  CanvasName += "_TrackMultBBlow";   \r
-  TCanvas* cTrackMultBBlow = new TCanvas("cTrackMultBBlow","cTrackMultBBlow",1200,900);\r
-  // must be applied on the pads created by  divide\r
-  cTrackMultBBlow->Divide(1,2);\r
-  cTrackMultBBlow->cd(1);\r
-\r
-  TH1* hSumTriggerOverMBBlow = static_cast<TH1*>(hTriggerMBBlow->Clone("hSumTriggerOverMBBlow"));\r
-  hSumTriggerOverMBBlow->Add(hMatchedMBBlow);\r
-  hSumTriggerOverMBBlow->Divide(hMBBlow);\r
-  hSumTriggerOverMBBlow->SetTitle("Sum of trigger tracks (matched+trigger-only) in MBB events / # MBB events in low mult.");\r
-  //hSumTriggerOverMBBlow->LabelsOption("u");\r
-  hSumTriggerOverMBBlow->SetLabelSize(LabelSize);\r
-  hSumTriggerOverMBBlow->SetLineWidth(2);\r
-  hSumTriggerOverMBBlow->SetLineColor(kBlue);\r
-  hSumTriggerOverMBBlow->Draw("e");\r
-  cTrackMultBBlow->cd(2);\r
-  TH1* hSumTrackerOverMBBlow = static_cast<TH1*>(hTrackerMBBlow->Clone("hSumTrackerOverMBBlow"));\r
-  hSumTrackerOverMBBlow->Add(hMatchedMBBlow);\r
-  hSumTrackerOverMBBlow->Divide(hMBBlow);\r
-  hSumTrackerOverMBBlow->SetTitle("Sum tracker tracks (matched+tracker-only) in MBB events / # MBB events in low mult.");\r
-  //hSumTrackerOverMBBlow->LabelsOption("u");\r
-  hSumTrackerOverMBBlow->SetLabelSize(LabelSize);\r
-  hSumTrackerOverMBBlow->SetLineWidth(2);\r
-  hSumTrackerOverMBBlow->SetLineColor(kBlue);\r
-  hSumTrackerOverMBBlow->Draw("e");\r
-\r
-\r
-  cTrackMultBBlow->Print(OutFileNamePDF.Data());\r
-  cTrackMultBBlow->Write();\r
-\r
-\r
-\r
-  //===========================================\r
-  // draw ratio of track (summed, i.e all trigger=(matched+trigger-only)) for MB  versus run for high mult\r
-  CanvasName =  LHCPeriod.Data() ; \r
-  CanvasName += "_TrackMultBBhigh";   \r
-  TCanvas* cTrackMultBBhigh = new TCanvas("cTrackMultBBhigh","cTrackMultBBhigh",1200,900);\r
-  // must be applied on the pads created by  divide\r
-  cTrackMultBBhigh->Divide(1,2);\r
-  cTrackMultBBhigh->cd(1);\r
-\r
-  TH1* hSumTriggerOverMBBhigh = static_cast<TH1*>(hTriggerMBBhigh->Clone("hSumTriggerOverMBBhigh"));\r
-  hSumTriggerOverMBBhigh->Add(hMatchedMBBhigh);\r
-  hSumTriggerOverMBBhigh->Divide(hMBBhigh);\r
-  hSumTriggerOverMBBhigh->SetTitle("Sum of trigger tracks (matched+trigger-only) in MBB events / # MBB events in high mult.");\r
-  //hSumTriggerOverMBBhigh->LabelsOption("u");\r
-  hSumTriggerOverMBBhigh->SetLabelSize(LabelSize);\r
-  hSumTriggerOverMBBhigh->SetLineWidth(2);\r
-  hSumTriggerOverMBBhigh->SetLineColor(kBlue);\r
-  hSumTriggerOverMBBhigh->Draw("e");\r
-  cTrackMultBBhigh->cd(2);\r
-  TH1* hSumTrackerOverMBBhigh = static_cast<TH1*>(hTrackerMBBhigh->Clone("hSumTrackerOverMBBhigh"));\r
-  hSumTrackerOverMBBhigh->Add(hMatchedMBBhigh);\r
-  hSumTrackerOverMBBhigh->Divide(hMBBhigh);\r
-  hSumTrackerOverMBBhigh->SetTitle("Sum tracker tracks (matched+tracker-only) in MBB events / # MBB events in high mult.");\r
-  //hSumTrackerOverMBBhigh->LabelsOption("u");\r
-  hSumTrackerOverMBBhigh->SetLabelSize(LabelSize);\r
-  hSumTrackerOverMBBhigh->SetLineWidth(2);\r
-  hSumTrackerOverMBBhigh->SetLineColor(kBlue);\r
-  hSumTrackerOverMBBhigh->Draw("e");\r
-\r
-\r
-  cTrackMultBBhigh->Print(OutFileNamePDF.Data());\r
-  cTrackMultBBhigh->Write();\r
-\r
-  \r
-  \r
-  //===========================================\r
-  // draw mixed ratio of track over track versus run for MBB in low mult \r
-  CanvasName =  LHCPeriod.Data() ; \r
-  CanvasName += "_RatioTrackMBBlow";   \r
-  TCanvas* cRatioTrackMBBlow = new TCanvas("cRatioTrackMBBlow","cRatioTrackMBBlow",1200,900);\r
-  cRatioTrackMBBlow->Divide(1,3);\r
-\r
-  cRatioTrackMBBlow->cd(1);\r
-  TH1* hTrackerOverTriggerMBBlow = static_cast<TH1*>(hTrackerMBBlow->Clone("hTrackerOverTriggerMBBlow"));\r
-  hTrackerOverTriggerMBBlow->Divide(hTriggerMBBlow);\r
-  hTrackerOverTriggerMBBlow->SetTitle("# tracker tracks / # trigger tracks in MBB low mult.");\r
-  //hTrackerOverTriggerMBBlow->LabelsOption("u");\r
-  hTrackerOverTriggerMBBlow->SetLabelSize(LabelSize);\r
-  hTrackerOverTriggerMBBlow->SetLineWidth(2);\r
-  hTrackerOverTriggerMBBlow->SetLineColor(kBlue);\r
-  hTrackerOverTriggerMBBlow->Draw("e");\r
-\r
-  cRatioTrackMBBlow->cd(2);\r
-  TH1* hMatchedOverTriggerMBBlow = static_cast<TH1*>(hMatchedMBBlow->Clone("hMatchedOverTriggerMBBlow"));\r
-  hMatchedOverTriggerMBBlow->Divide(hTriggerMBBlow);\r
-  hMatchedOverTriggerMBBlow->SetTitle("# matched tracks / # trigger tracks in MBB low mult.");\r
-  //hMatchedOverTriggerMBBlow->LabelsOption("u");\r
-  hMatchedOverTriggerMBBlow->SetLabelSize(LabelSize);\r
-  hMatchedOverTriggerMBBlow->SetLineWidth(2);\r
-  hMatchedOverTriggerMBBlow->SetLineColor(kBlue);\r
-  hMatchedOverTriggerMBBlow->Draw("e");\r
-\r
-  cRatioTrackMBBlow->cd(3);\r
-  TH1* hMatchedOverTrackerMBBlow = static_cast<TH1*>(hMatchedMBBlow->Clone("hMatchedOverTrackerMBBlow"));\r
-  hMatchedOverTrackerMBBlow->Divide(hTrackerMBBlow);\r
-  hMatchedOverTrackerMBBlow->SetTitle("# matched tracks / # tracker tracks in MBB low mult.");\r
-  //hMatchedOverTrackerMBBlow->LabelsOption("u");\r
-  hMatchedOverTrackerMBBlow->SetLabelSize(LabelSize);\r
-  hMatchedOverTrackerMBBlow->SetLineWidth(2);\r
-  hMatchedOverTrackerMBBlow->SetLineColor(kBlue);\r
-  hMatchedOverTrackerMBBlow->Draw("e");\r
-  \r
-  cRatioTrackMBBlow->Print(OutFileNamePDF.Data());\r
-  cRatioTrackMBBlow->Write();\r
-\r
-  \r
-  //===========================================\r
-  // draw mixed ratio of track over track versus run for MBB in high mult \r
-  CanvasName =  LHCPeriod.Data() ; \r
-  CanvasName += "_RatioTrackMBBhigh";   \r
-  TCanvas* cRatioTrackMBBhigh = new TCanvas("cRatioTrackMBBhigh","cRatioTrackMBBhigh",1200,900);\r
-  cRatioTrackMBBhigh->Divide(1,3);\r
-\r
-  cRatioTrackMBBhigh->cd(1);\r
-  TH1* hTrackerOverTriggerMBBhigh = static_cast<TH1*>(hTrackerMBBhigh->Clone("hTrackerOverTriggerMBBhigh"));\r
-  hTrackerOverTriggerMBBhigh->Divide(hTriggerMBBhigh);\r
-  hTrackerOverTriggerMBBhigh->SetTitle("# tracker tracks / # trigger tracks in MBB high mult.");\r
-  //hTrackerOverTriggerMBBhigh->LabelsOption("u");\r
-  hTrackerOverTriggerMBBhigh->SetLabelSize(LabelSize);\r
-  hTrackerOverTriggerMBBhigh->SetLineWidth(2);\r
-  hTrackerOverTriggerMBBhigh->SetLineColor(kBlue);\r
-  hTrackerOverTriggerMBBhigh->Draw("e");\r
-\r
-  cRatioTrackMBBhigh->cd(2);\r
-  TH1* hMatchedOverTriggerMBBhigh = static_cast<TH1*>(hMatchedMBBhigh->Clone("hMatchedOverTriggerMBBhigh"));\r
-  hMatchedOverTriggerMBBhigh->Divide(hTriggerMBBhigh);\r
-  hMatchedOverTriggerMBBhigh->SetTitle("# matched tracks / # trigger tracks in MBB high mult.");\r
-  //hMatchedOverTriggerMBBhigh->LabelsOption("u");\r
-  hMatchedOverTriggerMBBhigh->SetLabelSize(LabelSize);\r
-  hMatchedOverTriggerMBBhigh->SetLineWidth(2);\r
-  hMatchedOverTriggerMBBhigh->SetLineColor(kBlue);\r
-  hMatchedOverTriggerMBBhigh->Draw("e");\r
-\r
-  cRatioTrackMBBhigh->cd(3);\r
-  TH1* hMatchedOverTrackerMBBhigh = static_cast<TH1*>(hMatchedMBBhigh->Clone("hMatchedOverTrackerMBBhigh"));\r
-  hMatchedOverTrackerMBBhigh->Divide(hTrackerMBBhigh);\r
-  hMatchedOverTrackerMBBhigh->SetTitle("# matched tracks / # tracker tracks in MBB high mult.");\r
-  //hMatchedOverTrackerMBBhigh->LabelsOption("u");\r
-  hMatchedOverTrackerMBBhigh->SetLabelSize(LabelSize);\r
-  hMatchedOverTrackerMBBhigh->SetLineWidth(2);\r
-  hMatchedOverTrackerMBBhigh->SetLineColor(kBlue);\r
-  hMatchedOverTrackerMBBhigh->Draw("e");\r
-  \r
-  cRatioTrackMBBhigh->Print(OutFileNamePDF.Data());\r
-  cRatioTrackMBBhigh->Write();\r
-\r
-\r
-\r
-\r
-\r
-//   //===========================================\r
-//   // Draw ratio of tracks over CMUS1B versus run\r
-//   TH1* hTrackerPerCMUS1B= static_cast<TH1*>(hTrackerCMUS1B->Clone("hTrackerPerCMUS1B"));\r
-//   hTrackerPerCMUS1B->Divide(hCMUS1B);\r
-//   hTrackerPerCMUS1B->SetLineWidth(2);\r
-//   hTrackerPerCMUS1B->SetLineColor(kRed);\r
-\r
-//   TH1* hTriggerPerCMUS1B= static_cast<TH1*>(hTriggerCMUS1B->Clone("hTriggerPerCMUS1B"));\r
-//   hTriggerPerCMUS1B->Divide(hCMUS1B);\r
-//   hTriggerPerCMUS1B->SetLineWidth(2);\r
-//   hTriggerPerCMUS1B->SetLineColor(kBlue);\r
-\r
-//   TH1* hMatchedPerCMUS1B= static_cast<TH1*>(hMatchedCMUS1B->Clone("hMatchedPerCMUS1B"));\r
-//   hMatchedPerCMUS1B->Divide(hCMUS1B);\r
-//   hMatchedPerCMUS1B->SetLineWidth(2);\r
-//   hMatchedPerCMUS1B->SetLineColor(kViolet);\r
-\r
-\r
-//   TH1* hAllTracksPerCMUS1B= static_cast<TH1*>(hAllTracksCMUS1B->Clone("hAllTracksPerCMUS1B"));\r
-//   hAllTracksPerCMUS1B->Divide(hCMUS1B);\r
-//   hAllTracksPerCMUS1B->SetLineWidth(3);\r
-//   hAllTracksPerCMUS1B->SetLineColor(kBlack);\r
-\r
-\r
-//   CanvasName =  LHCPeriod.Data() ; \r
-//   CanvasName += "_RatioTrackTypesCMUS1B"; \r
-//   TCanvas *cRatioTrackTypesCMUS1B = new TCanvas(CanvasName.Data(),"cRatioTrackTypesCMUS1B",1200,900);\r
-//   cRatioTrackTypesCMUS1B->SetRightMargin(0.01);\r
-//   cRatioTrackTypesCMUS1B->SetGridy(1);\r
-//   cRatioTrackTypesCMUS1B->cd();\r
-\r
-//   hAllTracksPerCMUS1B->SetTitle("Ratio (Number of Tracks)/CMUS1B");\r
-//   hAllTracksPerCMUS1B->SetMinimum(0.01);\r
-//   hAllTracksPerCMUS1B->SetLabelSize(LabelSize);\r
-//   hAllTracksPerCMUS1B->Draw("E");\r
-\r
-//   hTrackerPerCMUS1B->Draw("Esame");\r
-//   hMatchedPerCMUS1B->Draw("Esame");\r
-//   hTriggerPerCMUS1B->Draw("Esame");\r
-\r
-//   TLegend* legcTTCMUS1B = new TLegend(0.75,0.55,0.90,0.75);\r
-//   legcTTCMUS1B->AddEntry(hAllTracksPerCMUS1B,"All tracks","l");\r
-//   legcTTCMUS1B->AddEntry(hTrackerPerCMUS1B,"Tracking (only) tracks","l");\r
-//   legcTTCMUS1B->AddEntry(hMatchedPerCMUS1B,"Matched tracks","l");\r
-//   legcTTCMUS1B->AddEntry(hTriggerPerCMUS1B,"Trigger (only) tracks","l");\r
-//   legcTTCMUS1B->Draw("same");\r
-\r
-//   cRatioTrackTypesCMUS1B->Print(OutFileNamePDF.Data());\r
-//   cRatioTrackTypesCMUS1B->Write();\r
-\r
-\r
-//   //===========================================\r
-//   // draw ratio of track (summed, i.e all trigger=(matched+trigger-only)) over CMUS1B versus run\r
-//   TCanvas* cTrackMultCMUS1B = new TCanvas("cTrackMultCMUS1B","cTrackMultCMUS1B",1200,900);\r
-//   cTrackMultCMUS1B->Divide(1,2);\r
-//   cTrackMultCMUS1B->cd(1);\r
-//   TH1* hSumTriggerOverCMUS1B = static_cast<TH1*>(hTriggerCMUS1B->Clone("hSumTriggerOverCMUS1B"));\r
-//   hSumTriggerOverCMUS1B->Add(hMatchedCMUS1B);\r
-//   hSumTriggerOverCMUS1B->Divide(hCMUS1B);\r
-//   hSumTriggerOverCMUS1B->SetTitle("Sum of trigger tracks (matched+trigger-only) in CMUS1B events / # CMUS1B events");\r
-//   //hSumTriggerOverCMUS1B->LabelsOption("u");\r
-//   hSumTriggerOverCMUS1B->SetLabelSize(LabelSize);\r
-//   hSumTriggerOverCMUS1B->SetLineWidth(2);\r
-//   hSumTriggerOverCMUS1B->SetLineColor(kRed);\r
-//   hSumTriggerOverCMUS1B->Draw("e");\r
-\r
-//   cTrackMultCMUS1B->cd(2);\r
-//   TH1* hSumTrackerOverCMUS1B = static_cast<TH1*>(hTrackerCMUS1B->Clone("hSumTrackerOverCMUS1B"));\r
-//   hSumTrackerOverCMUS1B->Add(hMatchedCMUS1B);\r
-//   hSumTrackerOverCMUS1B->Divide(hCMUS1B);\r
-//   hSumTrackerOverCMUS1B->SetTitle("Sum of tracker tracks (matched+tracker-only) in CMUS1B events / # CMUS1B events");\r
-//   //hSumTrackerOverCMUS1B->LabelsOption("u");\r
-//   hSumTrackerOverCMUS1B->SetLabelSize(LabelSize);\r
-//   hSumTrackerOverCMUS1B->SetLineWidth(2);\r
-//   hSumTrackerOverCMUS1B->SetLineColor(kRed);\r
-//   hSumTrackerOverCMUS1B->Draw("e");\r
-\r
-//   cTrackMultCMUS1B->Print(OutFileNamePDF.Data());\r
-//   cTrackMultCMUS1B->Write();\r
-  \r
-//   //===========================================\r
-//   // draw mixed ratio of track over track versus run for CMUS1B\r
-//   TCanvas* cRatioTrackCMUS1B = new TCanvas("cRatioTrackCMUS1B","cRatioTrackCMUS1B",1200,900);\r
-//   cRatioTrackCMUS1B->Divide(1,3);\r
-\r
-//   cRatioTrackCMUS1B->cd(1);\r
-//   TH1* hTrackerOverTriggerCMUS1B = static_cast<TH1*>(hTrackerCMUS1B->Clone("hTrackerOverTriggerCMUS1B"));\r
-//   hTrackerOverTriggerCMUS1B->Divide(hTriggerCMUS1B);\r
-//   hTrackerOverTriggerCMUS1B->SetTitle("# tracker tracks / # trigger tracks in CMUS1B");\r
-//   //hTrackerOverTriggerCMUS1B->LabelsOption("u");\r
-//   hTrackerOverTriggerCMUS1B->SetLabelSize(LabelSize);\r
-//   hTrackerOverTriggerCMUS1B->SetLineWidth(2);\r
-//   hTrackerOverTriggerCMUS1B->SetLineColor(kRed);\r
-//   hTrackerOverTriggerCMUS1B->Draw("e");\r
-\r
-//   cRatioTrackCMUS1B->cd(2);\r
-//   TH1* hMatchedOverTriggerCMUS1B = static_cast<TH1*>(hMatchedCMUS1B->Clone("hMatchedOverTriggerCMUS1B"));\r
-//   hMatchedOverTriggerCMUS1B->Divide(hTriggerCMUS1B);\r
-//   hMatchedOverTriggerCMUS1B->SetTitle("# matched tracks / # trigger tracks in CMUS1B");\r
-//   //hMatchedOverTriggerCMUS1B->LabelsOption("u");\r
-//   hMatchedOverTriggerCMUS1B->SetLabelSize(LabelSize);\r
-//   hMatchedOverTriggerCMUS1B->SetLineWidth(2);\r
-//   hMatchedOverTriggerCMUS1B->SetLineColor(kRed);\r
-//   hMatchedOverTriggerCMUS1B->Draw("e");\r
-\r
-//   cRatioTrackCMUS1B->cd(3);\r
-//   TH1* hMatchedOverTrackerCMUS1B = static_cast<TH1*>(hMatchedCMUS1B->Clone("hMatchedOverTrackerCMUS1B"));\r
-//   hMatchedOverTrackerCMUS1B->Divide(hTrackerCMUS1B);\r
-//   hMatchedOverTrackerCMUS1B->SetTitle("# matched tracks / # tracker tracks in CMUS1B");\r
-//   //hMatchedOverTrackerCMUS1B->LabelsOption("u");\r
-//   hMatchedOverTrackerCMUS1B->SetLabelSize(LabelSize);\r
-//   hMatchedOverTrackerCMUS1B->SetLineWidth(2);\r
-//   hMatchedOverTrackerCMUS1B->SetLineColor(kRed);\r
-//   hMatchedOverTrackerCMUS1B->Draw("e");\r
-  \r
-//   cRatioTrackCMUS1B->Print(OutFileNamePDF.Data());\r
-//   cRatioTrackCMUS1B->Write();\r
-\r
-   //==================================================\r
-   // Draw matched tracks charge asymetry in low mult for MBB  triggers  \r
-   TH1 *hDiffMatchedMBBlow= static_cast<TH1*>(hPosMatchedMBBlow->Clone("hDiffMatchedMBBlow"));\r
-   hDiffMatchedMBBlow->Add(hNegMatchedMBBlow,-1);\r
-   hDiffMatchedMBBlow->Sumw2();\r
-  \r
-   TH1 *hAsymMatchedMBBlow= static_cast<TH1*>(hDiffMatchedMBBlow->Clone("hAsymMatchedMBBlow"));\r
-   hAsymMatchedMBBlow->Divide(hAllMatchedMBBlow);\r
-   hAsymMatchedMBBlow->SetLineColor(kBlue);\r
-   hAsymMatchedMBBlow->SetLineWidth(2);\r
-   hAsymMatchedMBBlow->SetMinimum(-0.2);\r
-   hAsymMatchedMBBlow->SetMaximum(0.2);\r
-   hAsymMatchedMBBlow->SetLabelSize(LabelSize);\r
-   hAsymMatchedMBBlow->SetTitle("Matched tracks charge asymmetry in Physics Selected events for MBB low (blue) and high (red) mult.");\r
-\r
-   TH1 *hDiffMatchedMBBhigh= static_cast<TH1*>(hPosMatchedMBBhigh->Clone("hDiffMatchedMBBhigh"));\r
-   hDiffMatchedMBBhigh->Add(hNegMatchedMBBhigh,-1);\r
-   hDiffMatchedMBBhigh->Sumw2();\r
-  \r
-   TH1 *hAsymMatchedMBBhigh= static_cast<TH1*>(hDiffMatchedMBBhigh->Clone("hAsymMatchedMBBhigh"));\r
-   hAsymMatchedMBBhigh->Divide(hAllMatchedMBBhigh);\r
-   hAsymMatchedMBBhigh->SetLineColor(kRed);\r
-   hAsymMatchedMBBhigh->SetLineWidth(2);\r
-   hAsymMatchedMBBhigh->SetMinimum(-0.2);\r
-   hAsymMatchedMBBhigh->SetMaximum(0.2);\r
-   hAsymMatchedMBBhigh->SetLabelSize(LabelSize);\r
-   hAsymMatchedMBBhigh->SetTitle("Matched tracks asymetry in Physics Selected events");\r
-  \r
-\r
-   CanvasName =  LHCPeriod.Data() ; \r
-   CanvasName += "_AsymMatched"; \r
-   TCanvas *cAsymMatched = new TCanvas(CanvasName.Data(),"cAsymMatched",1200,900);\r
-   cAsymMatched->SetRightMargin(0.01);\r
-   cAsymMatched->SetGridy(1);\r
-   cAsymMatched->cd();\r
-   hAsymMatchedMBBlow->GetYaxis()->SetTitle("Charge asymmetry");  \r
-   hAsymMatchedMBBlow->Draw("EH");\r
-   hAsymMatchedMBBhigh->Draw("EHsame");\r
-   \r
-   TLegend* legcAMT = new TLegend(0.60,0.25,0.98,0.45);\r
-   legcAMT->SetHeader("Charge asymmetry  of matched track per MBB (include Vtx, #eta  and R_{Abs} cuts) ");\r
-   legcAMT->AddEntry(hAsymMatchedMBBlow," Low mult. events","l");\r
-   legcAMT->AddEntry(hAsymMatchedMBBhigh," High mult. events ","l");\r
-   legcAMT->Draw("same");\r
-\r
-   cAsymMatched->Print(OutFileNamePDF.Data());\r
-   cAsymMatched->Write();\r
-\r
-\r
-  //=========================================================\r
-  // Draw low/high pt tracks in acceptance  per MBB  all mult \r
-  TH1* hMatchedLowPtPerMBB = static_cast<TH1*> (hMatchedLowPtMBB->Clone("hMatchedLowPtPerMBB"));\r
-  hMatchedLowPtPerMBB->Sumw2();\r
-  hMatchedLowPtPerMBB->Divide(hMBB);\r
-  hMatchedLowPtPerMBB->SetLineWidth(2);\r
-  hMatchedLowPtPerMBB->SetLineColor(kBlue);\r
-\r
-  TH1* hMatchedHighPtPerMBB = static_cast<TH1*> (hMatchedHighPtMBB->Clone("hMatchedHighPtPerMBB"));\r
-  hMatchedHighPtPerMBB->Sumw2();\r
-  hMatchedHighPtPerMBB->Divide(hMBB);\r
-  hMatchedHighPtPerMBB->SetLineWidth(2);\r
-  hMatchedHighPtPerMBB->SetLineColor(kRed);\r
-\r
-  TH1* hMatchedLowPtPerMBBlow = static_cast<TH1*> (hMatchedLowPtMBBlow->Clone("hMatchedLowPtPerMBBlow"));\r
-  hMatchedLowPtPerMBBlow->Sumw2();\r
-  hMatchedLowPtPerMBBlow->Divide(hMBBlow);\r
-  hMatchedLowPtPerMBBlow->SetLineWidth(2);\r
-  hMatchedLowPtPerMBBlow->SetMarkerSize(2);\r
-  hMatchedLowPtPerMBBlow->SetMarkerStyle(27);\r
-  hMatchedLowPtPerMBBlow->SetMarkerColor(kBlue);\r
-  hMatchedLowPtPerMBBlow->SetLineWidth(2);\r
-  hMatchedLowPtPerMBBlow->SetLineColor(kBlue);\r
-\r
-  TH1* hMatchedHighPtPerMBBlow = static_cast<TH1*> (hMatchedHighPtMBBlow->Clone("hMatchedHighPtPerMBBlow"));\r
-  hMatchedHighPtPerMBBlow->Sumw2();\r
-  hMatchedHighPtPerMBBlow->Divide(hMBB);\r
-  hMatchedHighPtPerMBBlow->SetLineWidth(2);\r
-  hMatchedHighPtPerMBBlow->SetLineColor(kRed);\r
-  hMatchedHighPtPerMBBlow->SetMarkerSize(2);\r
-  hMatchedHighPtPerMBBlow->SetMarkerStyle(27);\r
-  hMatchedHighPtPerMBBlow->SetMarkerColor(kRed);\r
-\r
-  TH1* hMatchedLowPtPerMBBhigh = static_cast<TH1*> (hMatchedLowPtMBBhigh->Clone("hMatchedLowPtPerMBBhigh"));\r
-  hMatchedLowPtPerMBBhigh->Sumw2();\r
-  hMatchedLowPtPerMBBhigh->Divide(hMBBhigh);\r
-  hMatchedLowPtPerMBBhigh->SetLineWidth(2);\r
-  hMatchedLowPtPerMBBhigh->SetLineColor(kBlue);\r
-  hMatchedLowPtPerMBBhigh->SetMarkerSize(2);\r
-  hMatchedLowPtPerMBBhigh->SetMarkerStyle(24);\r
-  hMatchedLowPtPerMBBhigh->SetMarkerColor(kBlue);\r
-\r
-\r
-  TH1* hMatchedHighPtPerMBBhigh = static_cast<TH1*> (hMatchedHighPtMBBhigh->Clone("hMatchedHighPtPerMBBhigh"));\r
-  hMatchedHighPtPerMBBhigh->Sumw2();\r
-  hMatchedHighPtPerMBBhigh->Divide(hMBB);\r
-  hMatchedHighPtPerMBBhigh->SetLineWidth(2);\r
-  hMatchedHighPtPerMBBhigh->SetLineColor(kRed);\r
-  hMatchedHighPtPerMBBhigh->SetMarkerSize(2);\r
-  hMatchedHighPtPerMBBhigh->SetMarkerStyle(24);\r
-  hMatchedHighPtPerMBBhigh->SetMarkerColor(kRed);\r
-\r
-\r
-  CanvasName =  LHCPeriod.Data() ; \r
-  CanvasName += "_HighPtMuons"; \r
-  TCanvas *cHighPtMuons = new TCanvas(CanvasName.Data(),"cHighPtMuons",1200,900);\r
-  cHighPtMuons->SetTopMargin(0.05);\r
-  cHighPtMuons->SetRightMargin(0.01);\r
-  //cHighPtMuons->SetLogy(1);\r
-  cHighPtMuons->SetGridy(1);\r
-  cHighPtMuons->cd();\r
-\r
-  hMatchedLowPtPerMBB->SetTitle("");\r
-  hMatchedLowPtPerMBB->GetYaxis()->SetTitle("Ratio per MBB");\r
-  hMatchedLowPtPerMBB->SetMaximum(0.13);\r
-  hMatchedLowPtPerMBB->SetMinimum(0.02);\r
-  hMatchedLowPtPerMBB->SetLabelSize(LabelSize);\r
-\r
-  hMatchedLowPtPerMBB->Draw("E");\r
-  hMatchedHighPtPerMBB->Scale(5);\r
-  hMatchedHighPtPerMBB->Draw("Esame");\r
-    \r
-  TLegend* legcHPM = new TLegend(0.60,0.50,0.98,0.65);\r
-  legcHPM->SetHeader("Number of matched track per MBB (include Vtx, #eta  and R_{Abs} cuts) ");\r
-  legcHPM->AddEntry(hMatchedLowPtPerMBB," p_{T} > 1 GeV/c ","l");\r
-  legcHPM->AddEntry(hMatchedHighPtPerMBB," (x5) p_{T} >  2 GeV/c ","l");\r
-  legcHPM->Draw("same");\r
-\r
-  cHighPtMuons->Print(OutFileNamePDF.Data());\r
-  cHighPtMuons->Write(); \r
-\r
-\r
-  //=====================================================================\r
-  // Draw low/high pt tracks in acceptance per MBB  in low and high  mult \r
-  CanvasName =  LHCPeriod.Data() ; \r
-  CanvasName += "_HighPtMuonsVsMult"; \r
-  TCanvas *cHighPtMuonsVsMult = new TCanvas(CanvasName.Data(),"cHighPtMuonsVsMult",1200,900);\r
-  cHighPtMuonsVsMult->SetTopMargin(0.05);\r
-  cHighPtMuonsVsMult->SetRightMargin(0.01);\r
-  cHighPtMuonsVsMult->SetLogy(1);\r
-  cHighPtMuonsVsMult->SetGridy(1);\r
-  cHighPtMuonsVsMult->Divide(1,2);\r
-\r
-\r
-  cHighPtMuonsVsMult->cd(1);\r
-\r
-  hMatchedLowPtPerMBBlow->SetTitle("");\r
-  hMatchedLowPtPerMBBlow->GetYaxis()->SetTitle("Ratio per MBB in low mult");\r
-  hMatchedLowPtPerMBBlow->SetMaximum(0.015);\r
-  hMatchedLowPtPerMBBlow->SetMinimum(0.000001);\r
-  hMatchedLowPtPerMBBlow->SetLabelSize(LabelSize);\r
-\r
-  hMatchedLowPtPerMBBlow->Draw("E");\r
-  hMatchedHighPtPerMBBlow->Scale(10);\r
-  hMatchedHighPtPerMBBlow->Draw("Esame");\r
-  TLegend* legcHPMlow = new TLegend(0.60,0.35,0.98,0.5);\r
-  legcHPMlow->SetHeader("Number of matched track per MBB (include Vtx, #eta  and R_{Abs} cuts) ");\r
-  legcHPMlow->AddEntry(hMatchedLowPtPerMBBlow," p_{T} > 1 GeV/c in low mult","p");\r
-  legcHPMlow->AddEntry(hMatchedHighPtPerMBBlow,"(x10) p_{T} >  2 GeV/c in low mult","p");\r
-  legcHPMlow->Draw("same");\r
-\r
-\r
-  cHighPtMuonsVsMult->cd(2);\r
-  hMatchedLowPtPerMBBhigh->SetTitle("");\r
-  hMatchedLowPtPerMBBhigh->GetYaxis()->SetTitle("Ratio per MBB in high mult");\r
-  hMatchedLowPtPerMBBhigh->SetMinimum(0.005);\r
-  hMatchedLowPtPerMBBhigh->Draw("E");\r
-  hMatchedHighPtPerMBBhigh->Scale(10);\r
-  hMatchedHighPtPerMBBhigh->Draw("Esame");\r
-    \r
-  TLegend* legcHPMhigh = new TLegend(0.60,0.4,0.98,0.55);\r
-  legcHPMhigh->SetHeader("Number of matched track per MBB (include Vtx, #eta  and R_{Abs} cuts) ");\r
-  legcHPMhigh->AddEntry(hMatchedLowPtPerMBBhigh," p_{T} > 1 GeV/c in high mult","p");\r
-  legcHPMhigh->AddEntry(hMatchedHighPtPerMBBhigh,"(x10)  p_{T} >  2 GeV/c in high mult","p");\r
-  legcHPMhigh->Draw("same");\r
-  \r
-  cHighPtMuonsVsMult->Print(OutFileNamePDF.Data());\r
-  cHighPtMuonsVsMult->Write(); \r
-\r
-  // close merged file\r
-  globalFile->Close();\r
-\r
-\r
-  //--------------------------------------------- //\r
-  //        monitor quantities run per run        //\r
-  //--------------------------------------------- //\r
-  \r
-\r
-  // Are the runs stored locally or in alien?\r
-  Int_t isAlienFile = 0;\r
-  if(alienBaseDir.Contains("alien:")){\r
-    isAlienFile = 1;\r
-    alienBaseDir.ReplaceAll("alien://","");\r
-  }\r
-\r
-  /*   if ( ! alienBaseDir.Contains("alien:")){\r
-       Info("PlotMuonQA","Working locally, stopping here");\r
-       rootFileOut->Close();\r
-       return;\r
-       }\r
-  */ \r
-  //   else (!TGrid::Connect("alien://")) {\r
-  //     Error("PlotMuonQA","cannot connect to grid. It's really needed here");\r
-  //     c1->Print(OutFileNamePDF_close.Data());\r
-  //     rootFileOut->Close();\r
-  //     return;\r
-  //   }\r
-\r
-  TH1F* hNClustersPerTrackVsRun_Mean = new TH1F("hNClustersPerTrackVsRun_Mean", "averaged number of associated clusters per track;run;<n_{clusters}>",10000,1,10000);\r
-  TH1F* hNClustersPerTrackVsRun_Sigma = new TH1F("hNClustersPerTrackVsRun_Sigma", "dispersion of the number of associated clusters per track;run;#sigma_{n_{clusters}}",10000,1,10000);\r
-  TH1F* hNChamberHitPerTrack_Mean = new TH1F("hNChamberHitPerTrack_Mean", "averaged number of chambers hit per track;run;<n_{chamber hit}>",10000,1,10000);\r
-  TH1F* hNChamberHitPerTrack_Sigma = new TH1F("hNChamberHitPerTrack_Sigma", "dispersion of the number of chambers hit per track;run;#sigma_{n_{chamber hit}}",10000,1,10000);\r
-  TH1F* hChi2_Mean = new TH1F("hChi2_Mean", "averaged normalized #chi^{2} distribution;run;<#chi^{2} / ndf>",10000,1,10000);\r
-  TH1F* hChi2_Sigma = new TH1F("hChi2_Sigma", "dispersion of normalized #chi^{2} distribution;run;#sigma_{#chi^{2} / ndf}",10000,1,10000);\r
-  TH1F* hNClustersInCh[10];\r
-  for (Int_t ich=0; ich<10; ich++){\r
-    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);\r
-  }\r
-  TH1F* hClusterHitMapXInCh[10];\r
-  for (Int_t ich=0; ich<10; ich++){\r
-    hClusterHitMapXInCh[ich] = new TH1F(Form("hClusterHitMapXInCh%d",ich+1), Form("averaged cluster position distribution in chamber %d;X (cm)",ich+1),10000,1,10000);\r
-  }\r
-  TH1F* hClusterHitMapYInCh[10];\r
-  for (Int_t ich=0; ich<10; ich++){\r
-    hClusterHitMapYInCh[ich] = new TH1F(Form("hClusterHitMapYInCh%d",ich+1), Form("averaged cluster position distribution in chamber %d;Y (cm)",ich+1),10000,1,10000);\r
-  }\r
-\r
-  Int_t ibin = 1;\r
-  \r
-  // loop over runs\r
-  for ( Int_t irun=0; irun<runs.GetEntriesFast(); irun++ ) { //loop over runs \r
-    \r
-    TString run = ((TObjString*)runs.UncheckedAt(irun))->GetString();\r
-    // get the file (or list of files) to be analyzed\r
-    TString command;\r
-    TGridResult *res = 0;\r
-    TObjString *objs = 0;\r
-  \r
-    if(isAlienFile){\r
-      // get the file (or list of files) to be analyzed\r
-      command = Form("find %s/ %s/%s", alienBaseDir.Data(), run.Data(), QAFileName.Data());\r
-      res = gGrid->Command(command);\r
-      if (!res) {\r
-       Error("PlotMuonQAPbPb",Form("no result for the command: %s",command.Data()));\r
-       return;\r
-      }\r
-    }\r
-    else{\r
-      res = new TGridResult();\r
-\r
-      if(runList){\r
-        objs = new TObjString(Form("%s/%s/AnalysisResults.root", alienBaseDir.Data(), run.Data()));\r
-        res->Add(objs);\r
-      }\r
-      else {\r
-        //loop over the directory to find the root files                                                                                                                     \r
-        void *dir = gSystem->OpenDirectory(alienBaseDir.Data());\r
-        TString sDirFilename;\r
-        Int_t iEntry=0, iFile=0;\r
-\r
-        while(kTRUE){\r
-          iEntry++;\r
-          const char* dirFilename = gSystem->GetDirEntry(dir);\r
-          if(!dirFilename) break;\r
-          sDirFilename = dirFilename;\r
-          if(!sDirFilename.IsDigit()) continue;\r
-          iFile++;\r
-          objs = new TObjString(Form("%s/%s/AnalysisResults.root", alienBaseDir.Data(), sDirFilename.Data()));\r
-          res->Add(objs);\r
-        }\r
-      }\r
-    }\r
-\r
-    // Loop over the 'find' results and get next LFN\r
-    TIter nextmap(res);\r
-    TMap *map = 0;\r
-    TObjString *objs;\r
-\r
-    //some checks\r
-    Int_t iLoop=0, iLoopMax=1000;\r
-\r
-    while (kTRUE){\r
-      // get the current file url\r
-      if(isAlienFile){\r
-       map=(TMap*)nextmap();\r
-       if(!map) break;\r
-        objs = dynamic_cast<TObjString*>(map->GetValue("turl"));\r
-      }\r
-      else{\r
-       objs=(TObjString*)nextmap();\r
-        if(!objs) break;\r
-      }\r
-\r
-      //in case of infinite loop\r
-      iLoop++;\r
-      if(iLoop>iLoopMax) break;\r
-\r
-\r
-      if (!objs || !objs->GetString().Length()) {\r
-       Error("PlotMuonQA","turl not found for the run %s... SKIPPING", run.Data());\r
-       continue;\r
-      }\r
-      \r
-      // open the outfile for this run\r
-      TFile *runFile = TFile::Open(objs->GetString());\r
-      if (!runFile || ! runFile->IsOpen()) {\r
-       Error("PlotMuonQA", Form("failed to open file: %s", objs->GetName()));\r
-       return;\r
-      }\r
-\r
-      // change here\r
-      runFile->Cd("MUON_QA");\r
-      \r
-      // get interesting histos\r
-      TObjArray* general1 = static_cast<TObjArray*>(runFile->FindObjectAny("general1"));\r
-      TObjArray* general2 = static_cast<TObjArray*>(runFile->FindObjectAny("general2"));\r
-      TObjArray* expert = static_cast<TObjArray*>(runFile->FindObjectAny("expert"));\r
-\r
-      if (!general1 || !general2 || !expert){\r
-        Error("PlotMUONQAPbPb", Form("All objects not here !!! ===> Skipping...for %s",objs->GetName()));\r
-        continue;\r
-      }\r
-\r
-      TH1* hNClustersPerTrack = static_cast<TH1*>(general1->FindObject("hNClustersPerTrack"));\r
-      TH1* hNChamberHitPerTrack = static_cast<TH1*>(general1->FindObject("hNChamberHitPerTrack"));\r
-      TH1* hChi2 = static_cast<TH1*>(general1->FindObject("hChi2"));\r
-      TH1* hNClustersPerCh = static_cast<TH1*>(general2->FindObject("hNClustersPerCh"));\r
-\r
-      TH2* hClusterHitMapInCh[10];\r
-      for(Int_t ich=0; ich<10; ich++) hClusterHitMapInCh[ich] = static_cast<TH2*>(expert->FindObject(Form("hClusterHitMapInCh%d",ich+1)));\r
-\r
-      // do not skip empty runs butrather set values to 0\r
-      if (!hNClustersPerCh) {\r
-       Warning("PlotQA", Form("File: %s has empty histograms !", objs->GetName()));\r
-       hNClustersPerTrackVsRun_Mean->SetBinContent(ibin, 0.);\r
-       hNClustersPerTrackVsRun_Mean->SetBinError(ibin, 1.);\r
-       hNClustersPerTrackVsRun_Sigma->SetBinContent(ibin, 0.);\r
-       hNClustersPerTrackVsRun_Sigma->SetBinError(ibin, 1.);\r
-       hNChamberHitPerTrack_Mean->SetBinContent(ibin, 0.);\r
-       hNChamberHitPerTrack_Mean->SetBinError(ibin, 1.);\r
-       hNChamberHitPerTrack_Sigma->SetBinContent(ibin, 0.);\r
-       hNChamberHitPerTrack_Sigma->SetBinError(ibin, 1.);\r
-       hChi2_Mean->SetBinContent(ibin, 0.);\r
-       hChi2_Mean->SetBinError(ibin, 1.);\r
-       hChi2_Sigma->SetBinContent(ibin, 0.);\r
-       hChi2_Sigma->SetBinError(ibin, 1.);\r
-       for (Int_t ich=0; ich<10; ich++) {\r
-         hNClustersInCh[ich]->SetBinContent(ibin,0.);\r
-         hNClustersInCh[ich]->SetBinError(ibin,1.);\r
-         hClusterHitMapXInCh[ich]->SetBinContent(ibin,0.);\r
-         hClusterHitMapXInCh[ich]->SetBinError(ibin,1.);\r
-         hClusterHitMapYInCh[ich]->SetBinContent(ibin,0.);\r
-         hClusterHitMapYInCh[ich]->SetBinError(ibin,1.);       \r
-       }\r
-       //runFile->Close();\r
-       //continue;\r
-      }\r
-      else {\r
-       // fill monitoring plots\r
-       hNClustersPerTrackVsRun_Mean->SetBinContent(ibin, hNClustersPerTrack->GetMean());\r
-       hNClustersPerTrackVsRun_Mean->SetBinError(ibin, hNClustersPerTrack->GetMeanError());\r
-       hNClustersPerTrackVsRun_Sigma->SetBinContent(ibin, hNClustersPerTrack->GetRMS());\r
-       hNClustersPerTrackVsRun_Sigma->SetBinError(ibin, hNClustersPerTrack->GetRMSError());\r
-       hNChamberHitPerTrack_Mean->SetBinContent(ibin, hNChamberHitPerTrack->GetMean());\r
-       hNChamberHitPerTrack_Mean->SetBinError(ibin, hNChamberHitPerTrack->GetMeanError());\r
-       hNChamberHitPerTrack_Sigma->SetBinContent(ibin, hNChamberHitPerTrack->GetRMS());\r
-       hNChamberHitPerTrack_Sigma->SetBinError(ibin, hNChamberHitPerTrack->GetRMSError());\r
-       hChi2_Mean->SetBinContent(ibin, hChi2->GetMean());\r
-       hChi2_Mean->SetBinError(ibin, hChi2->GetMeanError());\r
-       hChi2_Sigma->SetBinContent(ibin, hChi2->GetRMS());\r
-       hChi2_Sigma->SetBinError(ibin, hChi2->GetRMSError());\r
-       for (Int_t ich=0; ich<10; ich++) {\r
-         hNClustersInCh[ich]->SetBinContent(ibin,hNClustersPerCh->GetBinContent(ich+1));\r
-         hNClustersInCh[ich]->SetBinError(ibin,hNClustersPerCh->GetBinError(ich+1));\r
-         hClusterHitMapXInCh[ich]->SetBinContent(ibin,hClusterHitMapInCh[ich]->GetMean(1));\r
-         hClusterHitMapXInCh[ich]->SetBinError(ibin,hClusterHitMapInCh[ich]->GetMeanError(1));\r
-         hClusterHitMapYInCh[ich]->SetBinContent(ibin,hClusterHitMapInCh[ich]->GetMean(2));\r
-         hClusterHitMapYInCh[ich]->SetBinError(ibin,hClusterHitMapInCh[ich]->GetMeanError(2));\r
-       }\r
-      }\r
-\r
-      // set labels\r
-      run = objs->GetString();\r
-      run.ReplaceAll(baseDir, "");\r
-      run.Remove(TString::kLeading, '/');\r
-      run.Remove(TString::kLeading, '0');\r
-      run.ReplaceAll(QAFileName.Data(),"");\r
-      run.Remove(TString::kTrailing, '/');\r
-      hNClustersPerTrackVsRun_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());\r
-      hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());\r
-      hNChamberHitPerTrack_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());\r
-      hNChamberHitPerTrack_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());\r
-      hChi2_Mean->GetXaxis()->SetBinLabel(ibin, run.Data());\r
-      hChi2_Sigma->GetXaxis()->SetBinLabel(ibin, run.Data());\r
-      for (Int_t ich=0; ich<10; ich++) {\r
-       hNClustersInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());\r
-       hClusterHitMapXInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());\r
-       hClusterHitMapYInCh[ich]->GetXaxis()->SetBinLabel(ibin, run.Data());\r
-      }\r
-      // close outfile for this run\r
-      runFile->Close();\r
-      ibin++;      \r
-    }\r
-    \r
-    delete res;\r
-  }\r
-\r
-  //sort label\r
-  hNClustersPerTrackVsRun_Mean->LabelsOption("a");\r
-  hNClustersPerTrackVsRun_Sigma->LabelsOption("a");\r
-  hNChamberHitPerTrack_Mean->LabelsOption("a");\r
-  hNChamberHitPerTrack_Sigma->LabelsOption("a");\r
-  hChi2_Mean->LabelsOption("a");\r
-  hChi2_Sigma->LabelsOption("a");\r
-\r
-  for(Int_t ich=0; ich<10; ich++){\r
-    hNClustersInCh[ich]->LabelsOption("a");\r
-    hClusterHitMapXInCh[ich]->LabelsOption("a");\r
-    hClusterHitMapYInCh[ich]->LabelsOption("a");\r
-  }\r
-  \r
-  TString dirToGo =  OutFileNameROOT.Data(); dirToGo+=":/";\r
-  gDirectory->Cd(dirToGo.Data());\r
-  //==================================================\r
-  //Display Mean and Sigma of the number of associated clusters to a track \r
-  TLegend *lNClusters = new TLegend(0.75,0.85,0.99,0.99);\r
-  lNClusters->AddEntry(hNClustersPerTrackVsRun_Mean,"clusters","PL");\r
-  lNClusters->AddEntry(hNChamberHitPerTrack_Mean,"chamber hit","PL");\r
-  \r
-  TCanvas* cNClusters = new TCanvas("cNClusters","cNClusters",1200,900);\r
-  cNClusters->SetLogy(0);\r
-  cNClusters->Divide(1,2);\r
-  cNClusters->cd(1);\r
-  //hNClustersPerTrackVsRun_Mean->SetMaximum(11);\r
-  hNClustersPerTrackVsRun_Mean->SetMinimum(7);\r
-  hNClustersPerTrackVsRun_Mean->SetStats(kFALSE);\r
-  hNClustersPerTrackVsRun_Mean->GetXaxis()->SetRange(1,ibin-1);\r
-  hNClustersPerTrackVsRun_Mean->GetXaxis()->SetNdivisions(1,kFALSE);\r
-  //hNClustersPerTrackVsRun_Mean->LabelsOption("u");\r
-  hNClustersPerTrackVsRun_Mean->SetLabelSize(LabelSize);\r
-  hNClustersPerTrackVsRun_Mean->SetTitle("averaged number of associated clusters or of the number of chamber hit per track");\r
-  hNClustersPerTrackVsRun_Mean->SetLineWidth(2);\r
-  hNClustersPerTrackVsRun_Mean->Draw("e");\r
-  hNChamberHitPerTrack_Mean->SetLineColor(kRed);\r
-  hNChamberHitPerTrack_Mean->SetLineWidth(2);\r
-  hNChamberHitPerTrack_Mean->Draw("esame");\r
-  lNClusters->Draw("same");\r
-\r
-  cNClusters->cd(2);\r
-  //hNClustersPerTrackVsRun_Sigma->SetMaximum(1.1);\r
-  hNClustersPerTrackVsRun_Sigma->SetMinimum(0.4);\r
-  hNClustersPerTrackVsRun_Sigma->SetStats(kFALSE);\r
-  hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetRange(1,ibin-1);\r
-  hNClustersPerTrackVsRun_Sigma->GetXaxis()->SetNdivisions(1,kFALSE);\r
-  //hNClustersPerTrackVsRun_Sigma->LabelsOption("u");\r
-  hNClustersPerTrackVsRun_Sigma->SetLabelSize(LabelSize);\r
-  hNClustersPerTrackVsRun_Sigma->SetTitle("dispersion of the number of associated clusters or of the number of chamber hit per track");\r
-  hNClustersPerTrackVsRun_Sigma->SetLineWidth(2);\r
-  hNClustersPerTrackVsRun_Sigma->Draw("e");\r
-  hNChamberHitPerTrack_Sigma->SetLineWidth(2);\r
-  hNChamberHitPerTrack_Sigma->SetLineColor(kRed);\r
-  hNChamberHitPerTrack_Sigma->Draw("esame");\r
-  lNClusters->Draw("same");\r
-\r
-  cNClusters->Print(OutFileNamePDF.Data());\r
-  cNClusters->Write();\r
-\r
-\r
-  //==================================================\r
-  // Display average number of cluster per chamber\r
-  TLegend *lNClustersPerCh = new TLegend(0.92,0.45,0.99,0.99);\r
-  TCanvas* cNClustersPerCh = new TCanvas("cNClustersPerCh","cNClustersPerCh",1200,900);\r
-  cNClustersPerCh->cd();\r
-  cNClustersPerCh->SetRightMargin(0.1);\r
-  hNClustersInCh[0]->SetStats(kFALSE);\r
-  hNClustersInCh[0]->GetXaxis()->SetRange(1,ibin-1);\r
-  hNClustersInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);\r
-  //hNClustersInCh[0]->LabelsOption("u");\r
-  hNClustersInCh[0]->SetLabelSize(LabelSize);\r
-  hNClustersInCh[0]->SetTitle("averaged number of clusters in chamber i per track");\r
-  hNClustersInCh[0]->SetMaximum(1.2);\r
-  hNClustersInCh[0]->SetMinimum(0.01);\r
-  for (Int_t ich=0; ich<10; ich++) {\r
-    hNClustersInCh[ich]->SetLineColor(ich+1+ich/9);\r
-    hNClustersInCh[ich]->SetLineWidth(2);\r
-    if (ich == 0) hNClustersInCh[ich]->Draw("e");\r
-    else hNClustersInCh[ich]->Draw("esame");\r
-    lNClustersPerCh->AddEntry(hNClustersInCh[ich],Form("ch%d",ich+1),"PL");\r
-  }\r
-  lNClustersPerCh->Draw("same");\r
-  \r
-  cNClustersPerCh->Print(OutFileNamePDF.Data());\r
-  cNClustersPerCh->Write();\r
-\r
-  //==================================================\r
-  // Display average X and Y position of clusters per chamber\r
-  TLegend *lClusterHitMapPerCh = new TLegend(0.92,0.45,0.99,0.99);\r
-  TCanvas* cClusterHitMapPerCh = new TCanvas("cClusterHitMapPerCh","cClusterHitMapPerCh",1200,900);\r
-  cClusterHitMapPerCh->Divide(1,2);\r
-  cClusterHitMapPerCh->GetPad(1)->SetRightMargin(0.1);\r
-  cClusterHitMapPerCh->GetPad(2)->SetRightMargin(0.1);\r
-       \r
-  cClusterHitMapPerCh->cd(1);\r
-  hClusterHitMapXInCh[0]->SetStats(kFALSE);\r
-  hClusterHitMapXInCh[0]->GetXaxis()->SetRange(1,ibin-1);\r
-  hClusterHitMapXInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);\r
-  //hNClustersInCh[0]->LabelsOption("u");\r
-  hClusterHitMapXInCh[0]->SetLabelSize(LabelSize);\r
-  hClusterHitMapXInCh[0]->SetTitle("<X> of clusters - associated to a track - in chamber i");\r
-  hClusterHitMapXInCh[0]->SetMaximum(30);\r
-  hClusterHitMapXInCh[0]->SetMinimum(-30);\r
-  for (Int_t ich=0; ich<10; ich++) {\r
-    hClusterHitMapXInCh[ich]->SetLineColor(ich+1+ich/9);\r
-    hClusterHitMapXInCh[ich]->SetLineWidth(2);\r
-    if (ich == 0) hClusterHitMapXInCh[ich]->Draw("e");\r
-    else hClusterHitMapXInCh[ich]->Draw("esame");\r
-               \r
-    lClusterHitMapPerCh->AddEntry(hClusterHitMapXInCh[ich],Form("ch%d",ich+1),"PL");\r
-  }\r
-  lClusterHitMapPerCh->Draw("same");\r
-  \r
-  cClusterHitMapPerCh->cd(2);\r
-  hClusterHitMapYInCh[0]->SetStats(kFALSE);\r
-  hClusterHitMapYInCh[0]->GetXaxis()->SetRange(1,ibin-1);\r
-  hClusterHitMapYInCh[0]->GetXaxis()->SetNdivisions(1,kFALSE);\r
-  //hNClustersInCh[0]->LabelsOption("u");\r
-  hClusterHitMapYInCh[0]->SetLabelSize(LabelSize);\r
-  hClusterHitMapYInCh[0]->SetTitle("<Y> of clusters - associated to a track - in chamber i");\r
-  hClusterHitMapYInCh[0]->SetMaximum(30);\r
-  hClusterHitMapYInCh[0]->SetMinimum(-30);\r
-  for (Int_t ich=0; ich<10; ich++) {\r
-    hClusterHitMapYInCh[ich]->SetLineColor(ich+1+ich/9);\r
-    hClusterHitMapYInCh[ich]->SetLineWidth(2);\r
-    if (ich == 0) hClusterHitMapYInCh[ich]->Draw("e");\r
-    else hClusterHitMapYInCh[ich]->Draw("esame");\r
-  }\r
-  lClusterHitMapPerCh->Draw("same");\r
-  \r
-  cClusterHitMapPerCh->Print(OutFileNamePDF.Data());\r
-  cClusterHitMapPerCh->Write();\r
-\r
-\r
-  //==================================================\r
-  // Display tracks ChiSquare \r
-  TCanvas* cChi2 = new TCanvas("cChi2","cChi2",1200,900);\r
-  cChi2->Divide(1,2);\r
-  cChi2->cd(1);\r
-  hChi2_Mean->SetStats(kFALSE);\r
-  hChi2_Mean->GetXaxis()->SetRange(1,ibin-1);\r
-  hChi2_Mean->GetXaxis()->SetNdivisions(1,kFALSE);\r
-  //hChi2_Mean->LabelsOption("u");\r
-  hChi2_Mean->SetLabelSize(LabelSize);\r
-  hChi2_Mean->SetLineWidth(2);\r
-  hChi2_Mean->Draw("e");\r
-\r
-  cChi2->cd(2);\r
-  hChi2_Sigma->SetStats(kFALSE);\r
-  hChi2_Sigma->GetXaxis()->SetRange(1,ibin-1);\r
-  hChi2_Sigma->GetXaxis()->SetNdivisions(1,kFALSE);\r
-  //hChi2_Sigma->LabelsOption("u");\r
-  hChi2_Sigma->SetLabelSize(LabelSize);\r
-  hChi2_Sigma->SetLineWidth(2);\r
-  hChi2_Sigma->Draw("e");\r
-\r
-  cChi2->Print(OutFileNamePDF.Data());\r
-  cChi2->Write();\r
-\r
-  // close the PDF file\r
-  c1->Print(OutFileNamePDF_close.Data());\r
-  rootFileOut->Close();\r
-    \r
-  //====================================================\r
-  if (PRINTSTAT){\r
-    // set the format to print labels\r
-    THashList* labels = hMBB->GetXaxis()->GetLabels();\r
-    TString format(Form("\n%%%ds %%9d",0));\r
-  \r
-    // print value for each label\r
-    TObjString* label = 0x0;\r
-    TIter nextLabel(labels);\r
-    cout << "-------------------------------------------------" << endl;\r
-    cout << "Run Number" << "\t Number of CMBB after Phys. Sel. " << endl ;  \r
-    while ((label = static_cast<TObjString*>(nextLabel()))) {\r
-      Int_t bin = (Int_t) label->GetUniqueID();\r
-      printf(format.Data(), label->String().Data(), (Int_t) hMBB->GetBinContent(bin));\r
-    }\r
-    printf("\n\n");\r
-\r
-\r
-    cout << "-------------------------------------------------" << endl;\r
-    cout << "Total statistic" << endl; \r
-    cout << " " << endl ; \r
-    cout << "Number of  NumOfAllTriggers " << endl ;\r
-    cout << "\t before selection " << NumOfAllTriggersNoPS << "\t  after selection " <<   NumOfAllTriggersWithPS << " --> rejection = " <<  (Double_t) (NumOfAllTriggersNoPS-NumOfAllTriggersWithPS)/(NumOfAllTriggersNoPS)*100. << "%" << endl ; \r
-    cout << "Number of  NumOfCMBB " << endl ;\r
-    cout << "\t before selection " << NumOfMBBNoPS << "\t  after selection " <<   NumOfMBBWithPS << " --> rejection = " <<  (Double_t) (NumOfMBBNoPS-NumOfMBBWithPS)/(NumOfMBBNoPS)*100. << "%" << endl ; \r
-    cout << " " << endl ; \r
-    \r
-  }\r
-}\r