CMS 3D CMS Logo

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

List of all members.

Public Types

typedef std::vector< SimHitTPPairSimHitTPAssociationList
typedef std::pair
< TrackingParticleRef,
TrackPSimHitRef
SimHitTPPair

Public Member Functions

 SimHitTPAssociationProducer (const edm::ParameterSet &)
 ~SimHitTPAssociationProducer ()

Static Public Member Functions

static bool simHitTPAssociationListGreater (SimHitTPPair i, SimHitTPPair j)

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

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.

  : _simHitSrc(cfg.getParameter<std::vector<edm::InputTag> >("simHitSrc")),
    _trackingParticleSrc(cfg.getParameter<edm::InputTag>("trackingParticleSrc"))
{
  produces<SimHitTPAssociationList>();
}
SimHitTPAssociationProducer::~SimHitTPAssociationProducer ( )

Definition at line 24 of file SimHitTPAssociationProducer.cc.

                                                          {
}

Member Function Documentation

virtual void SimHitTPAssociationProducer::beginJob ( void  ) [inline, private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 27 of file SimHitTPAssociationProducer.h.

{}
virtual void SimHitTPAssociationProducer::endJob ( void  ) [inline, private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 29 of file SimHitTPAssociationProducer.h.

{}
void SimHitTPAssociationProducer::produce ( edm::Event iEvent,
const edm::EventSetup es 
) [private, virtual]

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().

                                                                                   {
  std::auto_ptr<SimHitTPAssociationList> simHitTPList(new SimHitTPAssociationList);
 
  // TrackingParticle
  edm::Handle<TrackingParticleCollection>  TPCollectionH;
  iEvent.getByLabel(_trackingParticleSrc,  TPCollectionH);

  // prepare temporary map between SimTrackId and TrackingParticle index
  std::map<std::pair<size_t, EncodedEventId>, TrackingParticleRef> mapping;
  for (TrackingParticleCollection::size_type itp = 0; itp < TPCollectionH.product()->size(); ++itp) {
    TrackingParticleRef trackingParticle(TPCollectionH, itp);
    // SimTracks inside TrackingParticle
    EncodedEventId eid(trackingParticle->eventId());
    for (auto itrk  = trackingParticle->g4Track_begin(); itrk != trackingParticle->g4Track_end(); ++itrk) {
      std::pair<uint32_t, EncodedEventId> trkid(itrk->trackId(), eid);
      mapping.insert(std::make_pair(trkid, trackingParticle));
    }
  }

  // PSimHits
  for (auto psit=_simHitSrc.begin();psit<_simHitSrc.end();++psit) {
    edm::Handle<edm::PSimHitContainer>  PSimHitCollectionH;
    iEvent.getByLabel(*psit,  PSimHitCollectionH);
    for (unsigned int psimHit = 0;psimHit != PSimHitCollectionH->size();++psimHit) {
      TrackPSimHitRef pSimHitRef(PSimHitCollectionH,psimHit);
      std::pair<uint32_t, EncodedEventId> simTkIds(pSimHitRef->trackId(),pSimHitRef->eventId()); 
      auto ipos = mapping.find(simTkIds);
      if (ipos != mapping.end()) {
        simHitTPList->push_back(std::make_pair(ipos->second,pSimHitRef));
      }
    }
  } 
  
  std::sort(simHitTPList->begin(),simHitTPList->end(),simHitTPAssociationListGreater);
  iEvent.put(simHitTPList);

}
static bool SimHitTPAssociationProducer::simHitTPAssociationListGreater ( SimHitTPPair  i,
SimHitTPPair  j 
) [inline, static]

Member Data Documentation

Definition at line 31 of file SimHitTPAssociationProducer.h.

Referenced by produce().

Definition at line 32 of file SimHitTPAssociationProducer.h.

Referenced by produce().