00001
00002
00003 #include "StjTPCTxt.h"
00004
00005 #include <iostream>
00006 #include <string>
00007 #include <sstream>
00008
00009 #include <TVector3.h>
00010
00011 ClassImp(StjTPCTxt)
00012
00013 using namespace std;
00014
00015 StjTPCTxt::StjTPCTxt(const char* path)
00016 : _currentEvent(-1)
00017 , _oldLine("")
00018 {
00019 _dataFile.open(path);
00020 }
00021
00022 StjTrackList StjTPCTxt::getTrackList()
00023 {
00024 ++_currentEvent;
00025
00026 string line;
00027
00028 vector<string> currentLines;
00029
00030 while(!_dataFile.eof()) {
00031
00032 if(_oldLine.size()) {
00033 line = _oldLine;
00034 _oldLine = "";
00035 } else {
00036 getline(_dataFile, line);
00037 }
00038
00039 if(0 == line.size()) break;
00040
00041 istringstream ist(line);
00042 long i;
00043 ist >> i;
00044
00045 if (_currentEvent != i) {
00046 _oldLine = line;
00047 break;
00048 }
00049 currentLines.push_back(line);
00050 }
00051
00052 StjTrackList ret;
00053
00054 for(vector<string>::const_iterator it = currentLines.begin(); it != currentLines.end(); ++it) {
00055 istringstream ist(*it);
00056 long i;
00057
00058 StjTrack track;
00059
00060 double px, py, pz;
00061
00062 ist >> i
00063 >> px
00064 >> py
00065 >> pz
00066 >> track.flag
00067 >> track.nHits
00068 >> track.charge
00069 >> track.nHitsPoss
00070 >> track.nHitsDedx
00071 >> track.nHitsFit
00072 >> track.nSigmaPion
00073 >> track.Tdca
00074 >> track.dcaZ
00075 >> track.dcaD
00076 >> track.BField
00077 >> track.bemcRadius
00078 >> track.exitEta
00079 >> track.exitPhi
00080 >> track.dEdx
00081 >> track.trackIndex
00082 >> track.id;
00083
00084 TVector3 p(px, py, pz);
00085 track.pt = p.Pt();
00086 track.eta = p.Eta();
00087 track.phi = p.Phi();
00088
00089 ret.push_back(track);
00090 }
00091
00092 return ret;
00093 }