CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
ClusterTPAssociationProducer Class Reference

#include <ClusterTPAssociationProducer.h>

Inheritance diagram for ClusterTPAssociationProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef std::vector< std::pair
< OmniClusterRef,
TrackingParticleRef > > 
ClusterTPAssociationList
 
typedef std::vector
< OmniClusterRef
OmniClusterCollection
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

 ClusterTPAssociationProducer (const edm::ParameterSet &)
 
 ~ClusterTPAssociationProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
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
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

edm::InputTag _pixelClusterSrc
 
edm::InputTag _pixelSimLinkSrc
 
edm::InputTag _stripClusterSrc
 
edm::InputTag _stripSimLinkSrc
 
edm::InputTag _trackingParticleSrc
 
bool _verbose
 
edm::EDGetTokenT
< edmNew::DetSetVector
< SiPixelCluster > > 
pixelClustersToken_
 
edm::EDGetTokenT
< edm::DetSetVector
< PixelDigiSimLink > > 
sipixelSimLinksToken_
 
edm::EDGetTokenT
< edm::DetSetVector
< StripDigiSimLink > > 
sistripSimLinksToken_
 
edm::EDGetTokenT
< edmNew::DetSetVector
< SiStripCluster > > 
stripClustersToken_
 
edm::EDGetTokenT
< TrackingParticleCollection
trackingParticleToken_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 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 24 of file ClusterTPAssociationProducer.h.

Member Typedef Documentation

Definition at line 28 of file ClusterTPAssociationProducer.h.

Definition at line 29 of file ClusterTPAssociationProducer.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file ClusterTPAssociationProducer.cc.

References edm::ParameterSet::getParameter(), pixelClustersToken_, sipixelSimLinksToken_, sistripSimLinksToken_, stripClustersToken_, and trackingParticleToken_.

