16 #define HBT_BFIELD 0.5*tesla
19 #include "StHbtMaker/Reader/StHbtGstarTxtReader.h"
20 #include "StHbtMaker/Base/StHbtEventCut.h"
21 #include "StHbtMaker/Base/StHbtTrackCut.h"
22 #include "StHbtMaker/Base/StHbtV0Cut.h"
23 #include "StHbtMaker/Base/StHbtKinkCut.h"
25 #include "SystemOfUnits.h"
26 #include "StHbtMaker/Infrastructure/StHbtTrackCollection.hh"
27 #include "StHbtMaker/Infrastructure/StHbtV0Collection.hh"
28 #include "phys_constants.h"
29 #include "StPhysicalHelix.hh"
35 #if !(ST_NO_NAMESPACES)
36 using namespace units;
40 int get_next_int(
string strline,
int start_at,
int& wordends){
41 int wordstarts = strline.find_first_not_of(
" ",start_at);
42 wordends = strline.find_first_of(
" ",wordstarts);
43 int ians = atoi((strline.substr(wordstarts,wordends-1)).c_str());
46 float get_next_float(
string strline,
int start_at,
int& wordends){
47 int wordstarts = strline.find_first_not_of(
" ",start_at);
48 wordends = strline.find_first_of(
" ",wordstarts);
49 float ans = atof((strline.substr(wordstarts,wordends-1)).c_str());
52 double dedxMean_geantTxt(
double mass,
double momentum){
54 double tpcDedxGain = 0.174325e-06;
55 double tpcDedxOffset = -2.71889;
56 double tpcDedxRise = 776.626;
58 double gamma = ::sqrt(::pow(momentum/mass,2)+1.);
59 double beta = ::sqrt(1. - 1./::pow(gamma,2));
60 double rise = tpcDedxRise*::pow(beta*gamma,2);
62 dedxMean = tpcDedxGain/::pow(beta,2) * (0.5*::log(rise)-::pow(beta,2)- tpcDedxOffset);
71 StHbtGstarTxtReader::StHbtGstarTxtReader() : mInputStream(0){
72 mFileName =
"GstarTextFile";
77 StHbtGstarTxtReader::StHbtGstarTxtReader(
char* file) : mInputStream(0), mFileName(file)
83 StHbtGstarTxtReader::~StHbtGstarTxtReader(){
91 StHbtEvent* StHbtGstarTxtReader::ReturnHbtEvent(){
93 cout <<
"StHbtGstarTxtReader::ReturnHbtEvent() - there is no input stream!";
97 if (!(*mInputStream)){
98 cout <<
"StHbtGstarTxtReader::ReturnHbtEvent() - input stream in bad state!" << endl;
99 cout <<
"State is " << mInputStream->rdstate() << endl;
112 cout <<
"StHbtGstarTxtReader::ReturnHbtEvent() -- find and decode EVENT line..." << endl;
113 while (strline.substr(0,keyword.size()) != keyword){
114 (*mInputStream).getline(line,100);
116 if (!(mInputStream->good())){
117 cout <<
"StHbtGstarTxtReader::ReturnHbtEvent() - input stream in bad state!" <<endl;
118 cout <<
"State is " << mInputStream->rdstate() << endl;
127 int ievent = get_next_int(strline,keyword.size()+1,stringposition);
128 int ntracks = get_next_int(strline,stringposition,stringposition);
129 int nvertices = get_next_int(strline,stringposition,stringposition);
130 cout <<
"Event number is " << ievent << endl;
131 cout <<
"Number of tracks is " << ntracks << endl;
132 cout <<
"Number of vertices is " << nvertices << endl;
135 cout <<
"StHbtGstarTxtReader::ReturnHbtEvent() - hit end-of-file " << endl;
136 cout <<
"State is " << mInputStream->rdstate() << endl;
145 event->SetEventNumber(ievent);
146 event->SetCtbMult(0);
147 event->SetZdcAdcEast(0);
148 event->SetZdcAdcWest(0);
149 event->SetNumberOfTpcHits(0);
150 event->SetNumberOfTracks(ntracks);
151 event->SetNumberOfGoodTracks(ntracks);
152 event->SetReactionPlane(0.);
153 event->SetReactionPlaneSubEventDifference(0.);
154 event->SetPrimVertPos(vertexPos);
162 for (
int itrack=0; itrack<ntracks; itrack++){
164 while (strline.substr(0,keyword.size()) != keyword){
165 (*mInputStream).getline(line,100);
167 if (!(mInputStream->good())){
168 cout <<
"StHbtGstarTxtReader::ReturnHbtEvent() - input stream in bad state!" <<endl;
169 cout <<
"State is " << mInputStream->rdstate() << endl;
177 pid = get_next_int(strline,keyword.size()+1,stringposition);
178 px = get_next_float(strline,stringposition,stringposition);
179 py = get_next_float(strline,stringposition,stringposition);
180 pz = get_next_float(strline,stringposition,stringposition);
188 hbtTrack->SetTrackId(itrack);
194 hbtTrack->SetNSigmaElectron(0.);
195 hbtTrack->SetNSigmaPion(999.);
196 hbtTrack->SetNSigmaKaon(-999.);
197 hbtTrack->SetNSigmaProton(-999.);
198 mass = 5.1099905E-04;
203 hbtTrack->SetNSigmaElectron(999.);
204 hbtTrack->SetNSigmaPion(0.);
205 hbtTrack->SetNSigmaKaon(-999.);
206 hbtTrack->SetNSigmaProton(-999.);
212 hbtTrack->SetNSigmaElectron(999.);
213 hbtTrack->SetNSigmaPion(999.0);
214 hbtTrack->SetNSigmaKaon(0.);
215 hbtTrack->SetNSigmaProton(-999.);
220 hbtTrack->SetNSigmaElectron(999.);
221 hbtTrack->SetNSigmaPion(999.);
222 hbtTrack->SetNSigmaKaon(999.);
223 hbtTrack->SetNSigmaProton(0.);
244 hbtTrack->SetP( tmpP );
249 hbtTrack->SetNHits(45);
250 hbtTrack->SetNHitsPossible(45);
251 hbtTrack->SetdEdx( dedxMean_geantTxt( mass, tmpP.mag() ) );
252 hbtTrack->SetPt( tmpP.perp());
253 hbtTrack->SetCharge(charge);
256 hbtTrack->SetHelix(helix);
258 hbtTrack->SetDCAxy(0.001);
259 hbtTrack->SetDCAz(0.001);
260 hbtTrack->SetChiSquaredXY( 0.);
261 hbtTrack->SetChiSquaredZ( 0.);
263 event->TrackCollection()->push_back(hbtTrack);
265 cout <<
event->TrackCollection()->size() <<
" tracks pushed to collection" << endl;
271 StHbtString StHbtGstarTxtReader::Report(){
272 StHbtString temp =
"\n This is the StHbtGstarTxtReader - no Early Cuts applied\n";
273 temp +=
" *** NOTE I am kinda stupid-- I do NOT handle vertices, and I ONLY\n";
274 temp +=
" *** know about pions protons and kaons\n";
280 int StHbtGstarTxtReader::Init(
const char* ReadWrite, StHbtString& Message){
281 cout <<
" *\n *\n *\n StHbtGstarTxtReader::Init() being called*\n *\n";
284 if (((*ReadWrite)==
'r')|| ((*ReadWrite)==
'R')){
285 mInputStream =
new ifstream;
286 mInputStream->open(mFileName);
287 if (!(*mInputStream)){
288 cout <<
"StHbtGstarTxtReader::Init() - Cannot open input file! " << endl;
291 cout <<
"StHbtGstarTxtReader::Init() - being configured as a Reader - " << ReadWrite << endl;
294 cout <<
" CANNOT BE CONFIGURED AS A WRITER" << endl;
301 void StHbtGstarTxtReader::Finish(){
302 if (mInputStream) mInputStream->close();