]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGLF/FORWARD/analysis2/AliForwardUtil.h
Updates
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliForwardUtil.h
index 8eae47aa9d7293ce9ec4be8aed33987879a9c9b3..030362c0ebfc599a9d07a812c272f99835f3905b 100644 (file)
@@ -22,7 +22,10 @@ class TH1I;
 class TH1;
 class TF1;
 class TAxis;
+class TArrayD;
 class AliESDEvent;
+class AliAODEvent;
+class AliAnalysisTaskSE;
 
 /** 
  * Utilities used in the forward multiplcity analysis 
@@ -32,6 +35,9 @@ class AliESDEvent;
 class AliForwardUtil : public TObject
 {
 public:
+  enum { 
+    kSkipRing = (1 << 19) // Bit for skipping a histogram
+  };
   /** 
    * Get the standard color for a ring  
    *
@@ -46,6 +52,29 @@ public:
            + ((r == 'I' || r == 'i') ? 2 : -3));
   }
   //==================================================================
+  /** 
+   * @{ 
+   * @name AliROOT version
+   */
+  /** 
+   * Get the revision number of AliROOT
+   * 
+   * @return Subversion revision number of AliROOT used
+   */
+  static ULong_t AliROOTRevision();
+  /**
+   * Get the branch identifier of AliROOT.  In case of trunk, return
+   * 0xFFFFFFFF, while for @b vM-N-R{-S}, we get
+   *
+   * @code 
+   *    ((M & 0xFF) << 12 | (N & 0xFF) << 8 | (R & 0xFF) << 3 | (X))
+   * @endcode 
+   * where @c X is 0xAA if @b S is specified (e.g., analysis tag). 
+   *
+   * @return branch identifer encoded in bits 
+   */
+  static ULong_t AliROOTBranch();
+  //==================================================================
   /** 
    * @{ 
    * @name Collision/run parameters 
@@ -60,6 +89,44 @@ public:
     kPPb
   };
   //__________________________________________________________________
+  /** 
+   * Calculate the beam rapidity. 
+   *
+   * @b Note: The beam energy is given in GeV/charge
+   * 
+   * @param beam Beam energy in GeV/charge 
+   * @param z    Charge number of projectile
+   * @param a    Mass number of projectile 
+   * 
+   * @return The rapidity of the beam
+   */
+  static Float_t BeamRapidity(Float_t beam, UShort_t z, UShort_t a);
+  /** 
+   * Calculate the center of mass energy from the beam energy per
+   * charge and the nucleus numbers.
+   * 
+   * @param beam Beam energy in GeV/charge 
+   * @param z1   Charge number of projectile
+   * @param a1   Mass number of projectile
+   * @param z2   Charge number of projectile
+   * @param a2          Mass number of projectile  
+   * 
+   * @return The center of mass energy in GeV/nucleon
+   */
+  static Float_t CenterOfMassEnergy(Float_t beam, UShort_t z1, UShort_t a1, 
+                                   Short_t z2=-1, Short_t a2=-1);
+  /** 
+   * Calculate the center of mass rapidity (shift)
+   * 
+   * @param z1 Charge number of projectile
+   * @param a1 Mass number of projectile  
+   * @param z2 Charge number of projectile
+   * @param a2 Mass number of projectile  
+   * x
+   * @return Rapidity of the center of mass 
+   */
+  static Float_t CenterOfMassRapidity(UShort_t z1, UShort_t a1, 
+                                     Short_t z2=-1, Short_t a2=-1);
   /** 
    * Parse a collision system spec given in a string.   Known values are 
    * 
@@ -113,6 +180,30 @@ public:
    * @return Short integer value of magnetic field in kG 
    */
   static Short_t ParseMagneticField(Float_t field);
