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
< 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 Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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::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.

Constructor & Destructor Documentation

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

Definition at line 24 of file ClusterTPAssociationProducer.cc.

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

25  : _verbose(cfg.getParameter<bool>("verbose")),
26  _pixelSimLinkSrc(cfg.getParameter<edm::InputTag>("pixelSimLinkSrc")),
27  _stripSimLinkSrc(cfg.getParameter<edm::InputTag>("stripSimLinkSrc")),
28  _pixelClusterSrc(cfg.getParameter<edm::InputTag>("pixelClusterSrc")),
29  _stripClusterSrc(cfg.getParameter<edm::InputTag>("stripClusterSrc")),
30  _trackingParticleSrc(cfg.getParameter<edm::InputTag>("trackingParticleSrc"))
31 {
32 
33  sipixelSimLinksToken_ = consumes<edm::DetSetVector<PixelDigiSimLink> >(cfg.getParameter<edm::InputTag>("pixelSimLinkSrc"));
34  sistripSimLinksToken_ = consumes<edm::DetSetVector<StripDigiSimLink> >(cfg.getParameter<edm::InputTag>("stripSimLinkSrc"));
35  pixelClustersToken_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(cfg.getParameter<edm::InputTag>("pixelClusterSrc"));
36  stripClustersToken_ = consumes<edmNew::DetSetVector<SiStripCluster> >(cfg.getParameter<edm::InputTag>("stripClusterSrc"));
37  trackingParticleToken_ = consumes<TrackingParticleCollection>(cfg.getParameter<edm::InputTag>("trackingParticleSrc"));
38 
39  produces<ClusterTPAssociationList>();
40 }
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 42 of file ClusterTPAssociationProducer.cc.

42  {
43 }

Member Function Documentation

virtual void ClusterTPAssociationProducer::beginJob ( void  )
inlineprivatevirtual

Definition at line 34 of file ClusterTPAssociationProducer.h.

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

Definition at line 36 of file ClusterTPAssociationProducer.h.

36 {}
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 163 of file ClusterTPAssociationProducer.cc.

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

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

References SiStripCluster::amplitudes(), edmNew::DetSet< T >::begin(), clusterTPAssociationListGreater(), cond::rpcobgas::detid, edmNew::DetSet< T >::end(), plotBeamSpotDB::first, SiStripCluster::firstStrip(), edm::Event::getByToken(), 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_, python.multivaluedict::sort(), HLT_25ns14e33_v1_cff::stripClusters, stripClustersToken_, and trackingParticleToken_.

