58 if (
verbose_ )
cout <<
"---------- Hello from FlavorHistoryProducer! -----" << endl;
62 evt.getByToken(
srcToken_, particlesViewH );
70 particles.push_back(&*
p);
74 vector<int> partonIndices;
76 vector<int> progenitorIndices;
78 vector<int> sisterIndices;
80 vector<FlavorHistory::FLAVOR_T> flavorSources;
83 auto flavorHistoryEvent = std::make_unique<FlavorHistoryEvent>();
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;
156 vector<Candidate const *>::const_iterator
found =
find(particles.begin(),particles.end(),aParent);
160 progenitorIndex = found - particles.begin();
167 if( progenitorIndex > 5 ) {
179 if(
verbose_)
cout <<
"Matrix Element progenitor" << endl;
180 if ( flavorSource == FlavorHistory::FLAVOR_NULL ) flavorSource = FlavorHistory::FLAVOR_ME;
181 foundProgenitor =
true;
184 else if( (aParentId>
pdgIdToSelect_ && aParentId<FlavorHistory::gluonId) ||
185 aParentId > FlavorHistory::gluonId ) {
187 if ( flavorSource == FlavorHistory::FLAVOR_NULL ) flavorSource = FlavorHistory::FLAVOR_DECAY;
188 foundProgenitor =
true;
195 if ( !foundProgenitor ) {
196 if ( flavorSource == FlavorHistory::FLAVOR_NULL ) flavorSource = FlavorHistory::FLAVOR_GS;
200 vector<Candidate const *>::const_iterator found =
find(particles.begin(),particles.end(),aParent);
202 progenitorIndex = found - particles.begin();
205 foundProgenitor =
true;
216 if ( !foundProgenitor ) progenitorIndex = j_max;
220 partonIndices.push_back( partonIndex );
221 progenitorIndices.push_back( progenitorIndex );
222 flavorSources.push_back(flavorSource);
223 sisterIndices.push_back( -1 );
234 if ( partonIndices.size() == progenitorIndices.size() && !partonIndices.empty() ) {
236 for (
unsigned int ii = 0;
ii < partonIndices.size(); ++
ii ) {
238 const Candidate * candi = particles[partonIndices[
ii]];
239 if (
verbose_ )
cout <<
" Sister candidate particle 1: " <<
ii <<
", pdgid = " << candi->
pdgId() <<
", status = " << candi->
status() << endl;
243 for (
unsigned int jj = 0;
jj < partonIndices.size(); ++
jj ) {
245 const Candidate * candj = particles[partonIndices[
jj]];
246 if (
verbose_ )
cout <<
" Sister candidate particle 2: " <<
jj <<
", pdgid = " << candj->
pdgId() <<
", status = " << candj->
status() << endl;
250 sisterIndices[
ii] = partonIndices[
jj];
251 if (
verbose_ )
cout <<
"Parton " << partonIndices[
ii] <<
" has sister " << sisterIndices[
ii] << endl;
257 if ( sisterIndices[
ii] < 0 ) {
258 if (
verbose_ )
cout <<
"No sister. Classified as flavor excitation" << endl;
259 flavorSources[
ii] = FlavorHistory::FLAVOR_EXC;
272 ( sisterIndices[
ii] >= 0 &&
static_cast<unsigned int>(sisterIndices[
ii]) < particles.size() ) ?
276 if (
verbose_ )
cout <<
"Making matched shallow clones : ";
278 if ( matched != matchedEnd ) {
285 if (
verbose_ )
cout <<
"Making sister shallow clones : ";
287 if ( sister != matchedEnd ) {
294 if (
verbose_ )
cout <<
"Making history object" << endl;
298 partonIndices[ii], progenitorIndices[ii], sisterIndices[ii],
301 if (
verbose_ )
cout <<
"Adding flavor history : " << history << endl;
302 flavorHistoryEvent->push_back( history );
307 if ( flavorHistoryEvent->size() > 0 ) {
310 if (
verbose_ )
cout <<
"Caching flavor history event" << endl;
311 flavorHistoryEvent->cache();
314 cout <<
"Outputting pdg id = " <<
pdgIdToSelect_ <<
" with nelements = " << flavorHistoryEvent->size() << endl;
315 vector<FlavorHistory>::const_iterator
i = flavorHistoryEvent->begin(),
316 iend = flavorHistoryEvent->end();
317 for ( ; i !=iend; ++
i ) {
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
edm::EDGetTokenT< reco::CandidateView > srcToken_
virtual int status() const =0
status word
const_iterator begin() const
virtual int pdgId() const =0
PDG identifier.
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
Abs< T >::type abs(const T &t)
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
void getAncestors(const reco::Candidate &c, std::vector< reco::Candidate const * > &moms)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
const_iterator end() const
edm::EDGetTokenT< reco::CandidateView > matchedSrcToken_