#include <TObject.h>
#include <TString.h>
+#include <fstream>
class AliTRDtrapConfig : public TObject
{
public:
+ ~AliTRDtrapConfig();
+
static AliTRDtrapConfig* Instance();
enum TrapReg_t { kSML0,
kDMDELS,
kLastReg }; // enum of all TRAP registers, to be used for access to them
- const char* GetRegName(TrapReg_t reg) const { return fRegs[reg].fName.Data(); }
- UShort_t GetRegAddress(TrapReg_t reg) const { return fRegs[reg].fAddr; }
- UShort_t GetRegNBits(TrapReg_t reg) const { return fRegs[reg].fNbits; }
- UInt_t GetRegResetValue(TrapReg_t reg) const { return fRegs[reg].fResetValue; }
+ const char* GetRegName(TrapReg_t reg) const { return reg >= 0 && reg < kLastReg ? fRegs[reg].fName.Data() : ""; }
+ UShort_t GetRegAddress(TrapReg_t reg) const { return reg >= 0 && reg < kLastReg ? fRegs[reg].fAddr : 0; }
+ UShort_t GetRegNBits(TrapReg_t reg) const { return reg >= 0 && reg < kLastReg ? fRegs[reg].fNbits : 0; }
+ UInt_t GetRegResetValue(TrapReg_t reg) const { return reg >= 0 && reg < kLastReg ? fRegs[reg].fResetValue : 0; }
TrapReg_t GetRegByAddress(Int_t address) const;
- Int_t GetTrapReg(TrapReg_t reg, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1);
- Bool_t PrintTrapReg(TrapReg_t reg, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1);
- Bool_t PrintTrapAddr(Int_t addr, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1);
+ Int_t GetTrapReg(TrapReg_t reg, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1) const;
+ Bool_t PrintTrapReg(TrapReg_t reg, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1) const;
+ Bool_t PrintTrapAddr(Int_t addr, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1) const;
Bool_t SetTrapReg(TrapReg_t reg, Int_t value);
Bool_t SetTrapReg(TrapReg_t reg, Int_t value, Int_t det);
Bool_t SetTrapReg(TrapReg_t reg, Int_t value, Int_t det, Int_t rob, Int_t mcm);
- Int_t Peek(Int_t addr, Int_t det, Int_t rob, Int_t mcm);
- Bool_t Poke(Int_t addr, Int_t value, Int_t det, Int_t rob, Int_t mcm);
+ UInt_t Peek(Int_t addr, Int_t det, Int_t rob, Int_t mcm) const;
+ Bool_t Poke(Int_t addr, UInt_t value, Int_t det, Int_t rob, Int_t mcm);
void InitRegs();
void ResetRegs();
+ void ResetDmem();
// DMEM
- Bool_t SetDmem(Int_t addr, Int_t value);
- Bool_t SetDmem(Int_t addr, Int_t value, Int_t det);
- Bool_t SetDmem(Int_t addr, Int_t value, Int_t det, Int_t rob, Int_t mcm);
-
- Int_t GetDmem(Int_t addr, Int_t det, Int_t rob, Int_t mcm);
+ Bool_t SetDmem(Int_t addr, UInt_t value);
+ // Bool_t SetDmem(Int_t addr, UInt_t value, Int_t det);
+ Bool_t SetDmem(Int_t addr, UInt_t value, Int_t det, Int_t rob, Int_t mcm);
+ Bool_t SetDmem(Int_t addr, Int_t value) { return SetDmem(addr, (UInt_t) value); }
+ // Bool_t SetDmem(Int_t addr, Int_t value, Int_t det) { return SetDmem(addr, (UInt_t) value, det); }
+ Bool_t SetDmem(Int_t addr, Int_t value, Int_t det, Int_t rob, Int_t mcm) { return SetDmem(addr, (UInt_t) value, det, rob, mcm); }
+
+ UInt_t GetDmemUnsigned(Int_t addr) const;
+ UInt_t GetDmemUnsigned(Int_t addr, Int_t det, Int_t rob, Int_t mcm) const;
+
+ void PrintMemDatx(ostream &os, Int_t addr) const;
+ void PrintMemDatx(ostream &os, Int_t addr, Int_t det, Int_t rob, Int_t mcm) const;
+ void PrintMemDatx(ostream &os, TrapReg_t reg) const;
+ void PrintMemDatx(ostream &os, TrapReg_t reg, Int_t det, Int_t rob, Int_t mcm) const;
+ void PrintDatx(ostream &os, UInt_t addr, UInt_t data, Int_t rob, Int_t mcm) const;
+
+ // PID
+ void SetPIDscale(Double_t sq0, Double_t sq1) {fScaleQ0=sq0; fScaleQ1=sq1;} // The two scaling factors are not available in the TRAP but needed by the DCS board
+ void GetPIDscale(Double_t scale[2]) {scale[0] = fScaleQ0; scale[1]=fScaleQ1;} // The two scaling factors are not available in the TRAP but needed by the DCS board
// configuration handling
- Bool_t LoadConfig();
- Bool_t LoadConfig(Int_t det, TString filename);
+ Bool_t ReadPackedConfig(Int_t det, UInt_t *data, Int_t size);
- Bool_t ReadPackedConfig(UInt_t *data, Int_t size);
+ Bool_t AddValues(UInt_t det, UInt_t cmd, UInt_t extali, Int_t addr, UInt_t data);
- Int_t ExtAliToAli( UInt_t dest, UShort_t linkpair, UShort_t rocType);
+ // DMEM addresses
+ static const Int_t fgkDmemAddrLUTcor0 = 0xC02A;
+ static const Int_t fgkDmemAddrLUTcor1 = 0xC028;
+ static const Int_t fgkDmemAddrLUTnbins = 0xC029;
+
+ static const Int_t fgkDmemAddrLUTStart = 0xC100; // LUT start address
+ static const Int_t fgkDmemAddrLUTEnd = 0xC3FF; // maximum possible end address for the LUT table
+ static const Int_t fgkDmemAddrLUTLength = 0xC02B; // address where real size of the LUT table is stored
+
+ static const Int_t fgkDmemAddrTrackletStart = 0xC0E0; // Storage area for tracklets, start address
+ static const Int_t fgkDmemAddrTrackletEnd = 0xC0E3; // Storage area for tracklets, end address
+
+ static const Int_t fgkDmemAddrDeflCorr = 0xc022; // DMEM address of deflection correction
+ static const Int_t fgkDmemAddrNdrift = 0xc025; // DMEM address of Ndrift
+ static const Int_t fgkDmemAddrDeflCutStart = 0xc030; // DMEM start address of deflection cut
+ static const Int_t fgkDmemAddrDeflCutEnd = 0xc055; // DMEM end address of deflection cut
+
+ // DMEM memory in simulation;
+ static const Int_t fgkDmemStartAddress; // start address in TRAP GIO
+ static const Int_t fgkDmemWords = 0xc400; // number of words in DMEM
protected:
static AliTRDtrapConfig *fgInstance; // pointer to instance (singleton)
SimpleReg_t fRegs[kLastReg]; // array of TRAP registers
RegValue_t fRegisterValue[kLastReg]; // array of TRAP register values in use
- Bool_t AddValues(UInt_t det, UInt_t cmd, UInt_t extali, Int_t addr, UInt_t data);
- Short_t GetRobAB( UShort_t robsel, UShort_t linkpair ) const; // Converts the ROB part of the extended ALICE ID to robs
- Short_t ChipmaskToMCMlist( Int_t cmA, Int_t cmB, UShort_t linkpair ); // Converts the chipmask to a list of MCMs
-
static const UInt_t fgkScsnCmdWrite=10; // Command number for the write command
static const Int_t fgkMaxLinkPairs=4; // number of linkpairs used during configuration
static const Int_t fgkMaxMcm; // max. no. of MCMs to be treated
static const Int_t fgkMcmlistSize=256; // list of MCMs to which a value has to be written
- Int_t fMcmlist[fgkMcmlistSize]; // stores the list of MCMs after the conversion from extAliID -> AliID
-
// DMEM
- static const Int_t fgkDmemStartAddress; // = 0xc000; // start address in TRAP GIO
- static const Int_t fgkDmemWords = 0x400; // number of words in DMEM
- UInt_t fDmem[540*8*18][fgkDmemWords]; // DMEM storage
- Bool_t fDmemValid[540*8*18][fgkDmemWords]; // DMEM valid flag storage
+ UInt_t* fDmem[fgkDmemWords]; // DMEM storage
+ Int_t fDmemDepth[fgkDmemWords]; // memory space indicator for fDmem
+
+ static const Int_t fgkDmemSizeEmpty=0;
+ static const Int_t fgkDmemSizeUniform = 1;
+ static const Int_t fgkDmemSizeSmIndividual = 30*8*16; // storage for each MCM within one supermodule
+ static const Int_t fgkDmemSizeTotalIndividual = 540*6*8*16; // one individual value for each and every MCM in the TRD
+ static const Int_t fgkDmemSizeSmRocIndividual = 540; // one individual value for each chamber in TRD
+
+ // Online PID
+ Double_t fScaleQ0; // scaling factor for the x-axis of the PID table
+ Double_t fScaleQ1; // scaling factor for the y-axis of the PID table
AliTRDtrapConfig(); // private constructor due to singleton implementation