test
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 | 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
< OmniClusterRef
OmniClusterCollection
 
- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase 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::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &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 ()
 

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

Private Attributes

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

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

Member Typedef Documentation

Definition at line 33 of file ClusterTPAssociationProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 54 of file ClusterTPAssociationProducer.cc.

59  trackingParticleToken_(consumes<TrackingParticleCollection>(cfg.getParameter<edm::InputTag>("trackingParticleSrc")))
60 {
61  produces<ClusterTPAssociation>();
62 }
T getParameter(std::string const &) const
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 ( )

Definition at line 64 of file ClusterTPAssociationProducer.cc.

64  {
65 }

Member Function Documentation

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

Definition at line 67 of file ClusterTPAssociationProducer.cc.

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

67  {
69  desc.add<edm::InputTag>("simTrackSrc", edm::InputTag("g4SimHits"));
70  desc.add<edm::InputTag>("pixelSimLinkSrc", edm::InputTag("simSiPixelDigis"));
71  desc.add<edm::InputTag>("stripSimLinkSrc", edm::InputTag("simSiStripDigis"));
72  desc.add<edm::InputTag>("pixelClusterSrc", edm::InputTag("siPixelClusters"));
73  desc.add<edm::InputTag>("stripClusterSrc", edm::InputTag("siStripClusters"));
74  desc.add<edm::InputTag>("trackingParticleSrc", edm::InputTag("mix", "MergedTrackTruth"));
75  descriptions.add("tpClusterProducer", desc);
76 }
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 196 of file ClusterTPAssociationProducer.cc.

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

198 {
199  //std::pair<uint32_t, EncodedEventId> simTrkId;
200  std::vector<std::pair<uint32_t, EncodedEventId> > simTrkId;
201  auto isearch = simLinks->find(detId);
202  if (isearch != simLinks->end()) {
203  // Loop over DigiSimLink in this det unit
204  edm::DetSet<T> link_detset = (*isearch);
205  for (typename edm::DetSet<T>::const_iterator it = link_detset.data.begin();
206  it != link_detset.data.end(); ++it) {
207  if (channel == it->channel()) {
208  simTrkId.push_back(std::make_pair(it->SimTrackId(), it->eventId()));
209  }
210  }
211  }
212  return simTrkId;
213 }
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::StreamID  ,
edm::Event iEvent,
const edm::EventSetup es 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 78 of file ClusterTPAssociationProducer.cc.

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

