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
460 else if ( tPC->at(it->key()).
pdgId() == 22 )
467 if (nElectrons == 1 && nPhotons >= 0 && nOthers == 0)
480 std::map<int,std::size_t> vetoedTracks;
483 std::map<int,std::size_t> vetoedSimVertexes;
485 for (
int simTrackIndex = 0; simTrackIndex !=
simTracks_->size(); ++simTrackIndex)
488 if ( vetoedTracks.find(simTrackIndex) != vetoedTracks.end() )
continue;
499 SimTrack const * currentSimTrack = & simTrack;
502 int trackingParticleIndex = -1;
503 int trackingVertexIndex = -1;
509 if (trackingParticleIndex >= 0)
535 vetoedTracks.insert( std::make_pair(simTrackIndex, trackingParticleIndex) );
539 if (currentSimTrack->
noVertex())
break;
553 bool vetoSimVertex = vetoedSimVertexes.find(parentSimVertexIndex) != vetoedSimVertexes.end();
556 if ( !vetoSimVertex )
562 if (trackingVertexIndex < 0)
573 Vector xyz =
Vector(position.x(), position.y(), position.z());
574 double t = position.t();
579 vetoedSimVertexes.insert( std::make_pair(parentSimVertexIndex, trackingVertexIndex) );
582 trackingVertexIndex = vetoedSimVertexes[parentSimVertexIndex];
595 if (parentSimVertex->
noParent() || vetoSimVertex)
break;
606 if ( vetoedTracks.find(nextSimTrackIndex) != vetoedTracks.end() )
620 vetoedTracks.insert( std::make_pair(nextSimTrackIndex, trackingParticleIndex) );
623 currentSimTrack = &
simTracks_->getObject(nextSimTrackIndex);
625 while (!currentSimTrack->
noVertex());
666 const HepMC::GenParticle * genParticle = hepmc->GetEvent()->barcode_to_particle(genParticleIndex);
670 status = genParticle->status();
671 pdgId = genParticle->pdg_id();
679 Vector(position.x(), position.y(), position.z()),
689 int particleType = 0;
693 int totalSimHits = 0;
701 EncodedTruthIdToIndexes::const_iterator iEntry =
trackIdToHits_.lower_bound(simTrackId);
722 unsigned int detectorIdIndex = pSimHit.
detUnitId();
725 oldDetector = newDetector;
727 newDetector = detectorId.
subdetId();
731 if ( ( oldLayer != newLayer || (oldLayer==newLayer && oldDetector!=newDetector ) ) && newLayer != 0 ) totalSimHits++;
759 for (std::size_t trackingVertexIndex = 0; trackingVertexIndex <
trackingVertexes_->size(); ++trackingVertexIndex)
762 double distance = (position -
trackingVertexes_->at(trackingVertexIndex).position()).
P();
769 return trackingVertexIndex;
806 const HepMC::GenEvent *
genEvent = hepmc->GetEvent();
813 HepMC::GenEvent::vertex_const_iterator iGenVertex = genEvent->vertices_begin();
814 iGenVertex != genEvent->vertices_end();
819 HepMC::ThreeVector rawPosition = (*iGenVertex)->position();
822 Vector genPosition(rawPosition.x()/10.0, rawPosition.y()/10.0, rawPosition.z()/10.0);
825 double distance =
sqrt( (tvPosition - genPosition).
mag2() );
840 unsigned int subdetId =
static_cast<unsigned int>(detId.
subdetId());
845 layerNumber = tibid.
layer();
850 layerNumber = tobid.
layer();
855 layerNumber = tidid.
wheel();
860 layerNumber = tecid.
wheel();
865 layerNumber = pxbid.
layer();
870 layerNumber = pxfid.
disk();
873 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_
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()
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]
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.
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 &)
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