CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L1CTJetFileWriter Class Reference
Inheritance diagram for L1CTJetFileWriter:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 L1CTJetFileWriter (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
std::vector< ap_uint< 64 > > encodeJets (const std::vector< l1t::PFJet > jets, unsigned nJets)
 
std::vector< ap_uint< 64 > > encodeSums (const std::vector< l1t::EtSum > sums, unsigned nSums)
 
void endJob () override
 

Private Attributes

std::map< l1t::demo::LinkId, std::pair< l1t::demo::ChannelSpec, std::vector< size_t > > > channelSpecsOutputToGT_
 
std::vector< edm::ParameterSetcollections_
 
size_t ctl2BoardTMUX_
 
l1t::demo::BoardDataWriter fileWriterOutputToGT_
 
size_t gapLengthOutput_
 
size_t maxLinesPerFile_
 
size_t nFramesPerBX_
 
std::vector< unsigned > nJets_
 
std::vector< unsigned > nSums_
 
std::vector< std::pair< edm::EDGetTokenT< edm::View< l1t::PFJet > >, edm::EDGetTokenT< edm::View< l1t::EtSum > > > > tokens_
 
std::vector< std::pair< bool, bool > > tokensToWrite_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 26 of file L1CTJetFileWriter.cc.

Constructor & Destructor Documentation

◆ L1CTJetFileWriter()

L1CTJetFileWriter::L1CTJetFileWriter ( const edm::ParameterSet iConfig)
explicit

Definition at line 55 of file L1CTJetFileWriter.cc.

References ctl2BoardTMUX_, and gapLengthOutput_.

56  : collections_(iConfig.getParameter<std::vector<edm::ParameterSet>>("collections")),
57  nFramesPerBX_(iConfig.getParameter<unsigned>("nFramesPerBX")),
58  ctl2BoardTMUX_(iConfig.getParameter<unsigned>("TMUX")),
59  gapLengthOutput_(iConfig.getParameter<unsigned>("gapLengthOutput")),
60  maxLinesPerFile_(iConfig.getParameter<unsigned>("maxLinesPerFile")),
63  iConfig.getParameter<std::string>("outputFilename"),
64  iConfig.getParameter<std::string>("outputFileExtension"),
69  for (const auto& pset : collections_) {
72  unsigned nJets = pset.getParameter<unsigned>("nJets");
73  unsigned nSums = pset.getParameter<unsigned>("nSums");
74  nJets_.push_back(nJets);
75  nSums_.push_back(nSums);
76  bool writeJetToken(false), writeMhtToken(false);
77  if (nJets > 0) {
78  jetToken = consumes<edm::View<l1t::PFJet>>(pset.getParameter<edm::InputTag>("jets"));
79  writeJetToken = true;
80  }
81  if (nSums > 0) {
82  mhtToken = consumes<edm::View<l1t::EtSum>>(pset.getParameter<edm::InputTag>("mht"));
83  writeMhtToken = true;
84  }
85  tokens_.emplace_back(jetToken, mhtToken);
86  tokensToWrite_.emplace_back(writeJetToken, writeMhtToken);
87  }
88 }
std::map< l1t::demo::LinkId, std::pair< l1t::demo::ChannelSpec, std::vector< size_t > > > channelSpecsOutputToGT_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< std::pair< bool, bool > > tokensToWrite_
std::vector< std::pair< edm::EDGetTokenT< edm::View< l1t::PFJet > >, edm::EDGetTokenT< edm::View< l1t::EtSum > > > > tokens_
FileFormat parseFileFormat(const std::string &)
Definition: utilities.cc:73
static constexpr int nJets
l1t::demo::BoardDataWriter fileWriterOutputToGT_
std::vector< unsigned > nSums_
std::vector< unsigned > nJets_
std::vector< edm::ParameterSet > collections_

Member Function Documentation

◆ analyze()

void L1CTJetFileWriter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 90 of file L1CTJetFileWriter.cc.

References l1t::demo::EventData::add(), l1t::demo::BoardDataWriter::addEvent(), collections_, filterCSVwithJSON::copy, encodeJets(), encodeSums(), fileWriterOutputToGT_, mps_fire::i, iEvent, dqmiolumiharvest::j, PDWG_EXODelayedJetMET_cff::jets, unpackData-CaloStage1::jetToken, l1tJetFileWriter_cfi::mht, nJets_, nSums_, tokens_, and tokensToWrite_.

