CMS 3D CMS Logo

ProducerKFin.cc
Go to the documentation of this file.
12 
18 
19 #include <string>
20 #include <vector>
21 #include <deque>
22 #include <iterator>
23 #include <cmath>
24 #include <numeric>
25 
26 using namespace std;
27 using namespace edm;
28 using namespace trackerTFP;
29 using namespace tt;
30 
31 namespace trklet {
32 
38  class ProducerKFin : public stream::EDProducer<> {
39  public:
40  explicit ProducerKFin(const ParameterSet&);
41  ~ProducerKFin() override {}
42 
43  private:
44  void beginRun(const Run&, const EventSetup&) override;
45  void produce(Event&, const EventSetup&) override;
46  virtual void endJob() {}
47  // ED input token of Tracks
49  // ED input token of Stubs
51  // ED output token for stubs
54  // ED output token for tracks
57  // Setup token
59  // DataFormats token
61  // LayerEncoding token
63  // ChannelAssignment token
65  // configuration
67  // helper class to store configurations
68  const Setup* setup_ = nullptr;
69  // helper class to extract structured data from tt::Frames
70  const DataFormats* dataFormats_ = nullptr;
71  // helper class to encode layer
72  const LayerEncoding* layerEncoding_ = nullptr;
73  // helper class to assign tracks to channel
74  const ChannelAssignment* channelAssignment_ = nullptr;
75  };
76 
77  ProducerKFin::ProducerKFin(const ParameterSet& iConfig) : iConfig_(iConfig) {
78  const string& label = iConfig.getParameter<string>("LabelDR");
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  edGetTokenTracks_ = consumes<StreamsTrack>(InputTag(label, branchAcceptedTracks));
85  edGetTokenStubs_ = consumes<StreamsStub>(InputTag(label, branchAcceptedStubs));
86  edPutTokenAcceptedStubs_ = produces<StreamsStub>(branchAcceptedStubs);
87  edPutTokenAcceptedTracks_ = produces<StreamsTrack>(branchAcceptedTracks);
88  edPutTokenLostStubs_ = produces<StreamsStub>(branchLostStubs);
89  edPutTokenLostTracks_ = produces<StreamsTrack>(branchLostTracks);
90  // book ES products
91  esGetTokenSetup_ = esConsumes<Setup, SetupRcd, Transition::BeginRun>();
92  esGetTokenDataFormats_ = esConsumes<DataFormats, DataFormatsRcd, Transition::BeginRun>();
93  esGetTokenLayerEncoding_ = esConsumes<LayerEncoding, LayerEncodingRcd, Transition::BeginRun>();
94  esGetTokenChannelAssignment_ = esConsumes<ChannelAssignment, ChannelAssignmentRcd, Transition::BeginRun>();
95  }
96 
97  void ProducerKFin::beginRun(const Run& iRun, const EventSetup& iSetup) {
98  // helper class to store configurations
99  setup_ = &iSetup.getData(esGetTokenSetup_);
101  return;
102  // check process history if desired
103  if (iConfig_.getParameter<bool>("CheckHistory"))
105  // helper class to extract structured data from tt::Frames
107  // helper class to encode layer
109  // helper class to assign tracks to channel
111  }
112 
114  // empty KFin products
115  const int numStreamsTracks = setup_->kfNumWorker() * setup_->numRegions();
116  const int numStreamsStubs = numStreamsTracks * setup_->numLayers();
117  StreamsStub acceptedStubs(numStreamsStubs);
118  StreamsTrack acceptedTracks(numStreamsTracks);
119  StreamsStub lostStubs(numStreamsStubs);
120  StreamsTrack lostTracks(numStreamsTracks);
121  // read in TBout Product and produce KFin product
123  Handle<StreamsStub> handleStubs;
124  iEvent.getByToken<StreamsStub>(edGetTokenStubs_, handleStubs);
125  const StreamsStub& stubs = *handleStubs;
126  Handle<StreamsTrack> handleTracks;
127  iEvent.getByToken<StreamsTrack>(edGetTokenTracks_, handleTracks);
128  const StreamsTrack& tracks = *handleTracks;
129  for (int region = 0; region < setup_->numRegions(); region++) {
130  // object to reformat tracks from DR fromat to KF format in a processing region
132  // read in and organize input tracks and stubs
133  kfin.consume(tracks, stubs);
134  // fill output products
135  kfin.produce(acceptedStubs, acceptedTracks, lostStubs, lostTracks);
136  }
137  }
138  // store products
139  iEvent.emplace(edPutTokenAcceptedStubs_, std::move(acceptedStubs));
140  iEvent.emplace(edPutTokenAcceptedTracks_, std::move(acceptedTracks));
141  iEvent.emplace(edPutTokenLostStubs_, std::move(lostStubs));
143  }
144 
145 } // namespace trklet
146 
Class to emulate the data transformation happening betwwen DR and KF.
Definition: KFin.h:18
ESGetToken< ChannelAssignment, ChannelAssignmentRcd > esGetTokenChannelAssignment_
Definition: ProducerKFin.cc:64
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void beginRun(const Run &, const EventSetup &) override
Definition: ProducerKFin.cc:97
std::vector< StreamTrack > StreamsTrack
Definition: TTTypes.h:67
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
virtual void endJob()
Definition: ProducerKFin.cc:46
EDPutTokenT< StreamsStub > edPutTokenLostStubs_
Definition: ProducerKFin.cc:53
const Setup * setup_
Definition: ProducerKFin.cc:68
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
ESGetToken< LayerEncoding, LayerEncodingRcd > esGetTokenLayerEncoding_
Definition: ProducerKFin.cc:62
EDPutTokenT< StreamsTrack > edPutTokenAcceptedTracks_
Definition: ProducerKFin.cc:55
void produce(Event &, const EventSetup &) override
Class to assign tracklet tracks and stubs to output channel based on their Pt or seed type as well as...
const DataFormats * dataFormats_
Definition: ProducerKFin.cc:70
char const * label
EDGetTokenT< StreamsTrack > edGetTokenTracks_
Definition: ProducerKFin.cc:48
int iEvent
Definition: GenABIO.cc:224
const LayerEncoding * layerEncoding_
Definition: ProducerKFin.cc:72
Definition: TTTypes.h:54
const ChannelAssignment * channelAssignment_
Definition: ProducerKFin.cc:74
EDPutTokenT< StreamsStub > edPutTokenAcceptedStubs_
Definition: ProducerKFin.cc:52
int kfNumWorker() const
Definition: Setup.h:491
bool configurationSupported() const
Definition: Setup.h:60
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ProcessHistory const & processHistory() const
Definition: Run.cc:115
Transforms format of DR into that expected by KF input.
Definition: ProducerKFin.cc:38
int numLayers() const
Definition: Setup.h:215
ParameterSet iConfig_
Definition: ProducerKFin.cc:66
ESGetToken< DataFormats, DataFormatsRcd > esGetTokenDataFormats_
Definition: ProducerKFin.cc:60
void checkHistory(const edm::ProcessHistory &processHistory) const
Definition: Setup.cc:242
~ProducerKFin() override
Definition: ProducerKFin.cc:41
int numRegions() const
Definition: Setup.h:349
ESGetToken< Setup, SetupRcd > esGetTokenSetup_
Definition: ProducerKFin.cc:58
HLT enums.
EDPutTokenT< StreamsTrack > edPutTokenLostTracks_
Definition: ProducerKFin.cc:56
Class to encode layer ids for Kalman Filter Layers consitent with rough r-z track parameters are coun...
Definition: LayerEncoding.h:19
Class to calculate and provide dataformats used by Track Trigger emulator.
Definition: DataFormats.h:216
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45
EDGetTokenT< StreamsStub > edGetTokenStubs_
Definition: ProducerKFin.cc:50