]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFRawStream.h
Improved QAchecker and plots for DQM
[u/mrichter/AliRoot.git] / TOF / AliTOFRawStream.h
index f2733b0badf49f3cd95efa13e040b4c6c233af04..b12e74fe5dd34145d576dacf2b1cc8218686c8ef 100644 (file)
 //#include "AliTOFHitData.h"
 #include "AliTOFHitDataBuffer.h"
 #include "AliTOFDecoder.h"
+//#include "AliTOFCableLengthMap.h"
 
 class AliTOFHitData;
 
+class AliTOFDecoderV2;
+
 /**********************************
  * OLD DEFINITIONS 
  **********************************/ 
@@ -28,30 +31,23 @@ GENERAL DATA FORMAT
 ******************************************/
 
 //filler
-#ifndef FILLER
+//#ifndef FILLER
 #define FILLER 0x70000000
-#endif
+//#endif
 
 //word type mask/position
-#ifndef WORD_TYPE_MASK
 #define WORD_TYPE_MASK 0xf0000000
-#endif
 #define WORD_TYPE_POSITION 28
 
 //global header word required bit pattern
-#ifndef GLOBAL_HEADER
 #define GLOBAL_HEADER 0x40000000
-#endif
 
 //global trailer word required bit pattern
-#ifndef GLOBAL_TRAILER
 #define GLOBAL_TRAILER 0x50000000
-#endif
 
 //error word required bit pattern
-#ifndef ERROR
-#define ERROR 0x30000000
-#endif
+// already defined in AliTOFDecoder
+//#define ERROR 0x30000000
 
 //header slot ID mask/position
 #define HEADER_SLOT_ID_MASK 0x0000000f
@@ -263,14 +259,11 @@ TRM DATA FORMAT
 #define TRM_FIRST_SLOT_ID 3
 
 //define hptdc time bin width
-#ifndef TIME_BIN_WIDTH
 #define TIME_BIN_WIDTH 24.4e-3 //ns
-#endif
 
 //define hptdc tot bin width
-#ifndef TOT_BIN_WIDTH
-#define TOT_BIN_WIDTH 48.4e-3 //ns
-#endif
+// already defined in AliTOFDecoder
+//#define TOT_BIN_WIDTH 48.4e-3 //ns
 
 //TRM errors
 
@@ -394,6 +387,9 @@ class AliTOFRawStream: public TObject {
   AliTOFRawStream(AliRawReader* rawReader); // ctr
   virtual ~AliTOFRawStream(); // default dtr
 
+  AliTOFRawStream(const AliTOFRawStream& stream); // copy ctr
+  AliTOFRawStream& operator = (const AliTOFRawStream& stream); // ass. op.
+
   virtual Bool_t Next();
   
   virtual void   LoadRawData(Int_t indexDDL);
@@ -420,12 +416,16 @@ class AliTOFRawStream: public TObject {
     
   Int_t GetErrorFlag()  const {return fErrorFlag;};
 
+  Bool_t GetDecoderVersion() const {return fNewDecoderVersion;};
+
   void SetDDL(Int_t nDDL)            {fDDL = nDDL;};
   void SetTRM(Int_t nTRM)            {fTRM = nTRM;};
   void SetTDC(Int_t nTDC)            {fTDC = nTDC;};
   void SetTRMchain(Int_t nChain)     {fTRMchain = nChain;};
   void SetTDCchannel(Int_t nChannel) {fTDCchannel = nChannel;};
 
+  void SetDecoderVersion(Bool_t version) {fNewDecoderVersion = version;};
+
   TClonesArray *GetRawData() const {return fTOFrawData;};
 
   void SetSector();
@@ -434,38 +434,72 @@ class AliTOFRawStream: public TObject {
   void SetPadZ();
   void SetPadX();
 
-  Int_t GetLocalEventCounterDRM() {return fLocalEventCounterDRM;};//adc
-  Int_t GetLocalEventCounterLTM() {return fLocalEventCounterLTM;};//adc
-  Int_t GetLocalEventCounterTRM(Int_t trm) {return fLocalEventCounterTRM[trm];};//adc
-  Int_t GetLocalEventCounterChain(Int_t trm, Int_t chain) {return fLocalEventCounterChain[trm][chain];};//adc
+  Bool_t GetBCCorrections() const {return fgApplyBCCorrections;}; // getter for the BC application switch
+  Int_t GetDDLBCshift(Int_t ddl) const {return fgkddlBCshift[ddl];}; // getter for the DDL BC shift
+  Int_t GetLocalEventCounterDRM() const {return fLocalEventCounterDRM;}; // getter for the DRM event counter
+  Int_t GetLocalEventCounterLTM() const {return fLocalEventCounterLTM;}; // getter for the LTM event counter
+  Int_t GetLocalEventCounterTRM(Int_t trm) const {return fLocalEventCounterTRM[trm];}; // getter for the TRM event counter
+  Int_t GetLocalEventCounterChain(Int_t trm, Int_t chain) const {return fLocalEventCounterChain[trm][chain];}; // getter for the chain event counter
+  Int_t GetChainBunchID(Int_t trm, Int_t chain) const {return fChainBunchID[trm][chain];}; // getter for the chain BC ID
+
+
+  void Raw2Digits(AliRawReader* rawReader, TClonesArray * const digitsArray);
+  void Raw2SDigits(AliRawReader* rawReader, TClonesArray * const sdigitsArray);
 
-  void  EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
-                            Int_t iTDC, Int_t iCH, Int_t *volume) const;
+  static void  EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
+                                   Int_t iTDC, Int_t iCH, Int_t *volume);
   void  EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const;
   static Int_t Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC);
   static Int_t Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC);
   static Int_t Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC, Int_t iCH);
   static Int_t Equip2VolNpadX(Int_t iDDL, Int_t iChain, Int_t nTDC, Int_t iCH);
   static Int_t Equip2VolNpadZ(Int_t iDDL, Int_t iChain, Int_t nTDC, Int_t iCH);
