2 // *** Class AliRsnVATProcessInfo ***
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.
9 // authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
10 // M. Vala (email: martin.vala@cern.ch)
18 #include "AliRsnEvent.h"
19 #include "AliRsnFunction.h"
20 #include "AliRsnVATProcessInfo.h"
22 ClassImp(AliRsnVATProcessInfo)
24 //______________________________________________________________________________
25 AliRsnVATProcessInfo::AliRsnVATProcessInfo(const char *name) :
29 fEventFunctions("AliRsnFunction", 0),
30 fPrintInfoNumber(1000)
34 // Does nothing more than initialization of data members.
37 AliDebug(AliLog::kDebug + 2, "Entering");
38 AliDebug(AliLog::kDebug + 2, "Exiting");
41 //______________________________________________________________________________
42 AliRsnVATProcessInfo::AliRsnVATProcessInfo(const AliRsnVATProcessInfo& copy) :
45 fEventUsed(copy.fEventUsed),
46 fEventFunctions(copy.fEventFunctions),
47 fPrintInfoNumber(copy.fPrintInfoNumber)
51 // Clones the histogram and copies the values of other data members
54 AliDebug(AliLog::kDebug + 2, "Entering");
56 fHistUsedEvents = (TH1I*)copy.fHistUsedEvents->Clone();
58 AliDebug(AliLog::kDebug + 2, "Exiting");
61 //______________________________________________________________________________
62 AliRsnVATProcessInfo& AliRsnVATProcessInfo::operator=
63 (const AliRsnVATProcessInfo& copy)
66 // Assignment operator.
67 // Clones the histogram and copies the values of other data members.
70 AliDebug(AliLog::kDebug + 2, "Entering");
72 fHistUsedEvents = (TH1I*)copy.fHistUsedEvents->Clone();
73 fEventUsed = copy.fEventUsed;
74 fPrintInfoNumber = copy.fPrintInfoNumber;
75 fEventFunctions = copy.fEventFunctions;
77 AliDebug(AliLog::kDebug + 2, "Exiting");
82 //______________________________________________________________________________
83 AliRsnVATProcessInfo::~AliRsnVATProcessInfo()
87 // Does nothing, since the histogram it creates is usually owned
88 // by another object (TList output of AnalysisTask's), but sets
89 // the data member pointers to NULL.
92 AliDebug(AliLog::kDebug + 2, "Entering");
94 fHistUsedEvents = 0x0;
98 AliDebug(AliLog::kDebug + 2, "Exiting");
101 //______________________________________________________________________________
102 void AliRsnVATProcessInfo::GenerateInfoList(TList *list)
105 // Allocate in memory the histograms created in this class and store them
106 // inside the TList object passed as argument, which usually belongs to
107 // an AnalysisTask object, and represents one of its outputs.
108 // If the histogram was already initialized, it is deleted and recreated.
111 AliDebug(AliLog::kDebug + 2, "Entering");
113 // delete existing allocation of stored objects
114 if (fHistUsedEvents) delete fHistUsedEvents;
116 // create stored objects
117 fHistUsedEvents = new TH1I(GetEventHistogramName(), "Skipped/used events", 2, 0, 2);
119 // ad objects to list
120 list->Add(fHistUsedEvents);
122 // add all other functions
125 AliRsnFunction *fcn = 0;
126 for (i = 0; i < fEventFunctions.GetEntries(); i++) {
127 fcn = (AliRsnFunction*)fEventFunctions.At(i);
130 hName += fcn->GetName();
131 if (fcn->IsUsingTH1()) list->Add(fcn->CreateHistogram(hName.Data(), ""));
132 else list->Add(fcn->CreateHistogramSparse(hName.Data(), ""));
135 AliDebug(AliLog::kDebug + 2, "Exiting");
138 //______________________________________________________________________________
139 void AliRsnVATProcessInfo::FillInfo(AliRsnEvent *event)
142 // This method defines how the information histograms must be filled.
143 // The structure of this class is auto-consistent, but in case of inheritance
144 // this method must be modified accordingly.
145 // Current implementation uses the 'fEventUsed' flag to choose if the event
146 // has been used or not, and increments the corresponding bin in the related
147 // histogram (bin '0' = skipped, bin '1' = used).
150 fHistUsedEvents->Fill(fEventUsed);
152 if (!fEventUsed) return;
155 AliRsnFunction *fcn = 0;
156 for (i = 0; i < fEventFunctions.GetEntries(); i++) {
157 fcn = (AliRsnFunction*)fEventFunctions.At(i);
162 //______________________________________________________________________________
163 void AliRsnVATProcessInfo::PrintInfo(const Long64_t &num)
166 // This method is used in some cases
167 // to inform about number of events processed
170 if ((num + 1) % fPrintInfoNumber == 0) AliInfo(Form("Events processed %lld", num + 1));
173 //______________________________________________________________________________
174 Long64_t AliRsnVATProcessInfo::GetNumerOfEventsProcessed()
177 // returns number of events from histogram
180 if (fHistUsedEvents) return (Long64_t)fHistUsedEvents->GetEntries();
184 //_____________________________________________________________________________
185 void AliRsnVATProcessInfo::AddEventFunction(AliRsnFunction * fcn)
188 // Adds a new computing function
191 AliDebug(AliLog::kDebug + 2, "<-");
193 fEventFunctions.Print();
194 Int_t size = fEventFunctions.GetEntries();
195 new(fEventFunctions[size]) AliRsnFunction(*fcn);
197 AliDebug(AliLog::kDebug + 2, "->");