00001 #ifndef __EMCOMLCTOFFEMT_H__
00002 #define __EMCOMLCTOFFEMT_H__
00003
00004 #ifndef __EMCOMCALFEMT_H__
00005 #include "emcOMCalFEMT.h"
00006 #endif
00007
00013 template <class T>
00014 class emcOMLCTofFEMT : public emcOMCalFEMT<T>
00015 {
00016
00017 public:
00018 emcOMLCTofFEMT(const char* name, const char* title)
00019 : emcOMCalFEMT<T>(name, title)
00020 { }
00021
00022 virtual ~emcOMLCTofFEMT()
00023 { }
00024
00026 virtual bool CanRead(const emcManageable& object) const;
00027
00029 virtual bool CanWrite(const emcManageable& object) const;
00030
00032 virtual void FromPdbCalBank(emcCalFEM& calfem, PdbCalBank& bank);
00033
00035 virtual std::string GetPersistentClassName(void) const
00036 {
00037 return "PdbEmcLCTofBank";
00038 }
00039
00041 virtual void ToPdbCalBank(const emcCalFEM& calfem, PdbCalBank& bank);
00042
00043 };
00044
00045
00046
00047
00048
00049 #ifndef __EMCLCTOFFEM_H__
00050 #include "emcLCTofFEM.h"
00051 #endif
00052 #ifndef __EMCINDEXER_H__
00053 #include "EmcIndexer.h"
00054 #endif
00055
00056 #include "PdbCalBank.hh"
00057 #include "PdbEmcLCTof.hh"
00058
00059 #include <cassert>
00060 #include <iostream>
00061 #include <fstream>
00062 #include <cstdio>
00063
00064
00065 template <class T>
00066 bool
00067 emcOMLCTofFEMT<T>::CanRead(const emcManageable& object) const
00068 {
00069
00070
00071
00072 if ( object.GetSource() != storage() )
00073 {
00074 return false;
00075 }
00076
00077 bool rv = false;
00078 const emcManageable* object_ptr = &object;
00079 const emcLCTofFEM* test = dynamic_cast<const emcLCTofFEM*>(object_ptr);
00080
00081 if (test)
00082 {
00083 rv = true;
00084 }
00085 return rv;
00086 }
00087
00088
00089 template <class T>
00090 bool
00091 emcOMLCTofFEMT<T>::CanWrite(const emcManageable& object) const
00092 {
00093
00094
00095
00096 if ( object.GetDestination() != storage() )
00097 {
00098 return false;
00099 }
00100
00101 bool rv = false;
00102 const emcManageable* object_ptr = &object;
00103 const emcLCTofFEM* test = dynamic_cast<const emcLCTofFEM*>(object_ptr);
00104
00105 if (test)
00106 {
00107 rv = true;
00108 }
00109 return rv;
00110 }
00111
00112
00113 template <class T>
00114 void
00115 emcOMLCTofFEMT<T>::FromPdbCalBank(emcCalFEM& calfem, PdbCalBank& emcBank)
00116 {
00117 size_t thesize = emcBank.getLength();
00118 assert (thesize == 144);
00119 size_t i;
00120 float value1;
00121 float value2;
00122
00123 PdbEmcLCTof* pdblct;
00124 emcLCTofFEM* tofFEM = dynamic_cast<emcLCTofFEM*>(&calfem);
00125 tofFEM->Reset();
00126
00127 for ( i = 0; i < thesize; i++)
00128 {
00129 pdblct = dynamic_cast<PdbEmcLCTof*>(&(emcBank.getEntry(i)));
00130 assert(pdblct != 0);
00131 pdblct->GetLCTofs(value1, value2);
00132 tofFEM->AppendOneChannel(value1, value2);
00133 }
00134 }
00135
00136
00137 template<class T>
00138 void
00139 emcOMLCTofFEMT<T>::ToPdbCalBank(const emcCalFEM& calfem, PdbCalBank& emcBank)
00140 {
00141 PdbEmcLCTof* pdblct;
00142
00143 int i;
00144 size_t thesize = calfem.GetNumberOfChannels();
00145 assert(thesize == 144);
00146
00147 emcBank.setLength(thesize);
00148
00149 const emcLCTofFEM* tofFEM = dynamic_cast<const emcLCTofFEM*>(&calfem);
00150 assert(tofFEM != 0);
00151 assert(tofFEM->GetNumberOfChannels() == 144);
00152
00153 for ( i = 0; i < 144; i++)
00154 {
00155 pdblct = (PdbEmcLCTof*) & (emcBank.getEntry(i));
00156 assert(pdblct != 0);
00157 pdblct->SetLCTofs(tofFEM->getValue(i, 0), tofFEM->getValue(i, 1));
00158 }
00159 }
00160
00161 #endif