]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnAnalysisSE.cxx
Bugfix with zero event % alert
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnAnalysisSE.cxx
1 //
2 // Class AliRsnAnalysisSE
3 //
4 // Virtual Class derivated from AliRsnVAnalysisTaskSE 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 "AliESDEvent.h"
13 #include "AliMCEvent.h"
14 #include "AliAODEvent.h"
15
16 #include "AliRsnCutSet.h"
17 #include "AliRsnVATProcessInfo.h"
18 #include "AliRsnAnalysisSE.h"
19
20 ClassImp(AliRsnAnalysisSE)
21
22 //_____________________________________________________________________________
23 AliRsnAnalysisSE::AliRsnAnalysisSE(const char *name,Int_t numOfOutputs,Bool_t useKine) :
24     AliRsnVAnalysisTaskSE(name,numOfOutputs,useKine),
25     fRsnAnalysisManager(),
26     fEventCuts(0x0),
27     fZeroEventPercentWarning(50),
28     fUseZeroEventWarning(kTRUE)
29 {
30 //
31 // Default constructor.
32 //
33
34   AliDebug(AliLog::kDebug+2,"<-");
35   for (Int_t i=0;i<fNumberOfOutputs;i++) {
36     DefineOutput(i+2, TList::Class());
37   }
38   AliDebug(AliLog::kDebug+2,"->");
39 }
40
41 //_____________________________________________________________________________
42 AliRsnAnalysisSE::AliRsnAnalysisSE(const AliRsnAnalysisSE& copy) :
43   AliRsnVAnalysisTaskSE(copy),
44   fRsnAnalysisManager(copy.fRsnAnalysisManager),
45   fEventCuts(copy.fEventCuts),
46   fZeroEventPercentWarning(copy.fZeroEventPercentWarning),
47   fUseZeroEventWarning(copy.fUseZeroEventWarning)
48 {
49 //
50 // Copy constructor.
51 //
52
53   AliDebug(AliLog::kDebug+2,"<-");
54   AliDebug(AliLog::kDebug+2,"->");
55 }
56
57 //_____________________________________________________________________________
58 void AliRsnAnalysisSE::RsnUserCreateOutputObjects()
59 {
60 //
61 // Creation of output objects.
62 // These are created through the utility methods in the analysis manager,
63 // which produces a list of histograms for each specified set of pairs.
64 // Each of these lists is added to the main list of this task.
65 //
66
67   AliDebug(AliLog::kDebug+2,"<-");
68
69   Int_t i;
70   for (i = 1; i < kMaxNumberOfOutputs + 1; i++)
71   {
72     if (i <= fNumberOfOutputs + 1) OpenFile(i);
73     fOutList[i] = new TList();
74     fOutList[i]->SetOwner();
75   }
76
77   for (i = 0; i < fNumberOfOutputs; i++)
78   {
79     fRsnAnalysisManager[i].InitAllPairMgrs(fOutList[i+1]);
80   }
81
82   AliDebug(AliLog::kDebug+2,"->");
83 }
84
85 //_____________________________________________________________________________
86 void AliRsnAnalysisSE::RsnUserExec(Option_t*)
87 {
88 //
89 // Execution of the analysis task.
90 // Recovers the input event and processes it with all included pair objects.
91 //
92
93   AliDebug(AliLog::kDebug+2,"<-");
94   
95   fTaskInfo.SetEventUsed(kFALSE);
96
97   if (fESDEvent) {
98     AliDebug(AliLog::kDebug+1, Form("fESDEvent is %p", fESDEvent));
99     AliDebug(AliLog::kDebug, Form("ESD tracks %d", fESDEvent->GetNumberOfTracks()));
100   }
101   if (fMCEvent) {
102     AliDebug(AliLog::kDebug+1, Form("fMCEvent is %p", fMCEvent));
103     AliDebug(AliLog::kDebug, Form("MC tracks %d", fMCEvent->GetNumberOfTracks()));
104   }
105   if (fAODEventIn) {
106     AliDebug(AliLog::kDebug+1, Form("fAODEventIn is %p", fAODEventIn));
107     AliDebug(AliLog::kDebug, Form("AOD(in) tracks %d", fAODEventIn->GetNumberOfTracks()));
108   }
109   if (fAODEventOut) {
110     AliDebug(AliLog::kDebug+1, Form("fAODEventOut if %p", fAODEventOut));
111     AliDebug(AliLog::kDebug, Form("AOD(out) tracks %d", fAODEventOut->GetNumberOfTracks()));
112   }
113
114   // Removing empty events
115   if (fRsnEvent.GetMultiplicity()<=0) {
116     AliDebug(AliLog::kDebug, "Zero event!!! Skipping ...");
117     fTaskInfo.SetEventUsed(kFALSE);
118     if (fUseZeroEventWarning)
119     {
120       TH1I *hist = (TH1I*)fOutList[0]->FindObject(fTaskInfo.GetEventHistogramName());
121       if (!hist) return;
122       Double_t zeroEventPercent = 0.0;
123       if (hist->Integral() > 1) zeroEventPercent = (Double_t)hist->GetBinContent(1) / hist->Integral() * 100;
124       if ((zeroEventPercent>fZeroEventPercentWarning)&&(fEntry>100))
125         AliWarning(Form("%3.2f%% Events are with zero tracks (CurrentEvent=%d)!!!",zeroEventPercent,fEntry));
126     }
127     return;
128   }
129
130   // if general event cuts are added to the task (recommended)
131   // they are checked here on the RSN event interface and,
132   // if the event does not pass them, it is skipped and ProcessInfo
133   // is updated accordingly
134   if (fEventCuts) {
135     if (!fEventCuts->IsSelected(AliRsnCut::kEvent, &fRsnEvent)) {
136       fTaskInfo.SetEventUsed(kFALSE);
137       return;
138     }
139   }
140
141   // if cuts are passed or not cuts were defined,
142   // update the task info...
143   fTaskInfo.SetEventUsed(kTRUE);
144
145   // the virtual class has already sorted tracks in the PID index
146   // so we need here just to call the execution of analysis
147   for (Int_t i = 0; i < fNumberOfOutputs; i++)
148   {
149     fRsnAnalysisManager[i].ProcessAllPairMgrs(&fRsnPIDIndex, &fRsnEvent);
150     PostData(i+2, fOutList[i+1]);
151   }
152   AliDebug(AliLog::kDebug+2,"->");
153 }
154
155
156 //_____________________________________________________________________________
157 void AliRsnAnalysisSE::RsnTerminate(Option_t*)
158 {
159 //
160 // Termination.
161 // Could be added some monitor histograms here.
162 //
163
164   AliDebug(AliLog::kDebug+2,"<-");
165   AliDebug(AliLog::kDebug+2,"->");
166 }
167
168 //_____________________________________________________________________________
169 AliRsnAnalysisManager* AliRsnAnalysisSE::GetAnalysisManager(Int_t index, TString name)
170 {
171 //
172 // Recovery the analysis manager
173 //
174
175   if (!name.IsNull())
176   {
177     SetAnalysisManagerName(name.Data(), index);
178   }
179
180   return &fRsnAnalysisManager[index];
181 }