00001
00002
00003
00004
00005
00006 #include "reconstruction/data/RecoCsIData.h"
00007 #include "instrument/Calorimeter.h"
00008
00009
00010 RecoCsIData::RecoCsIData (int numLayers)
00011 {
00012 for(int i=0; i<numLayers; i++) {
00013 calorList.push_back((new std::vector<Xtal>));
00014 }
00015 }
00016
00017 RecoCsIData::~RecoCsIData ()
00018 {
00019 clear();
00020 for(unsigned i=0; i<calorList.size(); i++) {
00021 delete calorList[i];
00022 }
00023 }
00024
00025 int RecoCsIData::nHits (unsigned int layer) const
00026 {
00027 return calorList[layer]->size();
00028 }
00029
00030 float RecoCsIData::energy (unsigned int layer, unsigned int n) const
00031 {
00032 return (*calorList[layer])[n].energy;
00033 }
00034
00035 Point RecoCsIData::xtalPos (unsigned int layer, unsigned int n) const
00036 {
00037 return (*calorList[layer])[n].pos;
00038 }
00039
00040
00041 idents::ModuleId RecoCsIData::moduleId (unsigned int layer, unsigned int n) const
00042 {
00043 return (*calorList[layer])[n].module;
00044 }
00045
00046 idents::XtalId RecoCsIData::xtalId (unsigned int layer, unsigned int n) const
00047 {
00048 return (*calorList[layer])[n].id;
00049 }
00050
00051 float RecoCsIData::Lresp (unsigned int layer, unsigned int n) const
00052 {
00053 return (*calorList[layer])[n].Lresp;
00054 }
00055
00056 float RecoCsIData::Rresp (unsigned int layer, unsigned int n) const
00057 {
00058 return (*calorList[layer])[n].Rresp;
00059 }
00060
00061 const std::vector<double>& RecoCsIData::Diodes_Energy (unsigned int layer, unsigned int n) const
00062 {
00063 return (*calorList[layer])[n].Diodes_Energy;
00064 }
00065
00066 void RecoCsIData::load (const CsIDetector& xtal, idents::ModuleId moduleId)
00067 {
00068 if (xtal.hit()) {
00069 calorList[xtal.layer()]->push_back(Xtal(xtal.xtalPos(), xtal.energy(),moduleId ,
00070 xtal.xtalId(), xtal.Lresp(), xtal.Rresp(),
00071 xtal.getDiodesEnergy()));
00072
00073
00074 idents::XtalId id( moduleId, xtal.layer(), xtal.xtalId());
00075 int left = static_cast<int>(xtal.Lresp()*1e6),
00076 right = static_cast<int>(xtal.Rresp()*1e6);
00077 m_xtals[id]=std::pair<int,int>(left,right);
00078 }
00079 }
00080
00081
00082
00083
00084 void RecoCsIData::readData (std::istream& in)
00085 {
00086 float Left, Right;
00087 int X, Y, Z, E;
00088
00089 int numLayers;
00090 in>> numLayers;
00091
00092 for(int i=0; i<numLayers; i++) {
00093 int numX;
00094 in>>numX;
00095 unsigned st, mod;
00096 for(int j=0; j<numX; j++) {
00097 in>>mod>>st>>E>>X>>Y>>Z>>Left>>Right;
00098 calorList[i]->push_back(Xtal(Point(X/1e3, Y/1e3, Z/1e3), E/1e6, idents::ModuleId(mod), st,
00099 Left/1e6, Right/1e6));
00100 }
00101 }
00102 }
00103
00104 void RecoCsIData::writeData (std::ostream& out) const
00105 {
00106 int numLayers = calorList.size();
00107
00108 out<<numLayers<<'\n';
00109 if(out.eof() ) return;
00110 for(int i=0; i<numLayers; i++) {
00111 int numX = nHits(i);
00112 out<<numX<<'\n';
00113 for(int j=0; j<numX; j++) {
00114 out<<moduleId(i, j)<<' '<<xtalId(i, j)<<' '
00115 <<int(1e6*energy(i,j)) <<' '
00116 <<int(1e3*xtalPos(i, j).x())<<' '
00117 <<int(1e3*xtalPos(i, j).y())<<' '
00118 <<int(1e3*xtalPos(i, j).z())<<' '
00119 <<int(1e6*Lresp(i, j))<<' '
00120 <<int(1e6*Rresp(i, j))<<'\n';
00121 }
00122 }
00123 }
00124
00125 void RecoCsIData::clear ()
00126 {
00127 m_xtals.clear();
00128 for(unsigned i=0; i<calorList.size(); i++) {
00129 calorList[i]->clear();
00130 }
00131 }
00132
00133 void RecoCsIData::printOn(std::ostream& out) const
00134 {
00135 out << "RecoCsIData" << std::endl;
00136 writeData(out);
00137 }