00001
00002 #include "TdCsIData.h"
00003
00004
00006 TdCsIData::TdCsIData (int numLayers)
00007 {
00008 for(int i=0; i<numLayers; i++) {
00009 calorList.push_back((new std::vector<Xtal>));
00010 }
00011 }
00012
00016 void TdCsIData::copyUp( TdCsIData* copy,int numLayers)
00017 {
00018 for(int i = 0; i < numLayers; i++)
00019 {
00020 for(int j = 0;j < copy->nHits(i); j++)
00021 {
00022
00023 calorList[i]->push_back(Xtal(copy->xtalPos(i,j), copy->energy(i,j),0,
00024 copy->xtalId(i,j), copy->Lresp(i,j), copy->Rresp(i,j)));
00025 }
00026 }
00027 }
00028
00030 TdCsIData::~TdCsIData ()
00031 {
00032 clear();
00033 for(unsigned i=0; i<calorList.size(); i++) {
00034 delete calorList[i];
00035 }
00036 }
00037
00039 int TdCsIData::nHits (unsigned int layer) const
00040 {
00041 return calorList[layer]->size();
00042 }
00043
00045 float TdCsIData::energy (unsigned int layer, unsigned int n) const
00046 {
00047 if(n < calorList[layer]->size())
00048 {
00049 return (*calorList[layer])[n].energy;
00050 } else
00051 return -2;
00052 }
00053
00055 Point TdCsIData::xtalPos (unsigned int layer, unsigned int n) const
00056 {
00057 return (*calorList[layer])[n].pos;
00058 }
00059
00060
00061 idents::ModuleId TdCsIData::moduleId (unsigned int layer, unsigned int n) const
00062 {
00063 return (*calorList[layer])[n].module;
00064 }
00065
00067 idents::XtalId TdCsIData::xtalId (unsigned int layer, unsigned int n) const
00068 {
00069 return (*calorList[layer])[n].id;
00070 }
00071
00073 float TdCsIData::Lresp (unsigned int layer, unsigned int n) const
00074 {
00075 return (*calorList[layer])[n].Lresp;
00076 }
00077
00079 float TdCsIData::Rresp (unsigned int layer, unsigned int n) const
00080 {
00081 return (*calorList[layer])[n].Rresp;
00082 }
00083
00084
00085 const std::vector<double>& TdCsIData::Diodes_Energy (unsigned int layer, unsigned int n) const
00086 {
00087 return (*calorList[layer])[n].Diodes_Energy;
00088 }
00089
00090
00091
00095 void TdCsIData::load (const CsIDetector& xtal, idents::ModuleId tower)
00096 {
00097
00098 if (xtal.hit()) {
00099 calorList[xtal.layer()]->push_back(Xtal(xtal.xtalPos(), xtal.energy(),tower ,
00100 xtal.xtalId(), xtal.Lresp(), xtal.Rresp(),
00101 xtal.getDiodesEnergy()));
00102
00103
00104 idents::XtalId id( tower, xtal.layer(), xtal.xtalId());
00105 int left = static_cast<int>(xtal.Lresp()*1e6),
00106 right = static_cast<int>(xtal.Rresp()*1e6);
00107 m_xtals[id]=std::pair<int,int>(left,right);
00108 }
00109
00110 }
00111
00112
00113
00114
00115 void TdCsIData::clear ()
00116 {
00117
00118 for(unsigned i=0; i<calorList.size(); i++) {
00119 calorList[i]->clear();
00120 }
00121 }
00122
00123 void TdCsIData::printOn (std::ostream& cout) const
00124 {
00125 cout << "\nCsIData:\n";
00126 for(unsigned layer=0; layer < calorList.size(); layer++)
00127 {
00128 int nh = nHits(layer);
00129 if( nh==0 ) continue;
00130 for(int i=0; i<nh; i++)
00131 cout << '\t' << energy(layer,i) << '\t' << xtalPos(layer,i) << '\n';
00132 }
00133
00134 }
00135 int TdCsIData::count()const{
00136 int n = 0;
00137 for( int i=0; i<8; ++i) n+=nHits(i);
00138 return n;
00139 }