-  Int_t GetDDLnumberPerSector(Int_t nDDL) const;
-  Int_t GetSectorNumber(Int_t nDDL) const;
+  static Int_t GetDDLnumberPerSector(Int_t nDDL);
+  static Int_t GetSectorNumber(Int_t nDDL);
+
+  static Int_t Geant2DDL(Int_t vol[]);
+  static Int_t Geant2TRM(Int_t vol[]);
+  static Int_t Geant2TDC(Int_t vol[]);
+  static Int_t Geant2Chain(Int_t vol[]);
+  static Int_t Geant2Channel(Int_t vol[]);
+  static void  Geant2EquipmentId(Int_t vol[], Int_t eqId[]);
 
   Bool_t DecodeDDL(Int_t DDLMin, Int_t DDLMax, Int_t verbose);
   Bool_t Decode(Int_t verbose);
-  AliTOFDecoder *GetDecoder() {return fDecoder;};
+  Bool_t DecodeV2(Int_t verbose);
+  AliTOFDecoder *GetDecoder() const {return fDecoder;};
+  AliTOFDecoderV2 *GetDecoderV2() const {return fDecoderV2;};
   void SetV2718Patch(Bool_t V2718Patch = kTRUE) {fDecoder->SetV2718Patch(V2718Patch);};
 
+  void SetRawReader(AliRawReader * const rawReader) {fRawReader=rawReader;};
 
-  AliTOFHitDataBuffer *GetDataBuffer(Int_t DDL) {return fDataBuffer[DDL];};
-  AliTOFHitDataBuffer *GetPackedDataBuffer(Int_t DDL) {return fPackedDataBuffer[DDL];};
+  AliTOFHitDataBuffer * GetDataBuffer(Int_t DDL) {return &fDataBuffer[DDL];};
+  AliTOFHitDataBuffer * GetPackedDataBuffer(Int_t DDL) {return &fPackedDataBuffer[DDL];};
 
-  void ResetDataBuffer(Int_t DDL) {fDataBuffer[DDL]->Reset();};
-  void ResetPackedDataBuffer(Int_t DDL) {fPackedDataBuffer[DDL]->Reset();};
+  void ResetDataBuffer(Int_t DDL) {fDataBuffer[DDL].Reset();};
+  void ResetPackedDataBuffer(Int_t DDL) {fPackedDataBuffer[DDL].Reset();};
 
   void ResetBuffers();
 
   Bool_t LoadRawDataBuffers(Int_t indexDDL, Int_t verbose = 0);
+  Bool_t LoadRawDataBuffersV2(Int_t indexDDL, Int_t verbose = 0);
+  static void ApplyBCCorrections(Bool_t Value = kTRUE) {fgApplyBCCorrections = Value;};
   