+  /** 
+   * Get a string representation of the magnetic field
+   * 
+   * @param field Magnetic field in kG
+   * 
+   * @return String representation of the magnetic field
+   */
+  static const char* MagneticFieldString(Short_t field);
+  /* @} */
+
+  //==================================================================
+  /** 
+   * @{ 
+   * @name Recalculate @f$\eta@f$, @f$\phi@f$, etc. 
+   */
+  /** 
+   * Get the radius of a strip. 
+   * 
+   * @param ring  Ring identifier 'I' or 'O'
+   * @param strip Strip number 
+   * 
+   * @return Radial distance from beam of the strip 
+   */
+  static Double_t GetStripR(Char_t ring, UShort_t strip);
   /** 
    * Get eta from strip
    * 
@@ -120,17 +211,89 @@ public:
    * 
    * @return eta
    */
-  static Double_t GetEtaFromStrip(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, Double_t zvtx) ;
+  static Double_t GetEtaFromStrip(UShort_t det, Char_t ring, 
+                                 UShort_t sec, UShort_t strip, Double_t zvtx);
   /** 
-   * Get a string representation of the magnetic field
+   * Get the azimuthal angle of a strip
    * 
-   * @param field Magnetic field in kG
+   * @param ring  Ring identifier 'I' or 'O'
+   * @param strip Strip number 
+   * @param phi   Straight forward strip phi
+   * @param xvtx  Ip X coordinate 
+   * @param yvtx  Ip Y coordinate 
    * 
-   * @return String representation of the magnetic field
+   * @return The phi angle correctef for (X,Y) off set. 
+   */  
+  static Double_t GetPhiFromStrip(Char_t ring, UShort_t strip, 
+                                 Double_t phi, Double_t xvtx, Double_t yvtx);
+  /* @} */
+
+  //==================================================================
+  /** 
+   * @{ 
+   * @name Manager related tasks 
+   */
+  /** 
+   * Get the AOD event - either from the input (AOD analysis) or the
+   * output (ESD analysis)
+   * 
+   * @param task Task to do the investigation for
+   * 
+   * @return Found AOD event or null
+   */
+  static AliAODEvent* GetAODEvent(AliAnalysisTaskSE* task);
+  /** 
+   * Check if we have something that will provide and AOD event 
+   * 
+   * @return 0 if there's nothing that provide an AOD event, 1 if it
+   * is provided on the input (AOD analysis) or 2 if it is provided on
+   * the output (ESD analysis)
+   */
+  static UShort_t CheckForAOD();
+  /** 
+   * Check if we have a particular (kind) of task in our train
+   * 
+   * @param clsOrName  Class name or name of task 
+   * @param cls If true, look for a task of a particular class -
+   * otherwise search for a speficially name task
+   * 
+   * @return true if the needed task was found 
+   */
+  static Bool_t CheckForTask(const char* clsOrName, Bool_t cls=true);
+  /* @} */
+
+  //==================================================================
+  /** 
+   * @{ 
+   * @name Member functions to store and retrieve analysis parameters 
+   */
+  static TObject* MakeParameter(const char* name, UShort_t value);
+  static TObject* MakeParameter(const char* name, Int_t value);
+  static TObject* MakeParameter(const char* name, Double_t value);
+  static TObject* MakeParameter(const char* name, Bool_t value);
+  static TObject* MakeParameter(const char* name, ULong_t value);
+  static void GetParameter(TObject* o, UShort_t& value);
+  static void GetParameter(TObject* o, Int_t& value);
+  static void GetParameter(TObject* o, Double_t& value);
+  static void GetParameter(TObject* o, Bool_t& value);
+  static void GetParameter(TObject* o, ULong_t& value);
+  /* @} */
+
+  //==================================================================
+  /** 
+   * @{ 
+   * @name Axis functions 
    */
-   static const char* MagneticFieldString(Short_t field);
+  static TAxis* MakeFullIpZAxis(Int_t nCenter=20);
+  static void MakeFullIpZAxis(Int_t nCenter, TArrayD& bins);
+  static void MakeLogScale(Int_t nBins, Int_t minOrder, Int_t maxOrder, TArrayD& bins);
+  static void PrintTask(const TObject& o);
+  static void PrintName(const char* name);
+  static void PrintField(const char* name, const char* value, ...);
   /* @} */
 
+  //==================================================================
+#if 0 // Moved to separate classes
   /** 
    * @{ 
    * @name Energy stragling functions 
@@ -367,8 +530,9 @@ public:
      * 
      */
     virtual ~ELossFitter();
