35 using namespace Jetscape;
37 using namespace fjcore;
43 ostream &
operator<<(ostream & ostr,
const PseudoJet & jet);
54 int main(
int argc,
char** argv)
58 string inname =
"test_out.dat.gz";
59 string outname =
"test_out.root";
60 string filetype =
".dat.gz";
71 pos = outname.find( filetype);
72 if ( pos==std::string::npos ){
73 throw std::runtime_error (
"Please use a filename ending in .dat.gz for an automatically generated output name");
76 outname.replace(pos, filetype.length(),
".root");
82 cout <<
"Usage: readerTestWithRoot [inputname] [outputname]" << endl;
86 JetScapeLogger::Instance()->SetInfo(
false);
87 JetScapeLogger::Instance()->SetDebug(
false);
88 JetScapeLogger::Instance()->SetRemark(
false);
89 JetScapeLogger::Instance()->SetVerboseLevel(0);
97 inFile.
open(inname.c_str());
103 while (getline(inFile,line)) {
104 if ( line.compare(0, cs.length(), cs) != 0)
continue;
106 tofind =
"# nAccepted = ";
107 pos = line.find( tofind );
108 if ( pos!=std::string::npos ) nAccepted=atoi(
string ( line.begin()+pos+tofind.length(), line.end()).c_str());
110 tofind =
"# sigmaGen = ";
111 pos = line.find( tofind );
112 if ( pos!=std::string::npos ) sigmaGen=atof(
string ( line.begin()+pos+tofind.length(), line.end()).c_str());
114 if ( sigmaGen<0 || nAccepted<0 ){
115 throw std::runtime_error(
"Couldn't find sigmaGen and nAccepted in the footer.");
119 INFO <<
"Using sigmaGen = " << sigmaGen <<
" and nAccepted = " << nAccepted;
121 double weight = sigmaGen / nAccepted;
133 Selector select_cons = select_track_rap * select_pt;
138 Selector select_jet = select_jet_eta * select_jet_pt;
143 float ptsublead = 20;
145 auto reader=make_shared<JetScapeReaderAsciiGZ>(inname);
148 TFile*
fout =
new TFile( outname.data(),
"RECREATE");
151 TH1::SetDefaultSumw2();
154 TH1D* partonpt =
new TH1D (
"partonpt",
"Final Parton p_{T};p_{T} [GeV/c]",120, 0, 120);
155 TH1D* partoneta =
new TH1D (
"partoneta",
"Final Parton #eta; #eta",100, -5, 5);
156 TH1D* hardpartonpt =
new TH1D (
"hardpartonpt",
"Hard Parton p_{T};p_{T} [GeV/c]",80, 0, 40);
157 TH1D* hardpartoneta =
new TH1D (
"hardpartoneta",
"Hard Parton #eta; #eta",100, -5, 5);
159 TH1D* leadjetpt =
new TH1D (
"leadjetpt",
"Leading Jet p_{T};p_{T}^{jet} [GeV/c]",120, 0, 120);
160 TH1D* subleadjetpt =
new TH1D (
"subleadjetpt",
"Sub-Leading Jet p_{T};p_{T}^{jet} [GeV/c]",120, 0, 120);
162 TH1D* aj =
new TH1D (
"aj",
"A_{J};", 40, -1, 1 );
164 TH1D* jetpt =
new TH1D (
"jetpt",
"Jet p_{T};p_{T}^{jet} [GeV/c]",120,0,120);
165 TH1D* jeteta =
new TH1D (
"jeteta",
"Jet #eta;#eta^{jet} [GeV/c]",100, -3, 3);
168 TH1D* jetz =
new TH1D (
"jetz",
"Jet z;p_{T}^{constituent} / p_{T}^{jet}",100, 0, 1);
170 TH1D*
dR =
new TH1D (
"dR",
"#DeltaR;counts",50, 0, 1);
173 vector<shared_ptr<PartonShower>> mShowers;
176 while (!
reader->Finished()){
178 if ( !(
event%1000) ) cout <<
"Working on " <<
event << endl;
182 mShowers=
reader->GetPartonShowers();
185 vector<PseudoJet> jets;
186 for (
int i=0;
i<mShowers.size();
i++){
188 vector<PseudoJet>
particles = select_cons(mShowers[
i]->GetFinalPartonsForFastJet());
189 ClusterSequence cs(particles, jet_def);
195 hardpartonpt->Fill ( mShowers[
i]->GetPartonAt(0)->
pt(), weight );
196 hardpartoneta->Fill ( mShowers[
i]->GetPartonAt(0)->
eta(), weight );
199 for (
auto &
p : mShowers[
i]->GetFinalPartonsForFastJet() ){
200 partonpt->Fill (
p.pt(), weight );
201 partoneta->Fill (
p.eta(), weight );
205 for (
auto j : select_jet( cs.inclusive_jets()) ){
210 for (
auto &consts :
j.constituents() ){
223 jetz->Fill( consts.pt() /
j.pt(), weight );
224 dR->Fill( consts.delta_R(
j), weight );
233 if ( jets.size()==0 )
continue;
240 jetpt->Fill(
j.pt(), weight );
241 jeteta->Fill(
j.eta(), weight );
246 if ( jets.size()<2 )
continue;
247 PseudoJet lead = jets.at(0);
248 PseudoJet sublead = jets.at(1);
250 if ( lead.pt()<ptlead || sublead.pt()<ptsublead )
continue;
253 float dphi = lead.delta_phi_to( sublead );
255 cerr <<
" dphi = " << dphi << endl;
259 if ( dphi > -Jetscape::pi+R && dphi < Jetscape::pi-R )
continue;
262 leadjetpt->Fill( lead.pt(), weight );
263 subleadjetpt->Fill( sublead.pt(), weight );
264 aj->Fill( (lead.pt()-sublead.pt()) / (lead.pt()+sublead.pt()), weight);
272 INFO <<
"Read from " << inname;
273 INFO <<
"Wrote to " << outname;
283 INFO<<
"Some GTL graph/shower analysis/dfs search output:";
292 cout<<
"DFS graph search feature from GTL:"<<endl;
294 cout<<
"Node/Vertex ordering result from DFS:"<<endl;
296 for (itt2 = search.
begin(), endt2=search.
end(); itt2 !=endt2; ++itt2)
302 cout<<
"Edge/Parton ordering result from DFS:"<<endl;
311 cout<<
"List of root nodes found in graph/shower : ";
322 ostream &
operator<<(ostream & ostr,
const PseudoJet & jet) {
326 ostr <<
" pt = " << jet.pt()
327 <<
" m = " << jet.m()
328 <<
" y = " << jet.rap()
329 <<
" phi = " << jet.phi();