Fix problem in terminate. Add possibility to select the minimum number of vertex...
authorpcrochet <pcrochet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 13 Jun 2012 12:39:16 +0000 (12:39 +0000)
committerpcrochet <pcrochet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 13 Jun 2012 12:39:16 +0000 (12:39 +0000)
PWG/muon/AliAnalysisTaskSingleMu.cxx
PWG/muon/AliAnalysisTaskSingleMu.h
PWG/muon/AliVAnalysisMuon.cxx
PWG/muon/AliVAnalysisMuon.h

index 6edcdbc..f59ef09 100644 (file)
@@ -20,7 +20,6 @@
 /// Analysis task for single muons in the spectrometer.
 /// The output is a list of histograms and CF containers.
 /// The macro class can run on AODs or ESDs.
-/// In the latter case a flag can be activated to produce a tree as output.
 /// If Monte Carlo information is present, some basics checks are performed.
 ///
 /// \author Diego Stocco
@@ -294,11 +293,12 @@ void AliAnalysisTaskSingleMu::Terminate(Option_t *) {
   TString currName = "";
   for ( Int_t iopt=0; iopt<optArr->GetEntries(); iopt++ ) {
     currName = optArr->At(iopt)->GetName();
-    if ( currName.Contains("-B-") ) minBiasTrig = currName;
+    if ( currName.Contains("-B-") || currName.Contains("ANY") ) minBiasTrig = currName;
   }
   delete optArr;
 
   furtherOpt.ToUpper();
+  Bool_t plotChargeAsymmetry = furtherOpt.Contains("ASYM");
   
   AliCFContainer* cfContainer = static_cast<AliCFContainer*> ( GetSum(physSel,trigClassName,centralityRange,"SingleMuContainer") );
   if ( ! cfContainer ) return;
@@ -334,7 +334,7 @@ void AliAnalysisTaskSingleMu::Terminate(Option_t *) {
   TCanvas* canKine[3] = {0x0, 0x0, 0x0};
   TLegend* legKine[3] = {0x0, 0x0, 0x0};
   for ( Int_t isrc = firstSrc; isrc <= lastSrc; ++isrc ) {
-    for ( Int_t icharge=0; icharge<2; ++icharge ) {        
+    for ( Int_t icharge=0; icharge<2; ++icharge ) {
       for ( Int_t igrid=0; igrid<3; ++igrid ) {
         if ( gridSparseArray[igrid]->GetEntries() == 0. ) break;
         if ( gridSparseArray[igrid]->IsA() != AliCFEffGrid::Class() ) {
@@ -355,7 +355,7 @@ void AliAnalysisTaskSingleMu::Terminate(Option_t *) {
           canKine[igrid]->cd(iproj+1);
           if ( ( iproj == kHvarPt || iproj == kHvarVz ) && gridSparseArray[igrid]->IsA() != AliCFEffGrid::Class() ) gPad->SetLogy();
           TH1* projHisto = gridSparseArray[igrid]->Project(iproj);
-          projHisto->SetName(Form("proj%i_%s_src%i_charge%i", iproj, gridSparseName[igrid].Data(), isrc, icharge));
+          projHisto->SetName(Form("proj%i_%s_%s_%s", iproj, gridSparseName[igrid].Data(), fSrcKeys->At(isrc)->GetName(), fChargeKeys->At(icharge)->GetName()));
           if ( projHisto->GetEntries() == 0 ) continue;
           Bool_t isFirst = ( gPad->GetListOfPrimitives()->GetEntries() == 0 );
           drawOpt = isFirst ? "e" : "esames";
@@ -386,6 +386,49 @@ void AliAnalysisTaskSingleMu::Terminate(Option_t *) {
     if ( gridSparseArray[igrid]->IsA() == AliCFEffGrid::Class() ) continue;
     SetSparseRange(gridSparseArray[igrid], kHvarCharge, "", 1, gridSparseArray[igrid]->GetAxis(kHvarCharge)->GetNbins(), "USEBIN"); // Reset range
   } // loop on container steps
+
+  // Plot charge asymmetry or mu+/mu-
+  TString basePlotName = plotChargeAsymmetry ? "ChargeAsymmetry" : "ChargeRatio";
+  for ( Int_t igrid=0; igrid<2; igrid++ ) {
+    if ( ! canKine[igrid] ) continue;
+    TList* padList = canKine[igrid]->GetListOfPrimitives();
+    currName = canKine[igrid]->GetName();
+    currName.Append(Form("_%s", basePlotName.Data()));
+    can = new TCanvas(currName.Data(),currName.Data(),canKine[igrid]->GetWindowTopX(),igroup2*yshift,600,600);
+    can->Divide(2,2);
+    for ( Int_t ipad=0; ipad<padList->GetEntries(); ipad++ ) {
+      TPad* pad = dynamic_cast<TPad*> (padList->At(ipad));
+      if ( ! pad ) continue;
+      TList* histoList = pad->GetListOfPrimitives();
+      can->cd(ipad+1);
+      for ( Int_t iobj=0; iobj<histoList->GetEntries(); iobj++ ) {
+        currName = histoList->At(iobj)->GetName();
+        if ( ! histoList->At(iobj)->InheritsFrom(TH1::Class()) || ! currName.Contains(fChargeKeys->At(1)->GetName()) ) continue;
+        histoName = currName;
+        histoName.ReplaceAll(fChargeKeys->At(1)->GetName(),"");
+        histoName.Append(Form("_%s", basePlotName.Data()));
+        currName.ReplaceAll(fChargeKeys->At(1)->GetName(), fChargeKeys->At(0)->GetName());
+        TH1* auxHisto = dynamic_cast<TH1*> (histoList->FindObject(currName.Data()));
+        if ( ! auxHisto ) continue;        
+        TH1* histo = static_cast<TH1*> (histoList->At(iobj)->Clone(histoName.Data()));
+        if ( plotChargeAsymmetry ) {
+          histo->Add(auxHisto, -1.);
+          // h2 + h1 = 2xh2 + (h1-h2)
+          auxHisto->Add(auxHisto, histo, 2.);
+        }
+        histo->Divide(auxHisto);
+        histo->SetMarkerStyle(20);
+        TString axisTitle = plotChargeAsymmetry ? Form("(%s - %s) / (%s + %s)", fChargeKeys->At(1)->GetName(), fChargeKeys->At(0)->GetName(), fChargeKeys->At(1)->GetName(), fChargeKeys->At(0)->GetName()) : Form("%s / %s", fChargeKeys->At(1)->GetName(), fChargeKeys->At(0)->GetName());
+        axisTitle.ReplaceAll("MuPlus","#mu^{+}");
+        axisTitle.ReplaceAll("MuMinus","#mu^{-}");
+        histo->GetYaxis()->SetTitle(axisTitle.Data());
+        histo->SetStats(kFALSE);
+        drawOpt = ( gPad->GetListOfPrimitives()->GetEntries() == 0 ) ? "e" : "esames";
+        histo->Draw(drawOpt.Data());
+      } // loop on histos
+      gPad->Update();
+    } // loop on pads
+  } // loop on container steps
   
   
   //////////////////////
@@ -411,7 +454,8 @@ void AliAnalysisTaskSingleMu::Terminate(Option_t *) {
   // Vertex method //
   ///////////////////
   if ( ! furtherOpt.Contains("VERTEX") ) return;
-  Int_t firstMother = kUnidentified, lastMother = kUnidentified;
+  Int_t firstMother = ( isMC ) ? 0 : kUnidentified;
+  Int_t lastMother = ( isMC ) ? kNtrackSources - 1 : kUnidentified;
   igroup1++;
   TH1* eventVertex = (TH1*)GetSum(physSel, minBiasTrig, centralityRange, "hIpVtx");
   if ( ! eventVertex ) return;
index 953550c..42f8ea1 100644 (file)
 //
 
 #include "AliVAnalysisMuon.h"
-#include "TVector3.h"
 
 class TObjArray;
-class AliHistogramCollection;
 class TString;
 class TAxis;
-class AliVParticle;
-class AliAODEvent;
 class AliMuonTrackCuts;
 
 class AliAnalysisTaskSingleMu : public AliVAnalysisMuon {
index 456073e..ba87c06 100644 (file)
@@ -335,7 +335,7 @@ void AliVAnalysisMuon::UserExec(Option_t * /*option*/)
     return;
   }
 
-  Double_t centrality = InputEvent()->GetCentrality()->GetCentralityPercentile("V0M");
+  Double_t centrality = InputEvent()->GetCentrality()->GetCentralityPercentileUnchecked("V0M");
   Int_t centralityBin = fCentralityClasses->FindBin(centrality);
   TString centralityBinLabel = fCentralityClasses->GetBinLabel(centralityBin);
 
@@ -360,6 +360,8 @@ void AliVAnalysisMuon::Terminate(Option_t *)
   /// Draw some histogram at the end.
   //
   
+  if ( ! fTerminateOptions ) SetTerminateOptions();
+  
   if ( gROOT->IsBatch() ) return;
     
   fOutputList = dynamic_cast<TObjArray*>(GetOutputData(1));
@@ -367,9 +369,8 @@ void AliVAnalysisMuon::Terminate(Option_t *)
   fEventCounters = static_cast<AliCounterCollection*>(fOutputList->FindObject("eventCounters"));
   fMergeableCollection = static_cast<AliMergeableCollection*>(fOutputList->FindObject("outputObjects"));
   
-  if ( ! fTerminateOptions ) SetTerminateOptions();
   if ( ! fMergeableCollection ) return;
-  AliInfo(Form("Histogram collection size %g MB", fMergeableCollection->EstimateSize()/1024.0/1024.0));
+  AliInfo(Form("Mergeable collection size %g MB", fMergeableCollection->EstimateSize()/1024.0/1024.0));
   if ( fTerminateOptions->At(3) ) {
     TString sopt = fTerminateOptions->At(3)->GetName();
     if ( sopt.Contains("verbose") ) fMergeableCollection->Print("*"); 
@@ -404,7 +405,7 @@ AliVParticle* AliVAnalysisMuon::GetTrack(Int_t itrack)
 Double_t AliVAnalysisMuon::MuonMass2() const
 {
   /// A usefull constant
-  static Double_t m2 = 1.11636129640000012e-02; // using a constant here as the line below is a problem for CINT...
+  static Double_t m2 = 1.11636129640000012e-02;
   return m2;
 }
 
index ad6794a..c1a109e 100644 (file)
@@ -56,6 +56,9 @@ class AliVAnalysisMuon : public AliAnalysisTaskSE {
                                Int_t ivar, TString labelName,
                                Double_t varMin, Double_t varMax,
                                TString option = "");
+  
+  /// Set minimum number of vertex contributors
+  void SetMinNvtxContributors(Int_t minNvtxContributors) { fMinNvtxContirbutors = minNvtxContributors; }
 
  protected:
   
@@ -107,8 +110,6 @@ class AliVAnalysisMuon : public AliAnalysisTaskSE {
   
   // Methods for event information
   AliVVertex* GetVertexSPD() const;
-  /// Set minimum number of vertex contributors
-  void SetMinNvtxContributors(Int_t minNvtxContributors) { fMinNvtxContirbutors = minNvtxContributors; }
   
   enum {
     kPhysSelPass,    ///< Physics selected events