90  {
91  using namespace edm;
92 
93  // 1) Pack collections in the order they're specified. jets then sums within collection
94  std::vector<ap_uint<64>> link_words;
95  for (unsigned iCollection = 0; iCollection < collections_.size(); iCollection++) {
96  if (tokensToWrite_.at(iCollection).first) {
97  const auto& jetToken = tokens_.at(iCollection).first;
98  // 2) Encode jet information onto vectors containing link data
100  std::vector<l1t::PFJet> sortedJets;
101  sortedJets.reserve(jets.size());
102  std::copy(jets.begin(), jets.end(), std::back_inserter(sortedJets));
103 
104  std::stable_sort(
105  sortedJets.begin(), sortedJets.end(), [](l1t::PFJet i, l1t::PFJet j) { return (i.hwPt() > j.hwPt()); });
106  const auto outputJets(encodeJets(sortedJets, nJets_.at(iCollection)));
107  link_words.insert(link_words.end(), outputJets.begin(), outputJets.end());
108  }
109 
110  if (tokensToWrite_.at(iCollection).second) {
111  // 3) Encode sums onto vectors containing link data
112  const auto& mhtToken = tokens_.at(iCollection).second;
113  const edm::View<l1t::EtSum>& mht = iEvent.get(mhtToken);
114  std::vector<l1t::EtSum> orderedSums;
115  std::copy(mht.begin(), mht.end(), std::back_inserter(orderedSums));
116  const auto outputSums(encodeSums(orderedSums, nSums_.at(iCollection)));
117  link_words.insert(link_words.end(), outputSums.begin(), outputSums.end());
118  }
119  }
120  // 4) Pack jet information into 'event data' object, and pass that to file writer
121  l1t::demo::EventData eventDataJets;
122  eventDataJets.add({"jets", 0}, link_words);
123  fileWriterOutputToGT_.addEvent(eventDataJets);
124 }
std::vector< std::pair< bool, bool > > tokensToWrite_
std::vector< std::pair< edm::EDGetTokenT< edm::View< l1t::PFJet > >, edm::EDGetTokenT< edm::View< l1t::EtSum > > > > tokens_
void addEvent(const EventData &data)
void add(const LinkId &, const std::vector< ap_uint< 64 >> &)
Definition: EventData.cc:14
std::vector< ap_uint< 64 > > encodeSums(const std::vector< l1t::EtSum > sums, unsigned nSums)
int iEvent
Definition: GenABIO.cc:224
l1t::demo::BoardDataWriter fileWriterOutputToGT_
std::vector< ap_uint< 64 > > encodeJets(const std::vector< l1t::PFJet > jets, unsigned nJets)
std::vector< unsigned > nSums_
std::vector< unsigned > nJets_
std::vector< edm::ParameterSet > collections_
HLT enums.
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).
Definition: EventData.h:28

◆ encodeJets()

std::vector< ap_uint< 64 > > L1CTJetFileWriter::encodeJets ( const std::vector< l1t::PFJet jets,
unsigned  nJets 
)
private

Definition at line 132 of file L1CTJetFileWriter.cc.

References mps_fire::i, dqmiolumiharvest::j, PDWG_EXODelayedJetMET_cff::jets, SiStripPI::min, nJets, and parallelization::uint.

Referenced by analyze().

132  {
133  // Encode up to nJets jets, padded with 0s
134  std::vector<ap_uint<64>> jet_words(2 * nJets, 0); // allocate 2 words per jet
135  for (unsigned i = 0; i < std::min(nJets, (uint)jets.size()); i++) {
136  const l1t::PFJet& j = jets.at(i);
137  jet_words[2 * i] = j.encodedJet()[0];
138  jet_words[2 * i + 1] = j.encodedJet()[1];
139  }
140  return jet_words;
141 }
static constexpr int nJets

◆ encodeSums()

std::vector< ap_uint< 64 > > L1CTJetFileWriter::encodeSums ( const std::vector< l1t::EtSum sums,
unsigned  nSums 
)
private

Definition at line 143 of file L1CTJetFileWriter.cc.

References mps_fire::i, l1tJetFileWriter_cfi::nSums, l1gt::Sum::pack_ap(), l1gt::Sum::scalar_pt, l1gt::Sum::valid, l1gt::Sum::vector_phi, and l1gt::Sum::vector_pt.

Referenced by analyze().

