CMS 3D CMS Logo

ProducerDR.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 ProducerDR : public stream::EDProducer<> {
39  public:
40  explicit ProducerDR(const ParameterSet&);
41  ~ProducerDR() 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  // ChannelAssignment token
63  // configuration
65  // helper class to store configurations
66  const Setup* setup_ = nullptr;
67  // helper class to extract structured data from tt::Frames
68  const DataFormats* dataFormats_ = nullptr;
69  // helper class to assign tracks to channel
70  const ChannelAssignment* channelAssignment_ = nullptr;
71  };
72 
73  ProducerDR::ProducerDR(const ParameterSet& iConfig) : iConfig_(iConfig) {
74  const string& label = iConfig.getParameter<string>("LabelDRin");
75  const string& branchAcceptedStubs = iConfig.getParameter<string>("BranchAcceptedStubs");
76  const string& branchAcceptedTracks = iConfig.getParameter<string>("BranchAcceptedTracks");
77  const string& branchLostStubs = iConfig.getParameter<string>("BranchLostStubs");
78  const string& branchLostTracks = iConfig.getParameter<string>("BranchLostTracks");
79  // book in- and output ED products
80  edGetTokenTracks_ = consumes<StreamsTrack>(InputTag(label, branchAcceptedTracks));
81  edGetTokenStubs_ = consumes<StreamsStub>(InputTag(label, branchAcceptedStubs));
82  edPutTokenAcceptedStubs_ = produces<StreamsStub>(branchAcceptedStubs);
83  edPutTokenAcceptedTracks_ = produces<StreamsTrack>(branchAcceptedTracks);
84  edPutTokenLostStubs_ = produces<StreamsStub>(branchLostStubs);
85  edPutTokenLostTracks_ = produces<StreamsTrack>(branchLostTracks);
86  // book ES products
87  esGetTokenSetup_ = esConsumes<Setup, SetupRcd, Transition::BeginRun>();
88  esGetTokenDataFormats_ = esConsumes<DataFormats, DataFormatsRcd, Transition::BeginRun>();
89  esGetTokenChannelAssignment_ = esConsumes<ChannelAssignment, ChannelAssignmentRcd, Transition::BeginRun>();
90  }
91 
92  void ProducerDR::beginRun(const Run& iRun, const EventSetup& iSetup) {
93  // helper class to store configurations
94  setup_ = &iSetup.getData(esGetTokenSetup_);
96  return;
97  // check process history if desired
98  if (iConfig_.getParameter<bool>("CheckHistory"))
100  // helper class to extract structured data from tt::Frames
102  // helper class to assign tracks to channel
104  }
105 
106  void ProducerDR::produce(Event& iEvent, const EventSetup& iSetup) {
107  // empty DR products
108  const int numStreamsTracks = channelAssignment_->numNodesDR() * setup_->numRegions();
109  const int numStreamsStubs = numStreamsTracks * setup_->numLayers();
110  StreamsStub acceptedStubs(numStreamsStubs);
111  StreamsTrack acceptedTracks(numStreamsTracks);
112  StreamsStub lostStubs(numStreamsStubs);
113  StreamsTrack lostTracks(numStreamsTracks);
114  // read in TBout Product and produce KFin product
116  Handle<StreamsStub> handleStubs;
117  iEvent.getByToken<StreamsStub>(edGetTokenStubs_, handleStubs);
118  const StreamsStub& stubs = *handleStubs;
119  Handle<StreamsTrack> handleTracks;
120  iEvent.getByToken<StreamsTrack>(edGetTokenTracks_, handleTracks);
121  const StreamsTrack& tracks = *handleTracks;
122  for (int region = 0; region < setup_->numRegions(); region++) {
123  // object to remove duplicated tracks in a processing region
125  // read in and organize input tracks and stubs
126  dr.consume(tracks, stubs);
127  // fill output products
128  dr.produce(acceptedStubs, acceptedTracks, lostStubs, lostTracks);
129  }
130  }
131  // store products
132  iEvent.emplace(edPutTokenAcceptedStubs_, std::move(acceptedStubs));
133  iEvent.emplace(edPutTokenAcceptedTracks_, std::move(acceptedTracks));
134  iEvent.emplace(edPutTokenLostStubs_, std::move(lostStubs));
136  }
137 
138 } // namespace trklet
139 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< StreamTrack > StreamsTrack
Definition: TTTypes.h:67
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const DataFormats * dataFormats_
Definition: ProducerDR.cc:68
EDGetTokenT< StreamsTrack > edGetTokenTracks_
Definition: ProducerDR.cc:48
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
~ProducerDR() override
Definition: ProducerDR.cc:41
Class to assign tracklet tracks and stubs to output channel based on their Pt or seed type as well as...
void produce(Event &, const EventSetup &) override
Definition: ProducerDR.cc:106
const ChannelAssignment * channelAssignment_
Definition: ProducerDR.cc:70
char const * label
ESGetToken< DataFormats, DataFormatsRcd > esGetTokenDataFormats_
Definition: ProducerDR.cc:60
int iEvent
Definition: GenABIO.cc:224
Definition: TTTypes.h:54
EDPutTokenT< StreamsStub > edPutTokenLostStubs_
Definition: ProducerDR.cc:53
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: ProducerDR.cc:92
ParameterSet iConfig_
Definition: ProducerDR.cc:64
int numLayers() const
Definition: Setup.h:215
virtual void endJob()
Definition: ProducerDR.cc:46
void checkHistory(const edm::ProcessHistory &processHistory) const
Definition: Setup.cc:242
ESGetToken< ChannelAssignment, ChannelAssignmentRcd > esGetTokenChannelAssignment_
Definition: ProducerDR.cc:62
EDPutTokenT< StreamsTrack > edPutTokenAcceptedTracks_
Definition: ProducerDR.cc:55
EDGetTokenT< StreamsStub > edGetTokenStubs_
Definition: ProducerDR.cc:50
EDPutTokenT< StreamsStub > edPutTokenAcceptedStubs_
Definition: ProducerDR.cc:52
int numRegions() const
Definition: Setup.h:349
HLT enums.
ESGetToken< Setup, SetupRcd > esGetTokenSetup_
Definition: ProducerDR.cc:58
const Setup * setup_
Definition: ProducerDR.cc:66
Class to calculate and provide dataformats used by Track Trigger emulator.
Definition: DataFormats.h:216
Class to bit- and clock-accurate emulate duplicate removal DR identifies duplicates based on pairs of...
Definition: DR.h:19
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45
Emulates removal of duplicated TTTracks f/w.
Definition: ProducerDR.cc:38
EDPutTokenT< StreamsTrack > edPutTokenLostTracks_
Definition: ProducerDR.cc:56