adetParams.h 3.44 KB
Newer Older
1 2
#ifndef ADETPARAMS_H_INCLUDED
#define ADETPARAMS_H_INCLUDED
3 4 5 6 7 8 9 10 11

#include <memory.h>
#include <string>

// just a container of information
class achannel_t
{
public:
  achannel_t() : myID(-1), tfall(4600.f), trise(800.f), egain(1.f), sgain(1.f),
12 13 14 15 16
                 emink(10.f), tmove(0),
                 tfast(35.f),
                 oGainSG(1.f), oGainCC(1.f),
                 lambdaE(0), lambdaH(0),
                 cGainSG(1.f), cGainCC(1.f) {}
17 18 19 20 21 22 23 24
  int       myID;       // detector/channel sequential number
  float     tfall;      // main pole of the exponential (samples)
  float     trise;      // risetime of the trapezoid (samples)
  float     egain;      // energy calibration (keV/chan)
  float     sgain;      // amplitude calibration of traces (keV/chan)
  float     emink;      // energy threshold (keV)
  float     tmove;      // T0 shift calibration of traces (ns)
  float     tfast;      // preamplifier response (ns)
25 26 27 28 29 30
  float     oGainSG;    // extra gain before correction
  float     oGainCC;    // extra gain before correction
  float     lambdaE;    // electron-trapping correction lambdaE
  float     lambdaH;    // hole-trapping correction     lambdaH
  float     cGainSG;    // extra gain after correction
  float     cGainCC;    // extra gain after correction
31
};
32 33
//#SG gainSG_orig gainCC_orig factorE factorH gainSG_corr gainCC_corr     (factor = 1/lambda ??)

34 35 36 37 38 39 40 41 42 43 44

//template<int NCC, int NSG>    // too complicated
class adetParams
{
static const int NCC  =  2;   // number of core signals
static const int NSG =  36;   // total number of segments
static const int NSLI =  6;   // number of slices  (faster index)
static const int NSEC =  6;   // number of sectors (slower index)
public:
  adetParams() : vtrig(-1000.f), itrig(0), nCC(NCC), nSG(NSG),
                    doecalF2(false), bSegEmin(false), vSegEmin(0),
45
                    tntFactor(2097152.f) {  // 2^21
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
    for(int nn = 0; nn < nCC; nn++)
      pCC[nn].myID = nn;
    for(int nn = 0; nn < nSG; nn++)
      pSG[nn].myID = nn;
    for(int nn = 0; nn < nSG; nn++) {
      memset(xTalkProp[nn], 0, sizeof(float)*nSG);
      memset(xTalkDiff[nn], 0, sizeof(float)*nSG);
    }
    memset(xTalkAver, 0, sizeof(float)*nSG);
  }

  float vtrig;                // discriminator level (meaningful only for cores)
  int   itrig;                // which core is triggering
  int   nCC;                  // number of core channels
  int   nSG;                  // number of segments
  achannel_t pCC[NCC];        // parameters of the cores
  achannel_t pSG[NSG];        // parameters of the segments

  float xTalkProp[NSG][NSG];  // proportional cross-talk
  float xTalkDiff[NSG][NSG];  // differential cross-talk
  float xTalkAver[NSG];       // average proportional xTalk
  bool  doecalF2;             // flag to enable this correction

  bool  bSegEmin;
  float vSegEmin;
  float tntFactor;            // usually 2^21 = 2097152
  
  void SetTriggerLevel(float value) {vtrig    = value;}
  void SetSegMinEnergy(float value) {vSegEmin = value; bSegEmin = true;}
  bool ReadCalibCoeffs(std::string setupFile, bool verbose);
  bool ReadCalibV01(std::ifstream &cfg, std::string *keys, bool verbose);
  bool ReadCalibV02(std::ifstream &cfg, std::string *keys, bool verbose);
  bool ReadXtalkCoeffs(std::string cname, bool verbose);
79
  bool ReadTrappingCal(std::string cname, bool verbose);
80 81 82
  void CalcDifferentialXtalk(float xfactor);
};

83
#endif  // ADETPARAMS_H_INCLUDED
84