code cleanup
authorsnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 23 Oct 2010 17:34:38 +0000 (17:34 +0000)
committersnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 23 Oct 2010 17:34:38 +0000 (17:34 +0000)
PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowEvent.cxx
PWG2/FLOW/AliFlowTasks/AliFlowEvent.cxx
PWG2/FLOW/AliFlowTasks/AliFlowEvent.h
PWG2/FLOW/AliFlowTasks/AliFlowEventCuts.cxx
PWG2/FLOW/AliFlowTasks/AliFlowEventCuts.h
PWG2/FLOW/AliFlowTasks/AliFlowTrackCuts.cxx
PWG2/FLOW/macros/AddTaskFlowCentrality.C

index 7ab39bc..664cef6 100644 (file)
@@ -275,9 +275,13 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
       if (!fCutsEvent->IsSelected(InputEvent())) return;
     }
 
-    fCutsRP->SetMCevent( MCEvent() );
+    //first attach all possible information to the cuts
+    fCutsRP->SetEvent( InputEvent() );  //attach event
+    fCutsRP->SetMCevent( MCEvent() );   //attach mc truth
+    fCutsPOI->SetEvent( InputEvent() );
     fCutsPOI->SetMCevent( MCEvent() );
-    flowEvent = new AliFlowEvent( InputEvent(), fCutsRP, fCutsPOI );
+    //then make the event
+    flowEvent = new AliFlowEvent( fCutsRP, fCutsPOI );
     if (myESD)
       flowEvent->SetReferenceMultiplicity(fCutsEvent->GetReferenceMultiplicity(InputEvent()));
     if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
index 87deee1..9113362 100644 (file)
@@ -582,70 +582,30 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
 }
 
 //-----------------------------------------------------------------------