+    void SetDebug(Bool_t debug=true) { fDebug = debug; }
     /** 
-     * Clear internal arrays 
+     * Clear internal arrays
      * 
      */
     void Clear();
@@ -399,6 +563,18 @@ public:
      * @return The function fitted to the data 
      */
     TF1* FitNParticle(TH1* dist, UShort_t n, Double_t sigman=-1);
+    /** 
+     * Fit a composite distribution of energy loss from both primaries
+     * and secondaries
+     * 
+     * @param dist   Distribution 
+     * @param sigman If larger than zero, the initial guess of the
+     *                detector included noise.  If zero or less this
+     *                parameter is fixed to 0.
+     * 
+     * @return Function fitted to the data 
+     */
+    TF1* FitComposite(TH1* dist, Double_t sigman);
     /**
      * Get Lower cut on data 
      *
@@ -447,9 +623,10 @@ public:
     const UShort_t fMinusBins;  // Number of bins from maximum to fit 1st peak
     TObjArray fFitResults;      // Array of fit results 
     TObjArray fFunctions;       // Array of functions 
+    Bool_t    fDebug;
   };
   /* @} */
-      
+#endif      
 
   //==================================================================
   /** 
@@ -489,15 +666,28 @@ public:
      */
     Histos& operator=(const Histos&) { return *this;}
     /** 
-     * Destructor
+     * Destructor.  This does not delete the interally allocated
+     * memory.  Use the member function Delete for that.
      */
     ~Histos();
+    /** 
+     * Clear internal memory.  Note, if the internal histograms are
+     * added to an output container, then we must not free this
+     * memory.
+     */
+    void Delete(Option_t* opt="");
     /** 
      * Initialize the object 
      * 
      * @param etaAxis Eta axis to use 
      */
     void Init(const TAxis& etaAxis);
+    /** 
+     * Re-initialize the object with new @f$\eta@f$ axis 
+     * 
+     * @param etaAxis Eta axis to use 
+     */
+    void ReInit(const TAxis& etaAxis);
     /** 
      * Make a histogram 
      * 
@@ -507,7 +697,14 @@ public:
      * 
      * @return Newly allocated histogram 
      */
-    TH2D* Make(UShort_t d, Char_t r, const TAxis& etaAxis) const;
+    static TH2D* Make(UShort_t d, Char_t r, const TAxis& etaAxis);
+    /** 
+     * Set the @f$\eta@f$ axis 
+     * 
+     * @param hist    Histogram
+     * @param etaAxis @f$\eta@f$ axis to use
+     */
+    static void RebinEta(TH2D* hist, const TAxis& etaAxis);
     /** 
      * Clear data 
      * 
@@ -530,7 +727,7 @@ public:
     TH2D* fFMD3i; // Histogram for FMD3i
     TH2D* fFMD3o; // Histogram for FMD3o
 
-    ClassDef(Histos,1
+    ClassDef(Histos,2
   };
 
   //__________________________________________________________________
@@ -545,7 +742,7 @@ public:
      * Constructor
      * 
      */
-    RingHistos() : fDet(0), fRing('\0'), fName("") {}
+    RingHistos() : fDet(0), fRing('\0'), fName(""), fkNSector(0), fkNStrip(0) {}
     /** 
      * 
      * 
@@ -553,7 +750,9 @@ public:
      * @param r Ring 
      */
     RingHistos(UShort_t d, Char_t r) 
-      : fDet(d), fRing(r), fName(TString::Format("FMD%d%c", d, r)) 
+      : fDet(d), fRing(r), fName(TString::Format("FMD%d%c", d, r)),
+       fkNSector(r == 'i' || r == 'I' ? 20 : 40), 
+       fkNStrip(r == 'i' || r == 'I' ? 512 : 256)
     {}
     /** 
      * Copy constructor
@@ -561,7 +760,8 @@ public:
      * @param o Object to copy from 
      */
     RingHistos(const RingHistos& o) 
