ROOT logo
//*-- AUTHORS :  Pablo Cabanelas / Hector Alvarez Pol
//*-- Created : 18/10/2005
//*-- Modified: 28/09/2006
//*-- Modified: 22/08/2007 Pablo Cabanelas /Diego Gonzalez-Diaz

//_HADES_CLASS_DESCRIPTION
/////////////////////////////////////////////////////////////
//
//  HRpcRaw
//
//  Class for the raw data of the RPC detector
//
/////////////////////////////////////////////////////////////

#ifndef HRPCRAW_H
#define HRPCRAW_H

#include "hlocateddataobject.h"

class HRpcRaw : public HLocatedDataObject {
 protected:
  Float_t  rightTime;       //TDC: 1st leading time on the right
  Float_t  leftTime;        //TDC: 1st leading time on the left
  Float_t  rightTime2;      //TDC: 2nd leading time on the right
  Float_t  leftTime2;       //TDC: 2nd leading time on the left
  Float_t  rightTot;        //TDC: 1st Time-over-Threshold on the right
  Float_t  leftTot;         //TDC: 1st Time-over-Threshold on the left
  Float_t  rightTot2;       //TDC: 2nd Time-over-Threshold on the right
  Float_t  leftTot2;        //TDC: 2nd Time-over-Threshold on the left
  Float_t  rightTotLast;    //TDC: Time-over-Threshold on the left including all the reflexions up to 500 ns
  Float_t  leftTotLast;     //TDC: Time-over-Threshold on the right including all the reflexions up to 500 ns

  Int_t    leftFeeAddress;  //FEE address (DBO_input, DBO, MBO, TRB): see wiki for documentation
  Int_t    rightFeeAddress; //FEE address (DBO_input, DBO, MBO, TRB): see wiki for documentation

  Short_t  address;         //Geometrical address (sec, col, cell)
  Short_t  leftLogBit;      //Data Info
  Short_t  rightLogBit;     //Data Info
                            //See: http://hades-wiki.gsi.de/cgi-bin/view/RPC/SoftwareDocumentation1 

 public:
  HRpcRaw();    
  ~HRpcRaw();

  // Functions getVariable
  Float_t getRightTime()              { return rightTime;       }
  Float_t getLeftTime()               { return leftTime;        }
  Float_t getRightTime2()             { return rightTime2;      }
  Float_t getLeftTime2()              { return leftTime2;       }
  Float_t getRightTot()               { return rightTot;        }
  Float_t getLeftTot()                { return leftTot;         }
  Float_t getRightTot2()              { return rightTot2;       }
  Float_t getLeftTot2()               { return leftTot2;        }
  Float_t getRightTotLast()           { return rightTotLast;    }
  Float_t getLeftTotLast()            { return leftTotLast;     }
  Short_t getAddress()                { return address;         }
  Int_t   getLeftFeeAddress()         { return leftFeeAddress;  }
  Int_t   getRightFeeAddress()        { return rightFeeAddress; }

  Short_t getRightLogBit()            { return rightLogBit; }
  Short_t getLeftLogBit()             { return leftLogBit; }

  Int_t   getNLocationIndex()         { return 3;}
  
  inline Int_t   getLocationIndex(Int_t i);

  Int_t   getSector()          const  { return (address>>10)  & 7;  } 
  Int_t   getColumn()          const  { return (address>>7)   & 7;  }  
  Int_t   getCell()            const  { return  address       & 127; }   
 
  Int_t   getRightSubEvtId()   const  { if(rightFeeAddress<0) return -1; return (rightFeeAddress>>17) & 1023; }
  Int_t   getRightTrbChannel() const  { if(rightFeeAddress<0) return -1; return (rightFeeAddress>>10) & 127;  }
  Int_t   getRightDBOInput()   const  { if(rightFeeAddress<0) return -1; return (rightFeeAddress>>8)  & 3;    }
  Int_t   getRightDBONum()     const  { if(rightFeeAddress<0) return -1; return (rightFeeAddress>>5)  & 7;    }
  Int_t   getRightMBONum()     const  { if(rightFeeAddress<0) return -1; return (rightFeeAddress>>3)  & 3;    }
  Int_t   getRightTRBNum()     const  { if(rightFeeAddress<0) return -1; return (rightFeeAddress)     & 7;    }
  
