]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/AliForwardCorrectionManager.h
Renamed
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliForwardCorrectionManager.h
1 #ifndef ALIROOT_PWG2_FORWARD_ALIFORWARDCORRECTIONMANAGER_H
2 #define ALIROOT_PWG2_FORWARD_ALIFORWARDCORRECTIONMANAGER_H
3 #include <TObject.h>
4 #include "AliFMDCorrELossFit.h"
5 #include "AliFMDCorrSecondaryMap.h"
6 #include "AliFMDCorrDoubleHit.h"
7 #include "AliFMDCorrVertexBias.h"
8 #include "AliFMDCorrMergingEfficiency.h"
9 #include <TString.h>
10 class TFile;
11
12 /**
13  * Manager (singleton) of corrections 
14  * 
15  * @ingroup pwg2_forward_corr 
16  */
17 class AliForwardCorrectionManager : public TObject
18 {
19 public:
20   /**
21    * Enumeration of things that can be read in 
22    */
23   enum ECorrection { 
24     kSecondaryMap              = 0x01, 
25     kELossFits                 = 0x02, 
26     kVertexBias                = 0x04, 
27     kMergingEfficiency         = 0x08,
28     kDoubleHit                 = 0x10,
29     kAll                       = (kSecondaryMap| 
30                                   kELossFits|
31                                   kVertexBias|
32                                   kMergingEfficiency|
33                                   kDoubleHit)
34   };
35   /** 
36    * Access to the singleton object 
37    * 
38    * @return Reference to the singleton object 
39    */
40   static AliForwardCorrectionManager& Instance();
41   /** 
42    * Read in corrections based on the parameters given 
43    * 
44    * @param collisionSystem Collision system
45    * @param cmsNN           Center of mass energy per nuclean pair [GeV]
46    * @param field           Magnetic field setting [kG]
47    * @param mc              Monte-carlo switch
48    * @param what            What to read in. 
49    * @param force           Force (re-)reading of specified things
50    * 
51    * @return 
52    */
53   Bool_t Init(UShort_t collisionSystem, 
54               UShort_t cmsNN, 
55               Short_t  field, 
56               Bool_t   mc=false,
57               UInt_t   what=kAll,
58               Bool_t   force=false);
59   Bool_t Init(const char* collisionSystem, 
60               Float_t     cmsNN, 
61               Float_t     field, 
62               Bool_t      mc=false,
63               UInt_t      what=kAll,
64               Bool_t      force=false);
65   /** 
66    * Get the eta axis 
67    * 
68    * @return Eta axis or null
69    */
70   const TAxis* GetEtaAxis() const;
71   /** 
72    * Get the vertex axis 
73    * 
74    * @return The vertex axis or null
75    */
76   const TAxis* GetVertexAxis() const;
77   /** 
78    * Get the energy loss fit correction object. 
79    * 
80    * @return Get the energy loss fits corrections object or null pointer
81    */
82   AliFMDCorrELossFit* GetELossFit() const { return fELossFit; }
83   /** 
84    * Get the secondary correction map
85    * 
86    * @return Get the secondary correction map object or null
87    */
88   AliFMDCorrSecondaryMap* GetSecondaryMap() const { return fSecondaryMap; }
89   /** 
90    * Get the double hit correction object
91    * 
92    * @return Get the double hit correction object or null 
93    */
94   AliFMDCorrDoubleHit* GetDoubleHit() const { return fDoubleHit; }
95   /** 
96    * Get the vertex bias correction object
97    * 
98    * @return Get the vertex bias correction object or null 
99    */
100   AliFMDCorrVertexBias* GetVertexBias() const { return fVertexBias; }
101   AliFMDCorrMergingEfficiency* GetMergingEfficiency() const 
102   {
103     return fMergingEfficiency;
104   }
105   /** 
106    * @{ 
107    * @name Path, file, and object access utilities 
108    */
109   /** 
110    * Get the path to the specified object 
111    *
112    * @param what  Which stuff to get the path for 
113    * @param sys   Collision system
114    * @param sNN   Center of mass energy [GeV]
115    * @param field Magnetic field in the L3 magnet [kG]
116    * @param mc    Whether the correction objects should be valid for MC
117    * 
118    * @return The full path or null 
119    */
120   TString GetFileName(ECorrection what, 
121                       UShort_t    sys, 
122                       UShort_t    sNN, 
123                       Short_t     field,
124                       Bool_t      mc) const;
125   TString GetFileName(ECorrection what) const;
126   /** 
127    * Get the path to the specified object 
128    *
129    * @param what  Which stuff to get the path for 
130    * 
131    * @return The full path or null 
132    */
133   const Char_t* GetFileDir(ECorrection what) const;
134   /** 
135    * Get the path to the specified object 
136    *
137    * @param what  Which stuff to get the path for 
138    * @param sys   Collision system
139    * @param sNN   Center of mass energy [GeV]
140    * @param field Magnetic field in the L3 magnet [kG]
141    * @param mc    Whether the correction objects should be valid for MC
142    * 
143    * @return The full path or null 
144    */
145   TString GetFilePath(ECorrection what, 
146                       UShort_t    sys, 
147                       UShort_t    sNN, 
148                       Short_t     field,
149                       Bool_t      mc) const;
150   TString GetFilePath(ECorrection what) const;
151   /** 
152    * Open the file that contains the correction object specified 
153    * 
154    * @param what  Which stuff to get the path for 
155    * @param sys   Collision system
156    * @param sNN   Center of mass energy [GeV]
157    * @param field Magnetic field in the L3 magnet [kG]
158    * @param mc    Whether the correction objects should be valid for MC
159    * @param rw    Whether to open the file in read/write
160    * @param newfile Wheter to make the file if it doesn't exist
161    * 
162    * @return The file that contains the correction object or null 
163    */
164   TFile* GetFile(ECorrection what, 
165                  UShort_t    sys, 
166                  UShort_t    sNN, 
167                  Short_t     field,
168                  Bool_t      mc=false, 
169                  Bool_t      rw=false, 
170                  Bool_t      newfile=false) const;
171   TFile* GetFile(ECorrection what) const;
172   /** 
173    * Get the object name corresponding to correction type 
174    * 
175    * @param what Correction 
176    * 
177    * @return Object name or null
178    */
179   const Char_t* GetObjectName(ECorrection what) const;
180   /** 
181    * Check if the specified objet exists in the file, and return it
182    * 
183    * @param file File to query 
184    * @param what Correction type 
185    * 
186    * @return Object found, or null
187    */
188   TObject* CheckObject(TFile* file,  ECorrection what) const;
189   /** 
190    * Get the path to the specified object 
191    *
192    * @param what  Which stuff to get the path for 
193    * @param sys   Collision system
194    * @param sNN   Center of mass energy [GeV]
195    * @param field Magnetic field in the L3 magnet [kG]
196    * @param mc    Whether the correction objects should be valid for MC
197    * 
198    * @return The full path or null 
199    */
200   TObject* GetObject(ECorrection what, 
201                      UShort_t    sys, 
202                      UShort_t    sNN, 
203                      Short_t     field,
204                      Bool_t      mc) const;
205   TObject* GetObject(ECorrection what) const;
206   /* 
207    * @} 
208    */
209 private:
210   /** 
211    * Default constructor 
212    */
213   AliForwardCorrectionManager();
214   /** 
215    * Copy constructor 
216    * 
217    * @param o Object to copy from 
218    */
219   AliForwardCorrectionManager(const AliForwardCorrectionManager& o);
220   /** 
221    * Assignment operator 
222    * 
223    * @param o Object to assign from 
224    * 
225    * @return Reference to this object 
226    */
227   AliForwardCorrectionManager& operator=(const AliForwardCorrectionManager& o);
228   /** 
229    * @{ 
230    * @name Read in corrections 
231    */
232   /** 
233    * Read in the secondary map 
234    * 
235    * @param sys   Collision system
236    * @param sNN   Center of mass energy [GeV]
237    * @param field Magnetic field in the L3 magnet [kG]
238    * 
239    * @return True on success, false otherwise 
240    */
241   Bool_t ReadSecondaryMap(UShort_t sys, UShort_t sNN, Short_t field);
242   /** 
243    * Read in the double hit correction
244    * 
245    * @param sys   Collision system
246    * @param sNN   Center of mass energy [GeV]
247    * @param field Magnetic field in the L3 magnet [kG]
248    * 
249    * @return True on success, false otherwise 
250    */
251   Bool_t ReadDoubleHit(UShort_t sys, UShort_t sNN, Short_t field);
252   /** 
253    * Read in the energy loss fits 
254    * 
255    * @param sys   Collision system
256    * @param sNN   Center of mass energy [GeV]
257    * @param field Magnetic field in the L3 magnet [kG]
258    * @param mc    Whether the correction objects should be valid for MC
259    * 
260    * @return True on success, false otherwise 
261    */
262   Bool_t ReadELossFits(UShort_t sys, UShort_t sNN, Short_t field, Bool_t mc);
263   /** 
264    * Read in the event selection efficiency 
265    * 
266    * @param sys   Collision system
267    * @param sNN   Center of mass energy [GeV]
268    * @param field Magnetic field in the L3 magnet [kG]
269    * 
270    * @return True on success, false otherwise 
271    */
272   Bool_t ReadVertexBias(UShort_t sys, UShort_t sNN, Short_t field);
273   /** 
274    * Read in the merging efficiency 
275    * 
276    * @param sys   Collision system
277    * @param sNN   Center of mass energy [GeV]
278    * @param field Magnetic field in the L3 magnet [kG]
279    * 
280    * @return True on success, false otherwise 
281    */
282   Bool_t ReadMergingEfficiency(UShort_t sys, UShort_t sNN, Short_t field);
283   /* 
284    * @} 
285    */
286   
287   /** Static singleton instance */
288   static AliForwardCorrectionManager* fgInstance;
289   Bool_t    fInit;  // whether we have been initialised 
290   UShort_t  fSys;   // Collision System
291   UShort_t  fSNN;   // Collision energy per nucleon (GeV)
292   Short_t   fField; // L3 magnetic field (kG)
293   
294   /** 
295    * @{
296    * @name Paths 
297    */ 
298   TString fELossFitsPath;    // Path to energy loss fit correction 
299   TString fMergingEffPath;   // Path to sharing efficiency correction 
300   TString fSecondaryMapPath; // Path to secondary efficiency correction
301   TString fDoubleHitPath;    // Path to double hit correction
302   TString fVertexBiasPath;   // Path to event selection efficiency correction
303   /* 
304    * @}
305    */
306   /** 
307    * @{ 
308    * @name Object name 
309    */
310   static const Char_t* fgkSecondaryMapSkel;  // Name of correction object 
311   static const Char_t* fgkDoubleHitSkel;     // Name of correction object 
312   static const Char_t* fgkELossFitsSkel;     // Name of correction object 
313   static const Char_t* fgkVertexBiasSkel;    // Name of correction object 
314   static const Char_t* fgkMergingEffSkel;    // Name of correction object 
315   /* 
316    * @} 
317    */
318   /** 
319    * @{ 
320    * @name Correction objects 
321    */
322   AliFMDCorrELossFit*     fELossFit;     // Energy loss fits 
323   AliFMDCorrSecondaryMap* fSecondaryMap; // Secondary particle correction
324   AliFMDCorrDoubleHit*    fDoubleHit;    // Double hit correction (low flux)
325   AliFMDCorrVertexBias*   fVertexBias;   // Vertex bias correction
326   AliFMDCorrMergingEfficiency* fMergingEfficiency;
327   /* 
328    * @}
329    */
330
331   ClassDef(AliForwardCorrectionManager,1) // Manager of corrections 
332 };
333 //____________________________________________________________________
334 inline const TAxis* 
335 AliForwardCorrectionManager::GetEtaAxis() const
336 {
337   if (!fSecondaryMap) return 0;
338   return &(fSecondaryMap->GetEtaAxis());
339 }
340 //____________________________________________________________________
341 inline const TAxis* 
342 AliForwardCorrectionManager::GetVertexAxis() const
343 {
344   if (!fSecondaryMap) return 0;
345   return &(fSecondaryMap->GetVertexAxis());
346 }
347
348 #endif
349 // Local Variables:
350 //   mode: C++ 
351 // End: 
352