13 #include "fastjet/ClusterSequence.hh"
14 #include "fastjet/PseudoJet.hh"
16 #include "JetStabilityDefs.h"
17 #include "JetStability.h"
18 #include "DiffusionDistFastJet.h"
19 #include "SimpleSmear.h"
20 #include "SimpleEvent.hh"
21 #include "SimulatedEvent.hh"
22 #include "QCDandCmsLikeSmear.h"
24 #include "PythiaJetGun.hh"
26 #include "geners/BinaryFileArchive.hh"
27 #include "geners/Reference.hh"
36 bool oddSort (
const std::pair<unsigned,double> & a,
const std::pair<unsigned,double> &b ) {
37 return a.second > b.second;
41 void printUsage(
int argc,
char **argv ) {
43 std::cout << argv[0] <<
" -a archive [-A nEvents] [-C nCycles] [-o outputFile] [-q fuzzyFile] [-m scanMin] [-M scanMax] [-n nScan] [-f fixedVar] [-E (set exclusive)] [-d distCut] [-N nJets] [-r R] dataDir" << std::endl;
47 int main (
int argc,
char **argv ) {
51 char *archiveName = 0;
55 bool exclusive =
false;
69 double qcdCutOff = 0.705796;
70 bool doFlatPhaseSpace =
true;
74 while (( c = getopt(argc,argv,
"a:A:o:r:C:N:m:M:n:f:Ed:q:")) != -1 )
80 nEvents = atoi(optarg);
92 nCycles = atoi(optarg);
95 scanMin = atof(optarg);
98 scanMax = atof(optarg);
101 scanN = atoi(optarg);
104 fixed = atof(optarg);
110 distCut = atof(optarg);
116 printUsage(argc,argv);
122 for (
int index = optind; index < argc; index++ ) {
123 if ( index == optind ) dataDir = argv[index];
127 std::cerr <<
"Must provide data directory as non-option argument" << std::endl;
132 TFile f(
"output.root",
"RECREATE");
133 TTree *tree =
new TTree(
"tree",
"tree");
135 std::vector<double> *pt=0;
136 std::vector<int> *pid=0;
138 double bpt,bphi,beta,bbarpt,bbarphi,bbareta;
139 int bstatus,bbarstatus;
142 tree->Branch(
"pt",&pt);
143 tree->Branch(
"pid",&pid);
144 tree->Branch(
"bpt",&bpt,
"bpt/D");
145 tree->Branch(
"bphi",&bphi,
"bphi/D");
146 tree->Branch(
"beta",&beta,
"beta/D");
147 tree->Branch(
"bstatus",&bstatus,
"bstatus/I");
148 tree->Branch(
"bbarpt",&bbarpt,
"bbarpt/D");
149 tree->Branch(
"bbarphi",&bbarphi,
"bbarphi/D");
150 tree->Branch(
"bbareta",&bbareta,
"bbareta/D");
151 tree->Branch(
"bbarstatus",&bbarstatus,
"bbarstatus/I");
152 tree->Branch(
"bdR",&bdR,
"bdR/D");
160 out.open(outFile,std::ios_base::out);
165 fout.open(fuzzyFile,std::ios_base::out);
168 std::cout <<
"Opening archive.......";
170 BinaryFileArchive ar(archiveName,
"r");
173 std::cerr << ar.error() << std::endl;
176 std::cout <<
"done" << std::endl;
179 std::cout <<
"Finding events.......";
180 Reference<SimulatedEvent> ref(ar, Regex(
".*"),
"dijet");
181 if ( !nEvents ) nEvents = ref.size();
182 std::cout <<
"done found: " << ref.size() <<
" events" << std::endl;
187 jstab.setScan(scanN,scanMin,scanMax);
188 jstab.setNCycles(nCycles);
197 for (
unsigned evNum=0; evNum != nEvents; evNum++ ) {
203 stab::StabilityEventInfo evInfo;
206 ref.restore(evNum, &ev);
208 const unsigned nSimulatedJets = evs.size();
210 PythiaEventInfo & pyInfo = ev.pyev;
211 const int pyN = pyInfo.N();
212 const int bnum = pyInfo.findFirst(5);
213 const int bbarnum = pyInfo.findFirst(-5);
215 bpt = pyInfo.pt(bnum);
216 bphi = atan2(pyInfo.py(bnum),pyInfo.px(bnum));
217 beta = asinh(pyInfo.pz(bnum)/bpt);
218 bstatus = pyInfo.statusCode(bnum);
220 bbarpt = pyInfo.pt(bbarnum);
221 bbarphi = atan2(pyInfo.py(bbarnum),pyInfo.px(bbarnum));
222 bbareta = asinh(pyInfo.pz(bbarnum)/bbarpt);
223 bbarstatus = pyInfo.statusCode(bbarnum);
225 const double dEta = beta - bbareta;
226 double dPhi = bphi - bbarphi;
227 while ( dPhi > M_PI) dPhi -= 2*M_PI;
228 while ( dPhi <= -M_PI ) dPhi += 2*M_PI;
230 bdR = sqrt(dEta*dEta+dPhi*dPhi);
232 for (
unsigned j=0; j != nSimulatedJets; j++ ) {
233 const std::vector<PythiaJetGun::Particle> & constituents = evs[j].jetParticles;
234 const unsigned nConstituents = constituents.size();
235 for (
unsigned c=0; c != nConstituents; c++ ) {
237 const rk::P4 & p4 = part.p4();
238 const geom3::Vector3 & mom = p4.momentum();
239 stab::PseudoJet pj(mom.x(),mom.y(),mom.z(),p4.e());
243 event.push_back( pj );
244 pt->push_back(pj.pt());
245 pid->push_back(part.code());