74 struct DecayChainTrack {
76 struct DecayChainVertex *pParentVertex;
79 std::vector<struct DecayChainVertex *> daughterVertices;
80 DecayChainTrack *pMergedBremSource;
81 DecayChainTrack() : simTrackIndex(-1), pParentVertex(nullptr), pMergedBremSource(nullptr) {}
82 DecayChainTrack(
int newSimTrackIndex)
83 : simTrackIndex(newSimTrackIndex), pParentVertex(nullptr), pMergedBremSource() {}
91 struct DecayChainVertex {
93 DecayChainTrack *pParentTrack;
94 std::vector<DecayChainTrack *> daughterTracks;
95 DecayChainVertex *pMergedBremSource;
96 DecayChainVertex() : simVertexIndex(-1), pParentTrack(nullptr), pMergedBremSource(nullptr) {}
97 DecayChainVertex(
int newIndex) : simVertexIndex(newIndex), pParentTrack(nullptr), pMergedBremSource(nullptr) {}
115 const size_t decayTracksSize;
116 const size_t decayVerticesSize;
118 #if defined(DO_DEBUG_TESTING) 125 void integrityCheck();
127 const SimTrack &getSimTrack(const ::DecayChainTrack *pDecayTrack)
const {
128 return simTrackCollection_.at(pDecayTrack->simTrackIndex);
130 const SimVertex &getSimVertex(const ::DecayChainVertex *pDecayVertex)
const {
131 return simVertexCollection_.at(pDecayVertex->simVertexIndex);
136 std::unique_ptr<::DecayChainTrack[]> decayTracks_;
137 std::unique_ptr<::DecayChainVertex[]> decayVertices_;
141 std::vector<::DecayChainVertex *> rootVertices_;
144 const std::vector<SimTrack> &simTrackCollection_;
145 const std::vector<SimVertex> &simVertexCollection_;
148 const std::unique_ptr<::DecayChainTrack[]> &decayTracks;
149 const std::unique_ptr<::DecayChainVertex[]> &decayVertices;
151 const std::vector<::DecayChainVertex *> &rootVertices;
160 class TrackingParticleFactory {
163 const edm::Handle<std::vector<reco::GenParticle>> &hGenParticles,
165 const edm::Handle<std::vector<int>> &hHepMCGenParticleIndices,
166 const std::vector<const PSimHit *> &
simHits,
170 bool allowDifferentProcessTypes);
172 TrackingVertex createTrackingVertex(
const DecayChainVertex *pVertex)
const;
179 std::vector<int> genParticleIndices_;
180 const std::vector<const PSimHit *> &simHits_;
181 const double volumeRadius_;
182 const double volumeZ_;
183 const double vertexDistanceCut2_;
185 std::multimap<unsigned int, size_t> trackIdToHitIndex_;
186 bool allowDifferentProcessTypeForDifferentDetectors_;
197 class OutputCollectionWrapper {
199 OutputCollectionWrapper(
const DecayChain &decayChain,
204 TrackingParticle *getTrackingParticle(const ::DecayChainTrack *pDecayTrack);
207 void setProxy(const ::DecayChainTrack *pOriginalTrack, const ::DecayChainTrack *pProxyTrack);
208 void setProxy(const ::DecayChainVertex *pOriginalVertex, const ::DecayChainVertex *pProxyVertex);
209 TrackingVertex *getTrackingVertex(const ::DecayChainVertex *pDecayVertex);
214 void associateToExistingObjects(const ::DecayChainVertex *pChainVertex);
215 void associateToExistingObjects(const ::DecayChainTrack *pChainTrack);
217 std::vector<int> trackingParticleIndices_;
218 std::vector<int> trackingVertexIndices_;
228 ::OutputCollectionWrapper *pOutput);
236 void addTrack(::DecayChainTrack *pDecayChainTrack,
238 ::OutputCollectionWrapper *pUnmergedOutput,
239 ::OutputCollectionWrapper *pMergedOutput,
240 const ::TrackingParticleFactory &objectFactory,
260 : messageCategory_(
"TrackingTruthAccumulator"),
261 volumeRadius_(
config.getParameter<double>(
"volumeRadius")),
262 volumeZ_(
config.getParameter<double>(
"volumeZ")),
263 vertexDistanceCut_(
config.getParameter<double>(
"vertexDistanceCut")),
264 ignoreTracksOutsideVolume_(
config.getParameter<
bool>(
"ignoreTracksOutsideVolume")),
265 maximumPreviousBunchCrossing_(
config.getParameter<unsigned
int>(
"maximumPreviousBunchCrossing")),
266 maximumSubsequentBunchCrossing_(
config.getParameter<unsigned
int>(
"maximumSubsequentBunchCrossing")),
267 createUnmergedCollection_(
config.getParameter<
bool>(
"createUnmergedCollection")),
268 createMergedCollection_(
config.getParameter<
bool>(
"createMergedBremsstrahlung")),
269 createInitialVertexCollection_(
config.getParameter<
bool>(
"createInitialVertexCollection")),
270 addAncestors_(
config.getParameter<
bool>(
"alwaysAddAncestors")),
271 removeDeadModules_(
config.getParameter<
bool>(
"removeDeadModules")),
278 allowDifferentProcessTypeForDifferentDetectors_(
config.getParameter<
bool>(
"allowDifferentSimHitProcesses")) {
285 "\"createMergedBremsstrahlung\" have been" 286 <<
"set to false, which means no collections will be created";
290 if (
config.exists(
"select")) {
344 std::vector<std::string> parameterNames = simHitCollectionConfig.getParameterNames();
346 for (
const auto ¶meterName : parameterNames) {
347 std::vector<edm::InputTag>
tags = simHitCollectionConfig.getParameter<std::vector<edm::InputTag>>(parameterName);
352 iC.
consumes<std::vector<PSimHit>>(collectionTag);
361 const_cast<edm::Event &
>(
event).getRefBeforePut<TrackingParticleCollection>();
369 const_cast<edm::Event &
>(
event).getRefBeforePut<TrackingParticleCollection>(
"MergedTrackTruth");
371 const_cast<edm::Event &
>(
event).getRefBeforePut<TrackingVertexCollection>(
"MergedTrackTruth");
434 <<
"Adding " <<
pInitialVertices_->size() <<
" initial TrackingVertexs to the event.";
476 DecayChain decayChain(*hSimTracks, *hSimVertices);
479 std::unique_ptr<::OutputCollectionWrapper> pUnmergedCollectionWrapper;
480 std::unique_ptr<::OutputCollectionWrapper> pMergedCollectionWrapper;
482 pUnmergedCollectionWrapper = std::make_unique<::OutputCollectionWrapper>(decayChain,
unmergedOutput_);
484 pMergedCollectionWrapper = std::make_unique<::OutputCollectionWrapper>(decayChain,
mergedOutput_);
486 std::vector<const PSimHit *> simHitPointers;
488 TrackingParticleFactory objectFactory(decayChain,
498 #if defined(DO_DEBUG_TESTING) 501 decayChain.integrityCheck();
514 ::DecayChainTrack *pDecayTrack = &decayChain.decayTracks[
index];
530 const SimVertex &
simVertex = hSimVertices->at(pDecayTrack->pParentVertex->simVertexIndex);
531 if (!objectFactory.vectorIsInsideVolume(
simVertex.position()))
539 ::addTrack(pDecayTrack,
541 pUnmergedCollectionWrapper.get(),
542 pMergedCollectionWrapper.get(),
557 for (
const auto &pRootVertex : decayChain.rootVertices) {
558 const SimVertex &
vertex = hSimVertices->at(decayChain.rootVertices[0]->simVertexIndex);
559 if (
vertex.vertexId() != 0)
575 event.getByLabel(collectionTag, hSimHits);
578 for (
const auto &
simHit : *hSimHits) {
579 returnValue.push_back(&
simHit);
589 edm::isFinite(
a->timeOfFlight()) ?
a->timeOfFlight() : std::numeric_limits<decltype(
a->timeOfFlight())>::
max();
591 edm::isFinite(
b->timeOfFlight()) ?
b->timeOfFlight() : std::numeric_limits<decltype(
b->timeOfFlight())>::
max();
621 const edm::Handle<std::vector<reco::GenParticle>> &hGenParticles,
623 const edm::Handle<std::vector<int>> &hHepMCGenParticleIndices,
624 const std::vector<const PSimHit *> &
simHits,
628 bool allowDifferentProcessTypes)
629 : decayChain_(decayChain),
630 hGenParticles_(hGenParticles),
631 hepMCproduct_(hepMCproduct),
636 allowDifferentProcessTypeForDifferentDetectors_(allowDifferentProcessTypes) {
640 trackIdToHitIndex_.insert(std::make_pair(simHits_[
index]->trackId(),
index));
643 if (hHepMCGenParticleIndices.isValid())
646 genParticleIndices_.resize(hHepMCGenParticleIndices->size() + 1);
650 for (
size_t recoGenParticleIndex = 0; recoGenParticleIndex < hHepMCGenParticleIndices->size();
651 ++recoGenParticleIndex) {
652 size_t hepMCGenParticleIndex = (*hHepMCGenParticleIndices)[recoGenParticleIndex];
656 if (genParticleIndices_.size() <= hepMCGenParticleIndex)
657 genParticleIndices_.resize(hepMCGenParticleIndex + 1);
659 genParticleIndices_[hepMCGenParticleIndex] = recoGenParticleIndex;
664 TrackingParticle TrackingParticleFactory::createTrackingParticle(const ::DecayChainTrack *pChainTrack,
670 const SimVertex &parentSimVertex = decayChain_.getSimVertex(pChainTrack->pParentVertex);
687 if (
simTrack.eventId().event() == 0 &&
688 simTrack.eventId().bunchCrossing() == 0)
690 int hepMCGenParticleIndex =
simTrack.genpartIndex();
691 if (hepMCGenParticleIndex >= 0 && hepMCGenParticleIndex < static_cast<int>(genParticleIndices_.size()) &&
692 hGenParticles_.isValid()) {
693 int recoGenParticleIndex = genParticleIndices_[hepMCGenParticleIndex];
695 pdgId = generatorParticleRef->pdgId();
706 size_t matchedHits = 0;
708 size_t numberOfHits = 0;
709 size_t numberOfTrackerHits = 0;
725 for (
auto iHitIndex = trackIdToHitIndex_.lower_bound(
simTrack.trackId()),
726 end = trackIdToHitIndex_.upper_bound(
simTrack.trackId());
729 const auto &pSimHit = simHits_[iHitIndex->second];
732 if (pSimHit->particleType() !=
pdgId)
737 processType = pSimHit->processType();
739 newDetector =
DetId(pSimHit->detUnitId());
743 oldDetector = newDetector;
744 newDetector =
DetId(pSimHit->detUnitId());
749 if (allowDifferentProcessTypeForDifferentDetectors_ && newDetector.
det() != oldDetector.
det())
750 processType = pSimHit->processType();
753 if (processType == pSimHit->processType() &&
particleType == pSimHit->particleType()) {
758 ++numberOfTrackerHits;
760 newLayer = tTopo->
layer(newDetector);
763 if ((oldLayer != newLayer || (oldLayer == newLayer && oldDetector.
subdetId() != newDetector.
subdetId())))
776 TrackingVertex TrackingParticleFactory::createTrackingVertex(const ::DecayChainVertex *pChainVertex)
const {
783 bool isInVolume = this->vectorIsInsideVolume(
simVertex.position());
793 hepMCproduct_.isValid())
798 Vector tvPosition(returnValue.position().x(), returnValue.position().
y(), returnValue.position().z());
800 for (HepMC::GenEvent::vertex_const_iterator iGenVertex =
genEvent->vertices_begin();
801 iGenVertex !=
genEvent->vertices_end();
803 HepMC::ThreeVector rawPosition = (*iGenVertex)->position();
805 Vector genPosition(rawPosition.x() * 0.1, rawPosition.y() * 0.1, rawPosition.z() * 0.1);
807 auto distance2 = (tvPosition - genPosition).
mag2();
809 if (distance2 < vertexDistanceCut2_)
810 returnValue.addGenVertex(
GenVertexRef(hepMCproduct_, (*iGenVertex)->barcode()));
832 decayTracks_(new DecayChainTrack[decayTracksSize]),
833 decayVertices_(new DecayChainVertex[decayVerticesSize]),
836 decayTracks(decayTracks_),
838 decayVertices(decayVertices_),
839 rootVertices(rootVertices_) {
841 std::map<int, ::DecayChainTrack *> trackIdToDecayTrack;
842 std::map<int, ::DecayChainVertex *> vertexIdToDecayVertex;
848 size_t decayVertexIndex = 0;
850 ::DecayChainTrack *pDecayTrack = &decayTracks_[
index];
856 pDecayTrack->simTrackIndex =
index;
861 if (parentVertexIndex >= 0) {
864 ::DecayChainVertex *&pParentVertex = vertexIdToDecayVertex[parentVertexIndex];
865 if (pParentVertex ==
nullptr) {
868 pParentVertex = &decayVertices_[decayVertexIndex];
870 pParentVertex->simVertexIndex = parentVertexIndex;
872 pParentVertex->daughterTracks.push_back(pDecayTrack);
873 pDecayTrack->pParentVertex = pParentVertex;
875 throw std::runtime_error(
876 "TrackingTruthAccumulator: Found a track with " 877 "an invalid parent vertex index.");
892 for (
auto &decayVertexMapPair : vertexIdToDecayVertex) {
893 ::DecayChainVertex *pDecayVertex = decayVertexMapPair.second;
894 int parentTrackIndex =
vertexCollection[pDecayVertex->simVertexIndex].parentIndex();
895 if (parentTrackIndex != -1) {
896 std::map<int, ::DecayChainTrack *>::iterator iParentTrackMapPair = trackIdToDecayTrack.find(parentTrackIndex);
897 if (iParentTrackMapPair == trackIdToDecayTrack.end()) {
898 std::stringstream errorStream;
899 errorStream <<
"TrackingTruthAccumulator: Something has gone wrong " 900 "with the indexing. Parent track index is " 901 << parentTrackIndex <<
".";
902 throw std::runtime_error(errorStream.str());
905 ::DecayChainTrack *pParentTrackHierarchy = iParentTrackMapPair->second;
907 pParentTrackHierarchy->daughterVertices.push_back(pDecayVertex);
908 pDecayVertex->pParentTrack = pParentTrackHierarchy;
910 rootVertices_.push_back(pDecayVertex);
917 #if defined(DO_DEBUG_TESTING) 920 void ::DecayChain::integrityCheck() {
925 const auto &decayTrack = decayTracks[
index];
929 if (decayTrack.pParentVertex ==
NULL)
930 throw std::runtime_error(
931 "TrackingTruthAccumulator.cc integrityCheck(): " 932 "Found DecayChainTrack with no parent vertex.");
938 size_t numberOfTimesListed = 0;
939 for (
const auto pSiblingTrack : decayTrack.pParentVertex->daughterTracks) {
940 if (pSiblingTrack == &decayTrack)
941 ++numberOfTimesListed;
943 if (numberOfTimesListed != 1)
944 throw std::runtime_error(
945 "TrackingTruthAccumulator.cc integrityCheck(): " 946 "Found DecayChainTrack whose parent does not " 947 "have it listed once and only once as a child.");
952 for (
const auto pDaughterVertex : decayTrack.daughterVertices) {
953 if (pDaughterVertex->pParentTrack != &decayTrack)
954 throw std::runtime_error(
955 "TrackingTruthAccumulator.cc integrityCheck(): Found " 956 "DecayChainTrack whose child does not have it listed as the " 964 const DecayChainVertex *pAncestorVertex = decayTrack.pParentVertex;
965 while (pAncestorVertex->pParentTrack !=
NULL) {
966 if (pAncestorVertex->pParentTrack->pParentVertex ==
NULL)
967 throw std::runtime_error(
968 "TrackingTruthAccumulator.cc integrityCheck(): Found " 969 "DecayChainTrack with no parent vertex higher in the decay chain.");
970 pAncestorVertex = pAncestorVertex->pParentTrack->pParentVertex;
972 if (
std::find(rootVertices.begin(), rootVertices.end(), pAncestorVertex) == rootVertices.end()) {
973 throw std::runtime_error(
974 "TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack " 975 "whose root vertex is not recorded anywhere.");
983 const auto &decayVertex = decayVertices[
index];
989 const DecayChainVertex *pAncestorVertex = &decayVertex;
990 while (pAncestorVertex->pParentTrack !=
NULL) {
991 if (pAncestorVertex->pParentTrack->pParentVertex ==
NULL)
992 throw std::runtime_error(
993 "TrackingTruthAccumulator.cc integrityCheck(): Found " 994 "DecayChainTrack with no parent vertex higher in the vertex decay " 996 pAncestorVertex = pAncestorVertex->pParentTrack->pParentVertex;
998 if (
std::find(rootVertices.begin(), rootVertices.end(), pAncestorVertex) == rootVertices.end()) {
999 throw std::runtime_error(
1000 "TrackingTruthAccumulator.cc integrityCheck(): Found DecayChainTrack " 1001 "whose root vertex is not recorded anywhere.");
1007 if (decayVertex.pParentTrack !=
NULL) {
1008 size_t numberOfTimesListed = 0;
1009 for (
const auto pSibling : decayVertex.pParentTrack->daughterVertices) {
1010 if (pSibling == &decayVertex)
1011 ++numberOfTimesListed;
1013 if (numberOfTimesListed != 1)
1014 throw std::runtime_error(
1015 "TrackingTruthAccumulator.cc integrityCheck(): Found " 1016 "DecayChainVertex whose parent does not have it listed once and " 1017 "only once as a child.");
1023 for (
const auto pDaughter : decayVertex.daughterTracks) {
1024 if (pDaughter->pParentVertex != &decayVertex)
1025 throw std::runtime_error(
1026 "TrackingTruthAccumulator.cc integrityCheck(): Found " 1027 "DecayChainVertex whose child does not have it listed as the " 1032 std::cout <<
"TrackingTruthAccumulator.cc integrityCheck() completed successfully" << std::endl;
1036 void ::DecayChain::findBrem(
const std::vector<SimTrack> &
trackCollection,
1042 if (
vertex.pParentTrack ==
nullptr)
1045 if (
std::abs(parentTrackPDG) != 11)
1048 size_t numberOfElectrons = 0;
1049 size_t numberOfNonElectronsOrPhotons = 0;
1050 for (
auto &pDaughterTrack :
vertex.daughterTracks) {
1053 ++numberOfElectrons;
1055 ++numberOfNonElectronsOrPhotons;
1057 if (numberOfElectrons == 1 && numberOfNonElectronsOrPhotons == 0) {
1060 for (
auto &pDaughterTrack :
vertex.daughterTracks)
1061 pDaughterTrack->pMergedBremSource =
vertex.pParentTrack;
1062 vertex.pMergedBremSource =
vertex.pParentTrack->pParentVertex;
1076 : output_(outputCollections),
1077 trackingParticleIndices_(decayChain.decayTracksSize, -1),
1078 trackingVertexIndices_(decayChain.decayVerticesSize, -1) {
1082 TrackingParticle * ::OutputCollectionWrapper::addTrackingParticle(const ::DecayChainTrack *pDecayTrack,
1084 if (trackingParticleIndices_[pDecayTrack->simTrackIndex] != -1)
1085 throw std::runtime_error(
1086 "OutputCollectionWrapper::addTrackingParticle - " 1087 "trying to add a particle twice");
1089 trackingParticleIndices_[pDecayTrack->simTrackIndex] = output_.pTrackingParticles->size();
1090 output_.pTrackingParticles->push_back(trackingParticle);
1093 output_.pTrackingParticles->back().clearDecayVertices();
1094 output_.pTrackingParticles->back().clearParentVertex();
1097 associateToExistingObjects(pDecayTrack);
1099 return &output_.pTrackingParticles->back();
1102 TrackingVertex * ::OutputCollectionWrapper::addTrackingVertex(const ::DecayChainVertex *pDecayVertex,
1104 if (trackingVertexIndices_[pDecayVertex->simVertexIndex] != -1)
1105 throw std::runtime_error(
1106 "OutputCollectionWrapper::addTrackingVertex - " 1107 "trying to add a vertex twice");
1109 trackingVertexIndices_[pDecayVertex->simVertexIndex] = output_.pTrackingVertices->size();
1110 output_.pTrackingVertices->push_back(trackingVertex);
1114 associateToExistingObjects(pDecayVertex);
1116 return &output_.pTrackingVertices->back();
1119 TrackingParticle * ::OutputCollectionWrapper::getTrackingParticle(const ::DecayChainTrack *pDecayTrack) {
1120 const int index = trackingParticleIndices_[pDecayTrack->simTrackIndex];
1124 return &(*output_.pTrackingParticles)[
index];
1127 TrackingVertex * ::OutputCollectionWrapper::getTrackingVertex(const ::DecayChainVertex *pDecayVertex) {
1128 const int index = trackingVertexIndices_[pDecayVertex->simVertexIndex];
1132 return &(*output_.pTrackingVertices)[
index];
1136 const int index = trackingParticleIndices_[pDecayTrack->simTrackIndex];
1138 throw std::runtime_error(
1139 "OutputCollectionWrapper::getRefTrackingParticle - ref requested for a " 1140 "non existent TrackingParticle");
1146 const int index = trackingVertexIndices_[pDecayVertex->simVertexIndex];
1148 throw std::runtime_error(
1149 "OutputCollectionWrapper::getRefTrackingParticle - ref requested for a " 1150 "non existent TrackingVertex");
1155 void ::OutputCollectionWrapper::setProxy(const ::DecayChainTrack *pOriginalTrack,
1156 const ::DecayChainTrack *pProxyTrack) {
1157 int &
index = trackingParticleIndices_[pOriginalTrack->simTrackIndex];
1159 throw std::runtime_error(
1160 "OutputCollectionWrapper::setProxy() was called for a TrackingParticle " 1161 "that has already been created");
1164 index = trackingParticleIndices_[pProxyTrack->simTrackIndex];
1167 void ::OutputCollectionWrapper::setProxy(const ::DecayChainVertex *pOriginalVertex,
1168 const ::DecayChainVertex *pProxyVertex) {
1169 int &
index = trackingVertexIndices_[pOriginalVertex->simVertexIndex];
1170 const int newIndex = trackingVertexIndices_[pProxyVertex->simVertexIndex];
1173 throw std::runtime_error(
1174 "OutputCollectionWrapper::setProxy() was called for a TrackingVertex " 1175 "that has already been created");
1182 void ::OutputCollectionWrapper::associateToExistingObjects(const ::DecayChainVertex *pChainVertex) {
1185 TrackingVertex *pTrackingVertex = getTrackingVertex(pChainVertex);
1186 if (pTrackingVertex ==
nullptr)
1187 throw std::runtime_error(
"associateToExistingObjects was passed a non existent TrackingVertex");
1192 ::DecayChainTrack *pParentChainTrack = pChainVertex->pParentTrack;
1193 if (pParentChainTrack !=
nullptr)
1197 TrackingParticle *pParentTrackingParticle = getTrackingParticle(pParentChainTrack);
1198 if (pParentTrackingParticle !=
nullptr) {
1215 void ::OutputCollectionWrapper::associateToExistingObjects(const ::DecayChainTrack *pChainTrack) {
1221 if (pTrackingParticle ==
nullptr)
1222 throw std::runtime_error(
1223 "associateToExistingObjects was passed a non " 1224 "existent TrackingParticle");
1228 ::DecayChainVertex *pParentChainVertex = pChainTrack->pParentVertex;
1229 TrackingVertex *pParentTrackingVertex = getTrackingVertex(pParentChainVertex);
1241 for (
auto pDaughterChainVertex : pChainTrack->daughterVertices) {
1242 TrackingVertex *pDaughterTrackingVertex = getTrackingVertex(pDaughterChainVertex);
1243 if (pDaughterTrackingVertex !=
nullptr) {
1252 ::OutputCollectionWrapper *pOutput) {
1256 TrackingParticle *pTrackingParticle = pOutput->getTrackingParticle(pDecayTrack);
1257 if (pTrackingParticle ==
nullptr) {
1259 if (pOutput->getTrackingVertex(pDecayTrack->pParentVertex) ==
nullptr) {
1267 pOutput->addTrackingVertex(pDecayTrack->pParentVertex, *trackingParticle.
parentVertex());
1270 pTrackingParticle = pOutput->addTrackingParticle(pDecayTrack, trackingParticle);
1273 return pTrackingParticle;
1276 void addTrack(::DecayChainTrack *pDecayChainTrack,
1278 ::OutputCollectionWrapper *pUnmergedOutput,
1279 ::OutputCollectionWrapper *pMergedOutput,
1280 const ::TrackingParticleFactory &objectFactory,
1283 if (pDecayChainTrack ==
nullptr)
1292 bool alreadyProcessed =
true;
1293 if (pUnmergedOutput !=
nullptr) {
1294 if (pUnmergedOutput->getTrackingParticle(pDecayChainTrack) ==
nullptr)
1295 alreadyProcessed =
false;
1297 if (pMergedOutput !=
nullptr) {
1298 if (pMergedOutput->getTrackingParticle(pDecayChainTrack) ==
nullptr)
1299 alreadyProcessed =
false;
1301 if (alreadyProcessed)
1306 TrackingParticle newTrackingParticle = objectFactory.createTrackingParticle(pDecayChainTrack, tTopo);
1318 dummyCollection.push_back(objectFactory.createTrackingVertex(pDecayChainTrack->pParentVertex));
1325 if (!(*pSelector)(newTrackingParticle))
1335 addTrack(pDecayChainTrack->pParentVertex->pParentTrack,
1345 if (pUnmergedOutput !=
nullptr)
1346 addTrackAndParentVertex(pDecayChainTrack, newTrackingParticle, pUnmergedOutput);
1350 if (pMergedOutput !=
nullptr) {
1351 ::DecayChainTrack *pBremParentChainTrack = pDecayChainTrack;
1352 while (pBremParentChainTrack->pMergedBremSource !=
nullptr)
1353 pBremParentChainTrack = pBremParentChainTrack->pMergedBremSource;
1355 if (pBremParentChainTrack != pDecayChainTrack) {
1357 addTrackAndParentVertex(pBremParentChainTrack, newTrackingParticle, pMergedOutput);
1370 pMergedOutput->setProxy(pDecayChainTrack->pParentVertex, pBremParentChainTrack->pParentVertex);
1375 addTrackAndParentVertex(pDecayChainTrack, newTrackingParticle, pMergedOutput);
1379 for (
const auto &trackSegment : newTrackingParticle.
g4Tracks()) {
1380 pBremParentTrackingParticle->
addG4Track(trackSegment);
1384 for (
const auto &genParticleRef : newTrackingParticle.
genParticles()) {
1398 pMergedOutput->setProxy(pDecayChainTrack, pBremParentChainTrack);
1403 addTrackAndParentVertex(pDecayChainTrack, newTrackingParticle, pMergedOutput);
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
edm::Ref< edm::HepMCProduct, HepMC::GenVertex > GenVertexRef
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::unique_ptr< TrackingParticleCollection > pTrackingParticles
T getParameter(std::string const &) const
const reco::GenParticleRefVector & genParticles() const
std::unique_ptr< TrackingVertexCollection > pInitialVertices_
const bool ignoreTracksOutsideVolume_
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
std::unique_ptr< TrackingVertexCollection > pTrackingVertices
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
ROOT::Math::Plane3D::Vector Vector
TrackingParticleRefProd refTrackingParticles
const math::XYZTLorentzVectorD & position() const
void addDaughterTrack(const TrackingParticleRef &)
const double vertexDistanceCut_
maximum distance for HepMC::GenVertex to be added to SimVertex
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void addParentTrack(const TrackingParticleRef &)
constexpr bool isFinite(T x)
double y() const
Same as rapidity().
constexpr Detector det() const
get the detector field from this detid
unsigned int layer(const DetId &id) const
const std::vector< SimTrack > & g4Tracks() const
const unsigned int maximumSubsequentBunchCrossing_
void setParentVertex(const TrackingVertexRef &ref)
void addGenParticle(const reco::GenParticleRef &ref)
int numberOfTrackerLayers() const
The number of tracker layers with a hit.
void accumulateEvent(const T &event, const edm::EventSetup &setup, const edm::Handle< edm::HepMCProduct > &hepMCproduct)
Both forms of accumulate() delegate to this templated method.
void finalizeEvent(edm::Event &event, const edm::EventSetup &setup) override
adjacency_list< listS, vecS, directedS, VertexMotherParticleProperty, EdgeParticleClustersProperty > DecayChain
int numberOfTrackerHits() const
The number of hits in the tracker. Hits on overlaps in the same layer count separately.
void addG4Track(const SimTrack &t)
const std::string messageCategory_
Abs< T >::type abs(const T &t)
math::XYZTLorentzVector LorentzVector
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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
Log< level::Info, false > LogInfo
const TrackingVertexRef & parentVertex() const
const bool createInitialVertexCollection_
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
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_
void setNumberOfTrackerHits(int numberOfTrackerHits)
#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_
std::vector< TrackingParticle > TrackingParticleCollection
void setNumberOfTrackerLayers(const int numberOfTrackerLayers)
Replacement for TrackingTruthProducer in the new pileup mixing setup.
const bool createMergedCollection_
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...
SingleObjectSelector< TrackingParticleCollection, ::TrackingParticleSelector > TrackingParticleSelector
TrackingTruthAccumulator(const edm::ParameterSet &config, edm::ProducesCollector, edm::ConsumesCollector &iC)
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_