24  : _verbose(cfg.getParameter<bool>("verbose")),
25  _pixelSimLinkSrc(cfg.getParameter<edm::InputTag>("pixelSimLinkSrc")),
26  _stripSimLinkSrc(cfg.getParameter<edm::InputTag>("stripSimLinkSrc")),
27  _pixelClusterSrc(cfg.getParameter<edm::InputTag>("pixelClusterSrc")),
28  _stripClusterSrc(cfg.getParameter<edm::InputTag>("stripClusterSrc")),
29  _trackingParticleSrc(cfg.getParameter<edm::InputTag>("trackingParticleSrc"))
30 {
31 
32  sipixelSimLinksToken_ = consumes<edm::DetSetVector<PixelDigiSimLink> >(cfg.getParameter<edm::InputTag>("pixelSimLinkSrc"));
33  sistripSimLinksToken_ = consumes<edm::DetSetVector<StripDigiSimLink> >(cfg.getParameter<edm::InputTag>("stripSimLinkSrc"));
34  pixelClustersToken_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(cfg.getParameter<edm::InputTag>("pixelClusterSrc"));
35  stripClustersToken_ = consumes<edmNew::DetSetVector<SiStripCluster> >(cfg.getParameter<edm::InputTag>("stripClusterSrc"));
36  trackingParticleToken_ = consumes<TrackingParticleCollection>(cfg.getParameter<edm::InputTag>("trackingParticleSrc"));
37 
38  produces<ClusterTPAssociationList>();
39 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersToken_
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClustersToken_
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleToken_
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > sipixelSimLinksToken_
edm::EDGetTokenT< edm::DetSetVector< StripDigiSimLink > > sistripSimLinksToken_
ClusterTPAssociationProducer::~ClusterTPAssociationProducer ( )

Definition at line 41 of file ClusterTPAssociationProducer.cc.

41  {
42 }

Member Function Documentation

virtual void ClusterTPAssociationProducer::beginJob ( void  )
inlineprivatevirtual

Definition at line 35 of file ClusterTPAssociationProducer.h.

35 {}
virtual void ClusterTPAssociationProducer::endJob ( void  )
inlineprivatevirtual

Definition at line 37 of file ClusterTPAssociationProducer.h.

37 {}
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 161 of file ClusterTPAssociationProducer.cc.

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

163 {
164  //std::pair<uint32_t, EncodedEventId> simTrkId;
165  std::vector<std::pair<uint32_t, EncodedEventId> > simTrkId;
166  auto isearch = simLinks->find(detId);
167  if (isearch != simLinks->end()) {
168  // Loop over DigiSimLink in this det unit
169  edm::DetSet<T> link_detset = (*isearch);
170  for (typename edm::DetSet<T>::const_iterator it = link_detset.data.begin();
171  it != link_detset.data.end(); ++it) {
172  if (channel == it->channel()) {
173  simTrkId.push_back(std::make_pair(it->SimTrackId(), it->eventId()));
174  }
175  }
176  }
177  return simTrkId;
178 }
void push_back(const T &t)
Definition: DetSet.h:68
collection_type data
Definition: DetSet.h:78
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
void ClusterTPAssociationProducer::produce ( edm::Event iEvent,
const edm::EventSetup es 
)
privatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 44 of file ClusterTPAssociationProducer.cc.

References SiStripCluster::amplitudes(), edmNew::DetSet< T >::begin(), cond::rpcobgas::detid, edmNew::DetSet< T >::end(), plotBeamSpotDB::first, SiStripCluster::firstStrip(), edm::Event::getByToken(), getDQMSummary::iter, prof2calltree::last, edmNew::makeRefTo(), SiPixelCluster::maxPixelCol(), SiPixelCluster::maxPixelRow(), SiPixelCluster::minPixelCol(), SiPixelCluster::minPixelRow(), HLT_25ns14e33_v1_cff::pixelClusters, pixelClustersToken_, PixelChannelIdentifier::pixelToChannel(), edm::Handle< T >::product(), edm::Event::put(), sipixelSimLinksToken_, sistripSimLinksToken_, HLT_25ns14e33_v1_cff::stripClusters, stripClustersToken_, and trackingParticleToken_.

44  {
45  std::auto_ptr<ClusterTPAssociationList> clusterTPList(new ClusterTPAssociationList);
46 
47  // Pixel DigiSimLink
49  // iEvent.getByLabel(_pixelSimLinkSrc, sipixelSimLinks);
50  iEvent.getByToken(sipixelSimLinksToken_,sipixelSimLinks);
51 
52  // SiStrip DigiSimLink
54  iEvent.getByToken(sistripSimLinksToken_,sistripSimLinks);
55 
56  // Pixel Cluster
58  bool foundPixelClusters = iEvent.getByToken(pixelClustersToken_,pixelClusters);
59 
60  // Strip Cluster
62  bool foundStripClusters = iEvent.getByToken(stripClustersToken_,stripClusters);
63 
64 
65  // TrackingParticle
67  iEvent.getByToken(trackingParticleToken_,TPCollectionH);
68 
69  // prepare temporary map between SimTrackId and TrackingParticle index
70  std::map<std::pair<size_t, EncodedEventId>, TrackingParticleRef> mapping;
72  itp < TPCollectionH.product()->size(); ++itp) {
73  TrackingParticleRef trackingParticle(TPCollectionH, itp);
74 
75  // SimTracks inside TrackingParticle
76  EncodedEventId eid(trackingParticle->eventId());
77  //size_t index = 0;
78  for (std::vector<SimTrack>::const_iterator itrk = trackingParticle->g4Track_begin();
79  itrk != trackingParticle->g4Track_end(); ++itrk) {
80  std::pair<uint32_t, EncodedEventId> trkid(itrk->trackId(), eid);
81  //std::cout << "creating map for id: " << trkid.first << " with tp: " << trackingParticle.key() << std::endl;
82  mapping.insert(std::make_pair(trkid, trackingParticle));
83  }
84  }
85 
86  if ( foundPixelClusters ) {
87  // Pixel Clusters
88  for (edmNew::DetSetVector<SiPixelCluster>::const_iterator iter = pixelClusters->begin();
89  iter != pixelClusters->end(); ++iter) {
90  uint32_t detid = iter->id();
91  DetId detId(detid);
92  edmNew::DetSet<SiPixelCluster> link_pixel = (*iter);
94  di != link_pixel.end(); ++di) {
95  const SiPixelCluster& cluster = (*di);
97  edmNew::makeRefTo(pixelClusters, di);
98 
99  std::set<std::pair<uint32_t, EncodedEventId> > simTkIds;
100  for (int irow = cluster.minPixelRow(); irow <= cluster.maxPixelRow(); ++irow) {
101  for (int icol = cluster.minPixelCol(); icol <= cluster.maxPixelCol(); ++icol) {
102  uint32_t channel = PixelChannelIdentifier::pixelToChannel(irow, icol);
103  std::vector<std::pair<uint32_t, EncodedEventId> > trkid(getSimTrackId<PixelDigiSimLink>(sipixelSimLinks, detId, channel));
104  if (trkid.size()==0) continue;
105  simTkIds.insert(trkid.begin(),trkid.end());
106  }
107  }
108  for (std::set<std::pair<uint32_t, EncodedEventId> >::const_iterator iset = simTkIds.begin();
109  iset != simTkIds.end(); iset++) {
110  auto ipos = mapping.find(*iset);
111  if (ipos != mapping.end()) {
112  //std::cout << "cluster in detid: " << detid << " from tp: " << ipos->second.key() << " " << iset->first << std::endl;
113  clusterTPList->push_back(std::make_pair(OmniClusterRef(c_ref), ipos->second));
114  }
115  }
116  }
117  }
118  }
119 
120  if ( foundStripClusters ) {
121  // Strip Clusters
122  for (edmNew::DetSetVector<SiStripCluster>::const_iterator iter = stripClusters->begin(false), eter = stripClusters->end(false);
123  iter != eter; ++iter) {
124  if (!(*iter).isValid()) continue;
125  uint32_t detid = iter->id();
126  DetId detId(detid);
127  edmNew::DetSet<SiStripCluster> link_strip = (*iter);
129  di != link_strip.end(); di++) {
130  const SiStripCluster& cluster = (*di);
132  edmNew::makeRefTo(stripClusters, di);
133 
134  std::set<std::pair<uint32_t, EncodedEventId> > simTkIds;
135  int first = cluster.firstStrip();
136  int last = first + cluster.amplitudes().size();
137 
138  for (int istr = first; istr < last; ++istr) {
139  std::vector<std::pair<uint32_t, EncodedEventId> > trkid(getSimTrackId<StripDigiSimLink>(sistripSimLinks, detId, istr));
140  if (trkid.size()==0) continue;
141  simTkIds.insert(trkid.begin(),trkid.end());
142  }
143  for (std::set<std::pair<uint32_t, EncodedEventId> >::const_iterator iset = simTkIds.begin();
144  iset != simTkIds.end(); iset++) {
145  auto ipos = mapping.find(*iset);
146  if (ipos != mapping.end()) {
147  //std::cout << "cluster in detid: " << detid << " from tp: " << ipos->second.key() << " " << iset->first << std::endl;
148  clusterTPList->push_back(std::make_pair(OmniClusterRef(c_ref), ipos->second));
149  }
150  }
151  }
152  }
153  }
154 
155  iEvent.put(clusterTPList);
156 }
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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
uint16_t firstStrip() const
data_type const * const_iterator
Definition: DetSetNew.h:30
uint16_t size_type
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersToken_
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClustersToken_
int maxPixelRow() const
int minPixelRow() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleToken_
Definition: DetId.h:18
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > sipixelSimLinksToken_
int maxPixelCol() const
Pixel cluster – collection of neighboring pixels above threshold.
iterator end()
Definition: DetSetNew.h:70
QuickTrackAssociatorByHitsImpl::ClusterTPAssociationList ClusterTPAssociationList
static int pixelToChannel(int row, int col)
edm::EDGetTokenT< edm::DetSetVector< StripDigiSimLink > > sistripSimLinksToken_
const std::vector< uint8_t > & amplitudes() const
iterator begin()
Definition: DetSetNew.h:67

