#include "EventReader.h" #include "../littrack/parallel/LitHit.h" #include "../littrack/parallel/LitTrack.h" #include "../littrack/parallel/LitTrackParam.h" #include "../littrack/parallel/muon/LitDetectorGeometryMuon.h" #include "../littrack/utils/CbmLitMemoryManagment.h" #include #include EventReader::EventReader(): fNofEvents(10), fHitsFileName("data/sa_hits.txt"), fSeedsFileName("data/sa_seeds.txt") { } EventReader::~EventReader() { } void EventReader::CreateEventBuffer() { // Read hit data std::ifstream finHits(fHitsFileName.c_str(), std::ifstream::in); fHits.resize(fNofEvents); for(int iEvent = 0; iEvent < fNofEvents; iEvent++) { int event, nofHits; finHits >> event >> nofHits; // std::cout << event << " " << nofHits << std::endl; for (int j = 0; j < nofHits; j++) { float x, y, z, dx, dy, dxy; int planeId, refId; finHits >> x >> y >> z >> dx >> dy >> dxy >> planeId >> refId; LitScalPixelHit* lhit = new LitScalPixelHit; lhit->X = x; lhit->Y = y; lhit->Dx = dx; lhit->Dy = dy; lhit->Dxy = dxy; lhit->planeId = planeId; lhit->refId = refId; lhit->Z = z; fHits[iEvent].push_back(lhit); // std::cout << *lhit; } // std::cout << "check " << iEvent << " " << fHits[iEvent].size() << std::endl; } finHits.close(); // Read seeds data std::ifstream finSeeds(fSeedsFileName.c_str(), std::ifstream::in); fSeeds.resize(fNofEvents); for(int i = 0; i < fNofEvents; i++) { int event, nofSeeds; finSeeds >> event >> nofSeeds; // std::cout << event << " " << nofSeeds << std::endl; for (int j = 0; j < nofSeeds; j++) { float x, y, z, tx, ty, qp; finSeeds >> x >> y >> z >> tx >> ty >> qp; float cov[15]; for (unsigned int k = 0; k < 15; ++k) finSeeds >> cov[k]; LitTrackParamScal lpar; lpar.X = x; lpar.Y = y; lpar.Tx = tx; lpar.Ty = ty; lpar.Qp = qp; lpar.Z = z; lpar.C0 = cov[0]; lpar.C1 = cov[1]; lpar.C2 = cov[2]; lpar.C3 = cov[3]; lpar.C4 = cov[4]; lpar.C5 = cov[5]; lpar.C6 = cov[6]; lpar.C7 = cov[7]; lpar.C8 = cov[8]; lpar.C9 = cov[9]; lpar.C10 = cov[10]; lpar.C11 = cov[11]; lpar.C12 = cov[12]; lpar.C13 = cov[13]; lpar.C14 = cov[14]; LitScalTrack* ltrack = new LitScalTrack; ltrack->paramLast = lpar; ltrack->paramFirst = lpar; fSeeds[i].push_back(ltrack); // std::cout << *ltrack; } // std::cout << "check " << i << " " << fSeeds[i].size() << std::endl; } finSeeds.close(); } void EventReader::ClearEventBuffer() { for(int iEvent = 0; iEvent < GetNofEvents(); iEvent++) { std::for_each(&fSeeds[iEvent][0], &fSeeds[iEvent][0] + GetNofSeeds(iEvent), DeleteObject()); fSeeds[iEvent].clear(); std::for_each(&fHits[iEvent][0], &fHits[iEvent][0] + GetNofHits(iEvent), DeleteObject()); fHits[iEvent].clear(); } fSeeds.clear(); fHits.clear(); }