CMS 3D CMS Logo

TrackAssociatorByChi2Producer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SimTracker/TrackAssociatorProducers
4 // Class: TrackAssociatorByChi2Producer
5 //
13 //
14 // Original Author: Christopher Jones
15 // Created: Tue, 06 Jan 2015 16:13:00 GMT
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
30 
32 
36 
38 
41 
42 //
43 // class declaration
44 //
45 
47 public:
50 
51  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
52 
53 private:
54  virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
55 
56  // ----------member data ---------------------------
58  const double chi2cut_;
59  const bool onlyDiagonal_;
60 };
61 
62 //
63 // constants, enums and typedefs
64 //
65 
66 
67 //
68 // static data member definitions
69 //
70 
71 //
72 // constructors and destructor
73 //
75  bsToken_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))),
76  chi2cut_(iConfig.getParameter<double>("chi2cut")),
77  onlyDiagonal_(iConfig.getParameter<bool>("onlyDiagonal"))
78 {
79  //register your products
80  produces<reco::TrackToTrackingParticleAssociator>();
81  produces<reco::TrackToGenParticleAssociator>();
82 }
83 
84 
86 {
87 
88  // do anything here that needs to be done at desctruction time
89  // (e.g. close files, deallocate resources etc.)
90 
91 }
92 
93 
94 //
95 // member functions
96 //
97 
98 // ------------ method called to produce the data ------------
99 void
101 {
102  using namespace edm;
103 
105  iSetup.get<IdealMagneticFieldRecord>().get(magField);
106 
108  iEvent.getByToken(bsToken_,beamSpot);
109 
110  {
111  std::unique_ptr<reco::TrackToTrackingParticleAssociatorBaseImpl> impl( new TrackAssociatorByChi2Impl(*magField,
112  *beamSpot,
113  chi2cut_,
114  onlyDiagonal_));
115 
116  std::unique_ptr<reco::TrackToTrackingParticleAssociator> assoc(new reco::TrackToTrackingParticleAssociator(std::move(impl)));
117 
118  iEvent.put(std::move(assoc));
119  }
120 
121  {
122  std::unique_ptr<reco::TrackToGenParticleAssociatorBaseImpl> impl( new TrackGenAssociatorByChi2Impl(*magField,
123  *beamSpot,
124  chi2cut_,
125  onlyDiagonal_));
126 
127  std::unique_ptr<reco::TrackToGenParticleAssociator> assoc(new reco::TrackToGenParticleAssociator(std::move(impl)));
128 
129  iEvent.put(std::move(assoc));
130  }
131 }
132 
133 
134 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
135 void
137  //The following says we do not know what parameters are allowed so do no validation
138  // Please change this to state exactly what you do use, even if it is no parameters
140  desc.setUnknown();
141  descriptions.addDefault(desc);
142 }
143 
144 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
TrackAssociatorByChi2Producer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
const T & get() const
Definition: EventSetup.h:55
fixed size matrix
HLT enums.
edm::EDGetTokenT< reco::BeamSpot > bsToken_
def move(src, dest)
Definition: eostools.py:510