emcOMHLRatioFEMT.h

Go to the documentation of this file.
00001 #ifndef __EMCOMHLRATIOFEMT_H__
00002 #define __EMCOMHLRATIOFEMT_H__
00003 
00004 #ifndef __EMCOMCALFEMT_H__
00005 #include "emcOMCalFEMT.h"
00006 #endif
00007 
00013 template <class T>
00014 class emcOMHLRatioFEMT : public emcOMCalFEMT<T>
00015 {
00016 public:
00017   emcOMHLRatioFEMT(const char* name, const char* title)
00018     : emcOMCalFEMT<T>(name, title)
00019   { }
00020 
00021   virtual ~emcOMHLRatioFEMT()
00022   { }
00023 
00025   virtual bool CanRead(const emcManageable& object) const;
00026 
00028   virtual bool CanWrite(const emcManageable& object) const;
00029 
00031   virtual void FromPdbCalBank(emcCalFEM& calfem, PdbCalBank& bank);
00032 
00034   virtual std::string GetPersistentClassName(void) const
00035   {
00036     return "PdbEmcHLRatioVectorBank";
00037   }
00038 
00040   virtual void ToPdbCalBank(const emcCalFEM& calfem, PdbCalBank& bank);
00041 };
00042 
00043 //_____________________________________________________________________________
00044 //_____________________________________________________________________________
00045 //_____________________________________________________________________________
00046 
00047 #include "EmcIndexer.h"
00048 #include "emcDefines.h"
00049 #include "PdbEmcHLRatioVector.hh"
00050 #include "emcHLRatioFEM.h"
00051 
00052 //_____________________________________________________________________________
00053 template <class T>
00054 bool
00055 emcOMHLRatioFEMT<T>::CanRead(const emcManageable& object) const
00056 {
00057   // we advertize here that we can only handle a given
00058   // number of object types, e.g. emcHLRatioFEM only.
00059 
00060   bool rv = false ;
00061 
00062   if ( object.GetSource() != storage() )
00063     {
00064       return false;
00065     }
00066 
00067   const emcManageable* object_ptr = &object ;
00068   const emcHLRatioFEM* test = dynamic_cast<const emcHLRatioFEM*>(object_ptr) ;
00069 
00070   if (test)
00071     {
00072       rv = true ;
00073     }
00074   return rv ;
00075 }
00076 
00077 //_____________________________________________________________________________
00078 template <class T>
00079 bool
00080 emcOMHLRatioFEMT<T>::CanWrite(const emcManageable& object) const
00081 {
00082   // we advertize here that we can only handle a given
00083   // number of object types, e.g. emcHLRatioFEM only.
00084 
00085   bool rv = false ;
00086 
00087   if ( object.GetDestination() != storage() )
00088     {
00089       return false;
00090     }
00091 
00092   const emcManageable* object_ptr = &object ;
00093   const emcHLRatioFEM* test = dynamic_cast<const emcHLRatioFEM*>(object_ptr) ;
00094 
00095   if (test)
00096     {
00097       rv = true ;
00098     }
00099   return rv ;
00100 }
00101 
00102 //_____________________________________________________________________________
00103 template <class T>
00104 void
00105 emcOMHLRatioFEMT<T>::FromPdbCalBank(emcCalFEM& calfem, PdbCalBank& emcBank)
00106 {
00107   size_t thesize = emcBank.getLength() ;
00108   assert (thesize == 144);
00109   PdbEmcHLRatioVector* pdbhlr;
00110   emcHLRatioFEM* hlrFEM = dynamic_cast<emcHLRatioFEM*>(&calfem) ;
00111   assert(hlrFEM != 0) ;
00112   hlrFEM->Reset() ;
00113 
00114   size_t i;
00115   float average;
00116   float rms;
00117   float intercept;
00118   float slope;
00119 
00120   for ( i = 0 ; i < thesize ; i++)
00121     {
00122       pdbhlr = dynamic_cast<PdbEmcHLRatioVector*>(&(emcBank.getEntry(i)));
00123       pdbhlr->GetRatioVector(average, rms, intercept, slope);
00124       hlrFEM->AppendOneChannel(average, rms, intercept, slope);
00125     }
00126 }
00127 
00128 //_____________________________________________________________________________
00129 template <class T>
00130 void
00131 emcOMHLRatioFEMT<T>::ToPdbCalBank(const emcCalFEM& calfem, PdbCalBank& emcBank)
00132 {
00133 
00134   PdbEmcHLRatioVector* pdbhlr;
00135 
00136   emcBank.setLength(144);
00137 
00138   const emcHLRatioFEM* hlrFEM = dynamic_cast<const emcHLRatioFEM*>(&calfem) ;
00139   assert(hlrFEM != 0) ;
00140   assert(hlrFEM->GetNumberOfChannels() == 144) ;
00141 
00142   for ( size_t i = 0 ; i < hlrFEM->GetNumberOfChannels(); i++)
00143     {
00144       pdbhlr = (PdbEmcHLRatioVector*) & (emcBank.getEntry(i)) ;
00145       assert(pdbhlr != 0) ;
00146       pdbhlr->SetRatioVector(hlrFEM->getValue(i, 0),
00147                              hlrFEM->getValue(i, 1),
00148                              hlrFEM->getValue(i, 2),
00149                              hlrFEM->getValue(i, 3)) ;
00150     }
00151 }
00152 
00153 #endif