CMS 3D CMS Logo

ProducerKFin.cc
Go to the documentation of this file.
12 
20 
21 #include <string>
22 #include <vector>
23 #include <deque>
24 #include <iterator>
25 #include <cmath>
26 #include <numeric>
27 
28 using namespace std;
29 using namespace edm;
30 using namespace trackerTFP;
31 using namespace tt;
32 
33 namespace trklet {
34 
40  class ProducerKFin : public stream::EDProducer<> {
41  public:
42  explicit ProducerKFin(const ParameterSet&);
43  ~ProducerKFin() override {}
44 
45  private:
46  void beginRun(const Run&, const EventSetup&) override;
47  void produce(Event&, const EventSetup&) override;
48  virtual void endJob() {}
49 
50  // ED input token of Tracks
52  // ED input token of Stubs
54  // ED output token for stubs
57  // ED output token for tracks
60  // Setup token
62  // DataFormats token
64  // LayerEncoding token
66  // ChannelAssignment token
68  // configuration
70  // helper class to store configurations
71  const Setup* setup_ = nullptr;
72  // helper class to extract structured data from tt::Frames
73  const DataFormats* dataFormats_ = nullptr;
74  // helper class to encode layer
75  const LayerEncoding* layerEncoding_ = nullptr;
76  // helper class to assign tracks to channel
77  const ChannelAssignment* channelAssignment_ = nullptr;
78  // helper class to store tracklet configurations
80  };
81 
82  ProducerKFin::ProducerKFin(const ParameterSet& iConfig) : iConfig_(iConfig) {
83  const string& label = iConfig.getParameter<string>("LabelTBout");
84  const string& branchAcceptedStubs = iConfig.getParameter<string>("BranchAcceptedStubs");
85  const string& branchAcceptedTracks = iConfig.getParameter<string>("BranchAcceptedTracks");
86  const string& branchLostStubs = iConfig.getParameter<string>("BranchLostStubs");
87  const string& branchLostTracks = iConfig.getParameter<string>("BranchLostTracks");
88  // book in- and output ED products
89  edGetTokenTracks_ = consumes<StreamsTrack>(InputTag(label, branchAcceptedTracks));
90  edGetTokenStubs_ = consumes<StreamsStub>(InputTag(label, branchAcceptedStubs));
91  edPutTokenAcceptedStubs_ = produces<StreamsStub>(branchAcceptedStubs);
92  edPutTokenAcceptedTracks_ = produces<StreamsTrack>(branchAcceptedTracks);
93  edPutTokenLostStubs_ = produces<StreamsStub>(branchLostStubs);
94  edPutTokenLostTracks_ = produces<StreamsTrack>(branchLostTracks);
95  // book ES products
96  esGetTokenSetup_ = esConsumes<Setup, SetupRcd, Transition::BeginRun>();
97  esGetTokenDataFormats_ = esConsumes<DataFormats, DataFormatsRcd, Transition::BeginRun>();
98  esGetTokenLayerEncoding_ = esConsumes<LayerEncoding, LayerEncodingRcd, Transition::BeginRun>();
99  esGetTokenChannelAssignment_ = esConsumes<ChannelAssignment, ChannelAssignmentRcd, Transition::BeginRun>();
100  }
101 
102  void ProducerKFin::beginRun(const Run& iRun, const EventSetup& iSetup) {
103  // helper class to store configurations
104  setup_ = &iSetup.getData(esGetTokenSetup_);
106  return;
107  // check process history if desired
108  if (iConfig_.getParameter<bool>("CheckHistory"))
110  // helper class to extract structured data from tt::Frames
112  // helper class to encode layer
114  // helper class to assign tracks to channel
116  }
117 
119  // empty KFin products
120  StreamsStub acceptedStubs(dataFormats_->numStreamsStubs(Process::kfin));
121  StreamsTrack acceptedTracks(dataFormats_->numStreamsTracks(Process::kfin));
122  StreamsStub lostStubs(dataFormats_->numStreamsStubs(Process::kfin));
124  // read in TBout Product and produce KFin product
126  Handle<StreamsStub> handleStubs;
127  iEvent.getByToken<StreamsStub>(edGetTokenStubs_, handleStubs);
128  const StreamsStub& stubs = *handleStubs;
129  Handle<StreamsTrack> handleTracks;
130  iEvent.getByToken<StreamsTrack>(edGetTokenTracks_, handleTracks);
131  const StreamsTrack& tracks = *handleTracks;
132  for (int region = 0; region < setup_->numRegions(); region++) {
133  // object to reformat tracks from tracklet fromat to TMTT format in a processing region
135  // read in and organize input tracks and stubs
136  kfin.consume(tracks, stubs);
137  // fill output products
138  kfin.produce(acceptedStubs, acceptedTracks, lostStubs, lostTracks);
139  }
140  }
141  // store products
142  iEvent.emplace(edPutTokenAcceptedStubs_, move(acceptedStubs));
143  iEvent.emplace(edPutTokenAcceptedTracks_, move(acceptedTracks));
144  iEvent.emplace(edPutTokenLostStubs_, move(lostStubs));
146  }
147 
148 } // namespace trklet
149 
Class to emulate transformation of tracklet tracks and stubs into TMTT format.
Definition: KFin.h:19
ESGetToken< ChannelAssignment, ChannelAssignmentRcd > esGetTokenChannelAssignment_
Definition: ProducerKFin.cc:67
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void beginRun(const Run &, const EventSetup &) override
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:48
EDPutTokenT< StreamsStub > edPutTokenLostStubs_
Definition: ProducerKFin.cc:56
const Setup * setup_
Definition: ProducerKFin.cc:71
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:65
EDPutTokenT< StreamsTrack > edPutTokenAcceptedTracks_
Definition: ProducerKFin.cc:58
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:73
char const * label
EDGetTokenT< StreamsTrack > edGetTokenTracks_
Definition: ProducerKFin.cc:51
int iEvent
Definition: GenABIO.cc:224
const LayerEncoding * layerEncoding_
Definition: ProducerKFin.cc:75
Definition: TTTypes.h:54
const ChannelAssignment * channelAssignment_
Definition: ProducerKFin.cc:77
EDPutTokenT< StreamsStub > edPutTokenAcceptedStubs_
Definition: ProducerKFin.cc:55
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 TBout into that expected by KF input.
Definition: ProducerKFin.cc:40
ParameterSet iConfig_
Definition: ProducerKFin.cc:69
ESGetToken< DataFormats, DataFormatsRcd > esGetTokenDataFormats_
Definition: ProducerKFin.cc:63
void checkHistory(const edm::ProcessHistory &processHistory) const
Definition: Setup.cc:238
int numStreamsTracks(Process p) const
Definition: DataFormats.h:504
~ProducerKFin() override
Definition: ProducerKFin.cc:43
int numRegions() const
Definition: Setup.h:345
ESGetToken< Setup, SetupRcd > esGetTokenSetup_
Definition: ProducerKFin.cc:61
HLT enums.
int numStreamsStubs(Process p) const
Definition: DataFormats.h:502
EDPutTokenT< StreamsTrack > edPutTokenLostTracks_
Definition: ProducerKFin.cc:59
Class to encode layer ids for Kalman Filter Layers consitent with rough r-z track parameters are coun...
Definition: LayerEncoding.h:18
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:53