modifications and additional classes for nonprimary particle flow
authorsnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 26 Dec 2010 21:24:31 +0000 (21:24 +0000)
committersnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 26 Dec 2010 21:24:31 +0000 (21:24 +0000)
13 files changed:
PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.cxx
PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.h
PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowEvent.cxx
PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowEvent.h
PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowK0Candidates.cxx [new file with mode: 0644]
PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowK0Candidates.h [new file with mode: 0644]
PWG2/FLOW/AliFlowTasks/AliFlowCandidateTrack.cxx [new file with mode: 0644]
PWG2/FLOW/AliFlowTasks/AliFlowCandidateTrack.h [new file with mode: 0644]
PWG2/FLOW/AliFlowTasks/AliFlowTrackCuts.cxx
PWG2/FLOW/AliFlowTasks/AliFlowTrackCuts.h
PWG2/FLOW/macros/runFlowTaskCentralityTrain4Candidates.C [new file with mode: 0644]
PWG2/PWG2flowTasksLinkDef.h
PWG2/libPWG2flowTasks.pkg

index 0a3598f..08ed027 100644 (file)
@@ -40,7 +40,8 @@ AliFlowTrackSimple::AliFlowTrackSimple():
   fTrackWeight(1.),
   fCharge(0),
   fFlowBits(0),
-  fSubEventBits(0)
+  fSubEventBits(0),
+  fCollIndex(-1)
 {
   //constructor 
 }
@@ -54,7 +55,8 @@ AliFlowTrackSimple::AliFlowTrackSimple(Double_t phi, Double_t eta, Double_t pt,
   fTrackWeight(weight),
   fCharge(charge),
   fFlowBits(0),
-  fSubEventBits(0)
+  fSubEventBits(0),
+  fCollIndex(-1)
 {
   //constructor 
 }
@@ -68,7 +70,8 @@ AliFlowTrackSimple::AliFlowTrackSimple( TParticle* p ):
   fTrackWeight(1.),
   fCharge(0),
   fFlowBits(0),
-  fSubEventBits(0)
+  fSubEventBits(0),
+  fCollIndex(-1)
 {
   //ctor
   TParticlePDG* ppdg = p->GetPDG();
@@ -84,7 +87,8 @@ AliFlowTrackSimple::AliFlowTrackSimple(const AliFlowTrackSimple& aTrack):
   fTrackWeight(aTrack.fTrackWeight),
   fCharge(aTrack.fCharge),
   fFlowBits(aTrack.fFlowBits),
-  fSubEventBits(aTrack.fSubEventBits)
+  fSubEventBits(aTrack.fSubEventBits),
+  fCollIndex(-1)
 {
   //copy constructor 
 }
@@ -106,6 +110,7 @@ AliFlowTrackSimple& AliFlowTrackSimple::operator=(const AliFlowTrackSimple& aTra
   fCharge = aTrack.fCharge;
   fFlowBits = aTrack.fFlowBits;
   fSubEventBits = aTrack.fSubEventBits;
+  fCollIndex = aTrack.fCollIndex;
 
   return *this;
 }
index e1cb5bb..fde228c 100644 (file)
@@ -82,6 +82,8 @@ public:
     
   const TBits* GetFlowBits() const {return &fFlowBits;}
 
+  void SetIndexOnCollection(int i) {fCollIndex=i;}
+
  private:
   AliFlowTrackSimple(Double_t phi, Double_t eta, Double_t pt, Double_t weight, Int_t charge);
   Double_t fEta;         // eta
@@ -91,6 +93,7 @@ public:
   Int_t fCharge;         //charge
   TBits    fFlowBits;    // bits to set if track is selected
   TBits    fSubEventBits;// bits to set if track is selected for a subevent
+  Int_t    fCollIndex;   // stores the relative position of the track in the original collection
 
   ClassDef(AliFlowTrackSimple,1)                 // macro for rootcint
 
index f1e7225..3dcefc8 100644 (file)
 #include "AliGenGeVSimEventHeader.h"
 #include "AliGenEposEventHeader.h"
 
+// Interface to Load short life particles
+#include "TObjArray.h"
+#include "AliFlowCandidateTrack.h"
+
 // Interface to make the Flow Event Simple used in the flow analysis methods
 #include "AliFlowEvent.h"
 #include "AliFlowTrackCuts.h"
@@ -96,6 +100,7 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() :
   fMinB(0.01),
   fMaxB(1.0),
   fQA(kFALSE),
+  fLoadCandidates(kFALSE),
   fNbinsMult(10000),
   fNbinsPt(100),   
   fNbinsPhi(100),
@@ -132,7 +137,7 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() :
 }
 
 //________________________________________________________________________
-AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPtype, Bool_t on, UInt_t iseed) :
+AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPtype, Bool_t on, UInt_t iseed, Bool_t bCandidates) :
   AliAnalysisTaskSE(name),
   //  fOutputFile(NULL),
   fAnalysisType("AUTOMATIC"),
@@ -151,6 +156,7 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPt
   fMinB(0.01),
   fMaxB(1.0),
   fQA(on),
+  fLoadCandidates(bCandidates),
   fNbinsMult(10000),
   fNbinsPt(100),   
   fNbinsPhi(100),
