36 #include <ext/algorithm>
83 std::vector<int> &genBarcodes,
84 bool &barcodesAreSorted )
const ;
99 GenPlusSimParticleProducer::GenPlusSimParticleProducer(
const ParameterSet& cfg) :
103 setStatus_(cfg.getParameter<int32_t>(
"setStatus")),
105 genBarcodesToken_(consumes<std::vector<int> >(cfg.getParameter<
InputTag>(
"genParticles")))
108 if (cfg.
exists(
"particleTypes")) {
113 if (cfg.
existsAs<
string>(
"filter")) {
115 if (!filter.empty()) {
119 produces<GenParticleCollection>();
120 produces<vector<int> >();
130 std::vector<int> &genBarcodes,
131 bool &barcodesAreSorted)
const
147 genp.addMother(parentRef);
148 mergedGens.push_back(
genp);
150 unsigned int dauidx = mergedGens.size()-1;
158 for (SimTrackContainer::const_iterator isimtrk = simtracksSorted.begin();
159 isimtrk != simtracksSorted.end(); ++isimtrk) {
160 if (!isimtrk->noVertex()) {
162 const SimVertex &vtx = simvertices[isimtrk->vertIndex()];
169 SimTrackContainer::const_iterator it = std::lower_bound(simtracksSorted.begin(), simtracksSorted.end(),
idx,
LessById());
170 if ((it != simtracksSorted.end()) && (it->trackId() ==
idx)) {
171 if (it->trackId()==stDau.
trackId()) {
173 addGenParticle(stDau, *isimtrk, dauidx, simtracksSorted, simvertices, mergedGens, ref, genBarcodes, barcodesAreSorted);
184 if (!
pdts_.empty()) {
186 for (vector<PdtEntry>::iterator itp =
pdts_.begin(), edp =
pdts_.end(); itp != edp; ++itp) {
200 std::auto_ptr<SimTrackContainer> simtracksTmp;
202 if (!__gnu_cxx::is_sorted(simtracks->begin(), simtracks->end(),
LessById())) {
205 simtracksSorted = &* simtracksTmp;
215 bool barcodesAreSorted =
true;
218 if (gens->size() != genBarcodes->size())
throw cms::Exception(
"Corrupt data") <<
"Barcodes not of the same size as GenParticles!\n";
227 for(
size_t i = 0;
i < gens->size(); ++
i ) {
229 cands.push_back(cand);
233 auto_ptr<vector<int> > newGenBarcodes(
new vector<int>() );
234 for (
unsigned int i = 0;
i < genBarcodes->size(); ++
i) {
235 newGenBarcodes->push_back((*genBarcodes)[
i]);
237 barcodesAreSorted = __gnu_cxx::is_sorted(newGenBarcodes->begin(), newGenBarcodes->end());
239 for(
size_t i = 0;
i < cands.size(); ++
i ) {
244 for (
size_t d = 0; d < nDaus; ++d) {
251 for (
size_t m = 0;
m < nMoms; ++
m) {
256 for (SimTrackContainer::const_iterator isimtrk = simtracks->begin();
257 isimtrk != simtracks->end(); ++isimtrk) {
260 if (isimtrk->genpartIndex() != -1)
continue;
269 if (!isimtrk->noVertex()) {
272 const SimVertex &vtx = (*simvertices)[isimtrk->vertIndex()];
279 SimTrackContainer::const_iterator it = std::lower_bound(simtracksSorted->begin(), simtracksSorted->end(),
idx,
LessById());
280 if ((it != simtracksSorted->end()) && (it->trackId() ==
idx)) {
281 if (it->genpartIndex() != -1) {
282 std::vector<int>::const_iterator itIndex;
283 if (barcodesAreSorted) {
284 itIndex = std::lower_bound(genBarcodes->begin(), genBarcodes->end(), it->genpartIndex());
286 itIndex =
std::find( genBarcodes->begin(), genBarcodes->end(), it->genpartIndex());
291 if ((itIndex != genBarcodes->end()) && (*itIndex == it->genpartIndex())) {
294 unsigned int momidx = itIndex - genBarcodes->begin();
295 addGenParticle(*it, *isimtrk, momidx, *simtracksSorted, *simvertices, *candsPtr, ref, *newGenBarcodes, barcodesAreSorted);
304 event.put(newGenBarcodes);
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
T getParameter(std::string const &) const
bool operator()(const SimTrack &tk1, const SimTrack &tk2) const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
std::auto_ptr< StrFilter > filter_
edm::EDGetTokenT< edm::SimVertexContainer > simverticesToken_
#define DEFINE_FWK_MODULE(type)
std::vector< PdtEntry > pdts_
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
edm::EDGetTokenT< std::vector< int > > genBarcodesToken_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
const daughters & daughterRefVector() const
references to daughtes
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
float charge() const
charge
void addDaughter(const typename daughters::value_type &)
add a daughter via a reference
void resetDaughters(const edm::ProductID &id)
set daughters product ID
StringCutObjectSelector< reco::GenParticle > StrFilter
virtual void endJob() override
const mothers & motherRefVector() const
references to mothers
virtual size_t numberOfMothers() const
number of mothers
virtual size_t numberOfDaughters() const
number of daughters
Abs< T >::type abs(const T &t)
bool operator()(unsigned int id, const SimTrack &tk2) const
GenPlusSimParticleProducer(const edm::ParameterSet &)
Produces reco::GenParticle from SimTracks.
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
tuple genp
produce generated paricles in acceptance #
void addMother(const typename mothers::value_type &)
add a daughter via a reference
~GenPlusSimParticleProducer()
int vertIndex() const
index of the vertex in the Event container (-1 if no vertex)
bool operator()(const SimTrack &tk1, unsigned int id) const
unsigned int trackId() const
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
edm::EDGetTokenT< reco::GenParticleCollection > gensToken_
Collection of GenParticles I need to make refs to. It must also have its associated vector<int> of ba...
std::vector< SimVertex > SimVertexContainer
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual void produce(edm::Event &, const edm::EventSetup &) override
int type() const
particle type (HEP PDT convension)
const math::XYZTLorentzVectorD & momentum() const
particle info...
ProductID id() const
Accessor for product ID.
void addGenParticle(const SimTrack &stMom, const SimTrack &stDau, unsigned int momidx, const edm::SimTrackContainer &simtks, const edm::SimVertexContainer &simvtxs, reco::GenParticleCollection &mergedGens, const reco::GenParticleRefProd ref, std::vector< int > &genBarcodes, bool &barcodesAreSorted) const
Try to link the GEANT particle to the generator particle it came from.
math::XYZPoint Point
point in the space
void resetMothers(const edm::ProductID &id)
set mother product ID
std::vector< SimTrack > SimTrackContainer
edm::EDGetTokenT< edm::SimTrackContainer > simtracksToken_