From bd3cd9c2a256dc8bbb57bdadba9eb803d6ff7d27 Mon Sep 17 00:00:00 2001 From: dsilverm Date: Wed, 1 Jul 2009 20:49:43 +0000 Subject: [PATCH] avoid redefining common constants, or using magic numbers in code, by instead having a common parameter header file --- EMCAL/AliCaloCalibPedestal.cxx | 8 ++-- EMCAL/AliCaloCalibPedestal.h | 16 ++----- EMCAL/AliCaloCalibSignal.cxx | 10 ++--- EMCAL/AliCaloCalibSignal.h | 16 ++----- EMCAL/AliEMCALGeoParams.h | 81 ++++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 34 deletions(-) create mode 100644 EMCAL/AliEMCALGeoParams.h diff --git a/EMCAL/AliCaloCalibPedestal.cxx b/EMCAL/AliCaloCalibPedestal.cxx index d01e33246b1..264e427062c 100644 --- a/EMCAL/AliCaloCalibPedestal.cxx +++ b/EMCAL/AliCaloCalibPedestal.cxx @@ -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 diff --git a/EMCAL/AliCaloCalibPedestal.h b/EMCAL/AliCaloCalibPedestal.h index b3abe6a1cf5..252d3c0cb43 100644 --- a/EMCAL/AliCaloCalibPedestal.h +++ b/EMCAL/AliCaloCalibPedestal.h @@ -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) }; diff --git a/EMCAL/AliCaloCalibSignal.cxx b/EMCAL/AliCaloCalibSignal.cxx index 67021e90117..6532f88cb91 100644 --- a/EMCAL/AliCaloCalibSignal.cxx +++ b/EMCAL/AliCaloCalibSignal.cxx @@ -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(); diff --git a/EMCAL/AliCaloCalibSignal.h b/EMCAL/AliCaloCalibSignal.h index f00e96d590f..8609af3e5ad 100644 --- a/EMCAL/AliCaloCalibSignal.h +++ b/EMCAL/AliCaloCalibSignal.h @@ -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 index 00000000000..0c16ae6307f --- /dev/null +++ b/EMCAL/AliEMCALGeoParams.h @@ -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 -- 2.43.0