]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnAnalysisTask.cxx
e90eceec4f411ca6a8e59939292782723c75d6a5
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnAnalysisTask.cxx
1 //
2 // Class AliRsnAnalysisTask
3 //
4 // Virtual Class derivated from AliRsnVAnalysisTask which will be base class
5 // for all RSN SE tasks
6 //
7 // authors: Martin Vala (martin.vala@cern.ch)
8 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
9 //
10
11 #include <Riostream.h>
12 #include <TList.h>
13 #include "AliESDEvent.h"
14 #include "AliMCEvent.h"
15 #include "AliAODEvent.h"
16
17 #include "AliRsnCutSet.h"
18 #include "AliRsnVATProcessInfo.h"
19 #include "AliRsnAnalysisTask.h"
20
21 ClassImp(AliRsnAnalysisTask)
22
23 //_____________________________________________________________________________
24 AliRsnAnalysisTask::AliRsnAnalysisTask(const char *name, Bool_t useKine) :
25    AliRsnVAnalysisTask(name, useKine),
26    fRsnAnalysisManager(),
27    fEventCuts("eventCuts", AliRsnCut::kEvent),
28    fOutList(0x0),
29    fZeroEventPercentWarning(100),
30    fUseZeroEventWarning(kTRUE)
31 {
32 //
33 // Default constructor.
34 // Defines another output slot for histograms/ntuples
35 //
36
37    DefineOutput(2, TList::Class());
38 }
39
40 //_____________________________________________________________________________
41 AliRsnAnalysisTask::AliRsnAnalysisTask(const AliRsnAnalysisTask& copy) :
42    AliRsnVAnalysisTask(copy),
43    fRsnAnalysisManager(copy.fRsnAnalysisManager),
44    fEventCuts(copy.fEventCuts),
45    fOutList(0x0),
46    fZeroEventPercentWarning(copy.fZeroEventPercentWarning),
47    fUseZeroEventWarning(copy.fUseZeroEventWarning)
48 {
49 //
50 // Copy constructor.
51 //
52 }
53
54 //_____________________________________________________________________________
55 AliRsnAnalysisTask& AliRsnAnalysisTask::operator=(const AliRsnAnalysisTask& copy)
56 {
57 //
58 // Assigment operator.
59 //
60
61    AliRsnVAnalysisTask::operator=(copy);
62
63    fRsnAnalysisManager = copy.fRsnAnalysisManager;
64    fEventCuts = copy.fEventCuts;
65    if (fOutList) fOutList->Clear();
66    fZeroEventPercentWarning = copy.fZeroEventPercentWarning;
67    fUseZeroEventWarning = copy.fUseZeroEventWarning;
68
69    return (*this);
70 }
71
72 //_____________________________________________________________________________
73 void AliRsnAnalysisTask::RsnUserCreateOutputObjects()
74 {
75 //
76 // Creation of output objects.
77 // These are created through the utility methods in the analysis manager,
78 // which asks all the AliRsnPair objects to initialize their output which
79 // is then linked to the TList data member of this, which will contain all the output.
80 //
81
82    if (!fOutList) fOutList = new TList;
83    fOutList->Clear();
84
85    fRsnAnalysisManager.InitAllPairs(fOutList);
86
87    PostData(2, fOutList);
88 }
89
90 //_____________________________________________________________________________
91 void AliRsnAnalysisTask::RsnUserExec(Option_t*)
92 {
93 //
94 // Execution of the analysis task.
95 // Recovers the input event and processes it with all included pair objects,
96 // using 'reconstructed' or 'MonteCarlo' functions depending on MC-only flag.
97 //
98    if (IsMixing()) return;
99
100    if (fMCOnly) {
101       fRsnAnalysisManager.ProcessAllMonitorsMC();
102       fRsnAnalysisManager.ProcessAllPairsMC();
103    }
104    else {
105       fRsnAnalysisManager.ProcessAllMonitors();
106       fRsnAnalysisManager.ProcessAllPairs();
107    }
108
109    PostData(2, fOutList);
110 }
111
112 void AliRsnAnalysisTask::RsnUserExecMix(Option_t* /*opt*/)
113 {
114    if (!IsMixing()) return;
115    AliDebug(AliLog::kDebug, Form("RSN Mixing %lld %d [%lld,%lld] %d", fMixedEH->CurrentEntry(), fMixedEH->NumberMixed(), fMixedEH->CurrentEntryMain(), fMixedEH->CurrentEntryMix(), fMixedEH->CurrentBinIndex()));
116
117    // the virtual class has already sorted tracks in the PID index
118    // so we need here just to call the execution of analysis
119    if (!fMCOnly)
120       fRsnAnalysisManager.ProcessAllPairs();
121    else
122       fRsnAnalysisManager.ProcessAllPairsMC();
123 }
124
125 //_____________________________________________________________________________
126 void AliRsnAnalysisTask::RsnTerminate(Option_t*)
127 {
128 //
129 // Termination.
130 // Could be added some monitor histograms here.
131 //
132 }
133
134 //______________________________________________________________________________
135 Bool_t AliRsnAnalysisTask::EventProcess()
136 {
137 //
138 // Customized event pre-processing.
139 // First checks if the current event passes all cuts,
140 // and if it does, updates the informations and then
141 // call the operations which are already defined in the
142 // omonyme function in mother class
143 //
144
145    // initially, an event is expected to be bad
146    fTaskInfo.SetEventUsed(kFALSE);
147
148    if (!AliRsnVAnalysisTask::EventProcess()) return kFALSE;
149
150    // check #1: number of tracks in event (reject empty events)
151    Int_t    ntracks = fRsnEvent[0].GetMultiplicity();
152    Double_t zeroEventPercent = 0.0;
153    if (ntracks < 1) {
154       // if using the checker for amount of empty events, update it
155       if (fUseZeroEventWarning) {
156          TH1I *hist = (TH1I*)fInfoList->FindObject(fTaskInfo.GetEventHistogramName());
157          if (hist) {
158             if (hist->Integral() > 1) zeroEventPercent = (Double_t)hist->GetBinContent(1) / hist->Integral() * 100;
159             if ((zeroEventPercent > fZeroEventPercentWarning) && (fEntry > 100))
160                AliWarning(Form("%3.2f%% Events are with zero tracks (CurrentEvent=%d)!!!", zeroEventPercent, fEntry));
161          }
162       }
163
164       // empty events are rejected by default
165       fTaskInfo.SetEventUsed(kFALSE);
166       AliDebug(AliLog::kDebug, "Empty event. Skipping...");
167       return kFALSE;
168    }
169
170    // check the event cuts and update the info data accordingly
171    // events not passing the cuts must be rejected
172    if (!fEventCuts.IsSelected(&fRsnEvent[0])) {
173       fTaskInfo.SetEventUsed(kFALSE);
174       return kFALSE;
175    }
176
177    // if we reach this point, cuts were passed;
178    // then additional operations can be done
179
180    // find leading particle (without any PID/momentum restriction)
181    fRsnEvent[0].SelectLeadingParticle(0);
182
183    // final return value is positive
184    // but call the mother class method which updates info object
185    fTaskInfo.SetEventUsed(kTRUE);
186    return kTRUE;
187 }