45  {
46  auto clusterTPList = std::make_unique<ClusterTPAssociationList>();
47 
48  // Pixel DigiSimLink
50  // iEvent.getByLabel(_pixelSimLinkSrc, sipixelSimLinks);
51  iEvent.getByToken(sipixelSimLinksToken_,sipixelSimLinks);
52 
53  // SiStrip DigiSimLink
55  iEvent.getByToken(sistripSimLinksToken_,sistripSimLinks);
56 
57  // Pixel Cluster
59  bool foundPixelClusters = iEvent.getByToken(pixelClustersToken_,pixelClusters);
60 
61  // Strip Cluster
63  bool foundStripClusters = iEvent.getByToken(stripClustersToken_,stripClusters);
64 
65 
66  // TrackingParticle
68  iEvent.getByToken(trackingParticleToken_,TPCollectionH);
69 
70  // prepare temporary map between SimTrackId and TrackingParticle index
71  std::map<std::pair<size_t, EncodedEventId>, TrackingParticleRef> mapping;
73  itp < TPCollectionH.product()->size(); ++itp) {
74  TrackingParticleRef trackingParticle(TPCollectionH, itp);
75 
76  // SimTracks inside TrackingParticle
77  EncodedEventId eid(trackingParticle->eventId());
78  //size_t index = 0;
79  for (std::vector<SimTrack>::const_iterator itrk = trackingParticle->g4Track_begin();
80  itrk != trackingParticle->g4Track_end(); ++itrk) {
81  std::pair<uint32_t, EncodedEventId> trkid(itrk->trackId(), eid);
82  //std::cout << "creating map for id: " << trkid.first << " with tp: " << trackingParticle.key() << std::endl;
83  mapping.insert(std::make_pair(trkid, trackingParticle));
84  }
85  }
86 
87  if ( foundPixelClusters ) {
88  // Pixel Clusters
89  for (edmNew::DetSetVector<SiPixelCluster>::const_iterator iter = pixelClusters->begin();
90  iter != pixelClusters->end(); ++iter) {
91  uint32_t detid = iter->id();
92  DetId detId(detid);
93  edmNew::DetSet<SiPixelCluster> link_pixel = (*iter);
95  di != link_pixel.end(); ++di) {
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 
121  if ( foundStripClusters ) {
122  // Strip Clusters
123  for (edmNew::DetSetVector<SiStripCluster>::const_iterator iter = stripClusters->begin(false), eter = stripClusters->end(false);
124  iter != eter; ++iter) {
125  if (!(*iter).isValid()) continue;
126  uint32_t detid = iter->id();
127  DetId detId(detid);
128  edmNew::DetSet<SiStripCluster> link_strip = (*iter);
130  di != link_strip.end(); di++) {
131  const SiStripCluster& cluster = (*di);
133  edmNew::makeRefTo(stripClusters, di);
134 
135  std::set<std::pair<uint32_t, EncodedEventId> > simTkIds;
136  int first = cluster.firstStrip();
137  int last = first + cluster.amplitudes().size();
138 
139  for (int istr = first; istr < last; ++istr) {
140  std::vector<std::pair<uint32_t, EncodedEventId> > trkid(getSimTrackId<StripDigiSimLink>(sistripSimLinks, detId, istr));
141  if (trkid.size()==0) continue;
142  simTkIds.insert(trkid.begin(),trkid.end());
143  }
144  for (std::set<std::pair<uint32_t, EncodedEventId> >::const_iterator iset = simTkIds.begin();
145  iset != simTkIds.end(); iset++) {
146  auto ipos = mapping.find(*iset);
147  if (ipos != mapping.end()) {
148  //std::cout << "cluster in detid: " << detid << " from tp: " << ipos->second.key() << " " << iset->first << std::endl;
149  clusterTPList->push_back(std::make_pair(OmniClusterRef(c_ref), ipos->second));
150  }
151  }
152  }
153  }
154  }
155 
156  std::sort(clusterTPList->begin(), clusterTPList->end(), clusterTPAssociationListGreater);
157  iEvent.put(std::move(clusterTPList));
158 }
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:457
bool clusterTPAssociationListGreater(std::pair< OmniClusterRef, TrackingParticleRef > i, std::pair< OmniClusterRef, TrackingParticleRef > j)
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:115
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
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 45 of file ClusterTPAssociationProducer.h.

edm::InputTag ClusterTPAssociationProducer::_pixelSimLinkSrc
private

Definition at line 43 of file ClusterTPAssociationProducer.h.

edm::InputTag ClusterTPAssociationProducer::_stripClusterSrc
private

Definition at line 46 of file ClusterTPAssociationProducer.h.

edm::InputTag ClusterTPAssociationProducer::_stripSimLinkSrc
private

Definition at line 44 of file ClusterTPAssociationProducer.h.

edm::InputTag ClusterTPAssociationProducer::_trackingParticleSrc
private

Definition at line 47 of file ClusterTPAssociationProducer.h.

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

Definition at line 51 of file ClusterTPAssociationProducer.h.

Referenced by ClusterTPAssociationProducer(), and produce().

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

Definition at line 49 of file ClusterTPAssociationProducer.h.

Referenced by ClusterTPAssociationProducer(), and produce().

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

Definition at line 50 of file ClusterTPAssociationProducer.h.

Referenced by ClusterTPAssociationProducer(), and produce().

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

Definition at line 52 of file ClusterTPAssociationProducer.h.

Referenced by ClusterTPAssociationProducer(), and produce().

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

Definition at line 53 of file ClusterTPAssociationProducer.h.

Referenced by ClusterTPAssociationProducer(), and produce().