Using custom helper centrality class. Can now run with either a centrality or a selec...
authormfloris <mfloris@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 5 Nov 2010 17:10:08 +0000 (17:10 +0000)
committermfloris <mfloris@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 5 Nov 2010 17:10:08 +0000 (17:10 +0000)
PWG0/multPbPb/AddTaskMultPbPbTracks.C
PWG0/multPbPb/AliAnalysisMultPbCentralitySelector.cxx
PWG0/multPbPb/AliAnalysisMultPbCentralitySelector.h
PWG0/multPbPb/AliAnalysisTaskMultPbTracks.cxx
PWG0/multPbPb/AliAnalysisTaskMultPbTracks.h
PWG0/multPbPb/correct.C
PWG0/multPbPb/run.C

index a99b2b5..b5395ec 100644 (file)
@@ -1,4 +1,4 @@
-AliAnalysisTaskMultPbTracks * AddTaskMultPbPbTracks(const char * outfilename, AliESDtrackCuts * esdTrackCuts = 0)
+AliAnalysisTaskMultPbTracks * AddTaskMultPbPbTracks(const char * outfilename, AliESDtrackCuts * esdTrackCuts = 0, AliAnalysisMultPbCentralitySelector * centr)
 {
   // TODO: add some parameters to set the centrality for this task, and maybe the name of the task
   // TODO: shall I use the same file and different dirs for the different centralities?
@@ -36,11 +36,12 @@ AliAnalysisTaskMultPbTracks * AddTaskMultPbPbTracks(const char * outfilename, Al
       return;
     }  
   task->SetTrackCuts(esdTrackCuts);
-  
+
+  // set centrality
+  task->SetCentralitySelector(centr);
+
   // TODO:
   // IO into folders in a file?
-  // FIXME:
-  // Add centrality selection configuration (included arguments)
 
   // Set I/O
   AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer();
@@ -52,15 +53,15 @@ AliAnalysisTaskMultPbTracks * AddTaskMultPbPbTracks(const char * outfilename, Al
                                                            AliESDtrackCuts::Class(),
                                                            AliAnalysisManager::kOutputContainer,
                                                            outfilename);
-  // AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("cmultPbTracksOutCM",
-  //                                                       AliAnalysisMultPbCentralitySelector::Class(),
-  //                                                       AliAnalysisManager::kOutputContainer,
-  //                                                       outfilename);
+  AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("cmultPbTracksOutCM",
+                                                           AliAnalysisMultPbCentralitySelector::Class(),
+                                                           AliAnalysisManager::kOutputContainer,
+                                                           outfilename);
 
   mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
   mgr->ConnectOutput(task,1,coutput1);
   mgr->ConnectOutput(task,2,coutput2);
-  //  mgr->ConnectOutput(task,3,coutput3);
+  mgr->ConnectOutput(task,3,coutput3);
 
   return task;
 }   
index 6b0f646..789366d 100644 (file)
@@ -8,7 +8,9 @@
 #include "AliESDCentrality.h"
 #include "AliESDEvent.h"
 #include "AliLog.h"
+#include <iostream>
 
+using namespace std;
 
 
 // FIXME: bookkeep here all parameters of centrality estimate (files, estimator, selected bin...)
