CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
ClusterTPAssociationProducer Class Reference
Inheritance diagram for ClusterTPAssociationProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef std::vector< OmniClusterRefOmniClusterCollection
 
- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 ClusterTPAssociationProducer (const edm::ParameterSet &)
 
 ~ClusterTPAssociationProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

template<typename T >
std::vector< std::pair< uint32_t, EncodedEventId > > getSimTrackId (const edm::Handle< edm::DetSetVector< T > > &simLinks, const DetId &detId, uint32_t channel) const
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

edm::EDGetTokenT< edmNew::DetSetVector< Phase2TrackerCluster1D > > phase2OTClustersToken_
 
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersToken_
 
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > siphase2OTSimLinksToken_
 
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > sipixelSimLinksToken_
 
edm::EDGetTokenT< edm::DetSetVector< StripDigiSimLink > > sistripSimLinksToken_
 
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClustersToken_
 
edm::EDGetTokenT< TrackingParticleCollectiontrackingParticleToken_
 

Additional Inherited Members

- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 32 of file ClusterTPAssociationProducer.cc.

Member Typedef Documentation

Definition at line 35 of file ClusterTPAssociationProducer.cc.

Constructor & Destructor Documentation

ClusterTPAssociationProducer::ClusterTPAssociationProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 58 of file ClusterTPAssociationProducer.cc.

