CMS 3D CMS Logo

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

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

Inheritance diagram for L1TStage2InputPatternWriter:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 L1TStage2InputPatternWriter (const edm::ParameterSet &)
 
 ~L1TStage2InputPatternWriter () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, 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
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

std::vector< std::vector< int > > data_
 
std::vector< int > dataValid_
 
std::string filename_
 
edm::EDGetToken m_towerToken
 
std::map< int, int > map_
 
unsigned nChan_
 
unsigned nClearFrames_
 
unsigned nEvents_
 
unsigned nFrame_
 
unsigned nHeaderFrames_
 
unsigned nLink_
 
unsigned nPayloadFrames_
 
unsigned nQuad_
 
std::string outDir_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer 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)
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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<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)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 48 of file L1TStage2InputPatternWriter.cc.

Constructor & Destructor Documentation

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

Definition at line 104 of file L1TStage2InputPatternWriter.cc.

References data_, filename_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), LogDebug, m_towerToken, nChan_, nClearFrames_, nEvents_, nFrame_, nHeaderFrames_, nLink_, nPayloadFrames_, nQuad_, outDir_, and AlCaHLTBitMon_QueryRunRegistry::string.

105 {
106  //now do what ever initialization is needed
107 
108  // register what you consume and keep token for later access:
109  m_towerToken = consumes<l1t::CaloTowerBxCollection> (iConfig.getParameter<edm::InputTag>("towerToken"));
110 
111  filename_ = iConfig.getUntrackedParameter<std::string>("filename");
112  outDir_ = iConfig.getUntrackedParameter<std::string>("outDir");
113 
114  nChan_ = 4;
115  nQuad_ = 18;
116 
117  nHeaderFrames_ = iConfig.getUntrackedParameter<unsigned>("mpHeaderFrames");
118  nPayloadFrames_ = iConfig.getUntrackedParameter<unsigned>("mpPayloadFrames");
119  nClearFrames_ = iConfig.getUntrackedParameter<unsigned>("mpClearFrames");
120  nFrame_ = 0;
121  nEvents_ = 0;
122 
123  nLink_ = nChan_ * nQuad_;
124  data_.resize(nLink_);
125  LogDebug("L1TDebug") << "Preparing for " << nLink_ << " links" << std::endl;
126 
127 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::vector< int > > data_
L1TStage2InputPatternWriter::~L1TStage2InputPatternWriter ( )
override

Definition at line 130 of file L1TStage2InputPatternWriter.cc.

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

Member Function Documentation

void L1TStage2InputPatternWriter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 145 of file L1TStage2InputPatternWriter.cc.

References l1t::CaloTools::caloEta(), data, data_, dataValid_, edm::Event::getByToken(), l1t::CaloTools::getTower(), l1t::CaloTower::hwEtRatio(), l1t::L1Candidate::hwPt(), l1t::L1Candidate::hwQual(), m_towerToken, nChan_, nClearFrames_, nEvents_, nFrame_, nHeaderFrames_, nPayloadFrames_, and nQuad_.

146 {
147  using namespace edm;
148 
149  //count events
150  nEvents_++;
151 
152  // get towers
154  iEvent.getByToken(m_towerToken,towHandle);
155 
156  std::vector<l1t::CaloTower> towers;
157 
158  for(std::vector<l1t::CaloTower>::const_iterator tower = towHandle->begin(0);
159  tower != towHandle->end(0);
160  ++tower) {
161  towers.push_back(*tower);
162  }
163 
164 
165  // insert header frames
166  for ( unsigned iFrame=0; iFrame<nHeaderFrames_; ++iFrame ) {
167 
168  dataValid_.push_back( 1 );
169 
170  // loop over links
171  for ( unsigned iQuad=0; iQuad<nQuad_; ++iQuad ) {
172  for ( unsigned iChan=0; iChan<nChan_; ++iChan ) {
173 
174  int data=0;
175 
176  // get tower ieta, iphi for link
177  unsigned iLink = (iQuad*nChan_)+iChan;
178 
179  // add data to output
180  data_.at(iLink).push_back( data );
181 
182  }
183 
184  }
185 
186  nFrame_++;
187 
188  }
189 
190  // loop over frames
191  for ( unsigned iFrame=0; iFrame<nPayloadFrames_; ++iFrame ) {
192 
193  dataValid_.push_back( 1 );
194 
195  // loop over links
196  for ( unsigned iQuad=0; iQuad<nQuad_; ++iQuad ) {
197  for ( unsigned iChan=0; iChan<nChan_; ++iChan ) {
198 
199  int data=0;
200 
201  // get tower ieta, iphi for link
202  int iLink = (iQuad*nChan_)+iChan;
203  int ietaSgn = (iLink % 2==0 ? +1 : -1);
204  int ieta = ietaSgn * (iFrame + 1);
205  int iphi = 1+(iLink % 2==0 ? iLink : iLink-1);
206 
207  // get tower 1 data
209  data |= tower.hwPt() & 0x1ff;
210  data |= (tower.hwEtRatio() & 0x7)<<9;
211  data |= (tower.hwQual() & 0xf)<<12;
212 
213  // get tower 2
214  iphi = iphi + 1;
215  tower = l1t::CaloTools::getTower(towers, l1t::CaloTools::caloEta(ieta), iphi);
216  data |= (tower.hwPt() & 0x1ff)<<16;
217  data |= (tower.hwEtRatio() & 0x7)<<25;
218  data |= (tower.hwQual() & 0xf)<<28;
219 
220  // add data to output
221  data_.at(iLink).push_back( data );
222 
223  }
224 
225  }
226 
227  nFrame_++;
228 
229  }
230 
231 
232  // loop over clear frames
233  for ( unsigned iFrame=0; iFrame<nClearFrames_; ++iFrame ) {
234 
235  dataValid_.push_back( 0 );
236 
237  // loop over links
238  for ( unsigned iQuad=0; iQuad<nQuad_; ++iQuad ) {
239  for ( unsigned iChan=0; iChan<nChan_; ++iChan ) {
240 
241  int data=0;
242 
243  // get tower ieta, iphi for link
244  unsigned iLink = (iQuad*nChan_)+iChan;
245 
246  // add data to output
247  data_.at(iLink).push_back( data );
248 
249  }
250 
251  }
252 
253  nFrame_++;
254 
255  }
256 
257 
258 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
int hwEtRatio() const
Definition: CaloTower.cc:74
int hwQual() const
Definition: L1Candidate.h:51
int hwPt() const
Definition: L1Candidate.h:48
static int caloEta(int ietaMP)
Definition: CaloTools.cc:210
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static const l1t::CaloTower & getTower(const std::vector< l1t::CaloTower > &towers, int iEta, int iPhi)
Definition: CaloTools.cc:37
std::vector< std::vector< int > > data_
void L1TStage2InputPatternWriter::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 263 of file L1TStage2InputPatternWriter.cc.

264 {
265 
266 
267 }
void L1TStage2InputPatternWriter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 271 of file L1TStage2InputPatternWriter.cc.

References MessageLogger_cfi::cerr, gather_cfg::cout, data_, dataValid_, TauDecayModes::dec, filename_, mps_fire::i, LogDebug, nChan_, nClearFrames_, nEvents_, nFrame_, nHeaderFrames_, nPayloadFrames_, nQuad_, outDir_, and parallelization::uint().

272 {
273 
274  //frames per event
275  unsigned int framesPerEv = nHeaderFrames_ + nPayloadFrames_ + nClearFrames_;
276 
277  //events per file
278  unsigned int evPerFile = floor(1024/framesPerEv);
279 
280  //frames per file
281  unsigned int framesPerFile = framesPerEv*evPerFile;
282 
283  //number of output files
284  unsigned int nOutFiles = ceil(nEvents_/evPerFile);
285 
286  LogDebug("L1TDebug") << "Read " << nFrame_ << " frames" << std::endl;
287  LogDebug("L1TDebug") << "Read " << nEvents_ << " events" << std::endl;
288  LogDebug("L1TDebug") << "Writing " << nOutFiles << " files" << std::endl;
289  LogDebug("L1TDebug") << "Output directory: ./" << outDir_ << "/" << std::endl;
290 
291  //files
292  std::vector< std::ofstream > outFiles(nOutFiles);
293 
294  //make output files and write to them
295  for(uint itFile=0; itFile<nOutFiles; ++itFile){
296  std::stringstream outFilename;
297  outFilename << outDir_ << "/" << filename_ << "_" << itFile << ".txt";
298  outFiles[itFile] = std::ofstream(outFilename.str());
299  LogDebug("L1TDebug") << "Writing to file: ./" << outFilename.str() << std::endl;
300  std::cout << "Writing to file: ./" << outFilename.str() << std::endl;
301 
302  outFiles[itFile] << "Board MP7_TEST" << std::endl;
303 
304  // quad/chan numbers
305  outFiles[itFile] << " Quad/Chan : ";
306  for ( unsigned i=0; i<nQuad_; ++i ) {
307  for ( unsigned j=0; j<nChan_; ++j ) {
308  outFiles[itFile] << " q" << setfill('0') << setw(2) << i << "c" << j << " ";
309  }
310  }
311  outFiles[itFile] << std::endl;
312 
313  // link numbers
314  outFiles[itFile] << " Link : ";
315  for ( unsigned i=0; i<nQuad_; ++i ) {
316  for ( unsigned j=0; j<nChan_; ++j ) {
317  outFiles[itFile] << " " << setfill('0') << setw(2) << (i*nChan_)+j << " ";
318  }
319  }
320 
321  outFiles[itFile] << std::endl;
322 
323  // then the data
324  unsigned iFileFrame=0;
325  for ( unsigned iFrame=itFile*framesPerFile; iFrame<(itFile*framesPerFile+framesPerFile); ++iFrame ) {
326  if( iFrame <= nFrame_ ){
327  outFiles[itFile] << "Frame " << std::dec << std::setw(4) << std::setfill('0') << iFileFrame << " : ";
328  for ( unsigned iQuad=0; iQuad<nQuad_; ++iQuad ) {
329  for ( unsigned iChan=0; iChan<nChan_; ++iChan ) {
330  unsigned iLink = (iQuad*nChan_)+iChan;
331  if (iLink<data_.size() && iFrame<data_.at(iLink).size()) {
332  outFiles[itFile] << std::hex << ::std::setw(1) << dataValid_.at(iFrame) << "v" << std::hex << std::setw(8) << std::setfill('0') << data_.at(iLink).at(iFrame) << " ";
333  }
334  else {
335  std::cerr << "Out of range : " << iLink << ", " << iFrame << std::endl;
336  }
337  }
338  }
339  }
340  outFiles[itFile] << std::endl;
341  iFileFrame++;
342  }
343  outFiles[itFile].close();
344  }
345 
346 }
#define LogDebug(id)
def uint(string)
std::vector< std::vector< int > > data_
void L1TStage2InputPatternWriter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 384 of file L1TStage2InputPatternWriter.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

384  {
385  //The following says we do not know what parameters are allowed so do no validation
386  // Please change this to state exactly what you do use, even if it is no parameters
388  desc.setUnknown();
389  descriptions.addDefault(desc);
390 }
void addDefault(ParameterSetDescription const &psetDescription)

Member Data Documentation

std::vector< std::vector<int> > L1TStage2InputPatternWriter::data_
private

Definition at line 83 of file L1TStage2InputPatternWriter.cc.

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

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

Definition at line 86 of file L1TStage2InputPatternWriter.cc.

Referenced by analyze(), and endJob().

std::string L1TStage2InputPatternWriter::filename_
private

Definition at line 69 of file L1TStage2InputPatternWriter.cc.

Referenced by endJob(), and L1TStage2InputPatternWriter().

edm::EDGetToken L1TStage2InputPatternWriter::m_towerToken
private

Definition at line 67 of file L1TStage2InputPatternWriter.cc.

Referenced by analyze(), and L1TStage2InputPatternWriter().

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

Definition at line 89 of file L1TStage2InputPatternWriter.cc.

unsigned L1TStage2InputPatternWriter::nChan_
private

Definition at line 73 of file L1TStage2InputPatternWriter.cc.

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

unsigned L1TStage2InputPatternWriter::nClearFrames_
private

Definition at line 78 of file L1TStage2InputPatternWriter.cc.

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

unsigned L1TStage2InputPatternWriter::nEvents_
private

Definition at line 80 of file L1TStage2InputPatternWriter.cc.

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

unsigned L1TStage2InputPatternWriter::nFrame_
private

Definition at line 79 of file L1TStage2InputPatternWriter.cc.

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

unsigned L1TStage2InputPatternWriter::nHeaderFrames_
private

Definition at line 76 of file L1TStage2InputPatternWriter.cc.

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

unsigned L1TStage2InputPatternWriter::nLink_
private

Definition at line 75 of file L1TStage2InputPatternWriter.cc.

Referenced by L1TStage2InputPatternWriter().

unsigned L1TStage2InputPatternWriter::nPayloadFrames_
private

Definition at line 77 of file L1TStage2InputPatternWriter.cc.

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

unsigned L1TStage2InputPatternWriter::nQuad_
private

Definition at line 74 of file L1TStage2InputPatternWriter.cc.

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

std::string L1TStage2InputPatternWriter::outDir_
private

Definition at line 70 of file L1TStage2InputPatternWriter.cc.

Referenced by endJob(), and L1TStage2InputPatternWriter().