78  {
79  // Pixel DigiSimLink
81  // iEvent.getByLabel(_pixelSimLinkSrc, sipixelSimLinks);
82  iEvent.getByToken(sipixelSimLinksToken_,sipixelSimLinks);
83 
84  // SiStrip DigiSimLink
86  iEvent.getByToken(sistripSimLinksToken_,sistripSimLinks);
87 
88  // Pixel Cluster
90  bool foundPixelClusters = iEvent.getByToken(pixelClustersToken_,pixelClusters);
91 
92  // Strip Cluster
94  bool foundStripClusters = iEvent.getByToken(stripClustersToken_,stripClusters);
95 
96 
97  // TrackingParticle
99  iEvent.getByToken(trackingParticleToken_,TPCollectionH);
100 
101  auto clusterTPList = std::make_unique<ClusterTPAssociation>(TPCollectionH);
102 
103  // prepare temporary map between SimTrackId and TrackingParticle index
104  std::map<std::pair<size_t, EncodedEventId>, TrackingParticleRef> mapping;
106  itp < TPCollectionH.product()->size(); ++itp) {
107  TrackingParticleRef trackingParticle(TPCollectionH, itp);
108 
109  // SimTracks inside TrackingParticle
110  EncodedEventId eid(trackingParticle->eventId());
111  //size_t index = 0;
112  for (std::vector<SimTrack>::const_iterator itrk = trackingParticle->g4Track_begin();
113  itrk != trackingParticle->g4Track_end(); ++itrk) {
114  std::pair<uint32_t, EncodedEventId> trkid(itrk->trackId(), eid);
115  //std::cout << "creating map for id: " << trkid.first << " with tp: " << trackingParticle.key() << std::endl;
116  mapping.insert(std::make_pair(trkid, trackingParticle));
117  }
118  }
119 
120  if ( foundPixelClusters ) {
121  // Pixel Clusters
122  for (edmNew::DetSetVector<SiPixelCluster>::const_iterator iter = pixelClusters->begin();
123  iter != pixelClusters->end(); ++iter) {
124  uint32_t detid = iter->id();
125  DetId detId(detid);
126  edmNew::DetSet<SiPixelCluster> link_pixel = (*iter);
128  di != link_pixel.end(); ++di) {
129  const SiPixelCluster& cluster = (*di);
131  edmNew::makeRefTo(pixelClusters, di);
132 
133  std::set<std::pair<uint32_t, EncodedEventId> > simTkIds;
134  for (int irow = cluster.minPixelRow(); irow <= cluster.maxPixelRow(); ++irow) {
135  for (int icol = cluster.minPixelCol(); icol <= cluster.maxPixelCol(); ++icol) {
136  uint32_t channel = PixelChannelIdentifier::pixelToChannel(irow, icol);
137  std::vector<std::pair<uint32_t, EncodedEventId> > trkid(getSimTrackId<PixelDigiSimLink>(sipixelSimLinks, detId, channel));
138  if (trkid.size()==0) continue;
139  simTkIds.insert(trkid.begin(),trkid.end());
140  }
141  }
142  for (std::set<std::pair<uint32_t, EncodedEventId> >::const_iterator iset = simTkIds.begin();
143  iset != simTkIds.end(); iset++) {
144  auto ipos = mapping.find(*iset);
145  if (ipos != mapping.end()) {
146  //std::cout << "cluster in detid: " << detid << " from tp: " << ipos->second.key() << " " << iset->first << std::endl;
147  clusterTPList->emplace_back(OmniClusterRef(c_ref), ipos->second);
148  }
149  }
150  }
151  }
152  }
153 
154  if ( foundStripClusters ) {
155  // Strip Clusters
156  for (edmNew::DetSetVector<SiStripCluster>::const_iterator iter = stripClusters->begin(false), eter = stripClusters->end(false);
157  iter != eter; ++iter) {
158  if (!(*iter).isValid()) continue;
159  uint32_t detid = iter->id();
160  DetId detId(detid);
161  edmNew::DetSet<SiStripCluster> link_strip = (*iter);
163  di != link_strip.end(); di++) {
164  const SiStripCluster& cluster = (*di);
166  edmNew::makeRefTo(stripClusters, di);
167 
168  std::set<std::pair<uint32_t, EncodedEventId> > simTkIds;
169  int first = cluster.firstStrip();
170  int last = first + cluster.amplitudes().size();
171 
172  for (int istr = first; istr < last; ++istr) {
173  std::vector<std::pair<uint32_t, EncodedEventId> > trkid(getSimTrackId<StripDigiSimLink>(sistripSimLinks, detId, istr));
174  if (trkid.size()==0) continue;
175  simTkIds.insert(trkid.begin(),trkid.end());
176  }
177  for (std::set<std::pair<uint32_t, EncodedEventId> >::const_iterator iset = simTkIds.begin();
178  iset != simTkIds.end(); iset++) {
179  auto ipos = mapping.find(*iset);
180  if (ipos != mapping.end()) {
181  //std::cout << "cluster in detid: " << detid << " from tp: " << ipos->second.key() << " " << iset->first << std::endl;
182  clusterTPList->emplace_back(OmniClusterRef(c_ref), ipos->second);
183  }
184  }
185  }
186  }
187  }
188 
189  clusterTPList->sort();
190  iEvent.put(std::move(clusterTPList));
191 }
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:462
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:121
def move
Definition: eostools.py:510
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::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > ClusterTPAssociationProducer::pixelClustersToken_
private

Definition at line 49 of file ClusterTPAssociationProducer.cc.

Referenced by produce().

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

Definition at line 47 of file ClusterTPAssociationProducer.cc.

Referenced by produce().

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

Definition at line 48 of file ClusterTPAssociationProducer.cc.

Referenced by produce().

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

Definition at line 50 of file ClusterTPAssociationProducer.cc.

Referenced by produce().

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

Definition at line 51 of file ClusterTPAssociationProducer.cc.

Referenced by produce().