75 struct DecayChainTrack
78 struct DecayChainVertex* pParentVertex;
80 std::vector<struct DecayChainVertex*> daughterVertices;
81 DecayChainTrack* pMergedBremSource;
82 DecayChainTrack() : simTrackIndex(-1), pParentVertex(
NULL), pMergedBremSource(
NULL) {}
83 DecayChainTrack(
int newSimTrackIndex ) : simTrackIndex(newSimTrackIndex), pParentVertex(
NULL), pMergedBremSource() {}
90 struct DecayChainVertex
93 DecayChainTrack* pParentTrack;
94 std::vector<DecayChainTrack*> daughterTracks;
95 DecayChainVertex* pMergedBremSource;
96 DecayChainVertex() : simVertexIndex(-1), pParentTrack(
NULL), pMergedBremSource(
NULL) {}
97 DecayChainVertex(
int newIndex ) : simVertexIndex(newIndex), pParentTrack(
NULL), pMergedBremSource(
NULL) {}
114 const size_t decayTracksSize;
115 const size_t decayVerticesSize;
121 void integrityCheck();
122 const SimTrack& getSimTrack( const ::DecayChainTrack* pDecayTrack )
const {
return simTrackCollection_.at( pDecayTrack->simTrackIndex ); }
123 const SimVertex& getSimVertex( const ::DecayChainVertex* pDecayVertex )
const {
return simVertexCollection_.at( pDecayVertex->simVertexIndex ); }
126 std::unique_ptr< ::DecayChainTrack[]> decayTracks_;
127 std::unique_ptr< ::DecayChainVertex[]> decayVertices_;
130 std::vector< ::DecayChainVertex*> rootVertices_;
133 const std::vector<SimTrack>& simTrackCollection_;
134 const std::vector<SimVertex>& simVertexCollection_;
136 const std::unique_ptr< ::DecayChainTrack[]>& decayTracks;
137 const std::unique_ptr< ::DecayChainVertex[]>& decayVertices;
138 const std::vector< ::DecayChainVertex*>& rootVertices;
145 class TrackingParticleFactory
148 TrackingParticleFactory( const ::DecayChain& decayChain,
const edm::Handle< std::vector<reco::GenParticle> >& hGenParticles,
150 const std::vector<const PSimHit*>&
simHits,
double volumeRadius,
double volumeZ,
double vertexDistanceCut,
bool allowDifferentProcessTypes );
152 TrackingVertex createTrackingVertex(
const DecayChainVertex* pVertex)
const;
155 const ::DecayChain& decayChain_;
158 std::vector<int> genParticleIndices_;
159 const std::vector<const PSimHit*>& simHits_;
160 const double volumeRadius_;
161 const double volumeZ_;
162 const double vertexDistanceCut2_;
163 std::multimap<unsigned int, size_t> trackIdToHitIndex_;
164 bool allowDifferentProcessTypeForDifferentDetectors_;
171 class OutputCollectionWrapper
177 TrackingParticle* getTrackingParticle( const ::DecayChainTrack* pDecayTrack );
179 void setProxy( const ::DecayChainTrack* pOriginalTrack, const ::DecayChainTrack* pProxyTrack );
180 void setProxy( const ::DecayChainVertex* pOriginalVertex, const ::DecayChainVertex* pProxyVertex );
181 TrackingVertex* getTrackingVertex( const ::DecayChainVertex* pDecayVertex );
185 void associateToExistingObjects( const ::DecayChainVertex* pChainVertex );
186 void associateToExistingObjects( const ::DecayChainTrack* pChainTrack );
188 std::vector<int> trackingParticleIndices_;
189 std::vector<int> trackingVertexIndices_;
202 void addTrack( ::DecayChainTrack* pDecayChainTrack,
const TrackingParticleSelector* pSelector, ::OutputCollectionWrapper* pUnmergedOutput, ::OutputCollectionWrapper* pMergedOutput, const ::TrackingParticleFactory& objectFactory,
bool addAncestors,
const TrackerTopology *tTopo);
221 messageCategory_(
"TrackingTruthAccumulator"),
222 volumeRadius_( config.getParameter<double>(
"volumeRadius") ),
223 volumeZ_( config.getParameter<double>(
"volumeZ") ),
224 vertexDistanceCut_( config.getParameter<double>(
"vertexDistanceCut") ),
225 ignoreTracksOutsideVolume_( config.getParameter<bool>(
"ignoreTracksOutsideVolume") ),
226 maximumPreviousBunchCrossing_( config.getParameter<unsigned int>(
"maximumPreviousBunchCrossing") ),
227 maximumSubsequentBunchCrossing_( config.getParameter<unsigned int>(
"maximumSubsequentBunchCrossing") ),
228 createUnmergedCollection_( config.getParameter<bool>(
"createUnmergedCollection") ),
229 createMergedCollection_(config.getParameter<bool>(
"createMergedBremsstrahlung") ),
230 createInitialVertexCollection_(config.getParameter<bool>(
"createInitialVertexCollection") ),
231 addAncestors_( config.getParameter<bool>(
"alwaysAddAncestors") ),
232 removeDeadModules_( config.getParameter<bool>(
"removeDeadModules") ),
233 simTrackLabel_( config.getParameter<edm::
InputTag>(
"simTrackCollection") ),
234 simVertexLabel_( config.getParameter<edm::
InputTag>(
"simVertexCollection") ),
236 genParticleLabel_( config.getParameter<edm::
InputTag>(
"genParticleCollection") ),
237 hepMCproductLabel_( config.getParameter<edm::
InputTag>(
"HepMCProductLabel") ),
238 allowDifferentProcessTypeForDifferentDetectors_( config.getParameter<bool>(
"allowDifferentSimHitProcesses") )
246 <<
"set to false, which means no collections will be created";
250 if( config.
exists(
"select" ) )
308 std::vector<std::string> parameterNames=simHitCollectionConfig.
getParameterNames();
310 for(
const auto& parameterName : parameterNames )
312 std::vector<edm::InputTag>
tags=simHitCollectionConfig.getParameter<std::vector<edm::InputTag> >(parameterName);
317 iC.
consumes<std::vector<PSimHit> >(collectionTag);
381 <<
" TrackingVertexs to the event.";
390 <<
" merged TrackingVertexs to the event.";
444 DecayChain decayChain( *hSimTracks, *hSimVertices );
447 std::auto_ptr< ::OutputCollectionWrapper> pUnmergedCollectionWrapper;
448 std::auto_ptr< ::OutputCollectionWrapper> pMergedCollectionWrapper;
452 std::vector<const PSimHit*> simHitPointers;
470 ::DecayChainTrack* pDecayTrack=&decayChain.decayTracks[
index];
471 const SimTrack& simTrack=hSimTracks->at(pDecayTrack->simTrackIndex);
484 const SimVertex& simVertex=hSimVertices->at( pDecayTrack->pParentVertex->simVertexIndex );
485 if( !objectFactory.vectorIsInsideVolume( simVertex.
position() ) )
continue;
492 ::addTrack( pDecayTrack, pSelector, pUnmergedCollectionWrapper.get(), pMergedCollectionWrapper.get(), objectFactory,
addAncestors_, tTopo );
504 for(
const auto& pRootVertex : decayChain.rootVertices )
506 const SimVertex& vertex=hSimVertices->at(decayChain.rootVertices[0]->simVertexIndex);
507 if( vertex.
vertexId()!=0 )
continue;
521 event.getByLabel( collectionTag, hSimHits );
524 for(
const auto& simHit : *hSimHits )
526 returnValue.push_back( &simHit );
555 ::TrackingParticleFactory::TrackingParticleFactory( const ::DecayChain& decayChain,
const edm::Handle< std::vector<reco::GenParticle> >& hGenParticles,
557 double volumeRadius,
double volumeZ,
double vertexDistanceCut,
bool allowDifferentProcessTypes )
558 : decayChain_(decayChain), hGenParticles_(hGenParticles), hepMCproduct_(hepMCproduct), simHits_(simHits), volumeRadius_(volumeRadius),
559 volumeZ_(volumeZ), vertexDistanceCut2_(vertexDistanceCut*vertexDistanceCut), allowDifferentProcessTypeForDifferentDetectors_(allowDifferentProcessTypes)
565 trackIdToHitIndex_.insert( std::make_pair( simHits_[
index]->trackId(),
index ) );
568 if( hHepMCGenParticleIndices.isValid() )
570 genParticleIndices_.resize( hHepMCGenParticleIndices->size()+1 );
574 for(
size_t recoGenParticleIndex=0; recoGenParticleIndex<hHepMCGenParticleIndices->size(); ++recoGenParticleIndex )
576 size_t hepMCGenParticleIndex=(*hHepMCGenParticleIndices)[recoGenParticleIndex];
579 if( genParticleIndices_.size()<=hepMCGenParticleIndex ) genParticleIndices_.resize(hepMCGenParticleIndex+1);
581 genParticleIndices_[ hepMCGenParticleIndex ]=recoGenParticleIndex;
591 const SimTrack& simTrack=decayChain_.getSimTrack( pChainTrack );
592 const SimVertex& parentSimVertex=decayChain_.getSimVertex( pChainTrack->pParentVertex );
594 LorentzVector
position( 0, 0, 0, 0 );
611 if( hepMCGenParticleIndex>=0 && hepMCGenParticleIndex<static_cast<int>(genParticleIndices_.size()) && hGenParticles_.isValid() )
613 int recoGenParticleIndex=genParticleIndices_[hepMCGenParticleIndex];
615 pdgId=generatorParticleRef->pdgId();
625 size_t matchedHits=0;
626 size_t numberOfHits=0;
627 size_t numberOfTrackerHits=0;
637 for( std::multimap<unsigned int,size_t>::const_iterator iHitIndex=trackIdToHitIndex_.lower_bound( simTrack.
trackId() );
638 iHitIndex!=trackIdToHitIndex_.upper_bound( simTrack.
trackId() );
641 const auto& pSimHit=simHits_[ iHitIndex->second ];
646 processType=pSimHit->processType();
647 particleType=pSimHit->particleType();
648 newDetector=
DetId( pSimHit->detUnitId() );
652 oldDetector=newDetector;
653 newDetector=
DetId( pSimHit->detUnitId() );
657 if( allowDifferentProcessTypeForDifferentDetectors_ && newDetector.
det()!=oldDetector.
det() ) processType=pSimHit->processType();
660 if( processType==pSimHit->processType() && particleType==pSimHit->particleType() && pdgId==pSimHit->particleType() )
666 ++numberOfTrackerHits;
668 newLayer=tTopo->
layer( newDetector );
671 if( (oldLayer!=newLayer || (oldLayer==newLayer && oldDetector.
subdetId()!=newDetector.
subdetId())) ) ++matchedHits;
683 TrackingVertex TrackingParticleFactory::createTrackingVertex( const ::DecayChainVertex* pChainVertex)
const
690 const SimVertex& simVertex=decayChain_.getSimVertex( pChainVertex );
692 bool isInVolume=this->vectorIsInsideVolume( simVertex.
position() );
697 returnValue.addG4Vertex(simVertex);
702 const HepMC::GenEvent*
genEvent = hepMCproduct_->GetEvent();
704 if (genEvent !=
NULL)
706 Vector tvPosition(returnValue.position().x(), returnValue.position().
y(), returnValue.position().z());
708 for (HepMC::GenEvent::vertex_const_iterator iGenVertex = genEvent->vertices_begin(); iGenVertex != genEvent->vertices_end(); ++iGenVertex)
710 HepMC::ThreeVector rawPosition = (*iGenVertex)->position();
712 Vector genPosition(rawPosition.x()*0.1, rawPosition.y()*0.1, rawPosition.z()*0.1);
714 auto distance2 = (tvPosition - genPosition).
mag2();
716 if (distance2 < vertexDistanceCut2_)
717 returnValue.addGenVertex(
GenVertexRef(hepMCproduct_, (*iGenVertex)->barcode()) );
727 return ( vector.Pt()<volumeRadius_ &&
std::abs( vector.z() )<volumeZ_ );
737 : decayTracksSize( trackCollection.
size() ),
738 decayVerticesSize( vertexCollection.
size() ),
739 decayTracks_( new DecayChainTrack[decayTracksSize] ),
740 decayVertices_( new DecayChainVertex[decayVerticesSize] ),
741 simTrackCollection_( trackCollection ),
742 simVertexCollection_( vertexCollection ),
743 decayTracks( decayTracks_ ),
744 decayVertices( decayVertices_ ),
745 rootVertices( rootVertices_ )
748 std::map<int,::DecayChainTrack*> trackIdToDecayTrack;
749 std::map<int,::DecayChainVertex*> vertexIdToDecayVertex;
755 size_t decayVertexIndex=0;
758 ::DecayChainTrack* pDecayTrack=&decayTracks_[
index];
763 pDecayTrack->simTrackIndex=
index;
765 trackIdToDecayTrack[ trackCollection[
index].trackId() ]=pDecayTrack;
767 int parentVertexIndex=trackCollection[
index].vertIndex();
768 if( parentVertexIndex>=0 )
771 ::DecayChainVertex*& pParentVertex=vertexIdToDecayVertex[parentVertexIndex];
772 if( pParentVertex==
NULL )
775 pParentVertex=&decayVertices_[decayVertexIndex];
777 pParentVertex->simVertexIndex=parentVertexIndex;
779 pParentVertex->daughterTracks.push_back(pDecayTrack);
780 pDecayTrack->pParentVertex=pParentVertex;
782 else throw std::runtime_error(
"TrackingTruthAccumulator: Found a track with an invalid parent vertex index." );
794 for(
auto& decayVertexMapPair : vertexIdToDecayVertex )
796 ::DecayChainVertex* pDecayVertex=decayVertexMapPair.second;
797 int parentTrackIndex=vertexCollection[pDecayVertex->simVertexIndex].parentIndex();
798 if( parentTrackIndex!=-1 )
800 std::map<int,::DecayChainTrack*>::iterator iParentTrackMapPair=trackIdToDecayTrack.find(parentTrackIndex);
801 if( iParentTrackMapPair==trackIdToDecayTrack.end() )
803 std::stringstream errorStream;
804 errorStream <<
"TrackingTruthAccumulator: Something has gone wrong with the indexing. Parent track index is " << parentTrackIndex <<
".";
805 throw std::runtime_error( errorStream.str() );
808 ::DecayChainTrack* pParentTrackHierarchy=iParentTrackMapPair->second;
810 pParentTrackHierarchy->daughterVertices.push_back( pDecayVertex );
811 pDecayVertex->pParentTrack=pParentTrackHierarchy;
813 else rootVertices_.push_back(pDecayVertex);
816 findBrem( trackCollection, vertexCollection );
821 void ::DecayChain::integrityCheck()
828 const auto& decayTrack=decayTracks[
index];
832 if( decayTrack.pParentVertex==
NULL )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack with no parent vertex." );
837 size_t numberOfTimesListed=0;
838 for(
const auto pSiblingTrack : decayTrack.pParentVertex->daughterTracks )
840 if( pSiblingTrack==&decayTrack ) ++numberOfTimesListed;
842 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." );
847 for(
const auto pDaughterVertex : decayTrack.daughterVertices )
849 if( pDaughterVertex->pParentTrack!=&decayTrack )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack whose child does not have it listed as the parent." );
855 const DecayChainVertex* pAncestorVertex=decayTrack.pParentVertex;
856 while( pAncestorVertex->pParentTrack!=
NULL )
858 if( pAncestorVertex->pParentTrack->pParentVertex==
NULL )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack with no parent vertex higher in the decay chain." );
859 pAncestorVertex=pAncestorVertex->pParentTrack->pParentVertex;
861 if(
std::find( rootVertices.begin(), rootVertices.end(), pAncestorVertex )==rootVertices.end() )
863 throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack whose root vertex is not recorded anywhere." );
872 const auto& decayVertex=decayVertices[
index];
877 const DecayChainVertex* pAncestorVertex=&decayVertex;
878 while( pAncestorVertex->pParentTrack!=
NULL )
880 if( pAncestorVertex->pParentTrack->pParentVertex==
NULL )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack with no parent vertex higher in the vertex decay chain." );
881 pAncestorVertex=pAncestorVertex->pParentTrack->pParentVertex;
883 if(
std::find( rootVertices.begin(), rootVertices.end(), pAncestorVertex )==rootVertices.end() )
885 throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack whose root vertex is not recorded anywhere." );
891 if( decayVertex.pParentTrack!=
NULL )
893 size_t numberOfTimesListed=0;
894 for(
const auto pSibling : decayVertex.pParentTrack->daughterVertices )
896 if( pSibling==&decayVertex ) ++numberOfTimesListed;
898 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." );
904 for(
const auto pDaughter : decayVertex.daughterTracks )
906 if( pDaughter->pParentVertex!=&decayVertex )
throw std::runtime_error(
"TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainVertex whose child does not have it listed as the parent." );
910 std::cout <<
"TrackingTruthAccumulator.cc integrityCheck() completed successfully" << std::endl;
913 void ::DecayChain::findBrem(
const std::vector<SimTrack>& trackCollection,
const std::vector<SimVertex>& vertexCollection )
917 auto& vertex=decayVertices_[
index];
920 if( vertex.pParentTrack==
NULL )
continue;
921 int parentTrackPDG=trackCollection[vertex.pParentTrack->simTrackIndex].type();
922 if(
std::abs( parentTrackPDG )!=11 )
continue;
924 size_t numberOfElectrons=0;
925 size_t numberOfNonElectronsOrPhotons=0;
926 for(
auto& pDaughterTrack : vertex.daughterTracks )
928 const auto& simTrack=trackCollection[pDaughterTrack->simTrackIndex];
929 if( simTrack.
type()==11 || simTrack.
type()==-11 ) ++numberOfElectrons;
930 else if( simTrack.
type()!=22 ) ++numberOfNonElectronsOrPhotons;
932 if( numberOfElectrons==1 && numberOfNonElectronsOrPhotons==0 )
936 for(
auto& pDaughterTrack : vertex.daughterTracks ) pDaughterTrack->pMergedBremSource=vertex.pParentTrack;
937 vertex.pMergedBremSource=vertex.pParentTrack->pParentVertex;
950 : output_(outputCollections),
951 trackingParticleIndices_(decayChain.decayTracksSize,-1),
952 trackingVertexIndices_(decayChain.decayVerticesSize,-1)
959 if( trackingParticleIndices_[pDecayTrack->simTrackIndex]!=-1 )
throw std::runtime_error(
"OutputCollectionWrapper::addTrackingParticle - trying to add a particle twice" );
961 trackingParticleIndices_[pDecayTrack->simTrackIndex]=output_.pTrackingParticles->size();
962 output_.pTrackingParticles->push_back( trackingParticle );
965 output_.pTrackingParticles->back().clearDecayVertices();
966 output_.pTrackingParticles->back().clearParentVertex();
969 associateToExistingObjects( pDecayTrack );
971 return &output_.pTrackingParticles->back();
974 TrackingVertex* ::OutputCollectionWrapper::addTrackingVertex( const ::DecayChainVertex* pDecayVertex,
const TrackingVertex& trackingVertex )
976 if( trackingVertexIndices_[pDecayVertex->simVertexIndex]!=-1 )
throw std::runtime_error(
"OutputCollectionWrapper::addTrackingVertex - trying to add a vertex twice" );
978 trackingVertexIndices_[pDecayVertex->simVertexIndex]=output_.pTrackingVertices->size();
979 output_.pTrackingVertices->push_back( trackingVertex );
982 associateToExistingObjects( pDecayVertex );
984 return &output_.pTrackingVertices->back();
987 TrackingParticle* ::OutputCollectionWrapper::getTrackingParticle( const ::DecayChainTrack* pDecayTrack )
989 const int index=trackingParticleIndices_[pDecayTrack->simTrackIndex];
990 if( index==-1 )
return NULL;
991 else return &(*output_.pTrackingParticles)[index];
994 TrackingVertex* ::OutputCollectionWrapper::getTrackingVertex( const ::DecayChainVertex* pDecayVertex )
996 const int index=trackingVertexIndices_[pDecayVertex->simVertexIndex];
997 if( index==-1 )
return NULL;
998 else return &(*output_.pTrackingVertices)[index];
1003 const int index=trackingParticleIndices_[pDecayTrack->simTrackIndex];
1004 if( index==-1 )
throw std::runtime_error(
"OutputCollectionWrapper::getRefTrackingParticle - ref requested for a non existent TrackingParticle" );
1010 const int index=trackingVertexIndices_[pDecayVertex->simVertexIndex];
1011 if( index==-1 )
throw std::runtime_error(
"OutputCollectionWrapper::getRefTrackingParticle - ref requested for a non existent TrackingVertex" );
1015 void ::OutputCollectionWrapper::setProxy( const ::DecayChainTrack* pOriginalTrack, const ::DecayChainTrack* pProxyTrack )
1017 int& index=trackingParticleIndices_[pOriginalTrack->simTrackIndex];
1018 if( index!=-1 )
throw std::runtime_error(
"OutputCollectionWrapper::setProxy() was called for a TrackingParticle that has already been created" );
1020 index=trackingParticleIndices_[pProxyTrack->simTrackIndex];
1023 void ::OutputCollectionWrapper::setProxy( const ::DecayChainVertex* pOriginalVertex, const ::DecayChainVertex* pProxyVertex )
1025 int& index=trackingVertexIndices_[pOriginalVertex->simVertexIndex];
1026 const int newIndex=trackingVertexIndices_[pProxyVertex->simVertexIndex];
1028 if( index!=-1 && index!=newIndex )
throw std::runtime_error(
"OutputCollectionWrapper::setProxy() was called for a TrackingVertex that has already been created" );
1034 void ::OutputCollectionWrapper::associateToExistingObjects( const ::DecayChainVertex* pChainVertex )
1037 TrackingVertex* pTrackingVertex=getTrackingVertex( pChainVertex );
1038 if( pTrackingVertex==
NULL )
throw std::runtime_error(
"associateToExistingObjects was passed a non existent TrackingVertex" );
1043 ::DecayChainTrack* pParentChainTrack=pChainVertex->pParentTrack;
1044 if( pParentChainTrack!=
NULL )
1047 TrackingParticle* pParentTrackingParticle=getTrackingParticle(pParentChainTrack);
1048 if( pParentTrackingParticle!=
NULL )
1065 void ::OutputCollectionWrapper::associateToExistingObjects( const ::DecayChainTrack* pChainTrack )
1071 if( pTrackingParticle==
NULL )
throw std::runtime_error(
"associateToExistingObjects was passed a non existent TrackingParticle" );
1075 ::DecayChainVertex* pParentChainVertex=pChainTrack->pParentVertex;
1076 TrackingVertex* pParentTrackingVertex=getTrackingVertex( pParentChainVertex );
1088 for(
auto pDaughterChainVertex : pChainTrack->daughterVertices )
1090 TrackingVertex* pDaughterTrackingVertex=getTrackingVertex( pDaughterChainVertex );
1091 if( pDaughterTrackingVertex!=
NULL )
1104 TrackingParticle* pTrackingParticle=pOutput->getTrackingParticle( pDecayTrack );
1105 if( pTrackingParticle==
NULL )
1108 if( pOutput->getTrackingVertex( pDecayTrack->pParentVertex ) ==
nullptr )
1115 pOutput->addTrackingVertex( pDecayTrack->pParentVertex, *trackingParticle.
parentVertex() );
1119 pTrackingParticle=pOutput->addTrackingParticle( pDecayTrack, trackingParticle );
1122 return pTrackingParticle;
1125 void addTrack( ::DecayChainTrack* pDecayChainTrack,
const TrackingParticleSelector* pSelector, ::OutputCollectionWrapper* pUnmergedOutput, ::OutputCollectionWrapper* pMergedOutput, const ::TrackingParticleFactory& objectFactory,
bool addAncestors,
const TrackerTopology *tTopo )
1127 if( pDecayChainTrack==
NULL )
return;
1133 bool alreadyProcessed=
true;
1134 if( pUnmergedOutput!=
NULL )
1136 if( pUnmergedOutput->getTrackingParticle( pDecayChainTrack )==
NULL ) alreadyProcessed=
false;
1138 if( pMergedOutput!=
NULL )
1140 if( pMergedOutput->getTrackingParticle( pDecayChainTrack )==
NULL ) alreadyProcessed=
false;
1142 if( alreadyProcessed )
return;
1146 TrackingParticle newTrackingParticle=objectFactory.createTrackingParticle( pDecayChainTrack, tTopo );
1156 dummyCollection.push_back( objectFactory.createTrackingVertex( pDecayChainTrack->pParentVertex) );
1163 if( !(*pSelector)( newTrackingParticle ) )
return;
1170 if( addAncestors ) addTrack( pDecayChainTrack->pParentVertex->pParentTrack,
NULL, pUnmergedOutput, pMergedOutput, objectFactory, addAncestors, tTopo );
1174 if( pUnmergedOutput!=
NULL ) addTrackAndParentVertex( pDecayChainTrack, newTrackingParticle, pUnmergedOutput );
1178 if( pMergedOutput!=
NULL )
1180 ::DecayChainTrack* pBremParentChainTrack=pDecayChainTrack;
1181 while( pBremParentChainTrack->pMergedBremSource!=
NULL ) pBremParentChainTrack=pBremParentChainTrack->pMergedBremSource;
1183 if( pBremParentChainTrack!=pDecayChainTrack )
1185 TrackingParticle* pBremParentTrackingParticle=addTrackAndParentVertex( pBremParentChainTrack, newTrackingParticle, pMergedOutput );
1198 pMergedOutput->setProxy( pDecayChainTrack->pParentVertex, pBremParentChainTrack->pParentVertex );
1203 addTrackAndParentVertex( pDecayChainTrack, newTrackingParticle, pMergedOutput );
1208 for(
const auto& trackSegment : newTrackingParticle.
g4Tracks() )
1210 pBremParentTrackingParticle->
addG4Track( trackSegment );
1214 for(
const auto& genParticleRef : newTrackingParticle.
genParticles() )
1225 pMergedOutput->setProxy( pDecayChainTrack, pBremParentChainTrack );
1231 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?)
const std::vector< SimTrack > & g4Tracks() const
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
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 &)
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
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
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
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
std::auto_ptr< TrackingVertexCollection > pInitialVertices_
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
std::auto_ptr< TrackingVertexCollection > pTrackingVertices
XYZPointD XYZPoint
point in space with cartesian internal representation
void addDecayVertex(const TrackingVertexRef &ref)
std::vector< TrackingVertex > TrackingVertexCollection
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)
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_