55 cout <<
"---------- Hello from FlavorHistoryProducer! -----" << endl;
59 evt.getByToken(
srcToken_, particlesViewH);
67 particles.push_back(&*
p);
71 vector<int> partonIndices;
73 vector<int> progenitorIndices;
75 vector<int> sisterIndices;
77 vector<FlavorHistory::FLAVOR_T> flavorSources;
80 auto flavorHistoryEvent = std::make_unique<FlavorHistoryEvent>();
87 for (j = 0; j < j_max; ++
j) {
93 bool foundProgenitor =
false;
97 int nDa = (
p)->numberOfDaughters();
107 cout <<
"--------------------------" << endl;
109 cout <<
"Processing particle " << j <<
", status = " << p->
status() <<
", pdg id = " << p->
pdgId() << endl;
112 vector<Candidate const *> allParents;
116 cout <<
"Parents : " << endl;
117 vector<Candidate const *>::const_iterator iprint = allParents.begin(), iprintend = allParents.end();
118 for (; iprint != iprintend; ++iprint)
119 cout <<
" status = " << (*iprint)->status() <<
", pdg id = " << (*iprint)->pdgId()
120 <<
", pt = " << (*iprint)->pt() << endl;
150 vector<Candidate const *>::const_iterator
found =
find(particles.begin(), particles.end(), aParent);
153 progenitorIndex = found - particles.begin();
160 if (progenitorIndex > 5) {
172 cout <<
"Matrix Element progenitor" << endl;
173 if (flavorSource == FlavorHistory::FLAVOR_NULL)
174 flavorSource = FlavorHistory::FLAVOR_ME;
175 foundProgenitor =
true;
178 else if ((aParentId >
pdgIdToSelect_ && aParentId < FlavorHistory::gluonId) ||
179 aParentId > FlavorHistory::gluonId) {
181 cout <<
"Flavor decay progenitor" << endl;
182 if (flavorSource == FlavorHistory::FLAVOR_NULL)
183 flavorSource = FlavorHistory::FLAVOR_DECAY;
184 foundProgenitor =
true;
191 if (!foundProgenitor) {
192 if (flavorSource == FlavorHistory::FLAVOR_NULL)
193 flavorSource = FlavorHistory::FLAVOR_GS;
197 vector<Candidate const *>::const_iterator found =
find(particles.begin(), particles.end(), aParent);
199 progenitorIndex = found - particles.begin();
202 foundProgenitor =
true;
211 if (!foundProgenitor)
212 progenitorIndex = j_max;
216 partonIndices.push_back(partonIndex);
217 progenitorIndices.push_back(progenitorIndex);
218 flavorSources.push_back(flavorSource);
219 sisterIndices.push_back(-1);
229 cout <<
"Making sisters" << endl;
231 if (partonIndices.size() == progenitorIndices.size() && !partonIndices.empty()) {
233 for (
unsigned int ii = 0;
ii < partonIndices.size(); ++
ii) {
235 const Candidate *candi = particles[partonIndices[
ii]];
237 cout <<
" Sister candidate particle 1: " <<
ii <<
", pdgid = " << candi->
pdgId()
238 <<
", status = " << candi->
status() << endl;
242 for (
unsigned int jj = 0;
jj < partonIndices.size(); ++
jj) {
244 const Candidate *candj = particles[partonIndices[
jj]];
246 cout <<
" Sister candidate particle 2: " <<
jj <<
", pdgid = " << candj->
pdgId()
247 <<
", status = " << candj->
status() << endl;
251 sisterIndices[
ii] = partonIndices[
jj];
253 cout <<
"Parton " << partonIndices[
ii] <<
" has sister " << sisterIndices[
ii] << endl;
259 if (sisterIndices[
ii] < 0) {
261 cout <<
"No sister. Classified as flavor excitation" << endl;
262 flavorSources[
ii] = FlavorHistory::FLAVOR_EXC;
266 cout <<
"Getting matched jet" << endl;
273 cout <<
"Getting sister jet" << endl;
276 (sisterIndices[
ii] >= 0 &&
static_cast<unsigned int>(sisterIndices[
ii]) < particles.size())
281 cout <<
"Making matched shallow clones : ";
283 if (matched != matchedEnd) {
285 cout <<
" found" << endl;
289 cout <<
" NOT found" << endl;
293 cout <<
"Making sister shallow clones : ";
295 if (sister != matchedEnd) {
297 cout <<
" found" << endl;
301 cout <<
" NOT found" << endl;
305 cout <<
"Making history object" << endl;
310 progenitorIndices[ii],
315 cout <<
"Adding flavor history : " << history << endl;
316 flavorHistoryEvent->push_back(history);
321 if (flavorHistoryEvent->size() > 0) {
324 cout <<
"Caching flavor history event" << endl;
325 flavorHistoryEvent->cache();
328 cout <<
"Outputting pdg id = " <<
pdgIdToSelect_ <<
" with nelements = " << flavorHistoryEvent->size() << endl;
329 vector<FlavorHistory>::const_iterator
i = flavorHistoryEvent->begin(), iend = flavorHistoryEvent->end();
330 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_