86 #include <Math/VectorUtil.h> 127 produces<JetMatchedPartonsCollection>();
131 if ( iConfig.
exists(
"doPriority") ) {
133 priorityList = iConfig.
getParameter<vector<int> >(
"priorityList");
136 priorityList.clear();
160 aParton.
pdgId() <<
" " <<
161 aParton.
pt() <<
" " <<
162 aParton.
eta() <<
" " <<
163 aParton.
phi() << endl;
166 auto jetMatchedPartons = std::make_unique<JetMatchedPartonsCollection>(
reco::JetRefBaseProd(jets_h));
168 for (
size_t j = 0; j < jets_h->size(); j++) {
170 const int theMappedPartonAlg = fillAlgoritDefinition( (*jets_h)[j], wv );
171 const int theMappedPartonPhy = fillPhysicsDefinition( (*jets_h)[j], wv );
182 if(theMappedPartonPhy>=0) pPH = wv.
particles->at( theMappedPartonPhy );
183 if(theMappedPartonAlg>=0) pAL = wv.
particles->at( theMappedPartonAlg );
185 (*jetMatchedPartons)[jets_h->refAt(j)]=
MatchedPartons(pHV,pN2,pN3,pPH,pAL);
217 int tempParticle = -1;
218 int tempPartonHighestPt = -1;
219 int tempNearest = -1;
222 bool foundPriority =
false;
243 for(
size_t m = 0;
m < wv.
particles->size() && !foundPriority; ++
m ) {
252 vector<int>::const_iterator ipriority =
find( priorityList.begin(), priorityList.end(),
flavour );
254 if ( ipriority != priorityList.end() ) {
257 double dist =
DeltaR( theJet.
p4(), aParton.
p4() );
260 foundPriority =
true;
267 foundPriority =
false;
275 if( !foundPriority && aParton.
status() != 3 ) {
276 double dist =
DeltaR( theJet.
p4(), aParton.
p4() );
282 if( tempParticle == -1 && ( flavour == 4 ) ) tempParticle =
m;
283 if( flavour == 5 ) tempParticle =
m;
285 maxPt = aParton.
pt();
286 tempPartonHighestPt =
m;
292 if ( foundPriority ) {
300 if ( tempParticle == -1 ) tempParticle = tempPartonHighestPt;
329 float TheBiggerConeSize = 0.7;
330 int tempParticle = -1;
332 int tempNearest = -1;
334 bool foundPriority =
false;
336 vector<const reco::Candidate *> theContaminations;
337 theContaminations.clear();
358 for(
size_t m = 0;
m < wv.
particles->size() && !foundPriority; ++
m ) {
368 vector<int>::const_iterator ipriority =
find( priorityList.begin(), priorityList.end(),
flavour );
370 if ( ipriority != priorityList.end() ) {
373 double dist =
DeltaR( theJet.
p4(), aParticle.
p4() );
376 foundPriority =
true;
383 foundPriority =
false;
387 if ( !foundPriority ) {
390 bool isAParton =
false;
396 flavour == 21 ) isAParton =
true;
397 if(!isAParton)
continue;
398 double dist =
DeltaR( theJet.
p4(), aParticle.
p4() );
399 if( aParticle.
status() == 3 && dist < minDr ) {
413 flavour == 21 )
continue;
414 if( dist < TheBiggerConeSize ) theContaminations.push_back( &aParticle );
421 if ( !foundPriority ) {
424 if(nInTheCone != 1)
return -1;
425 if(theContaminations.empty() )
return tempParticle;
426 int initialPartonFlavour =
abs( (wv.
particles->at(tempParticle).get()) ->
pdgId() );
428 vector<const Candidate *>::const_iterator itCont = theContaminations.begin();
429 for( ; itCont != theContaminations.end(); itCont++ ) {
430 int contaminatingFlavour =
abs( (*itCont)->pdgId() );
431 if( (*itCont)->numberOfMothers()>0 && (*itCont)->mother(0) == wv.
particles->at(tempParticle).get() )
continue;
432 if( initialPartonFlavour == 4 ) {
433 if( contaminatingFlavour == 4 )
continue;
T getParameter(std::string const &) const
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
int pdgId() const final
PDG identifier.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
int fillAlgoritDefinition(const Jet &, WorkingVariables &) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
double pt() const final
transverse momentum
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
edm::RefToBaseProd< reco::Jet > JetRefBaseProd
edm::EDGetTokenT< GenParticleRefVector > m_ParticleSrcToken
#define DEFINE_FWK_MODULE(type)
Abs< T >::type abs(const T &t)
const LorentzVector & p4() const final
four-momentum Lorentz vector
JetPartonMatcher(const edm::ParameterSet &)
vector< int > priorityList
size_t numberOfDaughters() const override
number of daughters
~JetPartonMatcher() override
double coneSizeToAssociate
int status() const final
status word
int fillPhysicsDefinition(const Jet &, WorkingVariables &) const
edm::EDGetTokenT< edm::View< reco::Jet > > m_jetsSrcToken
double phi() const final
momentum azimuthal angle
Handle< GenParticleRefVector > particles