2 // Class AliRsnAnalysisTaskEff
4 // Base class for efficiency computation tasks
5 // which should be inherited by different efficiency computators
7 // author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
10 #include "AliVEvent.h"
12 #include "AliRsnEvent.h"
13 #include "AliRsnCutSet.h"
15 #include "AliRsnAnalysisTaskEff.h"
17 ClassImp(AliRsnAnalysisTaskEff)
19 //_____________________________________________________________________________
20 AliRsnAnalysisTaskEff::AliRsnAnalysisTaskEff(const char *name) :
21 AliRsnVAnalysisTask(name),
25 fAxes("AliRsnValue", 0),
27 fEventCuts("eventCuts", AliRsnCut::kEvent),
31 // Default constructor.
34 DefineOutput(2, TList::Class());
37 //_____________________________________________________________________________
38 AliRsnAnalysisTaskEff::AliRsnAnalysisTaskEff(const AliRsnAnalysisTaskEff& copy) :
39 AliRsnVAnalysisTask(copy),
41 fStepsMC(copy.fStepsMC),
42 fStepsRec(copy.fStepsRec),
45 fEventCuts(copy.fEventCuts),
53 //_____________________________________________________________________________
54 AliRsnAnalysisTaskEff& AliRsnAnalysisTaskEff::operator=(const AliRsnAnalysisTaskEff& copy)
57 // Assignment operator
60 AliRsnVAnalysisTask::operator=(copy);
63 fStepsMC = copy.fStepsMC;
64 fStepsRec = copy.fStepsRec;
66 fEventCuts = copy.fEventCuts;
71 //_____________________________________________________________________________
72 void AliRsnAnalysisTaskEff::AddDef(TObject* def)
75 // Adds pair definition
80 //_____________________________________________________________________________
81 void AliRsnAnalysisTaskEff::AddAxis(AliRsnValue *axis)
87 Int_t n = fAxes.GetEntries();
88 new (fAxes[n]) AliRsnValue(*axis);
91 //_____________________________________________________________________________
92 void AliRsnAnalysisTaskEff::AddStepMC(TObject *cuts)
95 // Add a step on montecarlo
98 fStepsMC.AddLast(cuts);
101 //_____________________________________________________________________________
102 void AliRsnAnalysisTaskEff::AddStepRec(TObject *cuts)
108 fStepsRec.AddLast(cuts);
111 //_____________________________________________________________________________
112 void AliRsnAnalysisTaskEff::RsnUserCreateOutputObjects()
115 // Creation of output objects.
116 // These are created through the utility methods in the analysis manager,
117 // which produces a list of histograms for each specified set of pairs.
118 // Each of these lists is added to the main list of this task.
121 // get number of steps and axes
123 Int_t nAxes = fAxes.GetEntries();
124 Int_t nSteps = (Int_t)fStepsMC.GetEntries() + (Int_t)fStepsRec.GetEntries();
127 AliError("No steps defined");
131 AliError("No axes defined");
135 // initialize variable list
138 // retrieve number of bins for each axis
139 Int_t *nBins = new Int_t[nAxes];
140 for (iaxis = 0; iaxis < nAxes; iaxis++) {
141 AliRsnValue *fcnAxis = (AliRsnValue*)fAxes.At(iaxis);
142 nBins[iaxis] = fcnAxis->GetArray().GetSize() - 1;
145 // initialize output list
147 fOutList = new TList();
148 fOutList->SetOwner();
150 // create the containers
151 Int_t i, nDef = (Int_t)fDefs.GetEntries();
152 for (i = 0; i < nDef; i++) {
153 // instantiate a new container
154 AliCFContainer *cont = new AliCFContainer(fDefs[i]->GetName(), "", nSteps, nAxes, nBins);
155 // set the bin limits for each axis
156 for (iaxis = 0; iaxis < nAxes; iaxis++) {
157 AliRsnValue *fcnAxis = (AliRsnValue*)fAxes.At(iaxis);
158 cont->SetBinLimits(iaxis, fcnAxis->GetArray().GetArray());
160 // add the container to output list
164 PostData(2, fOutList);
170 //_____________________________________________________________________________
171 void AliRsnAnalysisTaskEff::RsnUserExec(Option_t*)
174 // Execution of the analysis task.
175 // Recovers the input event and processes it with all included pair objects.
176 // In this case, we NEED to have reconstruction and MC, otherwise we cannot do anything.
179 if (fRsnEvent[0].IsESD()) ProcessEventESD();
180 if (fRsnEvent[0].IsAOD()) ProcessEventAOD();
182 PostData(2, fOutList);
185 //_____________________________________________________________________________
186 void AliRsnAnalysisTaskEff::RsnTerminate(Option_t*)
190 // Could be added some monitor histograms here.
194 //______________________________________________________________________________
195 Bool_t AliRsnAnalysisTaskEff::RsnEventProcess()
198 // Customized event pre-processing.
199 // First checks if the current event passes all cuts,
200 // and if it does, updates the informations and then
201 // call the operations which are already defined in the
202 // omonyme function in mother class
205 // initially, an event is expected to be bad
206 fTaskInfo.SetEventUsed(kFALSE);
208 // check the event cuts and update the info data accordingly
209 // events not passing the cuts must be rejected
210 if (!fEventCuts.IsSelected(&fRsnEvent[0])) {
211 fTaskInfo.SetEventUsed(kFALSE);
215 // if we reach this point, cuts were passed;
216 // then additional operations can be done
218 // find leading particle (without any PID/momentum restriction)
219 fRsnEvent[0].SelectLeadingParticle(0);
221 // final return value is positive
222 // but call the mother class method which updates info object
223 fTaskInfo.SetEventUsed(kTRUE);
224 return AliRsnVAnalysisTask::RsnEventProcess();
227 //_____________________________________________________________________________
228 TArrayI AliRsnAnalysisTaskEff::FindTracks(Int_t label, AliVEvent *event)
231 // Loops an event and find all tracks which have a label
232 // equal to that passed as first argument.
235 Int_t i = 0, nfound = 0;
236 Int_t ntracks = event->GetNumberOfTracks();
239 for (i = 0; i < ntracks; i++) {
240 AliVParticle *track = event->GetTrack(i);
241 if (TMath::Abs(track->GetLabel()) != label) continue;
249 //_____________________________________________________________________________
250 Int_t AliRsnAnalysisTaskEff::NGoodSteps()
253 // Tells the maximum step where cuts for the checked objects are passed
256 AliInfo("Must be overloaded in inheriting tasks");
261 //_____________________________________________________________________________
262 void AliRsnAnalysisTaskEff::ProcessEventESD()
265 // Process current event with the definitions of the specified step in MC list
266 // and store results in the container slot defined in second argument.
267 // It is associated with the AliCFContainer with the name of the pair.
270 AliInfo("Must be overloaded in inheriting tasks");
273 //_____________________________________________________________________________
274 void AliRsnAnalysisTaskEff::ProcessEventAOD()
277 // Process current event with the definitions of the specified step in MC list
278 // and store results in the container slot defined in second argument.
279 // It is associated with the AliCFContainer with the name of the pair.
282 AliInfo("Must be overloaded in inheriting tasks");
285 //_____________________________________________________________________________
286 void AliRsnAnalysisTaskEff::FillContainer(Bool_t, TObject*)
289 // Fill the containers
292 AliInfo("Must be overloaded in inheriting tasks");