emcTowerContentv2.C

Go to the documentation of this file.
00001 #include "emcTowerContentv2.h"
00002 #include <iostream>
00003 #include <iomanip>
00004 #include "EmcIndexer.h"
00005 #include "emcDataError.h"
00006 
00007 ClassImp(emcTowerContentv2)
00008 
00009   using namespace std;
00010 
00011 //_____________________________________________________________________________
00012   emcTowerContentv2::emcTowerContentv2()
00013 {
00014   Reset();
00015 }
00016 
00017 //_____________________________________________________________________________
00018 emcTowerContentv2::~emcTowerContentv2()
00019 {
00020 }
00021 
00022 //_____________________________________________________________________________
00023 void
00024 emcTowerContentv2::identify(ostream& os) const
00025 {
00026   os << "emcTowerContentv2::identify" << endl;
00027 }
00028 
00029 //_____________________________________________________________________________
00030 int
00031 emcTowerContentv2::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 emcTowerContentv2::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 emcTowerContentv2::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           << " Gain " << Gain();
00100       out.flags(oldflags);
00101     }
00102 
00103   if ( level > 0 )
00104     {
00105       if ( hasRaw() )
00106         {
00107           out << endl 
00108               << "             "
00109               << " HPre" << setw(6) << HGPre() 
00110               << " HPos" << setw(6) << HGPost() 
00111               << " LPre" << setw(6) << LGPre() 
00112               << " LPos" << setw(6) << LGPost() 
00113               << " TAC " << setw(6) << TAC() 
00114               << " LG" << setw(6) << LG() 
00115               << " HG " << setw(6) << HG() 
00116               << endl
00117               << "             "
00118               << " APre" << setw(7) << AMUPre()
00119               << " APos" << setw(6) << AMUPost()
00120               << " ATAC" << setw(6) << AMUTAC()
00121               << endl
00122               << "             ";
00123           out.flags(oldflags);
00124         }
00125       out  << " DER " << hex << setw(5) << "0x" << DataError();     
00126     }
00127 
00128   out   << " ERN " << hex << setw(5) << "0x" << ErrorNeighbours()
00129        << " WRN " << hex << setw(5) << "0x" << WarnNeighbours()
00130        << dec;
00131 
00132   out << endl;
00133 
00134   out.flags(oldflags);
00135 }
00136 
00137 //_____________________________________________________________________________
00138 void
00139 emcTowerContentv2::Reset()
00140 {
00141   fFEM=-1;
00142   fChannel=-1;
00143   fTowerID=-1;
00144  
00145   fAMUPre = 0;
00146   fAMUPost = 0;
00147   fAMUTAC = 0;
00148 
00149   fHasCalib = false;
00150   fHasDC = false;
00151   fHasRaw = false;
00152   
00153   fGain=0;
00154 
00155   Zero();
00156 }
00157 
00158 //_____________________________________________________________________________
00159 void 
00160 emcTowerContentv2::SetADCTDC(int adc, int tdc, int hg, int lg)
00161 {
00162   fADC=adc;
00163   fTDC=tdc;
00164   fHG=hg;
00165   fLG=lg;
00166   fHasDC=true;
00167 }
00168 
00169 //_____________________________________________________________________________
00170 void 
00171 emcTowerContentv2::SetCalibrated(float energy, float tof)
00172 {
00173   fEnergy = energy;
00174   fTOF = tof;
00175   fHasCalib=true;
00176 }
00177 
00178 //_____________________________________________________________________________
00179 void 
00180 emcTowerContentv2::SetDataError(int dataerror)
00181 {
00182   fDataError = dataerror;
00183 }
00184 
00185 //_____________________________________________________________________________
00186 void
00187 emcTowerContentv2::SetGain(float gain)
00188 {
00189   fGain = gain;
00190 }
00191 
00192 //_____________________________________________________________________________
00193 void
00194 emcTowerContentv2::SetID(int fem, int channel)
00195 {
00196   fFEM = fem;
00197   fChannel = channel;
00198   fTowerID = EmcIndexer::PXSM144iCH_iPX(fFEM,channel);
00199 }
00200 
00201 //_____________________________________________________________________________
00202 void 
00203 emcTowerContentv2::SetNeighbours(unsigned int error, unsigned int warning)
00204 {
00205   fErrorNeighbours = error;
00206   fWarnNeighbours = warning;
00207 }
00208 
00209 //_____________________________________________________________________________
00210 void 
00211 emcTowerContentv2::SetRaw(int hgpost, int hgpre, int lgpost, int lgpre,
00212                           int tac,
00213                           int amupre, int amupost, int amutac, int beamclock)
00214 {
00215   fHGPost = hgpost;
00216   fHGPre = hgpre;
00217   fLGPost = lgpost;
00218   fLGPre = lgpre;
00219   fTAC = tac;
00220   fAMUPre = amupre;
00221   fAMUPost = amupost;
00222   fAMUTAC = amutac;
00223   fBeamClock = beamclock;
00224   fHasRaw=true;
00225 }
00226 
00227 //_____________________________________________________________________________
00228 void
00229 emcTowerContentv2::Zero(void)
00230 {
00231   fHGPost = 4095;
00232   fHGPre = 4095;
00233   fLGPost = 4095;
00234   fLGPre = 4095;
00235   fTAC = 4095;
00236 
00237   fHG = 0;
00238   fLG = 0;
00239 
00240   fADC = 0;
00241   fTDC = 0;
00242 
00243   fEnergy = 0.0;
00244   fTOF = 0.0;
00245   fGain = 0.0;
00246 
00247   fDataError = 0;
00248   fErrorNeighbours = 0;
00249   fWarnNeighbours = 0;
00250 }