]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
avoid redefining common constants, or using magic numbers in code, by instead having...
authordsilverm <dsilverm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 1 Jul 2009 20:49:43 +0000 (20:49 +0000)
committerdsilverm <dsilverm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 1 Jul 2009 20:49:43 +0000 (20:49 +0000)
EMCAL/AliCaloCalibPedestal.cxx
EMCAL/AliCaloCalibPedestal.h
EMCAL/AliCaloCalibSignal.cxx
EMCAL/AliCaloCalibSignal.h
EMCAL/AliEMCALGeoParams.h [new file with mode: 0644]

index d01e33246b160c964c75cd7670602b513d0678f9..264e427062c4971c8ecaeb98a80daaede660271d 100644 (file)
@@ -101,9 +101,9 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) :
     //We'll just trust the enum to keep everything in line, so that if detectorType
     //isn't kPhos then it is kEmCal. Note, however, that this is not necessarily the
     //case, if someone intentionally gives another number
-    fColumns = fgkEmCalCols;
-    fRows = fgkEmCalRows;
-    fModules = fgkEmCalModules;
+    fColumns = AliEMCALGeoParams::fgkEMCALCols;
+    fRows = AliEMCALGeoParams::fgkEMCALRows;
+    fModules = AliEMCALGeoParams::fgkEMCALModules;
     fCaloString = "EMCAL";
     fRowMin = 0;
     fRowMax = fRows;
