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 // system include files
20 #include <memory>
21 
22 // user include files
25 
29 
31 
35 
37 
40 
41 //
42 // class declaration
43 //
44 
46 public:
49 
50  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
51 
52 private:
53  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
54 
55  // ----------member data ---------------------------
57  const double chi2cut_;
58  const bool onlyDiagonal_;
59 };
60 
61 //
62 // constants, enums and typedefs
63 //
64 
65 //
66 // static data member definitions
67 //
68 
69 //
70 // constructors and destructor
71 //
73  : bsToken_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))),
74  chi2cut_(iConfig.getParameter<double>("chi2cut")),
75  onlyDiagonal_(iConfig.getParameter<bool>("onlyDiagonal")) {
76  //register your products
77  produces<reco::TrackToTrackingParticleAssociator>();
78  produces<reco::TrackToGenParticleAssociator>();
79 }
80 
82  // do anything here that needs to be done at desctruction time
83  // (e.g. close files, deallocate resources etc.)
84 }
85 
86 //
87 // member functions
88 //
89 
90 // ------------ method called to produce the data ------------
92  using namespace edm;
93 
95  iSetup.get<IdealMagneticFieldRecord>().get(magField);
96 
98  iEvent.getByToken(bsToken_, beamSpot);
99 
100  {
101  std::unique_ptr<reco::TrackToTrackingParticleAssociatorBaseImpl> impl(
102  new TrackAssociatorByChi2Impl(*magField, *beamSpot, chi2cut_, onlyDiagonal_));
103 
104  std::unique_ptr<reco::TrackToTrackingParticleAssociator> assoc(
106 
107  iEvent.put(std::move(assoc));
108  }
109 
110  {
111  std::unique_ptr<reco::TrackToGenParticleAssociatorBaseImpl> impl(
112  new TrackGenAssociatorByChi2Impl(*magField, *beamSpot, chi2cut_, onlyDiagonal_));
113 
114  std::unique_ptr<reco::TrackToGenParticleAssociator> assoc(new reco::TrackToGenParticleAssociator(std::move(impl)));
115 
116  iEvent.put(std::move(assoc));
117  }
118 }
119 
120 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
122  //The following says we do not know what parameters are allowed so do no validation
123  // Please change this to state exactly what you do use, even if it is no parameters
125  desc.setUnknown();
126  descriptions.addDefault(desc);
127 }
128 
129 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void addDefault(ParameterSetDescription const &psetDescription)
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:73
edm::EDGetTokenT< reco::BeamSpot > bsToken_
def move(src, dest)
Definition: eostools.py:511