27 pSimHitSelector_(config), pixelPSimHitSelector_(config), trackerPSimHitSelector_(config), muonPSimHitSelector_(config)
41 if ( config.
exists(
"select") )
71 if (!mergedBremsstrahlung_)
73 produces<TrackingVertexCollection>();
74 produces<TrackingParticleCollection>();
78 produces<TrackingVertexCollection>();
79 produces<TrackingParticleCollection>();
80 produces<TrackingVertexCollection>(
"MergedTrackTruth");
81 produces<TrackingParticleCollection>(
"MergedTrackTruth");
112 edm::LogInfo (
MessageCategory_) <<
"If the labels are not in the same order as the events in the crossing frame (i.e. signal, pileup(s) ) ";
179 event.put(mergedTrackingVertexes_,
"MergedTrackTruth");
181 event.put(trackingVertexes_);
187 event.put(trackingVertexes_);
193 std::vector<PSimHit>
const & pSimHits,
201 for (std::size_t
i = 0;
i < pSimHits.size(); ++
i)
203 EncodedTruthIdToIndexes::key_type objectId = EncodedTruthIdToIndexes::key_type(pSimHits[
i].eventId(), pSimHits[
i].trackId());
204 association.insert( std::make_pair(objectId,
i) );
221 association.insert( std::make_pair(objectId, index) );
234 bool useVertexId =
true;
237 unsigned int oldVertexId = 0;
242 if (!index || iterator->eventId() != oldEventId)
244 oldEventId = iterator->eventId();
245 oldVertexId = iterator->vertexId();
249 if ( iterator->vertexId() == oldVertexId )
268 objectId =
EncodedTruthId(iterator->eventId(), iterator->vertexId());
270 objectId =
EncodedTruthId(iterator->eventId(), vertexId[iterator->eventId()]++);
271 association.insert( std::make_pair(objectId, index) );
278 unsigned int index = 0;
280 std::set<unsigned int> excludedTV, excludedTP;
306 daughterRef = *idaughter;
308 else if ( pointer->
pdgId() == 22 )
328 for (std::vector<PSimHit>::const_iterator ihit = daughter->
pSimHit_begin(); ihit != daughter->
pSimHit_end(); ++ihit)
354 if (*isource != daughterRef)
361 excludedTV.insert(index);
364 excludedTP.insert( daughterRef.
key() );
375 std::map<unsigned int, unsigned int> vertexMap;
380 if ( excludedTV.find(index) != excludedTV.end() )
continue;
395 if ( excludedTP.find(index) != excludedTP.end() )
continue;
407 unsigned int parentIndex = vertexMap[sourceV.
key()];
419 unsigned int daughterIndex = vertexMap[iDecayV->key()];
433 std::auto_ptr<TrackingParticleCollection> & tPC
459 else if ( tPC->at(it->key()).
pdgId() == 22 )
466 if (nElectrons == 1 && nPhotons >= 0 && nOthers == 0)
479 std::map<int,std::size_t> vetoedTracks;
482 std::map<int,std::size_t> vetoedSimVertexes;
484 for (
int simTrackIndex = 0; simTrackIndex !=
simTracks_->size(); ++simTrackIndex)
487 if ( vetoedTracks.find(simTrackIndex) != vetoedTracks.end() )
continue;
498 SimTrack const * currentSimTrack = & simTrack;
501 int trackingParticleIndex = -1;
502 int trackingVertexIndex = -1;
508 if (trackingParticleIndex >= 0)
534 vetoedTracks.insert( std::make_pair(simTrackIndex, trackingParticleIndex) );
538 if (currentSimTrack->
noVertex())
break;
552 bool vetoSimVertex = vetoedSimVertexes.find(parentSimVertexIndex) != vetoedSimVertexes.end();
555 if ( !vetoSimVertex )
561 if (trackingVertexIndex < 0)
572 Vector xyz =
Vector(position.x(), position.y(), position.z());
573 double t = position.t();
578 vetoedSimVertexes.insert( std::make_pair(parentSimVertexIndex, trackingVertexIndex) );
581 trackingVertexIndex = vetoedSimVertexes[parentSimVertexIndex];
594 if (parentSimVertex->
noParent() || vetoSimVertex)
break;
605 if ( vetoedTracks.find(nextSimTrackIndex) != vetoedTracks.end() )
619 vetoedTracks.insert( std::make_pair(nextSimTrackIndex, trackingParticleIndex) );
622 currentSimTrack = &
simTracks_->getObject(nextSimTrackIndex);
624 while (!currentSimTrack->
noVertex());
665 const HepMC::GenParticle * genParticle = hepmc->GetEvent()->barcode_to_particle(genParticleIndex);
669 status = genParticle->status();
670 pdgId = genParticle->pdg_id();
678 Vector(position.x(), position.y(), position.z()),
692 int totalSimHits = 0;
700 EncodedTruthIdToIndexes::const_iterator iEntry =
trackIdToHits_.lower_bound(simTrackId);
721 unsigned int detectorIdIndex = pSimHit.
detUnitId();
724 oldDetector = newDetector;
726 newDetector = detectorId.
subdetId();
730 if ( ( oldLayer != newLayer || (oldLayer==newLayer && oldDetector!=newDetector ) ) && newLayer != 0 ) totalSimHits++;
758 for (std::size_t trackingVertexIndex = 0; trackingVertexIndex <
trackingVertexes_->size(); ++trackingVertexIndex)
761 double distance = (position -
trackingVertexes_->at(trackingVertexIndex).position()).
P();
768 return trackingVertexIndex;
805 const HepMC::GenEvent *
genEvent = hepmc->GetEvent();
812 HepMC::GenEvent::vertex_const_iterator iGenVertex = genEvent->vertices_begin();
813 iGenVertex != genEvent->vertices_end();
818 HepMC::ThreeVector rawPosition = (*iGenVertex)->position();
821 Vector genPosition(rawPosition.x()/10.0, rawPosition.y()/10.0, rawPosition.z()/10.0);
824 double distance =
sqrt( (tvPosition - genPosition).
mag2() );
839 unsigned int subdetId =
static_cast<unsigned int>(detId.
subdetId());
844 layerNumber = tibid.
layer();
849 layerNumber = tobid.
layer();
854 layerNumber = tidid.
wheel();
859 layerNumber = tecid.
wheel();
864 layerNumber = pxbid.
layer();
869 layerNumber = pxfid.
disk();
872 edm::LogVerbatim(
"TrackingTruthProducer") <<
"Unknown subdetid: " << subdetId;
std::auto_ptr< TrackingVertexCollection > trackingVertexes_
T getParameter(std::string const &) const
tp_iterator daughterTracks_begin() const
const TrackingParticleRefVector & sourceTracks() const
void createTrackingTruth()
tv_iterator decayVertices_end() const
EncodedEventId eventId() const
std::auto_ptr< TrackingParticleCollection > trackingParticles_
int event() const
get the contents of the subdetector field (should be protected?)
tv_iterator decayVertices_begin() const
void produce(edm::Event &, const edm::EventSetup &)
unsigned int layer() const
layer id
TrackingParticleRefProd refMergedTrackingParticles_
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
std::auto_ptr< MixCollection< SimTrack > > simTracks_
std::auto_ptr< TrackingVertexCollection > mergedTrackingVertexes_
MuonPSimHitSelector muonPSimHitSelector_
std::auto_ptr< TrackingParticleCollection > mergedTrackingParticles_
PixelPSimHitSelector pixelPSimHitSelector_
ROOT::Math::Plane3D::Vector Vector
EncodedEventIdToIndex eventIdCounter_
#define DEFINE_FWK_MODULE(type)
g4t_iterator g4Track_begin() const
int pdgId() const
PDG id, signal source, crossing number.
int LayerFromDetid(const unsigned int &)
std::multimap< EncodedTruthId, unsigned int > EncodedTruthIdToIndexes
unsigned int layerNumber(align::ID)
Layer number increases with rho from 1 to 8.
TrackingParticleRefProd refTrackingParticles_
const std::vector< PSimHit >::const_iterator pSimHit_begin() const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void addDaughterTrack(const TrackingParticleRef &)
const std::vector< PSimHit >::const_iterator pSimHit_end() const
EncodedTruthIdToIndexes trackIdToHits_
TrackerPSimHitSelector trackerPSimHitSelector_
TrackingParticleSelector selector_
void clearDaughterTracks()
edm::Ref< edm::HepMCProduct, HepMC::GenParticle > GenParticleRef
const_iterator end() const
Termination of iteration.
void addParentTrack(const TrackingParticleRef &)
float charge() const
charge
void setMatchedHit(const int &)
TrackingVertexRefProd refMergedTrackingVertexes_
bool isBremsstrahlungVertex(TrackingVertex const &vertex, std::auto_ptr< TrackingParticleCollection > &tPC)
static int position[TOTALCHAMBERS][3]
math::XYZTLorentzVector LorentzVector
const_iterator begin() const
Initialize an iterator over the RefVector.
unsigned int layer() const
layer id
EncodedTruthIdToIndex trackIdToIndex_
void addG4Vertex(const SimVertex &)
uint32_t rawId() const
get the raw id
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
TrackingVertexRefProd refTrackingVertexes_
virtual void select(PSimHitCollection &, edm::Event const &, edm::EventSetup const &) const
Pre-process event information.
void associator(std::vector< PSimHit > const &, EncodedTruthIdToIndexes &)
void addPSimHit(const PSimHit &)
std::auto_ptr< MixCollection< SimVertex > > simVertexes_
int bunchCrossing() const
get the detector field from this detid
void addCloseGenVertexes(TrackingVertex &)
void addDecayVertex(const TrackingVertexRef &)
int genpartIndex() const
index of the corresponding Generator particle in the Event container (-1 if no Genpart) ...
TrackingTruthProducer(const edm::ParameterSet &)
void clearDecayVertices()
const math::XYZTLorentzVectorD & position() const
uint32_t rawId() const
get the raw id
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
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
tp_iterator daughterTracks_end() const
const TrackingVertexRef & parentVertex() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
unsigned int disk() const
disk id
PSimHitSelector::PSimHitCollection pSimHits_
std::vector< edm::Handle< edm::HepMCProduct > > hepMCProducts_
std::vector< SimTrack >::const_iterator g4t_iterator
int vertIndex() const
index of the vertex in the Event container (-1 if no vertex)
edm::Ref< TrackingVertexCollection > TrackingVertexRef
bool mergedBremsstrahlung_
edm::Ref< edm::HepMCProduct, HepMC::GenVertex > GenVertexRef
unsigned int trackId() const
PSimHitSelector pSimHitSelector_
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< TrackingVertex > TrackingVertexCollection
key_type key() const
Accessor for product key.
std::vector< std::string > dataLabels_
int setTrackingVertex(SimVertex const &, TrackingVertex &)
T const * product() const
unsigned int wheel() const
wheel id
unsigned short processType() const
unsigned int layer() const
layer id
void addGenVertex(const GenVertexRef &)
const EncodedEventId & eventId() const
int type() const
particle type (HEP PDT convension)
void addGenParticle(const GenParticleRef &)
EncodedEventId eventId() const
const math::XYZTLorentzVectorD & momentum() const
particle info...
virtual void select(PSimHitCollection &, edm::Event const &, edm::EventSetup const &) const
Pre-process event information.
void mergeBremsstrahlung()
void addG4Track(const SimTrack &)
virtual void select(PSimHitCollection &, edm::Event const &, edm::EventSetup const &) const
Select the psimhit add them to a PSimHitCollection.
std::vector< TrackingParticle > TrackingParticleCollection
virtual void select(PSimHitCollection &, edm::Event const &, edm::EventSetup const &) const
Pre-process event information.
bool setTrackingParticle(SimTrack const &, TrackingParticle &)
Detector det() const
get the detector field from this detid
g4t_iterator g4Track_end() const
const TrackingVertexRefVector & decayVertices() const
void setParentVertex(const TrackingVertexRef &)
edm::Ref< TrackingParticleCollection > TrackingParticleRef
bool useMultipleHepMCLabels_
unsigned int detUnitId() const
std::string MessageCategory_
math::PtEtaPhiELorentzVectorF LorentzVector
unsigned int wheel() const
wheel id
std::map< EncodedEventId, unsigned int > EncodedEventIdToIndex
std::map< EncodedTruthId, unsigned int > EncodedTruthIdToIndex
EncodedTruthIdToIndex vertexIdToIndex_
const LorentzVector & position() const