@@ -351,7 +351,7 @@ Bool_t AliCaloCalibPedestal::ProcessEvent(AliCaloRawStreamV3 *in)
     while (in->NextChannel()) {
 
       // counters
-      int max = fgkSampleMin, min = fgkSampleMax; // min and max sample values
+      int max = AliEMCALGeoParams::fgkSampleMin, min = AliEMCALGeoParams::fgkSampleMax; // min and max sample values
       
       // for the pedestal calculation
       int sampleSum = 0; // sum of samples
index b3abe6a1cf5dfbcb34fefca661f22000fd013585..252d3c0cb4313c142e920652dcb158bae29b005d 100644 (file)
@@ -26,6 +26,7 @@
 #include "TProfile2D.h"
 #include "TH2.h"
 #include "TObjArray.h"
+#include "AliEMCALGeoParams.h"
 class AliCaloRawStreamV3;
 class AliCaloAltroMapping;
 class AliRawReader;
@@ -45,10 +46,6 @@ class AliCaloCalibPedestal : public TObject {
   AliCaloCalibPedestal(const AliCaloCalibPedestal &ped); 
   AliCaloCalibPedestal& operator = (const  AliCaloCalibPedestal &source);
   
-  //Functions to ask for the constants (in case a GUI needs them, for an example
-  int GetSampleMax() const {return fgkSampleMax;};
-  int GetSampleMin() const {return fgkSampleMin;};
-
   // Event processing methods:  
   Bool_t ProcessEvent(AliRawReader *rawReader);
   Bool_t ProcessEvent(AliCaloRawStreamV3    *in);
@@ -182,19 +179,12 @@ class AliCaloCalibPedestal : public TObject {
   int fFirstPedestalSample; // first sample to use
   int fLastPedestalSample; // last sample to use
 
-  //Constants needed by the class
-  static const int fgkSampleMax = 1023; // highest possible sample value (10-bit = 0x3ff)
-  static const int fgkSampleMin = 0; // lowest possible sample value 
-  
+  //Constants needed by the class: EMCAL ones are kept in AliEMCALGeoParams.h
   static const int fgkPhosRows = 64; // number of rows per module for PHOS
   static const int fgkPhosCols = 56; // number of columns per module for PHOS
   static const int fgkPhosModules = 5; // number of modules for PHOS
   
-  static const int fgkEmCalRows = 24; // number of rows per module for EMCAL
-  static const int fgkEmCalCols = 48; // number of columns per module for EMCAL
-  static const int fgkEmCalModules = 12; // number of modules for EMCAL
-  
-  ClassDef(AliCaloCalibPedestal,3)
+  ClassDef(AliCaloCalibPedestal, 4)
 
 };
     
index 67021e901173ceb8b8e596e5beed81bfb37ce418..6532f88cb91e5ad89e4544ac38f48ba059719102 100644 (file)
@@ -91,10 +91,10 @@ AliCaloCalibSignal::AliCaloCalibSignal(kDetType detectorType) :
     //We'll just trust the enum to keep everything in line, so that if detectorType
     //isn't kPhos then it is kEmCal. Note, however, that this is not necessarily the
     //case, if someone intentionally gives another number
-    fColumns = fgkEmCalCols;
-    fRows = fgkEmCalRows;
-    fLEDRefs = fgkEmCalLEDRefs;
-    fModules = fgkEmCalModules;
+    fColumns = AliEMCALGeoParams::fgkEMCALCols;
+    fRows = AliEMCALGeoParams::fgkEMCALRows;
+    fLEDRefs = AliEMCALGeoParams::fgkEMCALLEDRefs;
+    fModules = AliEMCALGeoParams::fgkEMCALModules;
     fCaloString = "EMCAL";
   }
 
@@ -363,7 +363,7 @@ Bool_t AliCaloCalibSignal::ProcessEvent(AliCaloRawStreamV3 *in, AliRawEventHeade
     while (in->NextChannel()) {
 
       // counters
-      int max = fgkSampleMin, min = fgkSampleMax; // min and max sample values
+      int max = AliEMCALGeoParams::fgkSampleMin, min = AliEMCALGeoParams::fgkSampleMax; // min and max sample values
       
       while (in->NextBunch()) {
        const UShort_t *sig = in->GetSignals();
index f00e96d590fc8cf14295e57b77366d850ac450ce..8609af3e5ad91d268c3edef189bc27239a4eacd5 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "TString.h"
 #include "TTree.h"
-
+#include "AliEMCALGeoParams.h"
 class AliCaloRawStreamV3;
 class AliCaloAltroMapping;
 class AliRawReader;
@@ -178,25 +178,17 @@ class AliCaloCalibSignal : public TObject {
   int fNEvents; // # events processed
   int fNAcceptedEvents; // # events accepted
 
-  //Constants needed by the class
-  static const int fgkSampleMax = 1023; // highest possible sample value (10-bit = 0x3ff)
-  static const int fgkSampleMin = 0; // lowest possible sample value 
-  
+  //Constants needed by the class: EMCAL ones are kept in AliEMCALGeoParams.h
   static const int fgkPhosRows = 64; // number of rows per module for PHOS
   static const int fgkPhosCols = 56; // number of columns per module for PHOS
   static const int fgkPhosLEDRefs = 0; // no LED monitor channels for PHOS
   static const int fgkPhosModules = 5; // number of modules for PHOS
   
-  static const int fgkEmCalRows = 24; // number of rows per module for EMCAL
-  static const int fgkEmCalCols = 48; // number of columns per module for EMCAL
-  static const int fgkEmCalLEDRefs = 24; // number of LEDs (reference/monitors) per module for EMCAL; one per StripModule
-  static const int fgkEmCalModules = 12; // number of modules for EMCAL
-
   // From numbers above: PHOS has more possible towers (17920) than EMCAL (13824) 
   // so use PHOS numbers to set max. array sizes
   static const int fgkMaxTowers = 17920; // fgkPhosModules * fgkPhosCols * fgkPhosRows; 
   // for LED references; maximum from EMCAL
-  static const int fgkMaxRefs = 288; // fgkEmCalModules * fgkEmCalLEDRefs
+  static const int fgkMaxRefs = 288; // AliEMCALGeoParams::fgkEMCALModules * AliEMCALGeoParams::fgkEMCALLEDRefs
 
   static const int fgkNumSecInHr = 3600;  // number of seconds in an hour, for the fractional hour conversion on the time graph
   
@@ -211,7 +203,7 @@ class AliCaloCalibSignal : public TObject {
   int fNLowGain[fgkMaxTowers]; // same, for low gain
   int fNRef[fgkMaxRefs * 2]; // same, for LED refs; *2 for both gains
   
-  ClassDef(AliCaloCalibSignal, 3) // don't forget to change version if you change class member list..
+  ClassDef(AliCaloCalibSignal, 4) // don't forget to change version if you change class member list..
     
 };
     
diff --git a/EMCAL/AliEMCALGeoParams.h b/EMCAL/AliEMCALGeoParams.h
new file mode 100644 (file)
index 0000000..0c16ae6
--- /dev/null
@@ -0,0 +1,81 @@
+#ifndef ALIEMCALGEOPARAMS_H
+#define ALIEMCALGEOPARAMS_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliEMCALGeoParams.h $ */
+
+//////////////////////////////////////////////////////////
+// class for holding various parameters; to be used by new 
+// AliEMCALGeoUtils class //
+//////////////////////////////////////////////////////////
+
+class AliEMCALGeoParams
+{
+public:
+
+  // general geometry info
+  static const int fgkEMCALModules = 12; // number of modules for EMCAL
+  static const int fgkEMCALRows = 24; // number of rows per module for EMCAL
+  static const int fgkEMCALCols = 48; // number of columns per module for EMCAL
+
+  static const int fgkEMCALLEDRefs = 24; // number of LEDs (reference/monitors) per module for EMCAL; one per StripModule
+
+  // also a few readout related variables:
+  static const int fgkSampleMax = 1023; // highest possible sample value (10-bit = 0x3ff)
+  static const int fgkSampleMin = 0; // lowest possible sample value 
+  
+  // RAW/AliCaloAltroMapping provides the correspondence information between
+  // an electronics HWAddress (Branch<<1 | FEC<<7 | ALTRO<<4 | Channel) 
+  // for the RCUs and which tower (Column and Row) that corresponds to. 
+  // For the cases when one doesn't have a Raw stream to decode the HW address
+  // into the other FEE indices, we provide the needed simple methods here 
+  // with arguments (within an RCU)
+  Int_t GetHWAddress(Int_t iBranch, Int_t iFEC, Int_t iALTRO, Int_t iChannel) const
+  { return ( (iBranch<<11) | (iFEC<<7) | (iALTRO<<4) | iChannel ); }; // 
+  // and for converting back to the individual indices
+  Int_t GetBranch(Int_t iHW) const { return ( (iHW>>11) & 0x1 ); }; // 
+  Int_t GetFEC(Int_t iHW) const { return ( (iHW>>7) & 0xf ); }; // 
+  Int_t GetAltro(Int_t iHW) const { return ( (iHW>>4) & 0x7 ); }; // 
+  Int_t GetChannel(Int_t iHW) const { return ( iHW & 0xf ); }; // 
+
+  // We can also encode a very similar CSP address
+  Int_t GetCSPAddress(Int_t iBranch, Int_t iFEC, Int_t iCSP) const
+  { return ( (iBranch<<11) | (iFEC<<7) | iCSP ); }; // 
+  // and for converting back to the individual indices
+  // Branch and FEC methods would just be the same as above
+  Int_t GetCSPFromAddress(Int_t i) const { return ( i & 0x1f ); }; // 
+
+  /* // Below is some placeholder info that can later be added
+     // in AliEMCALGeoUtils, together with the Get methods just above 
+
+  // But which CSP (0..31) corresponds to which ALTRO and Channel is not 
+  // given anywhere (CSPs are used for APD biases etc).
+  // So, we add a conversion method for that here also.
+  // The order that the CSPs appear in the data is a bit funky so I include
+  // a mapping array instead of some complicated function
+  static const int fgkNCSP = 32;
+  static const int fgkCspOrder[32] =
+    { // just from ALTRO mapping of chips/channels to CSP
+      11,  27,  10,  26,  24,   8,  25,   9, // ALTRO 0
+      3,  19,   2,  18,  16,   0,  17,   1, // ALTRO 2
+      4,  20,   5,  21,  23,   7,  22,   6, // ALTRO 3
+      12,  28,  13,  29,  31,  15,  30,  14 // ALTRO 4
+    };
+  // This method is not used for reconstruction or so, but just for cross-
+  // checks with the DCS for the APD biases. 
+  int GetCSP(int iALTRO, int iChannel) const 
+  { 
+    int id = iChannel/2; // 2 channels per tower (low and high gain)
+    int ichip = iALTRO;
+    if (ichip>=2) { ichip--; } // there is no ALTRO 1; (0,2,3,4 -> 0,1,2,3)
+    id += ichip*8; // 8 CSPs per ALTRO
+    //return fgkCspOrder[id];
+    return id;
+  }
+
+  */
+
+};
+
+#endif