1 #include "StDijetFilter.h"
2 #include "StarGenerator/EVENT/StarGenParticle.h"
21 mStablemidpoints =
true;
26 mParticleEtaRange = 3.5;
33 mDEta = mJetEtaHigh - mJetEtaLow;
56 vector<JetFourVec*> finalparticles;
57 vector<JetFourVec*> seeds;
62 TIter Iterator = mEvent->
IterAll();
69 finalparticles.push_back(vec);
70 v[0] = (double)p->
GetVx();
71 v[1] = (double)p->
GetVy();
72 v[2] = (double)p->
GetVz();
74 if(vec->
Pt() < mSeed)
continue;
80 seeds = addMidPoints(seeds);
84 vector< vector<JetFourVec*> > jetFour;
85 vector< vector<JetFourVec*> > recoJetFour;
88 for(
unsigned int k = 0; k < seeds.size(); k++){
90 vector<JetFourVec*> jf;
93 while(nChange != 0 && nIter < 10){
95 vector<JetFourVec*>::iterator jfiter;
96 for(
unsigned int l = 0; l < finalparticles.size(); l++){
97 if(finalparticles[l]->getEn()*sin(finalparticles[l]->Theta()) < mAssoc)
continue;
100 jfiter = find(jf.begin(),jf.end(),finalparticles[l]);
101 if(dR(finalparticles[l],j) > mRcone && jfiter == jf.end())
continue;
102 if(dR(finalparticles[l],j) > mRcone && jfiter != jf.end()){
107 if(jfiter != jf.end())
continue;
108 jf.push_back(finalparticles[l]);
112 j = combineTracks(jf);
115 if(jf.size() == 0)
continue;
116 jetFour.push_back(jf);
121 jetFour = EtOrderedList(jetFour);
122 jetFour = RemoveDuplicates(jetFour);
125 jetFour = doSplitMerge(jetFour);
126 jetFour = RemoveDuplicates(jetFour);
132 vector<JetFourVec*> dijetFour;
133 vector<JetFourVec*> dijetFourReco;
135 for(
unsigned int k = 0; k < jetFour.size(); k++){
137 j = combineTracks(jetFour[k]);
139 if(j->
Pt() < mMinJetPt)
continue;
140 if(fabs(j->
Eta()) > mJetEtaHigh)
continue;
142 if(j->
Eta() < mJetEtaLow)
continue;
143 dj = combineTracks(jetFour[k]);
144 dijetFour.push_back(dj);
149 for(
unsigned int k = 0; k < jetFour.size(); k++){
151 if(j->
getEn()*sin(j->
Theta()) > 4 && fabs(j->
Eta()) < 2.5) nTrJets++;
152 if(j->
Eta() < mJetEtaHigh && j->
Eta() > mJetEtaLow){
154 dijetFourReco.push_back(dj);
159 dijetFourReco = EtOrderedList(dijetFourReco);
161 if(dijetFour.size() > 1){
163 (*dj) = *(dijetFour[0]) + *(dijetFour[1]);
164 float dphi = fabs(dijetFour[0]->Phi() - dijetFour[1]->Phi());
165 float deta = fabs(dijetFour[0]->Eta() - dijetFour[1]->Eta());
166 if(dphi > acos(-1))dphi = fabs(2*acos(-1) - dphi);
167 if(dphi > mDPhi && deta < mDEta && dj->M() > 10. && dijetFour[0]->Pt() > mPtHigh && dijetFour[1]->Pt() > mPtLow)yesdijet += 1;
172 if(dijetFourReco.size() > 1){
174 (*dj) = *(dijetFourReco[0]) + *(dijetFourReco[1]);
175 float dphi = fabs(dijetFourReco[0]->Phi() - dijetFourReco[1]->Phi());
176 float deta = fabs(dijetFourReco[0]->Eta() - dijetFourReco[1]->Eta());
177 if(dphi > acos(-1))dphi = fabs(2*acos(-1) - dphi);
178 if(dphi > mDPhi && deta < mDEta && dj->M() > 10. && dijetFourReco[0]->Pt() > mPtHigh && dijetFourReco[1]->Pt() > mPtLow)yesdijet += 2;
182 cout <<
"\n" <<
"agrdl: event "<<(*nEvents)<<
" "<<nJets<<
" "<<nTrJets<<
" "<<yesdijet<<endl;
183 for(
unsigned int k = 0; k < finalparticles.size(); k++)
184 delete finalparticles[k];
185 finalparticles.clear();
189 return StarGenEvent::kReject;
192 return StarGenEvent::kAccept;
195 void StDijetFilter::readConfig()
197 ifstream cfile(
"dijet.cnf");
201 cfile >> attr >> val;
202 if(!cfile.good())
break;
211 cout<<
"RBTOW changed to "<<val<<endl;
216 cout<<
"RCONE changed to "<<val<<endl;
221 cout<<
"SEED changed to "<<val<<endl;
226 cout<<
"ASSOC changed to "<<val<<endl;
230 mSplitfraction = val;
231 cout<<
"SPLIT changed to "<<val<<endl;
234 if(attr ==
"MIDPOINT"){
236 mAddmidpoints =
true;
237 cout<<
"MIDPOINT changed to TRUE"<<endl;
239 }
else if(val == 0.0){
240 mAddmidpoints =
false;
241 cout<<
"MIDPOINT changed to FALSE"<<endl;
244 cout<<
"IMPRORER INPUT TO MIDPOINTS"<<endl;
247 if(attr ==
"STABLEMIDPOINTS"){
249 mStablemidpoints =
true;
250 cout<<
"STABLEMIDPOINTS changed to TRUE"<<endl;
252 }
else if(val == 0.0){
253 mStablemidpoints =
false;
254 cout<<
"STABLEMIDPOINTS changed to FALSE"<<endl;
257 cout<<
"IMPRORER INPUT TO STABLEMIDPOINTS"<<endl;
260 if(attr ==
"SPLITMERGE"){
263 cout<<
"SPLITMERGE changed to TRUE"<<endl;
265 }
else if(val == 0.0){
267 cout<<
"SPLITMERGE changed to FALSE"<<endl;
270 cout<<
"IMPRORER INPUT TO SPLITMERGE"<<endl;
273 if(attr ==
"PARTICLEETA"){
274 mParticleEtaRange = val;
275 cout<<
"PARTICLEETA changed to "<<val<<endl;
278 if(attr ==
"JETETAHIGH"){
280 cout<<
"JETETAHIGH changed to "<<val<<endl;
283 if(attr ==
"JETETALOW"){
285 cout<<
"JETETALOW changed to "<<val<<endl;
288 if(attr ==
"DIJETPTLOW"){
290 cout<<
"DIJETPTLOW changed to "<<val<<endl;
293 if(attr ==
"DIJETPTHIGH"){
295 cout<<
"DIJETPTHIGH changed to "<<val<<endl;
300 cout<<
"DPHI changed to "<<val<<endl;
303 if(attr ==
"MINJETPT"){
305 cout<<
"MINJETPT changed to "<<val<<endl;
310 cout<<
"DETA changed to "<<val<<endl;
313 if(attr ==
"RECOHADRON"){
315 cout<<
"RECOHADRON changed to "<<val<<endl;
318 if(attr ==
"RECOLEPTON"){
320 cout<<
"RECOLEPTON changed to "<<val<<endl;
325 JetFourVec* StDijetFilter::recoJet(vector<JetFourVec*> v,
double* vert)
const
328 for(
unsigned int i = 0; i < v.size(); i++){
330 if(abs(
id) != 11 &&
id != -2212 &&
id != -2122){
331 v[i]->setPtEtaPhiM(mRecohadron*v[i]->Pt(),v[i]->Eta(),v[i]->Phi(),v[i]->M());
333 v[i]->setPtEtaPhiM(mRecolepton*v[i]->Pt(),v[i]->Eta(),v[i]->Phi(),v[i]->M());
335 (*j) = (*j) + (*v[i]);
341 vector<JetFourVec*> StDijetFilter::addMidPoints(vector<JetFourVec*> seeds)
const
343 unsigned int n = seeds.size();
344 float pi = acos(-1.0);
345 for(
unsigned int k = 0; k < n; k++){
346 for(
unsigned int l = 0; l < k; l++){
347 if(dR(seeds[k],seeds[l]) > 2*mRcone)
continue;
349 float maxphi = max(seeds[k]->Phi(),seeds[l]->Phi());
350 float minphi = min(seeds[k]->Phi(),seeds[l]->Phi());
351 float dphi = fabs(maxphi - minphi);
352 if(dphi > pi)minphi += 2*pi;
353 float neta = 0.5*(seeds[k]->Eta() + seeds[l]->Eta());
354 float nphi = 0.5*(maxphi + minphi);
355 if(nphi > pi)nphi -= 2*pi;
356 if(nphi < -pi) nphi += 2*pi;
364 void StDijetFilter::split(vector<JetFourVec*> &v1, vector<JetFourVec*> &v2)
const
369 vector<JetFourVec*>::iterator dit;
370 for(vector<JetFourVec*>::iterator it = v1.begin(); it != v1.end(); it++){
371 dit = find(v2.begin(),v2.end(),*it);
372 if(dit == v2.end())
continue;
373 float d1 = dR(j1,*it);
374 float d2 = dR(j2,*it);
379 for(vector<JetFourVec*>::iterator it = v2.begin(); it != v2.end(); it++){
380 dit = find(v1.begin(),v1.end(),*it);
381 if(dit == v1.end())
continue;
382 float d1 = dR(j1,*it);
383 float d2 = dR(j2,*it);
393 vector<JetFourVec*> StDijetFilter::merge(vector<JetFourVec*> v1, vector<JetFourVec*> v2)
const
395 vector<JetFourVec*> nj = v1;
396 vector<JetFourVec*>::iterator iter;
397 for(iter = v2.begin(); iter != v2.end(); iter++){
398 vector<JetFourVec*>::iterator it2 = find(v1.begin(),v1.end(),*iter);
399 if(it2 == v1.end()) nj.push_back(*iter);
405 vector< vector<JetFourVec*> > StDijetFilter::doSplitMerge(vector< vector<JetFourVec*> >orig)
const
407 vector< vector<JetFourVec*> > njf;
408 vector< vector<JetFourVec* > > jetFour = orig;
412 if(nIter > 200)
break;
416 vector< vector<JetFourVec*> >::iterator iter1;
417 vector< vector<JetFourVec*> >::iterator iter2;
418 for(iter1 = njf.begin(); iter1 != njf.end(); iter1++){
420 if((*iter1).size() == 0)
continue;
422 for(iter2 = iter1+1; iter2 != njf.end(); iter2++){
424 if((*iter2).size() == 0)
continue;
426 if(dR(nj,j) > 2*mRcone){
430 float oe = overlapEnergy(*iter1,*iter2);
436 vector< vector<JetFourVec*> >::iterator njit1;
437 vector< vector<JetFourVec*> >::iterator njit2;
438 njit1 = find(jetFour.begin(),jetFour.end(),*iter1);
439 njit2 = find(jetFour.begin(),jetFour.end(),*iter2);
440 if ( njit1!=jetFour.end() && njit2!=jetFour.end() )
442 if(oe > mSplitfraction){
443 vector<JetFourVec*> mj = merge(*iter1,*iter2);
446 jetFour.erase(njit2);
447 jetFour.erase(njit1);
448 jetFour.insert(jetFour.begin(),mj);
452 split(*njit1,*njit2);
461 jetFour = EtOrderedList(jetFour);
469 float StDijetFilter::overlapEnergy(vector<JetFourVec*> v1,vector<JetFourVec*> v2)
const
476 for(vector<JetFourVec*>::iterator iter1 = v1.begin(); iter1 != v1.end(); iter1++){
477 vector<JetFourVec*>::iterator iter2 = find(v2.begin(),v2.end(),*iter1);
478 if(iter2 == v2.end())
continue;
479 e += (*iter2)->getEn()*sin((*iter2)->Theta());
489 vector<JetFourVec*> StDijetFilter::EtOrderedList(vector<JetFourVec*> jetFour)
const
491 vector<JetFourVec*> njf;
492 vector<JetFourVec*>::iterator jfvIter;
493 vector<JetFourVec*>::iterator njfvIter;
494 for(jfvIter = jetFour.begin(); jfvIter != jetFour.end(); jfvIter++){
495 if((*jfvIter)->Pt() == 0)
continue;
497 for(njfvIter = njf.begin(); njfvIter != njf.end(); njfvIter++){
498 if((*jfvIter)->Pt() > (*njfvIter)->Pt()){
499 njf.insert(njfvIter,*jfvIter);
505 njf.push_back(*jfvIter);
512 vector< vector<JetFourVec*> > StDijetFilter::RemoveDuplicates(vector< vector<JetFourVec*> >jetFour)
const
514 vector< vector<JetFourVec*> > njf;
515 vector< vector<JetFourVec*> >::iterator jfvIter;
516 vector< vector<JetFourVec*> >::iterator njfvIter;
517 for(jfvIter = jetFour.begin(); jfvIter != jetFour.end(); jfvIter++){
518 if((*jfvIter).size() == 0)
continue;
521 for(njfvIter = njf.begin(); njfvIter != njf.end(); njfvIter++){
523 if(*nj == *j)dupe = 1;
526 if(!dupe)njf.push_back(*jfvIter);
532 vector< vector<JetFourVec*> > StDijetFilter::EtOrderedList(vector< vector<JetFourVec*> >jetFour)
const
534 vector< vector<JetFourVec*> > njf;
535 vector< vector<JetFourVec*> >::iterator jfvIter;
536 vector< vector<JetFourVec*> >::iterator njfvIter;
537 for(jfvIter = jetFour.begin(); jfvIter != jetFour.end(); jfvIter++){
538 if((*jfvIter).size() == 0)
continue;
540 if(j->
Pt() == 0){
delete j;
continue;}
542 for(njfvIter = njf.begin(); njfvIter != njf.end(); njfvIter++){
544 if(j->
Pt() > nj->
Pt()){
545 njf.insert(njfvIter,*jfvIter);
553 njf.push_back(*jfvIter);
566 float pi = acos(-1.0);
567 if(dphi > pi)dphi = 2*pi - dphi;
568 return sqrt(pow(deta,2) + pow(dphi,2));
575 float pi = acos(-1.0);
576 if(dphi > pi)dphi = 2*pi - dphi;
577 return sqrt(pow(deta,2) + pow(dphi,2));
587 float dphi = fabs(v1->
Phi() - v2->
Phi());
588 float deta = v1->
Eta() - v2->
Eta();
589 float pi = acos(-1.0);
590 if(dphi > pi)dphi = 2*pi - dphi;
591 return sqrt(pow(deta,2) + pow(dphi,2));
594 JetFourVec* StDijetFilter::combineTracks(vector<JetFourVec*> jf)
const
597 if(jf.size() == 0)
return j;
598 for(
unsigned int i = 0; i < jf.size(); i++){
599 (*j) = (*j) + (*jf[i]);
608 px = 0,py = 0,pz = 0,en = 0;code = 0;
639 return sqrt(px*px + py*py + pz*pz);
644 return sqrt(px*px + py*py);
650 if(pmom > fabs(pz))
return -log(tan(
Theta()/2.));
666 if(en*en -
P()*
P() < 0)
return 0;
667 return sqrt(en*en-
P()*
P());
672 float x = pt * cos(phi);
673 float y = pt * sin(phi);
674 float p = pt*cosh(eta);
675 float z = sqrt(p*p-pt*pt)*eta/fabs(eta);
676 float e = sqrt(m*m + p*p);
682 float x = pt * cos(phi);
683 float y = pt * sin(phi);
684 float p = pt*cosh(eta);
685 float z = sqrt(p*p-pt*pt)*eta/fabs(eta);
703 if(code != x.
getCode())
return false;
704 if(fabs(px - x.
getPx()) > 1e-4)
return false;
705 if(fabs(py - x.
getPy()) > 1e-4)
return false;
706 if(fabs(pz - x.
getPz()) > 1e-4)
return false;
707 if(fabs(en - x.
getEn()) > 1e-4)
return false;
float getPz()
getter for py
Float_t GetVz()
Get the z-component of the start vertex.
virtual ~StDijetFilter()
constructor
float getEn()
getter for pz
float Eta()
calculate vector pt
Int_t GetNumberOfParticles()
Obtain the number of particles in the event record.
float getPx()
getter for pdg code
Yet another particle class.
Int_t GetStatus()
Get the status code of the particle according to the HEPEVT standard.
JetFourVec()
pdg code of four vector
float M()
calculate vector theta
Float_t GetPz()
Get the z-component of the momentum.
void setPx(float x)
setter for pdg code
Float_t GetEnergy()
Get the energy.
void setPxPyPzEn(float, float, float, float)
setter for en
void setCode(int x)
equality operator
JetFourVec operator+(JetFourVec)
destructor
float Theta()
calculate vector phi
Int_t GetId()
Get the id code of the particle according to the PDG standard.
float P()
calculate vector mass
Main filter class. Goes anywhere in the chain, filters StarGenEvent objects.
void setPz(float x)
setter for py
void setPy(float x)
setter for px
void setPtEtaPhiM(float, float, float, float)
four element setter
bool operator==(JetFourVec)
addition operator
int getCode()
alternative four element setter
Float_t GetPx()
Get the x-component of the momentum.
Float_t GetVy()
Get the y-component of the start vertex.
Float_t GetPy()
Get the y-component of the momentum.
void parseConfig(std::string, float)
float Phi()
calculate vector pseudorapidity
Base class for event records.
void setPtEtaPhiE(float, float, float, float)
alternative four element setter
Float_t GetVx()
Get the x-component of the start vertex.
void setEn(float x)
setter for pz
TIter IterAll(Bool_t dir=kIterForward)
float getPy()
getter for px
StDijetFilter()
read a config file to adjust parameters
Int_t Filter(StarGenEvent *mEvent)
destructor