10 addRadiation_(cfg.getParameter<bool>(
"addRadiation")),
18 else if(mode==
"kStable")
21 throw cms::Exception(
"Configuration") << mode <<
" is not a supported FillMode!\n";
26 produces<reco::GenParticleCollection>();
46 std::vector<const reco::GenParticle*> tops =
findTops(*src);
71 std::vector<const reco::GenParticle*>
74 std::vector<const reco::GenParticle*> tops;
75 for(reco::GenParticleCollection::const_iterator
t=parts.begin();
t!=parts.end(); ++
t){
77 tops.push_back( &(*
t) );
86 for(std::vector<const reco::GenParticle*>::const_iterator it=tops.begin(); it!=tops.end(); ++it){
99 bool containsWBoson=
false, containsQuarkDaughter=
false;
104 if(containsQuarkDaughter && containsWBoson)
111 <<
" Failed to find top quarks in decay chain. Will assume that this a \n"
112 <<
" non-top sample and produce an empty decaySubset.\n";
115 " Can not find back any of the supported hadronization models. Models \n"
116 " which are supported are: \n"
117 " Pythia LO(+PS): Top(status 3) --> WBoson(status 3), Quark(status 3)\n"
118 " Herwig NLO(+PS): Top(status 2) --> Top(status 3) --> Top(status 2) \n");
126 unsigned nTops = tops.size();
127 for(std::vector<const reco::GenParticle*>::iterator it=tops.begin(); it!=tops.end();) {
130 bool expectedStatus=
false;
133 "showerModel_!=kPythia && top->begin()==top->end()\n");
145 if(!expectedStatus) {
149 <<
" W boson does not have the expected status. This happens, e.g., \n"
150 <<
" with MC@NLO in the case of additional ttbar pairs from radiated \n"
151 <<
" gluons. We hope everything is fine, remove the correspdonding top \n"
152 <<
" quark from our list since it is not part of the primary ttbar pair \n"
153 <<
" and try to continue. \n";
158 if(tops.size()==0 && nTops!=0)
160 " Did not find a W boson with appropriate status for any of the top \n"
161 " quarks in this event. This means that the hadronization of the W \n"
162 " boson might be screwed up or there is another problem with the \n"
163 " particle listing in this MC sample. Please contact an expert. \n");
170 unsigned int statusFlag;
175 for(std::vector<const reco::GenParticle*>::const_iterator it=tops.begin(); it!=tops.end(); ++it){
179 target.push_back( *topPtr );
183 std::vector<int> topDaughters;
187 std::vector<int> wDaughters;
191 "showerModel_!=kPythia && t->begin()==t->end()\n");
197 target.push_back( *bPtr );
207 "showerModel_!=kPythia && td->begin()==td->end()\n");
212 target.push_back( *wPtr );
222 "showerModel_!=kPythia && buffer->begin()==buffer->end()\n");
227 std::auto_ptr<reco::GenParticle> qPtr(
new reco::GenParticle( wd->threeCharge(),
p4( wd, statusFlag ), wd->vertex(), wd->pdgId(), statusFlag,
false) );
228 target.push_back( *qPtr );
246 target.push_back( *radPtr );
261 std::auto_ptr<reco::GenParticle> sPtr( cand );
262 target.push_back( *sPtr );
263 if(ts->begin()!=ts->end()){
273 refs_[ iTop ] = topDaughters;
274 refs_[ iW ] = wDaughters;
294 vec+=
p4(
p, statusFlag );
307 if( vec.mass()-(*top)->mass()>0 ){
344 vec+=
p4(
p, statusFlag);
356 std::vector<int> daughters;
363 std::auto_ptr<reco::GenParticle> ptr(
new reco::GenParticle( daughter->threeCharge(), daughter->p4(), daughter->vertex(), daughter->pdgId(), daughter->status(),
false) );
364 target.push_back( *ptr );
365 daughters.push_back( ++idx );
368 if(daughters.size()) {
369 refs_[ idxBuffer ] = daughters;
377 std::vector<int> daughters;
380 std::auto_ptr<reco::GenParticle> ptr(
new reco::GenParticle( daughter->threeCharge(), daughter->p4(), daughter->vertex(), daughter->pdgId(), daughter->status(),
false) );
381 target.push_back( *ptr );
383 daughters.push_back( ++idx );
389 if(daughters.size()) {
390 refs_[ idxBuffer ] = daughters;
410 for(reco::GenParticleCollection::iterator
p=sel.begin();
p!=sel.end(); ++
p, ++
idx){
412 std::map<int, std::vector<int> >::const_iterator daughters=
refs_.find( idx );
413 if( daughters!=
refs_.end() ){
414 for(std::vector<int>::const_iterator daughter = daughters->second.begin();
415 daughter!=daughters->second.end(); ++daughter){
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
T getParameter(std::string const &) const
virtual int pdgId() const
PDG identifier.
static bool isContained(const std::vector< unsigned int > &list, int id)
void addDaughters(int &idx, const reco::GenParticle::const_iterator part, reco::GenParticleCollection &target, bool recursive=true)
recursively fill vector for all further decay particles of a given particle
ShowerModel checkShowerModel(const std::vector< const reco::GenParticle * > &tops) const
check the decay chain for the used shower model
ShowerModel showerModel_
parton shower mode (filled in checkShowerModel)
virtual void produce(edm::Event &event, const edm::EventSetup &setup)
write output into the event
virtual const Point & vertex() const
vertex position (overwritten by PF...)
void addRadiation(int &idx, const reco::GenParticle::const_iterator part, reco::GenParticleCollection &target)
fill vector including all radiations from quarks originating from W/top
virtual int threeCharge() const =0
electric charge
virtual int status() const =0
status word
std::vector< const reco::GenParticle * > findTops(const reco::GenParticleCollection &parts)
find top quarks in list of input particles
void addDaughter(const typename daughters::value_type &)
add a daughter via a reference
void clearReferences()
clear references
virtual size_type numberOfDaughters() const =0
number of daughters
virtual const_iterator end() const =0
last daughter const_iterator
virtual const_iterator begin() const
first daughter const_iterator
virtual size_t numberOfMothers() const
number of mothers
virtual size_t numberOfDaughters() const
number of daughters
reco::Particle::LorentzVector p4(const std::vector< const reco::GenParticle * >::const_iterator top, int statusFlag)
calculate lorentz vector from input (dedicated to top reconstruction)
void checkWBosons(std::vector< const reco::GenParticle * > &tops) const
check whether W bosons are contained in the original gen particle listing
Abs< T >::type abs(const T &t)
bool addRadiation_
add radiation or not?
ShowerModel
classification of potential shower types
virtual const Point & vertex() const =0
vertex position
virtual int threeCharge() const
electric charge
edm::EDGetTokenT< reco::GenParticleCollection > srcToken_
input tag for the genParticle source
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void fillReferences(const reco::GenParticleRefProd &refProd, reco::GenParticleCollection &target)
fill references for output vector
virtual int pdgId() const =0
PDG identifier.
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
TopDecaySubset(const edm::ParameterSet &cfg)
default constructor
std::map< int, std::vector< int > > refs_
management of daughter indices for fillRefs
void fillListing(const std::vector< const reco::GenParticle * > &tops, reco::GenParticleCollection &target)
fill output vector for full decay chain
virtual const_iterator begin() const =0
first daughter const_iterator
volatile std::atomic< bool > shutdown_flag false
~TopDecaySubset()
default destructor
virtual const_iterator end() const
last daughter const_iterator
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual const Candidate * mother(size_type=0) const
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector