Renamed
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliBasedNdetaTask.h
CommitLineData
ce85db45 1//
2// Task to analyse the AOD for for dN/deta in the base regions
3//
4#ifndef ALIBASEDNDETATASK_H
5#define ALIBASEDNDETATASK_H
ffca499d 6/**
7 * @file AliBasedNdetaTask.h
8 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
9 * @date Wed Mar 23 13:58:12 2011
10 *
11 * @brief
12 *
13 * @ingroup pwg2_forward_dndeta
14 *
15 */
ce85db45 16#include <AliAnalysisTaskSE.h>
e308a636 17class TAxis;
ce85db45 18class TList;
19class TH2D;
20class TH1D;
ffca499d 21class TH1I;
ce85db45 22class AliAODEvent;
e1f47419 23class AliAODForwardMult;
e308a636 24class TObjArray;
ce85db45 25
ffca499d 26/**
27 * @defgroup pwg2_forward_tasks_dndeta dN/deta tasks
28 * @ingroup pwg2_forward_tasks
29 */
30/**
31 * @defgroup pwg2_forward_dndeta dN/deta
32 *
33 * @f$ dN/d\eta@f$ code
34 *
35 * @ingroup pwg2_forward_topical
36 */
ce85db45 37/**
ffca499d 38 * Base class for tasks to determine @f$ dN/d\eta@f$
39 *
40 * @ingroup pwg2_forward_tasks_dndeta
41 * @ingroup pwg2_forward_dndeta
ce85db45 42 */
43class AliBasedNdetaTask : public AliAnalysisTaskSE
44{
45public:
46 /**
ffca499d 47 * Bit mask values of the normalisation scheme
48 */
49 enum {
50 /** Only normalize to accepted events */
51 kNone = 0,
52 /**
53 * Do the full normalisation
54 * @f[
55 * N = \frac{1}{\epsilon_X}(N_A-N_A/N_V(N_T-N_V)) =
56 * \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
57 * @f]
58 */
59 kEventLevel = 0x1,
60 /**
61 * Do the alternative event normalisation,
62 * @f[
63 * N' = \frac{1}{\epsilon_X}(N_A-N_A/N_V(N_T-N_A))
64 * @f]
65 */
66 kAltEventLevel = 0x2,
67 /**
68 * Do the shape correction
69 */
70 kShape = 0x4,
71 /**
72 * Correct for background events (A+C-E). Not implemented yet
73 */
74 kBackground = 0x8,
75 /**
76 * Do the full correction
77 */
78 kFull = kEventLevel | kShape | kBackground,
79 /**
80 * Do the full correction, using the alternative event-level normalisation.
81 */
82 kAltFull = kAltEventLevel | kShape | kBackground
83 };
84 /**
ce85db45 85 * Constructor
86 *
87 */
88 AliBasedNdetaTask();
89 /**
90 * Constructor
91 *
92 * @param name Name of task
ce85db45 93 */
94 AliBasedNdetaTask(const char* name);
e1f47419 95 /**
96 * Destructor
97 *
98 */
99 virtual ~AliBasedNdetaTask();
ce85db45 100
101 /**
e1f47419 102 * @{
103 * @name Task configuration
104 */
105 /**
ce85db45 106 * Set the vertex range to use
107 *
108 * @param min Minimum (in centermeter)
109 * @param max Maximum (in centermeter)
110 */
111 void SetVertexRange(Double_t min, Double_t max) { fVtxMin=min; fVtxMax=max; }
112 /**
113 * Set the rebinning factor
114 *
115 * @param rebin Rebinning factor
116 */
117 void SetRebinning(Int_t rebin) { fRebin = rebin; }
118 /**
119 * Set the trigger maskl
120 *
121 * @param mask Trigger mask
122 */
123 void SetTriggerMask(UShort_t mask) { fTriggerMask = mask; }
124 /**
125 * Set the trigger mask
126 *
127 * @param mask trigger mask
128 */
129 void SetTriggerMask(const char* mask);
e58000b7 130 /**
e308a636 131 * Set the centrality bins to use.
132 *
133 * @code
134 * UShort_t bins[] = { 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
135 * task->SetCentralityBins(11, bins);
136 * @endcode
137 *
138 * @param n Number of bins (elements in @a bins minus 1)
139 * @param bins Bin limits
140 */
141 void SetCentralityAxis(UShort_t n, Short_t* bins);
142 /**
ffca499d 143 * Whether to cut edges when merging
e58000b7 144 *
ffca499d 145 * @param cut If true, cut edges
e58000b7 146 */
3846ec25 147 void SetCutEdges(Bool_t cut) {fCutEdges = cut;}
148 /**
149 * Trigger efficiency for selected trigger(s)
150 *
151 * @param e Trigger efficiency
152 */
e58000b7 153 void SetTriggerEff(Double_t e) { fTriggerEff = e; }
154 /**
155 * Set the shape correction (a.k.a., track correction) for selected
156 * trigger(s)
157 *
158 * @param h Correction
159 */
678a4979 160 void SetShapeCorrection(const TH1* h);
161 /**
ffca499d 162 * Setthe normalisation scheme to use
163 *
164 * @param scheme Normalisation scheme
165 */
166 void SetNormalizationScheme(UShort_t scheme)
167 {
168 fNormalizationScheme = scheme;
169 }
170 /**
171 * Space, pipe, or comma separated list of options
172 *
173 * @param what List of options
678a4979 174 */
ffca499d 175 void SetNormalizationScheme(const char* what);
678a4979 176 /**
177 * Load the normalization data - done automatically if not set from outside
178 *
e1f47419 179 * @param sys system
180 * @param energy energy
678a4979 181 */
e1f47419 182 void LoadNormalizationData(UShort_t sys, UShort_t energy);
183 /** @} */
184
185 /** @{
186 * @name Task interface
ce85db45 187 */
ce85db45 188 /**
189 * Initialise on master - does nothing
190 *
191 */
192 virtual void Init() {}
193 /**
194 * Create output objects.
195 *
196 * This is called once per slave process
197 */
198 virtual void UserCreateOutputObjects();
199 /**
200 * Process a single event
201 *
202 * @param option Not used
203 */
204 virtual void UserExec(Option_t* option);
205 /**
ffca499d 206 * Called at end of event processing.
ce85db45 207 *
208 * This is called once in the master
209 *
210 * @param option Not used
211 */
212 virtual void Terminate(Option_t* option);
ffca499d 213 /* @} */
ce85db45 214
215 /**
e1f47419 216 * @{
217 * @name Services member functions
ce85db45 218 */
ce85db45 219 /**
220 * Make a copy of the input histogram and rebin that histogram
221 *
ffca499d 222 * @param h Histogram to rebin
223 * @param rebin Rebinning factor
224 * @param cutEdges Whether to cut edges when rebinning
ce85db45 225 *
226 * @return New (rebinned) histogram
227 */
e1f47419 228 static TH1D* Rebin(const TH1D* h, Int_t rebin, Bool_t cutEdges=false);
ce85db45 229 /**
230 * Make an extension of @a h to make it symmetric about 0
231 *
232 * @param h Histogram to symmertrice
233 *
234 * @return Symmetric extension of @a h
235 */
e1f47419 236 static TH1* Symmetrice(const TH1* h);
ce85db45 237 /**
238 * Project onto the X axis
239 *
240 * @param h 2D histogram
241 * @param name New name
242 * @param firstbin First bin to use
243 * @param lastbin Last bin to use
ffca499d 244 * @param corr Whether to do corrections or not
ce85db45 245 * @param error Whether to calculate errors
246 *
247 * @return Newly created histogram or null
248 */
e1f47419 249 static TH1D* ProjectX(const TH2D* h,
250 const char* name,
251 Int_t firstbin,
252 Int_t lastbin,
253 bool corr=true,
254 bool error=true);
ce85db45 255 /**
256 * Set histogram graphical options, etc.
257 *
258 * @param h Histogram to modify
259 * @param colour Marker color
260 * @param marker Marker style
261 * @param title Title of histogram
262 * @param ytitle Title on y-axis.
263 */
e1f47419 264 static void SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker,
265 const char* title,
266 const char* ytitle="#frac{1}{N} #frac{dN_{ch}}{d#eta}");
267 /** @} */
268protected:
269 AliBasedNdetaTask(const AliBasedNdetaTask&);
270 AliBasedNdetaTask& operator=(const AliBasedNdetaTask&) { return *this; }
271 class CentralityBin;
272
273 /**
274 * Retrieve the histogram
275 *
276 * @param aod AOD event
277 * @param mc Whether to get the MC histogram or not
278 *
279 * @return Retrieved histogram or null
280 */
281 virtual TH2D* GetHistogram(const AliAODEvent* aod, Bool_t mc=false) = 0;
282 /**
ffca499d 283 * Get the colour to use for markers
284 *
285 * @return Marker colour
286 */
287 virtual Int_t GetColor() const { return kRed+1; }
288 /**
289 * Get the marker style
290 *
291 * @return Marker style
292 */
293 virtual Int_t GetMarker() const { return 20; }
294 /**
e308a636 295 * Add a centrality bin
296 *
ffca499d 297 * @param at Where in the list to add this bin
e308a636 298 * @param low Low cut
299 * @param high High cut
300 */
301 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
302 /**
e1f47419 303 * Make a centrality bin
304 *
305 * @param name Name used for histograms
306 * @param low Low cut in percent
307 * @param high High cut in percent
308 *
309 * @return A newly created centrality bin
310 */
311 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
312 Short_t high) const;
e1f47419 313 /**
314 * Calculations done per centrality
315 *
316 */
317 struct CentralityBin : public TNamed
318 {
ffca499d 319 /** dN
e1f47419 320 * Constructor
321 */
322 CentralityBin();
323 /**
324 * Constructor
325 *
326 * @param name Name used for histograms (e.g., Forward)
327 * @param low Lower centrality cut in percent
328 * @param high Upper centrality cut in percent
329 */
330 CentralityBin(const char* name, Short_t low, Short_t high);
331 /**
332 * Copy constructor
333 *
334 * @param other Object to copy from
335 */
336 CentralityBin(const CentralityBin& other);
337 /**
338 * Destructor
339 */
340 virtual ~CentralityBin();
341 /**
342 * Assignment operator
343 *
344 * @param other Object to assign from
345 *
346 * @return Reference to this
347 */
348 CentralityBin& operator=(const CentralityBin& other);
349 /**
350 * Check if this is the 'all' bin
351 *
352 * @return true if low and high cuts are both zero
353 */
354 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
355 /**
356 * Get the list name
357 *
358 * @return List Name
359 */
360 const char* GetListName() const;
361 /**
362 * Create output objects
363 *
364 * @param dir Parent list
365 */
366 virtual void CreateOutputObjects(TList* dir);
367 /**
368 * Process an event
369 *
370 * @param forward Forward data (for trigger, vertex, & centrality)
371 * @param triggerMask Trigger mask
372 * @param vzMin Minimum IP z coordinate
373 * @param vzMax Maximum IP z coordinate
374 * @param data Data histogram
375 * @param mc MC histogram
376 */
377 virtual void ProcessEvent(const AliAODForwardMult* forward,
ffca499d 378 Int_t triggerMask,
379 Double_t vzMin,
380 Double_t vzMax,
381 const TH2D* data,
382 const TH2D* mc);
e1f47419 383 /**
384 * End of processing
385 *
386 * @param sums List of sums
387 * @param results Output list of results
ffca499d 388 * @param scheme Normalisation scheme options
e1f47419 389 * @param shapeCorr Shape correction or nil
390 * @param trigEff Trigger efficiency
391 * @param symmetrice Whether to symmetrice the results
392 * @param rebin Whether to rebin the results
393 * @param corrEmpty Whether to correct for empty bins
394 * @param cutEdges Whether to cut edges when rebinning
395 * @param vzMin Minimum IP z coordinate
396 * @param vzMax Maximum IP z coordinate
397 * @param triggerMask Trigger mask
ffca499d 398 * @param color Base colour for markers
399 * @param marker Marker style
e1f47419 400 */
401 virtual void End(TList* sums,
402 TList* results,
ffca499d 403 UShort_t scheme,
e1f47419 404 const TH1* shapeCorr,
405 Double_t trigEff,
406 Bool_t symmetrice,
407 Int_t rebin,
408 Bool_t corrEmpty,
409 Bool_t cutEdges,
410 Double_t vzMin,
411 Double_t vzMax,
ffca499d 412 Int_t triggerMask,
413 Int_t color,
414 Int_t marker);
e1f47419 415 /**
416 * @{
417 * @name Access histograms
418 */
419 /**
420 * Get sum histogram
421 *
422 * @param mc If true, return MC histogram
423 *
424 * @return Sum histogram
425 */
426 const TH2D* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
427 /**
428 * Get sum histogram
429 *
430 * @param mc If true, return MC histogram
431 *
432 * @return Sum histogram
433 */
434 TH2D* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
435 /**
436 * Get trigger histogram
437 *
438 * @return Trigger histogram
439 */
ffca499d 440 const TH1I* GetTriggers() const { return fTriggers; }
e1f47419 441 /**
442 * Get trigger histogram
443 *
444 * @return Trigger histogram
445 */
ffca499d 446 TH1I* GetTrigggers() { return fTriggers; }
e1f47419 447 /** @} */
448 protected:
449 /**
450 * Create sum histogram
451 *
452 * @param data Data histogram to clone
453 * @param mc (optional) MC histogram to clone
454 */
455 virtual void CreateSums(const TH2D* data, const TH2D* mc);
456 /**
457 * Check the trigger, vertex, and centrality
458 *
ffca499d 459 * @param forward Event input
460 * @param triggerMask The used trigger mask
461 * @param vzMin Least @f$ v_z@f$
462 * @param vzMax Largest @f$ v_z@f$
e1f47419 463 *
464 * @return true if the event is to be used
465 */
466 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
ffca499d 467 Int_t triggerMask,
468 Double_t vzMin,
469 Double_t vzMax);
e1f47419 470 TList* fSums; // Output list
471 TList* fOutput; // Output list
472 TH2D* fSum; // Sum histogram
473 TH2D* fSumMC; // MC sum histogram
ffca499d 474 TH1I* fTriggers; // Trigger histogram
e1f47419 475 UShort_t fLow; // Lower limit (inclusive)
476 UShort_t fHigh; // Upper limit (exclusive)
ce85db45 477
e1f47419 478 ClassDef(CentralityBin,1); // A centrality bin
479 };
ce85db45 480 TList* fSums; // Container of sums
481 TList* fOutput; // Container of outputs
ce85db45 482 Double_t fVtxMin; // Minimum v_z
483 Double_t fVtxMax; // Maximum v_z
484 Int_t fTriggerMask; // Trigger mask
485 Int_t fRebin; // Rebinning factor
486 Bool_t fCutEdges; // Whether to cut edges when rebinning
487 Bool_t fSymmetrice; // Whether to symmetrice data
488 Bool_t fCorrEmpty; // Correct for empty bins
e58000b7 489 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
490 TH1* fShapeCorr; // Shape correction
e308a636 491 TObjArray* fListOfCentralities; // Centrality bins
e1f47419 492 TNamed* fSNNString; // sqrt(s_NN) string
493 TNamed* fSysString; // Collision system string
494 TH1D* fCent; // Centrality distribution
e308a636 495 TAxis* fCentAxis; // Centrality axis
ffca499d 496 UShort_t fNormalizationScheme; // Normalization scheme
497 ClassDef(AliBasedNdetaTask,3); // Determine multiplicity in base area
ce85db45 498};
499
500#endif
501//
502// Local Variables:
503// mode: C++
504// End:
505//