CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L1TS2PFJetInputPatternWriter Class Reference

#include <L1Trigger/L1TCalorimeter/plugins/L1TS2PFJetInputPatternWriter.cc>

Inheritance diagram for L1TS2PFJetInputPatternWriter:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 L1TS2PFJetInputPatternWriter (const edm::ParameterSet &)
 
 ~L1TS2PFJetInputPatternWriter () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept 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 noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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
 
void beginJob () override
 
void endJob () override
 

Private Attributes

std::vector< std::vector< uint64_t > > data_
 
std::vector< int > dataValid_
 
std::string filename_
 
std::map< int, int > map_
 
unsigned nChan_
 
unsigned nClearFrames_
 
unsigned nEvents_
 
unsigned nFrame_
 
unsigned nFrameFile_
 
unsigned nHeaderFrames_
 
unsigned nLink_
 
unsigned nPayloadFrames_
 
unsigned nQuad_
 
std::string outDir_
 
edm::EDGetTokenT< std::vector< l1t::PFCandidate > > pfToken_
 

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

Description:

Implementation:

Definition at line 58 of file L1TS2PFJetInputPatternWriter.cc.

Constructor & Destructor Documentation

◆ L1TS2PFJetInputPatternWriter()

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

Definition at line 107 of file L1TS2PFJetInputPatternWriter.cc.

References data_, LogDebug, nChan_, nEvents_, nFrame_, nFrameFile_, nLink_, and nQuad_.

108  : pfToken_(consumes<std::vector<l1t::PFCandidate>>(iConfig.getParameter<edm::InputTag>("pfTag"))),
109  filename_(iConfig.getUntrackedParameter<std::string>("filename")),
110  outDir_(iConfig.getUntrackedParameter<std::string>("outDir")),
111  nChan_(iConfig.getUntrackedParameter<unsigned>("nChanPerQuad")),
112  nQuad_(iConfig.getUntrackedParameter<unsigned>("nQuads")),
113  nHeaderFrames_(iConfig.getUntrackedParameter<unsigned>("nHeaderFrames")),
114  nPayloadFrames_(iConfig.getUntrackedParameter<unsigned>("nPayloadFrames")),
115  nClearFrames_(iConfig.getUntrackedParameter<unsigned>("nClearFrames")) {
116  //now do what ever initialization is needed
117 
118  // register what you consume and keep token for later access:
119 
120  nFrame_ = 0;
121  nFrameFile_ = 0;
122  nEvents_ = 0;
123 
124  nLink_ = nChan_ * nQuad_;
125  data_.resize(nLink_);
126  LogDebug("L1TDebug") << "Preparing for " << nLink_ << " links" << std::endl;
127 }
std::vector< std::vector< uint64_t > > data_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< std::vector< l1t::PFCandidate > > pfToken_
#define LogDebug(id)

◆ ~L1TS2PFJetInputPatternWriter()

L1TS2PFJetInputPatternWriter::~L1TS2PFJetInputPatternWriter ( )
override

Definition at line 129 of file L1TS2PFJetInputPatternWriter.cc.

129  {
130  // do anything here that needs to be done at desctruction time
131  // (e.g. close files, deallocate resources etc.)
132 }

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 139 of file L1TS2PFJetInputPatternWriter.cc.

References bit_shift_eta, bit_shift_phi, data, data_, dataValid_, eta_first_region_boundary, eta_second_region_boundary, etaLSB, framesPerFile, hash_bitmask_10, hash_bitmask_16, iEvent, mod_13_1, mod_13_2, n_first_empty_frames, n_latency_clocks, nChan_, nEvents_, nFrame_, nFrameFile_, nPayloadFrames_, nQuad_, pfToken_, phi_region_boundary, phiLSB, ptLSB, and parallelization::uint.

