]>
Commit | Line | Data |
---|---|---|
c865cb1d | 1 | // |
2 | // Computator for single daughters. | |
3 | // Implements a simple loop on tracks from one of the entry lists | |
4 | // filled by the task AliRsnInputHandler, adding a check on their | |
5 | // definition specified in the daughter def. | |
b63357a0 | 6 | // Author: A. Pulvirenti |
c865cb1d | 7 | // |
8 | ||
b63357a0 | 9 | #include <Riostream.h> |
c865cb1d | 10 | #include <TEntryList.h> |
11 | ||
12 | #include "AliLog.h" | |
13 | ||
14 | #include "AliRsnEvent.h" | |
15 | #include "AliRsnDaughterDef.h" | |
16 | #include "AliRsnDaughterSelector.h" | |
17 | ||
18 | #include "AliRsnLoopDaughter.h" | |
19 | ||
20 | ClassImp(AliRsnLoopDaughter) | |
21 | ||
22 | //_____________________________________________________________________________ | |
23 | AliRsnLoopDaughter::AliRsnLoopDaughter(const char *name, Int_t listID, AliRsnDaughterDef *def) : | |
24 | AliRsnLoop(name), | |
b63357a0 | 25 | fTrueMC(kFALSE), |
f34f960b | 26 | fOnlyTrue(kFALSE), |
52e6652d | 27 | fUseMCRef(kFALSE), |
c865cb1d | 28 | fListID(listID), |
29 | fDef(def), | |
30 | fDaughter() | |
31 | { | |
32 | // | |
33 | // Default constructor | |
34 | // | |
35 | } | |
36 | ||
37 | //_____________________________________________________________________________ | |
61f275d1 | 38 | AliRsnLoopDaughter::AliRsnLoopDaughter(const AliRsnLoopDaughter ©) : |
c865cb1d | 39 | AliRsnLoop(copy), |
b63357a0 | 40 | fTrueMC(copy.fTrueMC), |
f34f960b | 41 | fOnlyTrue(copy.fOnlyTrue), |
52e6652d | 42 | fUseMCRef(copy.fUseMCRef), |
c865cb1d | 43 | fListID(copy.fListID), |
44 | fDef(copy.fDef), | |
45 | fDaughter(copy.fDaughter) | |
46 | { | |
47 | // | |
48 | // Copy constructor | |
49 | // | |
50 | } | |
51 | ||
52 | //_____________________________________________________________________________ | |
61f275d1 | 53 | AliRsnLoopDaughter &AliRsnLoopDaughter::operator=(const AliRsnLoopDaughter ©) |
c865cb1d | 54 | { |
55 | // | |
56 | // Assignment operator | |
57 | // | |
58 | ||
59 | AliRsnLoop::operator=(copy); | |
e6f3a909 | 60 | if (this == ©) |
61f275d1 | 61 | return *this; |
b63357a0 | 62 | fTrueMC = copy.fTrueMC; |
f34f960b | 63 | fOnlyTrue = copy.fOnlyTrue; |
52e6652d | 64 | fUseMCRef = copy.fUseMCRef; |
c865cb1d | 65 | fListID = copy.fListID; |
66 | fDaughter = copy.fDaughter; | |
67 | fDef = copy.fDef; | |
68 | ||
69 | return (*this); | |
70 | } | |
71 | ||
72 | //_____________________________________________________________________________ | |
73 | AliRsnLoopDaughter::~AliRsnLoopDaughter() | |
74 | { | |
75 | // | |
76 | // Destructor | |
77 | // | |
78 | } | |
79 | ||
80 | //_____________________________________________________________________________ | |
81 | void AliRsnLoopDaughter::Print(Option_t* /*option*/) const | |
82 | { | |
83 | // | |
84 | // Prints info about pair | |
85 | // | |
86 | } | |
87 | ||
88 | //_____________________________________________________________________________ | |
89 | Bool_t AliRsnLoopDaughter::Init(const char *prefix, TList *list) | |
90 | { | |
91 | // | |
92 | // Initialization function. | |
93 | // Loops on all functions and eventual the ntuple, to initialize output objects. | |
94 | // | |
95 | ||
96 | return AliRsnLoop::Init(Form("%s_%s", prefix, GetName()), list); | |
97 | } | |
98 | ||
99 | //_____________________________________________________________________________ | |
100 | Int_t AliRsnLoopDaughter::DoLoop | |
101 | (AliRsnEvent *evMain, AliRsnDaughterSelector *selMain, AliRsnEvent *, AliRsnDaughterSelector *) | |
102 | { | |
103 | // | |
104 | // Loop function. | |
105 | // Computes what is needed from passed events. | |
106 | // Returns the number of pairs successfully processed. | |
107 | // | |
108 | ||
109 | if (!OkEvent(evMain)) return 0; | |
110 | ||
111 | Int_t i, il, nadd = 0, nlist = 0; | |
112 | TEntryList *list[2] = {0, 0}; | |
61f275d1 | 113 | |
c865cb1d | 114 | if (fDef->IsChargeDefined()) { |
115 | list[0] = selMain->GetSelected(fListID, fDef->GetChargeC()); | |
116 | list[1] = 0x0; | |
117 | nlist = 1; | |
118 | } else { | |
119 | list[0] = selMain->GetSelected(fListID, '+'); | |
120 | if (list[0]) { | |
121 | list[1] = selMain->GetSelected(fListID, '-'); | |
122 | nlist = 2; | |
123 | } else { | |
124 | list[0] = selMain->GetSelected(fListID, '0'); | |
125 | list[1] = 0x0; | |
126 | nlist = 1; | |
127 | } | |
128 | } | |
61f275d1 | 129 | |
b63357a0 | 130 | // if it is required to loop over True MC, do this here and skip the rest of the method |
131 | if (fTrueMC) return LoopTrueMC(evMain); | |
61f275d1 | 132 | |
c865cb1d | 133 | TObjArrayIter next(&fOutputs); |
134 | AliRsnListOutput *out = 0x0; | |
61f275d1 | 135 | |
c865cb1d | 136 | for (il = 0; il < nlist; il++) { |
137 | if (!list[il]) { | |
138 | AliError(Form("List #%d is null", il)); | |
139 | continue; | |
140 | } | |
141 | for (i = 0; i < list[il]->GetN(); i++) { | |
f34f960b | 142 | evMain->SetDaughter(fDaughter, (Int_t)list[il]->GetEntry(i)); |
c865cb1d | 143 | // check matching |
f34f960b | 144 | if (fOnlyTrue && !fDef->MatchesPID(&fDaughter)) continue; |
145 | if (!fDef->MatchesCharge(&fDaughter)) continue; | |
146 | if (!fDef->MatchesRefType(&fDaughter)) continue; | |
b63357a0 | 147 | fDaughter.FillP(fDef->GetMass()); |
c865cb1d | 148 | // fill outputs |
149 | nadd++; | |
150 | next.Reset(); | |
61f275d1 | 151 | while ( (out = (AliRsnListOutput *)next()) ) { |
c865cb1d | 152 | out->Fill(&fDaughter); |
153 | } | |
154 | } | |
155 | } | |
61f275d1 | 156 | |
c865cb1d | 157 | return nadd; |
158 | } | |
b63357a0 | 159 | |
160 | //_____________________________________________________________________________ | |
161 | Int_t AliRsnLoopDaughter::LoopTrueMC(AliRsnEvent *rsn) | |
162 | { | |
163 | // | |
164 | // Loop on event and fill containers | |
165 | // | |
166 | ||
167 | // check presence of MC reference | |
168 | if (!rsn->GetRefMC()) { | |
169 | AliError("Need a MC to compute efficiency"); | |
170 | return 0; | |
171 | } | |
61f275d1 | 172 | |
b63357a0 | 173 | // check event type: |
174 | // must be ESD or AOD, and then use a bool to know in the rest | |
175 | if (!rsn->IsESD() && !rsn->IsAOD()) { | |
176 | AliError("Need to process ESD or AOD input"); | |
177 | return 0; | |
178 | } | |
61f275d1 | 179 | |
b63357a0 | 180 | // retrieve the MC primary vertex position |
181 | // and do some additional coherence checks | |
182 | Int_t npart = 0; | |
183 | TClonesArray *listAOD = 0x0; | |
184 | if (rsn->IsESD()) { | |
185 | npart = rsn->GetRefMCESD()->GetNumberOfTracks(); | |
186 | } else { | |
187 | AliAODEvent *aod = rsn->GetRefMCAOD(); | |
61f275d1 | 188 | listAOD = (TClonesArray *)(aod->GetList()->FindObject(AliAODMCParticle::StdBranchName())); |
b63357a0 | 189 | if (listAOD) npart = listAOD->GetEntries(); |
190 | } | |
61f275d1 | 191 | |
b63357a0 | 192 | // check number of particles |
193 | if (!npart) { | |
194 | AliInfo("Empty event"); | |
195 | return 0; | |
196 | } | |
61f275d1 | 197 | |
b63357a0 | 198 | // utility variables |
199 | Int_t ipart, count = 0; | |
200 | TObjArrayIter next(&fOutputs); | |
201 | AliRsnListOutput *out = 0x0; | |
202 | Int_t pdg = AliRsnDaughter::SpeciesPDG(fDef->GetPID()); | |
61f275d1 | 203 | |
204 | ||
b63357a0 | 205 | // loop over particles |
206 | for (ipart = 0; ipart < npart; ipart++) { | |
207 | // check i-th particle | |
208 | if (rsn->IsESD()) { | |
209 | if (!rsn->GetRefMCESD()->Stack()->IsPhysicalPrimary(ipart)) continue; | |
61f275d1 | 210 | AliMCParticle *part = (AliMCParticle *)rsn->GetRefMCESD()->GetTrack(ipart); |
b63357a0 | 211 | if (TMath::Abs(part->Particle()->GetPdgCode()) != pdg) continue; |
212 | fDaughter.SetRef (rsn->GetRefMCESD()->GetTrack(ipart)); | |
213 | fDaughter.SetRefMC(rsn->GetRefMCESD()->GetTrack(ipart)); | |
214 | } else { | |
61f275d1 | 215 | AliAODMCParticle *part = (AliAODMCParticle *)listAOD->At(ipart); |
b63357a0 | 216 | if (!part->IsPhysicalPrimary()) continue; |
217 | if (TMath::Abs(part->GetPdgCode()) != pdg) continue; | |
61f275d1 | 218 | fDaughter.SetRef ((AliAODMCParticle *)listAOD->At(ipart)); |
219 | fDaughter.SetRefMC((AliAODMCParticle *)listAOD->At(ipart)); | |
b63357a0 | 220 | } |
221 | //if (fDaughter.GetPDG() != AliRsnDaughter::SpeciesPDG(fDef->GetPID())) continue; | |
222 | fDaughter.FillP(fDef->GetMass()); | |
223 | // fill outputs | |
224 | count++; | |
225 | next.Reset(); | |
61f275d1 | 226 | while ( (out = (AliRsnListOutput *)next()) ) { |
b63357a0 | 227 | out->Fill(&fDaughter); |
228 | } | |
229 | } | |
61f275d1 | 230 | |
b63357a0 | 231 | return count; |
232 | } |