CMS 3D CMS Logo

ProducerKF.cc
Go to the documentation of this file.
12 
19 
20 #include <string>
21 
22 using namespace std;
23 using namespace edm;
24 using namespace tt;
25 
26 namespace trackerTFP {
27 
33  class ProducerKF : public stream::EDProducer<> {
34  public:
35  explicit ProducerKF(const ParameterSet&);
36  ~ProducerKF() override {}
37 
38  private:
39  void beginRun(const Run&, const EventSetup&) override;
40  void produce(Event&, const EventSetup&) override;
41  void endStream() override {
42  if (printDebug_)
43  kalmanFilterFormats_->endJob();
44  }
45 
46  // ED input token of sf stubs and tracks
49  // ED output token for accepted stubs and tracks
52  // ED output token for lost stubs and tracks
55  // ED output token for number of accepted and lost States
58  // Setup token
60  // DataFormats token
62  // KalmanFilterFormats token
64  // configuration
66  // helper class to store configurations
67  const Setup* setup_ = nullptr;
68  // helper class to extract structured data from tt::Frames
69  const DataFormats* dataFormats_ = nullptr;
70  // helper class to
71  KalmanFilterFormats* kalmanFilterFormats_ = nullptr;
72  // print end job internal unused MSB
74  };
75 
76  ProducerKF::ProducerKF(const ParameterSet& iConfig) : iConfig_(iConfig) {
77  printDebug_ = iConfig.getParameter<bool>("PrintKFDebug");
78  const string& label = iConfig.getParameter<string>("LabelKFin");
79  const string& branchAcceptedStubs = iConfig.getParameter<string>("BranchAcceptedStubs");
80  const string& branchAcceptedTracks = iConfig.getParameter<string>("BranchAcceptedTracks");
81  const string& branchLostStubs = iConfig.getParameter<string>("BranchLostStubs");
82  const string& branchLostTracks = iConfig.getParameter<string>("BranchLostTracks");
83  // book in- and output ED products
84  edGetTokenStubs_ = consumes<StreamsStub>(InputTag(label, branchAcceptedStubs));
85  edGetTokenTracks_ = consumes<StreamsTrack>(InputTag(label, branchAcceptedTracks));
86  edPutTokenAcceptedStubs_ = produces<StreamsStub>(branchAcceptedStubs);
87  edPutTokenAcceptedTracks_ = produces<StreamsTrack>(branchAcceptedTracks);
88  edPutTokenLostStubs_ = produces<StreamsStub>(branchLostStubs);
89  edPutTokenLostTracks_ = produces<StreamsTrack>(branchLostTracks);
90  edPutTokenNumAcceptedStates_ = produces<int>(branchAcceptedTracks);
91  edPutTokenNumLostStates_ = produces<int>(branchLostTracks);
92  // book ES products
93  esGetTokenSetup_ = esConsumes<Setup, SetupRcd, Transition::BeginRun>();
94  esGetTokenDataFormats_ = esConsumes<DataFormats, DataFormatsRcd, Transition::BeginRun>();
95  esGetTokenKalmanFilterFormats_ = esConsumes<KalmanFilterFormats, KalmanFilterFormatsRcd, Transition::BeginRun>();
96  }
97 
98  void ProducerKF::beginRun(const Run& iRun, const EventSetup& iSetup) {
99  // helper class to store configurations
100  setup_ = &iSetup.getData(esGetTokenSetup_);
102  return;
103  // check process history if desired
104  if (iConfig_.getParameter<bool>("CheckHistory"))
106  // helper class to extract structured data from tt::Frames
108  // helper class to
110  }
111 
112  void ProducerKF::produce(Event& iEvent, const EventSetup& iSetup) {
113  // empty KF products
118  int numAcceptedStates(0);
119  int numLostStates(0);
120  // read in SF Product and produce KF product
122  Handle<StreamsStub> handleStubs;
123  iEvent.getByToken<StreamsStub>(edGetTokenStubs_, handleStubs);
124  const StreamsStub& stubs = *handleStubs;
125  Handle<StreamsTrack> handleTracks;
126  iEvent.getByToken<StreamsTrack>(edGetTokenTracks_, handleTracks);
127  const StreamsTrack& tracks = *handleTracks;
128  for (int region = 0; region < setup_->numRegions(); region++) {
129  // object to fit tracks in a processing region
131  // read in and organize input tracks and stubs
132  kf.consume(tracks, stubs);
133  // fill output products
134  kf.produce(acceptedStubs, acceptedTracks, lostStubs, lostTracks, numAcceptedStates, numLostStates);
135  }
136  }
137  // store products
138  iEvent.emplace(edPutTokenAcceptedStubs_, std::move(acceptedStubs));
139  iEvent.emplace(edPutTokenAcceptedTracks_, std::move(acceptedTracks));
140  iEvent.emplace(edPutTokenLostStubs_, std::move(lostStubs));
142  iEvent.emplace(edPutTokenNumAcceptedStates_, numAcceptedStates);
143  iEvent.emplace(edPutTokenNumLostStates_, numLostStates);
144  }
145 
146 } // namespace trackerTFP
147 
L1TrackTrigger Kamlan Filter emulator.
Definition: ProducerKF.cc:33
EDPutTokenT< StreamsTrack > edPutTokenLostTracks_
Definition: ProducerKF.cc:54
ParameterSet iConfig_
Definition: ProducerKF.cc:65
const Setup * setup_
Definition: ProducerKF.cc:67
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< StreamTrack > StreamsTrack
Definition: TTTypes.h:67
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
EDPutTokenT< StreamsStub > edPutTokenLostStubs_
Definition: ProducerKF.cc:53
ESGetToken< KalmanFilterFormats, KalmanFilterFormatsRcd > esGetTokenKalmanFilterFormats_
Definition: ProducerKF.cc:63
Class to process and provide run-time constants used by Track Trigger emulators.
Definition: Setup.h:44
std::vector< StreamStub > StreamsStub
Definition: TTTypes.h:66
EDPutTokenT< StreamsStub > edPutTokenAcceptedStubs_
Definition: ProducerKF.cc:50
EDGetTokenT< StreamsStub > edGetTokenStubs_
Definition: ProducerKF.cc:47
const DataFormats * dataFormats_
Definition: ProducerKF.cc:69
char const * label
int iEvent
Definition: GenABIO.cc:224
Definition: TTTypes.h:54
void endStream() override
Definition: ProducerKF.cc:41
EDPutTokenT< StreamsTrack > edPutTokenAcceptedTracks_
Definition: ProducerKF.cc:51
bool configurationSupported() const
Definition: Setup.h:60
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ProcessHistory const & processHistory() const
Definition: Run.cc:115
void beginRun(const Run &, const EventSetup &) override
Definition: ProducerKF.cc:98
EDPutTokenT< int > edPutTokenNumLostStates_
Definition: ProducerKF.cc:57
ESGetToken< Setup, SetupRcd > esGetTokenSetup_
Definition: ProducerKF.cc:59
void checkHistory(const edm::ProcessHistory &processHistory) const
Definition: Setup.cc:238
int numStreamsTracks(Process p) const
Definition: DataFormats.h:504
~ProducerKF() override
Definition: ProducerKF.cc:36
int numRegions() const
Definition: Setup.h:345
HLT enums.
int numStreamsStubs(Process p) const
Definition: DataFormats.h:502
KalmanFilterFormats * kalmanFilterFormats_
Definition: ProducerKF.cc:71
void produce(Event &, const EventSetup &) override
Definition: ProducerKF.cc:112
Class to calculate and provide dataformats used by Track Trigger emulator.
Definition: DataFormats.h:216
ESGetToken< DataFormats, DataFormatsRcd > esGetTokenDataFormats_
Definition: ProducerKF.cc:61
def move(src, dest)
Definition: eostools.py:511
EDPutTokenT< int > edPutTokenNumAcceptedStates_
Definition: ProducerKF.cc:56
Definition: Run.h:45
EDGetTokenT< StreamsTrack > edGetTokenTracks_
Definition: ProducerKF.cc:48