CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
ConversionTrackProducer Class Reference

#include <ConversionTrackProducer.h>

Inheritance diagram for ConversionTrackProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 ConversionTrackProducer (const edm::ParameterSet &conf)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
virtual ~ConversionTrackProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

edm::ParameterSet conf_
 
std::auto_ptr
< reco::ConversionTrackCollection
outputTrks
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 36 of file ConversionTrackProducer.h.

Constructor & Destructor Documentation

ConversionTrackProducer::ConversionTrackProducer ( const edm::ParameterSet conf)
explicit

Definition at line 35 of file ConversionTrackProducer.cc.

35  :
36  conf_(conf)
37  {
38  produces<reco::ConversionTrackCollection>();
39 
40  }
ConversionTrackProducer::~ConversionTrackProducer ( )
virtual

Definition at line 44 of file ConversionTrackProducer.cc.

44 { }

Member Function Documentation

void ConversionTrackProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDProducer.

Definition at line 47 of file ConversionTrackProducer.cc.

References conf_, edm::Event::getByLabel(), edm::ParameterSet::getParameter(), outputTrks, edm::Event::put(), reco::ConversionTrack::setIsArbitratedEcalSeeded(), reco::ConversionTrack::setIsArbitratedMerged(), reco::ConversionTrack::setIsArbitratedMergedEcalGeneral(), reco::ConversionTrack::setIsTrackerOnly(), and reco::ConversionTrack::setTrajRef().

48  {
49  // retrieve producer name of input TrackCollection(s)
50  std::string trackProducer = conf_.getParameter<std::string>("TrackProducer");
51  bool useTrajectory = conf_.getParameter<bool>("useTrajectory");
52  bool setTrackerOnly = conf_.getParameter<bool>("setTrackerOnly");
53  bool setArbitratedEcalSeeded = conf_.getParameter<bool>("setArbitratedEcalSeeded");
54  bool setArbitratedMerged = conf_.getParameter<bool>("setArbitratedMerged");
55  bool setArbitratedMergedEcalGeneral = conf_.getParameter<bool>("setArbitratedMergedEcalGeneral");
56 
57  //get input collection (through edm::View)
59  e.getByLabel(trackProducer, hTrks);
60 
61  //get association maps between trajectories and tracks and build temporary maps
64  reco::GsfTrackCollection,unsigned short> > > hTTAssGsf;
65 
66  std::map<reco::TrackRef,edm::Ref<std::vector<Trajectory> > > tracktrajmap;
67  std::map<reco::GsfTrackRef,edm::Ref<std::vector<Trajectory> > > gsftracktrajmap;
68 
69  if (useTrajectory) {
70  if (hTrks->size()>0) {
71  if (dynamic_cast<const reco::GsfTrack*>(&hTrks->at(0))) {
72  //fill map for gsf tracks
73  e.getByLabel(trackProducer, hTTAssGsf);
74  for ( edm::AssociationMap<edm::OneToOne<std::vector<Trajectory>,
75  reco::GsfTrackCollection,unsigned short> >::const_iterator iPair = hTTAssGsf->begin();
76  iPair != hTTAssGsf->end(); ++iPair) {
77 
78  gsftracktrajmap[iPair->val] = iPair->key;
79 
80  }
81 
82  }
83  else {
84  //fill map for standard tracks
85  e.getByLabel(trackProducer, hTTAss);
86  for ( TrajTrackAssociationCollection::const_iterator iPair = hTTAss->begin();
87  iPair != hTTAss->end();
88  ++iPair) {
89 
90  tracktrajmap[iPair->val] = iPair->key;
91 
92  }
93  }
94  }
95  }
96 
97  // Step B: create empty output collection
98  outputTrks = std::auto_ptr<reco::ConversionTrackCollection>(new reco::ConversionTrackCollection);
99 
100  // Simple conversion of tracks to conversion tracks, setting appropriate flags from configuration
101  for (edm::RefToBaseVector<reco::Track>::const_iterator it = hTrks->refVector().begin(); it != hTrks->refVector().end(); ++it) {
102  reco::ConversionTrack convTrack(*it);
103  convTrack.setIsTrackerOnly(setTrackerOnly);
104  convTrack.setIsArbitratedEcalSeeded(setArbitratedEcalSeeded);
105  convTrack.setIsArbitratedMerged(setArbitratedMerged);
106  convTrack.setIsArbitratedMergedEcalGeneral(setArbitratedMergedEcalGeneral);
107 
108  //fill trajectory association if configured, using correct map depending on track type
109  if (useTrajectory) {
110  if (gsftracktrajmap.size()) {
111  convTrack.setTrajRef(gsftracktrajmap.find(it->castTo<reco::GsfTrackRef>())->second);
112  }
113  else {
114  convTrack.setTrajRef(tracktrajmap.find(it->castTo<reco::TrackRef>())->second);
115  }
116  }
117 
118  outputTrks->push_back(convTrack);
119  }
120 
121  e.put(outputTrks);
122  return;
123 
124  }//end produce
T getParameter(std::string const &) const
std::vector< ConversionTrack > ConversionTrackCollection
collection of ConversionTracks
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
std::auto_ptr< reco::ConversionTrackCollection > outputTrks
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355

Member Data Documentation

edm::ParameterSet ConversionTrackProducer::conf_
private

Definition at line 47 of file ConversionTrackProducer.h.

Referenced by produce().

std::auto_ptr<reco::ConversionTrackCollection> ConversionTrackProducer::outputTrks
private

Definition at line 49 of file ConversionTrackProducer.h.

Referenced by produce().