00001 #include "StHbtFlowPicoReader.h"
00002 #include "StThreeVectorD.hh"
00003 #include "StHbtMaker/Infrastructure/StHbtEvent.hh"
00004 #include "StHbtMaker/doc/Make/math_constants.h"
00005 #include "SystemOfUnits.h"
00006 #include <fstream>
00007
00008 ClassImp(StHbtFlowPicoReader)
00009
00010 const double ETAMIN = -5.;
00011 const double ETAMAX = 5.;
00013 StHbtFlowPicoReader::StHbtFlowPicoReader(string list_inp,int nevents)
00014 {
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 cout << "StHbtFlowPicoReader::StHbtFlowPicoReader Initializing the reader ! \n";
00025 to_do_list_inp = list_inp;
00026 mReaderStatus = 0;
00027 Nbytes = 0;
00028 crrnt_entry = 0;
00029 crrnt_eventI = 0;
00030 NEvt_in_chain = 0;
00031 NEVENTS = nevents;
00032
00033
00034
00035 std::ifstream input(to_do_list_inp.c_str());
00036
00037 while (input.good())
00038 {
00039 string filename;
00040 input >> filename;
00041
00042 if (filename!="" )
00043 {
00044 L_runs.push_back(filename);
00045 }
00046 }
00047
00048 input.close();
00049 cout << " chain has "<<L_runs.size()<<" runs \n";
00050
00051 Init();
00052 }
00054 int StHbtFlowPicoReader::Init()
00055 {
00056 cout << " StHbtFlowPicoReader::Init\n";
00057
00058
00059 DST_Chain = new TChain("FlowTree");
00060
00061 vector<string>::const_iterator it = L_runs.begin();
00062
00063
00064 while (it!=L_runs.end())
00065 {
00066 if (NEvt_in_chain <NEVENTS)
00067 {
00068 cout << "StHbtFlowPicoReader::StHbtFlowPicoReader add " <<*it<<"\n";
00069
00070 TChain* tmpChain = new TChain("FlowTree");
00071
00072 int ok1 = tmpChain->Add((*it).c_str());
00073 if (!ok1) {cout << "tmpChain->Add error !\n";}
00074 int tmpEntries = (int)tmpChain->GetEntries();
00075 NEvt_in_chain += tmpEntries;
00076 cout << " in file " <<tmpEntries<<" total "<<NEvt_in_chain<< "\n";
00077 delete tmpChain;
00078 cout << " adding... \n";
00079 int ok2 = DST_Chain->Add((*it).c_str());
00080 if (!ok2) {cout << "DST_Chain->Add error !\n";}
00081 }
00082 ++it;
00083 }
00084
00085 this->pDST = new flow_pDST(DST_Chain);
00086 cout << "ST_txtr::ST_txtr flow_pDST instantiated \n";
00087 this->pDST->fChain->SetBranchStatus("*",0);
00088
00089
00090 this->pDST->fChain->SetBranchStatus("mRunID",1);
00091 this->pDST->fChain->SetBranchStatus("mMagneticField",1);
00092 this->pDST->fChain->SetBranchStatus("mEventID",1);
00093 this->pDST->fChain->SetBranchStatus("mNtrack",1);
00094 this->pDST->fChain->SetBranchStatus("mVertexX",1);
00095 this->pDST->fChain->SetBranchStatus("mVertexY",1);
00096 this->pDST->fChain->SetBranchStatus("mVertexZ",1);
00097 this->pDST->fChain->SetBranchStatus("fTracks.fUniqueID",1);
00098 this->pDST->fChain->SetBranchStatus("fTracks.fBits",1);
00099 this->pDST->fChain->SetBranchStatus("fTracks.mPtGlobal",1);
00100 this->pDST->fChain->SetBranchStatus("fTracks.mEtaGlobal",1);
00101 this->pDST->fChain->SetBranchStatus("fTracks.mPhiGlobal",1);
00102 this->pDST->fChain->SetBranchStatus("fTracks.mNhits",1);
00103 this->pDST->fChain->SetBranchStatus("fTracks.mCharge",1);
00104 this->pDST->fChain->SetBranchStatus("fTracks.mFitPts",1);
00105 this->pDST->fChain->SetBranchStatus("fTracks.mMaxPts",1);
00106 this->pDST->fChain->SetBranchStatus("fTracks.mDedx",1);
00107 this->pDST->fChain->SetBranchStatus("fTracks.mPidElectron",1);
00108 this->pDST->fChain->SetBranchStatus("fTracks.mPidPion",1);
00109 this->pDST->fChain->SetBranchStatus("fTracks.mPidKaon",1);
00110 this->pDST->fChain->SetBranchStatus("fTracks.mPidProton",1);
00111 this->pDST->fChain->SetBranchStatus("fTracks.mMostLikelihoodPID",1);
00112 this->pDST->fChain->SetBranchStatus("fTracks.mMostLikelihoodProb",1);
00113 this->pDST->fChain->SetBranchStatus("fTracks.mDcaGlobal",1);
00114 this->pDST->fChain->SetBranchStatus("fTracks.mDcaGlobalX",1);
00115 this->pDST->fChain->SetBranchStatus("fTracks.mDcaGlobalY",1);
00116 this->pDST->fChain->SetBranchStatus("fTracks.mDcaGlobalZ",1);
00117
00118 Nentries = (int)(this->pDST->fChain->GetEntries());
00119
00120 if (Nentries) {return 0;}
00121 else
00122 {
00123 cout << "StHbtFlowPicoReader::Init() -- see no entries \n";
00124 return 1;
00125 }
00126 }
00128 StHbtEvent* StHbtFlowPicoReader::ReturnHbtEvent()
00129 {
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 StHbtEvent* hbtEvent = new StHbtEvent();
00143
00144 cout << "StHbtFlowPicoReader::ReturnHbtEvent() crrnt_entry begins "
00145 <<crrnt_entry<<"\n";
00146 int ientry;
00147 if (crrnt_entry<Nentries)
00148 {
00149 ientry = this->pDST->LoadTree(crrnt_entry);
00150 nb = this->pDST->fChain->GetEntry(crrnt_entry); Nbytes += nb;
00151
00152 hbtEvent->SetEventNumber(crrnt_eventI);
00153 hbtEvent->SetCtbMult(0);
00154 hbtEvent->SetZdcAdcEast(0);
00155 hbtEvent->SetZdcAdcWest(0);
00156 hbtEvent->SetNumberOfTpcHits(0);
00157
00158 int Mult = this->pDST->fTracks_;
00159 hbtEvent->SetNumberOfTracks(Mult);
00160 hbtEvent->SetNumberOfGoodTracks(Mult);
00161 hbtEvent->SetReactionPlane(0.);
00162 hbtEvent->SetReactionPlaneSubEventDifference(0.);
00163
00164 float BTesla = pDST->mMagneticField;
00165 float vX = pDST->mVertexX;
00166 float vY = pDST->mVertexY;
00167 float vZ = pDST->mVertexZ;
00168
00169 StHbtThreeVector VertexPosition = StHbtThreeVector(vX,vY,vZ);
00170
00171 hbtEvent->SetPrimVertPos(VertexPosition);
00172
00173
00174 int UncorrPositivePrim = 0;
00175 int UncorrNegativePrim = 0;
00176
00177 for (short itrack = 0; itrack<Mult; itrack++)
00178 {
00179 StHbtThreeVector tmpP;
00180 float Phi = pDST->fTracks_mPhiGlobal[itrack];
00181 float pT = pDST->fTracks_mPtGlobal[itrack];
00182 float eta = pDST->fTracks_mEtaGlobal[itrack];
00183 float pX = pT*cos(Phi);
00184 float pY = pT*sin(Phi);
00185 float expeta = exp(-eta);
00186 float theta = 2*atan(expeta);
00187
00188 short charge = pDST->fTracks_mCharge[itrack];
00189 bool reject = false;
00190 if (charge ==0) reject = true;
00191
00192 if ( !(eta>ETAMIN) || !(eta<ETAMAX)) reject = true;
00193
00194
00195 if (!reject)
00196 {
00197 StHbtTrack* hbtTrack = new StHbtTrack();
00198 hbtTrack->SetHiddenInfo(0);
00199
00200
00201
00202
00203
00204
00205 if (theta<0) {theta = C_PI+theta;}
00206 float p = pT/sin(theta);
00207 float pZ = p-pT*expeta;
00208
00209
00210 tmpP.setX(pX);
00211 tmpP.setY(pY);
00212 tmpP.setZ(pZ);
00213 hbtTrack->SetP(tmpP);
00214
00215 hbtTrack->SetTrackId(itrack);
00216
00217 float dEdx = pDST->fTracks_mDedx[itrack];
00218
00219 float ProbElectron = pDST->fTracks_mPidElectron[itrack];
00220 float ProbPion = pDST->fTracks_mPidPion[itrack];
00221 float ProbKaon = pDST->fTracks_mPidKaon[itrack];
00222 float ProbProton = pDST->fTracks_mPidProton[itrack];
00223
00224 hbtTrack->SetdEdx(dEdx);
00225
00226 hbtTrack->SetPidProbElectron(ProbElectron);
00227
00228 hbtTrack->SetPidProbPion(ProbPion);
00229 hbtTrack->SetPidProbKaon(ProbKaon);
00230 hbtTrack->SetPidProbProton(ProbProton);
00231
00232
00233 int Nhits = pDST->fTracks_mNhits[itrack];
00234
00235 float DCA = pDST->fTracks_mDcaGlobal[itrack];
00236 float DCAX = pDST->fTracks_mDcaGlobalX[itrack];
00237 float DCAY = pDST->fTracks_mDcaGlobalY[itrack];
00238 float DCAZ = pDST->fTracks_mDcaGlobalZ[itrack];
00239
00240 float DCAXY = sqrt(DCAX*DCAX+DCAY*DCAY);
00241
00242 hbtTrack->SetDCAxyGlobal(DCAXY);
00243 hbtTrack->SetDCAzGlobal(DCAZ);
00244
00245 if (Nhits>=10 && fabs(eta)<0.5 && DCA<3.)
00246 {
00247 if (charge>0) {UncorrPositivePrim++;}
00248 if (charge<0) {UncorrNegativePrim++;}
00249 }
00250 hbtTrack->SetNHits(Nhits);
00251 hbtTrack->SetCharge(charge);
00252 hbtTrack->SetNHitsPossible(pDST->fTracks_mMaxPts[itrack]);
00253 hbtTrack->SetPt(pT);
00254 hbtTrack->SetPtGlobal(pT);
00255
00256 int gid = pDST->fTracks_mMostLikelihoodPID[itrack];
00257 float pid_prob = pDST->fTracks_mMostLikelihoodProb[itrack];
00258
00259
00260 if (pid_prob == 1.)
00261 {
00262 if (gid ==2 || gid ==3)
00263 {
00264 hbtTrack->SetNSigmaElectron(0.);
00265 hbtTrack->SetNSigmaPion(-1000.);
00266 hbtTrack->SetNSigmaKaon(-1000.);
00267 hbtTrack->SetNSigmaProton(-1000.);
00268 }
00269 else if (gid==8 || gid ==9)
00270 {
00271 hbtTrack->SetNSigmaElectron(1000.);
00272 hbtTrack->SetNSigmaPion(0.);
00273 hbtTrack->SetNSigmaKaon(-1000.);
00274 hbtTrack->SetNSigmaProton(-1000.);
00275 }
00276 else if (gid==11 || gid==12)
00277 {
00278 hbtTrack->SetNSigmaElectron(1000.);
00279 hbtTrack->SetNSigmaPion(1000.);
00280 hbtTrack->SetNSigmaKaon(0.);
00281 hbtTrack->SetNSigmaProton(-1000.);
00282 }
00283 else if (gid==14 || gid==15)
00284 {
00285 hbtTrack->SetNSigmaElectron(1000.);
00286 hbtTrack->SetNSigmaPion(1000.);
00287 hbtTrack->SetNSigmaKaon(1000.);
00288 hbtTrack->SetNSigmaProton(0.);
00289 }
00290 else
00291 {
00292 hbtTrack->SetNSigmaElectron(1000.);
00293 hbtTrack->SetNSigmaPion(0.);
00294 hbtTrack->SetNSigmaKaon(-1000.);
00295 hbtTrack->SetNSigmaProton(-1000.);
00296 }
00297
00298 }
00299
00300
00301
00302 const StPhysicalHelixD& mHelix =
00303 StPhysicalHelixD(tmpP,VertexPosition,BTesla*tesla,charge);
00304
00305 hbtTrack->SetHelix(mHelix);
00306
00307 hbtEvent->TrackCollection()->push_back(hbtTrack);
00308 }
00309 }
00310
00311 hbtEvent->SetUncorrectedNumberOfPositivePrimaries(UncorrPositivePrim);
00312 hbtEvent->SetUncorrectedNumberOfNegativePrimaries(UncorrNegativePrim);
00313
00314 crrnt_entry++;
00315 crrnt_eventI++;
00316 cout << "StHbtFlowPicoReader return event # "<<crrnt_eventI<<"\n";
00317
00318 return hbtEvent;
00319 }
00320 else
00321 {
00322 mReaderStatus = 1;
00323 delete hbtEvent;
00324 return 0;
00325 }
00326 }
00328
00329
00330
00331
00332
00333
00334
00336
00337 StHbtString StHbtFlowPicoReader::Report()
00338 {
00339 return (StHbtString)" Here is the reader report \n";
00340 }
00342 StHbtFlowPicoReader::~StHbtFlowPicoReader()
00343 {
00344 }
00345
00346
00347
00348
00349