]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnEvent.h
- Removed small bug (otherwise chargeVector was not filled for normal data)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnEvent.h
1 #ifndef ALIRSNEVENT_H
2 #define ALIRSNEVENT_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6  
7 ////////////////////////////////////////////////////////////////////////////////
8 //
9 //  Interface to full event.
10 //
11 ////////////////////////////////////////////////////////////////////////////////
12
13 #include <TClonesArray.h>
14
15 #include "AliLog.h"
16
17 #include "AliStack.h"
18 #include "AliVEvent.h"
19 #include "AliMCEvent.h"
20 #include "AliESDEvent.h"
21 #include "AliAODEvent.h"
22 #include "AliAODMCParticle.h"
23
24 #include "AliRsnDaughter.h"
25
26 class AliRsnCutSet;
27 class AliPIDResponse;
28
29 class AliRsnEvent : public TObject {
30 public:
31
32    AliRsnEvent(AliVEvent *ref = 0, AliVEvent *refMC = 0);
33    AliRsnEvent(const AliRsnEvent& copy);
34    AliRsnEvent& operator= (const AliRsnEvent& copy);
35    virtual ~AliRsnEvent();
36
37    // basic setters/getters
38    void             SetRef(AliVEvent *ref)              {fRef = ref;}
39    void             SetRefMC(AliVEvent *refmc);
40    void             SetPIDResponse(AliPIDResponse *pid) {fPID = pid;}
41    AliVEvent*       GetRef()                            {return fRef;}
42    AliVEvent*       GetRefMC()                          {return fRefMC;}
43    Int_t            GetLeadingIndex() const             {return fLeading;}
44    AliPIDResponse*  GetPIDResponse()                    {return fPID;}
45
46    // getters which convert into allowed input types
47    Bool_t           Match(AliVEvent *ev, TClass *ref) {if (ev) return (ev->InheritsFrom(ref)); return kFALSE;}
48    Bool_t           IsESD()                           {return (Match(fRef, AliESDEvent::Class()));}
49    Bool_t           IsAOD()                           {return (Match(fRef, AliAODEvent::Class()));}
50    Bool_t           InputOK();                        
51    AliESDEvent*     GetRefESD()                       {if (IsESD()) return (AliESDEvent*)fRef;   return 0x0;}
52    AliMCEvent*      GetRefMCESD()                     {if (IsESD()) return (AliMCEvent *)fRefMC; return 0x0;}
53    AliAODEvent*     GetRefAOD()                       {if (IsAOD()) return (AliAODEvent*)fRef;   return 0x0;}
54    AliAODEvent*     GetRefMCAOD()                     {if (IsAOD()) return (AliAODEvent*)fRefMC; return 0x0;}
55    TClonesArray*    GetAODList()                      {return fAODList;}
56    Bool_t           HasMC()                           {if (IsESD()) return (fRefMC != 0x0); else if (IsAOD()) return (fRefMC != 0x0 && fAODList != 0x0); return kFALSE;}
57
58    // setters for a daughter
59    void             SetDaughter          (AliRsnDaughter &daughter, Int_t index, Bool_t fromMC = kFALSE);
60    AliRsnDaughter   GetDaughter          (Int_t index, Bool_t fromMC);
61    void             SetDaughterESDtrack  (AliRsnDaughter &target, Int_t index);
62    void             SetDaughterESDv0     (AliRsnDaughter &target, Int_t index);
63    void             SetDaughterESDcascade(AliRsnDaughter &target, Int_t index);
64    void             SetDaughterESDMCtrack(AliRsnDaughter &target, Int_t index);
65    void             SetDaughterAODtrack  (AliRsnDaughter &target, Int_t index);
66    void             SetDaughterAODv0     (AliRsnDaughter &target, Int_t index);
67    void             SetDaughterAODcascade(AliRsnDaughter &target, Int_t index);
68    void             SetDaughterAODMCtrack(AliRsnDaughter &target, Int_t index);
69    Bool_t           SetMCInfoESD         (AliRsnDaughter &target);
70    Bool_t           SetMCInfoAOD         (AliRsnDaughter &target);
71    
72    // counters/converters of candidates
73    Int_t            GetAbsoluteSum() {if (fRef) return (fRef->GetNumberOfTracks() + fRef->GetNumberOfV0s() + fRef->GetNumberOfCascades()); return 0;}
74    Bool_t           ConvertAbsoluteIndex(Int_t index, Int_t &realIndex, AliRsnDaughter::ERefType &type);
75    Int_t            ConvertRealIndex(Int_t index, AliRsnDaughter::ERefType type);
76
77    // leading particle stuff
78    void             SetLeadingParticle(AliRsnDaughter &leading) {if (fLeading >= 0) SetDaughter(leading, fLeading, kFALSE);}
79    Int_t            SelectLeadingParticle(AliRsnCutSet *cuts = 0x0);
80    
81 private:
82
83    AliVEvent      *fRef;            //  pointer to input event
84    AliVEvent      *fRefMC;          //  pointer to reference MC event (if any)
85    Int_t           fLeading;        //  index of leading track
86    AliPIDResponse *fPID;            //  pointer to PID response
87    TClonesArray   *fAODList;        //  pointer to AOD list of particles (if any)
88
89    ClassDef(AliRsnEvent, 6);
90 };
91
92 inline Bool_t AliRsnEvent::InputOK()
93 {
94 //
95 // Check that input is ESD or AOD
96 //
97
98    if (IsESD()) {
99       AliDebugClass(1, "Input is ESD");
100       return kTRUE;
101    } else if (IsAOD()) {
102       AliDebugClass(1, "Input is AOD");
103       return kTRUE;
104    } else {
105       AliError("Need to process ESD or AOD input");
106       return kFALSE;
107    }
108 }
109
110 inline void AliRsnEvent::SetRefMC(AliVEvent *mc) 
111 {
112 //
113 // Assign pointer to MC event.
114 // If it is an AOD, retrieve the list of MC particles
115 //
116
117    if (!mc) {
118       fRefMC = 0x0;
119       fAODList = 0x0;
120       return;
121    }
122
123    fRefMC = mc;
124    fAODList = 0x0;
125    if (fRefMC->InheritsFrom(AliAODEvent::Class())) {
126       AliAODEvent *aod = (AliAODEvent*)mc;
127       fAODList = (TClonesArray*)(aod->GetList()->FindObject(AliAODMCParticle::StdBranchName()));
128       if (!fAODList) fRefMC = 0x0;
129    }
130 }
131
132 #endif