27 pSimHitSelector_(config), pixelPSimHitSelector_(config), trackerPSimHitSelector_(config), muonPSimHitSelector_(config)
41 if ( config.
exists(
"select") )
72 if (!mergedBremsstrahlung_)
74 produces<TrackingVertexCollection>();
75 produces<TrackingParticleCollection>();
79 produces<TrackingVertexCollection>();
80 produces<TrackingParticleCollection>();
81 produces<TrackingVertexCollection>(
"MergedTrackTruth");
82 produces<TrackingParticleCollection>(
"MergedTrackTruth");
113 edm::LogInfo (
MessageCategory_) <<
"If the labels are not in the same order as the events in the crossing frame (i.e. signal, pileup(s) ) ";
180 event.put(mergedTrackingVertexes_,
"MergedTrackTruth");
182 event.put(trackingVertexes_);
188 event.put(trackingVertexes_);
194 std::vector<PSimHit>
const & pSimHits,
202 for (std::size_t
i = 0;
i < pSimHits.size(); ++
i)
204 EncodedTruthIdToIndexes::key_type objectId = EncodedTruthIdToIndexes::key_type(pSimHits[
i].eventId(), pSimHits[
i].trackId());
205 association.insert( std::make_pair(objectId,
i) );
222 association.insert( std::make_pair(objectId, index) );
235 bool useVertexId =
true;
238 unsigned int oldVertexId = 0;
243 if (!index || iterator->eventId() != oldEventId)
245 oldEventId = iterator->eventId();
246 oldVertexId = iterator->vertexId();
250 if ( iterator->vertexId() == oldVertexId )
269 objectId =
EncodedTruthId(iterator->eventId(), iterator->vertexId());
271 objectId =
EncodedTruthId(iterator->eventId(), vertexId[iterator->eventId()]++);
272 association.insert( std::make_pair(objectId, index) );
279 unsigned int index = 0;
281 std::set<unsigned int> excludedTV, excludedTP;
307 daughterRef = *idaughter;
309 else if ( pointer->
pdgId() == 22 )
329 for (std::vector<PSimHit>::const_iterator ihit = daughter->
pSimHit_begin(); ihit != daughter->
pSimHit_end(); ++ihit)
355 if (*isource != daughterRef)
362 excludedTV.insert(index);
365 excludedTP.insert( daughterRef.
key() );
376 std::map<unsigned int, unsigned int> vertexMap;
381 if ( excludedTV.find(index) != excludedTV.end() )
continue;
396 if ( excludedTP.find(index) != excludedTP.end() )
continue;
408 unsigned int parentIndex = vertexMap[sourceV.
key()];
420 unsigned int daughterIndex = vertexMap[iDecayV->key()];
434 std::auto_ptr<TrackingParticleCollection> & tPC
447 unsigned int nElectrons = 0;
448 unsigned int nOthers = 0;
459 else if ( tPC->at(it->key()).
pdgId() != 22 )
464 if (nElectrons == 1 && nOthers == 0)
477 std::map<int,std::size_t> vetoedTracks;
480 std::map<int,std::size_t> vetoedSimVertexes;
482 for (
int simTrackIndex = 0; simTrackIndex !=
simTracks_->size(); ++simTrackIndex)
485 if ( vetoedTracks.find(simTrackIndex) != vetoedTracks.end() )
continue;
496 SimTrack const * currentSimTrack = & simTrack;
499 int trackingParticleIndex = -1;
500 int trackingVertexIndex = -1;
506 if (trackingParticleIndex >= 0)
532 vetoedTracks.insert( std::make_pair(simTrackIndex, trackingParticleIndex) );
536 if (currentSimTrack->
noVertex())
break;
550 bool vetoSimVertex = vetoedSimVertexes.find(parentSimVertexIndex) != vetoedSimVertexes.end();
553 if ( !vetoSimVertex )
559 if (trackingVertexIndex < 0)
577 vetoedSimVertexes.insert( std::make_pair(parentSimVertexIndex, trackingVertexIndex) );
580 trackingVertexIndex = vetoedSimVertexes[parentSimVertexIndex];
593 if (parentSimVertex->
noParent() || vetoSimVertex)
break;
604 if ( vetoedTracks.find(nextSimTrackIndex) != vetoedTracks.end() )
618 vetoedTracks.insert( std::make_pair(nextSimTrackIndex, trackingParticleIndex) );
621 currentSimTrack = &
simTracks_->getObject(nextSimTrackIndex);
623 while (!currentSimTrack->
noVertex());
647 position =
simVertexes_->getObject(parentSimVertexIndex).position();
667 const HepMC::GenParticle * genParticle = hepmc->GetEvent()->barcode_to_particle(genParticleIndex);
671 status = genParticle->status();
672 pdgId = genParticle->pdg_id();
680 Vector(position.x(), position.y(), position.z()),
690 int particleType = 0;
694 int totalSimHits = 0;
702 EncodedTruthIdToIndexes::const_iterator iEntry =
trackIdToHits_.lower_bound(simTrackId);
723 unsigned int detectorIdIndex = pSimHit.
detUnitId();
726 oldDetector = newDetector;
728 newDetector = detectorId.
subdetId();
732 if ( ( oldLayer != newLayer || (oldLayer==newLayer && oldDetector!=newDetector ) ) && newLayer != 0 ) totalSimHits++;
760 for (std::size_t trackingVertexIndex = 0; trackingVertexIndex <
trackingVertexes_->size(); ++trackingVertexIndex)
763 double distance = (position -
trackingVertexes_->at(trackingVertexIndex).position()).
P();
770 return trackingVertexIndex;
807 const HepMC::GenEvent *
genEvent = hepmc->GetEvent();
814 HepMC::GenEvent::vertex_const_iterator iGenVertex = genEvent->vertices_begin();
815 iGenVertex != genEvent->vertices_end();
820 HepMC::ThreeVector rawPosition = (*iGenVertex)->position();
823 Vector genPosition(rawPosition.x()/10.0, rawPosition.y()/10.0, rawPosition.z()/10.0);
826 double distance =
sqrt( (tvPosition - genPosition).
mag2() );
841 unsigned int subdetId =
static_cast<unsigned int>(detId.
subdetId());
846 layerNumber = tibid.
layer();
851 layerNumber = tobid.
layer();
856 layerNumber = tidid.
wheel();
861 layerNumber = tecid.
wheel();
866 layerNumber = pxbid.
layer();
871 layerNumber = pxfid.
disk();
874 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::vector< TrackingParticle > TrackingParticleCollection
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
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
unsigned int layerNumber(align::ID)
Layer number increases with rho from 1 to 8.
TrackingParticleRefProd refTrackingParticles_
math::XYZTLorentzVector LorentzVector
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()
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]
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
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) ...
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
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.
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 &)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
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