CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TTStubAssociator< T > Class Template Reference

Plugin to create the MC truth for TTStubs. More...

#include <TTStubAssociator.h>

Inheritance diagram for TTStubAssociator< T >:
edm::stream::EDProducer<>

Public Member Functions

 TTStubAssociator (const edm::ParameterSet &iConfig)
 Constructors. More...
 
 ~TTStubAssociator () override
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

void beginRun (const edm::Run &run, const edm::EventSetup &iSetup) override
 Mandatory methods. More...
 
void endRun (const edm::Run &run, const edm::EventSetup &iSetup) override
 End run. More...
 
template<>
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
template<>
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 Implement the producer. More...
 

Private Attributes

edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtheTrackerGeometryToken_
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtheTrackerTopologyToken_
 
std::vector< edm::InputTagttClusterTruthInputTags_
 
std::vector< edm::EDGetTokenT< TTClusterAssociationMap< T > > > ttClusterTruthTokens_
 
std::vector< edm::InputTagttStubsInputTags_
 Data members. More...
 
std::vector< edm::EDGetTokenT< edmNew::DetSetVector< TTStub< T > > > > ttStubsTokens_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

template<typename T>
class TTStubAssociator< T >

Plugin to create the MC truth for TTStubs.

After moving from SimDataFormats to DataFormats, the template structure of the class was maintained in order to accomodate any types other than PixelDigis in case there is such a need in the future.

Author
Nicola Pozzobon
Date
2013, Jul 19 (tidy up: Ian Tomalin, 2020)

Definition at line 44 of file TTStubAssociator.h.

Constructor & Destructor Documentation

◆ TTStubAssociator()

template<typename T >
TTStubAssociator< T >::TTStubAssociator ( const edm::ParameterSet iConfig)
explicit

Constructors.

Close class.

NOTE since pattern hit correlation must be performed within a stacked module, one must store Clusters in a proper way, providing easy access to them in a detector/member-wise way

Implementation of methods

Here, in the header file, the methods which do not depend on the specific type <T> that can fit the template. Other methods, with type-specific features, are implemented in the source file.Constructors

Definition at line 81 of file TTStubAssociator.h.

References deDxTools::esConsumes(), and edm::ParameterSet::getParameter().

