20 if (TTClusterTruthInputTags.size() != TTStubsInputTags.size()) {
21 edm::LogError(
"TTStubAsso ") <<
"E R R O R! the InputTag vectors have different size!";
27 const TrackerGeometry*
const theTrackerGeom = theTrackerGeometry.product();
32 for (
auto iTag = TTStubsTokens.begin(); iTag != TTStubsTokens.end(); iTag++) {
34 auto associationMapForOutput = std::make_unique<TTStubAssociationMap<Ref_Phase2TrackerDigi_>>();
42 iEvent.
getByToken(TTClusterTruthTokens.at(ncont1), TTClusterAssociationMapHandle);
47 stubToTrackingParticleMap;
48 std::map<edm::Ptr<TrackingParticle>,
49 std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>, TTStub<Ref_Phase2TrackerDigi_>>>>
50 trackingParticleToStubVectorMap;
51 stubToTrackingParticleMap.clear();
52 trackingParticleToStubVectorMap.clear();
56 if (!TTStubHandle->empty()) {
57 for (
auto gd = theTrackerGeom->
dets().begin(); gd != theTrackerGeom->
dets().end(); gd++) {
58 DetId detid = (*gd)->geographicalId();
67 if (TTStubHandle->find(stackDetid) == TTStubHandle->end())
73 for (
auto contentIter = stubs.
begin(); contentIter != stubs.
end(); ++contentIter) {
82 for (
unsigned int ic = 0; ic < 2; ic++) {
83 std::vector<edm::Ptr<TrackingParticle>> tempTPs =
84 TTClusterAssociationMapHandle->findTrackingParticlePtrs(tempStubRef->clusterRef(ic));
86 for (
unsigned int itp = 0; itp < tempTPs.size(); itp++) {
93 if (trackingParticleToStubVectorMap.find(testTP) == trackingParticleToStubVectorMap.end()) {
98 trackingParticleToStubVectorMap.insert(std::make_pair(testTP, stubVector));
100 trackingParticleToStubVectorMap.find(testTP)->second.push_back(tempStubRef);
107 if (TTClusterAssociationMapHandle->isUnknown(tempStubRef->clusterRef(0)) ||
108 TTClusterAssociationMapHandle->isUnknown(tempStubRef->clusterRef(1))) {
117 if (TTClusterAssociationMapHandle->isGenuine(tempStubRef->clusterRef(0)) &&
118 TTClusterAssociationMapHandle->isGenuine(tempStubRef->clusterRef(1))) {
122 if (TTClusterAssociationMapHandle->findTrackingParticlePtr(tempStubRef->clusterRef(0)).
get() ==
123 TTClusterAssociationMapHandle->findTrackingParticlePtr(tempStubRef->clusterRef(1)).
get()) {
126 TTClusterAssociationMapHandle->findTrackingParticlePtr(tempStubRef->clusterRef(0));
130 stubToTrackingParticleMap.insert(std::make_pair(tempStubRef, testTP));
142 unsigned int whichTP = 0;
144 std::vector<edm::Ptr<TrackingParticle>> trackingParticles0 =
145 TTClusterAssociationMapHandle->findTrackingParticlePtrs(tempStubRef->clusterRef(0));
146 std::vector<edm::Ptr<TrackingParticle>> trackingParticles1 =
147 TTClusterAssociationMapHandle->findTrackingParticlePtrs(tempStubRef->clusterRef(1));
151 for (
unsigned int i = 0;
i < trackingParticles0.size() && !escape;
i++) {
153 if (trackingParticles0.at(
i).isNull())
156 for (
unsigned int k = 0;
k < trackingParticles1.size() && !escape;
k++) {
158 if (trackingParticles1.at(
k).isNull())
161 if (trackingParticles0.at(
i).get() == trackingParticles1.at(
k).get()) {
163 if (prevTPAddress ==
nullptr) {
170 if (prevTPAddress != const_cast<TrackingParticle*>(trackingParticles1.at(
k).get())) {
183 if (prevTPAddress ==
nullptr) {
195 stubToTrackingParticleMap.insert(std::make_pair(tempStubRef, testTP));
208 typename std::map<edm::Ptr<TrackingParticle>,
209 std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>,
210 TTStub<Ref_Phase2TrackerDigi_>>>>::iterator iterMapToClean;
211 for (iterMapToClean = trackingParticleToStubVectorMap.begin();
212 iterMapToClean != trackingParticleToStubVectorMap.end();
215 std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>, TTStub<Ref_Phase2TrackerDigi_>>>
216 tempVector = iterMapToClean->second;
219 std::sort(tempVector.begin(), tempVector.end());
220 tempVector.erase(
std::unique(tempVector.begin(), tempVector.end()), tempVector.end());
223 iterMapToClean->second = tempVector;
230 associationMapForOutput->setTTStubToTrackingParticleMap(stubToTrackingParticleMap);
231 associationMapForOutput->setTrackingParticleToTTStubsMap(trackingParticleToStubVectorMap);
232 associationMapForOutput->setTTClusterAssociationMap(theCluAssoMap);
235 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)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool isLower(const DetId &id) const
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
def unique(seq, keepstr=True)
bool isNull() const
Checks for null.
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
static constexpr auto TOB
Class to store the L1 Track Trigger stubs.
uint32_t stack(const DetId &id) const
Monte Carlo truth information used for tracking validation.
static constexpr auto TID