+  Int_t GetEventID() const {return fEventID;}; // getter for the eventID1 (bunch crossing) in the common data header
+
+  void LTM2VolumeID(Int_t iDDL,
+                   Int_t iTRM,
+                   Int_t iChain,
+                   Int_t iTDC,
+                   Int_t iChannel,
+                   Int_t detind0[], Int_t detind1[]) const;
+  void VolumeID2LTM(Int_t detind[],
+                   Int_t &iDDL,
+                   Int_t &iTRM,
+                   Int_t &iChain,
+                   Int_t &iTDC,
+                   Int_t &iChannel) const;
+
   enum ETOFRawStreamError {
     kPadXError = 0,
     kPadAlongStripError = 1,
@@ -482,14 +516,12 @@ class AliTOFRawStream: public TObject {
   
   Int_t GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const;
   
-  AliTOFRawStream(const AliTOFRawStream& stream); // copy ctr
-  AliTOFRawStream& operator = (const AliTOFRawStream& stream); // ass. op.
-  
   AliRawReader*  fRawReader; // object for reading the raw data
 
   TClonesArray *fTOFrawData; // pointer to AliTOFrawData TClonesArray
 
   AliTOFDecoder *fDecoder; //pointer to TOF decoder
+  AliTOFDecoderV2 *fDecoderV2; //pointer to TOF decoder
 
   Int_t         fDDL;          // DDL file number [0;71]
   Int_t         fTRM;          // TRM number [1;12]
@@ -521,13 +553,49 @@ class AliTOFRawStream: public TObject {
   Bool_t fInsideTRMchain0;   // inside/outside chain 0
   Bool_t fInsideTRMchain1;   // inside/outside chain 1
 
-  AliTOFHitDataBuffer *fDataBuffer[72]; // pointer to AliTOFHitDataBuffer
-  AliTOFHitDataBuffer *fPackedDataBuffer[72]; // pointer to AliTOFHitDataBuffer
+  AliTOFHitDataBuffer fDataBuffer[72]; // AliTOFHitDataBuffer
+  AliTOFHitDataBuffer fPackedDataBuffer[72]; // AliTOFHitDataBuffer
+
+  Int_t fLocalEventCounterDRM;          // event counter recorded in the DRM global trailer
+  Int_t fLocalEventCounterLTM;          // event counter recorded in the LTM global trailer
+  Int_t fLocalEventCounterTRM[13];      // event counter recorded in the TRMs global trailer
+  Int_t fLocalEventCounterChain[13][2]; // event counter recorded in the chains trailer
+  Int_t fChainBunchID[13][2];           // BC ID recorded in the chains header
+
+  //AliTOFCableLengthMap * fCableLengthMap; // Pointer to the map of Amphenol cable length
+
+  Int_t fEventID; // event ID1 in the common data header
+
+  Bool_t fNewDecoderVersion;   // setting whether to use the new decoder version
+                               //  -true -> new version
+                               //  -false ->old version (default value!!)
+
+  static const Int_t fgkddlBCshift[72]; // DDL BC shifts
+  static Bool_t fgApplyBCCorrections; // switch to choose if apply or not the BC shift corrections
+
+  static const Int_t fgkStrip0MapCrate0[];   // 1st strip number in crate 0
+  static const Int_t fgkStrip1MapCrate0[];   // 2nd strip number in crate 0
+  static const Int_t fgkStrip0MapCrate1[];   // 1st strip number in crate 1
+  static const Int_t fgkStrip1MapCrate1[];   // 2nd strip number in crate 1
+  static const Int_t fgkStrip0MapCrate2[];   // 1st strip number in crate 2
+  static const Int_t fgkStrip1MapCrate2[];   // 2nd strip number in crate 2
+  static const Int_t fgkStrip0MapCrate3[];   // 1st strip number in crate 3
+  static const Int_t fgkStrip1MapCrate3[];   // 2nd strip number in crate 3
+
+  static const Int_t fgkModule0MapCrate0[];  // 1st module number in crate 0
+  static const Int_t fgkModule1MapCrate0[];  // 2nd module number in crate 0
+  static const Int_t fgkModule0MapCrate1[];  // 1st module number in crate 1
+  static const Int_t fgkModule1MapCrate1[];  // 2nd module number in crate 1
+  static const Int_t fgkModule0MapCrate2[];  // 1st module number in crate 2
+  static const Int_t fgkModule1MapCrate2[];  // 2nd module number in crate 2
+  static const Int_t fgkModule0MapCrate3[];  // 1st module number in crate 3
+  static const Int_t fgkModule1MapCrate3[];  // 2nd module number in crate 3
+
+  static const Int_t fgkChannelMap0[5][19];  // mapping padX<24 <-> TDC channels
+  static const Int_t fgkChannelMap24[5][19]; // mapping padX>=24 <-> TDC channels
+  static const Int_t fgkChainMap0[5][19];    // mapping padX<24 <-> TRM chain
+  static const Int_t fgkChainMap24[5][19];   // mapping padX>=24 <-> TRM chain
 
-  Int_t   fLocalEventCounterDRM;//adc
-  Int_t   fLocalEventCounterLTM;//adc
-  Int_t  *fLocalEventCounterTRM;//adc
-  Int_t **fLocalEventCounterChain;//adc
 
   ClassDef(AliTOFRawStream, 3)  // class for reading TOF raw digits
 };