1 #include "StDijetFilter.h"
2 #include "StGenParticle.h"
23 mStablemidpoints =
true;
28 mParticleEtaRange = 3.5;
35 mDEta = mJetEtaHigh - mJetEtaLow;
60 if(ptl.Size() <= 0)
return 1;
62 vector<JetFourVec*> finalparticles;
63 vector<JetFourVec*> seeds;
68 for(
int i = 0; i < ptl.Size(); i++){
69 if(ptl(i)->GetStatusCode() != 1)
continue;
70 if(fabs(ptl(i)->Eta()) > mParticleEtaRange)
continue;
72 finalparticles.push_back(p);
75 if(p->
Pt() < mSeed)
continue;
81 seeds = addMidPoints(seeds);
85 vector< vector<JetFourVec*> > jetFour;
86 vector< vector<JetFourVec*> > recoJetFour;
89 for(
unsigned int k = 0; k < seeds.size(); k++){
91 vector<JetFourVec*> jf;
94 while(nChange != 0 && nIter < 10){
96 vector<JetFourVec*>::iterator jfiter;
97 for(
unsigned int l = 0; l < finalparticles.size(); l++){
98 if(finalparticles[l]->getEn()*sin(finalparticles[l]->Theta()) < mAssoc)
continue;
101 jfiter = find(jf.begin(),jf.end(),finalparticles[l]);
102 if(dR(finalparticles[l],j) > mRcone && jfiter == jf.end())
continue;
103 if(dR(finalparticles[l],j) > mRcone && jfiter != jf.end()){
108 if(jfiter != jf.end())
continue;
109 jf.push_back(finalparticles[l]);
113 j = combineTracks(jf);
120 jetFour.push_back(jf);
125 jetFour = EtOrderedList(jetFour);
126 jetFour = RemoveDuplicates(jetFour);
129 jetFour = doSplitMerge(jetFour);
130 jetFour = RemoveDuplicates(jetFour);
136 vector<JetFourVec*> dijetFour;
137 vector<JetFourVec*> dijetFourReco;
139 for(
unsigned int k = 0; k < jetFour.size(); k++){
141 j = combineTracks(jetFour[k]);
143 if(j->
Pt() < mMinJetPt)
continue;
144 if(fabs(j->
Eta()) > mJetEtaHigh)
continue;
146 if(j->
Eta() < mJetEtaLow)
continue;
147 dj = combineTracks(jetFour[k]);
148 dijetFour.push_back(dj);
153 for(
unsigned int k = 0; k < jetFour.size(); k++){
155 if(j->
getEn()*sin(j->
Theta()) > 4 && fabs(j->
Eta()) < 2.5) nTrJets++;
156 if(j->
Eta() < mJetEtaHigh && j->
Eta() > mJetEtaLow){
158 dijetFourReco.push_back(dj);
163 dijetFourReco = EtOrderedList(dijetFourReco);
165 if(dijetFour.size() > 1){
167 (*dj) = *(dijetFour[0]) + *(dijetFour[1]);
168 float dphi = fabs(dijetFour[0]->Phi() - dijetFour[1]->Phi());
169 float deta = fabs(dijetFour[0]->Eta() - dijetFour[1]->Eta());
170 if(dphi > acos(-1))dphi = fabs(2*acos(-1) - dphi);
171 if(dphi > mDPhi && deta < mDEta && dj->M() > 10. && dijetFour[0]->Pt() > mPtHigh && dijetFour[1]->Pt() > mPtLow)yesdijet += 1;
176 if(dijetFourReco.size() > 1){
178 (*dj) = *(dijetFourReco[0]) + *(dijetFourReco[1]);
179 float dphi = fabs(dijetFourReco[0]->Phi() - dijetFourReco[1]->Phi());
180 float deta = fabs(dijetFourReco[0]->Eta() - dijetFourReco[1]->Eta());
181 if(dphi > acos(-1))dphi = fabs(2*acos(-1) - dphi);
182 if(dphi > mDPhi && deta < mDEta && dj->M() > 10. && dijetFourReco[0]->Pt() > mPtHigh && dijetFourReco[1]->Pt() > mPtLow)yesdijet += 2;
186 cout <<
"\n" <<
"agrdl: event "<<(*nEvents)<<
" "<<nJets<<
" "<<nTrJets<<
" "<<yesdijet<<endl;
187 for(
unsigned int k = 0; k < finalparticles.size(); k++)
188 delete finalparticles[k];
189 finalparticles.clear();
191 if(yesdijet == 0)
return 1;
201 void StDijetFilter::readConfig()
203 ifstream cfile(
"dijet.cnf");
207 cfile >> attr >> val;
208 if(!cfile.good())
break;
217 cout<<
"RBTOW changed to "<<val<<endl;
222 cout<<
"RCONE changed to "<<val<<endl;
227 cout<<
"SEED changed to "<<val<<endl;
232 cout<<
"ASSOC changed to "<<val<<endl;
236 mSplitfraction = val;
237 cout<<
"SPLIT changed to "<<val<<endl;
240 if(attr ==
"MIDPOINT"){
242 mAddmidpoints =
true;
243 cout<<
"MIDPOINT changed to TRUE"<<endl;
245 }
else if(val == 0.0){
246 mAddmidpoints =
false;
247 cout<<
"MIDPOINT changed to FALSE"<<endl;
250 cout<<
"IMPRORER INPUT TO MIDPOINTS"<<endl;
253 if(attr ==
"STABLEMIDPOINTS"){
255 mStablemidpoints =
true;
256 cout<<
"STABLEMIDPOINTS changed to TRUE"<<endl;
258 }
else if(val == 0.0){
259 mStablemidpoints =
false;
260 cout<<
"STABLEMIDPOINTS changed to FALSE"<<endl;
263 cout<<
"IMPRORER INPUT TO STABLEMIDPOINTS"<<endl;
266 if(attr ==
"SPLITMERGE"){
269 cout<<
"SPLITMERGE changed to TRUE"<<endl;
271 }
else if(val == 0.0){
273 cout<<
"SPLITMERGE changed to FALSE"<<endl;
276 cout<<
"IMPRORER INPUT TO SPLITMERGE"<<endl;
279 if(attr ==
"PARTICLEETA"){
280 mParticleEtaRange = val;
281 cout<<
"PARTICLEETA changed to "<<val<<endl;
284 if(attr ==
"JETETAHIGH"){
286 cout<<
"JETETAHIGH changed to "<<val<<endl;
289 if(attr ==
"JETETALOW"){
291 cout<<
"JETETALOW changed to "<<val<<endl;
294 if(attr ==
"DIJETPTLOW"){
296 cout<<
"DIJETPTLOW changed to "<<val<<endl;
299 if(attr ==
"DIJETPTHIGH"){
301 cout<<
"DIJETPTHIGH changed to "<<val<<endl;
306 cout<<
"DPHI changed to "<<val<<endl;
309 if(attr ==
"MINJETPT"){
311 cout<<
"MINJETPT changed to "<<val<<endl;
316 cout<<
"DETA changed to "<<val<<endl;
319 if(attr ==
"RECOHADRON"){
321 cout<<
"RECOHADRON changed to "<<val<<endl;
324 if(attr ==
"RECOLEPTON"){
326 cout<<
"RECOLEPTON changed to "<<val<<endl;
331 JetFourVec* StDijetFilter::recoJet(vector<JetFourVec*> v,
double* vert)
const
334 for(
unsigned int i = 0; i < v.size(); i++){
336 if(abs(
id) != 11 &&
id != -2212 &&
id != -2122){
337 v[i]->setPtEtaPhiM(mRecohadron*v[i]->Pt(),v[i]->Eta(),v[i]->Phi(),v[i]->M());
339 v[i]->setPtEtaPhiM(mRecolepton*v[i]->Pt(),v[i]->Eta(),v[i]->Phi(),v[i]->M());
341 (*j) = (*j) + (*v[i]);
347 vector<JetFourVec*> StDijetFilter::addMidPoints(vector<JetFourVec*> seeds)
const
349 unsigned int n = seeds.size();
350 float pi = acos(-1.0);
351 for(
unsigned int k = 0; k < n; k++){
352 for(
unsigned int l = 0; l < k; l++){
353 if(dR(seeds[k],seeds[l]) > 2*mRcone)
continue;
355 float maxphi = max(seeds[k]->Phi(),seeds[l]->Phi());
356 float minphi = min(seeds[k]->Phi(),seeds[l]->Phi());
357 float dphi = fabs(maxphi - minphi);
358 if(dphi > pi)minphi += 2*pi;
359 float neta = 0.5*(seeds[k]->Eta() + seeds[l]->Eta());
360 float nphi = 0.5*(maxphi + minphi);
361 if(nphi > pi)nphi -= 2*pi;
362 if(nphi < -pi) nphi += 2*pi;
370 void StDijetFilter::split(vector<JetFourVec*> &v1, vector<JetFourVec*> &v2)
const
375 vector<JetFourVec*>::iterator dit;
376 for(vector<JetFourVec*>::iterator it = v1.begin(); it != v1.end(); it++){
377 dit = find(v2.begin(),v2.end(),*it);
378 if(dit == v2.end())
continue;
379 float d1 = dR(j1,*it);
380 float d2 = dR(j2,*it);
385 for(vector<JetFourVec*>::iterator it = v2.begin(); it != v2.end(); it++){
386 dit = find(v1.begin(),v1.end(),*it);
387 if(dit == v1.end())
continue;
388 float d1 = dR(j1,*it);
389 float d2 = dR(j2,*it);
399 vector<JetFourVec*> StDijetFilter::merge(vector<JetFourVec*> v1, vector<JetFourVec*> v2)
const
401 vector<JetFourVec*> nj = v1;
402 vector<JetFourVec*>::iterator iter;
403 for(iter = v2.begin(); iter != v2.end(); iter++){
404 vector<JetFourVec*>::iterator it2 = find(v1.begin(),v1.end(),*iter);
405 if(it2 == v1.end()) nj.push_back(*iter);
411 vector< vector<JetFourVec*> > StDijetFilter::doSplitMerge(vector< vector<JetFourVec*> >orig)
const
413 vector< vector<JetFourVec*> > njf;
414 vector< vector<JetFourVec* > > jetFour = orig;
418 if(nIter > 200)
break;
422 vector< vector<JetFourVec*> >::iterator iter1;
423 vector< vector<JetFourVec*> >::iterator iter2;
424 for(iter1 = njf.begin(); iter1 != njf.end(); iter1++){
426 if((*iter1).size() == 0)
continue;
428 for(iter2 = iter1+1; iter2 != njf.end(); iter2++){
430 if((*iter2).size() == 0)
continue;
432 if(dR(nj,j) > 2*mRcone){
436 float oe = overlapEnergy(*iter1,*iter2);
442 vector< vector<JetFourVec*> >::iterator njit1;
443 vector< vector<JetFourVec*> >::iterator njit2;
444 njit1 = find(jetFour.begin(),jetFour.end(),*iter1);
445 njit2 = find(jetFour.begin(),jetFour.end(),*iter2);
446 if ( njit1 != jetFour.end() && njit2 != jetFour.end() ) {
447 if(oe > mSplitfraction){
448 vector<JetFourVec*> mj = merge(*iter1,*iter2);
451 jetFour.erase(njit2);
452 jetFour.erase(njit1);
453 jetFour.insert(jetFour.begin(),mj);
457 split(*njit1,*njit2);
465 jetFour = EtOrderedList(jetFour);
473 float StDijetFilter::overlapEnergy(vector<JetFourVec*> v1,vector<JetFourVec*> v2)
const
480 for(vector<JetFourVec*>::iterator iter1 = v1.begin(); iter1 != v1.end(); iter1++){
481 vector<JetFourVec*>::iterator iter2 = find(v2.begin(),v2.end(),*iter1);
482 if(iter2 == v2.end())
continue;
483 e += (*iter2)->getEn()*sin((*iter2)->Theta());
493 vector<JetFourVec*> StDijetFilter::EtOrderedList(vector<JetFourVec*> jetFour)
const
495 vector<JetFourVec*> njf;
496 vector<JetFourVec*>::iterator jfvIter;
497 vector<JetFourVec*>::iterator njfvIter;
498 for(jfvIter = jetFour.begin(); jfvIter != jetFour.end(); jfvIter++){
499 if((*jfvIter)->Pt() == 0)
continue;
501 for(njfvIter = njf.begin(); njfvIter != njf.end(); njfvIter++){
502 if((*jfvIter)->Pt() > (*njfvIter)->Pt()){
503 njf.insert(njfvIter,*jfvIter);
509 njf.push_back(*jfvIter);
516 vector< vector<JetFourVec*> > StDijetFilter::RemoveDuplicates(vector< vector<JetFourVec*> >jetFour)
const
518 vector< vector<JetFourVec*> > njf;
519 vector< vector<JetFourVec*> >::iterator jfvIter;
520 vector< vector<JetFourVec*> >::iterator njfvIter;
521 for(jfvIter = jetFour.begin(); jfvIter != jetFour.end(); jfvIter++){
522 if((*jfvIter).size() == 0)
continue;
525 for(njfvIter = njf.begin(); njfvIter != njf.end(); njfvIter++){
527 if(*nj == *j)dupe = 1;
530 if(!dupe)njf.push_back(*jfvIter);
536 vector< vector<JetFourVec*> > StDijetFilter::EtOrderedList(vector< vector<JetFourVec*> >jetFour)
const
538 vector< vector<JetFourVec*> > njf;
539 vector< vector<JetFourVec*> >::iterator jfvIter;
540 vector< vector<JetFourVec*> >::iterator njfvIter;
541 for(jfvIter = jetFour.begin(); jfvIter != jetFour.end(); jfvIter++){
542 if((*jfvIter).size() == 0)
continue;
544 if(j->
Pt() == 0){
delete j;
continue;}
546 for(njfvIter = njf.begin(); njfvIter != njf.end(); njfvIter++){
548 if(j->
Pt() > nj->
Pt()){
549 njf.insert(njfvIter,*jfvIter);
557 njf.push_back(*jfvIter);
568 float dphi = fabs(p1->Phi() - p2->Phi());
569 float deta = p1->Eta() - p2->Eta();
570 float pi = acos(-1.0);
571 if(dphi > pi)dphi = 2*pi - dphi;
572 return sqrt(pow(deta,2) + pow(dphi,2));
577 float dphi = fabs(p->Phi() - v->
Phi());
578 float deta = p->Eta() - v->
Eta();
579 float pi = acos(-1.0);
580 if(dphi > pi)dphi = 2*pi - dphi;
581 return sqrt(pow(deta,2) + pow(dphi,2));
591 float dphi = fabs(v1->
Phi() - v2->
Phi());
592 float deta = v1->
Eta() - v2->
Eta();
593 float pi = acos(-1.0);
594 if(dphi > pi)dphi = 2*pi - dphi;
595 return sqrt(pow(deta,2) + pow(dphi,2));
598 JetFourVec* StDijetFilter::combineTracks(vector<JetFourVec*> jf)
const
601 if(jf.size() == 0)
return j;
602 for(
unsigned int i = 0; i < jf.size(); i++){
603 (*j) = (*j) + (*jf[i]);
612 px = 0,py = 0,pz = 0,en = 0;code = 0;
632 code = g->GetPdgCode();
645 return sqrt(px*px + py*py + pz*pz);
650 return sqrt(px*px + py*py);
656 if(pmom > fabs(pz))
return -log(tan(
Theta()/2.));
672 if(en*en -
P()*
P() < 0)
return 0;
673 return sqrt(en*en-
P()*
P());
678 float x = pt * cos(phi);
679 float y = pt * sin(phi);
680 float p = pt*cosh(eta);
681 float z = sqrt(p*p-pt*pt)*eta/fabs(eta);
682 float e = sqrt(m*m + p*p);
688 float x = pt * cos(phi);
689 float y = pt * sin(phi);
690 float p = pt*cosh(eta);
691 float z = sqrt(p*p-pt*pt)*eta/fabs(eta);
709 if(code != x.
getCode())
return false;
710 if(fabs(px - x.
getPx()) > 1e-4)
return false;
711 if(fabs(py - x.
getPy()) > 1e-4)
return false;
712 if(fabs(pz - x.
getPz()) > 1e-4)
return false;
713 if(fabs(en - x.
getEn()) > 1e-4)
return false;
float getPz()
getter for py
virtual ~StDijetFilter()
constructor
float getEn()
getter for pz
float Eta()
calculate vector pt
Abstract base class for particles related to common /HEPEVT/.
float getPx()
getter for pdg code
JetFourVec()
pdg code of four vector
float M()
calculate vector theta
void setPx(float x)
setter for pdg code
void setPxPyPzEn(float, float, float, float)
setter for en
void setCode(int x)
equality operator
JetFourVec operator+(JetFourVec)
destructor
float Theta()
calculate vector phi
float P()
calculate vector mass
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
int RejectEG(const StGenParticleMaster &ptl) const
destructor
void parseConfig(std::string, float)
float Phi()
calculate vector pseudorapidity
void setPtEtaPhiE(float, float, float, float)
alternative four element setter
int RejectGT(const StGenParticleMaster &ptl) const
Rejection of GEANT Tracking.
void setEn(float x)
setter for pz
float getPy()
getter for px
StDijetFilter()
read a config file to adjust parameters
int RejectGE(const StGenParticleMaster &ptl) const
Rejection at GEANT End, No GEANT output.