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 "AliRsnFunction.h"
19 #include "AliRsnVATProcessInfo.h"
21 ClassImp(AliRsnVATProcessInfo)
23 //______________________________________________________________________________
24 AliRsnVATProcessInfo::AliRsnVATProcessInfo(const char *name) :
28 fEventFunctions("AliRsnFunction", 0),
29 fPrintInfoNumber(1000)
33 // Does nothing more than initialization of data members.
36 AliDebug(AliLog::kDebug+2, "Entering");
37 AliDebug(AliLog::kDebug+2, "Exiting");
40 //______________________________________________________________________________
41 AliRsnVATProcessInfo::AliRsnVATProcessInfo(const AliRsnVATProcessInfo& copy) :
44 fEventUsed(copy.fEventUsed),
45 fEventFunctions(copy.fEventFunctions),
46 fPrintInfoNumber(copy.fPrintInfoNumber)
50 // Clones the histogram and copies the values of other data members
53 AliDebug(AliLog::kDebug+2, "Entering");
55 fHistUsedEvents = (TH1I*)copy.fHistUsedEvents->Clone();
57 AliDebug(AliLog::kDebug+2, "Exiting");
60 //______________________________________________________________________________
61 AliRsnVATProcessInfo& AliRsnVATProcessInfo::operator=
62 (const AliRsnVATProcessInfo& copy)
65 // Assignment operator.
66 // Clones the histogram and copies the values of other data members.
69 AliDebug(AliLog::kDebug+2, "Entering");
71 fHistUsedEvents = (TH1I*)copy.fHistUsedEvents->Clone();
72 fEventUsed = copy.fEventUsed;
73 fPrintInfoNumber = copy.fPrintInfoNumber;
74 fEventFunctions = copy.fEventFunctions;
76 AliDebug(AliLog::kDebug+2, "Exiting");
81 //______________________________________________________________________________
82 AliRsnVATProcessInfo::~AliRsnVATProcessInfo()
86 // Does nothing, since the histogram it creates is usually owned
87 // by another object (TList output of AnalysisTask's), but sets
88 // the data member pointers to NULL.
91 AliDebug(AliLog::kDebug+2, "Entering");
93 fHistUsedEvents = 0x0;
97 AliDebug(AliLog::kDebug+2, "Exiting");
100 //______________________________________________________________________________
101 void AliRsnVATProcessInfo::GenerateInfoList(TList *list)
104 // Allocate in memory the histograms created in this class and store them
105 // inside the TList object passed as argument, which usually belongs to
106 // an AnalysisTask object, and represents one of its outputs.
107 // If the histogram was already initialized, it is deleted and recreated.
110 AliDebug(AliLog::kDebug+2, "Entering");
112 // delete existing allocation of stored objects
113 if (fHistUsedEvents) delete fHistUsedEvents;
115 // create stored objects
116 fHistUsedEvents = new TH1I(GetEventHistogramName(), "Skipped/used events", 3, 0, 3);
118 // ad objects to list
119 list->Add(fHistUsedEvents);
121 // add all other functions
124 AliRsnFunction *fcn = 0;
125 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()
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++)
158 fcn = (AliRsnFunction*)fEventFunctions.At(i);
163 //______________________________________________________________________________
164 void AliRsnVATProcessInfo::PrintInfo(const Long64_t &num)
167 // This method is used in some cases
168 // to inform about number of events processed
171 if ((num+1) % fPrintInfoNumber == 0) AliInfo(Form("Events processed %lld", num+1));
174 //______________________________________________________________________________
175 Long64_t AliRsnVATProcessInfo::GetNumerOfEventsProcessed()
178 // returns number of events from histogram
181 if (fHistUsedEvents) return fHistUsedEvents->Integral();
185 //_____________________________________________________________________________
186 void AliRsnVATProcessInfo::AddEventFunction(AliRsnFunction * fcn)
189 // Adds a new computing function
192 AliDebug(AliLog::kDebug+2,"<-");
194 fEventFunctions.Print();
195 Int_t size = fEventFunctions.GetEntries();
196 new(fEventFunctions[size]) AliRsnFunction(*fcn);
198 AliDebug(AliLog::kDebug+2,"->");