72 struct DecayChainTrack
75 struct DecayChainVertex* pParentVertex;
77 std::vector<struct DecayChainVertex*> daughterVertices;
78 DecayChainTrack* pMergedBremSource;
79 DecayChainTrack() : simTrackIndex(-1), pParentVertex(
NULL), pMergedBremSource(
NULL) {}
80 DecayChainTrack(
int newSimTrackIndex ) : simTrackIndex(newSimTrackIndex), pParentVertex(
NULL), pMergedBremSource() {}
87 struct DecayChainVertex
90 DecayChainTrack* pParentTrack;
91 std::vector<DecayChainTrack*> daughterTracks;
92 DecayChainVertex* pMergedBremSource;
93 DecayChainVertex() : simVertexIndex(-1), pParentTrack(
NULL), pMergedBremSource(
NULL) {}
94 DecayChainVertex(
int newIndex ) : simVertexIndex(newIndex), pParentTrack(
NULL), pMergedBremSource(
NULL) {}
111 const size_t decayTracksSize;
112 const size_t decayVerticesSize;
118 void integrityCheck();
119 const SimTrack& getSimTrack( const ::DecayChainTrack* pDecayTrack )
const {
return simTrackCollection_.at( pDecayTrack->simTrackIndex ); }
120 const SimVertex& getSimVertex( const ::DecayChainVertex* pDecayVertex )
const {
return simVertexCollection_.at( pDecayVertex->simVertexIndex ); }
123 std::unique_ptr< ::DecayChainTrack[]> decayTracks_;
124 std::unique_ptr< ::DecayChainVertex[]> decayVertices_;
127 std::vector< ::DecayChainVertex*> rootVertices_;
130 const std::vector<SimTrack>& simTrackCollection_;
131 const std::vector<SimVertex>& simVertexCollection_;
133 const std::unique_ptr< ::DecayChainTrack[]>& decayTracks;
134 const std::unique_ptr< ::DecayChainVertex[]>& decayVertices;
135 const std::vector< ::DecayChainVertex*>& rootVertices;
142 class TrackingParticleFactory
145 TrackingParticleFactory( const ::DecayChain& decayChain,
const edm::Handle< std::vector<reco::GenParticle> >& hGenParticles,
147 const std::vector<const PSimHit*>&
simHits,
double volumeRadius,
double volumeZ,
double vertexDistanceCut,
bool allowDifferentProcessTypes );
149 TrackingVertex createTrackingVertex(
const DecayChainVertex* pVertex)
const;
152 const ::DecayChain& decayChain_;
155 std::vector<int> genParticleIndices_;
156 const std::vector<const PSimHit*>& simHits_;
157 const double volumeRadius_;
158 const double volumeZ_;
159 const double vertexDistanceCut2_;
160 std::multimap<unsigned int, size_t> trackIdToHitIndex_;
161 bool allowDifferentProcessTypeForDifferentDetectors_;
168 class OutputCollectionWrapper
174 TrackingParticle* getTrackingParticle( const ::DecayChainTrack* pDecayTrack );
176 void setProxy( const ::DecayChainTrack* pOriginalTrack, const ::DecayChainTrack* pProxyTrack );
177 void setProxy( const ::DecayChainVertex* pOriginalVertex, const ::DecayChainVertex* pProxyVertex );
178 TrackingVertex* getTrackingVertex( const ::DecayChainVertex* pDecayVertex );
182 void associateToExistingObjects( const ::DecayChainVertex* pChainVertex );
183 void associateToExistingObjects( const ::DecayChainTrack* pChainTrack );
185 std::vector<int> trackingParticleIndices_;
186 std::vector<int> trackingVertexIndices_;
199 void addTrack( ::DecayChainTrack* pDecayChainTrack,
const TrackingParticleSelector* pSelector, ::OutputCollectionWrapper* pUnmergedOutput, ::OutputCollectionWrapper* pMergedOutput, const ::TrackingParticleFactory& objectFactory,
bool addAncestors,
const TrackerTopology *tTopo);
218 messageCategory_(
"TrackingTruthAccumulator"),
219 volumeRadius_( config.getParameter<double>(
"volumeRadius") ),
220 volumeZ_( config.getParameter<double>(
"volumeZ") ),
221 vertexDistanceCut_( config.getParameter<double>(
"vertexDistanceCut") ),
222 ignoreTracksOutsideVolume_( config.getParameter<bool>(
"ignoreTracksOutsideVolume") ),
223 maximumPreviousBunchCrossing_( config.getParameter<unsigned int>(
"maximumPreviousBunchCrossing") ),
224 maximumSubsequentBunchCrossing_( config.getParameter<unsigned int>(
"maximumSubsequentBunchCrossing") ),
225 createUnmergedCollection_( config.getParameter<bool>(
"createUnmergedCollection") ),
226 createMergedCollection_(config.getParameter<bool>(
"createMergedBremsstrahlung") ),
227 addAncestors_( config.getParameter<bool>(
"alwaysAddAncestors") ),
228 removeDeadModules_( config.getParameter<bool>(
"removeDeadModules") ),
229 simTrackLabel_( config.getParameter<edm::
InputTag>(
"simTrackCollection") ),
230 simVertexLabel_( config.getParameter<edm::
InputTag>(
"simVertexCollection") ),
232 genParticleLabel_( config.getParameter<edm::
InputTag>(
"genParticleCollection") ),
233 hepMCproductLabel_( config.getParameter<edm::
InputTag>(
"HepMCProductLabel") ),
234 allowDifferentProcessTypeForDifferentDetectors_( config.getParameter<bool>(
"allowDifferentSimHitProcesses") )
242 <<
"set to false, which means no collections will be created";
246 if( config.
exists(
"select" ) )
298 std::vector<std::string> parameterNames=simHitCollectionConfig.
getParameterNames();
300 for(
const auto& parameterName : parameterNames )
302 std::vector<edm::InputTag>
tags=simHitCollectionConfig.getParameter<std::vector<edm::InputTag> >(parameterName);
307 iC.
consumes<std::vector<PSimHit> >(collectionTag);
366 <<
" TrackingVertexs to the event.";
375 <<
" merged TrackingVertexs to the event.";
423 DecayChain decayChain( *hSimTracks, *hSimVertices );
426 std::auto_ptr< ::OutputCollectionWrapper> pUnmergedCollectionWrapper;
427 std::auto_ptr< ::OutputCollectionWrapper> pMergedCollectionWrapper;
431 std::vector<const PSimHit*> simHitPointers;
449 ::DecayChainTrack* pDecayTrack=&decayChain.decayTracks[
index];
450 const SimTrack& simTrack=hSimTracks->at(pDecayTrack->simTrackIndex);
463 const SimVertex& simVertex=hSimVertices->at( pDecayTrack->pParentVertex->simVertexIndex );
464 if( !objectFactory.vectorIsInsideVolume( simVertex.
position() ) )
continue;
471 ::addTrack( pDecayTrack, pSelector, pUnmergedCollectionWrapper.get(), pMergedCollectionWrapper.get(), objectFactory,
addAncestors_, tTopo );
481 event.getByLabel( collectionTag, hSimHits );
484 for(
const auto& simHit : *hSimHits )
486 returnValue.push_back( &simHit );
515 ::TrackingParticleFactory::TrackingParticleFactory( const ::DecayChain& decayChain,
const edm::Handle< std::vector<reco::GenParticle> >& hGenParticles,
517 double volumeRadius,
double volumeZ,
double vertexDistanceCut,
bool allowDifferentProcessTypes )
518 : decayChain_(decayChain), hGenParticles_(hGenParticles), hepMCproduct_(hepMCproduct), simHits_(simHits), volumeRadius_(volumeRadius),
519 volumeZ_(volumeZ), vertexDistanceCut2_(vertexDistanceCut*vertexDistanceCut), allowDifferentProcessTypeForDifferentDetectors_(allowDifferentProcessTypes)
525 trackIdToHitIndex_.insert( std::make_pair( simHits_[
index]->trackId(),
index ) );
528 if( hHepMCGenParticleIndices.isValid() )
530 genParticleIndices_.resize( hHepMCGenParticleIndices->size()+1 );
534 for(
size_t recoGenParticleIndex=0; recoGenParticleIndex<hHepMCGenParticleIndices->size(); ++recoGenParticleIndex )
536 size_t hepMCGenParticleIndex=(*hHepMCGenParticleIndices)[recoGenParticleIndex];
539 if( genParticleIndices_.size()<=hepMCGenParticleIndex ) genParticleIndices_.resize(hepMCGenParticleIndex+1);
541 genParticleIndices_[ hepMCGenParticleIndex ]=recoGenParticleIndex;
551 const SimTrack& simTrack=decayChain_.getSimTrack( pChainTrack );
552 const SimVertex& parentSimVertex=decayChain_.getSimVertex( pChainTrack->pParentVertex );
554 LorentzVector
position( 0, 0, 0, 0 );
571 if( hepMCGenParticleIndex>=0 && hepMCGenParticleIndex<static_cast<int>(genParticleIndices_.size()) && hGenParticles_.isValid() )
573 int recoGenParticleIndex=genParticleIndices_[hepMCGenParticleIndex];
575 pdgId=generatorParticleRef->pdgId();
585 size_t matchedHits=0;
586 size_t numberOfHits=0;
587 size_t numberOfTrackerHits=0;
597 for( std::multimap<unsigned int,size_t>::const_iterator iHitIndex=trackIdToHitIndex_.lower_bound( simTrack.
trackId() );
598 iHitIndex!=trackIdToHitIndex_.upper_bound( simTrack.
trackId() );
601 const auto& pSimHit=simHits_[ iHitIndex->second ];
606 processType=pSimHit->processType();
607 particleType=pSimHit->particleType();
608 newDetector=
DetId( pSimHit->detUnitId() );
612 oldDetector=newDetector;
613 newDetector=
DetId( pSimHit->detUnitId() );
617 if( allowDifferentProcessTypeForDifferentDetectors_ && newDetector.
det()!=oldDetector.
det() ) processType=pSimHit->processType();
620 if( processType==pSimHit->processType() && particleType==pSimHit->particleType() && pdgId==pSimHit->particleType() )
626 ++numberOfTrackerHits;
628 newLayer=tTopo->
layer( newDetector );
631 if( (oldLayer!=newLayer || (oldLayer==newLayer && oldDetector.
subdetId()!=newDetector.
subdetId())) ) ++matchedHits;
643 TrackingVertex TrackingParticleFactory::createTrackingVertex( const ::DecayChainVertex* pChainVertex)
const
650 const SimVertex& simVertex=decayChain_.getSimVertex( pChainVertex );
652 bool isInVolume=this->vectorIsInsideVolume( simVertex.
position() );
657 returnValue.addG4Vertex(simVertex);
662 const HepMC::GenEvent*
genEvent = hepMCproduct_->GetEvent();
664 if (genEvent !=
NULL)
666 Vector tvPosition(returnValue.position().x(), returnValue.position().
y(), returnValue.position().z());
668 for (HepMC::GenEvent::vertex_const_iterator iGenVertex = genEvent->vertices_begin(); iGenVertex != genEvent->vertices_end(); ++iGenVertex)
670 HepMC::ThreeVector rawPosition = (*iGenVertex)->position();
672 Vector genPosition(rawPosition.x()*0.1, rawPosition.y()*0.1, rawPosition.z()*0.1);
674 auto distance2 = (tvPosition - genPosition).
mag2();
676 if (distance2 < vertexDistanceCut2_)
677 returnValue.addGenVertex(
GenVertexRef(hepMCproduct_, (*iGenVertex)->barcode()) );
687 return ( vector.Pt()<volumeRadius_ && vector.z()<volumeZ_ );
697 : decayTracksSize( trackCollection.
size() ),
698 decayVerticesSize( vertexCollection.
size() ),
699 decayTracks_( new DecayChainTrack[decayTracksSize] ),
700 decayVertices_( new DecayChainVertex[decayVerticesSize] ),
701 simTrackCollection_( trackCollection ),
702 simVertexCollection_( vertexCollection ),
703 decayTracks( decayTracks_ ),
704 decayVertices( decayVertices_ ),
705 rootVertices( rootVertices_ )
708 std::map<int,::DecayChainTrack*> trackIdToDecayTrack;
709 std::map<int,::DecayChainVertex*> vertexIdToDecayVertex;
715 size_t decayVertexIndex=0;
718 ::DecayChainTrack* pDecayTrack=&decayTracks_[
index];
723 pDecayTrack->simTrackIndex=
index;
725 trackIdToDecayTrack[ trackCollection[
index].trackId() ]=pDecayTrack;
727 int parentVertexIndex=trackCollection[
index].vertIndex();
728 if( parentVertexIndex>=0 )
731 ::DecayChainVertex*& pParentVertex=vertexIdToDecayVertex[parentVertexIndex];
732 if( pParentVertex==
NULL )
735 pParentVertex=&decayVertices_[decayVertexIndex];
737 pParentVertex->simVertexIndex=parentVertexIndex;
739 pParentVertex->daughterTracks.push_back(pDecayTrack);
740 pDecayTrack->pParentVertex=pParentVertex;
742 else throw std::runtime_error(
"TrackingTruthAccumulator: Found a track with an invalid parent vertex index." );
754 for(
auto& decayVertexMapPair : vertexIdToDecayVertex )
756 ::DecayChainVertex* pDecayVertex=decayVertexMapPair.second;
757 int parentTrackIndex=vertexCollection[pDecayVertex->simVertexIndex].parentIndex();
758 if( parentTrackIndex!=-1 )
760 std::map<int,::DecayChainTrack*>::iterator iParentTrackMapPair=trackIdToDecayTrack.find(parentTrackIndex);
761 if( iParentTrackMapPair==trackIdToDecayTrack.end() )
763 std::stringstream errorStream;
764 errorStream <<
"TrackingTruthAccumulator: Something has gone wrong with the indexing. Parent track index is " << parentTrackIndex <<
".";
765 throw std::runtime_error( errorStream.str() );
768 ::DecayChainTrack* pParentTrackHierarchy=iParentTrackMapPair->second;
770 pParentTrackHierarchy->daughterVertices.push_back( pDecayVertex );
771 pDecayVertex->pParentTrack=pParentTrackHierarchy;
773 else rootVertices_.push_back(pDecayVertex);
776 findBrem( trackCollection, vertexCollection );
781 void ::DecayChain::integrityCheck()
788 const auto& decayTrack=decayTracks[
index];
792 if( decayTrack.pParentVertex==
NULL )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack with no parent vertex." );
797 size_t numberOfTimesListed=0;
798 for(
const auto pSiblingTrack : decayTrack.pParentVertex->daughterTracks )
800 if( pSiblingTrack==&decayTrack ) ++numberOfTimesListed;
802 if( numberOfTimesListed!=1 )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack whose parent does not have it listed once and only once as a child." );
807 for(
const auto pDaughterVertex : decayTrack.daughterVertices )
809 if( pDaughterVertex->pParentTrack!=&decayTrack )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack whose child does not have it listed as the parent." );
815 const DecayChainVertex* pAncestorVertex=decayTrack.pParentVertex;
816 while( pAncestorVertex->pParentTrack!=
NULL )
818 if( pAncestorVertex->pParentTrack->pParentVertex==
NULL )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack with no parent vertex higher in the decay chain." );
819 pAncestorVertex=pAncestorVertex->pParentTrack->pParentVertex;
821 if(
std::find( rootVertices.begin(), rootVertices.end(), pAncestorVertex )==rootVertices.end() )
823 throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack whose root vertex is not recorded anywhere." );
832 const auto& decayVertex=decayVertices[
index];
837 const DecayChainVertex* pAncestorVertex=&decayVertex;
838 while( pAncestorVertex->pParentTrack!=
NULL )
840 if( pAncestorVertex->pParentTrack->pParentVertex==
NULL )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack with no parent vertex higher in the vertex decay chain." );
841 pAncestorVertex=pAncestorVertex->pParentTrack->pParentVertex;
843 if(
std::find( rootVertices.begin(), rootVertices.end(), pAncestorVertex )==rootVertices.end() )
845 throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack whose root vertex is not recorded anywhere." );
851 if( decayVertex.pParentTrack!=
NULL )
853 size_t numberOfTimesListed=0;
854 for(
const auto pSibling : decayVertex.pParentTrack->daughterVertices )
856 if( pSibling==&decayVertex ) ++numberOfTimesListed;
858 if( numberOfTimesListed!=1 )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainVertex whose parent does not have it listed once and only once as a child." );
864 for(
const auto pDaughter : decayVertex.daughterTracks )
866 if( pDaughter->pParentVertex!=&decayVertex )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainVertex whose child does not have it listed as the parent." );
870 std::cout <<
"TrackingTruthAccumulator.cc integrityCheck() completed successfully" << std::endl;
873 void ::DecayChain::findBrem(
const std::vector<SimTrack>& trackCollection,
const std::vector<SimVertex>& vertexCollection )
877 auto& vertex=decayVertices_[
index];
880 if( vertex.pParentTrack==
NULL )
continue;
881 int parentTrackPDG=trackCollection[vertex.pParentTrack->simTrackIndex].type();
882 if(
std::abs( parentTrackPDG )!=11 )
continue;
884 size_t numberOfElectrons=0;
885 size_t numberOfNonElectronsOrPhotons=0;
886 for(
auto& pDaughterTrack : vertex.daughterTracks )
888 const auto& simTrack=trackCollection[pDaughterTrack->simTrackIndex];
889 if( simTrack.
type()==11 || simTrack.
type()==-11 ) ++numberOfElectrons;
890 else if( simTrack.
type()!=22 ) ++numberOfNonElectronsOrPhotons;
892 if( numberOfElectrons==1 && numberOfNonElectronsOrPhotons==0 )
896 for(
auto& pDaughterTrack : vertex.daughterTracks ) pDaughterTrack->pMergedBremSource=vertex.pParentTrack;
897 vertex.pMergedBremSource=vertex.pParentTrack->pParentVertex;
910 : output_(outputCollections),
911 trackingParticleIndices_(decayChain.decayTracksSize,-1),
912 trackingVertexIndices_(decayChain.decayVerticesSize,-1)
919 if( trackingParticleIndices_[pDecayTrack->simTrackIndex]!=-1 )
throw std::runtime_error(
"OutputCollectionWrapper::addTrackingParticle - trying to add a particle twice" );
921 trackingParticleIndices_[pDecayTrack->simTrackIndex]=output_.pTrackingParticles->size();
922 output_.pTrackingParticles->push_back( trackingParticle );
925 output_.pTrackingParticles->back().clearDecayVertices();
926 output_.pTrackingParticles->back().clearParentVertex();
929 associateToExistingObjects( pDecayTrack );
931 return &output_.pTrackingParticles->back();
934 TrackingVertex* ::OutputCollectionWrapper::addTrackingVertex( const ::DecayChainVertex* pDecayVertex,
const TrackingVertex& trackingVertex )
936 if( trackingVertexIndices_[pDecayVertex->simVertexIndex]!=-1 )
throw std::runtime_error(
"OutputCollectionWrapper::addTrackingVertex - trying to add a vertex twice" );
938 trackingVertexIndices_[pDecayVertex->simVertexIndex]=output_.pTrackingVertices->size();
939 output_.pTrackingVertices->push_back( trackingVertex );
942 associateToExistingObjects( pDecayVertex );
944 return &output_.pTrackingVertices->back();
947 TrackingParticle* ::OutputCollectionWrapper::getTrackingParticle( const ::DecayChainTrack* pDecayTrack )
949 const int index=trackingParticleIndices_[pDecayTrack->simTrackIndex];
950 if( index==-1 )
return NULL;
951 else return &(*output_.pTrackingParticles)[index];
954 TrackingVertex* ::OutputCollectionWrapper::getTrackingVertex( const ::DecayChainVertex* pDecayVertex )
956 const int index=trackingVertexIndices_[pDecayVertex->simVertexIndex];
957 if( index==-1 )
return NULL;
958 else return &(*output_.pTrackingVertices)[index];
963 const int index=trackingParticleIndices_[pDecayTrack->simTrackIndex];
964 if( index==-1 )
throw std::runtime_error(
"OutputCollectionWrapper::getRefTrackingParticle - ref requested for a non existent TrackingParticle" );
970 const int index=trackingVertexIndices_[pDecayVertex->simVertexIndex];
971 if( index==-1 )
throw std::runtime_error(
"OutputCollectionWrapper::getRefTrackingParticle - ref requested for a non existent TrackingVertex" );
975 void ::OutputCollectionWrapper::setProxy( const ::DecayChainTrack* pOriginalTrack, const ::DecayChainTrack* pProxyTrack )
977 int& index=trackingParticleIndices_[pOriginalTrack->simTrackIndex];
978 if( index!=-1 )
throw std::runtime_error(
"OutputCollectionWrapper::setProxy() was called for a TrackingParticle that has already been created" );
980 index=trackingParticleIndices_[pProxyTrack->simTrackIndex];
983 void ::OutputCollectionWrapper::setProxy( const ::DecayChainVertex* pOriginalVertex, const ::DecayChainVertex* pProxyVertex )
985 int& index=trackingVertexIndices_[pOriginalVertex->simVertexIndex];
986 const int newIndex=trackingVertexIndices_[pProxyVertex->simVertexIndex];
988 if( index!=-1 && index!=newIndex )
throw std::runtime_error(
"OutputCollectionWrapper::setProxy() was called for a TrackingVertex that has already been created" );
994 void ::OutputCollectionWrapper::associateToExistingObjects( const ::DecayChainVertex* pChainVertex )
997 TrackingVertex* pTrackingVertex=getTrackingVertex( pChainVertex );
998 if( pTrackingVertex==
NULL )
throw std::runtime_error(
"associateToExistingObjects was passed a non existent TrackingVertex" );
1003 ::DecayChainTrack* pParentChainTrack=pChainVertex->pParentTrack;
1004 if( pParentChainTrack!=
NULL )
1007 TrackingParticle* pParentTrackingParticle=getTrackingParticle(pParentChainTrack);
1008 if( pParentTrackingParticle!=
NULL )
1025 void ::OutputCollectionWrapper::associateToExistingObjects( const ::DecayChainTrack* pChainTrack )
1031 if( pTrackingParticle==
NULL )
throw std::runtime_error(
"associateToExistingObjects was passed a non existent TrackingParticle" );
1035 ::DecayChainVertex* pParentChainVertex=pChainTrack->pParentVertex;
1036 TrackingVertex* pParentTrackingVertex=getTrackingVertex( pParentChainVertex );
1048 for(
auto pDaughterChainVertex : pChainTrack->daughterVertices )
1050 TrackingVertex* pDaughterTrackingVertex=getTrackingVertex( pDaughterChainVertex );
1051 if( pDaughterTrackingVertex!=
NULL )
1064 TrackingParticle* pTrackingParticle=pOutput->getTrackingParticle( pDecayTrack );
1065 if( pTrackingParticle==
NULL )
1068 TrackingVertex* pProductionVertex=pOutput->getTrackingVertex( pDecayTrack->pParentVertex );
1069 if( pProductionVertex==
NULL )
1076 pProductionVertex=pOutput->addTrackingVertex( pDecayTrack->pParentVertex, *trackingParticle.
parentVertex() );
1080 pTrackingParticle=pOutput->addTrackingParticle( pDecayTrack, trackingParticle );
1083 return pTrackingParticle;
1086 void addTrack( ::DecayChainTrack* pDecayChainTrack,
const TrackingParticleSelector* pSelector, ::OutputCollectionWrapper* pUnmergedOutput, ::OutputCollectionWrapper* pMergedOutput, const ::TrackingParticleFactory& objectFactory,
bool addAncestors,
const TrackerTopology *tTopo )
1088 if( pDecayChainTrack==
NULL )
return;
1094 bool alreadyProcessed=
true;
1095 if( pUnmergedOutput!=
NULL )
1097 if( pUnmergedOutput->getTrackingParticle( pDecayChainTrack )==
NULL ) alreadyProcessed=
false;
1099 if( pMergedOutput!=
NULL )
1101 if( pMergedOutput->getTrackingParticle( pDecayChainTrack )==
NULL ) alreadyProcessed=
false;
1103 if( alreadyProcessed )
return;
1107 TrackingParticle newTrackingParticle=objectFactory.createTrackingParticle( pDecayChainTrack, tTopo );
1117 dummyCollection.push_back( objectFactory.createTrackingVertex( pDecayChainTrack->pParentVertex) );
1124 if( !(*pSelector)( newTrackingParticle ) )
return;
1131 if( addAncestors ) addTrack( pDecayChainTrack->pParentVertex->pParentTrack,
NULL, pUnmergedOutput, pMergedOutput, objectFactory, addAncestors, tTopo );
1135 if( pUnmergedOutput!=
NULL ) addTrackAndParentVertex( pDecayChainTrack, newTrackingParticle, pUnmergedOutput );
1139 if( pMergedOutput!=
NULL )
1141 ::DecayChainTrack* pBremParentChainTrack=pDecayChainTrack;
1142 while( pBremParentChainTrack->pMergedBremSource!=
NULL ) pBremParentChainTrack=pBremParentChainTrack->pMergedBremSource;
1144 if( pBremParentChainTrack!=pDecayChainTrack )
1146 TrackingParticle* pBremParentTrackingParticle=addTrackAndParentVertex( pBremParentChainTrack, newTrackingParticle, pMergedOutput );
1159 pMergedOutput->setProxy( pDecayChainTrack->pParentVertex, pBremParentChainTrack->pParentVertex );
1164 addTrackAndParentVertex( pDecayChainTrack, newTrackingParticle, pMergedOutput );
1169 for(
const auto& trackSegment : newTrackingParticle.
g4Tracks() )
1171 pBremParentTrackingParticle->
addG4Track( trackSegment );
1175 for(
const auto& genParticleRef : newTrackingParticle.
genParticles() )
1186 pMergedOutput->setProxy( pDecayChainTrack, pBremParentChainTrack );
1192 addTrackAndParentVertex( pDecayChainTrack, newTrackingParticle, pMergedOutput );
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
int bunchCrossing() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
EncodedEventId eventId() const
const bool ignoreTracksOutsideVolume_
int event() const
get the contents of the subdetector field (should be protected?)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
virtual void initializeEvent(const edm::Event &event, const edm::EventSetup &setup)
std::vector< TrackingParticle > TrackingParticleCollection
ROOT::Math::Plane3D::Vector Vector
TrackingParticleRefProd refTrackingParticles
int pdgId() const
PDG ID.
const bool addAncestors_
Whether or not to add the full parentage of any TrackingParticle that is inserted in the collection...
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void addDaughterTrack(const TrackingParticleRef &)
const double vertexDistanceCut_
maximum distance for HepMC::GenVertex to be added to SimVertex
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void addParentTrack(const TrackingParticleRef &)
float charge() const
charge
bool signalOnly_
Uses the same config as selector_, but can be used to drop out early since selector_ requires the Tra...
void fillSimHits(std::vector< const PSimHit * > &returnValue, const T &event, const edm::EventSetup &setup)
Fills the supplied vector with pointers to the SimHits, checking for bad modules if required...
const unsigned int maximumSubsequentBunchCrossing_
void setParentVertex(const TrackingVertexRef &ref)
void addGenParticle(const reco::GenParticleRef &ref)
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
const reco::GenParticleRefVector & genParticles() const
void accumulateEvent(const T &event, const edm::EventSetup &setup, const edm::Handle< edm::HepMCProduct > &hepMCproduct)
Both forms of accumulate() delegate to this templated method.
double y() const
Same as rapidity().
int bunchCrossing() const
get the detector field from this detid
void addG4Track(const SimTrack &t)
int genpartIndex() const
index of the corresponding Generator particle in the Event container (-1 if no Genpart) ...
int numberOfTrackerLayers() const
The number of tracker layers with a hit.
virtual void finalizeEvent(edm::Event &event, const edm::EventSetup &setup)
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
const std::string messageCategory_
The message category used to send messages to MessageLogger.
Abs< T >::type abs(const T &t)
const math::XYZTLorentzVectorD & position() const
std::vector< std::string > getParameterNames() const
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) ...
edm::InputTag genParticleLabel_
TrackingVertexRefProd refTrackingVertexes
OutputCollections mergedOutput_
const edm::InputTag simTrackLabel_
bool allowDifferentProcessTypeForDifferentDetectors_
When counting hits, allows hits in different detectors to have a different process type...
std::auto_ptr< TrackingParticleCollection > pTrackingParticles
virtual void accumulate(const edm::Event &event, const edm::EventSetup &setup)
edm::Ref< TrackingVertexCollection > TrackingVertexRef
edm::Ref< edm::HepMCProduct, HepMC::GenVertex > GenVertexRef
unsigned int trackId() const
ParameterSet const & getParameterSet(std::string const &) const
std::auto_ptr< TrackingVertexCollection > pTrackingVertices
XYZPointD XYZPoint
point in space with cartesian internal representation
void addDecayVertex(const TrackingVertexRef &ref)
std::vector< TrackingVertex > TrackingVertexCollection
const std::vector< SimTrack > & g4Tracks() const
T const * product() const
int numberOfHits() const
Gives the total number of hits, including muon hits. Hits on overlaps in the same layer count separat...
const unsigned int maximumPreviousBunchCrossing_
const edm::InputTag simVertexLabel_
unsigned int layer(const DetId &id) const
void setNumberOfTrackerHits(int numberOfTrackerHits)
int type() const
particle type (HEP PDT convension)
const TrackingVertexRef & parentVertex() const
EncodedEventId eventId() const
#define DEFINE_DIGI_ACCUMULATOR(type)
static int position[264][3]
bool chargedOnly_
Uses the same config as selector_, but can be used to drop out early since selector_ requires the Tra...
const bool createUnmergedCollection_
If bremsstrahlung merging, whether to also add the unmerged collection to the event or not...
TrackingParticleSelector selector_
Monte Carlo truth information used for tracking validation.
OutputCollections unmergedOutput_
int numberOfTrackerHits() const
The number of hits in the tracker. Hits on overlaps in the same layer count separately.
void setNumberOfTrackerLayers(const int numberOfTrackerLayers)
TrackingTruthAccumulator(const edm::ParameterSet &config, edm::one::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
Replacement for TrackingTruthProducer in the new pileup mixing setup.
Detector det() const
get the detector field from this detid
const bool createMergedCollection_
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.
edm::Ref< TrackingParticleCollection > TrackingParticleRef
edm::InputTag hepMCproductLabel_
Needed to add HepMC::GenVertex to SimVertex.
math::PtEtaPhiELorentzVectorF LorentzVector
void setNumberOfHits(int numberOfHits)
std::vector< edm::InputTag > collectionTags_
const double volumeRadius_