]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliForwardCorrectionManager.h
Fixes for pA indenfication of events
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliForwardCorrectionManager.h
CommitLineData
7984e5f7 1//
2// Manager (singleton) of corrections
3//
4#ifndef ALIFORWARDCORRECTIONMANAGER_H
5#define ALIFORWARDCORRECTIONMANAGER_H
ffca499d 6/**
7 * @file AliForwardCorrectionManager.h
8 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
9 * @date Wed Mar 23 14:04:27 2011
10 *
11 * @brief
12 *
13 *
bd6f5206 14 * @ingroup pwglf_forward_aod
ffca499d 15 */
0bd4b00f 16#include <TObject.h>
0bd4b00f 17#include "AliFMDCorrSecondaryMap.h"
0bd4b00f 18#include <TString.h>
19class TFile;
19abe41d 20class TBrowser;
fb3430ac 21class AliFMDCorrELossFit;
fb3430ac 22class AliFMDCorrDoubleHit;
23class AliFMDCorrVertexBias;
24class AliFMDCorrMergingEfficiency;
25class AliFMDCorrAcceptance;
0bd4b00f 26
7c1a1f1d 27/**
28 * Manager (singleton) of corrections
19abe41d 29 *
30 * Note, that this class has a custom streamer. That is to ensure
31 * that the singleton pointer is correctly set on reading in an object
32 * of this type.
7c1a1f1d 33 *
bd6f5206 34 * @ingroup pwglf_forward_corr
35 * @ingroup pwglf_forward_aod
7c1a1f1d 36 */
0bd4b00f 37class AliForwardCorrectionManager : public TObject
38{
39public:
40 /**
41 * Enumeration of things that can be read in
42 */
43 enum ECorrection {
44 kSecondaryMap = 0x01,
45 kELossFits = 0x02,
46 kVertexBias = 0x04,
47 kMergingEfficiency = 0x08,
48 kDoubleHit = 0x10,
72cc12cd 49 kAcceptance = 0x20,
0bd4b00f 50 kAll = (kSecondaryMap|
51 kELossFits|
52 kVertexBias|
53 kMergingEfficiency|
72cc12cd 54 kDoubleHit|
55 kAcceptance)
0bd4b00f 56 };
19abe41d 57 /**
58 * Default constructor. This is public for the sake of the ROOT I/O
59 * system, but should never be used outside of that system - that
60 * is, do not use this constructor
61 */
62 AliForwardCorrectionManager();
0bd4b00f 63 /**
64 * Access to the singleton object
65 *
66 * @return Reference to the singleton object
67 */
68 static AliForwardCorrectionManager& Instance();
cc83fca2 69 /**
70 *
71 * @param prefix Prefix to correction objects.
72 */
73 void SetPrefix(const char* prefix);
fb3430ac 74 /**
75 * Set the file directory for a type
76 *
77 * @param what Type
78 * @param dirname Directory name
79 */
cc83fca2 80 void SetFileDir(ECorrection what, const char* dirname);
290052e7 81 /**
82 * Set path to corrections
83 *
84 * @param d Path
85 */
cc83fca2 86 void SetSecondaryMapPath(const char* d) { SetFileDir(kSecondaryMap, d); }
290052e7 87 /**
88 * Set path to corrections
89 *
90 * @param d Path
91 */
cc83fca2 92 void SetDoubleHitPath(const char* d) { SetFileDir(kDoubleHit, d); }
290052e7 93 /**
94 * Set path to corrections
95 *
96 * @param d Path
97 */
cc83fca2 98 void SetELossFitsPath(const char* d) { SetFileDir(kELossFits, d); }
290052e7 99 /**
100 * Set path to corrections
101 *
102 * @param d Path
103 */
cc83fca2 104 void SetVertexBiasPath(const char* d) { SetFileDir(kVertexBias, d); }
290052e7 105 /**
106 * Set path to corrections
107 *
108 * @param d Path
109 */
cc83fca2 110 void SetMergingEffPath(const char* d) { SetFileDir(kMergingEfficiency, d); }
290052e7 111 /**
112 * Set path to corrections
113 *
114 * @param d Path
115 */
cc83fca2 116 void SetAcceptancePath(const char* d) { SetFileDir(kAcceptance, d); }
0bd4b00f 117 /**
118 * Read in corrections based on the parameters given
119 *
120 * @param collisionSystem Collision system
121 * @param cmsNN Center of mass energy per nuclean pair [GeV]
122 * @param field Magnetic field setting [kG]
7c1a1f1d 123 * @param mc Monte-carlo switch
0bd4b00f 124 * @param what What to read in.
125 * @param force Force (re-)reading of specified things
126 *
127 * @return
128 */
129 Bool_t Init(UShort_t collisionSystem,
130 UShort_t cmsNN,
131 Short_t field,
132 Bool_t mc=false,
133 UInt_t what=kAll,
134 Bool_t force=false);
7984e5f7 135 /**
136 * Read in correction based on passed parameters
137 *
138 * @param collisionSystem Collision system string
139 * @param cmsNN Center of mass energy per nucleon pair [GeV]
140 * @param field Magnetic field [kG]
141 * @param mc Monte-carlo switch
142 * @param what What to read in
143 * @param force Force (re-)reading of specified things
144 *
145 * @return true on success
146 */
0bd4b00f 147 Bool_t Init(const char* collisionSystem,
148 Float_t cmsNN,
149 Float_t field,
150 Bool_t mc=false,
151 UInt_t what=kAll,
152 Bool_t force=false);
153 /**
154 * Get the eta axis
155 *
156 * @return Eta axis or null
157 */
158 const TAxis* GetEtaAxis() const;
159 /**
160 * Get the vertex axis
161 *
162 * @return The vertex axis or null
163 */
164 const TAxis* GetVertexAxis() const;
165 /**
166 * Get the energy loss fit correction object.
167 *
168 * @return Get the energy loss fits corrections object or null pointer
169 */
170 AliFMDCorrELossFit* GetELossFit() const { return fELossFit; }
171 /**
172 * Get the secondary correction map
173 *
174 * @return Get the secondary correction map object or null
175 */
176 AliFMDCorrSecondaryMap* GetSecondaryMap() const { return fSecondaryMap; }
177 /**
178 * Get the double hit correction object
179 *
180 * @return Get the double hit correction object or null
181 */
182 AliFMDCorrDoubleHit* GetDoubleHit() const { return fDoubleHit; }
183 /**
184 * Get the vertex bias correction object
185 *
186 * @return Get the vertex bias correction object or null
187 */
188 AliFMDCorrVertexBias* GetVertexBias() const { return fVertexBias; }
72cc12cd 189 /**
190 * Get the merging efficiency
191 *
192 *
193 * @return Get the vertex efficiency correction
194 */
0bd4b00f 195 AliFMDCorrMergingEfficiency* GetMergingEfficiency() const
196 {
197 return fMergingEfficiency;
198 }
72cc12cd 199 /**
200 * Get the acceptance correction due to dead channels
201 *
202 *
203 * @return Acceptance correction due to dead channels
204 */
205 AliFMDCorrAcceptance* GetAcceptance() const { return fAcceptance; }
0bd4b00f 206 /**
207 * @{
208 * @name Path, file, and object access utilities
209 */
210 /**
211 * Get the path to the specified object
212 *
213 * @param what Which stuff to get the path for
214 * @param sys Collision system
215 * @param sNN Center of mass energy [GeV]
216 * @param field Magnetic field in the L3 magnet [kG]
217 * @param mc Whether the correction objects should be valid for MC
218 *
72cc12cd 219 * @return The file name (sans directory) or null
0bd4b00f 220 */
221 TString GetFileName(ECorrection what,
222 UShort_t sys,
223 UShort_t sNN,
224 Short_t field,
225 Bool_t mc) const;
7984e5f7 226 /**
227 * Get the file name of the specified object
228 *
229 * @param what Which stuff to get the path for
230 *
72cc12cd 231 * @return The file name (sans directory) or null
7984e5f7 232 */
0bd4b00f 233 TString GetFileName(ECorrection what) const;
234 /**
235 * Get the path to the specified object
236 *
237 * @param what Which stuff to get the path for
238 *
72cc12cd 239 * @return The files directory full path or null
0bd4b00f 240 */
241 const Char_t* GetFileDir(ECorrection what) const;
242 /**
243 * Get the path to the specified object
244 *
245 * @param what Which stuff to get the path for
246 * @param sys Collision system
247 * @param sNN Center of mass energy [GeV]
248 * @param field Magnetic field in the L3 magnet [kG]
249 * @param mc Whether the correction objects should be valid for MC
250 *
251 * @return The full path or null
252 */
253 TString GetFilePath(ECorrection what,
254 UShort_t sys,
255 UShort_t sNN,
256 Short_t field,
257 Bool_t mc) const;
7984e5f7 258 /**
259 * Get the full path to the object. Note, the manager must be
260 * initialised for this to work
261 *
262 * @param what Which stuff to get the path for
263 *
264 * @return The full path or null
265 */
0bd4b00f 266 TString GetFilePath(ECorrection what) const;
267 /**
268 * Open the file that contains the correction object specified
269 *
270 * @param what Which stuff to get the path for
271 * @param sys Collision system
272 * @param sNN Center of mass energy [GeV]
273 * @param field Magnetic field in the L3 magnet [kG]
274 * @param mc Whether the correction objects should be valid for MC
275 * @param rw Whether to open the file in read/write
276 * @param newfile Wheter to make the file if it doesn't exist
277 *
278 * @return The file that contains the correction object or null
279 */
280 TFile* GetFile(ECorrection what,
281 UShort_t sys,
282 UShort_t sNN,
283 Short_t field,
284 Bool_t mc=false,
285 Bool_t rw=false,
286 Bool_t newfile=false) const;
7984e5f7 287 /**
288 * Get the file that contains the object specifed. Note, the manager
289 * must be initialised for this to work.
290 *
291 * @param what Which stuff to get the path for
292 *
293 * @return The file that contains the correction object or null
294 */
0bd4b00f 295 TFile* GetFile(ECorrection what) const;
296 /**
297 * Get the object name corresponding to correction type
298 *
299 * @param what Correction
300 *
301 * @return Object name or null
302 */
303 const Char_t* GetObjectName(ECorrection what) const;
304 /**
305 * Check if the specified objet exists in the file, and return it
306 *
307 * @param file File to query
308 * @param what Correction type
309 *
310 * @return Object found, or null
311 */
312 TObject* CheckObject(TFile* file, ECorrection what) const;
313 /**
314 * Get the path to the specified object
315 *
316 * @param what Which stuff to get the path for
317 * @param sys Collision system
318 * @param sNN Center of mass energy [GeV]
319 * @param field Magnetic field in the L3 magnet [kG]
320 * @param mc Whether the correction objects should be valid for MC
321 *
322 * @return The full path or null
323 */
324 TObject* GetObject(ECorrection what,
325 UShort_t sys,
326 UShort_t sNN,
327 Short_t field,
328 Bool_t mc) const;
7984e5f7 329 /**
330 * Get the object that contaisn the specified correction
331 *
332 * @param what Which object to get
333 *
334 * @return The object or null
335 */
0bd4b00f 336 TObject* GetObject(ECorrection what) const;
337 /*
338 * @}
339 */
19abe41d 340 /**
341 * @{
342 * @name Misc
343 */
0bd4b00f 344 /**
19abe41d 345 * Print this object
346 *
347 * @param option Passed verbatim to correction objects
0bd4b00f 348 */
19abe41d 349 void Print(Option_t* option="") const;
350 /**
351 * Browse this object
352 *
353 * @param b Browser to use
354 */
355 void Browse(TBrowser* b);
356 /*
357 * @}
358 */
e42d5338 359 /**
360 * Write a correction object to (a temporary) file.
361 *
362 * @param what What kind of correction
363 * @param sys Collision system
364 * @param cms Center of mass energy
365 * @param field Field
366 * @param mc Whether this is for MC only
367 * @param o Object to write
368 * @param full If true, write to full path
369 *
370 * @return True on success
371 */
372 Bool_t WriteFile(ECorrection what,
373 UShort_t sys, UShort_t cms, Short_t field, Bool_t mc,
374 TObject* o, Bool_t full) const;
19abe41d 375private:
0bd4b00f 376 /**
377 * Copy constructor
378 *
379 * @param o Object to copy from
380 */
381 AliForwardCorrectionManager(const AliForwardCorrectionManager& o);
382 /**
383 * Assignment operator
384 *
385 * @param o Object to assign from
386 *
387 * @return Reference to this object
388 */
389 AliForwardCorrectionManager& operator=(const AliForwardCorrectionManager& o);
390 /**
391 * @{
392 * @name Read in corrections
393 */
394 /**
395 * Read in the secondary map
396 *
397 * @param sys Collision system
398 * @param sNN Center of mass energy [GeV]
399 * @param field Magnetic field in the L3 magnet [kG]
400 *
401 * @return True on success, false otherwise
402 */
403 Bool_t ReadSecondaryMap(UShort_t sys, UShort_t sNN, Short_t field);
404 /**
405 * Read in the double hit correction
406 *
407 * @param sys Collision system
408 * @param sNN Center of mass energy [GeV]
409 * @param field Magnetic field in the L3 magnet [kG]
410 *
411 * @return True on success, false otherwise
412 */
413 Bool_t ReadDoubleHit(UShort_t sys, UShort_t sNN, Short_t field);
414 /**
415 * Read in the energy loss fits
416 *
417 * @param sys Collision system
418 * @param sNN Center of mass energy [GeV]
419 * @param field Magnetic field in the L3 magnet [kG]
420 * @param mc Whether the correction objects should be valid for MC
421 *
422 * @return True on success, false otherwise
423 */
424 Bool_t ReadELossFits(UShort_t sys, UShort_t sNN, Short_t field, Bool_t mc);
425 /**
426 * Read in the event selection efficiency
427 *
428 * @param sys Collision system
429 * @param sNN Center of mass energy [GeV]
430 * @param field Magnetic field in the L3 magnet [kG]
431 *
432 * @return True on success, false otherwise
433 */
434 Bool_t ReadVertexBias(UShort_t sys, UShort_t sNN, Short_t field);
435 /**
436 * Read in the merging efficiency
437 *
438 * @param sys Collision system
439 * @param sNN Center of mass energy [GeV]
440 * @param field Magnetic field in the L3 magnet [kG]
441 *
442 * @return True on success, false otherwise
443 */
444 Bool_t ReadMergingEfficiency(UShort_t sys, UShort_t sNN, Short_t field);
72cc12cd 445 /**
446 * Read in the acceptance correction due to dead-channels
447 *
448 * @param sys Collision system
449 * @param sNN Center of mass energy [GeV]
450 * @param field Magnetic field in the L3 magnet [kG]
451 *
452 * @return True on success, false otherwise
453 */
454 Bool_t ReadAcceptance(UShort_t sys, UShort_t sNN, Short_t field);
0bd4b00f 455 /*
456 * @}
457 */
458
459 /** Static singleton instance */
fb3430ac 460 static AliForwardCorrectionManager* fgInstance; // Skeleton
0bd4b00f 461 Bool_t fInit; // whether we have been initialised
462 UShort_t fSys; // Collision System
463 UShort_t fSNN; // Collision energy per nucleon (GeV)
464 Short_t fField; // L3 magnetic field (kG)
465
466 /**
467 * @{
468 * @name Paths
469 */
470 TString fELossFitsPath; // Path to energy loss fit correction
471 TString fMergingEffPath; // Path to sharing efficiency correction
472 TString fSecondaryMapPath; // Path to secondary efficiency correction
473 TString fDoubleHitPath; // Path to double hit correction
474 TString fVertexBiasPath; // Path to event selection efficiency correction
72cc12cd 475 TString fAcceptancePath; // Path to acceptance correction from dead areas
0bd4b00f 476 /*
477 * @}
478 */
479 /**
480 * @{
481 * @name Object name
482 */
483 static const Char_t* fgkSecondaryMapSkel; // Name of correction object
484 static const Char_t* fgkDoubleHitSkel; // Name of correction object
485 static const Char_t* fgkELossFitsSkel; // Name of correction object
486 static const Char_t* fgkVertexBiasSkel; // Name of correction object
487 static const Char_t* fgkMergingEffSkel; // Name of correction object
72cc12cd 488 static const Char_t* fgkAcceptanceSkel; // Name of correction object
0bd4b00f 489 /*
490 * @}
491 */
492 /**
493 * @{
494 * @name Correction objects
495 */
72cc12cd 496 AliFMDCorrELossFit* fELossFit; // Energy loss fits
497 AliFMDCorrSecondaryMap* fSecondaryMap; // Secondary particle correction
498 AliFMDCorrDoubleHit* fDoubleHit; // Double hit corr. (low flux)
499 AliFMDCorrVertexBias* fVertexBias; // Vertex bias correction
500 AliFMDCorrMergingEfficiency* fMergingEfficiency; // Merging eff.
501 AliFMDCorrAcceptance* fAcceptance; // Acceptance corr.
0bd4b00f 502 /*
503 * @}
504 */
19abe41d 505 ClassDef(AliForwardCorrectionManager,2) // Manager of corrections
0bd4b00f 506};
507//____________________________________________________________________
508inline const TAxis*
509AliForwardCorrectionManager::GetEtaAxis() const
510{
511 if (!fSecondaryMap) return 0;
512 return &(fSecondaryMap->GetEtaAxis());
513}
514//____________________________________________________________________
515inline const TAxis*
516AliForwardCorrectionManager::GetVertexAxis() const
517{
518 if (!fSecondaryMap) return 0;
519 return &(fSecondaryMap->GetVertexAxis());
520}
521
522#endif
523// Local Variables:
524// mode: C++
525// End:
526