65  trackingParticleToken_(consumes<TrackingParticleCollection>(cfg.getParameter<edm::InputTag>("trackingParticleSrc")))
66 {
67  produces<ClusterTPAssociation>();
68 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edmNew::DetSetVector< Phase2TrackerCluster1D > > phase2OTClustersToken_
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > siphase2OTSimLinksToken_
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClustersToken_
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleToken_
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > sipixelSimLinksToken_
edm::EDGetTokenT< edm::DetSetVector< StripDigiSimLink > > sistripSimLinksToken_
ClusterTPAssociationProducer::~ClusterTPAssociationProducer ( )
override

Definition at line 70 of file ClusterTPAssociationProducer.cc.

70  {
71 }

Member Function Documentation

void ClusterTPAssociationProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 73 of file ClusterTPAssociationProducer.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::add().

73  {
75  desc.add<edm::InputTag>("simTrackSrc", edm::InputTag("g4SimHits"));
76  desc.add<edm::InputTag>("pixelSimLinkSrc", edm::InputTag("simSiPixelDigis"));
77  desc.add<edm::InputTag>("stripSimLinkSrc", edm::InputTag("simSiStripDigis"));
78  desc.add<edm::InputTag>("phase2OTSimLinkSrc", edm::InputTag("simSiPixelDigis","Tracker"));
79  desc.add<edm::InputTag>("pixelClusterSrc", edm::InputTag("siPixelClusters"));
80  desc.add<edm::InputTag>("stripClusterSrc", edm::InputTag("siStripClusters"));
81  desc.add<edm::InputTag>("phase2OTClusterSrc", edm::InputTag("siPhase2Clusters"));
82  desc.add<edm::InputTag>("trackingParticleSrc", edm::InputTag("mix", "MergedTrackTruth"));
83  descriptions.add("tpClusterProducerDefault", desc);
84 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
template<typename T >
std::vector< std::pair< uint32_t, EncodedEventId > > ClusterTPAssociationProducer::getSimTrackId ( const edm::Handle< edm::DetSetVector< T > > &  simLinks,
const DetId detId,
uint32_t  channel 
) const
private

Definition at line 250 of file ClusterTPAssociationProducer.cc.

References edm::DetSet< T >::data, DEFINE_FWK_MODULE, and edm::DetSet< T >::push_back().

252 {
253  //std::pair<uint32_t, EncodedEventId> simTrkId;
254  std::vector<std::pair<uint32_t, EncodedEventId> > simTrkId;
255  auto isearch = simLinks->find(detId);
256  if (isearch != simLinks->end()) {
257  // Loop over DigiSimLink in this det unit
258  edm::DetSet<T> link_detset = (*isearch);
259  for (typename edm::DetSet<T>::const_iterator it = link_detset.data.begin();
260  it != link_detset.data.end(); ++it) {
261  if (channel == it->channel()) {
262  simTrkId.push_back(std::make_pair(it->SimTrackId(), it->eventId()));
263  }
264  }
265  }
266  return simTrkId;
267 }
void push_back(const T &t)
Definition: DetSet.h:68
collection_type data
Definition: DetSet.h:80
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
void ClusterTPAssociationProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup es 
) const
overrideprivate

Definition at line 86 of file ClusterTPAssociationProducer.cc.

References SiStripCluster::amplitudes(), edmNew::DetSet< T >::begin(), Phase2TrackerCluster1D::column(), runTauDisplay::eid, edmNew::DetSet< T >::end(), plotBeamSpotDB::first, Phase2TrackerCluster1D::firstRow(), SiStripCluster::firstStrip(), edm::Event::getByToken(), edm::HandleBase::id(), edm::HandleBase::isValid(), plotBeamSpotDB::last, edmNew::makeRefTo(), taus_updatedMVAIds_cff::mapping, SiPixelCluster::maxPixelCol(), SiPixelCluster::maxPixelRow(), SiPixelCluster::minPixelCol(), SiPixelCluster::minPixelRow(), eostools::move(), seedClusterRemoverPhase2_cfi::phase2OTClusters, phase2OTClustersToken_, HiRegitMuonDetachedTripletStep_cff::pixelClusters, pixelClustersToken_, PixelChannelIdentifier::pixelToChannel(), Phase2TrackerDigi::pixelToChannel(), edm::Handle< T >::product(), edm::Event::put(), siphase2OTSimLinksToken_, sipixelSimLinksToken_, sistripSimLinksToken_, Phase2TrackerCluster1D::size(), HiRegitMuonDetachedTripletStep_cff::stripClusters, stripClustersToken_, and trackingParticleToken_.

86  {
87  // Pixel DigiSimLink
89  // iEvent.getByLabel(_pixelSimLinkSrc, sipixelSimLinks);
90  iEvent.getByToken(sipixelSimLinksToken_,sipixelSimLinks);
91 
92  // SiStrip DigiSimLink
94  iEvent.getByToken(sistripSimLinksToken_,sistripSimLinks);
95 
96  // Phase2 OT DigiSimLink
98  iEvent.getByToken(siphase2OTSimLinksToken_, siphase2OTSimLinks);
99 
100  // Pixel Cluster
102  bool foundPixelClusters = iEvent.getByToken(pixelClustersToken_,pixelClusters);
103 
104  // Strip Cluster
106  bool foundStripClusters = iEvent.getByToken(stripClustersToken_,stripClusters);
107 
108  // Phase2 Cluster
110  bool foundPhase2OTClusters = iEvent.getByToken(phase2OTClustersToken_, phase2OTClusters);
111 
112  // TrackingParticle
114  iEvent.getByToken(trackingParticleToken_,TPCollectionH);
115 
116  auto clusterTPList = std::make_unique<ClusterTPAssociation>(TPCollectionH);
117 
118  // prepare temporary map between SimTrackId and TrackingParticle index
119  std::map<std::pair<size_t, EncodedEventId>, TrackingParticleRef> mapping;
121  itp < TPCollectionH.product()->size(); ++itp) {
122  TrackingParticleRef trackingParticle(TPCollectionH, itp);
123 
124  // SimTracks inside TrackingParticle
125  EncodedEventId eid(trackingParticle->eventId());
126  //size_t index = 0;
127  for (std::vector<SimTrack>::const_iterator itrk = trackingParticle->g4Track_begin();
128  itrk != trackingParticle->g4Track_end(); ++itrk) {
129  std::pair<uint32_t, EncodedEventId> trkid(itrk->trackId(), eid);
130  //std::cout << "creating map for id: " << trkid.first << " with tp: " << trackingParticle.key() << std::endl;
131  mapping.insert(std::make_pair(trkid, trackingParticle));
132  }
133  }
134 
135  if ( foundPixelClusters ) {
136  // Pixel Clusters
137  clusterTPList->addKeyID(pixelClusters.id());
138  for (edmNew::DetSetVector<SiPixelCluster>::const_iterator iter = pixelClusters->begin();
139  iter != pixelClusters->end(); ++iter) {
140  uint32_t detid = iter->id();
141  DetId detId(detid);
142  edmNew::DetSet<SiPixelCluster> link_pixel = (*iter);
144  di != link_pixel.end(); ++di) {
145  const SiPixelCluster& cluster = (*di);
147  edmNew::makeRefTo(pixelClusters, di);
148 
149  std::set<std::pair<uint32_t, EncodedEventId> > simTkIds;
150  for (int irow = cluster.minPixelRow(); irow <= cluster.maxPixelRow(); ++irow) {
151  for (int icol = cluster.minPixelCol(); icol <= cluster.maxPixelCol(); ++icol) {
152  uint32_t channel = PixelChannelIdentifier::pixelToChannel(irow, icol);
153  std::vector<std::pair<uint32_t, EncodedEventId> > trkid(getSimTrackId<PixelDigiSimLink>(sipixelSimLinks, detId, channel));
154  if (trkid.empty()) continue;
155  simTkIds.insert(trkid.begin(),trkid.end());
156  }
157  }
158  for (std::set<std::pair<uint32_t, EncodedEventId> >::const_iterator iset = simTkIds.begin();
159  iset != simTkIds.end(); iset++) {
160  auto ipos = mapping.find(*iset);
161  if (ipos != mapping.end()) {
162  //std::cout << "cluster in detid: " << detid << " from tp: " << ipos->second.key() << " " << iset->first << std::endl;
163  clusterTPList->emplace_back(OmniClusterRef(c_ref), ipos->second);
164  }
165  }
166  }
167  }
168  }
169 
170  if ( foundStripClusters ) {
171  // Strip Clusters
172  clusterTPList->addKeyID(stripClusters.id());
173  for (edmNew::DetSetVector<SiStripCluster>::const_iterator iter = stripClusters->begin(false), eter = stripClusters->end(false);
174  iter != eter; ++iter) {
175  if (!(*iter).isValid()) continue;
176  uint32_t detid = iter->id();
177  DetId detId(detid);
178  edmNew::DetSet<SiStripCluster> link_strip = (*iter);
180  di != link_strip.end(); di++) {
181  const SiStripCluster& cluster = (*di);
183  edmNew::makeRefTo(stripClusters, di);
184 
185  std::set<std::pair<uint32_t, EncodedEventId> > simTkIds;
186  int first = cluster.firstStrip();
187  int last = first + cluster.amplitudes().size();
188 
189  for (int istr = first; istr < last; ++istr) {
190  std::vector<std::pair<uint32_t, EncodedEventId> > trkid(getSimTrackId<StripDigiSimLink>(sistripSimLinks, detId, istr));
191  if (trkid.empty()) continue;
192  simTkIds.insert(trkid.begin(),trkid.end());
193  }
194  for (std::set<std::pair<uint32_t, EncodedEventId> >::const_iterator iset = simTkIds.begin();
195  iset != simTkIds.end(); iset++) {
196  auto ipos = mapping.find(*iset);
197  if (ipos != mapping.end()) {
198  //std::cout << "cluster in detid: " << detid << " from tp: " << ipos->second.key() << " " << iset->first << std::endl;
199  clusterTPList->emplace_back(OmniClusterRef(c_ref), ipos->second);
200  }
201  }
202  }
203  }
204  }
205 
206  if ( foundPhase2OTClusters ) {
207  // Phase2 Clusters
208  clusterTPList->addKeyID(phase2OTClusters.id());
209  if(phase2OTClusters.isValid()){
210  for (edmNew::DetSetVector<Phase2TrackerCluster1D>::const_iterator iter = phase2OTClusters->begin(false), eter = phase2OTClusters->end(false);
211  iter != eter; ++iter) {
212  if (!(*iter).isValid()) continue;
213  uint32_t detid = iter->id();
214  DetId detId(detid);
215  edmNew::DetSet<Phase2TrackerCluster1D> link_phase2 = (*iter);
217  di != link_phase2.end(); di++) {
218  const Phase2TrackerCluster1D& cluster = (*di);
220  edmNew::makeRefTo(phase2OTClusters, di);
221 
222  std::set<std::pair<uint32_t, EncodedEventId> > simTkIds;
223 
224  for (unsigned int istr(0); istr < cluster.size(); ++istr) {
225  uint32_t channel = Phase2TrackerDigi::pixelToChannel(cluster.firstRow() + istr, cluster.column());
226  std::vector<std::pair<uint32_t, EncodedEventId> > trkid(getSimTrackId<PixelDigiSimLink>(siphase2OTSimLinks, detId, channel));
227  if (trkid.empty()) continue;
228  simTkIds.insert(trkid.begin(),trkid.end());
229  }
230 
231  for (std::set<std::pair<uint32_t, EncodedEventId> >::const_iterator iset = simTkIds.begin();
232  iset != simTkIds.end(); iset++) {
233  auto ipos = mapping.find(*iset);
234  if (ipos != mapping.end()) {
235  clusterTPList->emplace_back(OmniClusterRef(c_ref), ipos->second);
236  }
237  }
238  }
239  }
240  }
241 
242  }
243  clusterTPList->sortAndUnique();
244  iEvent.put(std::move(clusterTPList));
245 }
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)
int minPixelCol() const
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
ProductID id() const
Definition: HandleBase.cc:15
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< edmNew::DetSetVector< Phase2TrackerCluster1D > > phase2OTClustersToken_
uint16_t firstStrip() const
data_type const * const_iterator
Definition: DetSetNew.h:30
uint16_t size_type
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > siphase2OTSimLinksToken_
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersToken_
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClustersToken_
int maxPixelRow() const
unsigned int firstRow() const
int minPixelRow() const
unsigned int column() const
static PackedDigiType pixelToChannel(unsigned int row, unsigned int col)
bool isValid() const
Definition: HandleBase.h:74
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleToken_
Definition: DetId.h:18
T const * product() const
Definition: Handle.h:74
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > sipixelSimLinksToken_
int maxPixelCol() const
Pixel cluster – collection of neighboring pixels above threshold.
iterator end()
Definition: DetSetNew.h:70
static int pixelToChannel(int row, int col)
edm::EDGetTokenT< edm::DetSetVector< StripDigiSimLink > > sistripSimLinksToken_
const std::vector< uint8_t > & amplitudes() const
def move(src, dest)
Definition: eostools.py:511
iterator begin()
Definition: DetSetNew.h:67

