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.
6 // Author: A. Pulvirenti
10 #include <TEntryList.h>
14 #include "AliRsnEvent.h"
15 #include "AliRsnDaughterDef.h"
16 #include "AliRsnDaughterSelector.h"
18 #include "AliRsnLoopDaughter.h"
20 ClassImp(AliRsnLoopDaughter)
22 //_____________________________________________________________________________
23 AliRsnLoopDaughter::AliRsnLoopDaughter(const char *name, Int_t listID, AliRsnDaughterDef *def) :
33 // Default constructor
37 //_____________________________________________________________________________
38 AliRsnLoopDaughter::AliRsnLoopDaughter(const AliRsnLoopDaughter ©) :
40 fTrueMC(copy.fTrueMC),
41 fOnlyTrue(copy.fOnlyTrue),
42 fUseMCRef(copy.fUseMCRef),
43 fListID(copy.fListID),
45 fDaughter(copy.fDaughter)
52 //_____________________________________________________________________________
53 AliRsnLoopDaughter &AliRsnLoopDaughter::operator=(const AliRsnLoopDaughter ©)
56 // Assignment operator
59 AliRsnLoop::operator=(copy);
62 fTrueMC = copy.fTrueMC;
63 fOnlyTrue = copy.fOnlyTrue;
64 fUseMCRef = copy.fUseMCRef;
65 fListID = copy.fListID;
66 fDaughter = copy.fDaughter;
72 //_____________________________________________________________________________
73 AliRsnLoopDaughter::~AliRsnLoopDaughter()
80 //_____________________________________________________________________________
81 void AliRsnLoopDaughter::Print(Option_t * /*option*/) const
84 // Prints info about pair
88 //_____________________________________________________________________________
89 Bool_t AliRsnLoopDaughter::Init(const char *prefix, TList *list)
92 // Initialization function.
93 // Loops on all functions and eventual the ntuple, to initialize output objects.
96 return AliRsnLoop::Init(Form("%s_%s", prefix, GetName()), list);
99 //_____________________________________________________________________________
100 Int_t AliRsnLoopDaughter::DoLoop
101 (AliRsnEvent *evMain, AliRsnDaughterSelector *selMain, AliRsnEvent *, AliRsnDaughterSelector *)
105 // Computes what is needed from passed events.
106 // Returns the number of pairs successfully processed.
109 if (!OkEvent(evMain)) return 0;
111 Int_t i, il, nadd = 0, nlist = 0;
112 TEntryList *list[2] = {0, 0};
114 if (fDef->IsChargeDefined()) {
115 list[0] = selMain->GetSelected(fListID, fDef->GetChargeC());
119 list[0] = selMain->GetSelected(fListID, '+');
121 list[1] = selMain->GetSelected(fListID, '-');
124 list[0] = selMain->GetSelected(fListID, '0');
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);
133 TObjArrayIter next(&fOutputs);
134 AliRsnListOutput *out = 0x0;
136 for (il = 0; il < nlist; il++) {
138 AliError(Form("List #%d is null", il));
141 for (i = 0; i < list[il]->GetN(); i++) {
142 evMain->SetDaughter(fDaughter, (Int_t)list[il]->GetEntry(i));
144 if (fOnlyTrue && !fDef->MatchesPID(&fDaughter)) continue;
145 if (!fDef->MatchesCharge(&fDaughter)) continue;
146 if (!fDef->MatchesRefType(&fDaughter)) continue;
147 fDaughter.FillP(fDef->GetMass());
151 while ( (out = (AliRsnListOutput *)next()) ) {
152 out->Fill(&fDaughter);
160 //_____________________________________________________________________________
161 Int_t AliRsnLoopDaughter::LoopTrueMC(AliRsnEvent *rsn)
164 // Loop on event and fill containers
167 // check presence of MC reference
168 if (!rsn->GetRefMC()) {
169 AliError("Need a MC to compute efficiency");
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");
180 // retrieve the MC primary vertex position
181 // and do some additional coherence checks
183 TClonesArray *listAOD = 0x0;
185 npart = rsn->GetRefMCESD()->GetNumberOfTracks();
187 AliAODEvent *aod = rsn->GetRefMCAOD();
188 listAOD = (TClonesArray *)(aod->GetList()->FindObject(AliAODMCParticle::StdBranchName()));
189 if (listAOD) npart = listAOD->GetEntries();
192 // check number of particles
194 AliInfo("Empty event");
199 Int_t ipart, count = 0;
200 TObjArrayIter next(&fOutputs);
201 AliRsnListOutput *out = 0x0;
202 Int_t pdg = AliRsnDaughter::SpeciesPDG(fDef->GetPID());
205 // loop over particles
206 for (ipart = 0; ipart < npart; ipart++) {
207 // check i-th particle
209 if (!rsn->GetRefMCESD()->Stack()->IsPhysicalPrimary(ipart)) continue;
210 AliMCParticle *part = (AliMCParticle *)rsn->GetRefMCESD()->GetTrack(ipart);
211 if (TMath::Abs(part->Particle()->GetPdgCode()) != pdg) continue;
212 fDaughter.SetRef (rsn->GetRefMCESD()->GetTrack(ipart));
213 fDaughter.SetRefMC(rsn->GetRefMCESD()->GetTrack(ipart));
215 AliAODMCParticle *part = (AliAODMCParticle *)listAOD->At(ipart);
216 if (!part->IsPhysicalPrimary()) continue;
217 if (TMath::Abs(part->GetPdgCode()) != pdg) continue;
218 fDaughter.SetRef ((AliAODMCParticle *)listAOD->At(ipart));
219 fDaughter.SetRefMC((AliAODMCParticle *)listAOD->At(ipart));
221 //if (fDaughter.GetPDG() != AliRsnDaughter::SpeciesPDG(fDef->GetPID())) continue;
222 fDaughter.FillP(fDef->GetMass());
226 while ( (out = (AliRsnListOutput *)next()) ) {
227 out->Fill(&fDaughter);