81  {
82  ttStubsInputTags_ = iConfig.getParameter<std::vector<edm::InputTag> >("TTStubs");
83  ttClusterTruthInputTags_ = iConfig.getParameter<std::vector<edm::InputTag> >("TTClusterTruth");
84 
85  for (const auto& iTag : ttClusterTruthInputTags_) {
86  ttClusterTruthTokens_.push_back(consumes<TTClusterAssociationMap<T> >(iTag));
87  }
88 
89  for (const auto& iTag : ttStubsInputTags_) {
90  ttStubsTokens_.push_back(consumes<edmNew::DetSetVector<TTStub<T> > >(iTag));
91 
92  produces<TTStubAssociationMap<T> >(iTag.instance());
93  }
94 
97 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< edm::InputTag > ttStubsInputTags_
Data members.
std::vector< edm::EDGetTokenT< edmNew::DetSetVector< TTStub< T > > > > ttStubsTokens_
std::vector< edm::EDGetTokenT< TTClusterAssociationMap< T > > > ttClusterTruthTokens_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > theTrackerTopologyToken_
Stores association of Truth Particles (TP) to L1 Track-Trigger Clusters.
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > theTrackerGeometryToken_
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
std::vector< edm::InputTag > ttClusterTruthInputTags_

◆ ~TTStubAssociator()

template<typename T >
TTStubAssociator< T >::~TTStubAssociator ( )
override

Destructor.

Definition at line 101 of file TTStubAssociator.h.

101 {}

Member Function Documentation

◆ beginRun()

template<typename T >
void TTStubAssociator< T >::beginRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
overrideprivate

Mandatory methods.

Begin run.

Print some information when loaded

Definition at line 105 of file TTStubAssociator.h.

105  {
107  edm::LogInfo("TTStubAssociator< ") << templateNameFinder<T>() << " > loaded.";
108 }
Log< level::Info, false > LogInfo

◆ endRun()

template<typename T >
void TTStubAssociator< T >::endRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
overrideprivate

End run.

Definition at line 112 of file TTStubAssociator.h.

112 {}

◆ produce() [1/3]

template<>
void TTStubAssociator< Ref_Phase2TrackerDigi_ >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
private

Here, in the source file, the methods which do depend on the specific type <T> that can fit the template.

Author
Nicola Pozzobon
Date
2013, Jul 19Implement the producer

Exit if real data

Exit if the vectors are uncorrectly dimensioned

Loop over the InputTags to handle multiple collections

Prepare output

Get the Stubs already stored away

Get the Cluster MC truth

Prepare the necessary maps

Loop over the input Stubs

Get the DetSets of the Clusters

Make the reference to be put in the map

Fill the inclusive map which is careless of the stub classification

Prepare the maps wrt TrackingParticle

Fill the auxiliary map

GENUINE for clusters means not combinatoric and not unknown: same MC truth content MUST be found in both clusters composing the stub





























If at least one cluster is unknown, it means either unknown, either combinatoric Do nothing, and go to the next Stub




























Here both are clusters are genuine/combinatoric If both clusters have some known SimTrack content they must be compared to each other



























If both clusters are genuine, they must be associated to the same TrackingParticle in order to return a genuine stub. Period. Note we can perform safely this comparison because, if both clusters are genuine, their TrackingParticle shall NEVER be NULL


























Two genuine clusters with same SimTrack content mean genuine

Fill the map: by construction, this will always be the first time the stub is inserted into the map: no need for "find"
























At this point, go to the next Stub

It means combinatoric

End of two genuine clusters

Here, at least one cluster is combinatoric

Skip NULL pointers

Skip NULL pointers

Same SimTrack is present in both clusters

If two different SimTracks are found in both clusters, then the stub is for sure combinatoric
















End of double loop over SimTracks of both clusters

If two different SimTracks are found in both clusters, go to the next stub














No SimTracks were found to be in both clusters

Only one SimTrack was found to be present in both clusters even if one of the clusters (or both) are combinatoric: this means there is only one track that participates in both clusters, hence the stub is genuine












Fill the map: by construction, this will always be the first time the stub is inserted into the map: no need for "find"











At this point, go to the next Stub

End of one single SimTrack in both clusters

End of "at least one cluster is combinatoric"

End of "both clusters are known, somehow..."

End of loop over Stubs

Clean the only map that needs cleaning Prepare the output map wrt TrackingParticle





Get the vector of references to TTStub

Sort and remove duplicates

Also, create the pointer to the TTClusterAssociationMap

Put the maps in the association object

Put output in the event

End of loop over InputTags

Definition at line 14 of file TTStubAssociator.cc.

References edmNew::DetSet< T >::begin(), TrackerGeometry::dets(), edmNew::DetSet< T >::end(), edm::EventSetup::getData(), mps_fire::i, iEvent, TrackerTopology::isLower(), dqmdumpme::k, edmNew::makeRefTo(), eostools::move(), AlCaHLTBitMon_ParallelJobs::p, jetsAK4_CHS_cff::sort, TrackerTopology::stack(), DetId::subdetId(), StripSubdetector::TID, StripSubdetector::TOB, and tier0::unique().

14  {
16  if (iEvent.isRealData())
17  return;
18 
20  if (ttClusterTruthInputTags_.size() != ttStubsInputTags_.size()) {
21  edm::LogError("TTStubAsso ") << "E R R O R! the InputTag vectors have different size!";
22  return;
23  }
24 
25  int ncont1 = 0;
26 
27  const TrackerGeometry* const theTrackerGeom = &iSetup.getData(theTrackerGeometryToken_);
28  const TrackerTopology* const tTopo = &iSetup.getData(theTrackerTopologyToken_);
29 
31 
32  for (const auto& iTag : ttStubsTokens_) {
34  auto associationMapForOutput = std::make_unique<TTStubAssociationMap<Ref_Phase2TrackerDigi_>>();
35 
37  edm::Handle<TTStubDetSetVec> ttStubHandle;
38  iEvent.getByToken(iTag, ttStubHandle);
39 
42  iEvent.getByToken(ttClusterTruthTokens_.at(ncont1), ttClusterAssociationMapHandle);
43 
45  std::map<TTStubRef, TrackingParticlePtr> stubToTrackingParticleMap;
46  std::map<TrackingParticlePtr, std::vector<TTStubRef>> trackingParticleToStubVectorMap;
47 
49 
50  if (not ttStubHandle->empty()) {
51  for (const auto& gd : theTrackerGeom->dets()) {
52  DetId detid = gd->geographicalId();
53  if (detid.subdetId() != StripSubdetector::TOB && detid.subdetId() != StripSubdetector::TID)
54  continue; // only run on OT
55 
56  if (!tTopo->isLower(detid))
57  continue; // loop on the stacks: choose the lower arbitrarily
58 
59  DetId stackDetid = tTopo->stack(detid); // Stub module detid
60 
61  if (ttStubHandle->find(stackDetid) == ttStubHandle->end())
62  continue;
63 
65  edmNew::DetSet<TTStub<Ref_Phase2TrackerDigi_>> stubs = (*ttStubHandle)[stackDetid];
66 
67  for (auto contentIter = stubs.begin(); contentIter != stubs.end(); ++contentIter) {
69  TTStubRef tempStubRef = edmNew::makeRefTo(ttStubHandle, contentIter);
70 
72  for (unsigned int ic = 0; ic < 2; ic++) {
73  const std::vector<TrackingParticlePtr>& tempTPs =
74  ttClusterAssociationMapHandle->findTrackingParticlePtrs(tempStubRef->clusterRef(ic));
75 
76  for (const TrackingParticlePtr& testTP : tempTPs) {
77  if (testTP.isNull())
78  continue;
79 
81  if (trackingParticleToStubVectorMap.find(testTP) == trackingParticleToStubVectorMap.end()) {
82  std::vector<TTStubRef> stubVector;
83  trackingParticleToStubVectorMap.emplace(testTP, stubVector);
84  }
85  trackingParticleToStubVectorMap.find(testTP)->second.push_back(tempStubRef);
86  }
87  }
88 
92  if (ttClusterAssociationMapHandle->isUnknown(tempStubRef->clusterRef(0)) ||
93  ttClusterAssociationMapHandle->isUnknown(tempStubRef->clusterRef(1))) {
97  continue;
98  } else {
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()) {
110  const TrackingParticlePtr& testTP =
111  ttClusterAssociationMapHandle->findTrackingParticlePtr(tempStubRef->clusterRef(0));
112 
115  stubToTrackingParticleMap.emplace(tempStubRef, testTP);
116 
118  continue;
119  } else {
121  continue;
122  }
123  }
124  else {
126  TrackingParticle* prevTPAddress = nullptr;
127  unsigned int whichTP = 0;
128 
129  const std::vector<TrackingParticlePtr>& trackingParticles0 =
130  ttClusterAssociationMapHandle->findTrackingParticlePtrs(tempStubRef->clusterRef(0));
131  const std::vector<TrackingParticlePtr>& trackingParticles1 =
132  ttClusterAssociationMapHandle->findTrackingParticlePtrs(tempStubRef->clusterRef(1));
133 
134  bool escape = false;
135 
136  for (unsigned int i = 0; i < trackingParticles0.size() && !escape; i++) {
138  if (trackingParticles0.at(i).isNull())
139  continue;
140 
141  for (unsigned int k = 0; k < trackingParticles1.size() && !escape; k++) {
143  if (trackingParticles1.at(k).isNull())
144  continue;
145 
146  if (trackingParticles0.at(i).get() == trackingParticles1.at(k).get()) {
148  if (prevTPAddress == nullptr) {
149  prevTPAddress = const_cast<TrackingParticle*>(trackingParticles1.at(k).get());
150  whichTP = k;
151  }
152 
155  if (prevTPAddress != const_cast<TrackingParticle*>(trackingParticles1.at(k).get())) {
156  escape = true;
157  continue;
158  }
159  }
160  }
161  }
162 
165  if (escape)
166  continue;
167 
168  if (prevTPAddress == nullptr) {
170  continue;
171  } else {
176  TrackingParticlePtr testTP = trackingParticles1.at(whichTP);
177 
180  stubToTrackingParticleMap.emplace(tempStubRef, testTP);
181 
183  continue;
184  }
185  }
186  }
187  }
188  }
189  }
190 
193  for (auto& p : trackingParticleToStubVectorMap) {
195  std::vector<TTStubRef>& tempVector = p.second;
196 
198  std::sort(tempVector.begin(), tempVector.end());
199  tempVector.erase(std::unique(tempVector.begin(), tempVector.end()), tempVector.end());
200  }
201 
203  edm::RefProd<TTClusterAssociationMap<Ref_Phase2TrackerDigi_>> theCluAssoMap(ttClusterAssociationMapHandle);
204 
206  associationMapForOutput->setTTStubToTrackingParticleMap(stubToTrackingParticleMap);
207  associationMapForOutput->setTrackingParticleToTTStubsMap(trackingParticleToStubVectorMap);
208  associationMapForOutput->setTTClusterAssociationMap(theCluAssoMap);
209 
211  iEvent.put(std::move(associationMapForOutput), ttStubsInputTags_.at(ncont1).instance());
212 
213  ++ncont1;
214  }
215 }
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)
std::vector< edm::InputTag > ttStubsInputTags_
Data members.
std::vector< edm::EDGetTokenT< edmNew::DetSetVector< TTStub< T > > > > ttStubsTokens_
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Log< level::Error, false > LogError
std::vector< edm::EDGetTokenT< TTClusterAssociationMap< T > > > ttClusterTruthTokens_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > theTrackerTopologyToken_
int iEvent
Definition: GenABIO.cc:224
def unique(seq, keepstr=True)
Definition: tier0.py:24
uint32_t stack(const DetId &id) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > theTrackerGeometryToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
static constexpr auto TOB
Definition: DetId.h:17
bool isLower(const DetId &id) const
iterator end()
Definition: DetSetNew.h:56
Monte Carlo truth information used for tracking validation.
std::vector< edm::InputTag > ttClusterTruthInputTags_
static constexpr auto TID
def move(src, dest)
Definition: eostools.py:511
iterator begin()
Definition: DetSetNew.h:54

