]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnMiniAnalysisTask.h
coverity bug fix
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnMiniAnalysisTask.h
CommitLineData
03d23846 1#ifndef ALIRSNMINIANALYSISTASK_H
2#define ALIRSNMINIANALYSISTASK_H
3
4//
5// Analysis task for 'mini' sub-package
6// Contains all definitions needed for running an analysis:
7// -- global event cut
8// -- a list of track cuts (any number)
9// -- definitions of output histograms
10// -- values to be computed.
11//
12
13#include "AliAnalysisTaskSE.h"
14
15#include <TString.h>
16#include <TClonesArray.h>
17
18#include "AliRsnEvent.h"
19#include "AliRsnMiniValue.h"
20#include "AliRsnMiniOutput.h"
21
22class TList;
23class AliTriggerAnalysis;
24class AliRsnMiniEvent;
25class AliRsnCutSet;
26
27class AliRsnMiniAnalysisTask : public AliAnalysisTaskSE {
28
29public:
30
31 AliRsnMiniAnalysisTask();
32 AliRsnMiniAnalysisTask(const char *name);
33 AliRsnMiniAnalysisTask(const AliRsnMiniAnalysisTask &copy);
34 AliRsnMiniAnalysisTask& operator=(const AliRsnMiniAnalysisTask &copy);
35 virtual ~AliRsnMiniAnalysisTask();
36
37 virtual void UserCreateOutputObjects();
38 virtual void UserExec(Option_t *option);
39 virtual void Terminate(Option_t *);
40 virtual void FinishTaskOutput();
41
42 void SetNMix(Int_t nmix) {fNMix = nmix;}
43 void SetMaxDiffMult (Double_t val) {fMaxDiffMult = val;}
44 void SetMaxDiffVz (Double_t val) {fMaxDiffVz = val;}
45 void SetMaxDiffAngle(Double_t val) {fMaxDiffAngle = val;}
46 void SetEventCuts(AliRsnCutSet *cuts) {fEventCuts = cuts;}
47 void UseCentrality(const char *type) {fUseCentrality = kTRUE; fCentralityType = type; fCentralityType.ToUpper();}
48 void UseMultiplicity(const char *type) {fUseCentrality = kFALSE; fCentralityType = type; fCentralityType.ToUpper();}
49 Int_t AddTrackCuts(AliRsnCutSet *cuts);
50
51 TClonesArray *Outputs() {return &fHistograms;}
52 TClonesArray *Values() {return &fValues;}
53
54 Int_t ValueID(AliRsnMiniValue::EType type, Bool_t useMC = kFALSE);
55 Int_t CreateValue(AliRsnMiniValue::EType type, Bool_t useMC = kFALSE);
56 AliRsnMiniOutput *CreateOutput(const char *name, AliRsnMiniOutput::EOutputType type, AliRsnMiniOutput::EComputation src);
57 AliRsnMiniOutput *CreateOutput(const char *name, const char *outType, const char *compType);
58
59 void ProcessEvents(AliRsnMiniEvent *evMain, AliRsnMiniEvent *evMix = 0x0);
60
61private:
62
63 void InitHistograms(TClonesArray *array);
64 Char_t CheckCurrentEvent();
65 Double_t ComputeCentrality(Bool_t isESD);
66 void FillTrueMotherESD(AliRsnMiniEvent *event);
67 void FillTrueMotherAOD(AliRsnMiniEvent *event);
68 void StoreTrueMother(AliRsnMiniPair *pair, AliRsnMiniEvent *event);
69
70 Int_t fEvNum; //! absolute event counter
71 Bool_t fUseCentrality; // if true, use centrality for event, otherwise use multiplicity
72 TString fCentralityType; // definition used to choose what centrality or multiplicity to use
73
74 Int_t fNMix; // mixing --> required number of mixes
75 Double_t fMaxDiffMult; // mixing --> max difference in multiplicity
76 Double_t fMaxDiffVz; // mixing --> max difference in Vz of prim vert
77 Double_t fMaxDiffAngle; // mixing --> max difference in reaction plane angle
78
79 TList *fOutput; // output list
80 TClonesArray fHistograms; // list of histogram definitions
81 TClonesArray fValues; // list of values to be computed
82 TH1F *fHEventStat; // histogram of event statistics
83
84 AliRsnCutSet *fEventCuts; // cuts on events
85 TObjArray fTrackCuts; // list of single track cuts
86 AliRsnEvent fRsnEvent; //! interface object to the event
87 TTree *fTempTree; //! tree to contain converted events (temporary)
88 TArrayI fNMixed; //! array to keep trace of how many times an event was mixed
89 AliTriggerAnalysis *fTriggerAna; //! trigger analysis
90
91 ClassDef(AliRsnMiniAnalysisTask, 1); // AliRsnMiniAnalysisTask
92};
93
94inline Int_t AliRsnMiniAnalysisTask::CreateValue(AliRsnMiniValue::EType type, Bool_t useMC)
95{
96//
97// Create a new value in the task,
98// and returns its ID, which is needed for setting up histograms.
99// If that value was already initialized, returns its ID and does not recreate it.
100//
101
102 Int_t valID = ValueID(type, useMC);
103 if (valID >= 0 && valID < fValues.GetEntries()) {
104 AliInfo(Form("Value '%s' is already created in slot #%d", AliRsnMiniValue::ValueName(type, useMC), valID));
105 } else {
106 valID = fValues.GetEntries();
107 AliInfo(Form("Creating value '%s' in slot #%d", AliRsnMiniValue::ValueName(type, useMC), valID));
108 new (fValues[valID]) AliRsnMiniValue(type, useMC);
109 }
110
111 return valID;
112}
113
114inline Int_t AliRsnMiniAnalysisTask::ValueID(AliRsnMiniValue::EType type, Bool_t useMC)
115{
116//
117// Searches if a value computation is initialized
118//
119
120 const char *name = AliRsnMiniValue::ValueName(type, useMC);
121 TObject *obj = fValues.FindObject(name);
122 if (obj)
123 return fValues.IndexOf(obj);
124 else
125 return -1;
126}
127
128inline AliRsnMiniOutput* AliRsnMiniAnalysisTask::CreateOutput
129(const char *name, AliRsnMiniOutput::EOutputType type, AliRsnMiniOutput::EComputation src)
130{
131//
132// Create a new histogram definition in the task,
133// which is then returned to the user for its configuration
134//
135
136 Int_t n = fHistograms.GetEntries();
137 AliRsnMiniOutput *newDef = new (fHistograms[n]) AliRsnMiniOutput(name, type, src);
138
139 return newDef;
140}
141
142inline AliRsnMiniOutput* AliRsnMiniAnalysisTask::CreateOutput
143(const char *name, const char *outType, const char *compType)
144{
145//
146// Create a new histogram definition in the task,
147// which is then returned to the user for its configuration
148//
149
150 Int_t n = fHistograms.GetEntries();
151 AliRsnMiniOutput *newDef = new (fHistograms[n]) AliRsnMiniOutput(name, outType, compType);
152
153 return newDef;
154}
155#endif