76 struct DecayChainTrack {
78 struct DecayChainVertex *pParentVertex;
81 std::vector<struct DecayChainVertex *> daughterVertices;
82 DecayChainTrack *pMergedBremSource;
83 DecayChainTrack() : simTrackIndex(-1), pParentVertex(
nullptr), pMergedBremSource(
nullptr) {}
84 DecayChainTrack(
int newSimTrackIndex)
85 : simTrackIndex(newSimTrackIndex), pParentVertex(
nullptr), pMergedBremSource() {}
93 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) {}
117 const size_t decayTracksSize;
118 const size_t decayVerticesSize;
120 #if defined(DO_DEBUG_TESTING) 127 void integrityCheck();
129 const SimTrack &getSimTrack(const ::DecayChainTrack *pDecayTrack)
const {
130 return simTrackCollection_.at(pDecayTrack->simTrackIndex);
132 const SimVertex &getSimVertex(const ::DecayChainVertex *pDecayVertex)
const {
133 return simVertexCollection_.at(pDecayVertex->simVertexIndex);
138 std::unique_ptr<::DecayChainTrack[]> decayTracks_;
139 std::unique_ptr<::DecayChainVertex[]> decayVertices_;
143 std::vector<::DecayChainVertex *> rootVertices_;
146 const std::vector<SimTrack> &simTrackCollection_;
147 const std::vector<SimVertex> &simVertexCollection_;
150 const std::unique_ptr<::DecayChainTrack[]> &decayTracks;
151 const std::unique_ptr<::DecayChainVertex[]> &decayVertices;
153 const std::vector<::DecayChainVertex *> &rootVertices;
162 class TrackingParticleFactory {
165 const edm::Handle<std::vector<reco::GenParticle>> &hGenParticles,
167 const edm::Handle<std::vector<int>> &hHepMCGenParticleIndices,
168 const std::vector<const PSimHit *> &
simHits,
172 bool allowDifferentProcessTypes);
174 TrackingVertex createTrackingVertex(
const DecayChainVertex *pVertex)
const;
181 std::vector<int> genParticleIndices_;
182 const std::vector<const PSimHit *> &simHits_;
183 const double volumeRadius_;
184 const double volumeZ_;
185 const double vertexDistanceCut2_;
187 std::multimap<unsigned int, size_t> trackIdToHitIndex_;
188 bool allowDifferentProcessTypeForDifferentDetectors_;
199 class OutputCollectionWrapper {
201 OutputCollectionWrapper(
const DecayChain &decayChain,
206 TrackingParticle *getTrackingParticle(const ::DecayChainTrack *pDecayTrack);
209 void setProxy(const ::DecayChainTrack *pOriginalTrack, const ::DecayChainTrack *pProxyTrack);
210 void setProxy(const ::DecayChainVertex *pOriginalVertex, const ::DecayChainVertex *pProxyVertex);
211 TrackingVertex *getTrackingVertex(const ::DecayChainVertex *pDecayVertex);
216 void associateToExistingObjects(const ::DecayChainVertex *pChainVertex);
217 void associateToExistingObjects(const ::DecayChainTrack *pChainTrack);
219 std::vector<int> trackingParticleIndices_;
220 std::vector<int> trackingVertexIndices_;
230 ::OutputCollectionWrapper *pOutput);
238 void addTrack(::DecayChainTrack *pDecayChainTrack,
240 ::OutputCollectionWrapper *pUnmergedOutput,
241 ::OutputCollectionWrapper *pMergedOutput,
242 const ::TrackingParticleFactory &objectFactory,
262 : messageCategory_(
"TrackingTruthAccumulator"),
263 volumeRadius_(config.getParameter<double>(
"volumeRadius")),
264 volumeZ_(config.getParameter<double>(
"volumeZ")),
265 vertexDistanceCut_(config.getParameter<double>(
"vertexDistanceCut")),
266 ignoreTracksOutsideVolume_(config.getParameter<
bool>(
"ignoreTracksOutsideVolume")),
267 maximumPreviousBunchCrossing_(config.getParameter<unsigned
int>(
"maximumPreviousBunchCrossing")),
268 maximumSubsequentBunchCrossing_(config.getParameter<unsigned
int>(
"maximumSubsequentBunchCrossing")),
269 createUnmergedCollection_(config.getParameter<
bool>(
"createUnmergedCollection")),
270 createMergedCollection_(config.getParameter<
bool>(
"createMergedBremsstrahlung")),
271 createInitialVertexCollection_(config.getParameter<
bool>(
"createInitialVertexCollection")),
272 addAncestors_(config.getParameter<
bool>(
"alwaysAddAncestors")),
273 removeDeadModules_(config.getParameter<
bool>(
"removeDeadModules")),
274 simTrackLabel_(config.getParameter<
edm::InputTag>(
"simTrackCollection")),
275 simVertexLabel_(config.getParameter<
edm::InputTag>(
"simVertexCollection")),
277 genParticleLabel_(config.getParameter<
edm::InputTag>(
"genParticleCollection")),
278 hepMCproductLabel_(config.getParameter<
edm::InputTag>(
"HepMCProductLabel")),
279 allowDifferentProcessTypeForDifferentDetectors_(config.getParameter<
bool>(
"allowDifferentSimHitProcesses")) {
286 "\"createMergedBremsstrahlung\" have been" 287 <<
"set to false, which means no collections will be created";
291 if (config.
exists(
"select")) {
345 std::vector<std::string> parameterNames = simHitCollectionConfig.
getParameterNames();
347 for (
const auto ¶meterName : parameterNames) {
348 std::vector<edm::InputTag> tags = simHitCollectionConfig.getParameter<std::vector<edm::InputTag>>(parameterName);
353 iC.
consumes<std::vector<PSimHit>>(collectionTag);
362 const_cast<edm::Event &
>(
event).getRefBeforePut<TrackingParticleCollection>();
370 const_cast<edm::Event &
>(
event).getRefBeforePut<TrackingParticleCollection>(
"MergedTrackTruth");
372 const_cast<edm::Event &
>(
event).getRefBeforePut<TrackingVertexCollection>(
"MergedTrackTruth");
435 <<
"Adding " <<
pInitialVertices_->size() <<
" initial TrackingVertexs to the event.";
479 DecayChain decayChain(*hSimTracks, *hSimVertices);
482 std::unique_ptr<::OutputCollectionWrapper> pUnmergedCollectionWrapper;
483 std::unique_ptr<::OutputCollectionWrapper> pMergedCollectionWrapper;
485 pUnmergedCollectionWrapper.reset(new ::OutputCollectionWrapper(decayChain,
unmergedOutput_));
487 pMergedCollectionWrapper.reset(new ::OutputCollectionWrapper(decayChain,
mergedOutput_));
489 std::vector<const PSimHit *> simHitPointers;
491 TrackingParticleFactory objectFactory(decayChain,
501 #if defined(DO_DEBUG_TESTING) 504 decayChain.integrityCheck();
517 ::DecayChainTrack *pDecayTrack = &decayChain.decayTracks[
index];
533 const SimVertex &
simVertex = hSimVertices->at(pDecayTrack->pParentVertex->simVertexIndex);
534 if (!objectFactory.vectorIsInsideVolume(simVertex.
position()))
542 ::addTrack(pDecayTrack,
544 pUnmergedCollectionWrapper.get(),
545 pMergedCollectionWrapper.get(),
560 for (
const auto &pRootVertex : decayChain.rootVertices) {
561 const SimVertex &vertex = hSimVertices->at(decayChain.rootVertices[0]->simVertexIndex);
578 event.getByLabel(collectionTag, hSimHits);
581 for (
const auto &
simHit : *hSimHits) {
582 returnValue.push_back(&
simHit);
594 edm::isFinite(
b->timeOfFlight()) ?
b->timeOfFlight() : std::numeric_limits<decltype(
b->timeOfFlight())>::
max();
624 const edm::Handle<std::vector<reco::GenParticle>> &hGenParticles,
626 const edm::Handle<std::vector<int>> &hHepMCGenParticleIndices,
627 const std::vector<const PSimHit *> &
simHits,
631 bool allowDifferentProcessTypes)
632 : decayChain_(decayChain),
633 hGenParticles_(hGenParticles),
634 hepMCproduct_(hepMCproduct),
638 vertexDistanceCut2_(vertexDistanceCut * vertexDistanceCut),
643 trackIdToHitIndex_.insert(std::make_pair(simHits_[
index]->trackId(),
index));
646 if (hHepMCGenParticleIndices.isValid())
649 genParticleIndices_.resize(hHepMCGenParticleIndices->size() + 1);
653 for (
size_t recoGenParticleIndex = 0; recoGenParticleIndex < hHepMCGenParticleIndices->size();
654 ++recoGenParticleIndex) {
655 size_t hepMCGenParticleIndex = (*hHepMCGenParticleIndices)[recoGenParticleIndex];
659 if (genParticleIndices_.size() <= hepMCGenParticleIndex)
660 genParticleIndices_.resize(hepMCGenParticleIndex + 1);
662 genParticleIndices_[hepMCGenParticleIndex] = recoGenParticleIndex;
667 TrackingParticle TrackingParticleFactory::createTrackingParticle(const ::DecayChainTrack *pChainTrack,
673 const SimVertex &parentSimVertex = decayChain_.getSimVertex(pChainTrack->pParentVertex);
677 position = parentSimVertex.
position();
694 if (hepMCGenParticleIndex >= 0 && hepMCGenParticleIndex < static_cast<int>(genParticleIndices_.size()) &&
695 hGenParticles_.isValid()) {
696 int recoGenParticleIndex = genParticleIndices_[hepMCGenParticleIndex];
698 pdgId = generatorParticleRef->pdgId();
709 size_t matchedHits = 0;
711 size_t numberOfHits = 0;
712 size_t numberOfTrackerHits = 0;
728 for (
auto iHitIndex = trackIdToHitIndex_.lower_bound(simTrack.
trackId()),
729 end = trackIdToHitIndex_.upper_bound(simTrack.
trackId());
732 const auto &pSimHit = simHits_[iHitIndex->second];
735 if (pSimHit->particleType() !=
pdgId)
740 processType = pSimHit->processType();
741 particleType = pSimHit->particleType();
742 newDetector =
DetId(pSimHit->detUnitId());
746 oldDetector = newDetector;
747 newDetector =
DetId(pSimHit->detUnitId());
753 processType = pSimHit->processType();
756 if (processType == pSimHit->processType() && particleType == pSimHit->particleType()) {
761 ++numberOfTrackerHits;
763 newLayer = tTopo->
layer(newDetector);
766 if ((oldLayer != newLayer || (oldLayer == newLayer && oldDetector.
subdetId() != newDetector.
subdetId())))
779 TrackingVertex TrackingParticleFactory::createTrackingVertex(const ::DecayChainVertex *pChainVertex)
const {
786 bool isInVolume = this->vectorIsInsideVolume(simVertex.
position());
796 hepMCproduct_.isValid())
800 if (genEvent !=
nullptr) {
801 Vector tvPosition(returnValue.position().x(), returnValue.position().y(), returnValue.position().z());
803 for (HepMC::GenEvent::vertex_const_iterator iGenVertex = genEvent->vertices_begin();
804 iGenVertex != genEvent->vertices_end();
806 HepMC::ThreeVector rawPosition = (*iGenVertex)->position();
808 Vector genPosition(rawPosition.x() * 0.1, rawPosition.y() * 0.1, rawPosition.z() * 0.1);
810 auto distance2 = (tvPosition - genPosition).
mag2();
812 if (distance2 < vertexDistanceCut2_)
813 returnValue.addGenVertex(
GenVertexRef(hepMCproduct_, (*iGenVertex)->barcode()));
833 : decayTracksSize(trackCollection.size()),
834 decayVerticesSize(vertexCollection.size()),
835 decayTracks_(
new DecayChainTrack[decayTracksSize]),
836 decayVertices_(
new DecayChainVertex[decayVerticesSize]),
837 simTrackCollection_(trackCollection),
838 simVertexCollection_(vertexCollection),
839 decayTracks(decayTracks_),
841 decayVertices(decayVertices_),
842 rootVertices(rootVertices_) {
844 std::map<int, ::DecayChainTrack *> trackIdToDecayTrack;
845 std::map<int, ::DecayChainVertex *> vertexIdToDecayVertex;
851 size_t decayVertexIndex = 0;
853 ::DecayChainTrack *pDecayTrack = &decayTracks_[
index];
859 pDecayTrack->simTrackIndex =
index;
861 trackIdToDecayTrack[trackCollection[
index].trackId()] = pDecayTrack;
863 int parentVertexIndex = trackCollection[
index].vertIndex();
864 if (parentVertexIndex >= 0) {
867 ::DecayChainVertex *&pParentVertex = vertexIdToDecayVertex[parentVertexIndex];
868 if (pParentVertex ==
nullptr) {
871 pParentVertex = &decayVertices_[decayVertexIndex];
873 pParentVertex->simVertexIndex = parentVertexIndex;
875 pParentVertex->daughterTracks.push_back(pDecayTrack);
876 pDecayTrack->pParentVertex = pParentVertex;
878 throw std::runtime_error(
879 "TrackingTruthAccumulator: Found a track with " 880 "an invalid parent vertex index.");
895 for (
auto &decayVertexMapPair : vertexIdToDecayVertex) {
896 ::DecayChainVertex *pDecayVertex = decayVertexMapPair.second;
897 int parentTrackIndex = vertexCollection[pDecayVertex->simVertexIndex].parentIndex();
898 if (parentTrackIndex != -1) {
899 std::map<int, ::DecayChainTrack *>::iterator iParentTrackMapPair = trackIdToDecayTrack.find(parentTrackIndex);
900 if (iParentTrackMapPair == trackIdToDecayTrack.end()) {
901 std::stringstream errorStream;
902 errorStream <<
"TrackingTruthAccumulator: Something has gone wrong " 903 "with the indexing. Parent track index is " 904 << parentTrackIndex <<
".";
905 throw std::runtime_error(errorStream.str());
908 ::DecayChainTrack *pParentTrackHierarchy = iParentTrackMapPair->second;
910 pParentTrackHierarchy->daughterVertices.push_back(pDecayVertex);
911 pDecayVertex->pParentTrack = pParentTrackHierarchy;
913 rootVertices_.push_back(pDecayVertex);
916 findBrem(trackCollection, vertexCollection);
920 #if defined(DO_DEBUG_TESTING) 923 void ::DecayChain::integrityCheck() {
928 const auto &decayTrack = decayTracks[
index];
932 if (decayTrack.pParentVertex ==
NULL)
933 throw std::runtime_error(
934 "TrackingTruthAccumulator.cc integrityCheck(): " 935 "Found DecayChainTrack with no parent vertex.");
941 size_t numberOfTimesListed = 0;
942 for (
const auto pSiblingTrack : decayTrack.pParentVertex->daughterTracks) {
943 if (pSiblingTrack == &decayTrack)
944 ++numberOfTimesListed;
946 if (numberOfTimesListed != 1)
947 throw std::runtime_error(
948 "TrackingTruthAccumulator.cc integrityCheck(): " 949 "Found DecayChainTrack whose parent does not " 950 "have it listed once and only once as a child.");
955 for (
const auto pDaughterVertex : decayTrack.daughterVertices) {
956 if (pDaughterVertex->pParentTrack != &decayTrack)
957 throw std::runtime_error(
958 "TrackingTruthAccumulator.cc integrityCheck(): Found " 959 "DecayChainTrack whose child does not have it listed as the " 967 const DecayChainVertex *pAncestorVertex = decayTrack.pParentVertex;
968 while (pAncestorVertex->pParentTrack !=
NULL) {
969 if (pAncestorVertex->pParentTrack->pParentVertex ==
NULL)
970 throw std::runtime_error(
971 "TrackingTruthAccumulator.cc integrityCheck(): Found " 972 "DecayChainTrack with no parent vertex higher in the decay chain.");
973 pAncestorVertex = pAncestorVertex->pParentTrack->pParentVertex;
975 if (
std::find(rootVertices.begin(), rootVertices.end(), pAncestorVertex) == rootVertices.end()) {
976 throw std::runtime_error(
977 "TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack " 978 "whose root vertex is not recorded anywhere.");
986 const auto &decayVertex = decayVertices[
index];
992 const DecayChainVertex *pAncestorVertex = &decayVertex;
993 while (pAncestorVertex->pParentTrack !=
NULL) {
994 if (pAncestorVertex->pParentTrack->pParentVertex ==
NULL)
995 throw std::runtime_error(
996 "TrackingTruthAccumulator.cc integrityCheck(): Found " 997 "DecayChainTrack with no parent vertex higher in the vertex decay " 999 pAncestorVertex = pAncestorVertex->pParentTrack->pParentVertex;
1001 if (
std::find(rootVertices.begin(), rootVertices.end(), pAncestorVertex) == rootVertices.end()) {
1002 throw std::runtime_error(
1003 "TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack " 1004 "whose root vertex is not recorded anywhere.");
1010 if (decayVertex.pParentTrack !=
NULL) {
1011 size_t numberOfTimesListed = 0;
1012 for (
const auto pSibling : decayVertex.pParentTrack->daughterVertices) {
1013 if (pSibling == &decayVertex)
1014 ++numberOfTimesListed;
1016 if (numberOfTimesListed != 1)
1017 throw std::runtime_error(
1018 "TrackingTruthAccumulator.cc integrityCheck(): Found " 1019 "DecayChainVertex whose parent does not have it listed once and " 1020 "only once as a child.");
1026 for (
const auto pDaughter : decayVertex.daughterTracks) {
1027 if (pDaughter->pParentVertex != &decayVertex)
1028 throw std::runtime_error(
1029 "TrackingTruthAccumulator.cc integrityCheck(): Found " 1030 "DecayChainVertex whose child does not have it listed as the " 1035 std::cout <<
"TrackingTruthAccumulator.cc integrityCheck() completed successfully" << std::endl;
1039 void ::DecayChain::findBrem(
const std::vector<SimTrack> &trackCollection,
1040 const std::vector<SimVertex> &vertexCollection) {
1042 auto &vertex = decayVertices_[
index];
1045 if (vertex.pParentTrack ==
nullptr)
1047 int parentTrackPDG = trackCollection[vertex.pParentTrack->simTrackIndex].type();
1048 if (
std::abs(parentTrackPDG) != 11)
1051 size_t numberOfElectrons = 0;
1052 size_t numberOfNonElectronsOrPhotons = 0;
1053 for (
auto &pDaughterTrack : vertex.daughterTracks) {
1054 const auto &
simTrack = trackCollection[pDaughterTrack->simTrackIndex];
1056 ++numberOfElectrons;
1058 ++numberOfNonElectronsOrPhotons;
1060 if (numberOfElectrons == 1 && numberOfNonElectronsOrPhotons == 0) {
1063 for (
auto &pDaughterTrack : vertex.daughterTracks)
1064 pDaughterTrack->pMergedBremSource = vertex.pParentTrack;
1065 vertex.pMergedBremSource = vertex.pParentTrack->pParentVertex;
1079 : output_(outputCollections),
1080 trackingParticleIndices_(decayChain.decayTracksSize, -1),
1081 trackingVertexIndices_(decayChain.decayVerticesSize, -1) {
1085 TrackingParticle * ::OutputCollectionWrapper::addTrackingParticle(const ::DecayChainTrack *pDecayTrack,
1087 if (trackingParticleIndices_[pDecayTrack->simTrackIndex] != -1)
1088 throw std::runtime_error(
1089 "OutputCollectionWrapper::addTrackingParticle - " 1090 "trying to add a particle twice");
1092 trackingParticleIndices_[pDecayTrack->simTrackIndex] = output_.pTrackingParticles->size();
1093 output_.pTrackingParticles->push_back(trackingParticle);
1096 output_.pTrackingParticles->back().clearDecayVertices();
1097 output_.pTrackingParticles->back().clearParentVertex();
1100 associateToExistingObjects(pDecayTrack);
1102 return &output_.pTrackingParticles->back();
1105 TrackingVertex * ::OutputCollectionWrapper::addTrackingVertex(const ::DecayChainVertex *pDecayVertex,
1107 if (trackingVertexIndices_[pDecayVertex->simVertexIndex] != -1)
1108 throw std::runtime_error(
1109 "OutputCollectionWrapper::addTrackingVertex - " 1110 "trying to add a vertex twice");
1112 trackingVertexIndices_[pDecayVertex->simVertexIndex] = output_.pTrackingVertices->size();
1113 output_.pTrackingVertices->push_back(trackingVertex);
1117 associateToExistingObjects(pDecayVertex);
1119 return &output_.pTrackingVertices->back();
1122 TrackingParticle * ::OutputCollectionWrapper::getTrackingParticle(const ::DecayChainTrack *pDecayTrack) {
1123 const int index = trackingParticleIndices_[pDecayTrack->simTrackIndex];
1127 return &(*output_.pTrackingParticles)[index];
1130 TrackingVertex * ::OutputCollectionWrapper::getTrackingVertex(const ::DecayChainVertex *pDecayVertex) {
1131 const int index = trackingVertexIndices_[pDecayVertex->simVertexIndex];
1135 return &(*output_.pTrackingVertices)[index];
1139 const int index = trackingParticleIndices_[pDecayTrack->simTrackIndex];
1141 throw std::runtime_error(
1142 "OutputCollectionWrapper::getRefTrackingParticle - ref requested for a " 1143 "non existent TrackingParticle");
1149 const int index = trackingVertexIndices_[pDecayVertex->simVertexIndex];
1151 throw std::runtime_error(
1152 "OutputCollectionWrapper::getRefTrackingParticle - ref requested for a " 1153 "non existent TrackingVertex");
1158 void ::OutputCollectionWrapper::setProxy(const ::DecayChainTrack *pOriginalTrack,
1159 const ::DecayChainTrack *pProxyTrack) {
1160 int &
index = trackingParticleIndices_[pOriginalTrack->simTrackIndex];
1162 throw std::runtime_error(
1163 "OutputCollectionWrapper::setProxy() was called for a TrackingParticle " 1164 "that has already been created");
1167 index = trackingParticleIndices_[pProxyTrack->simTrackIndex];
1170 void ::OutputCollectionWrapper::setProxy(const ::DecayChainVertex *pOriginalVertex,
1171 const ::DecayChainVertex *pProxyVertex) {
1172 int &
index = trackingVertexIndices_[pOriginalVertex->simVertexIndex];
1173 const int newIndex = trackingVertexIndices_[pProxyVertex->simVertexIndex];
1175 if (index != -1 && index != newIndex)
1176 throw std::runtime_error(
1177 "OutputCollectionWrapper::setProxy() was called for a TrackingVertex " 1178 "that has already been created");
1185 void ::OutputCollectionWrapper::associateToExistingObjects(const ::DecayChainVertex *pChainVertex) {
1188 TrackingVertex *pTrackingVertex = getTrackingVertex(pChainVertex);
1189 if (pTrackingVertex ==
nullptr)
1190 throw std::runtime_error(
"associateToExistingObjects was passed a non existent TrackingVertex");
1195 ::DecayChainTrack *pParentChainTrack = pChainVertex->pParentTrack;
1196 if (pParentChainTrack !=
nullptr)
1200 TrackingParticle *pParentTrackingParticle = getTrackingParticle(pParentChainTrack);
1201 if (pParentTrackingParticle !=
nullptr) {
1218 void ::OutputCollectionWrapper::associateToExistingObjects(const ::DecayChainTrack *pChainTrack) {
1224 if (pTrackingParticle ==
nullptr)
1225 throw std::runtime_error(
1226 "associateToExistingObjects was passed a non " 1227 "existent TrackingParticle");
1231 ::DecayChainVertex *pParentChainVertex = pChainTrack->pParentVertex;
1232 TrackingVertex *pParentTrackingVertex = getTrackingVertex(pParentChainVertex);
1244 for (
auto pDaughterChainVertex : pChainTrack->daughterVertices) {
1245 TrackingVertex *pDaughterTrackingVertex = getTrackingVertex(pDaughterChainVertex);
1246 if (pDaughterTrackingVertex !=
nullptr) {
1255 ::OutputCollectionWrapper *pOutput) {
1259 TrackingParticle *pTrackingParticle = pOutput->getTrackingParticle(pDecayTrack);
1260 if (pTrackingParticle ==
nullptr) {
1262 if (pOutput->getTrackingVertex(pDecayTrack->pParentVertex) ==
nullptr) {
1270 pOutput->addTrackingVertex(pDecayTrack->pParentVertex, *trackingParticle.
parentVertex());
1273 pTrackingParticle = pOutput->addTrackingParticle(pDecayTrack, trackingParticle);
1276 return pTrackingParticle;
1279 void addTrack(::DecayChainTrack *pDecayChainTrack,
1281 ::OutputCollectionWrapper *pUnmergedOutput,
1282 ::OutputCollectionWrapper *pMergedOutput,
1283 const ::TrackingParticleFactory &objectFactory,
1286 if (pDecayChainTrack ==
nullptr)
1295 bool alreadyProcessed =
true;
1296 if (pUnmergedOutput !=
nullptr) {
1297 if (pUnmergedOutput->getTrackingParticle(pDecayChainTrack) ==
nullptr)
1298 alreadyProcessed =
false;
1300 if (pMergedOutput !=
nullptr) {
1301 if (pMergedOutput->getTrackingParticle(pDecayChainTrack) ==
nullptr)
1302 alreadyProcessed =
false;
1304 if (alreadyProcessed)
1309 TrackingParticle newTrackingParticle = objectFactory.createTrackingParticle(pDecayChainTrack, tTopo);
1321 dummyCollection.push_back(objectFactory.createTrackingVertex(pDecayChainTrack->pParentVertex));
1328 if (!(*pSelector)(newTrackingParticle))
1338 addTrack(pDecayChainTrack->pParentVertex->pParentTrack,
1348 if (pUnmergedOutput !=
nullptr)
1349 addTrackAndParentVertex(pDecayChainTrack, newTrackingParticle, pUnmergedOutput);
1353 if (pMergedOutput !=
nullptr) {
1354 ::DecayChainTrack *pBremParentChainTrack = pDecayChainTrack;
1355 while (pBremParentChainTrack->pMergedBremSource !=
nullptr)
1356 pBremParentChainTrack = pBremParentChainTrack->pMergedBremSource;
1358 if (pBremParentChainTrack != pDecayChainTrack) {
1360 addTrackAndParentVertex(pBremParentChainTrack, newTrackingParticle, pMergedOutput);
1373 pMergedOutput->setProxy(pDecayChainTrack->pParentVertex, pBremParentChainTrack->pParentVertex);
1378 addTrackAndParentVertex(pDecayChainTrack, newTrackingParticle, pMergedOutput);
1382 for (
const auto &trackSegment : newTrackingParticle.
g4Tracks()) {
1383 pBremParentTrackingParticle->
addG4Track(trackSegment);
1387 for (
const auto &genParticleRef : newTrackingParticle.
genParticles()) {
1401 pMergedOutput->setProxy(pDecayChainTrack, pBremParentChainTrack);
1406 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.
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
constexpr bool isFinite(T x)
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
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)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
const std::string messageCategory_
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
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_
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]
const bool createUnmergedCollection_
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.
const bool createMergedCollection_
adjacency_list< listS, vecS, directedS, VertexMotherParticleProperty, EdgeParticleClustersProperty > DecayChain
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_
constexpr Detector det() const
get the detector field from this detid
const double volumeRadius_