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), eVal1(), eVal2(), eVal3(), 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);
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 ) ;}
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), eVal1(), eVal2(), eVal3(),
89 bool analyze(
const Event& event);
92 double thrust()
const {
return eVal1;}
93 double tMajor()
const {
return eVal2;}
94 double tMinor()
const {
return eVal3;}
95 double oblateness()
const {
return eVal2 - eVal3;}
96 Vec4 eventAxis(
int i)
const {
return (i < 2) ? eVec1 :
97 ( (i < 3) ? eVec2 : eVec3 ) ;}
103 int nError()
const {
return nFew;}
108 static const int NSTUDYMIN, TIMESTOPRINT;
109 static const double MAJORMIN;
115 double eVal1, eVal2, eVal3;
116 Vec4 eVec1, eVec2, eVec3;
128 class SingleClusterJet {
133 SingleClusterJet(Vec4 pJetIn = 0.,
int motherIn = 0) :
134 pJet(pJetIn), mother(motherIn), daughter(0), multiplicity(1),
135 isAssigned(false) {pAbs = max( PABSMIN, pJet.pAbs());}
136 SingleClusterJet(
const SingleClusterJet& j) {
137 pJet = j.pJet; mother = j.mother; daughter = j.daughter;
138 multiplicity = j.multiplicity; pAbs = j.pAbs;
139 isAssigned = j.isAssigned; }
140 SingleClusterJet& operator=(
const SingleClusterJet& j) {
if (
this != &j)
141 { pJet = j.pJet; mother = j.mother; daughter = j.daughter;
142 multiplicity = j.multiplicity; pAbs = j.pAbs;
143 isAssigned = j.isAssigned;}
return *
this; }
149 int mother, daughter, multiplicity;
155 friend double dist2Fun(
int measure,
const SingleClusterJet& j1,
156 const SingleClusterJet& j2);
161 static const double PABSMIN;
170 double dist2Fun(
int measure,
const SingleClusterJet& j1,
171 const SingleClusterJet& j2);
184 ClusterJet(
string measureIn =
"Lund",
int selectIn = 2,
int massSetIn = 2,
185 bool preclusterIn =
false,
bool reassignIn =
false) : measure(1),
186 select(selectIn), massSet(massSetIn), doPrecluster(preclusterIn),
187 doReassign(reassignIn), yScale(), pTscale(), nJetMin(), nJetMax(),
188 dist2Join(), dist2BigMin(), distPre(), dist2Pre(), nParticles(), nFew(0)
190 char firstChar = toupper(measureIn[0]);
191 if (firstChar ==
'J') measure = 2;
192 if (firstChar ==
'D') measure = 3;
196 bool analyze(
const Event& event,
double yScaleIn,
double pTscaleIn,
197 int nJetMinIn = 1,
int nJetMaxIn = 0);
200 int size()
const {
return jets.size();}
201 Vec4 p(
int i)
const {
return jets[i].pJet;}
202 int mult(
int i)
const {
return jets[i].multiplicity;}
205 int jetAssignment(
int i)
const {
206 for (
int iP = 0; iP < int(particles.size()); ++iP)
207 if (particles[iP].mother == i)
return particles[iP].daughter;
214 int distanceSize()
const {
return distances.size();}
215 double distance(
int i)
const {
216 return (i < distanceSize()) ? distances[i] : 0.; }
219 int nError()
const {
return nFew;}
224 static const int TIMESTOPRINT;
225 static const double PIMASS, PABSMIN, PRECLUSTERFRAC, PRECLUSTERSTEP;
228 int measure, select, massSet;
229 bool doPrecluster, doReassign;
230 double yScale, pTscale;
231 int nJetMin, nJetMax;
234 double dist2Join, dist2BigMin, distPre, dist2Pre;
235 vector<SingleClusterJet> particles;
246 vector<SingleClusterJet> jets;
249 deque<double> distances;
263 SingleCell(
int iCellIn = 0,
double etaCellIn = 0.,
double phiCellIn = 0.,
264 double eTcellIn = 0.,
int multiplicityIn = 0) : iCell(iCellIn),
265 etaCell(etaCellIn), phiCell(phiCellIn), eTcell(eTcellIn),
266 multiplicity(multiplicityIn), canBeSeed(true), isUsed(false),
271 double etaCell, phiCell, eTcell;
273 bool canBeSeed, isUsed, isAssigned;
282 class SingleCellJet {
287 SingleCellJet(
double eTjetIn = 0.,
double etaCenterIn = 0.,
288 double phiCenterIn = 0.,
double etaWeightedIn = 0.,
289 double phiWeightedIn = 0.,
int multiplicityIn = 0,
290 Vec4 pMassiveIn = 0.) : eTjet(eTjetIn), etaCenter(etaCenterIn),
291 phiCenter(phiCenterIn), etaWeighted(etaWeightedIn),
292 phiWeighted(phiWeightedIn), multiplicity(multiplicityIn),
293 pMassive(pMassiveIn) {}
296 double eTjet, etaCenter, phiCenter, etaWeighted, phiWeighted;
312 CellJet(
double etaMaxIn = 5.,
int nEtaIn = 50,
int nPhiIn = 32,
313 int selectIn = 2,
int smearIn = 0,
double resolutionIn = 0.5,
314 double upperCutIn = 2.,
double thresholdIn = 0., Rndm* rndmPtrIn = 0)
315 : etaMax(etaMaxIn), nEta(nEtaIn), nPhi(nPhiIn), select(selectIn),
316 smear(smearIn), resolution(resolutionIn), upperCut(upperCutIn),
317 threshold(thresholdIn), eTjetMin(), coneRadius(), eTseed(), nFew(0),
318 rndmPtr(rndmPtrIn) { }
321 bool analyze(
const Event& event,
double eTjetMinIn = 20.,
322 double coneRadiusIn = 0.7,
double eTseedIn = 1.5);
325 int size()
const {
return jets.size();}
326 double eT(
int i)
const {
return jets[i].eTjet;}
327 double etaCenter(
int i)
const {
return jets[i].etaCenter;}
328 double phiCenter(
int i)
const {
return jets[i].phiCenter;}
329 double etaWeighted(
int i)
const {
return jets[i].etaWeighted;}
330 double phiWeighted(
int i)
const {
return jets[i].phiWeighted;}
331 int multiplicity(
int i)
const {
return jets[i].multiplicity;}
332 Vec4 pMassless(
int i)
const {
return jets[i].eTjet * Vec4(
333 cos(jets[i].phiWeighted), sin(jets[i].phiWeighted),
334 sinh(jets[i].etaWeighted), cosh(jets[i].etaWeighted) );}
335 Vec4 pMassive(
int i)
const {
return jets[i].pMassive;}
336 double m(
int i)
const {
return jets[i].pMassive.mCalc();}
342 int nError()
const {
return nFew;}
347 static const int TIMESTOPRINT;
351 int nEta, nPhi, select, smear;
352 double resolution, upperCut, threshold;
353 double eTjetMin, coneRadius, eTseed;
359 vector<SingleCellJet> jets;
376 virtual ~SlowJetHook() { }
385 virtual bool include(
int iSel,
const Event& event, Vec4& pSel,
395 class SingleSlowJet {
400 SingleSlowJet( Vec4 pIn = 0.,
double pT2In = 0.,
double yIn = 0.,
401 double phiIn = 0.,
int idxIn = 0) : p(pIn), pT2(pT2In), y(yIn),
402 phi(phiIn), mult(1) { idx.insert(idxIn); }
403 SingleSlowJet(
const SingleSlowJet& ssj) : p(ssj.p), pT2(ssj.pT2),
404 y(ssj.y), phi(ssj.phi), mult(ssj.mult), idx(ssj.idx) { }
405 SingleSlowJet& operator=(
const SingleSlowJet& ssj) {
if (
this != &ssj)
406 { p = ssj.p; pT2 = ssj.pT2; y = ssj.y; phi = ssj.phi;
407 mult = ssj.mult; idx = ssj.idx; }
return *
this; }
427 SlowJet(
int powerIn,
double Rin,
double pTjetMinIn = 0.,
428 double etaMaxIn = 25.,
int selectIn = 2,
int massSetIn = 2,
429 SlowJetHook* sjHookPtrIn = 0,
bool useFJcoreIn =
true,
430 bool useStandardRin =
true) : power(powerIn), R(Rin),
431 pTjetMin(pTjetMinIn), etaMax(etaMaxIn), select(selectIn),
432 massSet(massSetIn), sjHookPtr(sjHookPtrIn), useFJcore(useFJcoreIn),
433 useStandardR(useStandardRin), origSize(), clSize(), clLast(), jtSize(),
434 iMin(), jMin(), dPhi(), dijTemp(), dMin() { isAnti = (power < 0);
435 isKT = (power > 0); R2 = R*R; pT2jetMin = pTjetMin*pTjetMin;
436 cutInEta = (etaMax <= 20.); chargedOnly = (select > 2);
437 visibleOnly = (select == 2); modifyMass = (massSet < 2);
438 noHook = (sjHookPtr == 0);}
441 virtual ~SlowJet() {};
444 bool analyze(
const Event& event) {
445 if ( !setup(event) )
return false;
446 if (useFJcore)
return clusterFJ();
447 while (clSize > 0) doStep();
451 bool setup(
const Event& event);
454 virtual bool doStep();
457 bool doNSteps(
int nStep) {
if (useFJcore)
return false;
458 while(nStep > 0 && clSize > 0) { doStep(); --nStep;}
459 return (nStep == 0); }
462 bool stopAtN(
int nStop) {
if (useFJcore)
return false;
463 while (clSize + jtSize > nStop && clSize > 0) doStep();
464 return (clSize + jtSize == nStop); }
467 int sizeOrig()
const {
return origSize;}
468 int sizeJet()
const {
return jtSize;}
469 int sizeAll()
const {
return jtSize + clSize;}
470 double pT(
int i)
const {
return (i < jtSize)
471 ? sqrt(jets[i].pT2) : sqrt(clusters[i - jtSize].pT2);}
472 double y(
int i)
const {
return (i < jtSize)
473 ? jets[i].y : clusters[i - jtSize].y;}
474 double phi(
int i)
const {
return (i < jtSize)
475 ? jets[i].phi : clusters[i - jtSize].phi;}
476 Vec4 p(
int i)
const {
return (i < jtSize)
477 ? jets[i].p : clusters[i - jtSize].p;}
478 double m(
int i)
const {
return (i < jtSize)
479 ? jets[i].p.mCalc() : clusters[i - jtSize].p.mCalc();}
480 int multiplicity(
int i)
const {
return (i < jtSize)
481 ? jets[i].mult : clusters[i - jtSize].mult;}
484 int iNext()
const {
return (iMin == -1) ? -1 : iMin + jtSize;}
485 int jNext()
const {
return (jMin == -1) ? -1 : jMin + jtSize;}
486 double dNext()
const {
return dMin;}
489 void list(
bool listAll =
false)
const;
492 vector<int> constituents(
int j) { vector<int> cTemp;
493 for (set<int>::iterator idxTmp = jets[j].idx.begin();
494 idxTmp != jets[j].idx.end(); ++idxTmp) cTemp.push_back( *idxTmp);
499 vector<int> clusConstituents(
int j) { vector<int> cTemp;
500 for (set<int>::iterator idxTmp = clusters[j].idx.begin();
501 idxTmp != clusters[j].idx.end(); ++idxTmp) cTemp.push_back( *idxTmp);
507 int jetAssignment(
int i) {
508 for (
int j = 0; j < sizeJet(); ++j)
509 if (jets[j].idx.find(i) != jets[j].idx.end())
return j;
514 void removeJet(
int i) {
515 if (i < 0 || i >= jtSize)
return;
516 jets.erase(jets.begin() + i);
523 static const int TIMESTOPRINT;
524 static const double PIMASS, TINY;
528 double R, pTjetMin, etaMax, R2, pT2jetMin;
531 SlowJetHook* sjHookPtr;
532 bool useFJcore, useStandardR, isAnti, isKT, cutInEta, chargedOnly,
533 visibleOnly, modifyMass, noHook;
536 vector<SingleSlowJet> clusters;
537 vector<SingleSlowJet> jets;
544 int origSize, clSize, clLast, jtSize, iMin, jMin;
545 double dPhi, dijTemp, dMin;
548 virtual void findNext();
559 #endif // end Pythia8_Analysis_H