]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/RESONANCES/AliRsnEvent.h
introduce the option to analyze with PROOF, plus cosmetics
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnEvent.h
index 6eada401fbcf460e4cc44d4e32736d27c7f28836..23750c91f4e151931f97b09092fea15a2eebf616 100644 (file)
 //
 ////////////////////////////////////////////////////////////////////////////////
 
+#include <TClonesArray.h>
+
+#include "AliLog.h"
+
+#include "AliStack.h"
 #include "AliVEvent.h"
 #include "AliMCEvent.h"
 #include "AliESDEvent.h"
 #include "AliAODEvent.h"
-#include "AliVVertex.h"
+#include "AliAODMCParticle.h"
+
 #include "AliRsnDaughter.h"
 
-class AliRsnCutPID;
-class AliESDtrackCuts;
+class AliRsnCutSet;
+class AliPIDResponse;
 
 class AliRsnEvent : public TObject {
 public:
@@ -29,68 +35,98 @@ public:
    virtual ~AliRsnEvent();
 
    // basic setters/getters
-   void       SetRef(AliVEvent *ref)       {fRef = ref;}
-   void       SetRefMC(AliVEvent *refmc)   {fRefMC = refmc;}
-   void       SetLeadingIndex(Int_t i)     {fLeading = i;}
-   void       SetLocalID(Int_t i)          {fLocalID = i;}
-   AliVEvent* GetRef()                     {return fRef;}
-   AliVEvent* GetRefMC()                   {return fRefMC;}
-   Int_t      GetLeadingIndex() const      {return fLeading;}
-   Int_t      GetLeadingParticleID() const {return fLeading;}
-   Int_t      GetLocalID() const           {return fLocalID;}
+   void             SetRef(AliVEvent *ref)              {fRef = ref;}
+   void             SetRefMC(AliVEvent *refmc);
+   void             SetPIDResponse(AliPIDResponse *pid) {fPID = pid;}
+   AliVEvent*       GetRef()                            {return fRef;}
+   AliVEvent*       GetRefMC()                          {return fRefMC;}
+   Int_t            GetLeadingIndex() const             {return fLeading;}
+   AliPIDResponse*  GetPIDResponse()                    {return fPID;}
 
    // getters which convert into allowed input types
-   AliESDEvent* GetRefESD()   {if (classMatchRef  (AliESDEvent::Class())) return static_cast<AliESDEvent*>(fRef)  ; return 0x0;}
-   AliAODEvent* GetRefAOD()   {if (classMatchRef  (AliAODEvent::Class())) return static_cast<AliAODEvent*>(fRef)  ; return 0x0;}
-   AliMCEvent*  GetRefMCESD() {if (classMatchRefMC(AliMCEvent ::Class())) return static_cast<AliMCEvent *>(fRefMC); return 0x0;}
-   AliAODEvent* GetRefMCAOD() {if (classMatchRefMC(AliAODEvent::Class())) return static_cast<AliAODEvent*>(fRefMC); return 0x0;}
-   Bool_t       IsESD()       {return (GetRefESD() != 0x0);}
-   Bool_t       IsAOD()       {return (GetRefAOD() != 0x0);}
-
-   // advanced getters
-   Double_t         GetVz()                       {if (fRef) return fRef->GetPrimaryVertex()->GetZ(); return 1E+10;}
-   Int_t            GetMultiplicityFromTracks()   {if (fRef) return fRef->GetNumberOfTracks(); return -1;}
-   Int_t            GetMultiplicityFromMC()       {if (fRefMC) return fRefMC->GetNumberOfTracks(); return -1;}
-   Int_t            GetMultiplicityFromESDCuts();
-   Int_t            GetMultiplicityFromSPD();
+   Bool_t           Match(AliVEvent *ev, TClass *ref) {if (ev) return (ev->InheritsFrom(ref)); return kFALSE;}
+   Bool_t           IsESD()                           {return (Match(fRef, AliESDEvent::Class()));}
+   Bool_t           IsAOD()                           {return (Match(fRef, AliAODEvent::Class()));}
+   Bool_t           InputOK();                        
+   AliESDEvent*     GetRefESD()                       {if (IsESD()) return (AliESDEvent*)fRef;   return 0x0;}
+   AliMCEvent*      GetRefMCESD()                     {if (IsESD()) return (AliMCEvent *)fRefMC; return 0x0;}
+   AliAODEvent*     GetRefAOD()                       {if (IsAOD()) return (AliAODEvent*)fRef;   return 0x0;}
+   AliAODEvent*     GetRefMCAOD()                     {if (IsAOD()) return (AliAODEvent*)fRefMC; return 0x0;}
+   TClonesArray*    GetAODList()                      {return fAODList;}
+   Bool_t           HasMC()                           {if (IsESD()) return (fRefMC != 0x0); else if (IsAOD()) return (fRefMC != 0x0 && fAODList != 0x0); return kFALSE;}
 
    // setters for a daughter
-   Bool_t           SetDaughterAbs(AliRsnDaughter &daughter, Int_t absoluteIndex);
-   Bool_t           SetDaughter(AliRsnDaughter &daughter, Int_t index, AliRsnDaughter::ERefType type = AliRsnDaughter::kTrack);
-   Bool_t           SetDaughterMC(AliRsnDaughter &daughter, Int_t index);
-   AliRsnDaughter   GetDaughterAbs(Int_t absoluteIndex);
-   AliRsnDaughter   GetDaughter(Int_t i, AliRsnDaughter::ERefType type = AliRsnDaughter::kTrack);
-   AliRsnDaughter   GetDaughterMC(Int_t i);
-   Int_t            GetAbsoluteSum();
+   void             SetDaughter          (AliRsnDaughter &daughter, Int_t index, Bool_t fromMC = kFALSE);
+   AliRsnDaughter   GetDaughter          (Int_t index, Bool_t fromMC);
+   void             SetDaughterESDtrack  (AliRsnDaughter &target, Int_t index);
+   void             SetDaughterESDv0     (AliRsnDaughter &target, Int_t index);
+   void             SetDaughterESDcascade(AliRsnDaughter &target, Int_t index);
+   void             SetDaughterESDMCtrack(AliRsnDaughter &target, Int_t index);
+   void             SetDaughterAODtrack  (AliRsnDaughter &target, Int_t index);
+   void             SetDaughterAODv0     (AliRsnDaughter &target, Int_t index);
+   void             SetDaughterAODcascade(AliRsnDaughter &target, Int_t index);
+   void             SetDaughterAODMCtrack(AliRsnDaughter &target, Int_t index);
+   Bool_t           SetMCInfoESD         (AliRsnDaughter &target);
+   Bool_t           SetMCInfoAOD         (AliRsnDaughter &target);
+   
+   // counters/converters of candidates
+   Int_t            GetAbsoluteSum() {if (fRef) return (fRef->GetNumberOfTracks() + fRef->GetNumberOfV0s() + fRef->GetNumberOfCascades()); return 0;}
    Bool_t           ConvertAbsoluteIndex(Int_t index, Int_t &realIndex, AliRsnDaughter::ERefType &type);
    Int_t            ConvertRealIndex(Int_t index, AliRsnDaughter::ERefType type);
 
    // leading particle stuff
-   void             SetLeadingParticle(AliRsnDaughter &leading) {if (fLeading >= 0) SetDaughter(leading, fLeading);}
-   Int_t            SelectLeadingParticle(Double_t ptMin = 0.0, AliRsnCutPID *cutPID = 0x0);
-   Double_t         GetAverageMomentum(Int_t &count, AliRsnCutPID *cutPID = 0x0);
-   Bool_t           GetAngleDistr(Double_t &angleMean, Double_t &angleRMS, AliRsnDaughter reference);
+   void             SetLeadingParticle(AliRsnDaughter &leading) {if (fLeading >= 0) SetDaughter(leading, fLeading, kFALSE);}
+   Int_t            SelectLeadingParticle(AliRsnCutSet *cuts = 0x0);
    
 private:
 
-   Bool_t classMatchRef  (TClass *ref) {if (fRef  ) return (fRef  ->InheritsFrom(ref)); return kFALSE;}
-   Bool_t classMatchRefMC(TClass *ref) {if (fRefMC) return (fRefMC->InheritsFrom(ref)); return kFALSE;}
+   AliVEvent      *fRef;            //  pointer to input event
+   AliVEvent      *fRefMC;          //  pointer to reference MC event (if any)
+   Int_t           fLeading;        //  index of leading track
+   AliPIDResponse *fPID;            //  pointer to PID response
+   TClonesArray   *fAODList;        //  pointer to AOD list of particles (if any)
 
-   Bool_t SetDaughterESDtrack(AliRsnDaughter &target, Int_t index);
-   Bool_t SetDaughterAODtrack(AliRsnDaughter &target, Int_t index);
-   Bool_t SetDaughterESDv0(AliRsnDaughter &target, Int_t index);
-   Bool_t SetDaughterAODv0(AliRsnDaughter &target, Int_t index);
-   Bool_t SetDaughterESDcascade(AliRsnDaughter &target, Int_t index);
-   Bool_t SetDaughterAODcascade(AliRsnDaughter &target, Int_t index);
-   Bool_t SetMCInfoESD(AliRsnDaughter &target);
-   Bool_t SetMCInfoAOD(AliRsnDaughter &target);
+   ClassDef(AliRsnEvent, 6);
+};
 