  Int_t   getLeftSubEvtId()    const  { if(leftFeeAddress<0) return -1;  return (leftFeeAddress>>17)  & 1023; }
  Int_t   getLeftTrbChannel()  const  { if(leftFeeAddress<0) return -1;  return (leftFeeAddress>>10)  & 127;  }
  Int_t   getLeftDBOInput()    const  { if(leftFeeAddress<0) return -1;  return (leftFeeAddress>>8)   & 3;    }
  Int_t   getLeftDBONum()      const  { if(leftFeeAddress<0) return -1;  return (leftFeeAddress>>5)   & 7;    }
  Int_t   getLeftMBONum()      const  { if(leftFeeAddress<0) return -1;  return (leftFeeAddress>>3)   & 3;    }
  Int_t   getLeftTRBNum()      const  { if(leftFeeAddress<0) return -1;  return (leftFeeAddress)      & 7;    }
  
  Int_t   getRightNLeadings()       const  { if(rightLogBit<0) return  0; return  rightLogBit>>12;      }
  Int_t   getRightNTrailings()      const  { if(rightLogBit<0) return  0; return (rightLogBit>>8) & 15; }
  Int_t   getRightLastTotFlag()     const  { if(rightLogBit<0) return -1; return (rightLogBit>>7) & 1;  }
  Int_t   getRightDataPairFlag()    const  { if(rightLogBit<0) return -1; return (rightLogBit>>6) & 1;  }
  Int_t   getRightDataVersion()     const  { if(rightLogBit<0) return -1; return (rightLogBit>>4) & 3;  }
  Int_t   getRightDataType()        const  { if(rightLogBit<0) return -1; return (rightLogBit>>1) & 7;  }

  Int_t   getLeftNLeadings()        const  { if(leftLogBit<0) return  0; return  leftLogBit>>12;      }
  Int_t   getLeftNTrailings()       const  { if(leftLogBit<0) return  0; return (leftLogBit>>8) & 15; }
  Int_t   getLeftLastTotFlag()      const  { if(leftLogBit<0) return -1; return (leftLogBit>>7) & 1;  }
  Int_t   getLeftDataPairFlag()     const  { if(leftLogBit<0) return -1; return (leftLogBit>>6) & 1;  }
  Int_t   getLeftDataVersion()      const  { if(leftLogBit<0) return -1; return (leftLogBit>>4) & 3;  }
  Int_t   getLeftDataType()         const  { if(leftLogBit<0) return -1; return (leftLogBit>>1) & 7;  }

 
  // Functions setVariable
  void    setRightTime(Float_t arightTime)         { rightTime=arightTime;        }
  void    setLeftTime(Float_t aleftTime)           { leftTime=aleftTime;          }
  void    setRightTime2(Float_t arightTime2)       { rightTime2=arightTime2;      }
  void    setLeftTime2(Float_t aleftTime2)         { leftTime2=aleftTime2;        }
  void    setRightTot(Float_t arightTot)           { rightTot=arightTot;          }
  void    setLeftTot(Float_t aleftTot)             { leftTot=aleftTot;            }
  void    setRightTot2(Float_t arightTot2)         { rightTot2=arightTot2;        }
  void    setLeftTot2(Float_t aleftTot2)           { leftTot2=aleftTot2;          }
  void    setRightTotLast(Float_t arightTotLast)   { rightTotLast=arightTotLast;  }
  void    setLeftTotLast(Float_t aleftTotLast)     { leftTotLast=aleftTotLast;    }

  inline void    setAddress(Int_t sec,Int_t col,Int_t cell);
  inline void    setRightFeeAddress(Int_t sevtid,Int_t chan,Int_t dbi,Int_t dbn,Int_t mbn,Int_t trbn);
  inline void    setLeftFeeAddress(Int_t sevtid,Int_t chan,Int_t dbi,Int_t dbn,Int_t mbn,Int_t trbn);
  inline void    setRightLogBit(Int_t lm,Int_t tm,Int_t ltf,Int_t pf,Int_t ref,Int_t type,Int_t ex);
  inline void    setLeftLogBit(Int_t lm,Int_t tm,Int_t ltf,Int_t pf,Int_t ref,Int_t type,Int_t ex);
  


  ClassDef(HRpcRaw,2) // Raw data class of RPC detector
};

inline void HRpcRaw::setAddress(Int_t sec,Int_t col,Int_t cell) { 
  address = (sec<<10) + (col<<7) + cell; }

inline void HRpcRaw::setRightFeeAddress(Int_t sevtid,Int_t chan,Int_t dbi,Int_t dbn,Int_t mbn,Int_t trbn) {
  if(sevtid<0 || chan<0 || dbi<0 || dbn<0 || mbn<0 || trbn<0) rightFeeAddress=-1;
  else rightFeeAddress = (sevtid<<17) + (chan<<10) + (dbi<<8) + (dbn<<5) + (mbn<<3) + trbn; 
}

inline void HRpcRaw::setLeftFeeAddress(Int_t sevtid,Int_t chan,Int_t dbi,Int_t dbn,Int_t mbn,Int_t trbn) {
  if(sevtid<0 || chan<0 || dbi<0 || dbn<0 || mbn<0 || trbn<0) leftFeeAddress=-1;
  else leftFeeAddress  = (sevtid<<17) + (chan<<10) + (dbi<<8) + (dbn<<5) + (mbn<<3) + trbn; 
}

inline void HRpcRaw::setRightLogBit(Int_t lm,Int_t tm,Int_t ltf,Int_t pf,Int_t ref,Int_t type,Int_t ex) {
  if(lm<0 || tm<0 || ltf<0 || pf<0 || ref<0 || type<0 || ex<0) rightLogBit=-1;
  else rightLogBit = (lm<<12) + (tm<<8) + (ltf<<7) + (pf<<6) + (ref<<4) + (type<<1) + ex;
}

inline void HRpcRaw::setLeftLogBit(Int_t lm,Int_t tm,Int_t ltf,Int_t pf,Int_t ref,Int_t type,Int_t ex) {
  if(lm<0 || tm<0 || ltf<0 || pf<0 || ref<0 || type<0 || ex<0) leftLogBit=-1;
  else leftLogBit = (lm<<12) + (tm<<8) + (ltf<<7) + (pf<<6) + (ref<<4) + (type<<1) + ex;
}

inline Int_t HRpcRaw::getLocationIndex(Int_t i) { 
  switch (i) {
  case 0 : return getSector(); break;
  case 1 : return getColumn(); break;
  case 2 : return getCell(); break;
  }
  return -1;
}


