70 struct DecayChainTrack
73 struct DecayChainVertex* pParentVertex;
75 std::vector<struct DecayChainVertex*> daughterVertices;
76 DecayChainTrack* pMergedBremSource;
77 DecayChainTrack() : simTrackIndex(-1), pParentVertex(
NULL), pMergedBremSource(
NULL) {}
78 DecayChainTrack(
int newSimTrackIndex ) : simTrackIndex(newSimTrackIndex), pParentVertex(
NULL), pMergedBremSource() {}
85 struct DecayChainVertex
88 DecayChainTrack* pParentTrack;
89 std::vector<DecayChainTrack*> daughterTracks;
90 DecayChainVertex* pMergedBremSource;
91 DecayChainVertex() : simVertexIndex(-1), pParentTrack(
NULL), pMergedBremSource(
NULL) {}
92 DecayChainVertex(
int newIndex ) : simVertexIndex(newIndex), pParentTrack(
NULL), pMergedBremSource(
NULL) {}
108 DecayChain(
const std::vector<SimTrack>& trackCollection,
const std::vector<SimVertex>&
vertexCollection );
109 const size_t decayTracksSize;
110 const size_t decayVerticesSize;
116 void integrityCheck();
117 const SimTrack& getSimTrack( const ::DecayChainTrack* pDecayTrack )
const {
return simTrackCollection_.at( pDecayTrack->simTrackIndex ); }
118 const SimVertex& getSimVertex( const ::DecayChainVertex* pDecayVertex )
const {
return simVertexCollection_.at( pDecayVertex->simVertexIndex ); }
120 void findBrem(
const std::vector<SimTrack>& trackCollection,
const std::vector<SimVertex>&
vertexCollection );
121 std::unique_ptr< ::DecayChainTrack[]> decayTracks_;
122 std::unique_ptr< ::DecayChainVertex[]> decayVertices_;
125 std::vector< ::DecayChainVertex*> rootVertices_;
128 const std::vector<SimTrack>& simTrackCollection_;
129 const std::vector<SimVertex>& simVertexCollection_;
131 const std::unique_ptr< ::DecayChainTrack[]>& decayTracks;
132 const std::unique_ptr< ::DecayChainVertex[]>& decayVertices;
133 const std::vector< ::DecayChainVertex*>& rootVertices;
140 class TrackingParticleFactory
143 TrackingParticleFactory( const ::DecayChain& decayChain,
const edm::Handle< std::vector<reco::GenParticle> >& hGenParticles,
144 const edm::Handle< std::vector<int> >& hHepMCGenParticleIndices,
const std::vector<const PSimHit*>&
simHits,
145 double volumeRadius,
double volumeZ,
bool allowDifferentProcessTypes );
146 TrackingParticle createTrackingParticle(
const DecayChainTrack* pTrack )
const;
147 TrackingVertex createTrackingVertex(
const DecayChainVertex* pVertex )
const;
150 const ::DecayChain& decayChain_;
152 std::vector<int> genParticleIndices_;
153 const std::vector<const PSimHit*>& simHits_;
154 const double volumeRadius_;
155 const double volumeZ_;
156 std::multimap<unsigned int, size_t> trackIdToHitIndex_;
157 bool allowDifferentProcessTypeForDifferentDetectors_;
164 class OutputCollectionWrapper
170 TrackingParticle* getTrackingParticle( const ::DecayChainTrack* pDecayTrack );
172 void setProxy( const ::DecayChainTrack* pOriginalTrack, const ::DecayChainTrack* pProxyTrack );
173 void setProxy( const ::DecayChainVertex* pOriginalVertex, const ::DecayChainVertex* pProxyVertex );
174 TrackingVertex* getTrackingVertex( const ::DecayChainVertex* pDecayVertex );
178 void associateToExistingObjects( const ::DecayChainVertex* pChainVertex );
179 void associateToExistingObjects( const ::DecayChainTrack* pChainTrack );
181 std::vector<int> trackingParticleIndices_;
182 std::vector<int> trackingVertexIndices_;
199 void addTrack( ::DecayChainTrack* pDecayChainTrack,
const TrackingParticleSelector* pSelector, ::OutputCollectionWrapper* pUnmergedOutput, ::OutputCollectionWrapper* pMergedOutput, const ::TrackingParticleFactory& objectFactory,
bool addAncestors );
218 messageCategory_(
"TrackingTruthAccumulator"),
219 volumeRadius_( config.getParameter<double>(
"volumeRadius") ),
220 volumeZ_( config.getParameter<double>(
"volumeZ") ),
221 ignoreTracksOutsideVolume_( config.getParameter<bool>(
"ignoreTracksOutsideVolume") ),
222 maximumPreviousBunchCrossing_( config.getParameter<unsigned int>(
"maximumPreviousBunchCrossing") ),
223 maximumSubsequentBunchCrossing_( config.getParameter<unsigned int>(
"maximumSubsequentBunchCrossing") ),
224 createUnmergedCollection_( config.getParameter<bool>(
"createUnmergedCollection") ),
225 createMergedCollection_(config.getParameter<bool>(
"createMergedBremsstrahlung") ),
226 addAncestors_( config.getParameter<bool>(
"alwaysAddAncestors") ),
227 removeDeadModules_( config.getParameter<bool>(
"removeDeadModules") ),
228 simTrackLabel_( config.getParameter<edm::InputTag>(
"simTrackCollection") ),
229 simVertexLabel_( config.getParameter<edm::InputTag>(
"simVertexCollection") ),
231 genParticleLabel_( config.getParameter<edm::InputTag>(
"genParticleCollection") ),
232 allowDifferentProcessTypeForDifferentDetectors_( config.getParameter<bool>(
"allowDifferentSimHitProcesses") )
240 <<
"set to false, which means no collections will be created";
244 if( config.
exists(
"select" ) )
295 std::vector<std::string> parameterNames=simHitCollectionConfig.
getParameterNames();
297 for(
const auto& parameterName : parameterNames )
299 std::vector<edm::InputTag>
tags=simHitCollectionConfig.getParameter<std::vector<edm::InputTag> >(parameterName);
304 iC.
consumes<std::vector<PSimHit> >(collectionTag);
351 <<
" TrackingVertexs to the event.";
360 <<
" merged TrackingVertexs to the event.";
402 DecayChain decayChain( *hSimTracks, *hSimVertices );
405 std::auto_ptr< ::OutputCollectionWrapper> pUnmergedCollectionWrapper;
406 std::auto_ptr< ::OutputCollectionWrapper> pMergedCollectionWrapper;
410 std::vector<const PSimHit*> simHitPointers;
428 ::DecayChainTrack* pDecayTrack=&decayChain.decayTracks[
index];
429 const SimTrack& simTrack=hSimTracks->at(pDecayTrack->simTrackIndex);
442 const SimVertex& simVertex=hSimVertices->at( pDecayTrack->pParentVertex->simVertexIndex );
443 if( !objectFactory.vectorIsInsideVolume( simVertex.
position() ) )
continue;
450 ::addTrack( pDecayTrack, pSelector, pUnmergedCollectionWrapper.get(), pMergedCollectionWrapper.get(), objectFactory,
addAncestors_ );
460 event.getByLabel( collectionTag, hSimHits );
463 for(
const auto& simHit : *hSimHits )
465 returnValue.push_back( &simHit );
494 ::TrackingParticleFactory::TrackingParticleFactory( const ::DecayChain& decayChain,
const edm::Handle< std::vector<reco::GenParticle> >& hGenParticles,
495 const edm::Handle< std::vector<int> >& hHepMCGenParticleIndices,
const std::vector<const PSimHit*>&
simHits,
496 double volumeRadius,
double volumeZ,
bool allowDifferentProcessTypes )
497 : decayChain_(decayChain), hGenParticles_(hGenParticles), simHits_(simHits), volumeRadius_(volumeRadius),
498 volumeZ_(volumeZ), allowDifferentProcessTypeForDifferentDetectors_(allowDifferentProcessTypes)
504 trackIdToHitIndex_.insert( std::make_pair( simHits_[
index]->trackId(),
index ) );
507 if( hHepMCGenParticleIndices.isValid() )
509 genParticleIndices_.resize( hHepMCGenParticleIndices->size()+1 );
513 for(
size_t recoGenParticleIndex=0; recoGenParticleIndex<hHepMCGenParticleIndices->size(); ++recoGenParticleIndex )
515 size_t hepMCGenParticleIndex=(*hHepMCGenParticleIndices)[recoGenParticleIndex];
518 if( genParticleIndices_.size()<=hepMCGenParticleIndex ) genParticleIndices_.resize(hepMCGenParticleIndex+1);
520 genParticleIndices_[ hepMCGenParticleIndex ]=recoGenParticleIndex;
525 TrackingParticle TrackingParticleFactory::createTrackingParticle( const ::DecayChainTrack* pChainTrack )
const
530 const SimTrack& simTrack=decayChain_.getSimTrack( pChainTrack );
531 const SimVertex& parentSimVertex=decayChain_.getSimVertex( pChainTrack->pParentVertex );
533 LorentzVector
position( 0, 0, 0, 0 );
550 if( hepMCGenParticleIndex>=0 && hepMCGenParticleIndex<static_cast<int>(genParticleIndices_.size()) && hGenParticles_.isValid() )
552 int recoGenParticleIndex=genParticleIndices_[hepMCGenParticleIndex];
554 pdgId=generatorParticleRef->pdgId();
564 size_t matchedHits=0;
565 size_t numberOfHits=0;
566 size_t numberOfTrackerHits=0;
576 for( std::multimap<unsigned int,size_t>::const_iterator iHitIndex=trackIdToHitIndex_.lower_bound( simTrack.
trackId() );
577 iHitIndex!=trackIdToHitIndex_.upper_bound( simTrack.
trackId() );
580 const auto& pSimHit=simHits_[ iHitIndex->second ];
585 processType=pSimHit->processType();
586 particleType=pSimHit->particleType();
587 newDetector=
DetId( pSimHit->detUnitId() );
591 oldDetector=newDetector;
592 newDetector=
DetId( pSimHit->detUnitId() );
596 if( allowDifferentProcessTypeForDifferentDetectors_ && newDetector.
det()!=oldDetector.
det() ) processType=pSimHit->processType();
599 if( processType==pSimHit->processType() && particleType==pSimHit->particleType() && pdgId==pSimHit->particleType() )
605 newLayer=LayerFromDetid( newDetector );
609 if( (oldLayer!=newLayer || (oldLayer==newLayer && oldDetector.
subdetId()!=newDetector.
subdetId())) && newLayer!=0 ) ++matchedHits;
620 TrackingVertex TrackingParticleFactory::createTrackingVertex( const ::DecayChainVertex* pChainVertex )
const
622 const SimVertex& simVertex=decayChain_.getSimVertex( pChainVertex );
624 bool isInVolume=this->vectorIsInsideVolume( simVertex.
position() );
634 return ( vector.Pt()<volumeRadius_ && vector.z()<volumeZ_ );
643 ::DecayChain::DecayChain(
const std::vector<SimTrack>& trackCollection,
const std::vector<SimVertex>&
vertexCollection )
644 : decayTracksSize( trackCollection.
size() ),
645 decayVerticesSize( vertexCollection.
size() ),
646 decayTracks_( new DecayChainTrack[decayTracksSize] ),
647 decayVertices_( new DecayChainVertex[decayVerticesSize] ),
648 simTrackCollection_( trackCollection ),
649 simVertexCollection_( vertexCollection ),
650 decayTracks( decayTracks_ ),
651 decayVertices( decayVertices_ ),
652 rootVertices( rootVertices_ )
655 std::map<int,::DecayChainTrack*> trackIdToDecayTrack;
656 std::map<int,::DecayChainVertex*> vertexIdToDecayVertex;
662 size_t decayVertexIndex=0;
665 ::DecayChainTrack* pDecayTrack=&decayTracks_[
index];
670 pDecayTrack->simTrackIndex=
index;
672 trackIdToDecayTrack[ trackCollection[
index].trackId() ]=pDecayTrack;
674 int parentVertexIndex=trackCollection[
index].vertIndex();
675 if( parentVertexIndex>=0 )
678 ::DecayChainVertex*& pParentVertex=vertexIdToDecayVertex[parentVertexIndex];
679 if( pParentVertex==
NULL )
682 pParentVertex=&decayVertices_[decayVertexIndex];
684 pParentVertex->simVertexIndex=parentVertexIndex;
686 pParentVertex->daughterTracks.push_back(pDecayTrack);
687 pDecayTrack->pParentVertex=pParentVertex;
689 else throw std::runtime_error(
"TrackingTruthAccumulator: Found a track with an invalid parent vertex index." );
701 for(
auto& decayVertexMapPair : vertexIdToDecayVertex )
703 ::DecayChainVertex* pDecayVertex=decayVertexMapPair.second;
704 int parentTrackIndex=vertexCollection[pDecayVertex->simVertexIndex].parentIndex();
705 if( parentTrackIndex!=-1 )
707 std::map<int,::DecayChainTrack*>::iterator iParentTrackMapPair=trackIdToDecayTrack.find(parentTrackIndex);
708 if( iParentTrackMapPair==trackIdToDecayTrack.end() )
710 std::stringstream errorStream;
711 errorStream <<
"TrackingTruthAccumulator: Something has gone wrong with the indexing. Parent track index is " << parentTrackIndex <<
".";
712 throw std::runtime_error( errorStream.str() );
715 ::DecayChainTrack* pParentTrackHierarchy=iParentTrackMapPair->second;
717 pParentTrackHierarchy->daughterVertices.push_back( pDecayVertex );
718 pDecayVertex->pParentTrack=pParentTrackHierarchy;
720 else rootVertices_.push_back(pDecayVertex);
723 findBrem( trackCollection, vertexCollection );
728 void ::DecayChain::integrityCheck()
735 const auto& decayTrack=decayTracks[
index];
739 if( decayTrack.pParentVertex==
NULL )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack with no parent vertex." );
744 size_t numberOfTimesListed=0;
745 for(
const auto pSiblingTrack : decayTrack.pParentVertex->daughterTracks )
747 if( pSiblingTrack==&decayTrack ) ++numberOfTimesListed;
749 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." );
754 for(
const auto pDaughterVertex : decayTrack.daughterVertices )
756 if( pDaughterVertex->pParentTrack!=&decayTrack )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack whose child does not have it listed as the parent." );
762 const DecayChainVertex* pAncestorVertex=decayTrack.pParentVertex;
763 while( pAncestorVertex->pParentTrack!=
NULL )
765 if( pAncestorVertex->pParentTrack->pParentVertex==
NULL )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack with no parent vertex higher in the decay chain." );
766 pAncestorVertex=pAncestorVertex->pParentTrack->pParentVertex;
768 if(
std::find( rootVertices.begin(), rootVertices.end(), pAncestorVertex )==rootVertices.end() )
770 throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack whose root vertex is not recorded anywhere." );
779 const auto& decayVertex=decayVertices[
index];
784 const DecayChainVertex* pAncestorVertex=&decayVertex;
785 while( pAncestorVertex->pParentTrack!=
NULL )
787 if( pAncestorVertex->pParentTrack->pParentVertex==
NULL )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack with no parent vertex higher in the vertex decay chain." );
788 pAncestorVertex=pAncestorVertex->pParentTrack->pParentVertex;
790 if(
std::find( rootVertices.begin(), rootVertices.end(), pAncestorVertex )==rootVertices.end() )
792 throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack whose root vertex is not recorded anywhere." );
798 if( decayVertex.pParentTrack!=
NULL )
800 size_t numberOfTimesListed=0;
801 for(
const auto pSibling : decayVertex.pParentTrack->daughterVertices )
803 if( pSibling==&decayVertex ) ++numberOfTimesListed;
805 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." );
811 for(
const auto pDaughter : decayVertex.daughterTracks )
813 if( pDaughter->pParentVertex!=&decayVertex )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainVertex whose child does not have it listed as the parent." );
817 std::cout <<
"TrackingTruthAccumulator.cc integrityCheck() completed successfully" << std::endl;
820 void ::DecayChain::findBrem(
const std::vector<SimTrack>& trackCollection,
const std::vector<SimVertex>& vertexCollection )
824 auto& vertex=decayVertices_[
index];
827 if( vertex.pParentTrack==
NULL )
continue;
828 int parentTrackPDG=trackCollection[vertex.pParentTrack->simTrackIndex].type();
829 if(
std::abs( parentTrackPDG )!=11 )
continue;
831 size_t numberOfElectrons=0;
832 size_t numberOfNonElectronsOrPhotons=0;
833 for(
auto& pDaughterTrack : vertex.daughterTracks )
835 const auto& simTrack=trackCollection[pDaughterTrack->simTrackIndex];
836 if( simTrack.
type()==11 || simTrack.
type()==-11 ) ++numberOfElectrons;
837 else if( simTrack.
type()!=22 ) ++numberOfNonElectronsOrPhotons;
839 if( numberOfElectrons==1 && numberOfNonElectronsOrPhotons==0 )
843 for(
auto& pDaughterTrack : vertex.daughterTracks ) pDaughterTrack->pMergedBremSource=vertex.pParentTrack;
844 vertex.pMergedBremSource=vertex.pParentTrack->pParentVertex;
857 : output_(outputCollections),
858 trackingParticleIndices_(decayChain.decayTracksSize,-1),
859 trackingVertexIndices_(decayChain.decayVerticesSize,-1)
866 if( trackingParticleIndices_[pDecayTrack->simTrackIndex]!=-1 )
throw std::runtime_error(
"OutputCollectionWrapper::addTrackingParticle - trying to add a particle twice" );
868 trackingParticleIndices_[pDecayTrack->simTrackIndex]=output_.pTrackingParticles->size();
869 output_.pTrackingParticles->push_back( trackingParticle );
872 output_.pTrackingParticles->back().clearDecayVertices();
873 output_.pTrackingParticles->back().clearParentVertex();
876 associateToExistingObjects( pDecayTrack );
878 return &output_.pTrackingParticles->back();
881 TrackingVertex* ::OutputCollectionWrapper::addTrackingVertex( const ::DecayChainVertex* pDecayVertex,
const TrackingVertex& trackingVertex )
883 if( trackingVertexIndices_[pDecayVertex->simVertexIndex]!=-1 )
throw std::runtime_error(
"OutputCollectionWrapper::addTrackingVertex - trying to add a vertex twice" );
885 trackingVertexIndices_[pDecayVertex->simVertexIndex]=output_.pTrackingVertices->size();
886 output_.pTrackingVertices->push_back( trackingVertex );
889 associateToExistingObjects( pDecayVertex );
891 return &output_.pTrackingVertices->back();
894 TrackingParticle* ::OutputCollectionWrapper::getTrackingParticle( const ::DecayChainTrack* pDecayTrack )
896 const int index=trackingParticleIndices_[pDecayTrack->simTrackIndex];
897 if( index==-1 )
return NULL;
898 else return &(*output_.pTrackingParticles)[index];
901 TrackingVertex* ::OutputCollectionWrapper::getTrackingVertex( const ::DecayChainVertex* pDecayVertex )
903 const int index=trackingVertexIndices_[pDecayVertex->simVertexIndex];
904 if( index==-1 )
return NULL;
905 else return &(*output_.pTrackingVertices)[index];
910 const int index=trackingParticleIndices_[pDecayTrack->simTrackIndex];
911 if( index==-1 )
throw std::runtime_error(
"OutputCollectionWrapper::getRefTrackingParticle - ref requested for a non existent TrackingParticle" );
917 const int index=trackingVertexIndices_[pDecayVertex->simVertexIndex];
918 if( index==-1 )
throw std::runtime_error(
"OutputCollectionWrapper::getRefTrackingParticle - ref requested for a non existent TrackingVertex" );
922 void ::OutputCollectionWrapper::setProxy( const ::DecayChainTrack* pOriginalTrack, const ::DecayChainTrack* pProxyTrack )
924 int& index=trackingParticleIndices_[pOriginalTrack->simTrackIndex];
925 if( index!=-1 )
throw std::runtime_error(
"OutputCollectionWrapper::setProxy() was called for a TrackingParticle that has already been created" );
927 index=trackingParticleIndices_[pProxyTrack->simTrackIndex];
930 void ::OutputCollectionWrapper::setProxy( const ::DecayChainVertex* pOriginalVertex, const ::DecayChainVertex* pProxyVertex )
932 int& index=trackingVertexIndices_[pOriginalVertex->simVertexIndex];
933 const int newIndex=trackingVertexIndices_[pProxyVertex->simVertexIndex];
935 if( index!=-1 && index!=newIndex )
throw std::runtime_error(
"OutputCollectionWrapper::setProxy() was called for a TrackingVertex that has already been created" );
941 void ::OutputCollectionWrapper::associateToExistingObjects( const ::DecayChainVertex* pChainVertex )
944 TrackingVertex* pTrackingVertex=getTrackingVertex( pChainVertex );
945 if( pTrackingVertex==
NULL )
throw std::runtime_error(
"associateToExistingObjects was passed a non existent TrackingVertex" );
950 ::DecayChainTrack* pParentChainTrack=pChainVertex->pParentTrack;
951 if( pParentChainTrack!=
NULL )
954 TrackingParticle* pParentTrackingParticle=getTrackingParticle(pParentChainTrack);
955 if( pParentTrackingParticle!=
NULL )
972 void ::OutputCollectionWrapper::associateToExistingObjects( const ::DecayChainTrack* pChainTrack )
978 if( pTrackingParticle==
NULL )
throw std::runtime_error(
"associateToExistingObjects was passed a non existent TrackingParticle" );
982 ::DecayChainVertex* pParentChainVertex=pChainTrack->pParentVertex;
983 TrackingVertex* pParentTrackingVertex=getTrackingVertex( pParentChainVertex );
995 for(
auto pDaughterChainVertex : pChainTrack->daughterVertices )
997 TrackingVertex* pDaughterTrackingVertex=getTrackingVertex( pDaughterChainVertex );
998 if( pDaughterTrackingVertex!=
NULL )
1014 int LayerFromDetid(
const DetId& detId )
1019 unsigned int subdetId=
static_cast<unsigned int>( detId.
subdetId() );
1024 layerNumber=tibid.
layer();
1029 layerNumber=tobid.
layer();
1034 layerNumber=tidid.
wheel();
1039 layerNumber=tecid.
wheel();
1044 layerNumber=pxbid.
layer();
1049 layerNumber=pxfid.
disk();
1051 else edm::LogVerbatim(
"TrackingTruthAccumulator" )<<
"Unknown subdetid: "<<subdetId;
1060 TrackingParticle* pTrackingParticle=pOutput->getTrackingParticle( pDecayTrack );
1061 if( pTrackingParticle==
NULL )
1064 TrackingVertex* pProductionVertex=pOutput->getTrackingVertex( pDecayTrack->pParentVertex );
1065 if( pProductionVertex==
NULL )
1072 pProductionVertex=pOutput->addTrackingVertex( pDecayTrack->pParentVertex, *trackingParticle.
parentVertex() );
1076 pTrackingParticle=pOutput->addTrackingParticle( pDecayTrack, trackingParticle );
1079 return pTrackingParticle;
1082 void addTrack( ::DecayChainTrack* pDecayChainTrack,
const TrackingParticleSelector* pSelector, ::OutputCollectionWrapper* pUnmergedOutput, ::OutputCollectionWrapper* pMergedOutput, const ::TrackingParticleFactory& objectFactory,
bool addAncestors )
1084 if( pDecayChainTrack==
NULL )
return;
1090 bool alreadyProcessed=
true;
1091 if( pUnmergedOutput!=
NULL )
1093 if( pUnmergedOutput->getTrackingParticle( pDecayChainTrack )==
NULL ) alreadyProcessed=
false;
1095 if( pMergedOutput!=
NULL )
1097 if( pMergedOutput->getTrackingParticle( pDecayChainTrack )==
NULL ) alreadyProcessed=
false;
1099 if( alreadyProcessed )
return;
1103 TrackingParticle newTrackingParticle=objectFactory.createTrackingParticle( pDecayChainTrack );
1113 dummyCollection.push_back( objectFactory.createTrackingVertex( pDecayChainTrack->pParentVertex ) );
1120 if( !(*pSelector)( newTrackingParticle ) )
return;
1127 if( addAncestors ) addTrack( pDecayChainTrack->pParentVertex->pParentTrack,
NULL, pUnmergedOutput, pMergedOutput, objectFactory, addAncestors );
1131 if( pUnmergedOutput!=
NULL ) addTrackAndParentVertex( pDecayChainTrack, newTrackingParticle, pUnmergedOutput );
1135 if( pMergedOutput!=
NULL )
1137 ::DecayChainTrack* pBremParentChainTrack=pDecayChainTrack;
1138 while( pBremParentChainTrack->pMergedBremSource!=
NULL ) pBremParentChainTrack=pBremParentChainTrack->pMergedBremSource;
1140 if( pBremParentChainTrack!=pDecayChainTrack )
1142 TrackingParticle* pBremParentTrackingParticle=addTrackAndParentVertex( pBremParentChainTrack, newTrackingParticle, pMergedOutput );
1155 pMergedOutput->setProxy( pDecayChainTrack->pParentVertex, pBremParentChainTrack->pParentVertex );
1160 addTrackAndParentVertex( pDecayChainTrack, newTrackingParticle, pMergedOutput );
1165 for(
const auto& trackSegment : newTrackingParticle.
g4Tracks() )
1167 pBremParentTrackingParticle->
addG4Track( trackSegment );
1171 for(
const auto& genParticleRef : newTrackingParticle.
genParticles() )
1182 pMergedOutput->setProxy( pDecayChainTrack, pBremParentChainTrack );
1188 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?)
unsigned int layer() const
layer id
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 &)
void accumulateEvent(const T &event, const edm::EventSetup &setup)
Both forms of accumulate() delegate to this templated method.
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...
static int position[TOTALCHAMBERS][3]
unsigned int layer() const
layer id
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_
uint32_t rawId() const
get the raw id
void setParentVertex(const TrackingVertexRef &ref)
void addGenParticle(const reco::GenParticleRef &ref)
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
const reco::GenParticleRefVector & genParticles() const
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)
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
unsigned int disk() const
disk id
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
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
unsigned int layerNumber(align::ID, const TrackerTopology *)
Layer number increases with rho from 1 to 8.
int numberOfHits() const
Gives the total number of hits, including muon hits. Hits on overlaps in the same layer count separat...
unsigned int wheel() const
wheel id
const unsigned int maximumPreviousBunchCrossing_
const edm::InputTag simVertexLabel_
unsigned int layer() const
layer id
void setNumberOfTrackerHits(int numberOfTrackerHits)
int type() const
particle type (HEP PDT convension)
const TrackingVertexRef & parentVertex() const
EncodedEventId eventId() const
#define DEFINE_DIGI_ACCUMULATOR(type)
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
math::PtEtaPhiELorentzVectorF LorentzVector
unsigned int wheel() const
wheel id
void setNumberOfHits(int numberOfHits)
std::vector< edm::InputTag > collectionTags_
const double volumeRadius_