77 struct DecayChainTrack
80 struct DecayChainVertex* pParentVertex;
82 std::vector<struct DecayChainVertex*> daughterVertices;
83 DecayChainTrack* pMergedBremSource;
84 DecayChainTrack() : simTrackIndex(-1), pParentVertex(
nullptr), pMergedBremSource(
nullptr) {}
85 DecayChainTrack(
int newSimTrackIndex ) : simTrackIndex(newSimTrackIndex), pParentVertex(
nullptr), pMergedBremSource() {}
92 struct DecayChainVertex
95 DecayChainTrack* pParentTrack;
96 std::vector<DecayChainTrack*> daughterTracks;
97 DecayChainVertex* pMergedBremSource;
98 DecayChainVertex() : simVertexIndex(-1), pParentTrack(
nullptr), pMergedBremSource(
nullptr) {}
99 DecayChainVertex(
int newIndex ) : simVertexIndex(newIndex), pParentTrack(
nullptr), pMergedBremSource(
nullptr) {}
116 const size_t decayTracksSize;
117 const size_t decayVerticesSize;
119 #if defined(DO_DEBUG_TESTING) 124 void integrityCheck();
126 const SimTrack& getSimTrack( const ::DecayChainTrack* pDecayTrack )
const {
return simTrackCollection_.at( pDecayTrack->simTrackIndex ); }
127 const SimVertex& getSimVertex( const ::DecayChainVertex* pDecayVertex )
const {
return simVertexCollection_.at( pDecayVertex->simVertexIndex ); }
130 std::unique_ptr< ::DecayChainTrack[]> decayTracks_;
131 std::unique_ptr< ::DecayChainVertex[]> decayVertices_;
134 std::vector< ::DecayChainVertex*> rootVertices_;
137 const std::vector<SimTrack>& simTrackCollection_;
138 const std::vector<SimVertex>& simVertexCollection_;
140 const std::unique_ptr< ::DecayChainTrack[]>& decayTracks;
141 const std::unique_ptr< ::DecayChainVertex[]>& decayVertices;
142 const std::vector< ::DecayChainVertex*>& rootVertices;
149 class TrackingParticleFactory
152 TrackingParticleFactory( const ::DecayChain& decayChain,
const edm::Handle< std::vector<reco::GenParticle> >& hGenParticles,
156 TrackingVertex createTrackingVertex(
const DecayChainVertex* pVertex)
const;
159 const ::DecayChain& decayChain_;
162 std::vector<int> genParticleIndices_;
163 const std::vector<const PSimHit*>& simHits_;
164 const double volumeRadius_;
165 const double volumeZ_;
166 const double vertexDistanceCut2_;
167 std::multimap<unsigned int, size_t> trackIdToHitIndex_;
168 bool allowDifferentProcessTypeForDifferentDetectors_;
175 class OutputCollectionWrapper
181 TrackingParticle* getTrackingParticle( const ::DecayChainTrack* pDecayTrack );
183 void setProxy( const ::DecayChainTrack* pOriginalTrack, const ::DecayChainTrack* pProxyTrack );
184 void setProxy( const ::DecayChainVertex* pOriginalVertex, const ::DecayChainVertex* pProxyVertex );
185 TrackingVertex* getTrackingVertex( const ::DecayChainVertex* pDecayVertex );
189 void associateToExistingObjects( const ::DecayChainVertex* pChainVertex );
190 void associateToExistingObjects( const ::DecayChainTrack* pChainTrack );
192 std::vector<int> trackingParticleIndices_;
193 std::vector<int> trackingVertexIndices_;
206 void addTrack( ::DecayChainTrack* pDecayChainTrack,
const TrackingParticleSelector* pSelector, ::OutputCollectionWrapper* pUnmergedOutput, ::OutputCollectionWrapper* pMergedOutput, const ::TrackingParticleFactory& objectFactory,
bool addAncestors,
const TrackerTopology *tTopo);
225 messageCategory_(
"TrackingTruthAccumulator"),
226 volumeRadius_( config.getParameter<double>(
"volumeRadius") ),
227 volumeZ_( config.getParameter<double>(
"volumeZ") ),
228 vertexDistanceCut_( config.getParameter<double>(
"vertexDistanceCut") ),
229 ignoreTracksOutsideVolume_( config.getParameter<
bool>(
"ignoreTracksOutsideVolume") ),
230 maximumPreviousBunchCrossing_( config.getParameter<unsigned
int>(
"maximumPreviousBunchCrossing") ),
231 maximumSubsequentBunchCrossing_( config.getParameter<unsigned
int>(
"maximumSubsequentBunchCrossing") ),
232 createUnmergedCollection_( config.getParameter<
bool>(
"createUnmergedCollection") ),
233 createMergedCollection_(config.getParameter<
bool>(
"createMergedBremsstrahlung") ),
234 createInitialVertexCollection_(config.getParameter<
bool>(
"createInitialVertexCollection") ),
235 addAncestors_( config.getParameter<
bool>(
"alwaysAddAncestors") ),
236 removeDeadModules_( config.getParameter<
bool>(
"removeDeadModules") ),
237 simTrackLabel_( config.getParameter<
edm::InputTag>(
"simTrackCollection") ),
238 simVertexLabel_( config.getParameter<
edm::InputTag>(
"simVertexCollection") ),
240 genParticleLabel_( config.getParameter<
edm::InputTag>(
"genParticleCollection") ),
241 hepMCproductLabel_( config.getParameter<
edm::InputTag>(
"HepMCProductLabel") ),
242 allowDifferentProcessTypeForDifferentDetectors_( config.getParameter<
bool>(
"allowDifferentSimHitProcesses") )
250 <<
"set to false, which means no collections will be created";
254 if( config.
exists(
"select" ) )
313 std::vector<std::string> parameterNames=simHitCollectionConfig.
getParameterNames();
315 for(
const auto& parameterName : parameterNames )
317 std::vector<edm::InputTag> tags=simHitCollectionConfig.getParameter<std::vector<edm::InputTag> >(parameterName);
322 iC.
consumes<std::vector<PSimHit> >(collectionTag);
386 <<
" TrackingVertexs to the event.";
395 <<
" merged TrackingVertexs to the event.";
449 DecayChain decayChain( *hSimTracks, *hSimVertices );
452 std::unique_ptr< ::OutputCollectionWrapper> pUnmergedCollectionWrapper;
453 std::unique_ptr< ::OutputCollectionWrapper> pMergedCollectionWrapper;
457 std::vector<const PSimHit*> simHitPointers;
461 #if defined(DO_DEBUG_TESTING) 464 decayChain.integrityCheck();
477 ::DecayChainTrack* pDecayTrack=&decayChain.decayTracks[
index];
491 const SimVertex&
simVertex=hSimVertices->at( pDecayTrack->pParentVertex->simVertexIndex );
492 if( !objectFactory.vectorIsInsideVolume( simVertex.
position() ) )
continue;
499 ::addTrack( pDecayTrack, pSelector, pUnmergedCollectionWrapper.get(), pMergedCollectionWrapper.get(), objectFactory,
addAncestors_, tTopo );
511 for(
const auto& pRootVertex : decayChain.rootVertices )
513 const SimVertex& vertex=hSimVertices->at(decayChain.rootVertices[0]->simVertexIndex);
514 if( vertex.
vertexId()!=0 )
continue;
528 event.getByLabel( collectionTag, hSimHits );
531 for(
const auto&
simHit : *hSimHits )
533 returnValue.push_back( &
simHit );
541 std::sort(returnValue.begin(), returnValue.end(), [](
const PSimHit *
a,
const PSimHit *
b) {
543 const auto btof =
edm::isFinite(
b->timeOfFlight()) ?
b->timeOfFlight() : std::numeric_limits<decltype(
b->timeOfFlight())>::
max();
571 ::TrackingParticleFactory::TrackingParticleFactory( const ::DecayChain& decayChain,
const edm::Handle< std::vector<reco::GenParticle> >& hGenParticles,
574 : decayChain_(decayChain), hGenParticles_(hGenParticles), hepMCproduct_(hepMCproduct), simHits_(simHits),
volumeRadius_(volumeRadius),
581 trackIdToHitIndex_.insert( std::make_pair( simHits_[
index]->trackId(),
index ) );
584 if( hHepMCGenParticleIndices.isValid() )
586 genParticleIndices_.resize( hHepMCGenParticleIndices->size()+1 );
590 for(
size_t recoGenParticleIndex=0; recoGenParticleIndex<hHepMCGenParticleIndices->size(); ++recoGenParticleIndex )
592 size_t hepMCGenParticleIndex=(*hHepMCGenParticleIndices)[recoGenParticleIndex];
595 if( genParticleIndices_.size()<=hepMCGenParticleIndex ) genParticleIndices_.resize(hepMCGenParticleIndex+1);
597 genParticleIndices_[ hepMCGenParticleIndex ]=recoGenParticleIndex;
608 const SimVertex& parentSimVertex=decayChain_.getSimVertex( pChainTrack->pParentVertex );
610 LorentzVector
position( 0, 0, 0, 0 );
627 if( hepMCGenParticleIndex>=0 && hepMCGenParticleIndex<static_cast<int>(genParticleIndices_.size()) && hGenParticles_.isValid() )
629 int recoGenParticleIndex=genParticleIndices_[hepMCGenParticleIndex];
631 pdgId=generatorParticleRef->pdgId();
641 size_t matchedHits=0;
642 size_t numberOfHits=0;
643 size_t numberOfTrackerHits=0;
659 for(
auto iHitIndex=trackIdToHitIndex_.lower_bound( simTrack.
trackId() ),
end=trackIdToHitIndex_.upper_bound( simTrack.
trackId() );
663 const auto& pSimHit=simHits_[ iHitIndex->second ];
666 if(pSimHit->particleType() !=
pdgId)
672 processType=pSimHit->processType();
673 particleType=pSimHit->particleType();
674 newDetector=
DetId( pSimHit->detUnitId() );
678 oldDetector=newDetector;
679 newDetector=
DetId( pSimHit->detUnitId() );
686 if( processType==pSimHit->processType() && particleType==pSimHit->particleType() )
692 ++numberOfTrackerHits;
694 newLayer=tTopo->
layer( newDetector );
697 if( (oldLayer!=newLayer || (oldLayer==newLayer && oldDetector.
subdetId()!=newDetector.
subdetId())) ) ++matchedHits;
709 TrackingVertex TrackingParticleFactory::createTrackingVertex( const ::DecayChainVertex* pChainVertex)
const 718 bool isInVolume=this->vectorIsInsideVolume( simVertex.
position() );
728 const HepMC::GenEvent*
genEvent = hepMCproduct_->GetEvent();
730 if (genEvent !=
nullptr)
732 Vector tvPosition(returnValue.position().x(), returnValue.position().y(), returnValue.position().z());
734 for (HepMC::GenEvent::vertex_const_iterator iGenVertex = genEvent->vertices_begin(); iGenVertex != genEvent->vertices_end(); ++iGenVertex)
736 HepMC::ThreeVector rawPosition = (*iGenVertex)->position();
738 Vector genPosition(rawPosition.x()*0.1, rawPosition.y()*0.1, rawPosition.z()*0.1);
740 auto distance2 = (tvPosition - genPosition).
mag2();
742 if (distance2 < vertexDistanceCut2_)
743 returnValue.addGenVertex(
GenVertexRef(hepMCproduct_, (*iGenVertex)->barcode()) );
763 : decayTracksSize( trackCollection.size() ),
764 decayVerticesSize( vertexCollection.size() ),
765 decayTracks_(
new DecayChainTrack[decayTracksSize] ),
766 decayVertices_(
new DecayChainVertex[decayVerticesSize] ),
767 simTrackCollection_( trackCollection ),
768 simVertexCollection_( vertexCollection ),
769 decayTracks( decayTracks_ ),
770 decayVertices( decayVertices_ ),
771 rootVertices( rootVertices_ )
774 std::map<int,::DecayChainTrack*> trackIdToDecayTrack;
775 std::map<int,::DecayChainVertex*> vertexIdToDecayVertex;
781 size_t decayVertexIndex=0;
784 ::DecayChainTrack* pDecayTrack=&decayTracks_[
index];
789 pDecayTrack->simTrackIndex=
index;
791 trackIdToDecayTrack[ trackCollection[
index].trackId() ]=pDecayTrack;
793 int parentVertexIndex=trackCollection[
index].vertIndex();
794 if( parentVertexIndex>=0 )
797 ::DecayChainVertex*& pParentVertex=vertexIdToDecayVertex[parentVertexIndex];
798 if( pParentVertex==
nullptr )
801 pParentVertex=&decayVertices_[decayVertexIndex];
803 pParentVertex->simVertexIndex=parentVertexIndex;
805 pParentVertex->daughterTracks.push_back(pDecayTrack);
806 pDecayTrack->pParentVertex=pParentVertex;
808 else throw std::runtime_error(
"TrackingTruthAccumulator: Found a track with an invalid parent vertex index." );
820 for(
auto& decayVertexMapPair : vertexIdToDecayVertex )
822 ::DecayChainVertex* pDecayVertex=decayVertexMapPair.second;
823 int parentTrackIndex=vertexCollection[pDecayVertex->simVertexIndex].parentIndex();
824 if( parentTrackIndex!=-1 )
826 std::map<int,::DecayChainTrack*>::iterator iParentTrackMapPair=trackIdToDecayTrack.find(parentTrackIndex);
827 if( iParentTrackMapPair==trackIdToDecayTrack.end() )
829 std::stringstream errorStream;
830 errorStream <<
"TrackingTruthAccumulator: Something has gone wrong with the indexing. Parent track index is " << parentTrackIndex <<
".";
831 throw std::runtime_error( errorStream.str() );
834 ::DecayChainTrack* pParentTrackHierarchy=iParentTrackMapPair->second;
836 pParentTrackHierarchy->daughterVertices.push_back( pDecayVertex );
837 pDecayVertex->pParentTrack=pParentTrackHierarchy;
839 else rootVertices_.push_back(pDecayVertex);
842 findBrem( trackCollection, vertexCollection );
846 #if defined(DO_DEBUG_TESTING) 848 void ::DecayChain::integrityCheck()
855 const auto& decayTrack=decayTracks[
index];
859 if( decayTrack.pParentVertex==
NULL )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack with no parent vertex." );
864 size_t numberOfTimesListed=0;
865 for(
const auto pSiblingTrack : decayTrack.pParentVertex->daughterTracks )
867 if( pSiblingTrack==&decayTrack ) ++numberOfTimesListed;
869 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." );
874 for(
const auto pDaughterVertex : decayTrack.daughterVertices )
876 if( pDaughterVertex->pParentTrack!=&decayTrack )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack whose child does not have it listed as the parent." );
882 const DecayChainVertex* pAncestorVertex=decayTrack.pParentVertex;
883 while( pAncestorVertex->pParentTrack!=
NULL )
885 if( pAncestorVertex->pParentTrack->pParentVertex==
NULL )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack with no parent vertex higher in the decay chain." );
886 pAncestorVertex=pAncestorVertex->pParentTrack->pParentVertex;
888 if(
std::find( rootVertices.begin(), rootVertices.end(), pAncestorVertex )==rootVertices.end() )
890 throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack whose root vertex is not recorded anywhere." );
899 const auto& decayVertex=decayVertices[
index];
904 const DecayChainVertex* pAncestorVertex=&decayVertex;
905 while( pAncestorVertex->pParentTrack!=
NULL )
907 if( pAncestorVertex->pParentTrack->pParentVertex==
NULL )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack with no parent vertex higher in the vertex decay chain." );
908 pAncestorVertex=pAncestorVertex->pParentTrack->pParentVertex;
910 if(
std::find( rootVertices.begin(), rootVertices.end(), pAncestorVertex )==rootVertices.end() )
912 throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack whose root vertex is not recorded anywhere." );
918 if( decayVertex.pParentTrack!=
NULL )
920 size_t numberOfTimesListed=0;
921 for(
const auto pSibling : decayVertex.pParentTrack->daughterVertices )
923 if( pSibling==&decayVertex ) ++numberOfTimesListed;
925 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." );
931 for(
const auto pDaughter : decayVertex.daughterTracks )
933 if( pDaughter->pParentVertex!=&decayVertex )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainVertex whose child does not have it listed as the parent." );
937 std::cout <<
"TrackingTruthAccumulator.cc integrityCheck() completed successfully" << std::endl;
941 void ::DecayChain::findBrem(
const std::vector<SimTrack>& trackCollection,
const std::vector<SimVertex>& vertexCollection )
945 auto& vertex=decayVertices_[
index];
948 if( vertex.pParentTrack==
nullptr )
continue;
949 int parentTrackPDG=trackCollection[vertex.pParentTrack->simTrackIndex].type();
950 if(
std::abs( parentTrackPDG )!=11 )
continue;
952 size_t numberOfElectrons=0;
953 size_t numberOfNonElectronsOrPhotons=0;
954 for(
auto& pDaughterTrack : vertex.daughterTracks )
956 const auto&
simTrack=trackCollection[pDaughterTrack->simTrackIndex];
958 else if(
simTrack.type()!=22 ) ++numberOfNonElectronsOrPhotons;
960 if( numberOfElectrons==1 && numberOfNonElectronsOrPhotons==0 )
964 for(
auto& pDaughterTrack : vertex.daughterTracks ) pDaughterTrack->pMergedBremSource=vertex.pParentTrack;
965 vertex.pMergedBremSource=vertex.pParentTrack->pParentVertex;
978 : output_(outputCollections),
979 trackingParticleIndices_(decayChain.decayTracksSize,-1),
980 trackingVertexIndices_(decayChain.decayVerticesSize,-1)
987 if( trackingParticleIndices_[pDecayTrack->simTrackIndex]!=-1 )
throw std::runtime_error(
"OutputCollectionWrapper::addTrackingParticle - trying to add a particle twice" );
989 trackingParticleIndices_[pDecayTrack->simTrackIndex]=output_.pTrackingParticles->size();
990 output_.pTrackingParticles->push_back( trackingParticle );
993 output_.pTrackingParticles->back().clearDecayVertices();
994 output_.pTrackingParticles->back().clearParentVertex();
997 associateToExistingObjects( pDecayTrack );
999 return &output_.pTrackingParticles->back();
1002 TrackingVertex* ::OutputCollectionWrapper::addTrackingVertex( const ::DecayChainVertex* pDecayVertex,
const TrackingVertex& trackingVertex )
1004 if( trackingVertexIndices_[pDecayVertex->simVertexIndex]!=-1 )
throw std::runtime_error(
"OutputCollectionWrapper::addTrackingVertex - trying to add a vertex twice" );
1006 trackingVertexIndices_[pDecayVertex->simVertexIndex]=output_.pTrackingVertices->size();
1007 output_.pTrackingVertices->push_back( trackingVertex );
1010 associateToExistingObjects( pDecayVertex );
1012 return &output_.pTrackingVertices->back();
1015 TrackingParticle* ::OutputCollectionWrapper::getTrackingParticle( const ::DecayChainTrack* pDecayTrack )
1017 const int index=trackingParticleIndices_[pDecayTrack->simTrackIndex];
1018 if( index==-1 )
return nullptr;
1019 else return &(*output_.pTrackingParticles)[index];
1022 TrackingVertex* ::OutputCollectionWrapper::getTrackingVertex( const ::DecayChainVertex* pDecayVertex )
1024 const int index=trackingVertexIndices_[pDecayVertex->simVertexIndex];
1025 if( index==-1 )
return nullptr;
1026 else return &(*output_.pTrackingVertices)[index];
1031 const int index=trackingParticleIndices_[pDecayTrack->simTrackIndex];
1032 if( index==-1 )
throw std::runtime_error(
"OutputCollectionWrapper::getRefTrackingParticle - ref requested for a non existent TrackingParticle" );
1038 const int index=trackingVertexIndices_[pDecayVertex->simVertexIndex];
1039 if( index==-1 )
throw std::runtime_error(
"OutputCollectionWrapper::getRefTrackingParticle - ref requested for a non existent TrackingVertex" );
1043 void ::OutputCollectionWrapper::setProxy( const ::DecayChainTrack* pOriginalTrack, const ::DecayChainTrack* pProxyTrack )
1045 int&
index=trackingParticleIndices_[pOriginalTrack->simTrackIndex];
1046 if( index!=-1 )
throw std::runtime_error(
"OutputCollectionWrapper::setProxy() was called for a TrackingParticle that has already been created" );
1048 index=trackingParticleIndices_[pProxyTrack->simTrackIndex];
1051 void ::OutputCollectionWrapper::setProxy( const ::DecayChainVertex* pOriginalVertex, const ::DecayChainVertex* pProxyVertex )
1053 int&
index=trackingVertexIndices_[pOriginalVertex->simVertexIndex];
1054 const int newIndex=trackingVertexIndices_[pProxyVertex->simVertexIndex];
1056 if( index!=-1 && index!=newIndex )
throw std::runtime_error(
"OutputCollectionWrapper::setProxy() was called for a TrackingVertex that has already been created" );
1062 void ::OutputCollectionWrapper::associateToExistingObjects( const ::DecayChainVertex* pChainVertex )
1065 TrackingVertex* pTrackingVertex=getTrackingVertex( pChainVertex );
1066 if( pTrackingVertex==
nullptr )
throw std::runtime_error(
"associateToExistingObjects was passed a non existent TrackingVertex" );
1071 ::DecayChainTrack* pParentChainTrack=pChainVertex->pParentTrack;
1072 if( pParentChainTrack!=
nullptr )
1075 TrackingParticle* pParentTrackingParticle=getTrackingParticle(pParentChainTrack);
1076 if( pParentTrackingParticle!=
nullptr )
1093 void ::OutputCollectionWrapper::associateToExistingObjects( const ::DecayChainTrack* pChainTrack )
1099 if( pTrackingParticle==
nullptr )
throw std::runtime_error(
"associateToExistingObjects was passed a non existent TrackingParticle" );
1103 ::DecayChainVertex* pParentChainVertex=pChainTrack->pParentVertex;
1104 TrackingVertex* pParentTrackingVertex=getTrackingVertex( pParentChainVertex );
1116 for(
auto pDaughterChainVertex : pChainTrack->daughterVertices )
1118 TrackingVertex* pDaughterTrackingVertex=getTrackingVertex( pDaughterChainVertex );
1119 if( pDaughterTrackingVertex!=
nullptr )
1132 TrackingParticle* pTrackingParticle=pOutput->getTrackingParticle( pDecayTrack );
1133 if( pTrackingParticle==
nullptr )
1136 if( pOutput->getTrackingVertex( pDecayTrack->pParentVertex ) ==
nullptr )
1143 pOutput->addTrackingVertex( pDecayTrack->pParentVertex, *trackingParticle.
parentVertex() );
1147 pTrackingParticle=pOutput->addTrackingParticle( pDecayTrack, trackingParticle );
1150 return pTrackingParticle;
1153 void addTrack( ::DecayChainTrack* pDecayChainTrack,
const TrackingParticleSelector* pSelector, ::OutputCollectionWrapper* pUnmergedOutput, ::OutputCollectionWrapper* pMergedOutput, const ::TrackingParticleFactory& objectFactory,
bool addAncestors,
const TrackerTopology *tTopo )
1155 if( pDecayChainTrack==
nullptr )
return;
1161 bool alreadyProcessed=
true;
1162 if( pUnmergedOutput!=
nullptr )
1164 if( pUnmergedOutput->getTrackingParticle( pDecayChainTrack )==
nullptr ) alreadyProcessed=
false;
1166 if( pMergedOutput!=
nullptr )
1168 if( pMergedOutput->getTrackingParticle( pDecayChainTrack )==
nullptr ) alreadyProcessed=
false;
1170 if( alreadyProcessed )
return;
1174 TrackingParticle newTrackingParticle=objectFactory.createTrackingParticle( pDecayChainTrack, tTopo );
1184 dummyCollection.push_back( objectFactory.createTrackingVertex( pDecayChainTrack->pParentVertex) );
1191 if( !(*pSelector)( newTrackingParticle ) )
return;
1198 if( addAncestors ) addTrack( pDecayChainTrack->pParentVertex->pParentTrack,
nullptr, pUnmergedOutput, pMergedOutput, objectFactory, addAncestors, tTopo );
1202 if( pUnmergedOutput!=
nullptr ) addTrackAndParentVertex( pDecayChainTrack, newTrackingParticle, pUnmergedOutput );
1206 if( pMergedOutput!=
nullptr )
1208 ::DecayChainTrack* pBremParentChainTrack=pDecayChainTrack;
1209 while( pBremParentChainTrack->pMergedBremSource!=
nullptr ) pBremParentChainTrack=pBremParentChainTrack->pMergedBremSource;
1211 if( pBremParentChainTrack!=pDecayChainTrack )
1213 TrackingParticle* pBremParentTrackingParticle=addTrackAndParentVertex( pBremParentChainTrack, newTrackingParticle, pMergedOutput );
1226 pMergedOutput->setProxy( pDecayChainTrack->pParentVertex, pBremParentChainTrack->pParentVertex );
1231 addTrackAndParentVertex( pDecayChainTrack, newTrackingParticle, pMergedOutput );
1236 for(
const auto& trackSegment : newTrackingParticle.
g4Tracks() )
1238 pBremParentTrackingParticle->
addG4Track( trackSegment );
1242 for(
const auto& genParticleRef : newTrackingParticle.
genParticles() )
1253 pMergedOutput->setProxy( pDecayChainTrack, pBremParentChainTrack );
1259 addTrackAndParentVertex( pDecayChainTrack, newTrackingParticle, pMergedOutput );
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
int bunchCrossing() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::unique_ptr< TrackingParticleCollection > pTrackingParticles
std::unique_ptr< TrackingVertexCollection > pInitialVertices_
EncodedEventId eventId() const
const bool ignoreTracksOutsideVolume_
int event() const
get the contents of the subdetector field (should be protected?)
const std::vector< SimTrack > & g4Tracks() const
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
std::unique_ptr< TrackingVertexCollection > pTrackingVertices
std::vector< TrackingParticle > TrackingParticleCollection
const reco::GenParticleRefVector & genParticles() const
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 &)
def setup(process, global_tag, zero_tesla=False)
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 addG4Vertex(const SimVertex &)
void setParentVertex(const TrackingVertexRef &ref)
void addGenParticle(const reco::GenParticleRef &ref)
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
void accumulateEvent(const T &event, const edm::EventSetup &setup, const edm::Handle< edm::HepMCProduct > &hepMCproduct)
Both forms of accumulate() delegate to this templated method.
float timeOfFlight() const
void finalizeEvent(edm::Event &event, const edm::EventSetup &setup) override
simTrack
per collection params
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.
TrackingTruthAccumulator(const edm::ParameterSet &config, edm::ProducerBase &mixMod, edm::ConsumesCollector &iC)
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
unsigned int vertexId() 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) ...
const TrackingVertexRef & parentVertex() const
void initializeEvent(const edm::Event &event, const edm::EventSetup &setup) override
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...
edm::Ref< TrackingVertexCollection > TrackingVertexRef
edm::Ref< edm::HepMCProduct, HepMC::GenVertex > GenVertexRef
unsigned int trackId() const
const bool createInitialVertexCollection_
Whether or not to create a separate collection for just the initial interaction vertices.
ParameterSet const & getParameterSet(std::string const &) const
XYZPointD XYZPoint
point in space with cartesian internal representation
void addDecayVertex(const TrackingVertexRef &ref)
std::vector< TrackingVertex > TrackingVertexCollection
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)
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_
void accumulate(const edm::Event &event, const edm::EventSetup &setup) override
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)
Replacement for TrackingTruthProducer in the new pileup mixing setup.
Detector det() const
get the detector field from this detid
const bool createMergedCollection_
T const * product() const
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_