@@ -20,23 +22,33 @@ Bool_t AliAnalysisMultPbCentralitySelector::IsCentralityBinSelected(AliESDEvent*
   // Centrality selection
   // On MC cuts on the number of good tracks,
   // On data cuts using AliESDCentrality and the cut requested in ntracks
-  if(fIsMC) {
+
+  //  cout << "Tracks " << trackCuts->CountAcceptedTracks(aEsd) << endl;
+  
+
+  if(fIsMC || fUseMultRange) {
     if(!trackCuts){
       AliFatal("Track cuts object is invalid");
     }
+    //    cout << "Hey!" << endl;
+    
+    if (fCentrBin == -1) return kTRUE;
     if (trackCuts->CountAcceptedTracks(aEsd) < fMultMin) return kFALSE;
     if (trackCuts->CountAcceptedTracks(aEsd) > fMultMax) return kFALSE;                                                       
   }
 
   AliESDCentrality *centrality = aEsd->GetCentrality();
-  if(!centrality) {
+  if(!centrality && !fUseMultRange) {
     AliFatal("Centrality object not available"); 
   }
   else {
     Int_t centrBin = centrality->GetCentralityClass5(fCentrEstimator.Data()) ;    
-    if (centrBin != fCentrBin && fCentrBin != -1) return kFALSE;
+    if (centrBin != fCentrBin && fCentrBin != -1 && !fUseMultRange) return kFALSE;
   }
 
+  //  cout << "Selected" << endl;
+  
+
   return kTRUE;
 
 }
@@ -44,9 +56,14 @@ Bool_t AliAnalysisMultPbCentralitySelector::IsCentralityBinSelected(AliESDEvent*
 void AliAnalysisMultPbCentralitySelector::Print(Option_t* option ) const {
   // Print some information
 
-  Printf("AliAnalysisMultPbCentralitySelector");
+  Printf("AliAnalysisMultPbCentralitySelector [%s]", option);
   Printf(" - Centrality estimator [%s]",fCentrEstimator.Data());
-
+  Printf(" - Centrality bin       [%d]",fCentrBin);
+  Printf(" - File1 used for centrality estimate: [%s]", fFile1.Data());
+  Printf(" - File2 used for centrality estimate: [%s]", fFile2.Data());
+  if ( fUseMultRange ) {
+    Printf ("Using multiplicity range [%d - %d]",fMultMin,fMultMax);
+  }
   if ( fIsMC ) {    
     Printf("Running on Monte Carlo, actual cut was on tracks multiplicity [%d - %d]",fMultMin,fMultMax);    
   } 
index 0053722..1309b4a 100644 (file)
@@ -30,7 +30,7 @@ class AliAnalysisMultPbCentralitySelector : public AliAnalysisCuts
 {
 public:
 
-  AliAnalysisMultPbCentralitySelector() : fIsMC (0), fCentrEstimator(""), fCentrBin(-1), fMultMin(0), fMultMax(1000000) {;}
+  AliAnalysisMultPbCentralitySelector() : fIsMC (0), fCentrEstimator(""), fCentrBin(-1), fMultMin(0), fMultMax(1000000), fFile1(""), fFile2(""), fUseMultRange(kFALSE) {;}
   virtual ~AliAnalysisMultPbCentralitySelector(){}
     
   // AliAnalysisCuts interface
@@ -41,18 +41,25 @@ public:
   Bool_t IsCentralityBinSelected(AliESDEvent* aEsd, AliESDtrackCuts * trackCuts);
     
   void SetAnalyzeMC(Bool_t flag = kTRUE, Double_t multMin = 0, Double_t multMax=10000) { fIsMC = flag; fMultMin = multMin; fMultMax = multMax; }
+  void SetMultRange(Double_t multMin = 0, Double_t multMax=10000) { fMultMin = multMin; fMultMax = multMax; }
+  void SetUseMultRange(Bool_t flag = kTRUE) {fUseMultRange = flag;}
   void SetCentralityEstimator(const char * estimator) { fCentrEstimator = estimator; }
-
+  void SetCentralityBin(Int_t bin) { fCentrBin = bin; }
+  void SetCentrTaskFiles(const char * file1, const char * file2) { fFile1 = file1; fFile2 = file2; }
   virtual void Print(Option_t* option = "") const ;
   virtual Long64_t Merge(TCollection* list){list->GetEntries();return 0;}
   
 protected:
   Bool_t fIsMC;             // flag if MC is analyzed
   TString fCentrEstimator;  // Centrality estimator for AliESDCentrality
-  TString fCentrBin; // centrality bin to be selected
+  Int_t   fCentrBin; // centrality bin to be selected
   Int_t fMultMin ; // Minimum multiplicity, because on MC we cut on tracks rather than on the estimator  
   Int_t fMultMax ; // Maximum multiplicity, because on MC we cut on tracks rather than on the estimator  
-  ClassDef(AliAnalysisMultPbCentralitySelector, 1)
+  TString fFile1; // file used by centrality task. Set here for bookkeeping
+  TString fFile2; // file used by centrality task. Set here for bookkeeping
+  Bool_t fUseMultRange; // if true, use track bins rather than multiplicity estimator
+
+  ClassDef(AliAnalysisMultPbCentralitySelector, 2)
     
   private:
   AliAnalysisMultPbCentralitySelector(const AliAnalysisMultPbCentralitySelector&); // not implemented
index 11532c8..975cf97 100644 (file)
@@ -20,6 +20,7 @@
 #include "AliESDCentrality.h"
 
 #include <iostream>
+#include "AliAnalysisMultPbCentralitySelector.h"
 
 using namespace std;
 
@@ -27,13 +28,13 @@ ClassImp(AliAnalysisTaskMultPbTracks)
 
 AliAnalysisTaskMultPbTracks::AliAnalysisTaskMultPbTracks()
 : AliAnalysisTaskSE("TaskMultPbTracks"),
-  fESD(0),fHistoManager(0),fCentrBin(0),fCentralityEstimator(0),fTrackCuts(0),fTrackCutsNoDCA(0),fIsMC(0)
+  fESD(0),fHistoManager(0),fCentrSelector(0),fTrackCuts(0),fTrackCutsNoDCA(0),fIsMC(0)
 {
   // constructor
 
   DefineOutput(1, AliAnalysisMultPbTrackHistoManager::Class());
   DefineOutput(2, AliESDtrackCuts::Class());
-  //  DefineOutput(3, AliAnalysisMultPbCentralitySelector::Class());
+  DefineOutput(3, AliAnalysisMultPbCentralitySelector::Class());
 
   fHistoManager = new AliAnalysisMultPbTrackHistoManager("histoManager","Hitograms, Multiplicity, Track analysis");
   if(fIsMC) fHistoManager->SetSuffix("MC");
@@ -41,7 +42,7 @@ AliAnalysisTaskMultPbTracks::AliAnalysisTaskMultPbTracks()
 }
 AliAnalysisTaskMultPbTracks::AliAnalysisTaskMultPbTracks(const char * name)
   : AliAnalysisTaskSE(name),
-    fESD(0),fHistoManager(0),fCentrBin(0),fCentralityEstimator(0),fTrackCuts(0),fTrackCutsNoDCA(0),fIsMC(0)
+    fESD(0),fHistoManager(0),fCentrSelector(0),fTrackCuts(0),fTrackCutsNoDCA(0),fIsMC(0)
 {
   //
   // Standard constructur which should be used
@@ -49,7 +50,7 @@ AliAnalysisTaskMultPbTracks::AliAnalysisTaskMultPbTracks(const char * name)
 
   DefineOutput(1, AliAnalysisMultPbTrackHistoManager::Class());
   DefineOutput(2, AliESDtrackCuts::Class());
-  //  DefineOutput(3, AliAnalysisMultPbCentralitySelector::Class());
+  DefineOutput(3, AliAnalysisMultPbCentralitySelector::Class());
 
   fHistoManager = new AliAnalysisMultPbTrackHistoManager("histoManager","Hitograms, Multiplicity, Track analysis");
   if(fIsMC) fHistoManager->SetSuffix("MC");
@@ -57,15 +58,14 @@ AliAnalysisTaskMultPbTracks::AliAnalysisTaskMultPbTracks(const char * name)
 }
 
 AliAnalysisTaskMultPbTracks::AliAnalysisTaskMultPbTracks(const AliAnalysisTaskMultPbTracks& obj) : 
-  AliAnalysisTaskSE(obj) ,fESD (0), fHistoManager(0), fCentrBin(0), fCentralityEstimator(0),fTrackCuts(0),fTrackCutsNoDCA(0),fIsMC(0)
+  AliAnalysisTaskSE(obj) ,fESD (0), fHistoManager(0), fCentrSelector(0), fTrackCuts(0),fTrackCutsNoDCA(0),fIsMC(0)
 {
   //copy ctor
   fESD = obj.fESD ;
   fHistoManager= obj.fHistoManager;
-  fCentrBin = obj.fCentrBin;
-  fCentralityEstimator = obj.fCentralityEstimator;
   fTrackCuts  = obj.fTrackCuts;
   fTrackCutsNoDCA  = obj.fTrackCutsNoDCA;
+  fCentrSelector = obj.fCentrSelector;
 
 }
 
@@ -104,7 +104,7 @@ void AliAnalysisTaskMultPbTracks::UserExec(Option_t *)
   /* PostData(0) is taken care of by AliAnalysisTaskSE */
   PostData(1,fHistoManager);
   PostData(2,fTrackCuts);
-  //  PostData(3,fCentralityEstimator);
+  PostData(3,fCentrSelector);
 
   // Cache histogram pointers
   static TH3D * hTracks  [AliAnalysisMultPbTrackHistoManager::kNHistos];
@@ -124,7 +124,8 @@ void AliAnalysisTaskMultPbTracks::UserExec(Option_t *)
   hDCA[AliAnalysisMultPbTrackHistoManager::kHistoRecSecMat]  = fHistoManager->GetHistoDCA(AliAnalysisMultPbTrackHistoManager::kHistoRecSecMat );
   hDCA[AliAnalysisMultPbTrackHistoManager::kHistoRecSecWeak] = fHistoManager->GetHistoDCA(AliAnalysisMultPbTrackHistoManager::kHistoRecSecWeak);
 
-  hNTracks[AliAnalysisMultPbTrackHistoManager::kHistoGen]        = fHistoManager->GetHistoMult(AliAnalysisMultPbTrackHistoManager::kHistoGen       );
+  hNTracks[AliAnalysisMultPbTrackHistoManager::kHistoGen]        = fHistoManager->GetHistoMult(AliAnalysisMultPbTrackHistoManager::kHistoGen );
+  hNTracks[AliAnalysisMultPbTrackHistoManager::kHistoRec]        = fHistoManager->GetHistoMult(AliAnalysisMultPbTrackHistoManager::kHistoRec );
 
   fESD = dynamic_cast<AliESDEvent*>(fInputEvent);
   if (strcmp(fESD->ClassName(),"AliESDEvent")) {
@@ -135,18 +136,18 @@ void AliAnalysisTaskMultPbTracks::UserExec(Option_t *)
   fHistoManager->GetHistoStats()->Fill(AliAnalysisMultPbTrackHistoManager::kStatAll);
 
   // Centrality selection
-  // Bool_t isCentralitySelected = fCentrSelector->IsSelected(fESD);  
-  // if(!isCentralitySelected) return;
-
-  AliESDCentrality *centrality = fESD->GetCentrality();
-  if(!centrality) {
-    AliFatal("Centrality object not available"); 
-  }
-  else {
-    Int_t centrBin = centrality->GetCentralityClass5(fCentralityEstimator.Data()) ;
+  Bool_t isCentralitySelected = fCentrSelector->IsCentralityBinSelected(fESD,fTrackCuts);  
+  if(!isCentralitySelected) return;
+
+  // AliESDCentrality *centrality = fESD->GetCentrality();
+  // if(!centrality) {
+  //   AliFatal("Centrality object not available"); 
+  // }
+  // else {
+  //   Int_t centrBin = centrality->GetCentralityClass5(fCentralityEstimator.Data()) ;
     
-    if (centrBin != fCentrBin && fCentrBin != -1) return;
-  }
+  //   if (centrBin != fCentrBin && fCentrBin != -1) return;
+  // }
 
   fHistoManager->GetHistoStats()->Fill(AliAnalysisMultPbTrackHistoManager::kStatCentr);
 
@@ -200,7 +201,7 @@ void AliAnalysisTaskMultPbTracks::UserExec(Option_t *)
 
   // loop on tracks
   Int_t ntracks = fESD->GetNumberOfTracks();
-
+  Int_t acceptedTracks = 0;
 
   for (Int_t itrack = 0; itrack<ntracks; itrack++) {    
     AliESDtrack * esdTrack = fESD->GetTrack(itrack);
@@ -209,6 +210,8 @@ void AliAnalysisTaskMultPbTracks::UserExec(Option_t *)
     Bool_t accepted = fTrackCuts->AcceptTrack(esdTrack);
     Bool_t acceptedNoDCA = fTrackCutsNoDCA->AcceptTrack(esdTrack);
 
+    if(accepted) acceptedTracks++;
+
     // Compute weighted offset
     // TODO: other choiches for the DCA?
     Double_t b = fESD->GetMagneticField();
@@ -296,6 +299,9 @@ void AliAnalysisTaskMultPbTracks::UserExec(Option_t *)
 
 
   }
+  //  cout << acceptedTracks << endl;
+  
+  hNTracks[AliAnalysisMultPbTrackHistoManager::kHistoRec]  ->Fill(acceptedTracks);
 
 
 }
index 3bd7979..24a6bb2 100644 (file)
@@ -29,10 +29,10 @@ public:
   AliAnalysisTaskMultPbTracks(const char * name);
   AliAnalysisTaskMultPbTracks(const AliAnalysisTaskMultPbTracks& obj) ;
   ~AliAnalysisTaskMultPbTracks();
-  //void SetCentralitySelector(AliAnalysisMultPbCentralitySelector * centr) { fCentrSelector=centr;}
   void SetTrackCuts(AliESDtrackCuts * cuts) { fTrackCuts = cuts;}
-  void SetCentralityBin(Int_t bin = 0) { fCentrBin = bin; }
-  void SetCentralityEstimator(const char * centr) { fCentralityEstimator = centr; }
+  void SetCentralitySelector(AliAnalysisMultPbCentralitySelector * centr) { fCentrSelector=centr;}
+  // void SetCentralityBin(Int_t bin = 0) { fCentrBin = bin; }
+  // void SetCentralityEstimator(const char * centr) { fCentralityEstimator = centr; }
 
   void SetIsMC(Bool_t flag=kTRUE) { fIsMC = flag;}
   AliAnalysisMultPbTrackHistoManager * GetHistoManager() { return fHistoManager;}
@@ -50,9 +50,9 @@ private:
   AliESDEvent *  fESD;    //! ESD object  AliVEvent*     fEvent;
   //  TList * fListHisto;     // list of output object
   AliAnalysisMultPbTrackHistoManager  * fHistoManager; // wrapper for the list, takes care of merging + histo booking and getters
-  //  AliAnalysisMultPbCentralitySelector * fCentrSelector; // centrality selector
-  Int_t fCentrBin; // centrality bin selected (5% XS percentiles)
-  TString fCentralityEstimator; // Name of the centrality estimator, for AliESDCentrality
+  AliAnalysisMultPbCentralitySelector * fCentrSelector; // centrality selector
+  // Int_t fCentrBin; // centrality bin selected (5% XS percentiles)
+  // TString fCentralityEstimator; // Name of the centrality estimator, for AliESDCentrality
   AliESDtrackCuts * fTrackCuts; // track cuts
   AliESDtrackCuts * fTrackCutsNoDCA; // copy of the previous one, but with no DCA cuts
   
index 244dfab..3234c0b 100644 (file)
@@ -10,6 +10,7 @@
 #include "TDatabasePDG.h"
 #include "AliPhysicsSelection.h"
 #include "AliESDtrackCuts.h"
+#include "AliAnalysisMultPbCentralitySelector.h"
 
 using namespace std;
 
@@ -320,6 +321,8 @@ void LoadData(TString dataFolder, TString correctionFolder){
   hEvStatData = (TH2D*) fStatData->Get("fHistStatistics");
   hEvStatCorr = (TH2D*) fStatCorr->Get("fHistStatistics");
 
+  AliAnalysisMultPbCentralitySelector * centrData = (AliAnalysisMultPbCentralitySelector*) fData->Get("");
+
   // Normalize
   Int_t irowGoodTrigger = 1;
   if (hEvStatCorr && hEvStatData) {
index 1a698fd..e00a51e 100644 (file)
@@ -57,11 +57,21 @@ void run(Char_t* data, Long64_t nev = -1, Long64_t offset = 0, Bool_t debug = kF
 
   // Centrality
   AliCentralitySelectionTask *taskCentr = new AliCentralitySelectionTask("CentralitySelection");
-  taskCentr->SetPercentileFile("$ALICE_ROOT/ANALYSIS/macros/test_AliCentralityBy1D.root");
-  taskCentr->SetPercentileFile2("$ALICE_ROOT/ANALYSIS/macros/test_AliCentralityByFunction.root");
+  const char * file1 = "$ALICE_ROOT/ANALYSIS/macros/test_AliCentralityBy1D.root";
+  const char * file2 = "$ALICE_ROOT/ANALYSIS/macros/test_AliCentralityByFunction.root";
+  taskCentr->SetPercentileFile (file1);
+  taskCentr->SetPercentileFile2(file2);
   mgr->AddTask(taskCentr);
   mgr->ConnectInput (taskCentr,0, mgr->GetCommonInputContainer());
 
+  // Create my own centrality selector
+  AliAnalysisMultPbCentralitySelector * centrSelector = new AliAnalysisMultPbCentralitySelector();
+  centrSelector->SetCentrTaskFiles(file1,file2);
+  centrSelector->SetCentralityBin(centrBin);
+  centrSelector->SetCentralityEstimator(centrEstimator);
+  // FIXME!!!
+  centrSelector->SetUseMultRange();
+  centrSelector->SetMultRange(10,20);
 
   // Parse option strings
   TString optionStr(option);
@@ -104,15 +114,13 @@ void run(Char_t* data, Long64_t nev = -1, Long64_t offset = 0, Bool_t debug = kF
   
   // load my task
   gROOT->ProcessLine(".L $ALICE_ROOT/PWG0/multPbPb/AddTaskMultPbPbTracks.C");
-  AliAnalysisTaskMultPbTracks * task = AddTaskMultPbPbTracks("multPbPbtracks.root", cuts); // kTRUE enables DCA cut
+  AliAnalysisTaskMultPbTracks * task = AddTaskMultPbPbTracks("multPbPbtracks.root", cuts, centrSelector); // kTRUE enables DCA cut
   task->SetIsMC(useMCKinematics);
   if(useMCKinematics) task->GetHistoManager()->SetSuffix("MC");
   if(customSuffix!=""){
     cout << "Setting custom suffix: " << customSuffix << endl;    
     task->GetHistoManager()->SetSuffix(customSuffix);
   }
-  task->SetCentralityBin(centrBin);
-  task->SetCentralityEstimator(centrEstimator);
   
   if (!mgr->InitAnalysis()) return;
        
@@ -191,6 +199,7 @@ void InitAndLoadLibs(Int_t runMode=kMyRunModeLocal, Int_t workers=0,Bool_t debug
   listToLoad->Add(new TObjString("$ALICE_ROOT/ANALYSIS/AliCentralitySelectionTask.cxx+"));
   listToLoad->Add(new TObjString("$ALICE_ROOT/PWG1/background/AliHistoListWrapper.cxx+"));
   listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisMultPbTrackHistoManager.cxx+"));
+  listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisMultPbCentralitySelector.cxx+"));
   listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisTaskMultPbTracks.cxx+"));