Skip to content

Instantly share code, notes, and snippets.

@jdbrice
Created July 28, 2021 18:06
Show Gist options
  • Save jdbrice/2b99556e76f5bca4c4c7854259fefd3c to your computer and use it in GitHub Desktop.
Save jdbrice/2b99556e76f5bca4c4c7854259fefd3c to your computer and use it in GitHub Desktop.
Example reader code for STARLight text format
ifstream infile( starlight.c_str() );
int iEvent =0;
while (infile) {
string sEvent, sVertex, sTrack1, sTrack2;
if (!getline( infile, sEvent )) break;
if (!getline( infile, sVertex )) break;
if (!getline( infile, sTrack1 )) break;
if (!getline( infile, sTrack2 )) break;
// cout << "track1 " << sTrack1 << endl;
// cout << "track2 " << sTrack2 << endl;
istringstream ss1( sTrack1 );
istringstream ss2( sTrack2 );
string nil;
int gpid, nev, ntr, stopv, pdgid;
float px1, py1, pz1;
float px2, py2, pz2;
nil = "";
gpid = 0;
nev = 0;
ntr = 0;
stopv = 0;
pdgid = 0;
px1 = py1 = pz1 = 0;
px2 = py2 = pz2 = 0;
ss1 >> nil >> gpid >> px1 >> py1 >> pz1 >> nev >> ntr >> stopv >> pdgid;
ss2 >> nil >> gpid >> px2 >> py2 >> pz2 >> nev >> ntr >> stopv >> pdgid;
TLorentzVector lv1, lv2, lv;
lv1.SetXYZM( px1, py1, pz1, daughterMass );
lv2.SetXYZM( px2, py2, pz2, daughterMass );
lv = lv1 + lv2;
this->_pair.reset();
this->_pair.d1_mPt = lv1.Pt();
this->_pair.d1_mEta = lv1.Eta();
this->_pair.d1_mPhi = lv1.Phi();
this->_pair.d2_mPt = lv2.Pt();
this->_pair.d2_mEta = lv2.Eta();
this->_pair.d2_mPhi = lv2.Phi();
this->_pair.mMass = lv.M();
this->_pair.mPt = lv.Pt();
this->_pair.mEta = lv.Eta();
this->_pair.mPhi = lv.Phi();
this->_pair.mRapidity = lv.Rapidity();
// if ( starAcc ){
// if ( lv1.Pt() < 0.100 || fabs(lv1.Eta())>1.0 )
// continue;
// if ( lv2.Pt() < 0.100 || fabs(lv2.Eta())>1.0 )
// continue;
// if ( fabs(lv.Rapidity())>1.0 )
// continue;
// if ( fabs(lv.M())<1.0 )
// continue;
// }
this->_fpw.set( this->_pair );
this->_pairDst->Fill();
iEvent++;
if ( iEvent >= maxEvents && maxEvents > 0 )
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment