CMS 3D CMS Logo

ProducerTT.cc
Go to the documentation of this file.
12 
16 
17 #include <string>
18 #include <numeric>
19 
20 using namespace std;
21 using namespace edm;
22 using namespace tt;
23 
24 namespace trackerTFP {
25 
31  class ProducerTT : public stream::EDProducer<> {
32  public:
33  explicit ProducerTT(const ParameterSet&);
34  ~ProducerTT() override {}
35 
36  private:
37  void beginRun(const Run&, const EventSetup&) override;
38  void produce(Event&, const EventSetup&) override;
39  void endJob() {}
40 
41  // ED input token of kf stubs
43  // ED input token of kf tracks
45  // ED output token for TTTracks
47  // Setup token
49  // DataFormats token
51  // configuration
53  // helper class to store configurations
54  const Setup* setup_ = nullptr;
55  // helper class to extract structured data from tt::Frames
56  const DataFormats* dataFormats_ = nullptr;
57  };
58 
59  ProducerTT::ProducerTT(const ParameterSet& iConfig) : iConfig_(iConfig) {
60  const string& label = iConfig.getParameter<string>("LabelKF");
61  const string& branchStubs = iConfig.getParameter<string>("BranchAcceptedStubs");
62  const string& branchTracks = iConfig.getParameter<string>("BranchAcceptedTracks");
63  // book in- and output ED products
64  edGetTokenStubs_ = consumes<StreamsStub>(InputTag(label, branchStubs));
65  edGetTokenTracks_ = consumes<StreamsTrack>(InputTag(label, branchTracks));
66  edPutToken_ = produces<TTTracks>(branchTracks);
67  // book ES products
68  esGetTokenSetup_ = esConsumes<Setup, SetupRcd, Transition::BeginRun>();
69  esGetTokenDataFormats_ = esConsumes<DataFormats, DataFormatsRcd, Transition::BeginRun>();
70  }
71 
72  void ProducerTT::beginRun(const Run& iRun, const EventSetup& iSetup) {
73  // helper class to store configurations
74  setup_ = &iSetup.getData(esGetTokenSetup_);
76  return;
77  // check process history if desired
78  if (iConfig_.getParameter<bool>("CheckHistory"))
80  // helper class to extract structured data from tt::Frames
82  }
83 
84  void ProducerTT::produce(Event& iEvent, const EventSetup& iSetup) {
85  // empty KFTTTrack product
86  TTTracks ttTracks;
87  // read in KF Product and produce KFTTTrack product
89  Handle<StreamsTrack> handleTracks;
90  iEvent.getByToken<StreamsTrack>(edGetTokenTracks_, handleTracks);
91  const StreamsTrack& streamsTracks = *handleTracks.product();
92  Handle<StreamsStub> handleStubs;
93  iEvent.getByToken<StreamsStub>(edGetTokenTracks_, handleStubs);
94  const StreamsStub& streamsStubs = *handleStubs.product();
95  int nTracks(0);
96  for (const StreamTrack& stream : streamsTracks)
97  nTracks += accumulate(stream.begin(), stream.end(), 0, [](int& sum, const FrameTrack& frame) {
98  return sum += frame.first.isNonnull() ? 1 : 0;
99  });
100  ttTracks.reserve(nTracks);
101  for (int channel = 0; channel < dataFormats_->numStreamsTracks(Process::kf); channel++) {
102  int iTrk(0);
103  const int offset = channel * setup_->numLayers();
104  for (const FrameTrack& frameTrack : streamsTracks[channel]) {
105  vector<StubKF> stubs;
106  stubs.reserve(setup_->numLayers());
107  for (int layer = 0; layer < setup_->numLayers(); layer++) {
108  const FrameStub& frameStub = streamsStubs[offset + layer][iTrk];
109  if (frameStub.first.isNonnull())
110  stubs.emplace_back(frameStub, dataFormats_, layer);
111  }
112  TrackKF track(frameTrack, dataFormats_);
113  ttTracks.emplace_back(track.ttTrack(stubs));
114  iTrk++;
115  }
116  }
117  }
118  // store products
119  iEvent.emplace(edPutToken_, move(ttTracks));
120  }
121 
122 } // namespace trackerTFP
123 
EDPutTokenT< TTTracks > edPutToken_
Definition: ProducerTT.cc:46
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
std::pair< TTStubRef, Frame > FrameStub
Definition: TTTypes.h:60
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
T const * product() const
Definition: Handle.h:70
EDGetTokenT< StreamsTrack > edGetTokenTracks_
Definition: ProducerTT.cc:44
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
std::vector< FrameTrack > StreamTrack
Definition: TTTypes.h:64
std::pair< TTTrackRef, Frame > FrameTrack
Definition: TTTypes.h:62
char const * label
int iEvent
Definition: GenABIO.cc:224
Definition: TTTypes.h:54
ESGetToken< Setup, SetupRcd > esGetTokenSetup_
Definition: ProducerTT.cc:48
void produce(Event &, const EventSetup &) override
Definition: ProducerTT.cc:84
bool configurationSupported() const
Definition: Setup.h:60
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ProcessHistory const & processHistory() const
Definition: Run.cc:115
int numLayers() const
Definition: Setup.h:215
void checkHistory(const edm::ProcessHistory &processHistory) const
Definition: Setup.cc:238
Converts KF output into TTTracks.
Definition: ProducerTT.cc:31
const Setup * setup_
Definition: ProducerTT.cc:54
int numStreamsTracks(Process p) const
Definition: DataFormats.h:504
EDGetTokenT< StreamsStub > edGetTokenStubs_
Definition: ProducerTT.cc:42
HLT enums.
std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > TTTracks
Definition: TTTypes.h:70
void beginRun(const Run &, const EventSetup &) override
Definition: ProducerTT.cc:72
ParameterSet iConfig_
Definition: ProducerTT.cc:52
const DataFormats * dataFormats_
Definition: ProducerTT.cc:56
ESGetToken< DataFormats, DataFormatsRcd > esGetTokenDataFormats_
Definition: ProducerTT.cc:50
Class to calculate and provide dataformats used by Track Trigger emulator.
Definition: DataFormats.h:216
~ProducerTT() override
Definition: ProducerTT.cc:34
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45