emcTowerContentv1.C

Go to the documentation of this file.
00001 #include "emcTowerContentv1.h"
00002 #include <iostream>
00003 #include <iomanip>
00004 #include "EmcIndexer.h"
00005 #include "emcDataError.h"
00006 
00007 ClassImp(emcTowerContentv1)
00008 
00009   using namespace std;
00010 
00011 //_____________________________________________________________________________
00012   emcTowerContentv1::emcTowerContentv1()
00013 {
00014   Reset();
00015 }
00016 
00017 //_____________________________________________________________________________
00018 emcTowerContentv1::~emcTowerContentv1()
00019 {
00020 }
00021 
00022 //_____________________________________________________________________________
00023 void
00024 emcTowerContentv1::identify(ostream& os) const
00025 {
00026   os << "emcTowerContentv1::identify" << std::endl;
00027 }
00028 
00029 //_____________________________________________________________________________
00030 int
00031 emcTowerContentv1::isValid(void) const
00032 {
00033   if (fFEM>=0)
00034     {
00035       return 1;
00036     }
00037   else
00038     {
00039       return 0;
00040     }
00041 }
00042 
00043 //_____________________________________________________________________________
00044 bool
00045 emcTowerContentv1::isZero(void) const
00046 {
00047  //  if ( fTAC != 4095 ||
00048 //        fHGPost != 4095 ||
00049 //        fLGPost != 4095 ||
00050 //        fHGPre != 4095 ||
00051 //        fLGPre != 4095 ) {
00052 //     return false ;
00053 //   }
00054 
00055   if ( fDataError & emcDataError::CHANNEL_DISABLED() )
00056     {
00057       return true;
00058     }
00059   else
00060     {
00061       return false;
00062     }
00063 }
00064 
00065 //_____________________________________________________________________________
00066 void
00067 emcTowerContentv1::print(ostream& out, int level) const
00068 {
00069   std::ostream::fmtflags oldflags = out.flags();
00070 
00071   int arm,sector,iy,iz;
00072 
00073   int iS,iST;
00074   EmcIndexer::iPXiSiST(TowerID(),iS,iST);
00075   EmcIndexer::iSTxyST(iS,iST,iz,iy);
00076 
00077   EmcIndexer::sectorOnlineToOffline(iS,arm,sector);
00078 
00079   out << "FEM" << setw(3) << dec << FEM()
00080       << " CH" << setw(4) << dec << Channel()
00081       << " TID " << setw(7) << TowerID() 
00082       << " ARM " << setw(2) << arm
00083       << " SEC " << setw(2) << sector
00084       << " Y   " << setw(3) << iy
00085       << " z   " << setw(3) << iz;
00086   if ( hasDC() )
00087     {
00088       out << " ADC " << setw(7) << ADC() 
00089           << " TDC " << setw(6) << TDC();
00090       out.flags(oldflags);
00091     }
00092   if ( hasCalib() ) 
00093     {
00094       out << " E   ";
00095       out.setf(ios::scientific);
00096       out.precision(3);
00097       out << Energy()
00098           << " TOF " << ToF();
00099       out.flags(oldflags);
00100     }
00101 
00102   if ( level > 0 )
00103     {
00104       if ( hasRaw() )
00105         {
00106           out << endl 
00107               << "             "
00108               << " HPre" << setw(6) << HGPre() 
00109               << " HPos" << setw(6) << HGPost() 
00110               << " LPre" << setw(6) << LGPre() 
00111               << " LPos" << setw(6) << LGPost() 
00112               << " TAC " << setw(6) << TAC() 
00113               << " LG" << setw(6) << LG() 
00114               << " HG " << setw(6) << HG() 
00115               << endl
00116               << "             "
00117               << " APre" << setw(7) << AMUPre()
00118               << " APos" << setw(6) << AMUPost()
00119               << " ATAC" << setw(6) << AMUTAC()
00120               << endl
00121               << "             ";
00122           out.flags(oldflags);
00123         }
00124       out  << " DER " << hex << setw(5) << "0x" << DataError();     
00125     }
00126 
00127   out   << " ERN " << hex << setw(5) << "0x" << ErrorNeighbours()
00128        << " WRN " << hex << setw(5) << "0x" << WarnNeighbours()
00129        << dec;
00130 
00131   out << endl;
00132 
00133   out.flags(oldflags);
00134 }
00135 
00136 //_____________________________________________________________________________
00137 void
00138 emcTowerContentv1::Reset()
00139 {
00140   fFEM=-1;
00141   fChannel=-1;
00142   fTowerID=-1;
00143  
00144   fAMUPre = 0;
00145   fAMUPost = 0;
00146   fAMUTAC = 0;
00147 
00148   fHasCalib = false;
00149   fHasDC = false;
00150   fHasRaw = false;
00151   
00152   Zero();
00153 }
00154 
00155 //_____________________________________________________________________________
00156 void 
00157 emcTowerContentv1::SetADCTDC(int adc, int tdc, int hg, int lg)
00158 {
00159   fADC=adc;
00160   fTDC=tdc;
00161   fHG=hg;
00162   fLG=lg;
00163   fHasDC=true;
00164 }
00165 
00166 //_____________________________________________________________________________
00167 void 
00168 emcTowerContentv1::SetCalibrated(float energy, float tof)
00169 {
00170   fEnergy = energy;
00171   fTOF = tof;
00172   fHasCalib=true;
00173 }
00174 
00175 //_____________________________________________________________________________
00176 void 
00177 emcTowerContentv1::SetDataError(int dataerror)
00178 {
00179   fDataError = dataerror;
00180 }
00181 
00182 //_____________________________________________________________________________
00183 void
00184 emcTowerContentv1::SetID(int fem, int channel)
00185 {
00186   fFEM = fem;
00187   fChannel = channel;
00188   fTowerID = EmcIndexer::PXSM144iCH_iPX(fFEM,channel);
00189 }
00190 
00191 //_____________________________________________________________________________
00192 void 
00193 emcTowerContentv1::SetNeighbours(unsigned int error, unsigned int warning)
00194 {
00195   fErrorNeighbours = error;
00196   fWarnNeighbours = warning;
00197 }
00198 
00199 //_____________________________________________________________________________
00200 void 
00201 emcTowerContentv1::SetRaw(int hgpost, int hgpre, int lgpost, int lgpre,
00202                           int tac,
00203                           int amupre, int amupost, int amutac, int beamclock)
00204 {
00205   fHGPost = hgpost;
00206   fHGPre = hgpre;
00207   fLGPost = lgpost;
00208   fLGPre = lgpre;
00209   fTAC = tac;
00210   fAMUPre = amupre;
00211   fAMUPost = amupost;
00212   fAMUTAC = amutac;
00213   fBeamClock = beamclock;
00214   fHasRaw=true;
00215 }
00216 
00217 //_____________________________________________________________________________
00218 void
00219 emcTowerContentv1::Zero(void)
00220 {
00221   fHGPost = 4095;
00222   fHGPre = 4095;
00223   fLGPost = 4095;
00224   fLGPre = 4095;
00225   fTAC = 4095;
00226 
00227   fHG = 0;
00228   fLG = 0;
00229 
00230   fADC = 0;
00231   fTDC = 0;
00232 
00233   fEnergy = 0.0;
00234   fTOF = 0.0;
00235 
00236   fDataError = 0;
00237   fErrorNeighbours = 0;
00238   fWarnNeighbours = 0;
00239 }