CMS 3D CMS Logo

TrackAssociatorByPositionProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SimTracker/TrackAssociatorProducers
4 // Class: TrackAssociatorByPositionProducer
5 //
13 //
14 // Original Author: Christopher Jones
15 // Created: Mon, 05 Jan 2015 22:05:57 GMT
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
31 
36 
37 //
38 // class declaration
39 //
41 
43  public:
46 
47  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
48 
49  private:
50  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
51 
52  // ----------member data ---------------------------
55  double theQminCut;
56  double theQCut;
61 };
62 
63 //
64 // constants, enums and typedefs
65 //
66 
67 
68 //
69 // static data member definitions
70 //
71 static
73  if (meth=="chi2"){ return TrackAssociatorByPositionImpl::Method::chi2; }
74  else if (meth=="dist"){return TrackAssociatorByPositionImpl::Method::dist;}
75  else if (meth=="momdr"){return TrackAssociatorByPositionImpl::Method::momdr;}
76  else if (meth=="posdr"){return TrackAssociatorByPositionImpl::Method::posdr;}
77  else{
78  throw cms::Exception("BadParameterName")<<meth<<" TrackAssociatorByPostionImpl::Method name not recognized.";
79  }
80 }
81 
82 //
83 // constructors and destructor
84 //
86  theSimHitTpMapToken{consumes<SimHitTPAssociationList>(iConfig.getParameter<edm::InputTag>("simHitTpMapTag"))},
87  thePname{iConfig.getParameter<std::string>("propagator")},
88  theQminCut{iConfig.getParameter<double>("QminCut")},
89  theQCut{iConfig.getParameter<double>("QCut")},
90  thePositionMinimumDistance{iConfig.getParameter<double>("positionMinimumDistance")},
91  theMethod{parseMethodName(iConfig.getParameter<std::string>("method"))},
92  theMinIfNoMatch{iConfig.getParameter<bool>("MinIfNoMatch")},
93  theConsiderAllSimHits{iConfig.getParameter<bool>("ConsiderAllSimHits")}
94 {
95  //register your products
96  produces<reco::TrackToTrackingParticleAssociator>();
97 }
98 
99 
101 {
102 
103  // do anything here that needs to be done at desctruction time
104  // (e.g. close files, deallocate resources etc.)
105 
106 }
107 
108 
109 //
110 // member functions
111 //
112 
113 // ------------ method called to produce the data ------------
114 void
116 {
117  using namespace edm;
118 
120  iEvent.getByToken(theSimHitTpMapToken,assocList);
121 
123  iSetup.get<TrackingComponentsRecord>().get(thePname,theP);
124 
126  iSetup.get<GlobalTrackingGeometryRecord>().get(theG);
127 
128  std::unique_ptr<reco::TrackToTrackingParticleAssociatorBaseImpl> impl{
130  theP.product(),
131  assocList.product(),
132  theQminCut,
133  theQCut,
135  theMethod,
138 
139  std::unique_ptr<reco::TrackToTrackingParticleAssociator> toPut{ new reco::TrackToTrackingParticleAssociator(std::move(impl))};
140 
141  iEvent.put(std::move(toPut));
142 
143 }
144 
145 
146 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
147 void
149  //The following says we do not know what parameters are allowed so do no validation
150  // Please change this to state exactly what you do use, even if it is no parameters
152  desc.setUnknown();
153  descriptions.addDefault(desc);
154 }
155 
156 //define this as a plug-in
static TrackAssociatorByPositionImpl::Method parseMethodName(const std::string &meth)
T getParameter(std::string const &) const
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
TrackAssociatorByHitsImpl::SimHitTPAssociationList SimHitTPAssociationList
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< SimHitTPAssociationList > theSimHitTpMapToken
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TrackAssociatorByPositionImpl::Method theMethod
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:59
HLT enums.
TrackAssociatorByPositionProducer(const edm::ParameterSet &)
std::vector< SimHitTPPair > SimHitTPAssociationList
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510