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