00001
00002
00003 #include "StjBEMCTxt.h"
00004
00005 #include <iostream>
00006 #include <string>
00007 #include <sstream>
00008
00009 #include <TVector3.h>
00010
00011 using namespace std;
00012
00013 ClassImp(StjBEMCTxt)
00014
00015 StjBEMCTxt::StjBEMCTxt(const char* path)
00016 : _currentEvent(-1)
00017 , _oldLine("")
00018 {
00019 _dataFile.open(path);
00020 }
00021
00022 StjTowerEnergyList StjBEMCTxt::getEnergyList()
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 istringstream ist(line);
00040 long i;
00041 ist >> i;
00042
00043 if (_currentEvent != i) {
00044 _oldLine = line;
00045 break;
00046 }
00047
00048 currentLines.push_back(line);
00049 }
00050
00051 StjTowerEnergyList ret;
00052
00053 for(vector<string>::const_iterator it = currentLines.begin(); it != currentLines.end(); ++it) {
00054 istringstream ist(*it);
00055 long i;
00056
00057 StjTowerEnergy dep;
00058
00059 dep.detectorId = 9;
00060
00061 double x, y, z;
00062
00063 ist >> i
00064 >> dep.towerId
00065 >> x
00066 >> y
00067 >> z
00068 >> dep.vertexX
00069 >> dep.vertexY
00070 >> dep.vertexZ
00071 >> dep.energy
00072 >> dep.adc
00073 >> dep.pedestal
00074 >> dep.rms
00075 >> dep.status;
00076
00077 TVector3 tower(x, y, z);
00078 dep.towerR = tower.Perp();
00079 dep.towerEta = tower.Eta();
00080 dep.towerPhi = tower.Phi();
00081
00082 ret.push_back(dep);
00083 }
00084
00085 return ret;
00086 }