Member Data Documentation

edm::EDGetTokenT<edmNew::DetSetVector<Phase2TrackerCluster1D> > ClusterTPAssociationProducer::phase2OTClustersToken_
private

Definition at line 54 of file ClusterTPAssociationProducer.cc.

Referenced by produce().

edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > ClusterTPAssociationProducer::pixelClustersToken_
private

Definition at line 52 of file ClusterTPAssociationProducer.cc.

Referenced by produce().

edm::EDGetTokenT<edm::DetSetVector<PixelDigiSimLink> > ClusterTPAssociationProducer::siphase2OTSimLinksToken_
private

Definition at line 51 of file ClusterTPAssociationProducer.cc.

Referenced by produce().

edm::EDGetTokenT<edm::DetSetVector<PixelDigiSimLink> > ClusterTPAssociationProducer::sipixelSimLinksToken_
private

Definition at line 49 of file ClusterTPAssociationProducer.cc.

Referenced by produce().

edm::EDGetTokenT<edm::DetSetVector<StripDigiSimLink> > ClusterTPAssociationProducer::sistripSimLinksToken_
private

Definition at line 50 of file ClusterTPAssociationProducer.cc.

Referenced by produce().

edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > ClusterTPAssociationProducer::stripClustersToken_
private

Definition at line 53 of file ClusterTPAssociationProducer.cc.

Referenced by produce().

edm::EDGetTokenT<TrackingParticleCollection> ClusterTPAssociationProducer::trackingParticleToken_
private

Definition at line 55 of file ClusterTPAssociationProducer.cc.

Referenced by produce().