]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnLoopDaughter.cxx
ff2408e655077a6a12ca5b2eb9c62d817ba1d928
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnLoopDaughter.cxx
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.
6 //
7
8 #include <TEntryList.h>
9
10 #include "AliLog.h"
11
12 #include "AliRsnEvent.h"
13 #include "AliRsnDaughterDef.h"
14 #include "AliRsnDaughterSelector.h"
15
16 #include "AliRsnLoopDaughter.h"
17
18 ClassImp(AliRsnLoopDaughter)
19
20 //_____________________________________________________________________________
21 AliRsnLoopDaughter::AliRsnLoopDaughter(const char *name, Int_t listID, AliRsnDaughterDef *def) :
22    AliRsnLoop(name),
23    fListID(listID),
24    fDef(def),
25    fDaughter()
26 {
27 //
28 // Default constructor
29 //
30 }
31
32 //_____________________________________________________________________________
33 AliRsnLoopDaughter::AliRsnLoopDaughter(const AliRsnLoopDaughter& copy) :
34    AliRsnLoop(copy),
35    fListID(copy.fListID),
36    fDef(copy.fDef),
37    fDaughter(copy.fDaughter)
38 {
39 //
40 // Copy constructor
41 //
42 }
43
44 //_____________________________________________________________________________
45 AliRsnLoopDaughter& AliRsnLoopDaughter::operator=(const AliRsnLoopDaughter& copy)
46 {
47 //
48 // Assignment operator
49 //
50
51    AliRsnLoop::operator=(copy);
52    fListID = copy.fListID;
53    fDaughter = copy.fDaughter;
54    fDef = copy.fDef;
55
56    return (*this);
57 }
58
59 //_____________________________________________________________________________
60 AliRsnLoopDaughter::~AliRsnLoopDaughter()
61 {
62 //
63 // Destructor
64 //
65 }
66
67 //_____________________________________________________________________________
68 void AliRsnLoopDaughter::Print(Option_t* /*option*/) const
69 {
70 //
71 // Prints info about pair
72 //
73 }
74
75 //_____________________________________________________________________________
76 Bool_t AliRsnLoopDaughter::Init(const char *prefix, TList *list)
77 {
78 //
79 // Initialization function.
80 // Loops on all functions and eventual the ntuple, to initialize output objects.
81 //
82
83    return AliRsnLoop::Init(Form("%s_%s", prefix, GetName()), list);
84 }
85
86 //_____________________________________________________________________________
87 Int_t AliRsnLoopDaughter::DoLoop
88 (AliRsnEvent *evMain, AliRsnDaughterSelector *selMain, AliRsnEvent *, AliRsnDaughterSelector *)
89 {
90 //
91 // Loop function.
92 // Computes what is needed from passed events.
93 // Returns the number of pairs successfully processed.
94 //
95
96    if (!OkEvent(evMain)) return 0;
97
98    Int_t i, il, nadd = 0, nlist = 0;
99    TEntryList *list[2] = {0, 0};
100    
101    if (fDef->IsChargeDefined()) {
102       list[0] = selMain->GetSelected(fListID, fDef->GetChargeC());
103       list[1] = 0x0;
104       nlist = 1;
105    } else {
106       list[0] = selMain->GetSelected(fListID, '+');
107       if (list[0]) {
108          list[1] = selMain->GetSelected(fListID, '-');
109          nlist = 2;
110       } else {
111          list[0] = selMain->GetSelected(fListID, '0');
112          list[1] = 0x0;
113          nlist = 1;
114       }
115    }
116    
117    TObjArrayIter next(&fOutputs);
118    AliRsnListOutput *out = 0x0;
119    
120    for (il = 0; il < nlist; il++) {
121       if (!list[il]) {
122          AliError(Form("List #%d is null", il));
123          continue;
124       }
125       for (i = 0; i < list[il]->GetN(); i++) {
126          evMain->SetDaughterAbs(fDaughter, (Int_t)list[il]->GetEntry(i));
127          // check matching
128          if (!fDef->MatchesDaughter(&fDaughter)) continue;
129          // fill outputs
130          nadd++;
131          next.Reset();
132          while ( (out = (AliRsnListOutput*)next()) ) {
133             out->Fill(&fDaughter);
134          }
135       }
136    }
137    
138    return nadd;
139 }