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