5 #include "SimpleEvent.hh"
6 #include "PythiaJetGun.hh"
8 #include "geners/GenericIO.hh"
9 #include "geners/IOException.hh"
11 using namespace geom3;
13 using namespace PythiaJetGun;
15 bool SimulatedJet::write(std::ostream& of)
const
17 parton.classId().write(of);
18 return parton.write(of) && write_item(of, jetParticles);
21 void SimulatedJet::restore(
const gs::ClassId&
id, std::istream& in,
24 static const ClassId myClassId(ClassId::makeId<SimulatedJet>());
25 myClassId.ensureSameId(
id);
27 ClassId partId(in, 1);
29 Particle::restore(partId, in, &ptr->parton);
30 restore_item(in, &ptr->jetParticles);
33 rk::P4 SimulatedJet::jetSum()
const
36 const unsigned npart = jetParticles.size();
37 for (
unsigned j=0; j<npart; ++j)
38 sum += jetParticles[j].p4();
42 rk::P4 SimulatedJet::chargedSum()
const
45 const unsigned npart = jetParticles.size();
46 for (
unsigned j=0; j<npart; ++j)
47 if (jetParticles[j].charge() != 0.0)
48 sum += jetParticles[j].p4();
52 rk::P4 SimpleEvent::closestJet(
const double eta,
const double phi)
const
54 const unsigned njets = size();
57 double bestDr = DBL_MAX;
60 const geom3::UnitVector3 direction(cos(phi), sin(phi), sinh(eta));
61 for (
unsigned i=0; i<njets; ++i)
64 rk::P4 jetSum(jet.jetSum());
65 const double dr = geom3::deltaR(direction, jetSum.momentum());
76 unsigned SimpleEvent::closestJetNumber(
const unsigned thisJetNumber)
const
78 rk::P4 thisSum(at(thisJetNumber).jetSum());
79 const double eta = thisSum.eta();
80 const double phi = thisSum.phi();
81 const unsigned njets = size();
83 double bestDr = DBL_MAX;
84 unsigned bestJet = njets;
86 const geom3::UnitVector3 direction(cos(phi), sin(phi), sinh(eta));
87 for (
unsigned i=0; i<njets; ++i)
88 if (i != thisJetNumber)
91 rk::P4 jetSum(jet.jetSum());
92 const double dr = geom3::deltaR(direction, jetSum.momentum());
103 double SimpleEvent::minDr()
const
105 const unsigned njets = size();
109 double dr, drmin = DBL_MAX;
110 for (
unsigned i=0; i<njets-1; ++i)
112 const geom3::Vector3 p((*
this)[i].jetSum().momentum());
113 for (
unsigned j=i+1; j<njets; ++j)
115 dr = geom3::deltaR(p, (*
this)[j].jetSum().momentum());
123 bool SimpleEvent::operator==(
const SimpleEvent& r)
const
125 const unsigned n = size();
128 for (
unsigned i=0; i<n; ++i)
129 if ((*
this)[i] != r[i])
134 bool SimpleEvent::write(std::ostream& of)
const
136 const unsigned sz = this->size();
142 if (!jets->classId().write(of))
144 for (
unsigned i=0; i<sz; ++i)
145 if (!jets[i].write(of))
152 void SimpleEvent::restore(
const gs::ClassId&
id, std::istream& in,
155 static const ClassId myClassId(ClassId::makeId<SimpleEvent>());
156 myClassId.ensureSameId(
id);
168 for (
unsigned i=0; i<sz; ++i)
170 SimulatedJet::restore(clid, in, &jet);
176 bool phiAtRadius(
const Particle& particle,
const double B,
177 const double r,
double *phi)
180 *phi = particle.p4().phi();
181 if (B == 0.0 || r == 0.0)
183 if (particle.charge() == 0.0)
185 const double a = particle.gyrationRadius(B);
186 const double twoa = 2.0*fabs(a);
195 *phi += asin(r/2.0/a);