example macros to run on proof
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnLoop.cxx
CommitLineData
c865cb1d 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
18ClassImp(AliRsnLoop)
19
20//_____________________________________________________________________________
21AliRsnLoop::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//_____________________________________________________________________________
33AliRsnLoop::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//_____________________________________________________________________________
45AliRsnLoop& AliRsnLoop::operator=(const AliRsnLoop& copy)
46{
47//
48// Assignment operator
49//
50
51 fIsMixed = copy.fIsMixed;
52 fEventCuts = copy.fEventCuts;
53 fOutputs = copy.fOutputs;
54 return (*this);
55}
56
57//_____________________________________________________________________________
58AliRsnLoop::~AliRsnLoop()
59{
60//
61// Destructor
62//
63}
64
65//_____________________________________________________________________________
66void AliRsnLoop::AddOutput(TObject *object)
67{
68//
69// Adds an object to any of the collections.
70// The target depends on the object type.
71// Returns kFALSE if the addition failed.
72//
73
74 //fOutputs.AddLast(out);
75 AliRsnListOutput *out = (AliRsnListOutput*)object;
76 Int_t n = fOutputs.GetEntries();
77 new (fOutputs[n]) AliRsnListOutput(*out);
78}
79
80//_____________________________________________________________________________
81void AliRsnLoop::Print(Option_t*) const
82{
83//
84// Prints info about pair
85//
86
87 TObjArrayIter next(&fOutputs);
88 AliRsnListOutput *out = 0x0;
89
90 while ( (out = (AliRsnListOutput*)next()) ) {
91 out->Print();
92 }
93}
94
95//_____________________________________________________________________________
96Bool_t AliRsnLoop::OkEvent(AliRsnEvent *rsn)
97{
98//
99// If event cuts are defined, check event against them
100//
101
102 if (fEventCuts)
103 return fEventCuts->IsSelected(rsn);
104 else
105 return kTRUE;
106}
107
108//_____________________________________________________________________________
109Bool_t AliRsnLoop::Init(const char *prefix, TList *list)
110{
111//
112// Initialization function.
113// Loops on all outputs, and initialize each of them.
114// Returns kTRUE only if all initializations were successful.
115//
116
117 TObjArrayIter next(&fOutputs);
118 AliRsnListOutput *out;
119 Bool_t globalOK = kTRUE;
120
121 while ( (out = (AliRsnListOutput*)next()) ) {
122 globalOK = globalOK && out->Init(prefix, list);
123 }
124
125 AliInfo(Form("[%s] Object initialization: %s", GetName(), (globalOK ? "successful" : "failed")));
126 return globalOK;
127}
128
129//_____________________________________________________________________________
130Int_t AliRsnLoop::DoLoop
131(AliRsnEvent *, AliRsnDaughterSelector *, AliRsnEvent *, AliRsnDaughterSelector *)
132{
133//
134// Main loop.
135// Performs all the computations, looping on the passed event(s) and using the lists
136// of selected daughters which are provided, for allowing the user to choose what to do
137// with them.
138//
139
140 AliWarning("Implement this method in derived class");
141 return 0;
142}