Member Data Documentation

edm::InputTag ClusterTPAssociationProducer::_pixelClusterSrc
private

Definition at line 46 of file ClusterTPAssociationProducer.h.

edm::InputTag ClusterTPAssociationProducer::_pixelSimLinkSrc
private

Definition at line 44 of file ClusterTPAssociationProducer.h.

edm::InputTag ClusterTPAssociationProducer::_stripClusterSrc
private

Definition at line 47 of file ClusterTPAssociationProducer.h.

edm::InputTag ClusterTPAssociationProducer::_stripSimLinkSrc
private

Definition at line 45 of file ClusterTPAssociationProducer.h.

edm::InputTag ClusterTPAssociationProducer::_trackingParticleSrc
private

Definition at line 48 of file ClusterTPAssociationProducer.h.

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

Definition at line 52 of file ClusterTPAssociationProducer.h.

Referenced by ClusterTPAssociationProducer(), and produce().

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

Definition at line 50 of file ClusterTPAssociationProducer.h.

Referenced by ClusterTPAssociationProducer(), and produce().

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

Definition at line 51 of file ClusterTPAssociationProducer.h.

Referenced by ClusterTPAssociationProducer(), and produce().

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

Definition at line 53 of file ClusterTPAssociationProducer.h.

Referenced by ClusterTPAssociationProducer(), and produce().

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

Definition at line 54 of file ClusterTPAssociationProducer.h.

Referenced by ClusterTPAssociationProducer(), and produce().