◆ produce() [2/3]

template<typename T >
void TTStubAssociator< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

◆ produce() [3/3]

template<>
void TTStubAssociator< Ref_Phase2TrackerDigi_ >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
private

Implement the producer.

Member Data Documentation

◆ theTrackerGeometryToken_

template<typename T >
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> TTStubAssociator< T >::theTrackerGeometryToken_
private

Definition at line 62 of file TTStubAssociator.h.

◆ theTrackerTopologyToken_

template<typename T >
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> TTStubAssociator< T >::theTrackerTopologyToken_
private

Definition at line 63 of file TTStubAssociator.h.

◆ ttClusterTruthInputTags_

template<typename T >
std::vector<edm::InputTag> TTStubAssociator< T >::ttClusterTruthInputTags_
private

Definition at line 57 of file TTStubAssociator.h.

◆ ttClusterTruthTokens_

template<typename T >
std::vector<edm::EDGetTokenT<TTClusterAssociationMap<T> > > TTStubAssociator< T >::ttClusterTruthTokens_
private

Definition at line 60 of file TTStubAssociator.h.

◆ ttStubsInputTags_

template<typename T >
std::vector<edm::InputTag> TTStubAssociator< T >::ttStubsInputTags_
private

Data members.

Definition at line 56 of file TTStubAssociator.h.

◆ ttStubsTokens_

template<typename T >
std::vector<edm::EDGetTokenT<edmNew::DetSetVector<TTStub<T> > > > TTStubAssociator< T >::ttStubsTokens_
private

Definition at line 59 of file TTStubAssociator.h.