-AliFlowEvent::AliFlowEvent( AliVEvent* inputEvent,
-                            AliFlowTrackCuts* rpCuts,
+AliFlowEvent::AliFlowEvent( AliFlowTrackCuts* rpCuts,
                             AliFlowTrackCuts* poiCuts ):
   AliFlowEventSimple(20)
 {
   //Fills the event from a vevent: AliESDEvent,AliAODEvent,AliMCEvent
-
-  if (!rpCuts || !poiCuts) return;
-
-  AliFlowTrackCuts::trackParameterType sourceRP = rpCuts->GetParamType();
-  AliFlowTrackCuts::trackParameterType sourcePOI = poiCuts->GetParamType();
-
-  //MC case is special: handle it
-  //if input event empty do MC analysis
-  AliVEvent* eventRP = inputEvent;
-  AliVEvent* eventPOI = inputEvent;
-  if (!inputEvent)
-  {
-    eventRP = rpCuts->GetMCevent();
-    eventPOI = poiCuts->GetMCevent();
-  }
-  if (sourceRP==AliFlowTrackCuts::kMC) eventRP = rpCuts->GetMCevent();
-  if (sourcePOI==AliFlowTrackCuts::kMC) eventPOI = poiCuts->GetMCevent();
-  
-  //if we dont have input data return
-  if (!eventRP || !eventPOI) return;
-
-  //check if we want to use tracklets, TODO: const_casts to be somehow removed!
-  AliESDEvent* esdEvent = NULL; 
-  AliMultiplicity* trackletsRP=NULL;
-  AliMultiplicity* trackletsPOI=NULL;
-  if (sourceRP==AliFlowTrackCuts::kESD_SPDtracklet)
-  { 
-    esdEvent = dynamic_cast<AliESDEvent*>(eventRP);
-    if (!esdEvent) return;
-    trackletsRP=const_cast<AliMultiplicity*>(esdEvent->GetMultiplicity());
-  }
-  if (sourcePOI==AliFlowTrackCuts::kESD_SPDtracklet)
-  { 
-    esdEvent = dynamic_cast<AliESDEvent*>(eventPOI);
-    if (!esdEvent) return;
-    trackletsPOI=const_cast<AliMultiplicity*>(esdEvent->GetMultiplicity());
-  }
-
+  //the input data needs to be attached to the cuts
   //we have two cases, if we're cutting the same collection of tracks
   //(same param type) then we can have tracks that are both rp and poi
   //in the other case we want to have two exclusive sets of rps and pois
   //e.g. one tracklets, the other PMD or global - USER IS RESPOSIBLE
   //FOR MAKING SURE THEY DONT OVERLAP OR ELSE THE SAME PARTICLE WILL BE
   //TAKEN TWICE
+
+  AliFlowTrackCuts::trackParameterType sourceRP = rpCuts->GetParamType();
+  AliFlowTrackCuts::trackParameterType sourcePOI = poiCuts->GetParamType();
+
+  if (!rpCuts || !poiCuts) return;
   if (sourceRP==sourcePOI)
   {
     //loop over tracks
-    //check the number of particles first
-    Int_t numberOfTracks = 0;
-    if (trackletsRP) numberOfTracks = trackletsRP->GetNumberOfTracklets();
-    else numberOfTracks = eventRP->GetNumberOfTracks();
-
-    for (Int_t i=0; i<numberOfTracks; i++)
+    for (Int_t i=0; i<rpCuts->GetNumberOfInputObjects(); i++)
     {
       //get input object (particle)
-      TObject* particle = NULL;
-      if (trackletsRP) particle = trackletsRP;
-      else particle = eventRP->GetTrack(i);
+      TObject* particle = rpCuts->GetInputObject(i);
 
       Bool_t rp = rpCuts->IsSelected(particle,i);
       Bool_t poi = poiCuts->IsSelected(particle,i);
@@ -657,7 +617,7 @@ AliFlowEvent::AliFlowEvent( AliVEvent* inputEvent,
       if (rp)
       {
         pTrack = rpCuts->MakeFlowTrack();
-      if (!pTrack) continue;
+        if (!pTrack) continue;
         pTrack->TagRP(); fNumberOfRPs++;
         if (poi) pTrack->TagPOI();
       }
@@ -665,7 +625,7 @@ AliFlowEvent::AliFlowEvent( AliVEvent* inputEvent,
       if (poi)
       {
         pTrack = poiCuts->MakeFlowTrack();
-      if (!pTrack) continue;
+        if (!pTrack) continue;
         pTrack->TagPOI();
       }
 
@@ -678,14 +638,9 @@ AliFlowEvent::AliFlowEvent( AliVEvent* inputEvent,
     //them independently
     AliFlowTrack* pTrack = NULL;
     //RP
-    Int_t numberOfRPs = 0;
-    if (trackletsRP) numberOfRPs = trackletsRP->GetNumberOfTracklets();
-    else numberOfRPs = eventRP->GetNumberOfTracks();
-    for (Int_t i=0; i<numberOfRPs; i++)
+    for (Int_t i=0; i<rpCuts->GetNumberOfInputObjects(); i++)
     {
-      TObject* particle = NULL;
-      if (trackletsRP) particle = trackletsRP;
-      else particle = eventRP->GetTrack(i);
+      TObject* particle = rpCuts->GetInputObject(i);
       Bool_t rp = rpCuts->IsSelected(particle,i);
       if (!rp) continue;
       pTrack = rpCuts->MakeFlowTrack();
@@ -694,14 +649,9 @@ AliFlowEvent::AliFlowEvent( AliVEvent* inputEvent,
       AddTrack(pTrack);
     }
     //POI
-    Int_t numberOfPOIs = 0;
-    if (trackletsPOI) numberOfPOIs = trackletsPOI->GetNumberOfTracklets();
-    else numberOfPOIs = eventPOI->GetNumberOfTracks();
-    for (Int_t i=0; i<numberOfPOIs; i++)
+    for (Int_t i=0; i<poiCuts->GetNumberOfInputObjects(); i++)
     {
-      TObject* particle = NULL;
-      if (trackletsPOI) particle = trackletsPOI;
-      else particle = eventPOI->GetTrack(i);
+      TObject* particle = poiCuts->GetInputObject(i);
       Bool_t poi = poiCuts->IsSelected(particle,i);
       if (!poi) continue;
       pTrack = poiCuts->MakeFlowTrack();
index 602480d..23207ef 100644 (file)
@@ -57,8 +57,7 @@ public:
   AliFlowEvent( const AliESDEvent* anInput,
                 const TH2F* anInputFMDhist,
                 const AliCFManager* poiCFManager );
-  AliFlowEvent( AliVEvent* anInput,
-                AliFlowTrackCuts* rpCuts,
+  AliFlowEvent( AliFlowTrackCuts* rpCuts,
                 AliFlowTrackCuts* poiCuts );
   //pmd
   AliFlowEvent( const AliESDEvent* anInput,
index 8ecee14..c76296c 100644 (file)
@@ -42,7 +42,7 @@ AliFlowEventCuts::AliFlowEventCuts():
   fRefMultMethod(kTPConly),
   fRefMultMax(INT_MAX),
   fRefMultMin(INT_MIN),
-  fRefMult(-1)
+  fRefMultCuts(NULL)
 {
   //constructor 
 }
@@ -57,31 +57,40 @@ AliFlowEventCuts::AliFlowEventCuts(const char* name, const char* title):
   fRefMultMethod(kTPConly),
   fRefMultMax(INT_MAX),
   fRefMultMin(INT_MIN),
-  fRefMult(-1)
+  fRefMultCuts(NULL)
 {
   //constructor 
 }
 
 ////-----------------------------------------------------------------------
-//AliFlowEventCuts::AliFlowEventCuts(const AliFlowEventCuts& someCuts):
-//  TNamed(someCuts),
-//  fCutNumberOfTracks(that.fCutNumberOfTracks),
-//  fNumberOfTracksMax(that.fNumberOfTracksMax),
-//  fNumberOfTracksMin(that.fNumberOfTracksMin),
-//{
-//  //copy constructor 
-//}
-//
+AliFlowEventCuts::AliFlowEventCuts(const AliFlowEventCuts& that):
+  TNamed(that),
+  fCutNumberOfTracks(that.fCutNumberOfTracks),
+  fNumberOfTracksMax(that.fNumberOfTracksMax),
+  fNumberOfTracksMin(that.fNumberOfTracksMin),
+  fCutRefMult(that.fCutRefMult),
+  fRefMultMethod(that.fRefMultMethod),
+  fRefMultMax(that.fRefMultMax),
+  fRefMultMin(that.fRefMultMin),
+  fRefMultCuts(new AliFlowTrackCuts(*(that.fRefMultCuts)))
+{
+  //copy constructor 
+}
+
 ////-----------------------------------------------------------------------
-//AliFlowEventCuts& AliFlowEventCuts::operator=(const AliFlowEventCuts& someCuts)
-//{
-//  //assignment
-//  fCutNumberOfTracks=that.fCutNumberOfTracks;
-//  fNumberOfTracksMax=that.fNumberOfTracksMax;
-//  fNumberOfTracksMin=that.fNumberOfTracksMin;
-//
-//  return *this;
-//}
+AliFlowEventCuts& AliFlowEventCuts::operator=(const AliFlowEventCuts& that)
+{
+  //assignment
+  fCutNumberOfTracks=that.fCutNumberOfTracks;
+  fNumberOfTracksMax=that.fNumberOfTracksMax;
+  fNumberOfTracksMin=that.fNumberOfTracksMin;
+  fCutRefMult=that.fCutRefMult;
+  fRefMultMethod=that.fRefMultMethod;
+  fRefMultMax=that.fRefMultMax;
+  fRefMultMin=that.fRefMultMin;
+  *fRefMultCuts=*(that.fRefMultCuts);
+  return *this;
+}
 
 //----------------------------------------------------------------------- 
 Bool_t AliFlowEventCuts::IsSelected(const TObject* obj)
@@ -99,8 +108,8 @@ Bool_t AliFlowEventCuts::PassesCuts(const AliVEvent *event)
   if(fCutRefMult)
   {
     //reference multiplicity still to be defined
-    fRefMult = RefMult(event);
-    if (fRefMult < fRefMultMin || fRefMult >= fRefMultMax )
+    Double_t refMult = RefMult(event);
+    if (refMult < fRefMultMin || refMult >= fRefMultMax )
       return kFALSE;
   }
   return kTRUE;
@@ -115,7 +124,7 @@ AliFlowEventCuts* AliFlowEventCuts::StandardCuts()
 }
 
 //----------------------------------------------------------------------- 
-Int_t AliFlowEventCuts::RefMult(const AliVEvent* event, AliFlowTrackCuts* cuts)
+Int_t AliFlowEventCuts::RefMult(const AliVEvent* event)
 {
   //calculate the reference multiplicity, if all fails return 0
   Int_t refmult=0;
@@ -128,30 +137,30 @@ Int_t AliFlowEventCuts::RefMult(const AliVEvent* event, AliFlowTrackCuts* cuts)
     switch (fRefMultMethod)
     {
       case kTPConly:
-        if (!cuts)
+        if (!fRefMultCuts)
         {
           //if not explicitly passed, make default cuts
-          cuts = AliFlowTrackCuts::GetStandardTPCOnlyTrackCuts();
-          cuts->SetEtaRange(-0.8,0.8);
-          cuts->SetPtMin(0.15);
+          fRefMultCuts = AliFlowTrackCuts::GetStandardTPCOnlyTrackCuts();
+          fRefMultCuts->SetEtaRange(-0.8,0.8);
+          fRefMultCuts->SetPtMin(0.15);
         }
         for (Int_t i=0; i<esd->GetNumberOfTracks();i++)
         {
           AliESDtrack* track = esd->GetTrack(i);
-          if (cuts->IsSelected(track)) refmult++;
+          if (fRefMultCuts->IsSelected(track)) refmult++;
         }
         break;
       case kSPDtracklets:
-        if (!cuts)
+        if (!fRefMultCuts)
         {
-          //if not explicitly passed, make default cuts
-          cuts = new AliFlowTrackCuts();
-          cuts->SetEtaRange(-0.8,0.8);
+          //if not explicitly passed, make default fRefMultCuts
+          fRefMultCuts = new AliFlowTrackCuts();
+          fRefMultCuts->SetEtaRange(-0.8,0.8);
         }
         tracklets = const_cast<AliMultiplicity*>(esd->GetMultiplicity());
         for (Int_t i=0; i<tracklets->GetNumberOfTracklets(); i++)
         {
-          if (cuts->IsSelected(tracklets,i)) refmult++;
+          if (fRefMultCuts->IsSelected(tracklets,i)) refmult++;
         }
         break;
       default:
index fca41e3..38e99a7 100644 (file)
@@ -22,8 +22,8 @@ class AliFlowEventCuts : public TNamed {
 
   AliFlowEventCuts();
   AliFlowEventCuts(const char* name, const char* title = "AliFlowEventCuts");
-  //AliFlowEventCuts(const AliFlowEventCuts& someCuts);
-  //AliFlowEventCuts& operator=(const AliFlowEventCuts& someCuts);
+  AliFlowEventCuts(const AliFlowEventCuts& someCuts);
+  AliFlowEventCuts& operator=(const AliFlowEventCuts& someCuts);
   virtual  ~AliFlowEventCuts() {}
   
   virtual Bool_t IsSelected(const TObject* obj);
@@ -45,8 +45,10 @@ class AliFlowEventCuts : public TNamed {
   Int_t GetRefMultMin() const {return fRefMultMin;}
   void SetRefMultMethod(refMultMethod m) {fRefMultMethod=m;}
   refMultMethod GetRefMultMethod() const {return fRefMultMethod;}
+  void SetRefMultCuts( AliFlowTrackCuts* cuts ) {fRefMultCuts=cuts;}
+  AliFlowTrackCuts* GetRefMultCuts() const {return fRefMultCuts;}
 
-  Int_t RefMult(const AliVEvent* event, AliFlowTrackCuts* cuts=NULL);
+  Int_t RefMult(const AliVEvent* event);
   //Int_t GetRefMult() {return fRefMult;}
   Int_t GetReferenceMultiplicity(const AliVEvent* event) {return RefMult(event);}
 
@@ -59,7 +61,7 @@ class AliFlowEventCuts : public TNamed {
   Int_t fRefMultMax; //max refmult
   Int_t fRefMultMin; //min refmult
 
-  Int_t fRefMult; //store the reference multiplicity
+  AliFlowTrackCuts* fRefMultCuts; //cuts
 
   ClassDef(AliFlowEventCuts,1)
 };
index 63c8f7a..e37a60c 100644 (file)
@@ -208,10 +208,10 @@ Bool_t AliFlowTrackCuts::PassesCuts(AliMultiplicity* tracklet, Int_t id)
 Bool_t AliFlowTrackCuts::PassesMCcuts()
 {
   //check the MC info
-  if (!fMCevent) {AliWarning("no MC info"); return kFALSE;}
+  if (!fMCevent) return kFALSE;
   if (fTrackLabel<0) return kFALSE;//otherwise AliCMevent prints a warning before returning NULL
   fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
-  if (!fMCparticle) {AliError("no MC info"); return kFALSE;}
+  if (!fMCparticle) {AliError("no MC track"); return kFALSE;}
 
   if (fCutMCisPrimary)
   {
index d8efc6c..12641bc 100644 (file)
@@ -54,15 +54,20 @@ Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
 
 // SETTING THE CUTS
 
-//----------For RP selection----------
+//---------Data selection----------
 //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet
 AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal;
 AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kGlobal;
 
+//---------Parameter mixing--------
+//kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt
+AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure;
+AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure;
+
+
 const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype);
 const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype);
 
-
 void AddTaskFlowCentrality( Int_t refMultMin=0,
                             Int_t refMultMax=1e10,
                             TString fileName="AnalysisResults.root" )
@@ -75,10 +80,13 @@ void AddTaskFlowCentrality( Int_t refMultMin=0,
   // EVENTS CUTS:
   AliFlowEventCuts* cutsEvent = new AliFlowEventCuts();
   cutsEvent->SetRefMultRange(refMultMin,refMultMax);
+  //cutsEvent->SetRefMultMethod(AliFlowEventCuts::kTPConly);
+  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kSPDtracklets);
   
   // RP TRACK CUTS:
   AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts();
   cutsRP->SetParamType(rptype);
+  cutsRP->SetParamMix(rpmix);
   cutsRP->SetPtRange(0.2,10.);
   cutsRP->SetEtaRange(-0.7,0.7);
   cutsRP->SetRequireCharge(kTRUE);
@@ -98,6 +106,7 @@ void AddTaskFlowCentrality( Int_t refMultMin=0,
   // POI TRACK CUTS:
   AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts();
   cutsPOI->SetParamType(poitype);
+  cutsPOI->SetParamMix(poimix);
   cutsPOI->SetPtRange(0.2,10.);
   cutsPOI->SetEtaRange(-0.7,0.7);
   cutsPOI->SetRequireCharge(kTRUE);