143  {
144  // Need two l1t::EtSum for each GT Sum
145  std::vector<ap_uint<64>> sum_words;
146  for (unsigned i = 0; i < nSums; i++) {
147  if (2 * i < sums.size()) {
148  l1gt::Sum gtSum;
149  gtSum.valid = 1; // if the sums are sent at all, they are valid
150  gtSum.vector_pt.V = sums.at(2 * i + 1).hwPt();
151  gtSum.vector_phi.V = sums.at(2 * i + 1).hwPhi();
152  gtSum.scalar_pt.V = sums.at(2 * i).hwPt();
153  sum_words.push_back(gtSum.pack_ap());
154  } else {
155  sum_words.push_back(0);
156  }
157  }
158  return sum_words;
159 }
ap_uint< BITWIDTH > pack_ap() const
Definition: gt_datatypes.h:159
pt_t vector_pt
Definition: gt_datatypes.h:142
phi_t vector_phi
Definition: gt_datatypes.h:143
pt_t scalar_pt
Definition: gt_datatypes.h:144
valid_t valid
Definition: gt_datatypes.h:141

◆ endJob()

void L1CTJetFileWriter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 127 of file L1CTJetFileWriter.cc.

References fileWriterOutputToGT_, and l1t::demo::BoardDataWriter::flush().

127  {
128  // Writing pending events to file before exiting
130 }
l1t::demo::BoardDataWriter fileWriterOutputToGT_

◆ fillDescriptions()

void L1CTJetFileWriter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 162 of file L1CTJetFileWriter.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addDefault(), edm::ParameterSetDescription::addOptional(), submitPVResolutionJobs::desc, AlCaHLTBitMon_QueryRunRegistry::string, and parallelization::uint.

162  {
164  {
166  vpsd1.addOptional<edm::InputTag>("jets");
167  vpsd1.addOptional<edm::InputTag>("mht");
168  vpsd1.add<uint>("nJets", 0);
169  vpsd1.add<uint>("nSums", 0);
170  desc.addVPSet("collections", vpsd1);
171  }
172  desc.add<std::string>("outputFilename");
173  desc.add<std::string>("outputFileExtension", "txt");
174  desc.add<uint32_t>("nJets", 12);
175  desc.add<uint32_t>("nFramesPerBX", 9);
176  desc.add<uint32_t>("gapLengthOutput", 4);
177  desc.add<uint32_t>("TMUX", 6);
178  desc.add<uint32_t>("maxLinesPerFile", 1024);
179  desc.add<std::string>("format", "EMPv2");
180  descriptions.addDefault(desc);
181 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void addDefault(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)

Member Data Documentation

◆ channelSpecsOutputToGT_

std::map<l1t::demo::LinkId, std::pair<l1t::demo::ChannelSpec, std::vector<size_t> > > L1CTJetFileWriter::channelSpecsOutputToGT_
private

Definition at line 40 of file L1CTJetFileWriter.cc.

◆ collections_

std::vector<edm::ParameterSet> L1CTJetFileWriter::collections_
private

Definition at line 34 of file L1CTJetFileWriter.cc.

Referenced by analyze().

◆ ctl2BoardTMUX_

size_t L1CTJetFileWriter::ctl2BoardTMUX_
private

Definition at line 37 of file L1CTJetFileWriter.cc.

Referenced by L1CTJetFileWriter().

◆ fileWriterOutputToGT_

l1t::demo::BoardDataWriter L1CTJetFileWriter::fileWriterOutputToGT_
private

Definition at line 48 of file L1CTJetFileWriter.cc.

Referenced by analyze(), and endJob().

◆ gapLengthOutput_

size_t L1CTJetFileWriter::gapLengthOutput_
private

Definition at line 38 of file L1CTJetFileWriter.cc.

Referenced by L1CTJetFileWriter().

◆ maxLinesPerFile_

size_t L1CTJetFileWriter::maxLinesPerFile_
private

Definition at line 39 of file L1CTJetFileWriter.cc.

◆ nFramesPerBX_

size_t L1CTJetFileWriter::nFramesPerBX_
private

Definition at line 36 of file L1CTJetFileWriter.cc.

◆ nJets_

std::vector<unsigned> L1CTJetFileWriter::nJets_
private

Definition at line 51 of file L1CTJetFileWriter.cc.

Referenced by analyze().

◆ nSums_

std::vector<unsigned> L1CTJetFileWriter::nSums_
private

Definition at line 52 of file L1CTJetFileWriter.cc.

Referenced by analyze().

◆ tokens_

std::vector<std::pair<edm::EDGetTokenT<edm::View<l1t::PFJet> >, edm::EDGetTokenT<edm::View<l1t::EtSum> > > > L1CTJetFileWriter::tokens_
private

Definition at line 49 of file L1CTJetFileWriter.cc.

Referenced by analyze().

◆ tokensToWrite_

std::vector<std::pair<bool, bool> > L1CTJetFileWriter::tokensToWrite_
private

Definition at line 50 of file L1CTJetFileWriter.cc.

Referenced by analyze().