13 #ifndef Pythia8_Analysis_H
14 #define Pythia8_Analysis_H
16 #include "Pythia8/Basics.h"
17 #include "Pythia8/Event.h"
18 #include "Pythia8/PythiaStdlib.h"
32 Sphericity(
double powerIn = 2.,
int selectIn = 2) : power(powerIn),
33 select(selectIn), nFew(0) {powerInt = 0;
34 if (abs(power - 1.) < 0.01) powerInt = 1;
35 if (abs(power - 2.) < 0.01) powerInt = 2;
36 powerMod = 0.5 * power - 1.;}
39 bool analyze(
const Event& event, ostream& os = cout);
42 double sphericity()
const {
return 1.5 * (eVal2 + eVal3);}
43 double aplanarity()
const {
return 1.5 * eVal3;}
44 double eigenValue(
int i)
const {
return (i < 2) ? eVal1 :
45 ( (i < 3) ? eVal2 : eVal3 ) ;}
46 Vec4 eventAxis(
int i)
const {
return (i < 2) ? eVec1 :
47 ( (i < 3) ? eVec2 : eVec3 ) ;}
50 void list(ostream& os = cout)
const;
53 int nError()
const {
return nFew;}
58 static const int NSTUDYMIN, TIMESTOPRINT;
59 static const double P2MIN, EIGENVALUEMIN;
67 double eVal1, eVal2, eVal3;
68 Vec4 eVec1, eVec2, eVec3;
85 Thrust(
int selectIn = 2) : select(selectIn), nFew(0) {}
88 bool analyze(
const Event& event, ostream& os = cout);
91 double thrust()
const {
return eVal1;}
92 double tMajor()
const {
return eVal2;}
93 double tMinor()
const {
return eVal3;}
94 double oblateness()
const {
return eVal2 - eVal3;}
95 Vec4 eventAxis(
int i)
const {
return (i < 2) ? eVec1 :
96 ( (i < 3) ? eVec2 : eVec3 ) ;}
99 void list(ostream& os = cout)
const;
102 int nError()
const {
return nFew;}
107 static const int NSTUDYMIN, TIMESTOPRINT;
108 static const double MAJORMIN;
114 double eVal1, eVal2, eVal3;
115 Vec4 eVec1, eVec2, eVec3;
127 class SingleClusterJet {
132 SingleClusterJet(Vec4 pJetIn = 0.,
int motherIn = 0) :
133 pJet(pJetIn), mother(motherIn), daughter(0), multiplicity(1),
134 isAssigned(false) {pAbs = max( PABSMIN, pJet.pAbs());}
135 SingleClusterJet& operator=(
const SingleClusterJet& j) {
if (
this != &j)
136 { pJet = j.pJet; mother = j.mother; daughter = j.daughter;
137 multiplicity = j.multiplicity; pAbs = j.pAbs;
138 isAssigned = j.isAssigned;}
return *
this; }
144 int mother, daughter, multiplicity;
150 friend double dist2Fun(
int measure,
const SingleClusterJet& j1,
151 const SingleClusterJet& j2);
156 static const double PABSMIN;
165 double dist2Fun(
int measure,
const SingleClusterJet& j1,
166 const SingleClusterJet& j2);
179 ClusterJet(
string measureIn =
"Lund",
int selectIn = 2,
int massSetIn = 2,
180 bool preclusterIn =
false,
bool reassignIn =
false) : measure(1),
181 select(selectIn), massSet(massSetIn), doPrecluster(preclusterIn),
182 doReassign(reassignIn), nFew(0) {
183 char firstChar = toupper(measureIn[0]);
184 if (firstChar ==
'J') measure = 2;
185 if (firstChar ==
'D') measure = 3;
189 bool analyze(
const Event& event,
double yScaleIn,
double pTscaleIn,
190 int nJetMinIn = 1,
int nJetMaxIn = 0, ostream& os = cout);
193 int size()
const {
return jets.size();}
194 Vec4 p(
int i)
const {
return jets[i].pJet;}
195 int mult(
int i)
const {
return jets[i].multiplicity;}
198 int jetAssignment(
int i)
const {
199 for (
int iP = 0; iP < int(particles.size()); ++iP)
200 if (particles[iP].mother == i)
return particles[iP].daughter;
204 void list(ostream& os = cout)
const;
207 int distanceSize()
const {
return distances.size();}
208 double distance(
int i)
const {
209 return (i < distanceSize()) ? distances[i] : 0.; }
212 int nError()
const {
return nFew;}
217 static const int TIMESTOPRINT;
218 static const double PIMASS, PABSMIN, PRECLUSTERFRAC, PRECLUSTERSTEP;
221 int measure, select, massSet;
222 bool doPrecluster, doReassign;
223 double yScale, pTscale;
224 int nJetMin, nJetMax;
227 double dist2Join, dist2BigMin, distPre, dist2Pre;
228 vector<SingleClusterJet> particles;
239 vector<SingleClusterJet> jets;
242 deque<double> distances;
256 SingleCell(
int iCellIn = 0,
double etaCellIn = 0.,
double phiCellIn = 0.,
257 double eTcellIn = 0.,
int multiplicityIn = 0) : iCell(iCellIn),
258 etaCell(etaCellIn), phiCell(phiCellIn), eTcell(eTcellIn),
259 multiplicity(multiplicityIn), canBeSeed(true), isUsed(false),
264 double etaCell, phiCell, eTcell;
266 bool canBeSeed, isUsed, isAssigned;
275 class SingleCellJet {
280 SingleCellJet(
double eTjetIn = 0.,
double etaCenterIn = 0.,
281 double phiCenterIn = 0.,
double etaWeightedIn = 0.,
282 double phiWeightedIn = 0.,
int multiplicityIn = 0,
283 Vec4 pMassiveIn = 0.) : eTjet(eTjetIn), etaCenter(etaCenterIn),
284 phiCenter(phiCenterIn), etaWeighted(etaWeightedIn),
285 phiWeighted(phiWeightedIn), multiplicity(multiplicityIn),
286 pMassive(pMassiveIn) {}
289 double eTjet, etaCenter, phiCenter, etaWeighted, phiWeighted;
305 CellJet(
double etaMaxIn = 5.,
int nEtaIn = 50,
int nPhiIn = 32,
306 int selectIn = 2,
int smearIn = 0,
double resolutionIn = 0.5,
307 double upperCutIn = 2.,
double thresholdIn = 0., Rndm* rndmPtrIn = 0)
308 : etaMax(etaMaxIn), nEta(nEtaIn), nPhi(nPhiIn), select(selectIn),
309 smear(smearIn), resolution(resolutionIn), upperCut(upperCutIn),
310 threshold(thresholdIn), nFew(0), rndmPtr(rndmPtrIn) { }
313 bool analyze(
const Event& event,
double eTjetMinIn = 20.,
314 double coneRadiusIn = 0.7,
double eTseedIn = 1.5, ostream& os = cout);
317 int size()
const {
return jets.size();}
318 double eT(
int i)
const {
return jets[i].eTjet;}
319 double etaCenter(
int i)
const {
return jets[i].etaCenter;}
320 double phiCenter(
int i)
const {
return jets[i].phiCenter;}
321 double etaWeighted(
int i)
const {
return jets[i].etaWeighted;}
322 double phiWeighted(
int i)
const {
return jets[i].phiWeighted;}
323 int multiplicity(
int i)
const {
return jets[i].multiplicity;}
324 Vec4 pMassless(
int i)
const {
return jets[i].eTjet * Vec4(
325 cos(jets[i].phiWeighted), sin(jets[i].phiWeighted),
326 sinh(jets[i].etaWeighted), cosh(jets[i].etaWeighted) );}
327 Vec4 pMassive(
int i)
const {
return jets[i].pMassive;}
328 double m(
int i)
const {
return jets[i].pMassive.mCalc();}
331 void list(ostream& os = cout)
const;
334 int nError()
const {
return nFew;}
339 static const int TIMESTOPRINT;
343 int nEta, nPhi, select, smear;
344 double resolution, upperCut, threshold;
345 double eTjetMin, coneRadius, eTseed;
351 vector<SingleCellJet> jets;
368 virtual ~SlowJetHook() { }
377 virtual bool include(
int iSel,
const Event& event, Vec4& pSel,
387 class SingleSlowJet {
392 SingleSlowJet( Vec4 pIn = 0.,
double pT2In = 0.,
double yIn = 0.,
393 double phiIn = 0.,
int idxIn = 0) : p(pIn), pT2(pT2In), y(yIn),
394 phi(phiIn), mult(1) { idx.insert(idxIn); }
395 SingleSlowJet(
const SingleSlowJet& ssj) : p(ssj.p), pT2(ssj.pT2),
396 y(ssj.y), phi(ssj.phi), mult(ssj.mult), idx(ssj.idx) { }
397 SingleSlowJet& operator=(
const SingleSlowJet& ssj) {
if (
this != &ssj)
398 { p = ssj.p; pT2 = ssj.pT2; y = ssj.y; phi = ssj.phi;
399 mult = ssj.mult; idx = ssj.idx; }
return *
this; }
419 SlowJet(
int powerIn,
double Rin,
double pTjetMinIn = 0.,
420 double etaMaxIn = 25.,
int selectIn = 2,
int massSetIn = 2,
421 SlowJetHook* sjHookPtrIn = 0,
bool useFJcoreIn =
true,
422 bool useStandardRin =
true) : power(powerIn), R(Rin),
423 pTjetMin(pTjetMinIn), etaMax(etaMaxIn), select(selectIn),
424 massSet(massSetIn), sjHookPtr(sjHookPtrIn), useFJcore(useFJcoreIn),
425 useStandardR(useStandardRin) { isAnti = (power < 0); isKT = (power > 0);
426 R2 = R*R; pT2jetMin = pTjetMin*pTjetMin; cutInEta = (etaMax <= 20.);
427 chargedOnly = (select > 2); visibleOnly = (select == 2);
428 modifyMass = (massSet < 2); noHook = (sjHookPtr == 0);}
431 bool analyze(
const Event& event) {
432 if ( !setup(event) )
return false;
433 if (useFJcore)
return clusterFJ();
434 while (clSize > 0) doStep();
return true; }
437 bool setup(
const Event& event);
443 bool doNSteps(
int nStep) {
if (useFJcore)
return false;
444 while(nStep > 0 && clSize > 0) { doStep(); --nStep;}
445 return (nStep == 0); }
448 bool stopAtN(
int nStop) {
if (useFJcore)
return false;
449 while (clSize + jtSize > nStop && clSize > 0) doStep();
450 return (clSize + jtSize == nStop); }
453 int sizeOrig()
const {
return origSize;}
454 int sizeJet()
const {
return jtSize;}
455 int sizeAll()
const {
return jtSize + clSize;}
456 double pT(
int i)
const {
return (i < jtSize)
457 ? sqrt(jets[i].pT2) : sqrt(clusters[i - jtSize].pT2);}
458 double y(
int i)
const {
return (i < jtSize)
459 ? jets[i].y : clusters[i - jtSize].y;}
460 double phi(
int i)
const {
return (i < jtSize)
461 ? jets[i].phi : clusters[i - jtSize].phi;}
462 Vec4 p(
int i)
const {
return (i < jtSize)
463 ? jets[i].p : clusters[i - jtSize].p;}
464 double m(
int i)
const {
return (i < jtSize)
465 ? jets[i].p.mCalc() : clusters[i - jtSize].p.mCalc();}
466 int multiplicity(
int i)
const {
return (i < jtSize)
467 ? jets[i].mult : clusters[i - jtSize].mult;}
470 int iNext()
const {
return (iMin == -1) ? -1 : iMin + jtSize;}
471 int jNext()
const {
return (jMin == -1) ? -1 : jMin + jtSize;}
472 double dNext()
const {
return dMin;}
475 void list(
bool listAll =
false, ostream& os = cout)
const;
478 vector<int> constituents(
int j) { vector<int> cTemp;
479 for (set<int>::iterator idxTmp = jets[j].idx.begin();
480 idxTmp != jets[j].idx.end(); ++idxTmp)
481 cTemp.push_back( *idxTmp);
return cTemp;
485 vector<int> clusConstituents(
int j) { vector<int> cTemp;
486 for (set<int>::iterator idxTmp = clusters[j].idx.begin();
487 idxTmp != clusters[j].idx.end(); ++idxTmp)
488 cTemp.push_back( *idxTmp);
return cTemp;
493 int jetAssignment(
int i) {
494 for (
int j = 0; j < sizeJet(); ++j)
495 if (jets[j].idx.find(i) != jets[j].idx.end())
return j;
500 void removeJet(
int i) {
501 if (i < 0 || i >= jtSize)
return;
502 jets.erase(jets.begin() + i);
509 static const int TIMESTOPRINT;
510 static const double PIMASS, TINY;
514 double R, pTjetMin, etaMax, R2, pT2jetMin;
517 SlowJetHook* sjHookPtr;
518 bool useFJcore, useStandardR, isAnti, isKT, cutInEta, chargedOnly,
519 visibleOnly, modifyMass, noHook;
522 vector<SingleSlowJet> clusters;
523 vector<SingleSlowJet> jets;
530 int origSize, clSize, clLast, jtSize, iMin, jMin;
531 double dPhi, dijTemp, dMin;
545 #endif // end Pythia8_Analysis_H