2 // Class AliRsnAnalysisTask
4 // Virtual Class derivated from AliRsnVAnalysisTask which will be base class
5 // for all RSN SE tasks
7 // authors: Martin Vala (martin.vala@cern.ch)
8 // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
11 #include <Riostream.h>
15 #include "AliESDEvent.h"
16 #include "AliMCEvent.h"
17 #include "AliAODEvent.h"
19 #include "AliRsnCutSet.h"
20 #include "AliRsnVATProcessInfo.h"
21 #include "AliRsnAnalysisTask.h"
23 ClassImp(AliRsnAnalysisTask)
25 //_____________________________________________________________________________
26 AliRsnAnalysisTask::AliRsnAnalysisTask(const char *name, Bool_t useKine) :
27 AliRsnVAnalysisTask(name, useKine),
28 fRsnAnalysisManager(),
29 fEventCuts("eventCuts", AliRsnCut::kEvent),
31 fZeroEventPercentWarning(100),
32 fUseZeroEventWarning(kTRUE)
35 // Default constructor.
36 // Defines another output slot for histograms/ntuples
39 DefineOutput(2, TList::Class());
42 //_____________________________________________________________________________
43 AliRsnAnalysisTask::AliRsnAnalysisTask(const AliRsnAnalysisTask& copy) :
44 AliRsnVAnalysisTask(copy),
45 fRsnAnalysisManager(copy.fRsnAnalysisManager),
46 fEventCuts(copy.fEventCuts),
48 fZeroEventPercentWarning(copy.fZeroEventPercentWarning),
49 fUseZeroEventWarning(copy.fUseZeroEventWarning)
56 //_____________________________________________________________________________
57 AliRsnAnalysisTask& AliRsnAnalysisTask::operator=(const AliRsnAnalysisTask& copy)
60 // Assigment operator.
63 AliRsnVAnalysisTask::operator=(copy);
65 fRsnAnalysisManager = copy.fRsnAnalysisManager;
66 fEventCuts = copy.fEventCuts;
67 if (fOutList) fOutList->Clear();
68 fZeroEventPercentWarning = copy.fZeroEventPercentWarning;
69 fUseZeroEventWarning = copy.fUseZeroEventWarning;
74 //_____________________________________________________________________________
75 void AliRsnAnalysisTask::RsnUserCreateOutputObjects()
78 // Creation of output objects.
79 // These are created through the utility methods in the analysis manager,
80 // which asks all the AliRsnPair objects to initialize their output which
81 // is then linked to the TList data member of this, which will contain all the output.
84 // initialize the list
85 if (!fOutList) fOutList = new TList;
87 fOutList->SetOwner(kTRUE);
89 // initialize all pairs
90 fRsnAnalysisManager.InitAllPairs(fOutList);
92 PostData(2, fOutList);
95 //_____________________________________________________________________________
96 void AliRsnAnalysisTask::RsnUserExec(Option_t*)
99 // Execution of the analysis task.
100 // Recovers the input event and processes it with all included pair objects,
101 // using 'reconstructed' or 'MonteCarlo' functions depending on MC-only flag.
104 if (IsMixing()) return;
106 fRsnAnalysisManager.ProcessAll(&fRsnEvent[0], 0x0, fMCOnly);
108 PostData(2, fOutList);
111 //_____________________________________________________________________________
112 void AliRsnAnalysisTask::RsnUserExecMix(Option_t* /*opt*/)
115 // Execution of the analysis task with event mixing.
116 // Recovers the input event and processes it with all included pair objects,
117 // using 'reconstructed' or 'MonteCarlo' functions depending on MC-only flag.
120 if (!IsMixing()) return;
121 AliDebug(AliLog::kDebug, Form("RSN Mixing %lld %d [%lld,%lld] %d", fMixedEH->CurrentEntry(), fMixedEH->NumberMixed(), fMixedEH->CurrentEntryMain(), fMixedEH->CurrentEntryMix(), fMixedEH->CurrentBinIndex()));
123 // the virtual class has already sorted tracks in the PID index
124 // so we need here just to call the execution of analysis
125 fRsnAnalysisManager.ProcessAll(&fRsnEvent[0], &fRsnEvent[1], fMCOnly);
128 //_____________________________________________________________________________
129 void AliRsnAnalysisTask::RsnTerminate(Option_t*)
133 // Could be added some monitor histograms here.
137 //______________________________________________________________________________
138 Bool_t AliRsnAnalysisTask::RsnEventProcess()
141 // Customized event pre-processing.
142 // First checks if the current event passes all cuts,
143 // and if it does, updates the informations and then
144 // call the operations which are already defined in the
145 // omonyme function in mother class
148 // initially, an event is expected to be bad
149 fTaskInfo.SetEventUsed(kFALSE);
151 if (!AliRsnVAnalysisTask::RsnEventProcess()) return kFALSE;
153 // check #1: number of tracks in event (reject empty events)
154 Int_t ntracks = fRsnEvent[0].GetMultiplicityFromTracks();
155 Double_t zeroEventPercent = 0.0;
157 // if using the checker for amount of empty events, update it
158 if (fUseZeroEventWarning) {
159 TH1I *hist = (TH1I*)fInfoList->FindObject(fTaskInfo.GetEventHistogramName());
161 if (hist->Integral() > 1) zeroEventPercent = (Double_t)hist->GetBinContent(1) / hist->Integral() * 100;
162 if ((zeroEventPercent > fZeroEventPercentWarning) && (fEntry > 100))
163 AliWarning(Form("%3.2f%% Events are with zero tracks (CurrentEvent=%d)!!!", zeroEventPercent, fEntry));
167 // empty events are rejected by default
168 fTaskInfo.SetEventUsed(kFALSE);
169 AliDebug(AliLog::kDebug, "Empty event. Skipping...");
173 // check the event cuts and update the info data accordingly
174 // events not passing the cuts must be rejected
175 if (!fEventCuts.IsSelected(&fRsnEvent[0])) {
176 fTaskInfo.SetEventUsed(kFALSE);
180 // if we reach this point, cuts were passed;
181 // then additional operations can be done
183 // find leading particle (without any PID/momentum restriction)
184 fRsnEvent[0].SelectLeadingParticle(0);
186 // final return value is positive
187 // but call the mother class method which updates info object
188 fTaskInfo.SetEventUsed(kTRUE);