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
SimHitTPAssociationProducer Class Reference

#include <SimHitTPAssociationProducer.h>

Inheritance diagram for SimHitTPAssociationProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef std::vector< SimHitTPPairSimHitTPAssociationList
 
typedef std::pair
< TrackingParticleRef,
TrackPSimHitRef
SimHitTPPair
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

 SimHitTPAssociationProducer (const edm::ParameterSet &)
 
 ~SimHitTPAssociationProducer ()
 
- 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 ()
 

Static Public Member Functions

static bool simHitTPAssociationListGreater (SimHitTPPair i, SimHitTPPair j)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

std::vector< edm::InputTag_simHitSrc
 
edm::InputTag _trackingParticleSrc
 

Additional Inherited Members

- 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 14 of file SimHitTPAssociationProducer.h.

Member Typedef Documentation

Definition at line 19 of file SimHitTPAssociationProducer.h.

Definition at line 18 of file SimHitTPAssociationProducer.h.

Constructor & Destructor Documentation

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

Definition at line 17 of file SimHitTPAssociationProducer.cc.

18  : _simHitSrc(cfg.getParameter<std::vector<edm::InputTag> >("simHitSrc")),
19  _trackingParticleSrc(cfg.getParameter<edm::InputTag>("trackingParticleSrc"))
20 {
21  produces<SimHitTPAssociationList>();
22 }
T getParameter(std::string const &) const
std::vector< edm::InputTag > _simHitSrc
SimHitTPAssociationProducer::~SimHitTPAssociationProducer ( )

Definition at line 24 of file SimHitTPAssociationProducer.cc.

24  {
25 }

Member Function Documentation

virtual void SimHitTPAssociationProducer::beginJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 27 of file SimHitTPAssociationProducer.h.

27 {}
virtual void SimHitTPAssociationProducer::endJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 29 of file SimHitTPAssociationProducer.h.

29 {}
void SimHitTPAssociationProducer::produce ( edm::Event iEvent,
const edm::EventSetup es 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 27 of file SimHitTPAssociationProducer.cc.

References _simHitSrc, _trackingParticleSrc, edm::Event::getByLabel(), edm::Handle< T >::product(), edm::Event::put(), simHitTPAssociationListGreater(), and python.multivaluedict::sort().

27  {
28  std::auto_ptr<SimHitTPAssociationList> simHitTPList(new SimHitTPAssociationList);
29 
30  // TrackingParticle
32  iEvent.getByLabel(_trackingParticleSrc, TPCollectionH);
33 
34  // prepare temporary map between SimTrackId and TrackingParticle index
35  std::map<std::pair<size_t, EncodedEventId>, TrackingParticleRef> mapping;
36  for (TrackingParticleCollection::size_type itp = 0; itp < TPCollectionH.product()->size(); ++itp) {
37  TrackingParticleRef trackingParticle(TPCollectionH, itp);
38  // SimTracks inside TrackingParticle
39  EncodedEventId eid(trackingParticle->eventId());
40  for (auto itrk = trackingParticle->g4Track_begin(); itrk != trackingParticle->g4Track_end(); ++itrk) {
41  std::pair<uint32_t, EncodedEventId> trkid(itrk->trackId(), eid);
42  mapping.insert(std::make_pair(trkid, trackingParticle));
43  }
44  }
45 
46  // PSimHits
47  for (auto psit=_simHitSrc.begin();psit<_simHitSrc.end();++psit) {
48  edm::Handle<edm::PSimHitContainer> PSimHitCollectionH;
49  iEvent.getByLabel(*psit, PSimHitCollectionH);
50  for (unsigned int psimHit = 0;psimHit != PSimHitCollectionH->size();++psimHit) {
51  TrackPSimHitRef pSimHitRef(PSimHitCollectionH,psimHit);
52  std::pair<uint32_t, EncodedEventId> simTkIds(pSimHitRef->trackId(),pSimHitRef->eventId());
53  auto ipos = mapping.find(simTkIds);
54  if (ipos != mapping.end()) {
55  simHitTPList->push_back(std::make_pair(ipos->second,pSimHitRef));
56  }
57  }
58  }
59 
60  std::sort(simHitTPList->begin(),simHitTPList->end(),simHitTPAssociationListGreater);
61  iEvent.put(simHitTPList);
62 
63 }
static bool simHitTPAssociationListGreater(SimHitTPPair i, SimHitTPPair j)
std::vector< edm::InputTag > _simHitSrc
uint16_t size_type
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
T const * product() const
Definition: Handle.h:81
std::vector< SimHitTPPair > SimHitTPAssociationList
static bool SimHitTPAssociationProducer::simHitTPAssociationListGreater ( SimHitTPPair  i,
SimHitTPPair  j 
)
inlinestatic

Member Data Documentation

std::vector<edm::InputTag> SimHitTPAssociationProducer::_simHitSrc
private

Definition at line 31 of file SimHitTPAssociationProducer.h.

Referenced by produce().

edm::InputTag SimHitTPAssociationProducer::_trackingParticleSrc
private

Definition at line 32 of file SimHitTPAssociationProducer.h.

Referenced by produce().