]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGLF/FORWARD/analysis2/AliForwardCorrectionManager.h
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliForwardCorrectionManager.h
index 45b21934a854a6588307e8130021f76f981a56a6..87444175abedbbfe38057be3576c3fd37779937c 100644 (file)
  * 
  * @ingroup pwglf_forward_aod
  */
-#include <TObject.h>
-#include "AliFMDCorrSecondaryMap.h"
+#include "AliCorrectionManagerBase.h"
 #include <TString.h>
-class TFile;
 class TBrowser;
 class AliFMDCorrELossFit;
 class AliFMDCorrDoubleHit;
 class AliFMDCorrVertexBias;
 class AliFMDCorrMergingEfficiency;
 class AliFMDCorrAcceptance;
+class AliFMDCorrSecondaryMap;
+class AliFMDCorrNoiseGain;
+class TAxis;
 
 /**
  * Manager (singleton) of corrections 
@@ -34,8 +35,21 @@ class AliFMDCorrAcceptance;
  * @ingroup pwglf_forward_corr 
  * @ingroup pwglf_forward_aod
  */
-class AliForwardCorrectionManager : public TObject
+class AliForwardCorrectionManager : public AliCorrectionManagerBase
 {
+private:
+  /**
+   * Enumeration of things that can be read in 
+   */
+  enum EId { 
+    kIdSecondaryMap            = 0, 
+    kIdELossFits,
+    kIdVertexBias,
+    kIdMergingEfficiency,
+    kIdDoubleHit,
+    kIdAcceptance,
+    kIdNoiseGain
+  };
 public:
   /**
    * Enumeration of things that can be read in 
@@ -47,12 +61,15 @@ public:
     kMergingEfficiency         = 0x08,
     kDoubleHit                 = 0x10,
     kAcceptance                = 0x20,
+    kNoiseGain                 = 0x40,
+    kDefault                   = (kSecondaryMap|kELossFits|kAcceptance),
     kAll                       = (kSecondaryMap| 
                                  kELossFits|
                                  kVertexBias|
                                  kMergingEfficiency|
                                  kDoubleHit|
-                                 kAcceptance)
+                                 kAcceptance|
+                                 kNoiseGain)
   };
   /** 
    * Default constructor.  This is public for the sake of the ROOT I/O
@@ -66,90 +83,129 @@ public:
    * @return Reference to the singleton object 
    */
   static AliForwardCorrectionManager& Instance();
+
   /** 
-   *
-   * @param prefix Prefix to correction objects. 
+   * Append the content of the file @a addition to the @a destination
+   * file for this manager.  This used TFileMerger::PartialMerge 
+   * 
+   * @param destination Filename of destination storage (in OADB_PATH)
+   * @param addition    Filename of addition. 
+   * 
+   * @return true on success 
    */
-  void SetPrefix(const char* prefix);
+  virtual Bool_t Append(const TString& addition,
+                       const TString& destination="") const;
+
   /** 
-   * Set the file directory for a type 
-   * 
-   * @param what     Type 
-   * @param dirname  Directory name 
+   * @return name of object 
    */
-  void SetFileDir(ECorrection what, const char* dirname);
+  const Char_t* GetName() const { return "forwardCorrections"; }
   /** 
    * Set path to corrections 
    * 
    * @param d Path
    */
-  void SetSecondaryMapPath(const char* d) { SetFileDir(kSecondaryMap, d); }
+  void SetSecondaryMapPath(const char* d) 
+  {
+    SetCorrectionFile(kIdSecondaryMap, d);
+  }
   /** 
    * Set path to corrections 
    * 
    * @param d Path
    */
-  void SetDoubleHitPath(const char* d)    { SetFileDir(kDoubleHit, d); }
+  void SetDoubleHitPath(const char* d)    
+  {
+    SetCorrectionFile(kIdDoubleHit, d);
+  }
   /** 
    * Set path to corrections 
    * 
    * @param d Path
    */
-  void SetELossFitsPath(const char* d)    { SetFileDir(kELossFits, d); }
+  void SetELossFitsPath(const char* d)    
+  {
+    SetCorrectionFile(kIdELossFits, d);
+  }
   /** 
    * Set path to corrections 
    * 
    * @param d Path
    */
-  void SetVertexBiasPath(const char* d)   { SetFileDir(kVertexBias, d); }
+  void SetVertexBiasPath(const char* d)   
+  {
+    SetCorrectionFile(kIdVertexBias, d);
+  }
   /** 
    * Set path to corrections 
    * 
    * @param d Path
    */
-  void SetMergingEffPath(const char* d)   { SetFileDir(kMergingEfficiency, d); }
+  void SetMergingEffPath(const char* d)   
+  {
+    SetCorrectionFile(kIdMergingEfficiency, d);
+  }
   /** 
    * Set path to corrections 
    * 
    * @param d Path
    */
-  void SetAcceptancePath(const char* d)   { SetFileDir(kAcceptance, d); }
+  void SetAcceptancePath(const char* d)   
+  {
+    SetCorrectionFile(kIdAcceptance, d);
+  }
   /** 
    * Read in corrections based on the parameters given 
    * 
+   * @param runNumber       Run number
    * @param collisionSystem Collision system
    * @param cmsNN           Center of mass energy per nuclean pair [GeV]
    * @param field           Magnetic field setting [kG]
    * @param mc              Monte-carlo switch
    * @param what            What to read in. 
    * @param force           Force (re-)reading of specified things
+   * @param satelliteCollisions For satellite collisions
    * 
    * @return 
    */
-  Bool_t Init(UShort_t collisionSystem, 
+  Bool_t Init(ULong_t  runNumber,
+             UShort_t collisionSystem, 
              UShort_t cmsNN, 
              Short_t  field, 
              Bool_t   mc=false,
-             UInt_t   what=kAll,
+             Bool_t   satelliteCollisions=false,
+             UInt_t   what=kDefault,
              Bool_t   force=false);
   /** 
    * Read in correction based on passed parameters
    * 
+   * @param runNumber       Run number
    * @param collisionSystem Collision system string 
    * @param cmsNN           Center of mass energy per nucleon pair [GeV]
    * @param field           Magnetic field [kG]
    * @param mc              Monte-carlo switch
    * @param what            What to read in 
    * @param force           Force (re-)reading of specified things
+   * @param satelliteCollisions For satellite collisions
    * 
    * @return true on success
    */
-  Bool_t Init(const char* collisionSystem, 
+  Bool_t Init(ULong_t     runNumber, 
+             const char* collisionSystem, 
              Float_t     cmsNN, 
              Float_t     field, 
              Bool_t      mc=false,
-             UInt_t      what=kAll,
+             Bool_t      satelliteCollisions=false,
+             UInt_t      what=kDefault,
              Bool_t      force=false);
+  /** 
+   * Parse string with fields in it, and return the corresponding bit mask
+   * 
+   * @param what The string 
+   * 
+   * @return The corresponding bit mask
+   */
+  static UInt_t ParseFields(const TString& what);
   /** 
    * Get the eta axis 
    * 
@@ -167,315 +223,69 @@ public:
    * 
    * @return Get the energy loss fits corrections object or null pointer
    */
-  AliFMDCorrELossFit* GetELossFit() const { return fELossFit; }
+  const AliFMDCorrELossFit* GetELossFit() const;
+  /** 
+   * Alias for GetELossFit
+   * 
+   * @return Get the energy loss fits corrections object or null pointer
+   */
+  const AliFMDCorrELossFit* GetELossFits() const { return GetELossFit(); }
   /** 
    * Get the secondary correction map
    * 
    * @return Get the secondary correction map object or null
    */
-  AliFMDCorrSecondaryMap* GetSecondaryMap() const { return fSecondaryMap; }
+  const AliFMDCorrSecondaryMap* GetSecondaryMap() const;
   /** 
    * Get the double hit correction object
    * 
    * @return Get the double hit correction object or null 
    */
-  AliFMDCorrDoubleHit* GetDoubleHit() const { return fDoubleHit; }
+  const AliFMDCorrDoubleHit* GetDoubleHit() const;
   /** 
    * Get the vertex bias correction object
    * 
    * @return Get the vertex bias correction object or null 
    */
-  AliFMDCorrVertexBias* GetVertexBias() const { return fVertexBias; }
+  const AliFMDCorrVertexBias* GetVertexBias() const;
   /** 
    * Get the merging efficiency 
    * 
-   * 
    * @return Get the vertex efficiency correction 
    */
-  AliFMDCorrMergingEfficiency* GetMergingEfficiency() const 
-  {
-    return fMergingEfficiency;
-  }
+  const AliFMDCorrMergingEfficiency* GetMergingEfficiency() const;
   /** 
    * Get the acceptance correction due to dead channels 
    * 
-   * 
    * @return Acceptance correction due to dead channels 
    */
-  AliFMDCorrAcceptance* GetAcceptance() const { return fAcceptance; }
+  const AliFMDCorrAcceptance* GetAcceptance() const;
   /** 
-   * @{ 
-   * @name Path, file, and object access utilities 
-   */
-  /** 
-   * Get the path to the specified object 
-   *
-   * @param what  Which stuff to get the path for 
-   * @param sys   Collision system
-   * @param sNN   Center of mass energy [GeV]
-   * @param field Magnetic field in the L3 magnet [kG]
-   * @param mc    Whether the correction objects should be valid for MC
-   * 
-   * @return The file name (sans directory) or null 
-   */
-  TString GetFileName(ECorrection what, 
-                     UShort_t    sys, 
-                     UShort_t    sNN, 
-                     Short_t     field,
-                     Bool_t      mc) const;
-  /** 
-   * Get the file name of the specified object
-   * 
-   * @param what Which stuff to get the path for 
-   * 
-   * @return The file name (sans directory) or null
-   */
-  TString GetFileName(ECorrection what) const;
-  /** 
-   * Get the path to the specified object 
+   * Get the noise calibration.  That is, the ratio 
    *
-   * @param what  Which stuff to get the path for 
-   * 
-   * @return The files directory full path or null 
-   */
-  const Char_t* GetFileDir(ECorrection what) const;
-  /** 
-   * Get the path to the specified object 
-   *
-   * @param what  Which stuff to get the path for 
-   * @param sys   Collision system
-   * @param sNN   Center of mass energy [GeV]
-   * @param field Magnetic field in the L3 magnet [kG]
-   * @param mc    Whether the correction objects should be valid for MC
-   * 
-   * @return The full path or null 
-   */
-  TString GetFilePath(ECorrection what, 
-                     UShort_t    sys, 
-                     UShort_t    sNN, 
-                     Short_t     field,
-                     Bool_t      mc) const;
-  /** 
-   * Get the full path to the object.  Note, the manager must be
-   * initialised for this to work
-   * 
-   * @param what Which stuff to get the path for 
-   * 
-   * @return The full path or null
-   */
-  TString GetFilePath(ECorrection what) const;
-  /** 
-   * Open the file that contains the correction object specified 
-   * 
-   * @param what  Which stuff to get the path for 
-   * @param sys   Collision system
-   * @param sNN   Center of mass energy [GeV]
-   * @param field Magnetic field in the L3 magnet [kG]
-   * @param mc    Whether the correction objects should be valid for MC
-   * @param rw    Whether to open the file in read/write
-   * @param newfile Wheter to make the file if it doesn't exist
-   * 
-   * @return The file that contains the correction object or null 
-   */
-  TFile* GetFile(ECorrection what, 
-                UShort_t    sys, 
-                UShort_t    sNN, 
-                Short_t     field,
-                Bool_t      mc=false, 
-                Bool_t      rw=false, 
-                Bool_t      newfile=false) const;
-  /** 
-   * Get the file that contains the object specifed.  Note, the manager
-   * must be initialised for this to work. 
-   * 
-   * @param what Which stuff to get the path for 
-   * 
-   * @return The file that contains the correction object or null
-   */
-  TFile* GetFile(ECorrection what) const;
-  /** 
-   * Get the object name corresponding to correction type 
-   * 
-   * @param what Correction 
-   * 
-   * @return Object name or null
-   */
-  const Char_t* GetObjectName(ECorrection what) const;
-  /** 
-   * Check if the specified objet exists in the file, and return it
-   * 
-   * @param file File to query 
-   * @param what Correction type 
-   * 
-   * @return Object found, or null
-   */
-  TObject* CheckObject(TFile* file,  ECorrection what) const;
-  /** 
-   * Get the path to the specified object 
+   * @f[ 
+   *   \frac{\sigma_{i}}{g_{i}k}
+   * @f] 
    *
-   * @param what  Which stuff to get the path for 
-   * @param sys   Collision system
-   * @param sNN   Center of mass energy [GeV]
-   * @param field Magnetic field in the L3 magnet [kG]
-   * @param mc    Whether the correction objects should be valid for MC
-   * 
-   * @return The full path or null 
-   */
-  TObject* GetObject(ECorrection what, 
-                    UShort_t    sys, 
-                    UShort_t    sNN, 
-                    Short_t     field,
-                    Bool_t      mc) const;
-  /** 
-   * Get the object that contaisn the specified correction
-   * 
-   * @param what Which object to get
-   * 
-   * @return The object or null
-   */
-  TObject* GetObject(ECorrection what) const;
-  /* 
-   * @} 
-   */
-  /**
-   * @{ 
-   * @name Misc 
-   */
-  /** 
-   * Print this object 
+   * where @f$ k@f$ is a constant determined by the electronics of
+   * units DAC/MIP, and @f$ \sigma_i, g_i@f$ are the noise and gain of
+   * the @f$ i @f$ strip respectively
    * 
-   * @param option Passed verbatim to correction objects
+   * @return Noise-gain calibration
    */
-  void Print(Option_t* option="") const;
-  /** 
-   * Browse this object 
-   * 
-   * @param b Browser to use 
-   */
-  void Browse(TBrowser* b);
-  /* 
-   * @}
-   */
-  /** 
-   * Write a correction object to (a temporary) file.  
-   *    
-   * @param what   What kind of correction
-   * @param sys    Collision system
-   * @param cms    Center of mass energy
-   * @param field  Field 
-   * @param mc     Whether this is for MC only
-   * @param o      Object to write
-   * @param full   If true, write to full path
-   * 
-   * @return True on success 
-   */
-  Bool_t WriteFile(ECorrection what, 
-                  UShort_t sys, UShort_t cms, Short_t field, Bool_t mc,
-                  TObject* o, Bool_t full) const;
+  const AliFMDCorrNoiseGain* GetNoiseGain() const;
 private:
   /** 
-   * Copy constructor 
-   * 
-   * @param o Object to copy from 
-   */
-  AliForwardCorrectionManager(const AliForwardCorrectionManager& o);
-  /** 
-   * Assignment operator 
-   * 
-   * @param o Object to assign from 
-   * 
-   * @return Reference to this object 
-   */
-  AliForwardCorrectionManager& operator=(const AliForwardCorrectionManager& o);
-  /** 
-   * @{ 
-   * @name Read in corrections 
-   */
-  /** 
-   * Read in the secondary map 
-   * 
-   * @param sys   Collision system
-   * @param sNN   Center of mass energy [GeV]
-   * @param field Magnetic field in the L3 magnet [kG]
-   * 
-   * @return True on success, false otherwise 
-   */
-  Bool_t ReadSecondaryMap(UShort_t sys, UShort_t sNN, Short_t field);
-  /** 
-   * Read in the double hit correction
-   * 
-   * @param sys   Collision system
-   * @param sNN   Center of mass energy [GeV]
-   * @param field Magnetic field in the L3 magnet [kG]
-   * 
-   * @return True on success, false otherwise 
-   */
-  Bool_t ReadDoubleHit(UShort_t sys, UShort_t sNN, Short_t field);
-  /** 
-   * Read in the energy loss fits 
-   * 
-   * @param sys   Collision system
-   * @param sNN   Center of mass energy [GeV]
-   * @param field Magnetic field in the L3 magnet [kG]
-   * @param mc    Whether the correction objects should be valid for MC
-   * 
-   * @return True on success, false otherwise 
-   */
-  Bool_t ReadELossFits(UShort_t sys, UShort_t sNN, Short_t field, Bool_t mc);
-  /** 
-   * Read in the event selection efficiency 
-   * 
-   * @param sys   Collision system
-   * @param sNN   Center of mass energy [GeV]
-   * @param field Magnetic field in the L3 magnet [kG]
+   * Non-default constructor - initializes corrections - used by
+   * singleton access member function Instance
    * 
-   * @return True on success, false otherwise 
-   */
-  Bool_t ReadVertexBias(UShort_t sys, UShort_t sNN, Short_t field);
-  /** 
-   * Read in the merging efficiency 
-   * 
-   * @param sys   Collision system
-   * @param sNN   Center of mass energy [GeV]
-   * @param field Magnetic field in the L3 magnet [kG]
-   * 
-   * @return True on success, false otherwise 
-   */
-  Bool_t ReadMergingEfficiency(UShort_t sys, UShort_t sNN, Short_t field);
-  /** 
-   * Read in the acceptance correction due to dead-channels 
-   * 
-   * @param sys   Collision system                   
-   * @param sNN   Center of mass energy [GeV]        
-   * @param field Magnetic field in the L3 magnet [kG]
-   * 
-   * @return True on success, false otherwise 
-   */
-  Bool_t ReadAcceptance(UShort_t sys, UShort_t sNN, Short_t field);
-  /* 
-   * @} 
+   * @param notUsed Ignored
    */
+  AliForwardCorrectionManager(Bool_t notUsed);
   
   /** Static singleton instance */
   static AliForwardCorrectionManager* fgInstance; // Skeleton
-  Bool_t    fInit;  // whether we have been initialised 
-  UShort_t  fSys;   // Collision System
-  UShort_t  fSNN;   // Collision energy per nucleon (GeV)
-  Short_t   fField; // L3 magnetic field (kG)
-  
-  /** 
-   * @{
-   * @name Paths 
-   */ 
-  TString fELossFitsPath;    // Path to energy loss fit correction 
-  TString fMergingEffPath;   // Path to sharing efficiency correction 
-  TString fSecondaryMapPath; // Path to secondary efficiency correction
-  TString fDoubleHitPath;    // Path to double hit correction
-  TString fVertexBiasPath;   // Path to event selection efficiency correction
-  TString fAcceptancePath;   // Path to acceptance correction from dead areas
-  /* 
-   * @}
-   */
+
   /** 
    * @{ 
    * @name Object name 
@@ -486,38 +296,12 @@ private:
   static const Char_t* fgkVertexBiasSkel;    // Name of correction object 
   static const Char_t* fgkMergingEffSkel;    // Name of correction object 
   static const Char_t* fgkAcceptanceSkel;    // Name of correction object 
+  static const Char_t* fgkNoiseGainSkel;     // Name of correction object 
   /* 
    * @} 
    */
-  /** 
-   * @{ 
-   * @name Correction objects 
-   */
-  AliFMDCorrELossFit*          fELossFit;     // Energy loss fits 
-  AliFMDCorrSecondaryMap*      fSecondaryMap; // Secondary particle correction
-  AliFMDCorrDoubleHit*         fDoubleHit;    // Double hit corr. (low flux)
-  AliFMDCorrVertexBias*        fVertexBias;   // Vertex bias correction
-  AliFMDCorrMergingEfficiency* fMergingEfficiency; // Merging eff. 
-  AliFMDCorrAcceptance*        fAcceptance;   // Acceptance corr. 
-  /* 
-   * @}
-   */
-  ClassDef(AliForwardCorrectionManager,2) // Manager of corrections 
+  ClassDef(AliForwardCorrectionManager,5) // Manager of corrections 
 };
-//____________________________________________________________________
-inline const TAxis* 
-AliForwardCorrectionManager::GetEtaAxis() const
-{
-  if (!fSecondaryMap) return 0;
-  return &(fSecondaryMap->GetEtaAxis());
-}
-//____________________________________________________________________
-inline const TAxis* 
-AliForwardCorrectionManager::GetVertexAxis() const
-{
-  if (!fSecondaryMap) return 0;
-  return &(fSecondaryMap->GetVertexAxis());
-}
 
 #endif
 // Local Variables: