]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Important bug fix in the maps used by FMD (Christian)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 Dec 2006 11:56:01 +0000 (11:56 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 Dec 2006 11:56:01 +0000 (11:56 +0000)
ESDCheck/AliFMDQATask.cxx
STEER/AliESDFMD.cxx
STEER/AliESDFMD.h
STEER/AliFMDFloatMap.h
STEER/AliFMDMap.cxx
STEER/AliFMDMap.h

index 56bb1279095e0d78cf04137b6867c7eb587d8829..11e3115aa07a4a94e1885afafe3006f4dc3a4de5 100644 (file)
@@ -130,6 +130,7 @@ void AliFMDQATask::Exec(Option_t *)
   // ************************  FMD *************************************
  
   AliESDFMD * fmd = fESD->GetFMDData() ;
+  fmd->CheckNeedUShort(fChain->GetFile());
 
   Int_t nFMD1 = 0, nFMD2i = 0, nFMD2o = 0, nFMD3i = 0, nFMD3o = 0 ;
   
index 61f5a68f4480803d615b5c8ea046143e9c438767..94392820e00ab101d2a2bb2efd865c1238c198a8 100755 (executable)
@@ -43,7 +43,8 @@ AliESDFMD::AliESDFMD()
     fEta(AliFMDFloatMap::kMaxDetectors, 
         AliFMDFloatMap::kMaxRings, 
         1,
-        AliFMDFloatMap::kMaxStrips)
+        AliFMDFloatMap::kMaxStrips), 
+    fAngleCorrected(kFALSE)
 {
   // Default CTOR
 }
@@ -67,6 +68,14 @@ AliESDFMD::operator=(const AliESDFMD& other)
   return *this;
 }
 
+//____________________________________________________________________
+void
+AliESDFMD::CheckNeedUShort(TFile* file) 
+{
+  fMultiplicity.CheckNeedUShort(file);
+  fEta.CheckNeedUShort(file);
+}
+
 //____________________________________________________________________
 void
 AliESDFMD::Clear(Option_t* )
index e2431c51bafe2a0db66980f88865919fa4af7c5b..098cbcfdb6eff1b7531b8e4f6b7653a279e1af96 100755 (executable)
 #endif
 
 //___________________________________________________________________