139  {
140  using namespace edm;
141 
142  //count events
143  nEvents_++;
144 
146  iEvent.getByToken(pfToken_, pfHandle);
147  std::vector<l1t::PFCandidate> const& pfCands = *pfHandle;
148 
149  std::vector<l1t::PFCandidate> pfPartsA;
150  std::vector<l1t::PFCandidate> pfPartsB;
151 
152  for (auto const& pfc : pfCands) {
153  // select first two "small" regions for current fw
154  if (pfc.eta() >= 0 && pfc.eta() < eta_first_region_boundary && pfc.phi() >= 0 && pfc.phi() < phi_region_boundary)
155  pfPartsA.push_back(pfc);
156  if (pfc.eta() >= eta_first_region_boundary && pfc.eta() < eta_second_region_boundary && pfc.phi() >= 0 &&
157  pfc.phi() < phi_region_boundary)
158  pfPartsB.push_back(pfc);
159  }
160 
161  if (pfPartsA.empty() && pfPartsB.empty())
162  return;
163 
164  if (nFrame_ == 0 || nFrameFile_ == 0) {
165  //first empty frames
167  dataValid_.push_back(1);
168  for (unsigned iQuad = 0; iQuad < nQuad_; ++iQuad) {
169  for (unsigned iChan = 0; iChan < nChan_; ++iChan) {
170  uint iLink = (iQuad * nChan_) + iChan;
171  data_.at(iLink).push_back(0);
172  }
173  }
174  nFrame_++;
175  nFrameFile_++;
176  }
177  }
178 
179  // loop over frames
180  for (unsigned iFrame = 0; iFrame < nPayloadFrames_; ++iFrame) {
181  dataValid_.push_back(1);
182  // loop over links
183  for (unsigned iQuad = 0; iQuad < nQuad_; ++iQuad) {
184  for (unsigned iChan = 0; iChan < nChan_; ++iChan) {
185  // get tower ieta, iphi for link
186  uint iLink = (iQuad * nChan_) + iChan;
187 
188  uint64_t data = 0;
189 
191  if (iLink < 24 && pfPartsA.size() > iLink) {
192  data |= ((uint64_t)floor(pfPartsA.at(iLink).pt() / ptLSB) & hash_bitmask_16);
193  data |= ((uint64_t)floor(pfPartsA.at(iLink).phi() / phiLSB) & hash_bitmask_10) << bit_shift_phi;
194  data |= ((uint64_t)floor(pfPartsA.at(iLink).eta() / etaLSB) & hash_bitmask_10) << bit_shift_eta;
195  }
196  }
198  if (iLink < 24 && pfPartsB.size() > iLink) {
199  data |= ((uint64_t)floor(pfPartsB.at(iLink).pt() / ptLSB) & hash_bitmask_16);
200  data |= ((uint64_t)floor(pfPartsB.at(iLink).phi() / phiLSB) & hash_bitmask_10) << bit_shift_phi;
201  data |= ((uint64_t)floor((pfPartsB.at(iLink).eta() - eta_first_region_boundary) / etaLSB) & hash_bitmask_10)
202  << bit_shift_eta;
203  }
204  }
205  // add data to output
206  data_.at(iLink).push_back(data);
207  }
208  }
209  nFrame_++;
210  nFrameFile_++;
211  if (nFrame_ % framesPerFile == 0)
212  nFrameFile_ = 0;
213  }
214 }
std::vector< std::vector< uint64_t > > data_
constexpr float eta_second_region_boundary
constexpr float phi_region_boundary
constexpr unsigned int bit_shift_eta
constexpr float ptLSB
constexpr unsigned int n_latency_clocks
constexpr unsigned int hash_bitmask_10
int iEvent
Definition: GenABIO.cc:224
constexpr unsigned int framesPerFile
constexpr unsigned int bit_shift_phi
constexpr unsigned int hash_bitmask_16
constexpr float etaLSB
constexpr float eta_first_region_boundary
unsigned long long uint64_t
Definition: Time.h:13
constexpr unsigned int mod_13_1
constexpr unsigned int n_first_empty_frames
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
constexpr unsigned int mod_13_2
edm::EDGetTokenT< std::vector< l1t::PFCandidate > > pfToken_
constexpr float phiLSB

