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
 
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
 

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 19 of file ClusterTPAssociationProducer.h.

Member Typedef Documentation

Definition at line 23 of file ClusterTPAssociationProducer.h.

Definition at line 24 of file ClusterTPAssociationProducer.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file ClusterTPAssociationProducer.cc.

29  : _verbose(cfg.getParameter<bool>("verbose")),
30  _pixelSimLinkSrc(cfg.getParameter<edm::InputTag>("pixelSimLinkSrc")),
31  _stripSimLinkSrc(cfg.getParameter<edm::InputTag>("stripSimLinkSrc")),
32  _pixelClusterSrc(cfg.getParameter<edm::InputTag>("pixelClusterSrc")),
33  _stripClusterSrc(cfg.getParameter<edm::InputTag>("stripClusterSrc")),
34  _trackingParticleSrc(cfg.getParameter<edm::InputTag>("trackingParticleSrc"))
35 {
36  produces<ClusterTPAssociationList>();
37 }
T getParameter(std::string const &) const
ClusterTPAssociationProducer::~ClusterTPAssociationProducer ( )

Definition at line 39 of file ClusterTPAssociationProducer.cc.

39  {
40 }

Member Function Documentation

virtual void ClusterTPAssociationProducer::beginJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 30 of file ClusterTPAssociationProducer.h.

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

Reimplemented from edm::EDProducer.

Definition at line 32 of file ClusterTPAssociationProducer.h.

32 {}
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 152 of file ClusterTPAssociationProducer.cc.

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

154 {
155  //std::pair<uint32_t, EncodedEventId> simTrkId;
156  std::vector<std::pair<uint32_t, EncodedEventId> > simTrkId;
157  auto isearch = simLinks->find(detId);
158  if (isearch != simLinks->end()) {
159  // Loop over DigiSimLink in this det unit
160  edm::DetSet<T> link_detset = (*isearch);
161  for (typename edm::DetSet<T>::const_iterator it = link_detset.data.begin();
162  it != link_detset.data.end(); ++it) {
163  if (channel == it->channel()) {
164  simTrkId.push_back(std::make_pair(it->SimTrackId(), it->eventId()));
165  }
166  }
167  }
168  return simTrkId;
169 }
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 42 of file ClusterTPAssociationProducer.cc.

References _pixelClusterSrc, _pixelSimLinkSrc, _stripClusterSrc, _stripSimLinkSrc, _trackingParticleSrc, SiStripCluster::amplitudes(), edmNew::DetSet< T >::begin(), cond::rpcobgas::detid, edmNew::DetSet< T >::end(), first, SiStripCluster::firstStrip(), edm::Event::getByLabel(), prof2calltree::last, edmNew::makeRefTo(), SiPixelCluster::maxPixelCol(), SiPixelCluster::maxPixelRow(), SiPixelCluster::minPixelCol(), SiPixelCluster::minPixelRow(), clustersummaryproducer_cfg::pixelClusters, PixelChannelIdentifier::pixelToChannel(), edm::Handle< T >::product(), edm::Event::put(), and clustersummaryproducer_cfg::stripClusters.

