CMS 3D CMS Logo

ProducerTT.cc
Go to the documentation of this file.
12 
15 
16 #include <string>
17 #include <numeric>
18 
19 using namespace std;
20 using namespace edm;
21 using namespace trackerTFP;
22 using namespace tt;
23 
24 namespace trklet {
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 KFout product
86  TTTracks ttTracks;
87  // read in KF Product and produce KFout product
89  Handle<StreamsStub> handleStubs;
90  iEvent.getByToken<StreamsStub>(edGetTokenStubs_, handleStubs);
91  const StreamsStub& streamsStubs = *handleStubs.product();
92  Handle<StreamsTrack> handleTracks;
93  iEvent.getByToken<StreamsTrack>(edGetTokenTracks_, handleTracks);
94  const StreamsTrack& streamsTracks = *handleTracks.product();
95  // count number of kf tracks
96  int nTracks(0);
97  for (const StreamTrack& stream : streamsTracks)
98  nTracks += accumulate(stream.begin(), stream.end(), 0, [](int sum, const FrameTrack& frame) {
99  return sum + (frame.first.isNonnull() ? 1 : 0);
100  });
101  ttTracks.reserve(nTracks);
102  // convert kf track frames per channel and stub frames per channel and layer to TTTracks
103  for (int channel = 0; channel < (int)streamsTracks.size(); channel++) {
104  const int offset = channel * setup_->numLayers();
105  int iTrk(0);
106  for (const FrameTrack& frameTrack : streamsTracks[channel]) {
107  if (frameTrack.first.isNull())
108  continue;
109  // convert stub frames to kf stubs
110  vector<StubKF> stubs;
111  stubs.reserve(setup_->numLayers());
112  for (int layer = 0; layer < setup_->numLayers(); layer++) {
113  const FrameStub& frameStub = streamsStubs[offset + layer][iTrk];
114  if (frameStub.first.isNonnull())
115  stubs.emplace_back(frameStub, dataFormats_, layer);
116  }
117  // convert track frame to kf track
118  TrackKF track(frameTrack, dataFormats_);
119  // convert kf track and kf stubs to TTTrack
120  ttTracks.emplace_back(track.ttTrack(stubs));
121  iTrk++;
122  }
123  }
124  }
125  // store products
126  iEvent.emplace(edPutToken_, std::move(ttTracks));
127  }
128 
129 } // namespace trklet
130 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void produce(Event &, const EventSetup &) override
Definition: ProducerTT.cc:84
std::vector< StreamTrack > StreamsTrack
Definition: TTTypes.h:67
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
ParameterSet iConfig_
Definition: ProducerTT.cc:52
void beginRun(const Run &, const EventSetup &) override
Definition: ProducerTT.cc:72
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
EDPutTokenT< TTTracks > edPutToken_
Definition: ProducerTT.cc:46
Converts KF output into TTTracks.
Definition: ProducerTT.cc:31
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
EDGetTokenT< StreamsTrack > edGetTokenTracks_
Definition: ProducerTT.cc:44
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
ESGetToken< DataFormats, DataFormatsRcd > esGetTokenDataFormats_
Definition: ProducerTT.cc:50
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:242
~ProducerTT() override
Definition: ProducerTT.cc:34
const Setup * setup_
Definition: ProducerTT.cc:54
HLT enums.
EDGetTokenT< StreamsStub > edGetTokenStubs_
Definition: ProducerTT.cc:42
std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > TTTracks
Definition: TTTypes.h:70
Class to calculate and provide dataformats used by Track Trigger emulator.
Definition: DataFormats.h:216
const DataFormats * dataFormats_
Definition: ProducerTT.cc:56
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45