-   AliVEvent   *fRef;               //  pointer to input event
-   AliVEvent   *fRefMC;             //  pointer to reference MC event (if any)
-   Int_t        fLeading;           //  index of leading track
-   Int_t        fLocalID;           //  identification number used locally
+inline Bool_t AliRsnEvent::InputOK()
+{
+//
+// Check that input is ESD or AOD
+//
 
-   ClassDef(AliRsnEvent, 4);
-};
+   if (IsESD()) {
+      AliDebugClass(1, "Input is ESD");
+      return kTRUE;
+   } else if (IsAOD()) {
+      AliDebugClass(1, "Input is AOD");
+      return kTRUE;
+   } else {
+      AliError("Need to process ESD or AOD input");
+      return kFALSE;
+   }
+}
+
+inline void AliRsnEvent::SetRefMC(AliVEvent *mc) 
+{
+//
+// Assign pointer to MC event.
+// If it is an AOD, retrieve the list of MC particles
+//
+
+   if (!mc) {
+      fRefMC = 0x0;
+      fAODList = 0x0;
+      return;
+   }
+
+   fRefMC = mc;
+   fAODList = 0x0;
+   if (fRefMC->InheritsFrom(AliAODEvent::Class())) {
+      AliAODEvent *aod = (AliAODEvent*)mc;
+      fAODList = (TClonesArray*)(aod->GetList()->FindObject(AliAODMCParticle::StdBranchName()));
+      if (!fAODList) fRefMC = 0x0;
+   }
+}
 
 #endif