File indexing completed on 2025-08-03 08:19:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include <iostream>
0018 #include <fstream>
0019 #include <memory>
0020 #include <chrono>
0021 #include <thread>
0022
0023 #include "gzstream.h"
0024 #include "PartonShower.h"
0025 #include "JetScapeLogger.h"
0026 #include "JetScapeReader.h"
0027 #include "JetScapeBanner.h"
0028 #include "fjcore.hh"
0029
0030 #include <GTL/dfs.h>
0031
0032 using namespace std;
0033
0034
0035 using namespace Jetscape;
0036
0037
0038
0039
0040 void Show();
0041 void AnalyzeGraph(shared_ptr<PartonShower> mS);
0042 ostream & operator<<(ostream & ostr, const fjcore::PseudoJet & jet);
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 int main(int argc, char** argv)
0054 {
0055 JetScapeLogger::Instance()->SetDebug(false);
0056 JetScapeLogger::Instance()->SetRemark(false);
0057
0058
0059 JetScapeLogger::Instance()->SetVerboseLevel(0);
0060
0061 cout<<endl;
0062 Show();
0063
0064
0065 fjcore::JetDefinition jet_def(fjcore::antikt_algorithm, 0.7);
0066
0067 vector<shared_ptr<PartonShower>> mShowers;
0068
0069
0070
0071
0072
0073
0074 auto reader=make_shared<JetScapeReaderAscii>("test_out.dat");
0075
0076
0077
0078
0079
0080
0081 {
0082 reader->Next();
0083
0084 cout<<"Analyze current event = "<<reader->GetCurrentEvent()<<endl;
0085 mShowers=reader->GetPartonShowers();
0086
0087 int finals = 0;
0088 for (int i=0;i<mShowers.size();i++)
0089 {
0090 cout<<" Analyze parton shower = "<<i<<endl;
0091
0092 mShowers[i]->PrintVertices();
0093 mShowers[i]->PrintPartons();
0094
0095 finals += mShowers[i]->GetFinalPartonsForFastJet().size();
0096
0097 fjcore::ClusterSequence cs(mShowers[i]->GetFinalPartonsForFastJet(), jet_def);
0098
0099 vector<fjcore::PseudoJet> jets = fjcore::sorted_by_pt(cs.inclusive_jets(2));
0100 cout<<endl;
0101 cout<<jet_def.description()<<endl;
0102
0103
0104 for (int k=0;k<jets.size();k++)
0105 cout<<"Anti-kT jet "<<k<<" : "<<jets[k]<<endl;
0106 cout<<endl;
0107 cout<<"Shower initiating parton : "<<*(mShowers[i]->GetPartonAt(0))<<endl;
0108 cout<<endl;
0109
0110 AnalyzeGraph(mShowers[i]);
0111
0112 if (i==0)
0113 {
0114 mShowers[i]->SaveAsGV("my_test.gv");
0115 mShowers[i]->SaveAsGML("my_test.gml");
0116 mShowers[i]->SaveAsGraphML("my_test.graphml");
0117 }
0118
0119
0120
0121 }
0122 cout << " Found " << finals << " final state partons." << endl;
0123 auto hadrons = reader->GetHadrons();
0124 cout<<"Number of hadrons is: " << hadrons.size() << endl;
0125
0126 fjcore::ClusterSequence hcs(reader->GetHadronsForFastJet(), jet_def);
0127 vector<fjcore::PseudoJet> hjets = fjcore::sorted_by_pt(hcs.inclusive_jets(2));
0128 cout<<"AT HADRONIC LEVEL " << endl;
0129 for (int k=0;k<hjets.size();k++)
0130 cout<<"Anti-kT jet "<<k<<" : "<<hjets[k]<<endl;
0131
0132
0133
0134
0135 }
0136
0137 reader->Close();
0138 }
0139
0140
0141
0142 void AnalyzeGraph(shared_ptr<PartonShower> mS)
0143 {
0144 JSINFO<<"Some GTL graph/shower analysis/dfs search output:";
0145
0146
0147 dfs search;
0148 search.calc_comp_num(true);
0149 search.scan_whole_graph(true);
0150 search.start_node();
0151 search.run(*mS);
0152
0153 cout<<endl;
0154 cout<<"DFS graph search feature from GTL:"<<endl;
0155 cout<<"Number of Nodes reached from node 0 = "<< search.number_of_reached_nodes () <<endl;
0156 cout<<"Node/Vertex ordering result from DFS:"<<endl;
0157 dfs::dfs_iterator itt2, endt2;
0158 for (itt2 = search.begin(), endt2=search.end(); itt2 !=endt2; ++itt2)
0159 {
0160 cout<<*itt2<<" ";
0161 }
0162 cout<<endl;
0163 cout<<"Edge/Parton ordering result from DFS:"<<endl;
0164 dfs::tree_edges_iterator itt, endt;
0165 for (itt = search.tree_edges_begin(), endt=search.tree_edges_end(); itt !=endt; ++itt)
0166 {
0167 cout<<*itt;
0168 }
0169 cout<<endl;
0170
0171 dfs::roots_iterator itt3, endt3;
0172 cout<<"List of root nodes found in graph/shower : ";
0173 for (itt3 = search.roots_begin(), endt3=search.roots_end(); itt3 !=endt3; ++itt3)
0174 {
0175 cout<<**itt3;
0176 }
0177 cout<<endl;
0178 cout<<endl;
0179 }
0180
0181
0182
0183
0184 void Show()
0185 {
0186 ShowJetscapeBanner();
0187 INFO_NICE;
0188 INFO_NICE<<"------------------------------------";
0189 INFO_NICE<<"| Reader Test JetScape Framework ... |";
0190 INFO_NICE<<"------------------------------------";
0191 INFO_NICE;
0192 }
0193
0194
0195
0196
0197 ostream & operator<<(ostream & ostr, const fjcore::PseudoJet & jet) {
0198 if (jet == 0) {
0199 ostr << " 0 ";
0200 } else {
0201 ostr << " pt = " << jet.pt()
0202 << " m = " << jet.m()
0203 << " y = " << jet.rap()
0204 << " phi = " << jet.phi();
0205 }
0206 return ostr;
0207 }
0208
0209
0210