#endif /* !HRPCRAW_H */
 hrpcraw.h:1
 hrpcraw.h:2
 hrpcraw.h:3
 hrpcraw.h:4
 hrpcraw.h:5
 hrpcraw.h:6
 hrpcraw.h:7
 hrpcraw.h:8
 hrpcraw.h:9
 hrpcraw.h:10
 hrpcraw.h:11
 hrpcraw.h:12
 hrpcraw.h:13
 hrpcraw.h:14
 hrpcraw.h:15
 hrpcraw.h:16
 hrpcraw.h:17
 hrpcraw.h:18
 hrpcraw.h:19
 hrpcraw.h:20
 hrpcraw.h:21
 hrpcraw.h:22
 hrpcraw.h:23
 hrpcraw.h:24
 hrpcraw.h:25
 hrpcraw.h:26
 hrpcraw.h:27
 hrpcraw.h:28
 hrpcraw.h:29
 hrpcraw.h:30
 hrpcraw.h:31
 hrpcraw.h:32
 hrpcraw.h:33
 hrpcraw.h:34
 hrpcraw.h:35
 hrpcraw.h:36
 hrpcraw.h:37
 hrpcraw.h:38
 hrpcraw.h:39
 hrpcraw.h:40
 hrpcraw.h:41
 hrpcraw.h:42
 hrpcraw.h:43
 hrpcraw.h:44
 hrpcraw.h:45
 hrpcraw.h:46
 hrpcraw.h:47
 hrpcraw.h:48
 hrpcraw.h:49
 hrpcraw.h:50
 hrpcraw.h:51
 hrpcraw.h:52
 hrpcraw.h:53
 hrpcraw.h:54
 hrpcraw.h:55
 hrpcraw.h:56
 hrpcraw.h:57
 hrpcraw.h:58
 hrpcraw.h:59
 hrpcraw.h:60
 hrpcraw.h:61
 hrpcraw.h:62
 hrpcraw.h:63
 hrpcraw.h:64
 hrpcraw.h:65
 hrpcraw.h:66
 hrpcraw.h:67
 hrpcraw.h:68
 hrpcraw.h:69
 hrpcraw.h:70
 hrpcraw.h:71
 hrpcraw.h:72
 hrpcraw.h:73
 hrpcraw.h:74
 hrpcraw.h:75
 hrpcraw.h:76
 hrpcraw.h:77
 hrpcraw.h:78
 hrpcraw.h:79
 hrpcraw.h:80
 hrpcraw.h:81
 hrpcraw.h:82
 hrpcraw.h:83
 hrpcraw.h:84
 hrpcraw.h:85
 hrpcraw.h:86
 hrpcraw.h:87
 hrpcraw.h:88
 hrpcraw.h:89
 hrpcraw.h:90
 hrpcraw.h:91
 hrpcraw.h:92
 hrpcraw.h:93
 hrpcraw.h:94
 hrpcraw.h:95
 hrpcraw.h:96
 hrpcraw.h:97
 hrpcraw.h:98
 hrpcraw.h:99
 hrpcraw.h:100
 hrpcraw.h:101
 hrpcraw.h:102
 hrpcraw.h:103
 hrpcraw.h:104
 hrpcraw.h:105
 hrpcraw.h:106
 hrpcraw.h:107
 hrpcraw.h:108
 hrpcraw.h:109
 hrpcraw.h:110
 hrpcraw.h:111
 hrpcraw.h:112
 hrpcraw.h:113
 hrpcraw.h:114
 hrpcraw.h:115
 hrpcraw.h:116
 hrpcraw.h:117
 hrpcraw.h:118
 hrpcraw.h:119
 hrpcraw.h:120
 hrpcraw.h:121
 hrpcraw.h:122
 hrpcraw.h:123
 hrpcraw.h:124
 hrpcraw.h:125
 hrpcraw.h:126
 hrpcraw.h:127
 hrpcraw.h:128
 hrpcraw.h:129
 hrpcraw.h:130
 hrpcraw.h:131
 hrpcraw.h:132
 hrpcraw.h:133
 hrpcraw.h:134
 hrpcraw.h:135
 hrpcraw.h:136
 hrpcraw.h:137
 hrpcraw.h:138
 hrpcraw.h:139
 hrpcraw.h:140
 hrpcraw.h:141
 hrpcraw.h:142
 hrpcraw.h:143
 hrpcraw.h:144
 hrpcraw.h:145
 hrpcraw.h:146
 hrpcraw.h:147
 hrpcraw.h:148
 hrpcraw.h:149
 hrpcraw.h:150
 hrpcraw.h:151
 hrpcraw.h:152
 hrpcraw.h:153
 hrpcraw.h:154
 hrpcraw.h:155
 hrpcraw.h:156