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