21 if ( TTClusterTruthInputTags.size() != TTStubsInputTags.size() )
23 edm::LogError(
"TTStubAsso ") <<
"E R R O R! the InputTag vectors have different size!";
29 const TrackerGeometry*
const theTrackerGeom = theTrackerGeometry.product();
34 for (
auto iTag = TTStubsTokens.begin(); iTag!= TTStubsTokens.end(); iTag++ )
37 auto associationMapForOutput = std::make_unique<TTStubAssociationMap<Ref_Phase2TrackerDigi_>>();
45 iEvent.
getByToken( TTClusterTruthTokens.at(ncont1), TTClusterAssociationMapHandle );
49 std::map< edm::Ptr< TrackingParticle >, std::vector< edm::Ref< edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > >, TTStub< Ref_Phase2TrackerDigi_ > > > > trackingParticleToStubVectorMap;
50 stubToTrackingParticleMap.clear();
51 trackingParticleToStubVectorMap.clear();
55 if ( !TTStubHandle->empty() )
57 for (
auto gd=theTrackerGeom->
dets().begin(); gd != theTrackerGeom->
dets().end(); gd++)
59 DetId detid = (*gd)->geographicalId();
62 if(!tTopo->
isLower(detid) )
continue;
66 if (TTStubHandle->find( stackDetid ) == TTStubHandle->end() )
continue;
71 for (
auto contentIter = stubs.
begin();contentIter != stubs.
end();++contentIter )
80 for (
unsigned int ic = 0; ic < 2; ic++ )
82 std::vector< edm::Ptr< TrackingParticle > > tempTPs = TTClusterAssociationMapHandle->findTrackingParticlePtrs( tempStubRef->getClusterRef(ic) );
84 for (
unsigned int itp = 0; itp < tempTPs.size(); itp++ )
92 if ( trackingParticleToStubVectorMap.find( testTP ) == trackingParticleToStubVectorMap.end() )
94 std::vector< edm::Ref< edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > >, TTStub< Ref_Phase2TrackerDigi_ > > > stubVector;
96 trackingParticleToStubVectorMap.insert( std::make_pair( testTP, stubVector ) );
98 trackingParticleToStubVectorMap.find( testTP )->second.push_back( tempStubRef );
105 if ( TTClusterAssociationMapHandle->isUnknown( tempStubRef->getClusterRef(0) ) ||
106 TTClusterAssociationMapHandle->isUnknown( tempStubRef->getClusterRef(1) ) )
118 if ( TTClusterAssociationMapHandle->isGenuine( tempStubRef->getClusterRef(0) ) &&
119 TTClusterAssociationMapHandle->isGenuine( tempStubRef->getClusterRef(1) ) )
124 if ( TTClusterAssociationMapHandle->findTrackingParticlePtr( tempStubRef->getClusterRef(0) ).
get() ==
125 TTClusterAssociationMapHandle->findTrackingParticlePtr( tempStubRef->getClusterRef(1) ).
get() )
132 stubToTrackingParticleMap.insert( std::make_pair( tempStubRef, testTP ) );
147 unsigned int whichTP = 0;
149 std::vector< edm::Ptr< TrackingParticle > > trackingParticles0 = TTClusterAssociationMapHandle->findTrackingParticlePtrs( tempStubRef->getClusterRef(0) );
150 std::vector< edm::Ptr< TrackingParticle > > trackingParticles1 = TTClusterAssociationMapHandle->findTrackingParticlePtrs( tempStubRef->getClusterRef(1) );
154 for (
unsigned int i = 0;
i < trackingParticles0.size() && !
escape;
i++ )
157 if ( trackingParticles0.at(
i).isNull() )
160 for (
unsigned int k = 0;
k < trackingParticles1.size() && !
escape;
k++ )
163 if ( trackingParticles1.at(
k).isNull() )
166 if ( trackingParticles0.at(
i).get() == trackingParticles1.at(
k).get() )
169 if ( prevTPAddress ==
nullptr )
177 if ( prevTPAddress != const_cast< TrackingParticle* >(trackingParticles1.at(
k).get()) )
191 if ( prevTPAddress ==
nullptr )
206 stubToTrackingParticleMap.insert( std::make_pair( tempStubRef, testTP ) );
220 typename std::map< edm::Ptr< TrackingParticle >, std::vector< edm::Ref< edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > >, TTStub< Ref_Phase2TrackerDigi_ > > > >::iterator iterMapToClean;
221 for ( iterMapToClean = trackingParticleToStubVectorMap.begin();
222 iterMapToClean != trackingParticleToStubVectorMap.end();
226 std::vector< edm::Ref< edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > >, TTStub< Ref_Phase2TrackerDigi_ > > > tempVector = iterMapToClean->second;
229 std::sort( tempVector.begin(), tempVector.end() );
230 tempVector.erase(
std::unique( tempVector.begin(), tempVector.end() ), tempVector.end() );
233 iterMapToClean->second = tempVector;
240 associationMapForOutput->setTTStubToTrackingParticleMap( stubToTrackingParticleMap );
241 associationMapForOutput->setTrackingParticleToTTStubsMap( trackingParticleToStubVectorMap );
242 associationMapForOutput->setTTClusterAssociationMap( theCluAssoMap );
245 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.
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Class to store the L1 Track Trigger stubs.
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
uint32_t stack(const DetId &id) const
Monte Carlo truth information used for tracking validation.