20 if (ttClusterTruthInputTags_.size() != ttStubsInputTags_.size()) {
21 edm::LogError(
"TTStubAsso ") <<
"E R R O R! the InputTag vectors have different size!";
32 for (
const auto& iTag : ttStubsTokens_) {
34 auto associationMapForOutput = std::make_unique<TTStubAssociationMap<Ref_Phase2TrackerDigi_>>();
38 iEvent.getByToken(iTag, ttStubHandle);
42 iEvent.getByToken(ttClusterTruthTokens_.at(ncont1), ttClusterAssociationMapHandle);
45 std::map<TTStubRef, TrackingParticlePtr> stubToTrackingParticleMap;
46 std::map<TrackingParticlePtr, std::vector<TTStubRef>> trackingParticleToStubVectorMap;
50 if (not ttStubHandle->empty()) {
51 for (
const auto& gd : theTrackerGeom->
dets()) {
52 DetId detid = gd->geographicalId();
61 if (ttStubHandle->find(stackDetid) == ttStubHandle->end())
67 for (
auto contentIter =
stubs.begin(); contentIter !=
stubs.end(); ++contentIter) {
72 for (
unsigned int ic = 0; ic < 2; ic++) {
73 const std::vector<TrackingParticlePtr>& tempTPs =
74 ttClusterAssociationMapHandle->findTrackingParticlePtrs(tempStubRef->clusterRef(ic));
81 if (trackingParticleToStubVectorMap.find(testTP) == trackingParticleToStubVectorMap.end()) {
82 std::vector<TTStubRef> stubVector;
83 trackingParticleToStubVectorMap.emplace(testTP, stubVector);
85 trackingParticleToStubVectorMap.find(testTP)->second.push_back(tempStubRef);
92 if (ttClusterAssociationMapHandle->isUnknown(tempStubRef->clusterRef(0)) ||
93 ttClusterAssociationMapHandle->isUnknown(tempStubRef->clusterRef(1))) {
102 if (ttClusterAssociationMapHandle->isGenuine(tempStubRef->clusterRef(0)) &&
103 ttClusterAssociationMapHandle->isGenuine(tempStubRef->clusterRef(1))) {
107 if (ttClusterAssociationMapHandle->findTrackingParticlePtr(tempStubRef->clusterRef(0)).
get() ==
108 ttClusterAssociationMapHandle->findTrackingParticlePtr(tempStubRef->clusterRef(1)).
get()) {
111 ttClusterAssociationMapHandle->findTrackingParticlePtr(tempStubRef->clusterRef(0));
115 stubToTrackingParticleMap.emplace(tempStubRef, testTP);
127 unsigned int whichTP = 0;
129 const std::vector<TrackingParticlePtr>& trackingParticles0 =
130 ttClusterAssociationMapHandle->findTrackingParticlePtrs(tempStubRef->clusterRef(0));
131 const std::vector<TrackingParticlePtr>& trackingParticles1 =
132 ttClusterAssociationMapHandle->findTrackingParticlePtrs(tempStubRef->clusterRef(1));
136 for (
unsigned int i = 0;
i < trackingParticles0.size() && !escape;
i++) {
138 if (trackingParticles0.at(
i).isNull())
141 for (
unsigned int k = 0;
k < trackingParticles1.size() && !escape;
k++) {
143 if (trackingParticles1.at(
k).isNull())
146 if (trackingParticles0.at(
i).get() == trackingParticles1.at(
k).get()) {
148 if (prevTPAddress ==
nullptr) {
155 if (prevTPAddress != const_cast<TrackingParticle*>(trackingParticles1.at(
k).get())) {
168 if (prevTPAddress ==
nullptr) {
180 stubToTrackingParticleMap.emplace(tempStubRef, testTP);
193 for (
auto&
p : trackingParticleToStubVectorMap) {
195 std::vector<TTStubRef>& tempVector =
p.second;
198 std::sort(tempVector.begin(), tempVector.end());
199 tempVector.erase(
std::unique(tempVector.begin(), tempVector.end()), tempVector.end());
206 associationMapForOutput->setTTStubToTrackingParticleMap(stubToTrackingParticleMap);
207 associationMapForOutput->setTrackingParticleToTTStubsMap(trackingParticleToStubVectorMap);
208 associationMapForOutput->setTTClusterAssociationMap(theCluAssoMap);
211 iEvent.put(
std::move(associationMapForOutput), ttStubsInputTags_.at(ncont1).instance());
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Log< level::Error, false > LogError
def unique(seq, keepstr=True)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Mandatory methods.
uint32_t stack(const DetId &id) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
static constexpr auto TOB
bool isLower(const DetId &id) const
Monte Carlo truth information used for tracking validation.
static constexpr auto TID