]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnLoop.cxx
Fix Coverity
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnLoop.cxx
1 //
2 // Base class to implement any computation within the RSN package.
3 // It contains only an array of output objects which must derive
4 // from AliRsnOutput.
5 // Its core functions ar Init() and DoLoop() which must be
6 // overloaded by any class which inherits from this.
7 //
8
9 #include <TList.h>
10 #include <TEntryList.h>
11
12 #include "AliLog.h"
13
14 #include "AliRsnDaughterSelector.h"
15
16 #include "AliRsnLoop.h"
17
18 ClassImp(AliRsnLoop)
19
20 //_____________________________________________________________________________
21 AliRsnLoop::AliRsnLoop(const char *name, Bool_t isMixed) :
22    TNamed(name, ""),
23    fIsMixed(isMixed),
24    fEventCuts(0x0),
25    fOutputs("AliRsnListOutput", 0)
26 {
27 //
28 // Default constructor
29 //
30 }
31
32 //_____________________________________________________________________________
33 AliRsnLoop::AliRsnLoop(const AliRsnLoop &copy) :
34    TNamed(copy),
35    fIsMixed(copy.fIsMixed),
36    fEventCuts(copy.fEventCuts),
37    fOutputs(copy.fOutputs)
38 {
39 //
40 // Default constructor
41 //
42 }
43
44 //_____________________________________________________________________________
45 AliRsnLoop &AliRsnLoop::operator=(const AliRsnLoop &copy)
46 {
47 //
48 // Assignment operator
49 //
50    if (this == &copy)
51       return *this;
52    fIsMixed = copy.fIsMixed;
53    fEventCuts = copy.fEventCuts;
54    fOutputs = copy.fOutputs;
55    return (*this);
56 }
57
58 //_____________________________________________________________________________
59 AliRsnLoop::~AliRsnLoop()
60 {
61 //
62 // Destructor
63 //
64 }
65
66 //_____________________________________________________________________________
67 void AliRsnLoop::AddOutput(TObject *object)
68 {
69 //
70 // Adds an object to any of the collections.
71 // The target depends on the object type.
72 // Returns kFALSE if the addition failed.
73 //
74
75    //fOutputs.AddLast(out);
76    AliRsnListOutput *out = (AliRsnListOutput *)object;
77    Int_t n = fOutputs.GetEntries();
78    new (fOutputs[n]) AliRsnListOutput(*out);
79 }
80
81 //_____________________________________________________________________________
82 void AliRsnLoop::Print(Option_t *) const
83 {
84 //
85 // Prints info about pair
86 //
87
88    TObjArrayIter next(&fOutputs);
89    AliRsnListOutput *out = 0x0;
90
91    while ( (out = (AliRsnListOutput *)next()) ) {
92       out->Print();
93    }
94 }
95
96 //_____________________________________________________________________________
97 Bool_t AliRsnLoop::OkEvent(AliRsnEvent *rsn)
98 {
99 //
100 // If event cuts are defined, check event against them
101 //
102
103    if (fEventCuts)
104       return fEventCuts->IsSelected(rsn);
105    else
106       return kTRUE;
107 }
108
109 //_____________________________________________________________________________
110 Bool_t AliRsnLoop::Init(const char *prefix, TList *list)
111 {
112 //
113 // Initialization function.
114 // Loops on all outputs, and initialize each of them.
115 // Returns kTRUE only if all initializations were successful.
116 //
117
118    TObjArrayIter next(&fOutputs);
119    AliRsnListOutput *out;
120    Bool_t globalOK = kTRUE;
121
122    while ( (out = (AliRsnListOutput *)next()) ) {
123       globalOK = globalOK && out->Init(prefix, list);
124    }
125
126    AliInfo(Form("[%s] Object initialization: %s", GetName(), (globalOK ? "successful" : "failed")));
127    return globalOK;
128 }
129
130 //_____________________________________________________________________________
131 Int_t AliRsnLoop::DoLoop
132 (AliRsnEvent *, AliRsnDaughterSelector *, AliRsnEvent *, AliRsnDaughterSelector *)
133 {
134 //
135 // Main loop.
136 // Performs all the computations, looping on the passed event(s) and using the lists
137 // of selected daughters which are provided, for allowing the user to choose what to do
138 // with them.
139 //
140
141    AliWarning("Implement this method in derived class");
142    return 0;
143 }