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::EDProducer 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::EDProducer
typedef EDProducer 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::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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
 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
 
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::EDProducer
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

Reimplemented from edm::EDProducer.

Definition at line 35 of file ClusterTPAssociationProducer.h.

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

Reimplemented from edm::EDProducer.

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 159 of file ClusterTPAssociationProducer.cc.

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

161 {
162  //std::pair<uint32_t, EncodedEventId> simTrkId;
163  std::vector<std::pair<uint32_t, EncodedEventId> > simTrkId;
164  auto isearch = simLinks->find(detId);
165  if (isearch != simLinks->end()) {
166  // Loop over DigiSimLink in this det unit
167  edm::DetSet<T> link_detset = (*isearch);
168  for (typename edm::DetSet<T>::const_iterator it = link_detset.data.begin();
169  it != link_detset.data.end(); ++it) {
170  if (channel == it->channel()) {
171  simTrkId.push_back(std::make_pair(it->SimTrackId(), it->eventId()));
172  }
173  }
174  }
175  return simTrkId;
176 }
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::EDProducer.

Definition at line 44 of file ClusterTPAssociationProducer.cc.

References SiStripCluster::amplitudes(), edmNew::DetSet< T >::begin(), cond::rpcobgas::detid, edmNew::DetSet< T >::end(), first, SiStripCluster::firstStrip(), edm::Event::getByToken(), getDQMSummary::iter, prof2calltree::last, edmNew::makeRefTo(), SiPixelCluster::maxPixelCol(), SiPixelCluster::maxPixelRow(), SiPixelCluster::minPixelCol(), SiPixelCluster::minPixelRow(), clustersummaryproducer_cfg::pixelClusters, pixelClustersToken_, PixelChannelIdentifier::pixelToChannel(), edm::Handle< T >::product(), edm::Event::put(), sipixelSimLinksToken_, sistripSimLinksToken_, clustersummaryproducer_cfg::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  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  // Pixel Clusters
87  for (edmNew::DetSetVector<SiPixelCluster>::const_iterator iter = pixelClusters->begin();
88  iter != pixelClusters->end(); ++iter)
89  {
90  uint32_t detid = iter->id();
91  DetId detId(detid);
92  edmNew::DetSet<SiPixelCluster> link_pixel = (*iter);
94  di != link_pixel.end(); ++di)
95  {
96  const SiPixelCluster& cluster = (*di);
98  edmNew::makeRefTo(pixelClusters, di);
99 
100  std::set<std::pair<uint32_t, EncodedEventId> > simTkIds;
101  for (int irow = cluster.minPixelRow(); irow <= cluster.maxPixelRow(); ++irow) {
102  for (int icol = cluster.minPixelCol(); icol <= cluster.maxPixelCol(); ++icol) {
103  uint32_t channel = PixelChannelIdentifier::pixelToChannel(irow, icol);
104  std::vector<std::pair<uint32_t, EncodedEventId> > trkid(getSimTrackId<PixelDigiSimLink>(sipixelSimLinks, detId, channel));
105  if (trkid.size()==0) continue;
106  simTkIds.insert(trkid.begin(),trkid.end());
107  }
108  }
109  for (std::set<std::pair<uint32_t, EncodedEventId> >::const_iterator iset = simTkIds.begin();
110  iset != simTkIds.end(); iset++) {
111  auto ipos = mapping.find(*iset);
112  if (ipos != mapping.end()) {
113  //std::cout << "cluster in detid: " << detid << " from tp: " << ipos->second.key() << " " << iset->first << std::endl;
114  clusterTPList->push_back(std::make_pair(OmniClusterRef(c_ref), ipos->second));
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  iEvent.put(clusterTPList);
155 }
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:434
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:116
bool first
Definition: L1TdeRCT.cc:75
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleToken_
Definition: DetId.h:18
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > sipixelSimLinksToken_
std::vector< std::pair< OmniClusterRef, TrackingParticleRef > > ClusterTPAssociationList
int maxPixelCol() const
T const * product() const
Definition: Handle.h:81
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
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().