A better way to specify the Nch axis for the MultDists task.
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliForwardMultDists.h
CommitLineData
bfab35d9 1#ifndef ALIFORWARDMULTDIST_H
2#define ALIFORWARDMULTDIST_H
3#include <AliAnalysisTaskSE.h>
4#include <TList.h>
5#include <TString.h>
6class TH1;
7class TH2;
8class AliAODForwardMult;
9
10/**
11 * Class to make raw @f$P(N_{ch})@f$ distributions
12 *
13 */
14class AliForwardMultDists : public AliAnalysisTaskSE
15{
16public:
17 enum {
18 kInvalidEta = 999
19 };
281a2bf8 20 enum {
21 kAnalysis = 1,
22 kMC = 2,
23 kTrigger = 3,
24 kVertex = 4,
25 kTriggerVertex = 5
26 };
52b36573 27 /**
28 * Structure to define @f$\eta@f$ bins with an @f$ N_{ch}@f$ axis
29 *
30 */
31 struct BinSpec
32 {
33 /**
34 * Constructor
35 *
36 * @param etaMin Low cut on @f$\eta@f$
37 * @param etaMax High cut on @f$\eta@f$
38 * @param nchLow Lowest @f$ N_{ch}@f$ (e.g., -0.5);
39 */
40 BinSpec(Double_t etaMin, Double_t etaMax, Double_t nchLow);
41 /**
42 * Push @a n bins of with @a d in @f$ N_{ch}@f$ onto the axis
43 *
44 * If only a single push is done, then we will get an axis of
45 * equally sized bins (@a d) from @f$ l@f$ edge to @f$ nd+low@f$ -
46 * e.g., if one only does
47 *
48 * @code
49 * BinSpec b(e1, e2, -.5);
50 * b.Push(10, 1);
51 * @endcode
52 *
53 * One ends up with 10 bins from -0.5 to 9.5.
54 *
55 * @param n Number of bins to push
56 * @param d Bin width of each of the bins
57 */
58 void Push(UShort_t n, Double_t d);
59 /**
60 * Get the axis computed from the setup using Push
61 *
62 * @return Reference to the axis
63 */
64 const TAxis& Axis() const;
65 Double_t fEtaMin;
66 Double_t fEtaMax;
67 Double_t fLow;
68 TArrayI fN;
69 TArrayD fD;
70 mutable TAxis fAxis;
71 };
72
bfab35d9 73 /**
74 * Default constructor
75 */
76 AliForwardMultDists();
77 /**
78 * User constructor
79 *
80 * @param name Name of the task
81 */
82 AliForwardMultDists(const char* name);
83 /**
84 * Copy constructor
85 *
86 * @param o object to copy fron
87 */
88 AliForwardMultDists(const AliForwardMultDists& o);
89 /**
90 * Assignment operator
91 *
92 * @param o object to assign from
93 *
94 * @return Reference to this object
95 */
96 AliForwardMultDists& operator=(const AliForwardMultDists& o);
97 /**
98 * Destructor
99 */
100 virtual ~AliForwardMultDists() {}
101 /**
102 * Create output objects - called at start of job in slave
103 *
104 */
105 void UserCreateOutputObjects();
106 /**
107 * Analyse a single event
108 *
109 * @param option Not used
110 */
111 void UserExec(Option_t* option="");
112 /**
113 * Called at the end of the final processing of the job on the
114 * full data set (merged data)
115 *
116 *
117 * @param option Not used
118 */
119 void Terminate(Option_t* option="");
120 /**
121 * Set-up internal structures on first seen event
122 *
123 * @param hist Basic histogram template from AOD object
124 */
125 void SetupForData(const TH2& hist, Bool_t useMC);
126 void StoreInformation(const AliAODForwardMult* forward);
127 /**
128 * Project a 2D histogram into a 1D histogram taking care to use
129 * either the @f$\phi2f$ acceptance stored in the overflow bins, or
130 * the @f$\eta@f$ coverage stored in the underflow bins.
131 *
132 * @param input 2D histogram to project
133 * @param cache 1D histogram to project into
134 * @param usePhiAcc If true, use the @f$\phi2f$ acceptance stored in
135 * the overflow bins, or if false the @f$\eta@f$ coverage stored in
136 * the underflow bins.
137 */
138 static void ProjectX(const TH2& input, TH1& cache, Bool_t usePhiAcc=true);
139 /**
140 * Project on @f$\eta@f$ axis. If any of the pointers passed is
141 * zero, do nothing.
142 *
143 * @param input
144 * @param cache
145 */
146 static void ProjectX(const TH2* input, TH1* cache);
52b36573 147 /**
148 * Add an @f$\eta@f$ bin
149 *
150 * @param spec Bin specification
151 */
152 void AddBin(const BinSpec& spec);
bfab35d9 153 /**
154 * Add an @f$\eta@f$ bin
155 *
156 * @param etaLow Low cut on @f$\eta@f$
157 * @param etaMax High cut on @f$\eta@f$
52b36573 158 * @param nAxis Axis to use for measured @f$ N_{ch}@f$
bfab35d9 159 */
52b36573 160 void AddBin(Double_t etaLow, Double_t etaMax, const TAxis& nAxis);
bfab35d9 161 /**
52b36573 162 * Add an @f$\eta@f$ bin
bfab35d9 163 *
52b36573 164 * @param etaLow Low cut on @f$\eta@f$
165 * @param etaMax High cut on @f$\eta@f$
166 * @param nMax Maximum @f$ N_{ch}@f$
167 * @param nDiv Number of subdivisions per @f$ N_{ch}@f$
bfab35d9 168 */
52b36573 169 void AddBin(Double_t etaLow, Double_t etaMax, UShort_t nMax, UShort_t nDiv);
170 /**
bfab35d9 171 * Set the range of valid interaction points
172 *
173 * @param z1 Least Z coordinate
174 * @param z2 Largest Z coordinate
175 */
176 void SetIpZRange(Double_t z1, Double_t z2) { fMinIpZ = z1; fMaxIpZ = z2; }
177 /**
178 * Set the trigger mask
179 *
180 * @param mask Mask
181 */
182 void SetTriggerMask(UInt_t mask) { fTriggerMask = mask; }
183 /**
184 * Set the trigger mask
185 *
186 * @param mask Mask
187 */
188 void SetTriggerMask(const char* mask);
189 /**
190 * Whether to use the stored phi acceptance
191 *
192 * @param use If true, use stored phi acceptance
193 */
194 void SetUsePhiAcc(Bool_t use) { fUsePhiAcc = use; }
195 /**
196 * Print this task
197 *
198 * @param option Not used
199 */
200 void Print(Option_t* option="") const;
201 /**
202 * An @f$\eta@f$ bin
203 */
204 struct EtaBin : public TObject
205 {
206 /**
207 * I/O constructor
208 */
209 EtaBin();
210 /**
211 * User constructor
212 *
213 * @param minEta Least @f$\eta@f$ to consider
214 * @param maxEta Largest @f$\eta@f$ to consider
52b36573 215 * @param mAxis The @f$ N_{ch}@f$ axis to use for measured data
216 * @param tAxis The @f$ N_{ch}@f$ axis to use for truth data
bfab35d9 217 */
52b36573 218 EtaBin(Double_t minEta, Double_t maxEta, const TAxis& mAxis);
bfab35d9 219 /**
220 * Copy constructor
221 *
222 * @param o object to copy fron
223 */
224 EtaBin(const EtaBin& o);
225 /**
226 * Assignment operator
227 *
228 * @param o object to assign from
229 *
230 * @return Reference to this object
231 */
232 EtaBin& operator=(const EtaBin& o);
233 /**
234 * Destructor
235 */
236 virtual ~EtaBin() {}
237 /**
238 * Get the name of the bin
239 */
240 const char* GetName() const { return fName.Data(); }
241 /**
242 * Is this bin symmetric around 0?
243 */
244 Bool_t IsSymmetric() const;
245 /**
246 * Is this bin positive only?
247 */
248 Bool_t IsNegative() const;
249 /**
250 * Is this bin positive only?
251 */
252 Bool_t IsPositive() const;
253 /**
254 * Get parent container name
255 *
256 *
257 * @return Parent container name
258 */
259 const char* ParentName() const;
260 /**
261 * Find the parent container. if not found, and @a create is
262 * true, then make the container.
263 *
264 * @param l Top container
265 * @param create If true, create container if not found
266 *
267 * @return Container, or null
268 */
269 TList* FindParent(TList* l, Bool_t create=true) const;
52b36573 270 /**
271 * Create a 1D histogram with specified axis
272 *
273 * @param name Name of histogram
274 * @param title Title of histogram
275 * @param xAxis X-axis to use
276 *
277 * @return Created histogram
278 */
279 static TH1* CreateH1(const char* name, const char* title,
280 const TAxis& xAxis);
281 /**
282 * Create a 2D histogram with specified axis
283 *
284 * @param name Name of histogram
285 * @param title Title of histogram
286 * @param xAxis X-axis to use
287 * @param yAxis Y-axis to use
288 *
289 * @return Created histogram
290 */
291 static TH2* CreateH2(const char* name, const char* title,
292 const TAxis& xAxis, const TAxis& yAxis);
bfab35d9 293 /**
294 * Set-up internal structures on first event.
295 *
296 * @param list List to add information to
297 * @param hist Template histogram
bfab35d9 298 * @param useMC Whether to set-up for MC input
299 */
52b36573 300 void SetupForData(TList* list, const TH2& hist, Bool_t useMC);
bfab35d9 301 /**
302 * Process a single event
303 *
304 * @param sumForward Projection of forward data
305 * @param sumCentral Projection of the central data
306 * @param forward The original forward data
307 * @param central The original central data
281a2bf8 308 * @param accepted True if event is accepted for analysis
309 * @param mc Distribution of primary particles from MC
bfab35d9 310 */
311 void Process(const TH1& sumForward, const TH1& sumCentral,
312 const TH2& forward, const TH2& central,
281a2bf8 313 Bool_t accepted, const TH1* mc);
bfab35d9 314 /**
315 * Called at the end of the final processing of the job on the
316 * full data set (merged data)
317 *
318 * @param in Input list
319 * @param out Output list
bfab35d9 320 */
52b36573 321 void Terminate(TList* in, TList* out);
bfab35d9 322
281a2bf8 323 TString fName; // Name of this bin
52b36573 324 TAxis fMAxis; // Axis used for measured Nch
325 TAxis fTAxis; // Axis used for true Nch
281a2bf8 326 Double_t fMinEta; // Least @f$\eta@f$ to consider
327 Double_t fMaxEta; // Largest @f$\eta@f$ to consider
328 Int_t fMinBin; // Least @f$\eta@f$ bin to consider
329 Int_t fMaxBin; // Largest @f$\eta@f$ bin to consider
330 TH1* fSum; // Distribution
331 TH2* fCorr; // Correlation between forward and central
332 TH2* fResponse; // Response matrix (for MC)
333 TH1* fTruth; // `true' distribution
334 TH1* fTruthAccepted; // `true' distribution for accepted events
335 TH1* fCoverage; // How much was covered
bfab35d9 336
52b36573 337 ClassDef(EtaBin,2);
bfab35d9 338 };
339 TList fBins; // List of bins
340 TList* fSymmetric; // Bins symmetric around 0
341 TList* fNegative; // Bins on negative side only
342 TList* fPositive; // Bins on the positive side only
343 TList* fList; // Output
344 TH1* fTriggers; // Histogram of triggers
345 TH1* fStatus; // Histogram of event selection status
281a2bf8 346 TH1* fVertex; // Histogram of IpZ
347 TH1* fMCVertex; // Histogram of MC IpZ
348 TH2* fDiag; // Diagnostics
bfab35d9 349 UInt_t fTriggerMask; // Trigger mask
350 Double_t fMinIpZ; // Least @f$IP_{z}@f$ to consider
351 Double_t fMaxIpZ; // Largest @f$IP_{z}@f$ to consider
352 Bool_t fFirstEvent; // First-event seen or not
353 TH1* fForwardCache; // Projection cache
354 TH1* fCentralCache; // Projection cache
355 TH1* fMCCache; // Projection cache
bfab35d9 356 Bool_t fUsePhiAcc; // If true, scale by phi acceptance
357
358 ClassDef(AliForwardMultDists,1);
359};
360
361#endif
362// Local Variables:
363// mode: C++
364// End:
365
366