+/** @class AliESDFMD 
+    @brief Event Summary Data for the Forward Multiplicity Detector. 
+    @ingroup FMD_data
+    This stores the psuedo-multiplicity and -rapidiy for each strip of
+    the FMD. 
+ */
 class AliESDFMD : public TObject
 {
 public:
+  /** Default constructor */
   AliESDFMD();
+  /** Copy constructor 
+      @param other Object to construct from */
   AliESDFMD(const AliESDFMD& other);
+  /** Assignment operator 
+      @param other Object to assign from
+      @return  reference to this object */
   AliESDFMD& operator=(const AliESDFMD& other);
+  /** Destructor - does nothing */
   virtual ~AliESDFMD() {}
 
   void Clear(Option_t *option="");
+  /** Get the pseudo-multiplicity of 
+      @f$ \text{FMD}\langle detector\rangle\lange ring\rangle_{\langle
+      sector\rangle\langle strip\rangle}@f$ 
+      @param detector Detector number (1-3)
+      @param ring     Ring identifier ('I' or 'O')
+      @param sector   Sector number (0-511, or 0-255)
+      @param strip    Strip number (0-19, or 0-39)
+      @return Psuedo multiplicity */
   Float_t Multiplicity(UShort_t detector, Char_t ring, 
                       UShort_t sector, UShort_t strip) const;
+  /** Get the pseudo-rapidity of 
+      @f$ \text{FMD}\langle detector\rangle\lange ring\rangle_{\langle
+      sector\rangle\langle strip\rangle}@f$ 
+      @param detector Detector number (1-3)
+      @param ring     Ring identifier ('I' or 'O')
+      @param sector   Sector number (0-511, or 0-255)
+      @param strip    Strip number (0-19, or 0-39)
+      @return Psuedo rapidity */
   Float_t Eta(UShort_t detector, Char_t ring, 
              UShort_t sector, UShort_t strip) const;
+  /** Set the pseudo-multiplicity of 
+      @f$ \text{FMD}\langle detector\rangle\lange ring\rangle_{\langle
+      sector\rangle\langle strip\rangle}@f$ 
+      @param detector Detector number (1-3)
+      @param ring     Ring identifier ('I' or 'O')
+      @param sector   Sector number (0-511, or 0-255)
+      @param strip    Strip number (0-19, or 0-39)
+      @param mult     Psuedo multiplicity */
   void SetMultiplicity(UShort_t detector, Char_t ring, 
                       UShort_t sector, UShort_t strip, 
                       Float_t mult);
+  /** Set the pseudo-rapidity of 
+      @f$ \text{FMD}\langle detector\rangle\lange ring\rangle_{\langle
+      sector\rangle\langle strip\rangle}@f$ 
+      @param detector Detector number (1-3)
+      @param ring     Ring identifier ('I' or 'O')
+      @param sector   Sector number (0-511, or 0-255)
+      @param strip    Strip number (0-19, or 0-39)
+      @param eta      Psuedo rapidity */
   void SetEta(UShort_t detector, Char_t ring, 
              UShort_t sector, UShort_t strip, 
-             Float_t mult);
-
+             Float_t eta);
+  /** @param f the factor for noise suppression */
+  void SetNoiseFactor(Float_t f) { fNoiseFactor = f; }
+  /** @param done Whether we've done angle correction or not */
+  void SetAngleCorrected(Bool_t done) { fAngleCorrected = done; }
+  /** @return Whether we've done angle correction or not */
+  Bool_t IsAngleCorrecte() const { return fAngleCorrected; }
+  /** @return the  factor for noise suppression */
+  Float_t GetNoiseFactor() const { return fNoiseFactor; }
+  /** @return maximum number of detectors */
   UShort_t MaxDetectors() const { return fMultiplicity.MaxDetectors(); }
+  /** @return maximum number of rings */
   UShort_t MaxRings()     const { return fMultiplicity.MaxRings(); }
+  /** @return maximum number of sectors */
   UShort_t MaxSectors()   const { return fMultiplicity.MaxSectors(); }
+  /** @return Maximum number of strips */
   UShort_t MaxStrips()    const { return fMultiplicity.MaxStrips(); }
+  /** Print this object to standard out. 
+      @param option Options */
   void Print(Option_t* option="") const;
+  /** Check if we need the @c UShort_t fix 
+      @param file File this object was read from */
+  void CheckNeedUShort(TFile* file);
   enum {
+    /** Value used for undefined multiplicity */
     kInvalidMult = 1000
   };
   enum {
+    /** Value used for undefined pseudo rapidity */
     kInvalidEta = 1000
   };
+  /** @return constant reference to multiplicity map */
+  const AliFMDFloatMap& MultiplicityMap() const { return fMultiplicity; }
+  /** @return constant reference to pseudo-rapidity map */
+  const AliFMDFloatMap& EtaMap() const { return fMultiplicity; }
 protected:
-  AliFMDFloatMap fMultiplicity; // Psuedo multplicity per strip
-  AliFMDFloatMap fEta;          // Psuedo-rapidity per strip
-  
-  ClassDef(AliESDFMD,2)  // ESD info from FMD
+  AliFMDFloatMap fMultiplicity;   // Psuedo multplicity per strip
+  AliFMDFloatMap fEta;            // Psuedo-rapidity per strip
+  Float_t        fNoiseFactor;    // Factor used for noise suppresion
+  Bool_t         fAngleCorrected; // Whether we've done angle correction
+  ClassDef(AliESDFMD,3)           // ESD info from FMD
 };
 #endif
 //____________________________________________________________________
index 01b12180ed6f6a4b2a4c54269575be08ed7d2172..26f4b7d3ce2e399434d55aae723aedc1a349b73f 100755 (executable)
@@ -36,6 +36,7 @@ public:
                                    Char_t   ring,
                                    UShort_t sec,
                                    UShort_t str) const;
+  Float_t* Data() const { return fData; }
 protected:
   Int_t   fTotal;  // Total number of entries
   Float_t* fData;   //[fTotal]
index c710f78e5c2e6dbd7fb37763f0783f221e33d2a2..f2e49a9775b711cc62a2536e16aff45b97811a54 100755 (executable)
 //
 #include "AliFMDMap.h"         // ALIFMDMAP_H
 #include "AliLog.h"
+//#include <TClass.h>
+//#include <TBuffer.h>
+#include <TFile.h>
+#include <TList.h>
+#include <TStreamerInfo.h>
 
 //____________________________________________________________________
 ClassImp(AliFMDMap)
@@ -49,8 +54,19 @@ AliFMDMap::AliFMDMap(UShort_t maxDet,
   //     maxRinf      Maximum # of rings
   //     maxSec       Maximum # of sectors
   //     maxStr       Maximum # of strips
+  SetBit(kNeedUShort, kFALSE);
 }
 
+//____________________________________________________________________
+void
+AliFMDMap::CheckNeedUShort(TFile* file) 
+{
+  if (!file) return;
+  TObject* o = file->GetStreamerInfoList()->FindObject(ClassName());
+  if (!o) return;
+  TStreamerInfo* info = static_cast<TStreamerInfo*>(o);
+  if (info->GetClassVersion() == 2) SetBit(kNeedUShort);
+}
 //____________________________________________________________________
 Int_t 
 AliFMDMap::CheckIndex(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) const
@@ -59,9 +75,11 @@ AliFMDMap::CheckIndex(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) con
   // on error. 
   if (det < 1) return -1;
   UShort_t ringi = (ring == 'I' ||  ring == 'i' ? 0 : 1);
-  UShort_t idx = 
+  Int_t idx = 
     (str + fMaxStrips * (sec + fMaxSectors * (ringi + fMaxRings * (det-1))));
-  if (idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) return -1;
+  if (TestBit(kNeedUShort)) idx = UShort_t(idx);
+  if (idx < 0 || idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) 
+    return -1;
   return idx;
 }
 
@@ -94,6 +112,27 @@ AliFMDMap::CalcIndex(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) cons
   return idx;
 }
 
+#if 0
+//___________________________________________________________________
+void AliFMDMap::Streamer(TBuffer &R__b)
+{
+  // Stream an object of class AliFMDMap.
+  // This is overridden so that we can know the version of the object
+  // that we are reading in.  In this way, we can fix problems that
+  // might occur in the class. 
+  if (R__b.IsReading()) {
+    // read the class version from the buffer
+    UInt_t R__s, R__c;
+    Version_t version = R__b.ReadVersion(&R__s, &R__c, this->Class());
+    TFile *file = (TFile*)R__b.GetParent();
+    if (file && file->GetVersion() < 30000) version = -1; 
+    AliFMDMap::Class()->ReadBuffer(R__b, this, version, R__s, R__c);
+    if (version == 2) SetBit(kNeedUShort);
+  } else {
+    AliFMDMap::Class()->WriteBuffer(R__b, this);
+  }
+}
+#endif
 
 //___________________________________________________________________
 //
index f50843395dd01d2230c2f3ddee5cfd912144dc0e..6ffdc68dc5b6685afc955aeb4d46e817a516970b 100755 (executable)
 #ifndef ROOT_TObject
 # include <TObject.h>
 #endif 
+class TFile;
+
 //____________________________________________________________________
-//
-// Base class for caches of per-strip information.
-// This is used to index a strip. 
-// Data stored depends on derived class. 
-//
+/** @class AliFMDMap
+    @brief Base class for caches of per-strip information.
+    @ingroup FMD_data
+    This is used to index a strip. Data stored depends on derived
+    class.  */
 class AliFMDMap : public TObject 
 {
 public:
   enum { 
+    /** Default maximum detector number */
     kMaxDetectors = 3, 
+    /** Default maximum number of rings */
     kMaxRings     = 2, 
+    /** Default maximum number of sectors */
     kMaxSectors   = 40, 
+    /** Default maximum number of strips */
     kMaxStrips    = 512
   };
+  /** Constructor 
+      @param maxDet  Maximum allowed detector number
+      @param maxRing Maximum number of rings
+      @param maxSec  Maximum number of sectors
+      @param maxStr  Maximum number of strips
+      @return  */
   AliFMDMap(UShort_t maxDet = kMaxDetectors, 
            UShort_t maxRing= kMaxRings, 
            UShort_t maxSec = kMaxSectors, 
            UShort_t maxStr = kMaxStrips);
+  /** Destructor */
   virtual ~AliFMDMap() {}
+  /** @return  Maximum detector number */
   UShort_t MaxDetectors() const { return fMaxDetectors; }
+  /** @return  Maximum number of rings */
   UShort_t MaxRings()     const { return fMaxRings; }
+  /** @return  Maximum number of sectors */
   UShort_t MaxSectors()   const { return fMaxSectors; }
+  /** @return  Maximum number of strip */
   UShort_t MaxStrips()    const { return fMaxStrips; }
+  /** Calculate, check, and return index for strip.  If the index is
+      invalid, -1 is returned
+      @param det   Detector number
+      @param ring  Ring identifier
+      @param sec   Sector number 
+      @param str   Strip number
+      @return  Unique index, or -1 in case of errors */
   Int_t  CheckIndex(UShort_t det, Char_t ring, 
                    UShort_t sec, UShort_t str) const;
+  /** Check if we need UShort_t hack 
+      @param file File this object was read from */
+  void CheckNeedUShort(TFile* file);
+  enum {
+    /** In case of version 2 of this class, this bit should be set. */
+    kNeedUShort = 14
+  };
 protected:
+  /** Calculate index and return 
+      @param det  Detector number
+      @param ring Ring identifier 
+      @param sec  Sector number 
+      @param str  Strip number 
+      @return  Index (not checked) */
   Int_t CalcIndex(UShort_t det, Char_t ring, 
-                  UShort_t sec, UShort_t str) const;
+                 UShort_t sec, UShort_t str) const;
   UShort_t fMaxDetectors;             // Maximum # of detectors
   UShort_t fMaxRings;                 // Maximum # of rings
   UShort_t fMaxSectors;               // Maximum # of sectors
   UShort_t fMaxStrips;                // Maximum # of strips
-  ClassDef(AliFMDMap, 2) // Cache of per strip information
-};
 
-#ifdef  MAY_USE_TEMPLATES
-#ifndef __VECTOR__
-# include <vector>
-#endif 
-//____________________________________________________________________
-//
-// Class template for classes that cache per strip information.  
-// Access to the data goes via 
-//
-//   Type& AliFMDMap<Type>::operator()(UShort_t detector,
-//                                     Char_t ring, 
-//                                     UShort_t sector,
-//                                     UShort_t strip);
-// 
-// (as well as a const version of this member function). 
-// The elements can be reset to the default value by calling 
-// AliFMDMap<Type>::Clear().  This resets the values to `Type()'. 
-//
-template <typename Type> 
-class AliFMDMap : public TObject 
-{
-public:
-  AliFMDMap(UShort_t maxDet=3, UShort_t maxRing=2, UShort_t maxSec=40, 
-           UShort_t maxStr=512);
-  virtual ~AliFMDMap() {}
-  void Clear(const Type& val=Type());
-  Type& operator()(UShort_t det, Char_t ring, UShort_t sec, UShort_t str);
-  const Type& operator()(UShort_t det, Char_t ring, 
-                        UShort_t sec, UShort_t str)const;
-private:
-  typedef std::vector<Type> ValueVector; // Type of container
-  ValueVector fValues;                   // Contained values
-  UShort_t      fMaxDetectors;             // Maximum # of detectors
-  UShort_t      fMaxRings;                 // Maximum # of rings
-  UShort_t      fMaxSectors;               // Maximum # of sectors
-  UShort_t      fMaxStrips;                // Maximum # of strips
-  
-  UShort_t CalcIndex(UShort_t det, Char_t ring, 
-                    UShort_t sec, UShort_t str) const;
-  ClassDef(AliFMDMap, 0); // Map of FMD index's to values 
+  ClassDef(AliFMDMap, 3) // Cache of per strip information
 };
 
