Coverity fix
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnEvent.h
CommitLineData
0dffcc8a 1#ifndef ALIRSNEVENT_H
2#define ALIRSNEVENT_H
3
7356f978 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
b63357a0 13#include <TClonesArray.h>
14
f34f960b 15#include "AliLog.h"
16
c865cb1d 17#include "AliStack.h"
5f1c287d 18#include "AliVEvent.h"
a378358c 19#include "AliMCEvent.h"
2dab9030 20#include "AliESDEvent.h"
21#include "AliAODEvent.h"
b63357a0 22#include "AliAODMCParticle.h"
f34f960b 23
e2bafbbc 24#include "AliRsnDaughter.h"
78b94cbd 25
f34f960b 26class AliRsnCutSet;
c865cb1d 27class AliPIDResponse;
7c2974c8 28
2a1c7696 29class AliRsnEvent : public TObject {
30public:
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
f34f960b 38 void SetRef(AliVEvent *ref) {fRef = ref;}
b63357a0 39 void SetRefMC(AliVEvent *refmc);
f34f960b 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;}
2a1c7696 45
46 // getters which convert into allowed input types
f34f960b 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;}
b63357a0 55 TClonesArray* GetAODList() {return fAODList;}
56 Bool_t HasMC() {if (IsESD()) return (fRefMC != 0x0); else if (IsAOD()) return (fRefMC != 0x0 && fAODList != 0x0); return kFALSE;}
2a1c7696 57
58 // setters for a daughter
f34f960b 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
c865cb1d 73 Int_t GetAbsoluteSum() {if (fRef) return (fRef->GetNumberOfTracks() + fRef->GetNumberOfV0s() + fRef->GetNumberOfCascades()); return 0;}
2a1c7696 74 Bool_t ConvertAbsoluteIndex(Int_t index, Int_t &realIndex, AliRsnDaughter::ERefType &type);
7356f978 75 Int_t ConvertRealIndex(Int_t index, AliRsnDaughter::ERefType type);
2a1c7696 76
77 // leading particle stuff
f34f960b 78 void SetLeadingParticle(AliRsnDaughter &leading) {if (fLeading >= 0) SetDaughter(leading, fLeading, kFALSE);}
79 Int_t SelectLeadingParticle(AliRsnCutSet *cuts = 0x0);
eaa44581 80
2a1c7696 81private:
82
f34f960b 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
b63357a0 87 TClonesArray *fAODList; // pointer to AOD list of particles (if any)
2a1c7696 88
b63357a0 89 ClassDef(AliRsnEvent, 6);
0dffcc8a 90};
91
f34f960b 92inline 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
b63357a0 110inline 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;
de957967 120 return;
b63357a0 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
0dffcc8a 132#endif