]> 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 331ffa160c769c0ff5b420e81a937775fa31ad6e..23750c91f4e151931f97b09092fea15a2eebf616 100644 (file)
+#ifndef ALIRSNEVENT_H
+#define ALIRSNEVENT_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+////////////////////////////////////////////////////////////////////////////////
 //
-// *** Class AliRsnEvent ***
-//
-// A container for a collection of AliRsnDaughter objects from an event.
-// Contains also the primary vertex, useful for some cuts.
-// In order to retrieve easily the tracks which have been identified
-// as a specific type and charge, there is an array of indexes which
-// allows to avoid to loop on all tracks and have only the neede ones.
-//
-// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
-//          M. Vala (email: martin.vala@cern.ch)
+//  Interface to full event.
 //
+////////////////////////////////////////////////////////////////////////////////
 
-#ifndef ALIRSNEVENT_H
-#define ALIRSNEVENT_H
+#include <TClonesArray.h>
 
+#include "AliLog.h"
+
+#include "AliStack.h"
+#include "AliVEvent.h"
 #include "AliMCEvent.h"
 #include "AliESDEvent.h"
 #include "AliAODEvent.h"
+#include "AliAODMCParticle.h"
+
 #include "AliRsnDaughter.h"
 
-class AliVEvent;
-class AliRsnCutPID;
-class AliESDtrackCuts;
+class AliRsnCutSet;
+class AliPIDResponse;
 
-class AliRsnEvent : public TObject
-{
-  public:
-
-    AliRsnEvent(AliVEvent *ref = 0, AliVEvent *refMC = 0);
-    AliRsnEvent(const AliRsnEvent& copy);
-    AliRsnEvent& operator= (const AliRsnEvent& copy);
-    virtual ~AliRsnEvent() { /*nothing*/ }
-    
-    // basic setters/getters
-    void       SetRef(AliVEvent *ref) {fRef = ref;}
-    void       SetRefMC(AliVEvent *refmc) {fRefMC = refmc;}
-    void       SetLeadingIndex(Int_t i) {fLeading = i;}
-    AliVEvent* GetRef() {return fRef;}
-    AliVEvent* GetRefMC() {return fRefMC;}
-    Int_t      GetLeadingIndex() const {return fLeading;}
-    
-    // getters which convert into allowed input types
-    AliESDEvent* GetRefESD()   {return dynamic_cast<AliESDEvent*>(fRef);}
-    AliAODEvent* GetRefAOD()   {return dynamic_cast<AliAODEvent*>(fRef);}
-    AliMCEvent*  GetRefMCESD() {return dynamic_cast<AliMCEvent*>(fRefMC);}
-    AliAODEvent* GetRefMCAOD() {return dynamic_cast<AliAODEvent*>(fRefMC);}
-    Bool_t       IsESD()       {return (GetRefESD() != 0x0);}
-    Bool_t       IsAOD()       {return (GetRefAOD() != 0x0);}
-    
-    // advanced getters
-    Double_t         GetVz();
-    Int_t            GetMultiplicity(AliESDtrackCuts *cuts = 0x0);
-    
-    // setters for a daughter
-    Bool_t           SetDaughter(AliRsnDaughter &daughter, Int_t index, AliRsnDaughter::ERefType type = AliRsnDaughter::kTrack);
-    Bool_t           SetDaughterMC(AliRsnDaughter &daughter, Int_t index);
-    AliRsnDaughter   GetDaughter(Int_t i, AliRsnDaughter::ERefType type = AliRsnDaughter::kTrack);
-    AliRsnDaughter   GetDaughterMC(Int_t i);
-    
-    // leading particle stuff
-    Int_t            SelectLeadingParticle(Double_t ptMin = 0.0, AliRsnCutPID *cutPID = 0x0);
-    Int_t            GetLeadingParticleID() {return fLeading;}
-    void             SetLeadingParticle(AliRsnDaughter &leading) {if (fLeading >= 0) SetDaughter(leading, fLeading);}
-    Double_t         GetAverageMomentum(Int_t &count, AliRsnCutPID *cutPID = 0x0);
-    Bool_t           GetAngleDistr(Double_t &angleMean, Double_t &angleRMS, AliRsnDaughter reference);
-
-  private:
-  
-    Int_t SetDaughterESDtrack(AliRsnDaughter &target, Int_t index);
-    Int_t SetDaughterAODtrack(AliRsnDaughter &target, Int_t index);
-    Int_t SetDaughterESDv0   (AliRsnDaughter &target, Int_t index);
-    Int_t SetDaughterAODv0   (AliRsnDaughter &target, Int_t index);
-
-    AliVEvent       *fRef;      // pointer to input event
-    AliVEvent       *fRefMC;    // pointer to reference MC event (if any)
-    Int_t            fLeading;  // index of leading track
-
-    ClassDef(AliRsnEvent, 4);
+class AliRsnEvent : public TObject {
+public:
+
+   AliRsnEvent(AliVEvent *ref = 0, AliVEvent *refMC = 0);
+   AliRsnEvent(const AliRsnEvent& copy);
+   AliRsnEvent& operator= (const AliRsnEvent& copy);
+   virtual ~AliRsnEvent();
+
+   // basic setters/getters
+   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
+   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
+   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, kFALSE);}
+   Int_t            SelectLeadingParticle(AliRsnCutSet *cuts = 0x0);
+   
+private:
+
+   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)
+
+   ClassDef(AliRsnEvent, 6);
 };
 
+inline Bool_t AliRsnEvent::InputOK()
+{
+//
+// Check that input is ESD or AOD
+//
+
+   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