CMS 3D CMS Logo

ProducerZHTout.cc
Go to the documentation of this file.
12 
16 
17 #include <string>
18 #include <vector>
19 #include <deque>
20 
21 using namespace std;
22 using namespace edm;
23 using namespace tt;
24 
25 namespace trackerTFP {
26 
33  public:
34  explicit ProducerZHTout(const ParameterSet&);
35  ~ProducerZHTout() override {}
36 
37  private:
38  void beginRun(const Run&, const EventSetup&) override;
39  void produce(Event&, const EventSetup&) override;
40  virtual void endJob() {}
41 
42  // ED input token of sf stubs
44  // ED output token of TTTracks
46  // Setup token
48  // DataFormats token
50  // configuration
52  // helper class to store configurations
53  const Setup* setup_ = nullptr;
54  // helper class to extract structured data from tt::Frames
55  const DataFormats* dataFormats_ = nullptr;
56  };
57 
58  ProducerZHTout::ProducerZHTout(const ParameterSet& iConfig) : iConfig_(iConfig) {
59  const string& label = iConfig.getParameter<string>("LabelZHT");
60  const string& branchAcceptedStubs = iConfig.getParameter<string>("BranchAcceptedStubs");
61  const string& branchAcceptedTracks = iConfig.getParameter<string>("BranchAcceptedTracks");
62  // book in- and output ED products
63  edGetToken_ = consumes<StreamsStub>(InputTag(label, branchAcceptedStubs));
64  edPutToken_ = produces<vector<TTTrack<Ref_Phase2TrackerDigi_>>>(branchAcceptedTracks);
65  // book ES products
66  esGetTokenSetup_ = esConsumes<Setup, SetupRcd, Transition::BeginRun>();
67  esGetTokenDataFormats_ = esConsumes<DataFormats, DataFormatsRcd, Transition::BeginRun>();
68  }
69 
70  void ProducerZHTout::beginRun(const Run& iRun, const EventSetup& iSetup) {
71  // helper class to store configurations
72  setup_ = &iSetup.getData(esGetTokenSetup_);
74  return;
75  // check process history if desired
76  if (iConfig_.getParameter<bool>("CheckHistory"))
78  // helper class to extract structured data from tt::Frames
80  }
81 
87  // empty SFout product
88  deque<TTTrack<Ref_Phase2TrackerDigi_>> ttTracks;
89  // read in SF Product and produce SFout product
92  iEvent.getByToken<StreamsStub>(edGetToken_, handle);
93  const StreamsStub& streams = *handle.product();
94  for (int region = 0; region < setup_->numRegions(); region++) {
95  for (int channel = 0; channel < dataFormats_->numChannel(Process::zht); channel++) {
96  const int index = region * dataFormats_->numChannel(Process::zht) + channel;
97  // convert stream to stubs
98  const StreamStub& stream = streams[index];
99  vector<StubZHT> stubs;
100  stubs.reserve(stream.size());
101  for (const FrameStub& frame : stream)
102  if (frame.first.isNonnull())
103  stubs.emplace_back(frame, dataFormats_);
104  // form tracks
105  int i(0);
106  for (auto it = stubs.begin(); it != stubs.end();) {
107  const auto start = it;
108  const int id = it->trackId();
109  auto different = [id](const StubZHT& stub) { return id != stub.trackId(); };
110  it = find_if(it, stubs.end(), different);
111  vector<TTStubRef> ttStubRefs;
112  ttStubRefs.reserve(distance(start, it));
113  transform(start, it, back_inserter(ttStubRefs), [](const StubZHT& stub) { return stub.ttStubRef(); });
114  const double zT = dfZT.floating(start->zT());
115  const double cot = dfCot.floating(start->cot());
116  const double phiT = dfPhiT.floating(start->phiT());
117  const double inv2R = dfinv2R.floating(start->inv2R());
118  ttTracks.emplace_back(inv2R, phiT, cot, zT, 0., 0., 0., 0., 0., 0, 0, 0.);
119  ttTracks.back().setStubRefs(ttStubRefs);
120  ttTracks.back().setPhiSector(start->sectorPhi() + region * setup_->numSectorsPhi());
121  ttTracks.back().setEtaSector(start->sectorEta());
122  ttTracks.back().setTrackSeedType(start->trackId());
123  if (i++ == setup_->zhtMaxTracks())
124  break;
125  }
126  }
127  }
128  }
129  // store product
130  iEvent.emplace(edPutToken_, ttTracks.begin(), ttTracks.end());
131  }
132 
133 } // namespace trackerTFP
134 
Definition: start.py:1
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
int numSectorsPhi() const
Definition: Setup.h:413
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
std::vector< FrameStub > StreamStub
Definition: TTTypes.h:63
const DataFormats * dataFormats_
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
TTStubRef ttStubRef() const
Definition: DataFormats.h:578
ESGetToken< Setup, SetupRcd > esGetTokenSetup_
int numChannel(Process p) const
Definition: DataFormats.h:498
char const * label
int iEvent
Definition: GenABIO.cc:224
Definition: TTTypes.h:54
double floating(int i) const
Definition: DataFormats.h:94
int zhtMaxTracks() const
Definition: Setup.h:475
bool configurationSupported() const
Definition: Setup.h:60
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ProcessHistory const & processHistory() const
Definition: Run.cc:115
ESGetToken< DataFormats, DataFormatsRcd > esGetTokenDataFormats_
transforms SF output into TTTracks
void produce(Event &, const EventSetup &) override
void checkHistory(const edm::ProcessHistory &processHistory) const
Definition: Setup.cc:242
EDGetTokenT< StreamsStub > edGetToken_
int numRegions() const
Definition: Setup.h:349
HLT enums.
Class to calculate and provide dataformats used by Track Trigger emulator.
Definition: DataFormats.h:216
void beginRun(const Run &, const EventSetup &) override
EDPutTokenT< vector< TTTrack< Ref_Phase2TrackerDigi_ > > > edPutToken_
Definition: Run.h:45
const DataFormat & format(Variable v, Process p) const
Definition: DataFormats.h:506
unsigned transform(const HcalDetId &id, unsigned transformCode)