@@ -187,10 +193,14 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPt
   fMyTRandom3 = new TRandom3(iseed);
   gRandom->SetSeed(fMyTRandom3->Integer(65539));
 
+  int availableINslot=1;
   //FMD input slot
   if (strcmp(RPtype,"FMD")==0) {
-    DefineInput(1, TList::Class());
+    DefineInput(availableINslot++, TList::Class());
   }
+  //Candidates input slot
+  if( fLoadCandidates )
+    DefineInput(availableINslot, TObjArray::Class());
 
   //PID
   fESDpid=new AliESDpid();
@@ -204,6 +214,7 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPt
     DefineOutput(2, TList::Class());
     DefineOutput(3, TList::Class());
   }
+
   // and for testing open an output file
   //  fOutputFile = new TFile("FlowEvents.root","RECREATE");
 
@@ -309,8 +320,9 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
   AliESDPmdTrack* pmdtracks = NULL;//pmd      
   TH2F* histFMD = NULL;
 
-  if(GetNinputs()==2) {                   
-    TList* FMDdata = dynamic_cast<TList*>(GetInputData(1));
+  int availableINslot=1;
+  if(strcmp(fRPType,"FMD")==0) {
+    TList* FMDdata = dynamic_cast<TList*>(GetInputData(availableINslot++));
     if(!FMDdata) {
       cout<<" No FMDdata "<<endl;
       exit(2);
@@ -487,6 +499,17 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
     flowEvent = new AliFlowEvent(myAOD);
   }
 
+  //inject candidates
+  if(fLoadCandidates) {
+    TObjArray* Candidates = dynamic_cast<TObjArray*>(GetInputData(availableINslot++));
+    AliFlowCandidateTrack *cand;
+    for(int iCand=0; iCand!=Candidates->GetEntriesFast(); ++iCand ) {
+      cand = dynamic_cast<AliFlowCandidateTrack*>(Candidates->At(iCand));
+      cand->SetForPOISelection();
+      flowEvent->AddTrack(cand);
+    }
+  }
+
   //check final event cuts
   Int_t mult = flowEvent->NumberOfTracks();
   AliInfo(Form("FlowEvent has %i tracks",mult));
index f8fa3a2..8bdcb2d 100644 (file)
@@ -26,7 +26,7 @@ class AliTOFT0maker;
 class AliAnalysisTaskFlowEvent : public AliAnalysisTaskSE {
  public:
   AliAnalysisTaskFlowEvent();
-  AliAnalysisTaskFlowEvent(const char *name, TString RPtype, Bool_t QAon, UInt_t seed=666);
+  AliAnalysisTaskFlowEvent(const char *name, TString RPtype, Bool_t QAon, UInt_t seed=666, Bool_t bCandidates=kFALSE);
   virtual ~AliAnalysisTaskFlowEvent();
   
   virtual void   UserCreateOutputObjects();
@@ -128,6 +128,7 @@ class AliAnalysisTaskFlowEvent : public AliAnalysisTaskSE {
   Double_t      fMaxB;              // Maximum of eta range for subevent B
 
   Bool_t fQA;                       // flag to set the filling of the QA hostograms
+  Bool_t fLoadCandidates;           // true if reciving candidates collection
 
   // setters for common constants
   //histogram sizes
diff --git a/PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowK0Candidates.cxx b/PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowK0Candidates.cxx
new file mode 100644 (file)
index 0000000..833b6db
--- /dev/null
@@ -0,0 +1,229 @@
+/*************************************************************************
+* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+/////////////////////////////////////////////////////
+// AliAnalysisTaskFlowK0Candidates:
+// Analysis task to select K0 candidates for flow analysis.
+// Uses one AliESDtrackCuts object for both daughters and
+// QA histograms to monitor the reconstruction.
+// Author: Carlos Perez (cperez@cern.ch)
+//////////////////////////////////////////////////////
+
+#include "TChain.h"
+#include "TList.h"
+#include "TH1D.h"
+#include "TVector3.h"
+
+#include "AliAnalysisTaskSE.h"
+#include "AliAnalysisManager.h"
+
+#include "AliESDEvent.h"
+#include "AliESDInputHandler.h"
+#include "AliESDtrack.h"
+#include "AliESDtrackCuts.h"
+
+#include "AliAODEvent.h"
+#include "AliAODInputHandler.h"
+#include "AliAODTrack.h"
+
+#include "AliCFManager.h"
+
+#include "TObjArray.h"
+#include "AliFlowCandidateTrack.h"
+#include "AliFlowEventCuts.h"
+
+#include "AliAnalysisTaskFlowK0Candidates.h"
+
+
+ClassImp(AliAnalysisTaskFlowK0Candidates)
+
+//_____________________________________________________________________________
+AliAnalysisTaskFlowK0Candidates::AliAnalysisTaskFlowK0Candidates() :
+  AliAnalysisTaskSE(),
+  fCutsEvent(NULL),
+  fCuts(NULL),
+  fList(NULL),
+  fMass(NULL),
+  fDCA(NULL),
+  fDL(NULL),
+  fCTP(NULL),
+  fMassF(NULL),
+  fDCAF(NULL),
+  fDLF(NULL),
+  fCTPF(NULL),
+  fMassMin(0),
+  fMassMax(0)
+{
+}
+
+//_____________________________________________________________________________
+AliAnalysisTaskFlowK0Candidates::AliAnalysisTaskFlowK0Candidates(const char *name, AliFlowEventCuts *cutsEvent, AliESDtrackCuts *cuts, Double_t MassMin, Double_t MassMax) :
+  AliAnalysisTaskSE(name),
+  fCutsEvent(cutsEvent),
+  fCuts(cuts),
+  fList(NULL),
+  fMass(NULL),
+  fDCA(NULL),
+  fDL(NULL),
+  fCTP(NULL),
+  fMassF(NULL),
+  fDCAF(NULL),
+  fDLF(NULL),
+  fCTPF(NULL),
+  fMassMin(MassMin),
+  fMassMax(MassMax)
+{
+  DefineInput(  0, TChain::Class() );
+  DefineOutput( 1, TObjArray::Class() );
+  DefineOutput( 2, TList::Class() );
+}
+
+//_____________________________________________________________________________
+AliAnalysisTaskFlowK0Candidates::~AliAnalysisTaskFlowK0Candidates()
+{
+  if(fList) {
+    fList->Delete();
+    delete fList;
+  }
+}
+
+//_____________________________________________________________________________
+void AliAnalysisTaskFlowK0Candidates::UserCreateOutputObjects()
+{
+  fList = new TList();
+  fList->SetOwner();
+  fMass = new TH1D( "fMass","Mass;M_{#pi#pi} [GeV];Counts per MeV", 180, 0.41, 0.59); fList->Add( fMass );
+  fDCA  = new TH1D( "fDCA" ,"DCA;[cm];Counts per 10 um",            180, 0.00, 0.18); fList->Add( fDCA  );
+  fDL   = new TH1D( "fDL"  ,"Decay Length;[cm];Counts per 0.1 mm",  180, 0.00, 1.80); fList->Add( fDL   );
+  fCTP  = new TH1D( "fCTP" ,"Cos#theta_{p}",                        180,-1.10, 1.10); fList->Add( fCTP  );
+
+  fMassF= new TH1D( "fMassF","Mass after Cuts;M_{#pi#pi} [GeV];Counts per MeV", 180, 0.41, 0.59); fList->Add( fMassF );
+  fDCAF = new TH1D( "fDCAF" ,"DCA after Cuts;[cm];Counts per 10 um",            180, 0.00, 0.18); fList->Add( fDCAF  );
+  fDLF  = new TH1D( "fDLF"  ,"Decay Length after Cuts;[cm];Counts per 0.1 mm",  180, 0.00, 1.80); fList->Add( fDLF   );
+  fCTPF = new TH1D( "fCTPF" ,"Cos#theta_{p} after Cuts",                        180,-1.10, 1.10); fList->Add( fCTPF  );
+
+  PostData( 2, fList);
+}
+
+
+//_____________________________________________________________________________
+void AliAnalysisTaskFlowK0Candidates::NotifyRun()
+{
+  AliESDEvent *fESD = dynamic_cast<AliESDEvent*>(InputEvent());
+  if(!fESD) return;
+}
+
+//_____________________________________________________________________________
+void AliAnalysisTaskFlowK0Candidates::UserExec(Option_t *)
+{
+  AliESDEvent *fESD = dynamic_cast<AliESDEvent*>(fInputEvent);
+  if(!fESD) return;
+  if(fCutsEvent)
+    if( !(fCutsEvent->IsSelected(InputEvent())) ) return;
+
+  TObjArray *POIselection =  new TObjArray();
+  POIselection->SetOwner();
+
+  int nTracks = fESD->GetNumberOfTracks();
+  for(int i=0; i!=nTracks; ++i) {  // first particle
+    AliESDtrack *ioT = fESD->GetTrack(i);
+    if(fCuts)
+      if( !(fCuts->IsSelected(ioT)) )
+        continue;
+    for(int j=i+1; j!=nTracks; ++j) {  // second particle
+      AliESDtrack *joT = fESD->GetTrack(j);
+      if( (ioT->Charge()*joT->Charge()) > 0 ) // only keeping opposite signs
+        continue;
+      if(fCuts)
+        if( !(fCuts->IsSelected(joT)) )
+          continue;
+      AliESDtrack *iT = new AliESDtrack(*ioT);
+      AliESDtrack *jT = new AliESDtrack(*joT);
+      // getting distance of closest approach
+      double DCA = iT->PropagateToDCA(jT,fESD->GetMagneticField());
+      fDCA->Fill( DCA );
+      // getting decay length
+      double DL;
+      double vx = fESD->GetPrimaryVertex()->GetX();
+      double vy = fESD->GetPrimaryVertex()->GetY();
+      double vz = fESD->GetPrimaryVertex()->GetZ();
+      double px = (iT->Xv()+jT->Xv())/2;
+      double py = (iT->Yv()+jT->Yv())/2;
+      double pz = (iT->Zv()+jT->Zv())/2;
+      DL  = (vx-px)*(vx-px);
+      DL += (vy-py)*(vy-py);
+      DL += (vz-pz)*(vz-pz);
+      DL = sqrt(DL);
+      fDL->Fill( DL );
+      // cos pointing angle
+      double CTP;
+      TVector3 vi, vj, vs, vp;
+      vi = TVector3( iT->Px(), iT->Py(), iT->Pz() );
+      vj = TVector3( jT->Px(), jT->Py(), jT->Pz() );
+      vs = vi + vj;
+      vp = TVector3( px, py, pz );
+      CTP = TMath::Cos( vp.Angle(vs) );
+      fCTP->Fill(CTP);
+
+      // getting invariant mass
+      double sum12 = iT->P()*iT->P()+jT->P()*jT->P();
+      double pro12 = iT->P()*iT->P()*jT->P()*jT->P();
+      double InvMass = 0;
+      InvMass += TMath::Power(0.13957018,2);
+      InvMass += sqrt( TMath::Power(0.13957018,4) + TMath::Power(0.13957018,2)*(sum12) + pro12 );
+      InvMass -= ( iT->Px()*jT->Px()+iT->Py()*jT->Py()+iT->Pz()*jT->Pz() );
+      InvMass *= 2;
+      InvMass = sqrt(InvMass);
+      fMass->Fill( InvMass );
+
+      // evaluating cuts
+      bool bW   = (InvMass>fMassMin) && (InvMass<fMassMax);
+      bool bCTP = (fabs(CTP)>0.95);
+      bool bDCA = (DCA<0.05);
+      bool bDL  = (DL>2.5);
+      if( (!bW) || (!bDCA) || (!bDL) || (!bCTP) ) {
+        delete iT;
+        delete jT;
+        continue;
+      }
+      fDCAF->Fill( DCA );
+      fDLF->Fill( DL );
+      fCTPF->Fill(CTP);
+      fMassF->Fill( InvMass );
+
+      AliFlowCandidateTrack *sTrack = new AliFlowCandidateTrack();
+      //booking pt of selected candidates
+      sTrack->SetMass( InvMass );
+      sTrack->SetPt( vs.Pt() );
+      sTrack->SetPhi( vs.Phi() );
+      sTrack->SetEta( vs.Eta() );
+      sTrack->SetCharge( 0 );
+      sTrack->AddDaughter( i );
+      sTrack->AddDaughter( j );
+      //saving selected candidate
+      POIselection->AddLast( sTrack );
+      delete iT;
+      delete jT;
+    }
+  }
+  PostData( 1, POIselection );
+  PostData( 2, fList);
+}
+
+//_____________________________________________________________________________
+void AliAnalysisTaskFlowK0Candidates::Terminate(Option_t *)
+{
+}
+
diff --git a/PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowK0Candidates.h b/PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowK0Candidates.h
new file mode 100644 (file)
index 0000000..a144d7d
--- /dev/null
@@ -0,0 +1,45 @@
+/////////////////////////////////////////////////////
+// AliAnalysisTaskFlowK0Candidates:
+// Analysis task to select K0 candidates for flow analysis.
+// Author: Carlos Perez (cperez@cern.ch)
+//////////////////////////////////////////////////////
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice */
+/* $Id: $ */
+
+#ifndef AliAnalysisTaskFlowK0Candidates_H
+#define AliAnalysisTaskFlowK0Candidates_H
+
+#include "AliAnalysisTaskSE.h"
+
+class AliESDtrackCuts;
+class AliFlowEventCuts;
+class TList;
+class TH1D;
+
+class AliAnalysisTaskFlowK0Candidates : public AliAnalysisTaskSE {
+  private:
+    AliAnalysisTaskFlowK0Candidates(const AliAnalysisTaskFlowK0Candidates& analysisTask);
+    AliAnalysisTaskFlowK0Candidates& operator=(const AliAnalysisTaskFlowK0Candidates& analysisTask);
+
+    AliFlowEventCuts *fCutsEvent; // cuts for event
+    AliESDtrackCuts  *fCuts;      // cuts for both pis
+    TList *fList;
+    TH1D *fMass,  *fDCA,  *fDL,  *fCTP;
+    TH1D *fMassF, *fDCAF, *fDLF, *fCTPF;
+    Double_t fMassMin, fMassMax;     // Mass cutting range
+
+  public:
+    AliAnalysisTaskFlowK0Candidates();
+    AliAnalysisTaskFlowK0Candidates(const char *name, AliFlowEventCuts *cutsEvent, AliESDtrackCuts *cuts, Double_t MassMin, Double_t MassMax);
+    virtual ~AliAnalysisTaskFlowK0Candidates();
+    virtual void UserCreateOutputObjects();
+    virtual void UserExec(Option_t *);
+    virtual void Terminate(Option_t *);
+    virtual void NotifyRun();
+
+  ClassDef(AliAnalysisTaskFlowK0Candidates, 1);  // example of analysis
+};
+
+#endif
diff --git a/PWG2/FLOW/AliFlowTasks/AliFlowCandidateTrack.cxx b/PWG2/FLOW/AliFlowTasks/AliFlowCandidateTrack.cxx
new file mode 100644 (file)
index 0000000..443ead5
--- /dev/null
@@ -0,0 +1,39 @@
+/*************************************************************************
+* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+////////////////////////////////////////////////////
+// AliFlowCandidateTrack:
+// Class for reconstructed particles to be used in flow analysis
+// Author: Carlos Perez (cperez@cern.ch)
+////////////////////////////////////////////////////
+
+#include "AliFlowCandidateTrack.h"
+
+ClassImp(AliFlowCandidateTrack)
+
+AliFlowCandidateTrack::AliFlowCandidateTrack():
+    AliFlowTrack(),
+    fMass(0),
+    fNDaughters(0)
+{
+  for(int i=0; i!=5; ++i)
+    fDaughter[i] = -1;
+}
+
+
+AliFlowCandidateTrack::~AliFlowCandidateTrack()
+{
+}
+
diff --git a/PWG2/FLOW/AliFlowTasks/AliFlowCandidateTrack.h b/PWG2/FLOW/AliFlowTasks/AliFlowCandidateTrack.h
new file mode 100644 (file)
index 0000000..5603c9f
--- /dev/null
@@ -0,0 +1,37 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice */
+/* $Id: $ */
+
+#ifndef AliFlowCandidateTrack_H
+#define AliFlowCandidateTrack_H
+
+#include "AliFlowTrack.h"
+
+////////////////////////////////////////////////////
+// AliFlowCandidateTrack:
+// Class for reconstructed particles to be used in flow analysis
+// Author: Carlos Perez (cperez@cern.ch)
+////////////////////////////////////////////////////
+
+class AliFlowCandidateTrack : public AliFlowTrack {
+  protected:
+    Double_t fMass;      // mass
+    Int_t fNDaughters;   // number of daughters (5 max)
+    Int_t fDaughter[5]; // index of daughters
+    
+  public:
+    AliFlowCandidateTrack();
+    AliFlowCandidateTrack(const AliFlowCandidateTrack& );
+    AliFlowCandidateTrack& operator=(const AliFlowCandidateTrack& );
+    ~AliFlowCandidateTrack();
+
+    Double_t Mass(void)            { return fMass; }
+    void SetMass(Double_t value)   { fMass=value; }
+
+    Int_t GetNDaughters(void)      { return fNDaughters; }
+    void AddDaughter(Int_t value)  { if(fNDaughters<3) fDaughter[fNDaughters++]=value; }
+
+    ClassDef(AliFlowCandidateTrack, 1);
+};
+
+#endif
index c3260cd..2fcdef9 100644 (file)
@@ -569,7 +569,7 @@ AliFlowTrackCuts* AliFlowTrackCuts::GetStandardITSTPCTrackCuts2009(Bool_t selPri
 }
 
 //-----------------------------------------------------------------------
-AliFlowTrack* AliFlowTrackCuts::MakeFlowTrack() const
+AliFlowTrack* AliFlowTrackCuts::MakeFlowTrack(int index) const
 {
   //get a flow track constructed from whatever we applied cuts on
   //caller is resposible for deletion
@@ -653,6 +653,9 @@ AliFlowTrack* AliFlowTrackCuts::MakeFlowTrack() const
     else if (dynamic_cast<AliAODTrack*>(fTrack)) flowtrack->SetSource(AliFlowTrack::kFromAOD);
     else if (dynamic_cast<AliMCParticle*>(fTrack)) flowtrack->SetSource(AliFlowTrack::kFromMC);
   }
+
+  if(flowtrack)
+    flowtrack->SetIndexOnCollection(index);
   return flowtrack;
 }
 
index bf35ae6..c5c9187 100644 (file)
@@ -117,7 +117,7 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
   virtual Bool_t IsSelectedMCtruth(TObject* obj, Int_t id=-666);
   AliVParticle* GetTrack() const {return fTrack;}
   AliMCParticle* GetMCparticle() const {return fMCparticle;}
-  AliFlowTrack* MakeFlowTrack() const;
+  AliFlowTrack* MakeFlowTrack(int index=0) const;
   Bool_t IsPhysicalPrimary() const; 
   static Bool_t IsPhysicalPrimary(AliMCEvent* p, Int_t label, Bool_t requiretransported=kTRUE); 
   
diff --git a/PWG2/FLOW/macros/runFlowTaskCentralityTrain4Candidates.C b/PWG2/FLOW/macros/runFlowTaskCentralityTrain4Candidates.C
new file mode 100644 (file)
index 0000000..1fe5a34
--- /dev/null
@@ -0,0 +1,413 @@
+enum anaModes {mLocal,mLocalPAR,mPROOF,mGrid,mGridPAR};
+//mLocal: Analyze locally files in your computer using aliroot
+//mLocalPAR: Analyze locally files in your computer using root + PAR files
+//mPROOF: Analyze CAF files with PROOF
+//mGrid: Analyze files on Grid via AliEn plug-in and using precompiled FLOW libraries
+//       (Remark: When using this mode set also Bool_t bUseParFiles = kFALSE; in CreateAlienHandler.C)
+//mGridPAR: Analyze files on Grid via AliEn plug-in and using par files for FLOW package
+//          (Remark: when using this mode set also Bool_t bUseParFiles = kTRUE; in CreateAlienHandler.C)
+// CENTRALITY DEFINITION
+//Int_t binfirst = 4;  //where do we start numbering bins
+//Int_t binlast = 6;  //where do we stop numbering bins
+//const Int_t numberOfCentralityBins = 9;
+Int_t binfirst = 0;  //where do we start numbering bins
+Int_t binlast = 8;  //where do we stop numbering bins
+const Int_t numberOfCentralityBins = 9;
+Float_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile
+//Int_t centralityArray[numberOfCentralityBins+1] = {41,80,146,245,384,576,835,1203,1471,10000}; // in terms of TPC only reference multiplicity
+
+TString commonOutputFileName = "outputCentrality"; // e.g.: result for centrality bin 0 will be in the file "outputCentrality0.root", etc
+
+
+//void runFlowTaskCentralityTrain(Int_t mode=mLocal, Int_t nRuns = 10, 
+//Bool_t DATA = kFALSE, const Char_t* dataDir="/Users/snelling/alice_data/Therminator_midcentral", Int_t offset = 0)
+
+void runFlowTaskCentralityTrain4Candidates(Int_t mode = mGridPAR, Int_t nRuns = 50000000, 
+                Bool_t DATA = kTRUE, const Char_t* dataDir="/alice/data/LHC10h_000137161_p1_plusplusplus", Int_t offset=0) 
+//void runFlowTaskCentralityTrain4Candidates(Int_t mode = mLocal, Int_t nRuns = 50000000, 
+//                             Bool_t DATA = kTRUE, const Char_t* dataDir="./data/", Int_t offset=0) 
+//void runFlowTaskCentralityTrain(Int_t mode = mGridPAR, Bool_t DATA = kTRUE)
+{
+  // Time:
+  TStopwatch timer;
+  timer.Start();
+  // Cross-check user settings before starting:
+  //  CrossCheckUserSettings(DATA);
+  // Load needed libraries:
+  LoadLibraries(mode);
+  // Create and configure the AliEn plug-in:
+  if(mode == mGrid || mode == mGridPAR) 
+    {    
+      gROOT->LoadMacro("CreateAlienHandler.C");
+      AliAnalysisGrid *alienHandler = CreateAlienHandler();  
+      if(!alienHandler) return;
+    }
+  // Chains: 
+  if(mode == mLocal || mode == mLocalPAR) {
+//    TChain* chain = CreateESDChain(dataDir, nRuns, offset);
+    TChain* chain = new TChain();
+    chain->Add("~/alice/datasets/Pb/AliESDs.root/esdTree");
+    //TChain* chain = CreateAODChain(dataDir, nRuns, offset);
+  }
+  
+  // Create analysis manager:
+  AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager"); 
+  // Connect plug-in to the analysis manager:
+  if(mode == mGrid || mode == mGridPAR) 
+    { 
+      mgr->SetGridHandler(alienHandler);
+    }
+  
+  // Event handlers:
+  AliVEventHandler* esdH = new AliESDInputHandler;
+  mgr->SetInputEventHandler(esdH);
+  if (!DATA) {
+    AliMCEventHandler *mc = new AliMCEventHandler();
+    mgr->SetMCtruthEventHandler(mc); 
+  }
+
+  // Task to check the offline trigger:
+  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); 
+  AddTaskPhysicsSelection(!DATA);
+
+  //Add the centrality determination task
+  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
+  AddTaskCentrality();
+
+  // Setup analysis per centrality bin:
+  gROOT->LoadMacro("AddTaskFlowCentrality4Candidates.C");
+  for (Int_t i=binfirst; i<binlast+1; i++)
+  {
+    Float_t lowCentralityBinEdge = centralityArray[i];
+    Float_t highCentralityBinEdge = centralityArray[i+1];
+    Printf("\nWagon for centrality bin %i: %.0f-%.0f",i,lowCentralityBinEdge,highCentralityBinEdge);
+    AddTaskFlowCentrality4Candidates( lowCentralityBinEdge,
+                                      highCentralityBinEdge,
+                                      commonOutputFileName,
+                                      0.474, 0.490 );
+    AddTaskFlowCentrality4Candidates( lowCentralityBinEdge,
+                                      highCentralityBinEdge,
+                                      commonOutputFileName,
+                                      0.490, 0.506 );
+    AddTaskFlowCentrality4Candidates( lowCentralityBinEdge,
+                                      highCentralityBinEdge,
+                                      commonOutputFileName,
+                                      0.506, 0.522 );
+  } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
+
+  // Enable debug printouts:
+  mgr->SetDebugLevel(2);
+  // Run the analysis:
+  if(!mgr->InitAnalysis()) return;  
+  mgr->PrintStatus();
+  if(mode == mLocal || mode == mLocalPAR) {
+    mgr->StartAnalysis("local",chain);
+  } else if(mode == mPROOF) {
+    mgr->StartAnalysis("proof",dataDir,nRuns,offset);
+  } else if(mode == mGrid || mode == mGridPAR) { 
+    mgr->StartAnalysis("grid");
+  }
+
+  // Print real and CPU time used for analysis:
+  timer.Stop();
+  timer.Print();  
+  
+} // end of void runFlowTaskCentralityTrain(...)
+
+//===============================================================================================
+/*
+void CrossCheckUserSettings(Bool_t bData) 
+{
+ // Check in this method if the user settings make sense. 
+ if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
+ if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
+ if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
+ if(LYZ1SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
+} // end of void CrossCheckUserSettings()
+*/
+//===============================================================================================
+
+void LoadLibraries(const anaModes mode) 
+{
+  //--------------------------------------
+  // Load the needed libraries most of them already loaded by aliroot
+  //--------------------------------------
+
+  gSystem->Load("libCore");  
+  gSystem->Load("libTree");
+  gSystem->Load("libGeom");
+  gSystem->Load("libVMC");
+  gSystem->Load("libXMLIO");
+  gSystem->Load("libPhysics");
+  gSystem->Load("libXMLParser");
+  gSystem->Load("libProof");
+  
+  if (mode==mLocal || mode==mGrid || mode == mGridPAR || mode == mLocalPAR )
+  {
+    gSystem->Load("libSTEERBase");
+    gSystem->Load("libCDB");
+    gSystem->Load("libRAWDatabase");
+    gSystem->Load("libRAWDatarec");
+    gSystem->Load("libESD");
+    gSystem->Load("libAOD");
+    gSystem->Load("libSTEER");
+    gSystem->Load("libANALYSIS");
+    gSystem->Load("libANALYSISalice");   
+    gSystem->Load("libTOFbase"); 
+    gSystem->Load("libTOFrec"); 
+
+    if (mode == mLocal || mode == mGrid)
+    {
+      gSystem->Load("libPWG2flowCommon"); 
+      gSystem->Load("libPWG2flowTasks"); 
+    }
+    if (mode == mLocalPAR || mode == mGridPAR )
+    {
+      AliAnalysisAlien::SetupPar("PWG2flowCommon");
+      AliAnalysisAlien::SetupPar("PWG2flowTasks");
+    }
+  }
+  
+  //---------------------------------------------------------
+  // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
+  //---------------------------------------------------------
+  else if (mode==mPROOF) {
+    //  set to debug root versus if needed
+    //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a_dbg");
+    //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a");
+    //TProof::Reset("proof://snelling@alicecaf.cern.ch");     
+    // Connect to proof
+    printf("*** Connect to PROOF ***\n");
+    gEnv->SetValue("XSec.GSI.DelegProxy","2");
+    TProof::Open("mkrzewic@alice-caf.cern.ch");
+    //TProof::Open("mkrzewic@skaf.saske.sk");
+     // list the data available
+    //gProof->ShowDataSets("/*/*"); 
+    //gProof->ShowDataSets("/alice/sim/"); //for MC Data
+    //gProof->ShowDataSets("/alice/data/"); //for REAL Data 
+    // Clear the Packages
+    /*    
+    gProof->ClearPackage("STEERBase.par");
+    gProof->ClearPackage("ESD.par");
+    gProof->ClearPackage("AOD.par");
+    */
+    //gProof->ClearPackage("ANALYSIS.par");
+    //gProof->ClearPackage("ANALYSISalice.par");
+    //gProof->ClearPackage("CORRFW.par");
+    
+    gProof->ClearPackage("PWG2flowCommon");
+    gProof->ClearPackage("PWG2flowTasks");
+    
+    // Upload the Packages
+    //gProof->UploadPackage("STEERBase.par");
+    //gProof->UploadPackage("ESD.par");    
+    //gProof->UploadPackage("AOD.par");
+       
+    //gProof->UploadPackage("ANALYSIS.par"); 
+    //gProof->UploadPackage("ANALYSISalice.par");
+    gProof->UploadPackage("CORRFW.par");
+    gProof->UploadPackage("PWG2flowCommon.par");
+    gProof->UploadPackage("PWG2flowTasks.par");
+    gProof->UploadPackage("ALIRECO.par");
+
+    // Enable the Packages 
+    // The global package
+    TList* list = new TList();
+    list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES","RAW:OCDB:STEER:TOF"));
+    gProof->EnablePackage("VO_ALICE@AliRoot::v4-21-07-AN",list);
+    gProof->EnablePackage("ALIRECO");
+    //gProof->EnablePackage("ANALYSIS");
+    //gProof->EnablePackage("ANALYSISalice");
+    //gProof->EnablePackage("CORRFW");
+    gProof->EnablePackage("PWG2flowCommon");
+    gProof->EnablePackage("PWG2flowTasks");
+
+    // Show enables Packages
+    gProof->ShowEnabledPackages();
+  }  
+  
+} // end of void LoadLibraries(const anaModes mode) 
+
+// Helper macros for creating chains
+// from: CreateESDChain.C,v 1.10 jgrosseo Exp
+
+TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
+{
+  // creates chain of files in a given directory or file containing a list.
+  // In case of directory the structure is expected as:
+  // <aDataDir>/<dir0>/AliESDs.root
+  // <aDataDir>/<dir1>/AliESDs.root
+  // ...
+  
+  if (!aDataDir)
+    return 0;
+  
+  Long_t id, size, flags, modtime;
+  if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
+    {
+      printf("%s not found.\n", aDataDir);
+      return 0;
+    }
+  
+  TChain* chain = new TChain("esdTree");
+  TChain* chaingAlice = 0;
+  
+  if (flags & 2)
+    {
+      TString execDir(gSystem->pwd());
+      TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
+      TList* dirList            = baseDir->GetListOfFiles();
+      Int_t nDirs               = dirList->GetEntries();
+      gSystem->cd(execDir);
+      
+      Int_t count = 0;
+      
+      for (Int_t iDir=0; iDir<nDirs; ++iDir)
+       {
+         TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
+         if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
+           continue;
+         
+         if (offset > 0)
+           {
+             --offset;
+             continue;
+           }
+         
+         if (count++ == aRuns)
+           break;
+         
+         TString presentDirName(aDataDir);
+         presentDirName += "/";
+         presentDirName += presentDir->GetName();        
+         chain->Add(presentDirName + "/AliESDs.root/esdTree");
+         //  cerr<<presentDirName<<endl;
+       }
+      
+    }
+  else
+    {
+      // Open the input stream
+      ifstream in;
+      in.open(aDataDir);
+      
+      Int_t count = 0;
+      
+      // Read the input list of files and add them to the chain
+      TString esdfile;
+      while(in.good()) {
+       in >> esdfile;
+       if (!esdfile.Contains("root")) continue; // protection
+       
+       if (offset > 0)
+         {
+           --offset;
+           continue;
+         }
+       
+       if (count++ == aRuns)
+         break;
+       
+       // add esd file
+       chain->Add(esdfile);
+      }
+      
+      in.close();
+    }
+  
+  return chain;
+
+} // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
+
+//===============================================================================================
+
+TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
+{
+  // creates chain of files in a given directory or file containing a list.
+  // In case of directory the structure is expected as:
+  // <aDataDir>/<dir0>/AliAOD.root
+  // <aDataDir>/<dir1>/AliAOD.root
+  // ...
+  
+  if (!aDataDir)
+    return 0;
+  
+  Long_t id, size, flags, modtime;
+  if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
+    {
+      printf("%s not found.\n", aDataDir);
+      return 0;
+    }
+  
+  TChain* chain = new TChain("aodTree");
+  TChain* chaingAlice = 0;
+  
+  if (flags & 2)
+    {
+      TString execDir(gSystem->pwd());
+      TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
+      TList* dirList            = baseDir->GetListOfFiles();
+      Int_t nDirs               = dirList->GetEntries();
+      gSystem->cd(execDir);
+      
+      Int_t count = 0;
+      
+      for (Int_t iDir=0; iDir<nDirs; ++iDir)
+       {
+         TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
+         if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
+           continue;
+         
+         if (offset > 0)
+           {
+             --offset;
+             continue;
+           }
+         
+         if (count++ == aRuns)
+           break;
+         
+         TString presentDirName(aDataDir);
+         presentDirName += "/";
+         presentDirName += presentDir->GetName();        
+         chain->Add(presentDirName + "/AliAOD.root/aodTree");
+         // cerr<<presentDirName<<endl;
+       }
+      
+    }
+  else
+    {
+      // Open the input stream
+      ifstream in;
+      in.open(aDataDir);
+      
+      Int_t count = 0;
+      
+      // Read the input list of files and add them to the chain
+      TString aodfile;
+      while(in.good()) {
+       in >> aodfile;
+       if (!aodfile.Contains("root")) continue; // protection
+       
+       if (offset > 0)
+         {
+           --offset;
+           continue;
+         }
+       
+       if (count++ == aRuns)
+         break;
+       
+       // add aod file
+       chain->Add(aodfile);
+      }
+      
+      in.close();
+    }
+  
+  return chain;
+
+} // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
+
index aa81e72..f9d8a4c 100644 (file)
@@ -6,6 +6,7 @@
 
 #pragma link C++ class AliFlowEvent+;
 #pragma link C++ class AliFlowEventCuts+;
+#pragma link C++ class AliFlowCandidateTrack+;
 #pragma link C++ class AliFlowTrack+;
 #pragma link C++ class AliFlowTrackCuts+;
 #pragma link C++ class AliFlowEventSimpleMaker+;
@@ -19,6 +20,7 @@
 #pragma link C++ class AliAnalysisTaskFittingQDistribution+;
 #pragma link C++ class AliAnalysisTaskFlowEvent+;
 #pragma link C++ class AliAnalysisTaskFlowEventforRP+;
+#pragma link C++ class AliAnalysisTaskFlowK0Candidates+;
 #pragma link C++ class AliAnalysisTaskMixedHarmonics+;
 #pragma link C++ class AliAnalysisTaskNestedLoops+;
 #pragma link C++ class AliAnalysisTaskQAflow+;
index b99a77c..798f6a7 100644 (file)
@@ -4,6 +4,7 @@ SRCS= FLOW/AliFlowTasks/AliFlowEventSimpleMaker.cxx \
       FLOW/AliFlowTasks/AliFlowEvent.cxx \
       FLOW/AliFlowTasks/AliFlowEventCuts.cxx \
       FLOW/AliFlowTasks/AliFlowTrack.cxx \
+      FLOW/AliFlowTasks/AliFlowCandidateTrack.cxx \
       FLOW/AliFlowTasks/AliFlowTrackCuts.cxx \
       FLOW/AliFlowTasks/AliAnalysisTaskScalarProduct.cxx \
       FLOW/AliFlowTasks/AliAnalysisTaskMCEventPlane.cxx \
@@ -13,6 +14,7 @@ SRCS= FLOW/AliFlowTasks/AliFlowEventSimpleMaker.cxx \
       FLOW/AliFlowTasks/AliAnalysisTaskLeeYangZeros.cxx \
       FLOW/AliFlowTasks/AliAnalysisTaskFittingQDistribution.cxx \
       FLOW/AliFlowTasks/AliAnalysisTaskFlowEvent.cxx \
+      FLOW/AliFlowTasks/AliAnalysisTaskFlowK0Candidates.cxx \
       FLOW/AliFlowTasks/AliAnalysisTaskFlowEventforRP.cxx \
       FLOW/AliFlowTasks/AliAnalysisTaskMixedHarmonics.cxx \
       FLOW/AliFlowTasks/AliAnalysisTaskNestedLoops.cxx \