-
-//____________________________________________________________________
-template <typename Type>
-inline 
-AliFMDMap<Type>::AliFMDMap(UShort_t maxDet, 
-                          UShort_t maxRing, 
-                          UShort_t maxSec, 
-                          UShort_t maxStr)
-  : fValues(maxDet * maxRing * maxSec * maxStr), 
-    fMaxDetectors(maxDet), 
-    fMaxRings(maxRing), 
-    fMaxSectors(maxSec), 
-    fMaxStrips(maxStr)
-{
-  // Construct a map
-  //
-  // Parameters:
-  //     maxDet       Maximum # of detectors
-  //     maxRinf      Maximum # of rings
-  //     maxSec       Maximum # of sectors
-  //     maxStr       Maximum # of strips
-}
-
-
-//____________________________________________________________________
-template <typename Type>
-inline UShort_t 
-AliFMDMap<Type>::CalcIndex(UShort_t det, Char_t ring, 
-                          UShort_t sec, UShort_t str) const
-{
-  // Calculate index into storage from arguments. 
-  // 
-  // Parameters: 
-  //     det       Detector #
-  //     ring      Ring ID
-  //     sec       Sector # 
-  //     str       Strip # 
-  //
-  // Returns appropriate index into storage 
-  //
-  UShort_t ringi = (ring == 'I' ||  ring == 'i' ? 0 : 1);
-  UShort_t idx = 
-    (det + fMaxDetectors * (ringi + fMaxRings * (sec + fMaxSectors * str)));
-  if (idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) {
-    Fatal("CalcIndex", "Index (%d,'%c',%d,%d) out of bounds, "
-         "in particular the %s index", 
-         det, ring, sec, str, 
-         (det >= fMaxDetectors ? "Detector" : 
-          (ringi >= fMaxRings ? "Ring" : 
-           (sec >= fMaxSectors ? "Sector" : "Strip"))));
-    return 0;
-  }
-  return idx;
-}
-
-//____________________________________________________________________
-template <typename Type>
-inline void
-AliFMDMap<Type>::Clear(const Type& val) 
-{
-  // Resets stored values to the default value for that type 
-  for (UShort_t i = 0; i < fValues.size(); ++i) fValues[i] = val;
-}
-
-//____________________________________________________________________
-template <typename Type>
-inline Type& 
-AliFMDMap<Type>::operator()(UShort_t det, Char_t ring, 
-                           UShort_t sec, UShort_t str)
-{
-  // Parameters: 
-  //     det       Detector #
-  //     ring      Ring ID
-  //     sec       Sector # 
-  //     str       Strip # 
-  //
-  // Returns data[det][ring][sec][str]
-  return fValues[CalcIndex(det, ring, sec, str)];
-}
-
-//____________________________________________________________________
-template <typename Type>
-inline const Type& 
-AliFMDMap<Type>::operator()(UShort_t det, 
-                           Char_t ring, 
-                           UShort_t sec, 
-                           UShort_t str) const
-{
-  // Parameters: 
-  //     det       Detector #
-  //     ring      Ring ID
-  //     sec       Sector # 
-  //     str       Strip # 
-  //
-  // Returns data[det][ring][sec][str]
-  return fValues[CalcIndex(det, ring, sec, str)];
-}
-
-
-//____________________________________________________________________
-// 
-// Some specialisations 
-//
-typedef AliFMDMap<UShort_t> AliFMDAdcMap;
-typedef AliFMDMap<std::pair<Float_t, UShort_t> > AliFMDEdepMap;
-
-#endif
 #endif 
 //____________________________________________________________________
 //