-      : TObject(o), fDet(o.fDet), fRing(o.fRing), fName(o.fName)
+      : TObject(o), fDet(o.fDet), fRing(o.fRing), fName(o.fName),
+       fkNSector(o.fkNSector), fkNStrip(o.fkNStrip)
     {}
     /** 
      * 
@@ -581,6 +781,8 @@ public:
       fDet  = o.fDet;
       fRing = o.fRing;
       fName = o.fName;
+      fkNSector = o.fkNSector;
+      fkNStrip  = o.fkNStrip;
       return *this;
     }
     /** 
@@ -609,7 +811,7 @@ public:
      */
     TH1* GetOutputHist(const TList* d, const char* name) const;
     /** 
-     * 
+     * Get the colour of this ring 
      * 
      * 
      * @return 
@@ -618,30 +820,98 @@ public:
     { 
       return AliForwardUtil::RingColor(fDet, fRing);
     }
+    /** 
+     * The name of this ring 
+     * 
+     * @return Name of this ring 
+     */
     const char* GetName() const { return fName.Data(); } 
+    /** 
+     * Get number of sectors 
+     */
+    const UShort_t& NSector() const { return fkNSector; }
+    /** 
+     * Get number of strips 
+     */
+    const UShort_t& NStrip() const { return fkNStrip; }
     UShort_t fDet;   // Detector
     Char_t   fRing;  // Ring
     TString  fName;  // Name
+    UShort_t fkNSector; // Number of sectors 
+    UShort_t fkNStrip;  // Number of strips 
 
     ClassDef(RingHistos,1) 
   };
   /* @} */
 
   //__________________________________________________________________
+  /**
+   * A guard idom for producing debug output 
+   * 
+   */
   struct DebugGuard 
   {
+    /** 
+     * Constructor 
+     * 
+     * @param lvl       Current level
+     * @param msgLvl    Target level 
+     * @param format    @c printf -like format
+     * 
+     * @return 
+     */
     DebugGuard(Int_t lvl, Int_t msgLvl, const char* format, ...);
+    /** 
+     * Destructor
+     */
     ~DebugGuard();
+    /** 
+     * Make a message 
+     * 
+     * @param lvl    Current level
+     * @param msgLvl Target level 
+     * @param format @c printf -like format
+     */
     static void Message(Int_t lvl, Int_t msgLvl, const char* format, ...);
   private:
+    /** 
+     * Output the message 
+     * 
+     * @param in    Direction
+     * @param msg   Message 
+     */
     static void Output(int in, TString& msg);
+    /** 
+     * Format a message 
+     * 
+     * @param out     Output is stored here
+     * @param format  @c printf -like format
+     * @param ap      List of arguments
+     */
     static void Format(TString& out, const char* format, va_list ap);
     TString fMsg;
   };
 private:
+  /** 
+   * Constructor 
+   */
   AliForwardUtil() {}
+  /** 
+   * Copy constructor 
+   * 
+   * @param o Object to copy from 
+   */
   AliForwardUtil(const AliForwardUtil& o) : TObject(o) {}
+  /** 
+   * Assingment operator 
+   * 
+   * 
+   * @return Reference to this object 
+   */
   AliForwardUtil& operator=(const AliForwardUtil&) { return *this; }
+  /** 
+   * Destructor
+   */
   ~AliForwardUtil() {}
   
 
@@ -651,8 +921,22 @@ private:
 // #ifdef LOG_NO_DEBUG
 // # define DGUARD(L,N,F,...) do {} while(false) 
 // #else
+/** 
+ * Macro to declare a DebugGuard
+ * 
+ * @param L Current debug level
+ * @param N Target debug level
+ * @param F @c printf -like Format 
+ */
 # define DGUARD(L,N,F,...)                                     \
   AliForwardUtil::DebugGuard _GUARD(L,N,F, ## __VA_ARGS__)
+/** 
+ * Macro to make a debug message, using DebugGuard::Message
+ * 
+ * @param L Current debug level
+ * @param N Target debug level
+ * @param F @c printf -like Format 
+ */
 # define DMSG(L,N,F,...)                                       \
   AliForwardUtil::DebugGuard::Message(L,N,F, ## __VA_ARGS__)
 // #endif