◆ beginJob()

void L1TS2PFJetInputPatternWriter::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 217 of file L1TS2PFJetInputPatternWriter.cc.

217 {}

◆ endJob()

void L1TS2PFJetInputPatternWriter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 220 of file L1TS2PFJetInputPatternWriter.cc.

References reco::ceil(), data_, dataValid_, TauDecayModes::dec, filename_, framesPerFile, mps_fire::i, dqmiolumiharvest::j, LogDebug, nChan_, nClearFrames_, nEvents_, nFrame_, nHeaderFrames_, nPayloadFrames_, nQuad_, outDir_, and parallelization::uint.

220  {
221  //frames per event
222  unsigned int framesPerEv = nHeaderFrames_ + nPayloadFrames_ + nClearFrames_;
223 
224  //events per file
225  unsigned int evPerFile = floor(framesPerFile / framesPerEv);
226 
227  //number of output files
228  unsigned int nOutFiles = ceil((float)nEvents_ / (float)evPerFile);
229 
230  LogDebug("L1TDebug") << "Read " << nFrame_ << " frames" << std::endl;
231  LogDebug("L1TDebug") << "Read " << nEvents_ << " events" << std::endl;
232  LogDebug("L1TDebug") << "Writing " << nOutFiles << " files" << std::endl;
233  LogDebug("L1TDebug") << "Output directory: ./" << outDir_ << "/" << std::endl;
234 
235  //files
236  std::vector<std::ofstream> outFiles(nOutFiles);
237 
238  //make output files and write to them
239  for (uint itFile = 0; itFile < nOutFiles; ++itFile) {
240  std::stringstream outFilename;
241  outFilename << outDir_ << "/" << filename_ << "_" << itFile << ".txt";
242  outFiles[itFile] = std::ofstream(outFilename.str());
243  LogDebug("L1TDebug") << "Writing to file: ./" << outFilename.str() << std::endl;
244 
245  outFiles[itFile] << "Board SRNTY_TEST" << std::endl;
246 
247  // quad/chan numbers
248  outFiles[itFile] << " Quad/Chan : ";
249  for (unsigned i = 0; i < nQuad_; ++i) {
250  for (unsigned j = 0; j < nChan_; ++j) {
251  outFiles[itFile] << " q" << setfill('0') << setw(2) << i << "c" << j << " ";
252  }
253  }
254  outFiles[itFile] << std::endl;
255 
256  // link numbers
257  outFiles[itFile] << " Link : ";
258  for (unsigned i = 0; i < nQuad_; ++i) {
259  for (unsigned j = 0; j < nChan_; ++j) {
260  outFiles[itFile] << " " << setfill('0') << setw(2) << (i * nChan_) + j << " ";
261  }
262  }
263 
264  outFiles[itFile] << std::endl;
265 
266  // then the data
267  unsigned iFileFrame = 0;
268  for (unsigned iFrame = itFile * framesPerFile; iFrame < (itFile * framesPerFile + framesPerFile); ++iFrame) {
269  if (iFrame <= nFrame_ && iFrame < (framesPerEv * nEvents_)) {
270  outFiles[itFile] << "Frame " << std::dec << std::setw(4) << std::setfill('0') << iFileFrame << " : ";
271  for (unsigned iQuad = 0; iQuad < nQuad_; ++iQuad) {
272  for (unsigned iChan = 0; iChan < nChan_; ++iChan) {
273  unsigned iLink = (iQuad * nChan_) + iChan;
274  if (iLink < data_.size() && iFrame < data_.at(iLink).size()) {
275  outFiles[itFile] << std::hex << ::std::setw(1) << dataValid_.at(iFrame) << "v" << std::hex
276  << std::setw(16) << std::setfill('0') << data_.at(iLink).at(iFrame) << " ";
277  } else {
278  outFiles[itFile] << std::hex << ::std::setw(1) << 0 << "v" << std::hex << std::setw(16)
279  << std::setfill('0') << 0 << " ";
280  }
281  }
282  }
283  }
284  outFiles[itFile] << std::endl;
285  iFileFrame++;
286  }
287  outFiles[itFile].close();
288  }
289 }
std::vector< std::vector< uint64_t > > data_
constexpr int32_t ceil(float num)
constexpr unsigned int framesPerFile
#define LogDebug(id)