42  {
43  std::auto_ptr<ClusterTPAssociationList> clusterTPList(new ClusterTPAssociationList);
44 
45  // Pixel DigiSimLink
47  iEvent.getByLabel(_pixelSimLinkSrc, sipixelSimLinks);
48 
49  // SiStrip DigiSimLink
51  iEvent.getByLabel(_stripSimLinkSrc, sistripSimLinks);
52 
53  // Pixel Cluster
55  iEvent.getByLabel(_pixelClusterSrc, pixelClusters);
56 
57  // Strip Cluster
59  iEvent.getByLabel(_stripClusterSrc, stripClusters);
60 
61  // TrackingParticle
63  iEvent.getByLabel(_trackingParticleSrc, TPCollectionH);
64 
65  // prepare temporary map between SimTrackId and TrackingParticle index
66  std::map<std::pair<size_t, EncodedEventId>, TrackingParticleRef> mapping;
68  itp < TPCollectionH.product()->size(); ++itp) {
69  TrackingParticleRef trackingParticle(TPCollectionH, itp);
70 
71  // SimTracks inside TrackingParticle
72  EncodedEventId eid(trackingParticle->eventId());
73  //size_t index = 0;
74  for (std::vector<SimTrack>::const_iterator itrk = trackingParticle->g4Track_begin();
75  itrk != trackingParticle->g4Track_end(); ++itrk) {
76  std::pair<uint32_t, EncodedEventId> trkid(itrk->trackId(), eid);
77  //std::cout << "creating map for id: " << trkid.first << " with tp: " << trackingParticle.key() << std::endl;
78  mapping.insert(std::make_pair(trkid, trackingParticle));
79  }
80  }
81 
82  // Pixel Clusters
83  for (edmNew::DetSetVector<SiPixelCluster>::const_iterator iter = pixelClusters->begin();
84  iter != pixelClusters->end(); ++iter)
85  {
86  uint32_t detid = iter->id();
87  DetId detId(detid);
88  edmNew::DetSet<SiPixelCluster> link_pixel = (*iter);
90  di != link_pixel.end(); ++di)
91  {
92  const SiPixelCluster& cluster = (*di);
94  edmNew::makeRefTo(pixelClusters, di);
95 
96  std::set<std::pair<uint32_t, EncodedEventId> > simTkIds;
97  for (int irow = cluster.minPixelRow(); irow <= cluster.maxPixelRow(); ++irow) {
98  for (int icol = cluster.minPixelCol(); icol <= cluster.maxPixelCol(); ++icol) {
99  uint32_t channel = PixelChannelIdentifier::pixelToChannel(irow, icol);
100  std::vector<std::pair<uint32_t, EncodedEventId> > trkid(getSimTrackId<PixelDigiSimLink>(sipixelSimLinks, detId, channel));
101  if (trkid.size()==0) continue;
102  simTkIds.insert(trkid.begin(),trkid.end());
103  }
104  }
105  for (std::set<std::pair<uint32_t, EncodedEventId> >::const_iterator iset = simTkIds.begin();
106  iset != simTkIds.end(); iset++) {
107  auto ipos = mapping.find(*iset);
108  if (ipos != mapping.end()) {
109  //std::cout << "cluster in detid: " << detid << " from tp: " << ipos->second.key() << " " << iset->first << std::endl;
110  clusterTPList->push_back(std::make_pair(OmniClusterRef(c_ref), ipos->second));
111  }
112  }
113  }
114  }
115 
116  // Strip Clusters
117  for (edmNew::DetSetVector<SiStripCluster>::const_iterator iter = stripClusters->begin();
118  iter != stripClusters->end(); ++iter) {
119  uint32_t detid = iter->id();
120  DetId detId(detid);
121  edmNew::DetSet<SiStripCluster> link_strip = (*iter);
123  di != link_strip.end(); di++) {
124  const SiStripCluster& cluster = (*di);
126  edmNew::makeRefTo(stripClusters, di);
127 
128  std::set<std::pair<uint32_t, EncodedEventId> > simTkIds;
129  int first = cluster.firstStrip();
130  int last = first + cluster.amplitudes().size();
131 
132  for (int istr = first; istr < last; ++istr) {
133  std::vector<std::pair<uint32_t, EncodedEventId> > trkid(getSimTrackId<StripDigiSimLink>(sistripSimLinks, detId, istr));
134  if (trkid.size()==0) continue;
135  simTkIds.insert(trkid.begin(),trkid.end());
136  }
137  for (std::set<std::pair<uint32_t, EncodedEventId> >::const_iterator iset = simTkIds.begin();
138  iset != simTkIds.end(); iset++) {
139  auto ipos = mapping.find(*iset);
140  if (ipos != mapping.end()) {
141  //std::cout << "cluster in detid: " << detid << " from tp: " << ipos->second.key() << " " << iset->first << std::endl;
142  clusterTPList->push_back(std::make_pair(OmniClusterRef(c_ref), ipos->second));
143  }
144  }
145  }
146  }
147  iEvent.put(clusterTPList);
148 }
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
uint16_t firstStrip() const
data_type const * const_iterator
Definition: DetSetNew.h:30
uint16_t size_type
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:79
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
Definition: DetId.h:18
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)
const std::vector< uint8_t > & amplitudes() const
iterator begin()
Definition: DetSetNew.h:67

Member Data Documentation

edm::InputTag ClusterTPAssociationProducer::_pixelClusterSrc
private

Definition at line 41 of file ClusterTPAssociationProducer.h.

Referenced by produce().

edm::InputTag ClusterTPAssociationProducer::_pixelSimLinkSrc
private

Definition at line 39 of file ClusterTPAssociationProducer.h.

Referenced by produce().

edm::InputTag ClusterTPAssociationProducer::_stripClusterSrc
private

Definition at line 42 of file ClusterTPAssociationProducer.h.

Referenced by produce().

edm::InputTag ClusterTPAssociationProducer::_stripSimLinkSrc
private

Definition at line 40 of file ClusterTPAssociationProducer.h.

Referenced by produce().

edm::InputTag ClusterTPAssociationProducer::_trackingParticleSrc
private

Definition at line 43 of file ClusterTPAssociationProducer.h.

Referenced by produce().

bool ClusterTPAssociationProducer::_verbose
private