29 #include <unordered_map> 50 return std::max<int>(0,
52 std::normal_distribution<double>(0, 500)(randomGenerator_));
63 void writeInputPatterns(
66 void writeOutputPatterns(
69 void endJob()
override;
95 "GMTSaDisplacedMuons",
104 "GTTDisplacedTracks",
107 template <
typename T1,
typename T2>
108 static std::vector<T1>
vconvert(std::vector<T2> ivec) {
109 return std::vector<T1>(ivec.begin(), ivec.end());
113 : randomGenerator_(
config.exists(
"random_seed") ?
config.getUntrackedParameter<unsigned
int>(
"random_seed")
114 :
std::random_device()()),
115 inputBoardDataWriter_(
121 config.getUntrackedParameter<unsigned
int>(
"maxFrames"),
128 {{6, 0}, vconvert<std::size_t>(iChannels.
getUntrackedParameter<std::vector<unsigned int>>(
"GCT_1"))}});
135 {{6, 0}, vconvert<std::size_t>(iChannels.
getUntrackedParameter<std::vector<unsigned int>>(
"GTT_1"))}});
138 {{6, 0}, vconvert<std::size_t>(iChannels.
getUntrackedParameter<std::vector<unsigned int>>(
"GTT_2"))}});
141 {{6, 0}, vconvert<std::size_t>(iChannels.
getUntrackedParameter<std::vector<unsigned int>>(
"GTT_3"))}});
144 {{6, 0}, vconvert<std::size_t>(iChannels.
getUntrackedParameter<std::vector<unsigned int>>(
"GTT_4"))}});
147 {{6, 0}, vconvert<std::size_t>(iChannels.
getUntrackedParameter<std::vector<unsigned int>>(
"CL2_1"))}});
150 {{6, 0}, vconvert<std::size_t>(iChannels.
getUntrackedParameter<std::vector<unsigned int>>(
"CL2_2"))}});
153 {{6, 0}, vconvert<std::size_t>(iChannels.
getUntrackedParameter<std::vector<unsigned int>>(
"CL2_3"))}});
163 config.getUntrackedParameter<
unsigned int>(
"maxFrames"),
165 const edm::ParameterSet &oChannels = config.getUntrackedParameterSet(
"OutputChannels");
166 demo::BoardDataWriter::ChannelMap_t channelMap;
167 for (const char *name : AVAILABLE_COLLECTIONS) {
168 if (oChannels.exists(name)) {
169 std::vector<unsigned int> channels =
170 oChannels.getUntrackedParameter<std::vector<unsigned int>>(name);
171 for (std::size_t i = 0; i < channels.size(); i++) {
172 channelMap.insert({{name, i}, {{1, 0}, {channels.at(i)}}});
175 numChannels_.insert({name, channels.size()});
177 numChannels_.insert({name, 0});
183 produces<P2GTCandidateCollection>(
name);
189 desc.addOptionalUntracked<
unsigned int>(
"random_seed");
190 desc.addUntracked<
unsigned int>(
"maxFrames", 1024);
198 inputChannelDesc.
addUntracked<std::vector<unsigned int>>(
"GCT_1");
199 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"GMT_1");
200 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"GTT_1");
201 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"GTT_2");
202 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"GTT_3");
203 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"GTT_4");
204 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"CL2_1");
205 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"CL2_2");
206 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"CL2_3");
231 template <
typename...
Args>
232 static std::vector<ap_uint<64>>
vpack(
const Args &...vobjects) {
233 std::vector<ap_uint<64>> vpacked;
236 [&vpacked](
const std::vector<std::unique_ptr<l1t::L1TGT_BaseInterface>> &
objects) {
237 std::optional<ap_uint<64>> next_packed;
238 for (
const auto &
object :
objects) {
239 if (
object->packed_width() == 64) {
241 vpacked.emplace_back(interface_obj.
pack());
242 }
else if (
object->packed_width() == 96) {
244 ap_uint<96> packed = interface_obj.
pack();
245 if (next_packed.has_value()) {
246 vpacked.emplace_back(packed(95, 64) << 32 | next_packed.value());
249 next_packed = packed(95, 64);
252 vpacked.emplace_back(packed(63, 0));
254 }
else if (
object->packed_width() == 128) {
256 ap_uint<128> packed = interface_obj.
pack();
257 vpacked.emplace_back(packed(63, 0));
258 vpacked.emplace_back(packed(127, 64));
307 const std::unordered_map<
std::string,
std::vector<std::unique_ptr<l1t::L1TGT_BaseInterface>>> &outputObjects) {
308 std::map<demo::LinkId, std::vector<ap_uint<64>>> eventData;
311 std::vector<ap_uint<64>>
data =
vpack(outputObjects.at(
name));
318 while (eventData[{
name,
i}].size() < 9) {
319 eventData[{
name,
i}].push_back(0);
329 std::unordered_map<std::string, std::vector<std::unique_ptr<l1t::L1TGT_BaseInterface>>>
inputObjects;
330 for (std::size_t
i = 0;
i < 12; ++
i) {
332 inputObjects[
"GMTSaPromptMuons"].emplace_back(std::make_unique<l1t::L1TGT_GMT_PromptDisplacedMuon>(
335 inputObjects[
"GMTSaDisplacedMuons"].emplace_back(std::make_unique<l1t::L1TGT_GMT_PromptDisplacedMuon>(
337 inputObjects[
"GMTTkMuons"].emplace_back(std::make_unique<l1t::L1TGT_GMT_TrackMatchedmuon>(
true,
360 inputObjects[
"GTTPromptTracks"].emplace_back(std::make_unique<l1t::L1TGT_GTT_Track>());
361 inputObjects[
"GTTDisplacedTracks"].emplace_back(std::make_unique<l1t::L1TGT_GTT_Track>());
366 inputObjects[
"GTTDisplacedJets"].emplace_back(std::make_unique<l1t::L1TGT_GTT_DisplacedJet>(
368 inputObjects[
"GTTHadronicTaus"].emplace_back(std::make_unique<l1t::L1TGT_GTT_HadronicTau>(
382 inputObjects[
"CL2Electrons"].emplace_back(std::make_unique<l1t::L1TGT_CL2_Electron>(
386 inputObjects[
"CL2Taus"].emplace_back(std::make_unique<l1t::L1TGT_CL2_Tau>(
411 std::unique_ptr<P2GTCandidateCollection> gtCollection = std::make_unique<P2GTCandidateCollection>();
413 gtCollection->emplace_back(
object->to_GTObject());
std::unordered_map< std::string, std::size_t > numChannels_
std::mt19937 randomGenerator_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
L1GTEvaluationProducer(const edm::ParameterSet &)
void addEvent(const EventData &data)
FileFormat parseFileFormat(const std::string &)
T getUntrackedParameter(std::string const &, T const &) const
static constexpr std::array< const char *, 29 > AVAILABLE_COLLECTIONS
static std::vector< T1 > vconvert(std::vector< T2 > ivec)
key
prepare the HTCondor submission files and eventually submit them
#define DEFINE_FWK_MODULE(type)
l1t::demo::BoardDataWriter inputBoardDataWriter_
void writeOutputPatterns(const std::unordered_map< std::string, std::vector< std::unique_ptr< l1t::L1TGT_BaseInterface >>> &inputObjects)
void produce(edm::Event &, const edm::EventSetup &) override
std::map< LinkId, std::pair< ChannelSpec, std::vector< size_t > > > ChannelMap_t
l1t::demo::BoardDataWriter outputBoardDataWriter_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void writeInputPatterns(const std::unordered_map< std::string, std::vector< std::unique_ptr< l1t::L1TGT_BaseInterface >>> &inputObjects)
virtual ap_uint< N > pack() const =0
int nextValue(int mean=1000, bool sign=false, int max=std::numeric_limits< int >::max())
char data[epos_bytes_allocation]
static void fillDescriptions(edm::ConfigurationDescriptions &)
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
static std::vector< ap_uint< 64 > > vpack(const Args &...vobjects)
Class representing information phase-2 ATCA I/O data corresponding to a single event, with logical channel IDs (essentially string-uint pairs, e.g. tracks-0 to tracks-17).