36 #include <ext/algorithm>
81 std::vector<int> &genBarcodes,
82 bool &barcodesAreSorted )
const ;
97 GenPlusSimParticleProducer::GenPlusSimParticleProducer(
const ParameterSet& cfg) :
99 src_(cfg.getParameter<
InputTag>(
"src")),
100 setStatus_(cfg.getParameter<int32_t>(
"setStatus")),
101 genParticles_(cfg.getParameter<
InputTag>(
"genParticles"))
104 if (cfg.
exists(
"particleTypes")) {
109 if (cfg.
existsAs<
string>(
"filter")) {
111 if (!filter.empty()) {
115 produces<GenParticleCollection>();
116 produces<vector<int> >();
126 std::vector<int> &genBarcodes,
127 bool &barcodesAreSorted)
const
143 genp.addMother(parentRef);
144 mergedGens.push_back(
genp);
146 unsigned int dauidx = mergedGens.size()-1;
154 for (SimTrackContainer::const_iterator isimtrk = simtracksSorted.begin();
155 isimtrk != simtracksSorted.end(); ++isimtrk) {
156 if (!isimtrk->noVertex()) {
158 const SimVertex &vtx = simvertices[isimtrk->vertIndex()];
165 SimTrackContainer::const_iterator it = std::lower_bound(simtracksSorted.begin(), simtracksSorted.end(), idx,
LessById());
166 if ((it != simtracksSorted.end()) && (it->trackId() == idx)) {
167 if (it->trackId()==stDau.
trackId()) {
169 addGenParticle(stDau, *isimtrk, dauidx, simtracksSorted, simvertices, mergedGens, ref, genBarcodes, barcodesAreSorted);
180 if (!
pdts_.empty()) {
182 for (vector<PdtEntry>::iterator itp =
pdts_.begin(), edp =
pdts_.end(); itp != edp; ++itp) {
193 event.getByLabel(
src_, simtracks);
196 std::auto_ptr<SimTrackContainer> simtracksTmp;
198 if (!__gnu_cxx::is_sorted(simtracks->begin(), simtracks->end(),
LessById())) {
201 simtracksSorted = &* simtracksTmp;
206 event.getByLabel(
src_, simvertices);
211 bool barcodesAreSorted =
true;
214 if (gens->size() != genBarcodes->size())
throw cms::Exception(
"Corrupt data") <<
"Barcodes not of the same size as GenParticles!\n";
223 for(
size_t i = 0;
i < gens->size(); ++
i ) {
225 cands.push_back(cand);
229 auto_ptr<vector<int> > newGenBarcodes(
new vector<int>() );
230 for (
unsigned int i = 0;
i < genBarcodes->size(); ++
i) {
231 newGenBarcodes->push_back((*genBarcodes)[
i]);
233 barcodesAreSorted = __gnu_cxx::is_sorted(newGenBarcodes->begin(), newGenBarcodes->end());
235 for(
size_t i = 0;
i < cands.size(); ++
i ) {
240 for (
size_t d = 0; d < nDaus; ++d) {
247 for (
size_t m = 0;
m < nMoms; ++
m) {
252 for (SimTrackContainer::const_iterator isimtrk = simtracks->begin();
253 isimtrk != simtracks->end(); ++isimtrk) {
256 if (isimtrk->genpartIndex() != -1)
continue;
265 if (!isimtrk->noVertex()) {
268 const SimVertex &vtx = (*simvertices)[isimtrk->vertIndex()];
275 SimTrackContainer::const_iterator it = std::lower_bound(simtracksSorted->begin(), simtracksSorted->end(), idx,
LessById());
276 if ((it != simtracksSorted->end()) && (it->trackId() == idx)) {
277 if (it->genpartIndex() != -1) {
278 std::vector<int>::const_iterator itIndex;
279 if (barcodesAreSorted) {
280 itIndex = std::lower_bound(genBarcodes->begin(), genBarcodes->end(), it->genpartIndex());
282 itIndex =
std::find( genBarcodes->begin(), genBarcodes->end(), it->genpartIndex());
287 if ((itIndex != genBarcodes->end()) && (*itIndex == it->genpartIndex())) {
290 unsigned int momidx = itIndex - genBarcodes->begin();
291 addGenParticle(*it, *isimtrk, momidx, *simtracksSorted, *simvertices, *candsPtr, ref, *newGenBarcodes, barcodesAreSorted);
300 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_
#define DEFINE_FWK_MODULE(type)
std::vector< PdtEntry > pdts_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
const daughters & daughterRefVector() const
references to daughtes
edm::Ref< edm::HepMCProduct, HepMC::GenParticle > GenParticleRef
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
float charge() const
charge
virtual void produce(edm::Event &, const edm::EventSetup &)
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
const mothers & motherRefVector() const
references to mothers
virtual size_t numberOfMothers() const
number of mothers
virtual size_t numberOfDaughters() const
number of daughters
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()
edm::InputTag genParticles_
Collection of GenParticles I need to make refs to. It must also have its associated vector<int> of ba...
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 filter
USE THIS FOR SKIMMED TRACKS process.p = cms.Path(process.hltLevel1GTSeed*process.skimming*process.offlineBeamSpot*process.TrackRefitter2) OTHERWISE USE THIS.
std::vector< SimVertex > SimVertexContainer
math::XYZTLorentzVector LorentzVector
Lorentz vector.
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