19 declareInterface<IGenParticleJetFinder>(
this);
29 return StatusCode::SUCCESS;
37 return StatusCode::SUCCESS;
45 if (GenStableCharged.empty()) {
49 std::vector< Trk::GenParticleJet >* myJets
50 =
new std::vector< Trk::GenParticleJet >;
51 ATH_MSG_DEBUG (
"start jetMCFinder() with input GenParticle-vector "
52 <<
"of size " << GenStableCharged.size() );
55 double totalEnergyFromTracks=0.;
58 bool combineParticles =
false;
62 for(
auto i = GenStableCharged.begin() ;
i < GenStableCharged.end(); ++
i){
63 totalEnergyFromTracks = totalEnergyFromTracks + (*i)->momentum().
e();
66 myJets->push_back(tempPJ);
69 int numParts = myJets->size();
71 combineParticles =
false;
80 double absI= sqrt((
i->getMomentum()).dot(
i->getMomentum()));
81 double absJ= sqrt(((*j).getMomentum()).dot((*j).getMomentum()));
82 double IdotJ= (((*i).getMomentum()).
dot((*j).getMomentum()));
83 if (fabs(absI*absJ)<0.000001 || fabs(totalEnergyFromTracks)<0.00001) {
86 <<
"can't continue calculations." );
91 yij=2*(
i->getEnergy())*(j->getEnergy())/
pow(totalEnergyFromTracks,2)*(1-(IdotJ/(absI*absJ)));
94 combineParticles=
true;
108 if (combineParticles) {
111 <<
" ("<<(*iAtMin).getIndicesInEvent().size()<<
")"
112 <<
" and "<< (*jAtMin).getNumParticles()
113 <<
" ("<<(*jAtMin).getIndicesInEvent().size()<<
")" );
114 if((*iAtMin).getNumParticles()>(*jAtMin).getNumParticles()) {
116 auto partsTemp = (*jAtMin).getParticles();
117 std::vector<int> indexTemp = (*jAtMin).getIndicesInEvent();
119 if (!partsTemp.empty()) {
122 for (
auto k =partsTemp.begin();
k!=partsTemp.end(); ++
k, ++ki) {
123 (*iAtMin).addParticle(*
k,*ki);
127 ATH_MSG_WARNING (
"No particles in this jet, logic failed, stop finder." );
131 myJets->erase(jAtMin);
135 auto partsTemp = (*iAtMin).getParticles();
136 std::vector<int> indexTemp = (*iAtMin).getIndicesInEvent();
137 if (!partsTemp.empty()) {
140 for (
auto k =partsTemp.begin();
k!=partsTemp.end(); ++
k, ++ki) {
142 (*jAtMin).addParticle(*
k,*ki);
146 ATH_MSG_WARNING (
"No particles in this jet, logic failed, stop finder." );
150 myJets->erase(iAtMin);
153 int currentNumParts = 0;
155 currentNumParts = currentNumParts +
k->getNumParticles();
157 if(numParts != currentNumParts){
162 if(partIterations==999)
163 ATH_MSG_INFO (
"JetMCFinder cut off because of too many (1000) iterations");
165 }
while (yijmin<m_yijCut && partIterations<1000);