◆ fillDescriptions()

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

Definition at line 292 of file L1TS2PFJetInputPatternWriter.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

292  {
294  desc.addUntracked<unsigned int>("nPayloadFrames", 40);
295  desc.addUntracked<unsigned int>("nHeaderFrames", 1);
296  desc.add<edm::InputTag>("inputCollectionTag", edm::InputTag("l1pfCandidates", "Puppi", "IN"));
297  desc.addUntracked<std::string>("filename", "pattern.txt");
298  desc.addUntracked<unsigned int>("nChanPerQuad", 4);
299  desc.addUntracked<unsigned int>("nClearFrames", 13);
300  desc.addUntracked<unsigned int>("nQuads", 18);
301  descriptions.add("l1tS2PFJetInputPatternWriter", desc);
302 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ data_

std::vector<std::vector<uint64_t> > L1TS2PFJetInputPatternWriter::data_
private

Definition at line 87 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by analyze(), endJob(), and L1TS2PFJetInputPatternWriter().

◆ dataValid_

std::vector<int> L1TS2PFJetInputPatternWriter::dataValid_
private

Definition at line 90 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by analyze(), and endJob().

◆ filename_

std::string L1TS2PFJetInputPatternWriter::filename_
private

Definition at line 72 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by endJob().

◆ map_

std::map<int, int> L1TS2PFJetInputPatternWriter::map_
private

Definition at line 93 of file L1TS2PFJetInputPatternWriter.cc.

◆ nChan_

unsigned L1TS2PFJetInputPatternWriter::nChan_
private

Definition at line 76 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by analyze(), endJob(), and L1TS2PFJetInputPatternWriter().

◆ nClearFrames_

unsigned L1TS2PFJetInputPatternWriter::nClearFrames_
private

Definition at line 81 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by endJob().

◆ nEvents_

unsigned L1TS2PFJetInputPatternWriter::nEvents_
private

Definition at line 84 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by analyze(), endJob(), and L1TS2PFJetInputPatternWriter().

◆ nFrame_

unsigned L1TS2PFJetInputPatternWriter::nFrame_
private

Definition at line 82 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by analyze(), endJob(), and L1TS2PFJetInputPatternWriter().

◆ nFrameFile_

unsigned L1TS2PFJetInputPatternWriter::nFrameFile_
private

Definition at line 83 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by analyze(), and L1TS2PFJetInputPatternWriter().

◆ nHeaderFrames_

unsigned L1TS2PFJetInputPatternWriter::nHeaderFrames_
private

Definition at line 79 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by endJob().

◆ nLink_

unsigned L1TS2PFJetInputPatternWriter::nLink_
private

Definition at line 78 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by L1TS2PFJetInputPatternWriter().

◆ nPayloadFrames_

unsigned L1TS2PFJetInputPatternWriter::nPayloadFrames_
private

Definition at line 80 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by analyze(), and endJob().

◆ nQuad_

unsigned L1TS2PFJetInputPatternWriter::nQuad_
private

Definition at line 77 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by analyze(), endJob(), and L1TS2PFJetInputPatternWriter().

◆ outDir_

std::string L1TS2PFJetInputPatternWriter::outDir_
private

Definition at line 73 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by endJob().

◆ pfToken_

edm::EDGetTokenT<std::vector<l1t::PFCandidate> > L1TS2PFJetInputPatternWriter::pfToken_
private

Definition at line 71 of file L1TS2PFJetInputPatternWriter.cc.

Referenced by analyze().