]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnVATProcessInfo.cxx
Added an information histogram on *real* number of events contributing to fill each...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnVATProcessInfo.cxx
1 //
2 // *** Class AliRsnVATProcessInfo ***
3 //
4 // Virtual class which makes computations at the event level,
5 // in order to return a list of histograms useful to have a look
6 // of the characteristics of used events.
7 // If can be inherited and customized for the needs of the analysis.
8 //
9 // authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
10 //          M. Vala (email: martin.vala@cern.ch)
11 //
12
13 #include <TList.h>
14 #include <TH1.h>
15
16 #include "AliLog.h"
17
18 #include "AliRsnVATProcessInfo.h"
19
20 ClassImp(AliRsnVATProcessInfo)
21
22 //______________________________________________________________________________
23 AliRsnVATProcessInfo::AliRsnVATProcessInfo(const char *name) :
24   TNamed(name,name),
25   fHistUsedEvents(0x0),
26   fEventUsed(kFALSE),
27   fPrintInfoNumber(1000)
28 {
29 //
30 // Constructor.
31 // Does nothing more than initialization of data members.
32 //
33
34   AliDebug(AliLog::kDebug+2, "Entering");
35   AliDebug(AliLog::kDebug+2, "Exiting");
36 }
37
38 //______________________________________________________________________________
39 AliRsnVATProcessInfo::AliRsnVATProcessInfo(const AliRsnVATProcessInfo& copy) :
40   TNamed(copy),
41   fHistUsedEvents(0x0),
42   fEventUsed(copy.fEventUsed),
43   fPrintInfoNumber(copy.fPrintInfoNumber)
44 {
45 //
46 // Copy constructor.
47 // Clones the histogram and copies the values of other data members
48 //
49
50   AliDebug(AliLog::kDebug+2, "Entering");
51   
52   fHistUsedEvents  = (TH1I*)copy.fHistUsedEvents->Clone();
53   
54   AliDebug(AliLog::kDebug+2, "Exiting");
55 }
56
57 //______________________________________________________________________________
58 AliRsnVATProcessInfo& AliRsnVATProcessInfo::operator= 
59 (const AliRsnVATProcessInfo& copy)
60 {
61 //
62 // Assignment operator.
63 // Clones the histogram and copies the values of other data members.
64 //
65
66   AliDebug(AliLog::kDebug+2, "Entering");
67
68   fHistUsedEvents  = (TH1I*)copy.fHistUsedEvents->Clone();
69   fEventUsed       = copy.fEventUsed;
70   fPrintInfoNumber = copy.fPrintInfoNumber;
71   
72   AliDebug(AliLog::kDebug+2, "Exiting");
73   
74   return (*this);
75 }
76
77 //______________________________________________________________________________
78 AliRsnVATProcessInfo::~AliRsnVATProcessInfo()
79 {
80 //
81 // Destructor.
82 // Does nothing, since the histogram it creates is usually owned
83 // by another object (TList output of AnalysisTask's), but sets
84 // the data member pointers to NULL.
85 //
86
87   AliDebug(AliLog::kDebug+2, "Entering");
88   
89   fHistUsedEvents  = 0x0;
90   fEventUsed       = 0;
91   fPrintInfoNumber = 0;
92   
93   AliDebug(AliLog::kDebug+2, "Exiting");
94 }
95
96 //______________________________________________________________________________
97 void AliRsnVATProcessInfo::GenerateInfoList(TList *list)
98 {
99 //
100 // Allocate in memory the histograms created in this class and store them
101 // inside the TList object passed as argument, which usually belongs to 
102 // an AnalysisTask object, and represents one of its outputs.
103 // If the histogram was already initialized, it is deleted and recreated.
104 //
105
106   AliDebug(AliLog::kDebug+2, "Entering");
107
108   // delete existing allocation of stored objects
109   if (fHistUsedEvents) delete fHistUsedEvents;
110   
111   // create stored objects
112   fHistUsedEvents = new TH1I(GetEventHistogramName(), "Skipped/used events", 3, 0, 3);
113
114   // ad objects to list
115   list->Add(fHistUsedEvents);
116
117   AliDebug(AliLog::kDebug+2, "Exiting");
118 }
119
120 //______________________________________________________________________________
121 void AliRsnVATProcessInfo::FillInfo()
122 {
123 //
124 // This method defines how the information histograms must be filled.
125 // The structure of this class is auto-consistent, but in case of inheritance
126 // this method must be modified accordingly.
127 // Current implementation uses the 'fEventUsed' flag to choose if the event
128 // has been used or not, and increments the corresponding bin in the related
129 // histogram (bin '0' = skipped, bin '1' = used).
130 //
131
132   fHistUsedEvents->Fill(fEventUsed);
133 }
134
135 //______________________________________________________________________________
136 void AliRsnVATProcessInfo::PrintInfo(const Long64_t &num)
137 {
138 //
139 // This method is used in some cases
140 // to inform about number of events processed
141 //
142
143   if ((num+1) % fPrintInfoNumber == 0) AliInfo(Form("Events processed %lld", num+1));
144 }
145
146 //______________________________________________________________________________
147 Long64_t AliRsnVATProcessInfo::GetNumerOfEventsProcessed()
148 {
149 //
150 // returns number of events from histogram
151 //
152
153   if (fHistUsedEvents) return fHistUsedEvents->Integral();
154   return 0;
155 }