39 src_( p.getParameter<
InputTag>(
"src" ) ),
40 matchedSrc_( p.getParameter<
InputTag>(
"matchedSrc") ),
41 matchDR_ ( p.getParameter<double> (
"matchDR") ),
42 pdgIdToSelect_( p.getParameter<int> (
"pdgIdToSelect") ),
43 ptMinParticle_( p.getParameter<double>(
"ptMinParticle") ),
44 ptMinShower_( p.getParameter<double>(
"ptMinShower") ),
45 etaMaxParticle_( p.getParameter<double>(
"etaMaxParticle" )),
46 etaMaxShower_( p.getParameter<double>(
"etaMaxShower" )),
47 flavorHistoryName_( p.getParameter<string>(
"flavorHistoryName") ),
48 verbose_( p.getUntrackedParameter<bool>(
"verbose" ) )
58 if (
verbose_ )
cout <<
"---------- Hello from FlavorHistoryProducer! -----" << endl;
68 vector<const Candidate* > particles;
70 particles.push_back(&*
p);
74 vector<int> partonIndices;
76 vector<int> progenitorIndices;
78 vector<int> sisterIndices;
80 vector<FlavorHistory::FLAVOR_T> flavorSources;
90 for( j=0; j<j_max; ++
j ) {
97 bool foundProgenitor =
false;
102 int nDa = (
p)->numberOfDaughters();
106 if ( idabs <= FlavorHistory::tQuarkId && p->
status() == 2 &&
113 if(
verbose_)
cout <<
"--------------------------" << endl;
114 if(
verbose_)
cout <<
"Processing particle " << j <<
", status = " << p->
status() <<
", pdg id = " << p->
pdgId() << endl;
118 vector<Candidate const *> allParents;
122 cout <<
"Parents : " << endl;
123 vector<Candidate const *>::const_iterator iprint = allParents.begin(),
124 iprintend = allParents.end();
125 for ( ; iprint != iprintend; ++iprint )
126 cout <<
" status = " << (*iprint)->status() <<
", pdg id = " << (*iprint)->pdgId() <<
", pt = " << (*iprint)->pt() << endl;
131 bool status3AncestorOfSameFlavor =
false;
160 vector<Candidate const *>::const_iterator
found =
find(particles.begin(),particles.end(),aParent);
164 progenitorIndex = found - particles.begin();
169 if ( aParent->
status() == 3 && aParent->
pdgId() == p->
pdgId() ) status3AncestorOfSameFlavor =
true;
174 if( progenitorIndex > 5 ) {
186 if(
verbose_)
cout <<
"Matrix Element progenitor" << endl;
187 if ( flavorSource == FlavorHistory::FLAVOR_NULL ) flavorSource = FlavorHistory::FLAVOR_ME;
188 foundProgenitor =
true;
191 else if( (aParentId>
pdgIdToSelect_ && aParentId<FlavorHistory::gluonId) ||
192 aParentId > FlavorHistory::gluonId ) {
194 if ( flavorSource == FlavorHistory::FLAVOR_NULL ) flavorSource = FlavorHistory::FLAVOR_DECAY;
195 foundProgenitor =
true;
202 if ( !foundProgenitor ) {
203 if ( flavorSource == FlavorHistory::FLAVOR_NULL ) flavorSource = FlavorHistory::FLAVOR_GS;
207 vector<Candidate const *>::const_iterator
found =
find(particles.begin(),particles.end(),aParent);
209 progenitorIndex = found - particles.begin();
212 foundProgenitor =
true;
223 if ( !foundProgenitor ) progenitorIndex = j_max;
227 partonIndices.push_back( partonIndex );
228 progenitorIndices.push_back( progenitorIndex );
229 flavorSources.push_back(flavorSource);
230 sisterIndices.push_back( -1 );
241 if ( partonIndices.size() == progenitorIndices.size() && partonIndices.size() > 0 ) {
243 for (
unsigned int ii = 0; ii < partonIndices.size(); ++ii ) {
245 const Candidate * candi = particles[partonIndices[ii]];
246 if (
verbose_ )
cout <<
" Sister candidate particle 1: " << ii <<
", pdgid = " << candi->
pdgId() <<
", status = " << candi->
status() << endl;
250 for (
unsigned int jj = 0; jj < partonIndices.size(); ++jj ) {
252 const Candidate * candj = particles[partonIndices[jj]];
253 if (
verbose_ )
cout <<
" Sister candidate particle 2: " << jj <<
", pdgid = " << candj->
pdgId() <<
", status = " << candj->
status() << endl;
257 sisterIndices[ii] = partonIndices[jj];
258 if (
verbose_ )
cout <<
"Parton " << partonIndices[ii] <<
" has sister " << sisterIndices[ii] << endl;
264 if ( sisterIndices[ii] < 0 ) {
265 if (
verbose_ )
cout <<
"No sister. Classified as flavor excitation" << endl;
266 flavorSources[ii] = FlavorHistory::FLAVOR_EXC;
279 ( sisterIndices[ii] >= 0 &&
static_cast<unsigned int>(sisterIndices[ii]) < particles.size() ) ?
280 getClosestJet( matchedView, *particles[sisterIndices[ii]] ) :
283 if (
verbose_ )
cout <<
"Making matched shallow clones : ";
285 if ( matched != matchedEnd ) {
292 if (
verbose_ )
cout <<
"Making sister shallow clones : ";
294 if ( sister != matchedEnd ) {
301 if (
verbose_ )
cout <<
"Making history object" << endl;
305 partonIndices[ii], progenitorIndices[ii], sisterIndices[ii],
308 if (
verbose_ )
cout <<
"Adding flavor history : " << history << endl;
309 flavorHistoryEvent->push_back( history );
314 if ( flavorHistoryEvent->size() > 0 ) {
317 if (
verbose_ )
cout <<
"Caching flavor history event" << endl;
318 flavorHistoryEvent->cache();
321 cout <<
"Outputting pdg id = " <<
pdgIdToSelect_ <<
" with nelements = " << flavorHistoryEvent->size() << endl;
322 vector<FlavorHistory>::const_iterator
i = flavorHistoryEvent->begin(),
323 iend = flavorHistoryEvent->end();
324 for ( ; i !=iend; ++
i ) {
337 vector<Candidate const *> & moms )
344 moms.push_back( dau );
360 for ( ; j != jend; ++
j ) {
361 double dri =
deltaR( parton.
p4(), j->p4() );
FlavorHistoryProducer(const edm::ParameterSet &)
constructor
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
#define DEFINE_FWK_MODULE(type)
virtual int status() const =0
status word
edm::InputTag matchedSrc_
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
std::string flavorHistoryName_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
reco::CandidateView::const_iterator getClosestJet(edm::Handle< reco::CandidateView > const &pJets, reco::Candidate const &parton) const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double deltaR(double eta1, double eta2, double phi1, double phi2)
virtual int pdgId() const =0
PDG identifier.
~FlavorHistoryProducer()
destructor
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
void produce(edm::Event &e, const edm::EventSetup &)
process one event
void getAncestors(const reco::Candidate &c, std::vector< reco::Candidate const * > &moms)
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector