emcCalFEM.C

Go to the documentation of this file.
00001 #include "emcCalFEM.h"
00002 #include <iostream>
00003 #include <cassert>
00004 
00005 using std::ostream;
00006 using std::string;
00007 using std::endl;
00008 
00009 int emcCalFEM::fgNemcCalFEM = 0 ;
00010 
00011 //_____________________________________________________________________________
00012 emcCalFEM::emcCalFEM(int absPosition)
00013   : emcManageable("emcCalFEM","Calibration data for one FEM (base class)",
00014                   "emcCalFEM"),
00015   fStart(0),fEnd(0),
00016   fAbsPosition(absPosition),  
00017   fXmin(0),fXmax(0),fDraft(false),fVersion(0),fDescription(""),
00018   fPinNumber(0),fDefault(false)
00019 {
00020   fgNemcCalFEM++ ;
00021 }
00022 
00023 //_____________________________________________________________________________
00024 emcCalFEM::emcCalFEM(int absPosition,
00025                      const PHTimeStamp& t1, const PHTimeStamp& t2)
00026   : emcManageable("emcCalFEM","Calibration data for one FEM (base class)",
00027                   "emcCalFEM"),
00028     fStart(t1),fEnd(t2),
00029     fAbsPosition(absPosition),
00030     fXmin(0),fXmax(0),fDraft(false),fVersion(0),fDescription(""),
00031     fPinNumber(0),fDefault(false)
00032 {
00033   fgNemcCalFEM++ ;
00034 }
00035 
00036 //_____________________________________________________________________
00037 emcCalFEM::emcCalFEM(const emcCalFEM& o) : emcManageable()
00038 {
00039   o.Copy(*this) ;
00040   fgNemcCalFEM++ ;
00041 }
00042 
00043 //_____________________________________________________________________________
00044 emcCalFEM&
00045 emcCalFEM::operator=(const emcCalFEM& o)
00046 {
00047   if ( this == &o ) return *this ;
00048   o.Copy(*this) ;
00049   return *this ;
00050 }
00051 
00052 //_____________________________________________________________________
00053 void emcCalFEM::Copy(emcCalFEM& o) const
00054 {
00055   o.fStart = fStart ;
00056   o.fEnd = fEnd ;
00057   o.fAbsPosition = fAbsPosition ;
00058   o.fXmin = fXmin ;
00059   o.fXmax = fXmax ;
00060   o.fDraft = fDraft ; 
00061   o.fVersion = fVersion ;
00062   o.fDescription = fDescription ;   
00063   o.fPinNumber = fPinNumber ;
00064   o.fDefault = fDefault ;
00065 }
00066 
00067 //_____________________________________________________________________________
00068 emcCalFEM::~emcCalFEM()
00069 {
00070   fgNemcCalFEM-- ;
00071 }
00072 
00073 //_____________________________________________________________________________
00074 int emcCalFEM::FEMCode(int absPosition, int pinNumber, 
00075                        int /*post_pre*/, int /*tac_pre*/)
00076 {
00077   // Make a single integer value from 4 characteristic values of a FEM.
00078   int code ;
00079 
00080   assert(absPosition>=0 && absPosition<200);
00081   assert(pinNumber>=0 && pinNumber<2048);
00082 
00083   code = ( ( absPosition ) & 0xFFF ) +
00084     ( ( pinNumber << 12 ) & 0xFFF000 );
00085 
00086   return code ;
00087 }
00088 
00089 //_____________________________________________________________________________
00090 void emcCalFEM::FEMDecode(int code, int& absPosition, int& pinNumber, 
00091                             int& post_pre, int& tac_pre)
00092 {
00093   absPosition = (code & 0xFFF) ;
00094   pinNumber = ( ( code & 0xFFF000 ) >> 12 ) ;
00095   post_pre = 0 ;
00096   tac_pre  = 0 ;
00097 }
00098 
00099 //_____________________________________________________________________________
00100 bool emcCalFEM::IsValid(const PHTimeStamp& cwhen) const
00101 {
00102   PHTimeStamp& when = const_cast<PHTimeStamp&>(cwhen) ;
00103   return when.isInRange(fStart,fEnd) ;
00104 }
00105 
00106 //_____________________________________________________________________________
00107 ostream&
00108 emcCalFEM::Print(ostream& out, int /*level*/) const
00109 {
00110   out << string(50,'-') << endl ;
00111   out << " AbsPosition=" << fAbsPosition ;
00112   if (fPinNumber>0) {
00113     out << " PinNumber=" << fPinNumber ;
00114   }
00115   out << " tStart=" << fStart
00116        << " tEnd=" << fEnd << endl ;
00117   out << " Flavour = " << GetCategory() << " Nchannels=" << size() ;
00118   if (IsDefault()) {
00119     out << " (DEFAULT)" ;
00120   }
00121   out << endl ;
00122   out << string(50,'-') << endl ;
00123   return out ;
00124 }