105 using namespace reco;
111 matchDR_(
p.getParameter<double>(
"matchDR")),
112 pdgIdToSelect_(
p.getParameter<
int>(
"pdgIdToSelect")),
113 ptMinParticle_(
p.getParameter<double>(
"ptMinParticle")),
114 ptMinShower_(
p.getParameter<double>(
"ptMinShower")),
115 etaMaxParticle_(
p.getParameter<double>(
"etaMaxParticle")),
116 etaMaxShower_(
p.getParameter<double>(
"etaMaxShower")),
117 flavorHistoryName_(
p.getParameter<
string>(
"flavorHistoryName")),
118 verbose_(
p.getUntrackedParameter<
bool>(
"verbose")) {
124 cout <<
"---------- Hello from FlavorHistoryProducer! -----" << endl;
140 vector<int> partonIndices;
142 vector<int> progenitorIndices;
144 vector<int> sisterIndices;
146 vector<FlavorHistory::FLAVOR_T> flavorSources;
149 auto flavorHistoryEvent = std::make_unique<FlavorHistoryEvent>();
156 for (
j = 0;
j < j_max; ++
j) {
162 bool foundProgenitor =
false;
166 int nDa = (
p)->numberOfDaughters();
176 cout <<
"--------------------------" << endl;
178 cout <<
"Processing particle " <<
j <<
", status = " <<
p->status() <<
", pdg id = " <<
p->pdgId() << endl;
181 vector<Candidate const *> allParents;
185 cout <<
"Parents : " << endl;
186 vector<Candidate const *>::const_iterator iprint = allParents.begin(), iprintend = allParents.end();
187 for (; iprint != iprintend; ++iprint)
188 cout <<
" status = " << (*iprint)->status() <<
", pdg id = " << (*iprint)->pdgId()
189 <<
", pt = " << (*iprint)->pt() << endl;
229 if (progenitorIndex > 5) {
241 cout <<
"Matrix Element progenitor" << endl;
242 if (flavorSource == FlavorHistory::FLAVOR_NULL)
243 flavorSource = FlavorHistory::FLAVOR_ME;
244 foundProgenitor =
true;
247 else if ((aParentId >
pdgIdToSelect_ && aParentId < FlavorHistory::gluonId) ||
248 aParentId > FlavorHistory::gluonId) {
250 cout <<
"Flavor decay progenitor" << endl;
251 if (flavorSource == FlavorHistory::FLAVOR_NULL)
252 flavorSource = FlavorHistory::FLAVOR_DECAY;
253 foundProgenitor =
true;
260 if (!foundProgenitor) {
261 if (flavorSource == FlavorHistory::FLAVOR_NULL)
262 flavorSource = FlavorHistory::FLAVOR_GS;
271 foundProgenitor =
true;
280 if (!foundProgenitor)
281 progenitorIndex = j_max;
285 partonIndices.push_back(partonIndex);
286 progenitorIndices.push_back(progenitorIndex);
287 flavorSources.push_back(flavorSource);
288 sisterIndices.push_back(-1);
298 cout <<
"Making sisters" << endl;
300 if (partonIndices.size() == progenitorIndices.size() && !partonIndices.empty()) {
302 for (
unsigned int ii = 0;
ii < partonIndices.size(); ++
ii) {
306 cout <<
" Sister candidate particle 1: " <<
ii <<
", pdgid = " << candi->
pdgId()
307 <<
", status = " << candi->
status() << endl;
311 for (
unsigned int jj = 0;
jj < partonIndices.size(); ++
jj) {
315 cout <<
" Sister candidate particle 2: " <<
jj <<
", pdgid = " << candj->
pdgId()
316 <<
", status = " << candj->
status() << endl;
320 sisterIndices[
ii] = partonIndices[
jj];
322 cout <<
"Parton " << partonIndices[
ii] <<
" has sister " << sisterIndices[
ii] << endl;
328 if (sisterIndices[
ii] < 0) {
330 cout <<
"No sister. Classified as flavor excitation" << endl;
331 flavorSources[
ii] = FlavorHistory::FLAVOR_EXC;
335 cout <<
"Getting matched jet" << endl;
342 cout <<
"Getting sister jet" << endl;
345 (sisterIndices[
ii] >= 0 &&
static_cast<unsigned int>(sisterIndices[
ii]) <
particles.size())
350 cout <<
"Making matched shallow clones : ";
354 cout <<
" found" << endl;
358 cout <<
" NOT found" << endl;
362 cout <<
"Making sister shallow clones : ";
364 if (sister != matchedEnd) {
366 cout <<
" found" << endl;
370 cout <<
" NOT found" << endl;
374 cout <<
"Making history object" << endl;
379 progenitorIndices[
ii],
384 cout <<
"Adding flavor history : " << history << endl;
385 flavorHistoryEvent->push_back(history);
390 if (flavorHistoryEvent->size() > 0) {
393 cout <<
"Caching flavor history event" << endl;
394 flavorHistoryEvent->cache();
397 cout <<
"Outputting pdg id = " <<
pdgIdToSelect_ <<
" with nelements = " << flavorHistoryEvent->size() << endl;
398 vector<FlavorHistory>::const_iterator
i = flavorHistoryEvent->begin(), iend = flavorHistoryEvent->end();
399 for (;
i != iend; ++
i) {
411 if (
c.numberOfMothers() == 1) {
427 for (;
j != jend; ++
j) {
428 double dri =
deltaR(parton.
p4(),
j->p4());
FlavorHistoryProducer(const edm::ParameterSet &)
constructor
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
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
void produce(edm::StreamID, edm::Event &e, const edm::EventSetup &) const override
process one event
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
const double ptMinShower_
void getAncestors(const reco::Candidate &c, std::vector< reco::Candidate const *> &moms) const
const double etaMaxShower_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const double etaMaxParticle_
const edm::EDGetTokenT< reco::CandidateView > srcToken_
const edm::EDGetTokenT< reco::CandidateView > matchedSrcToken_
reco::CandidateView::const_iterator getClosestJet(edm::Handle< reco::CandidateView > const &pJets, reco::Candidate const &parton) const
Abs< T >::type abs(const T &t)
virtual int pdgId() const =0
PDG identifier.
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
const double ptMinParticle_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
const std::string flavorHistoryName_
const_iterator begin() const
const_iterator end() const
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector