40 matchDR_(
p.getParameter<double>(
"matchDR")),
41 pdgIdToSelect_(
p.getParameter<
int>(
"pdgIdToSelect")),
42 ptMinParticle_(
p.getParameter<double>(
"ptMinParticle")),
43 ptMinShower_(
p.getParameter<double>(
"ptMinShower")),
44 etaMaxParticle_(
p.getParameter<double>(
"etaMaxParticle")),
45 etaMaxShower_(
p.getParameter<double>(
"etaMaxShower")),
46 flavorHistoryName_(
p.getParameter<
string>(
"flavorHistoryName")),
47 verbose_(
p.getUntrackedParameter<
bool>(
"verbose")) {
55 cout <<
"---------- Hello from FlavorHistoryProducer! -----" << endl;
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;
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;
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) {
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) {
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 : ";
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) {
342 if (
c.numberOfMothers() == 1) {
358 for (;
j != jend; ++
j) {
359 double dri =
deltaR(parton.
p4(),
j->p4());