CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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 &)
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginJob () override
 
virtual 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 nFrame_
 
unsigned nHeaderFrames_
 
unsigned nLink_
 
unsigned nPayloadFrames_
 
unsigned nQuad_
 

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 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 50 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_, nFrame_, nHeaderFrames_, nLink_, nPayloadFrames_, nQuad_, 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", "pattern.txt");
112 
113  nChan_ = iConfig.getUntrackedParameter<unsigned>("nChanPerQuad", 4);
114  nQuad_ = iConfig.getUntrackedParameter<unsigned>("nQuads", 18);
115 
116  nHeaderFrames_ = iConfig.getUntrackedParameter<unsigned>("nHeaderFrames", 1);
117  nPayloadFrames_ = iConfig.getUntrackedParameter<unsigned>("nPayloadFrames", 39);
118  nClearFrames_ = iConfig.getUntrackedParameter<unsigned>("nClearFrames", 6);
119  nFrame_ = 0;
120 
121  nLink_ = nChan_ * nQuad_;
122  data_.resize(nLink_);
123  LogDebug("L1TDebug") << "Preparing for " << nLink_ << " links" << std::endl;
124 
125 }
#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 ( )

Definition at line 128 of file L1TStage2InputPatternWriter.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 143 of file L1TStage2InputPatternWriter.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 260 of file L1TStage2InputPatternWriter.cc.

261 {
262 
263 
264 }
void L1TStage2InputPatternWriter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 268 of file L1TStage2InputPatternWriter.cc.

References ecal_dqm_sourceclient-live_cfg::cerr, data_, dataValid_, TauDecayModes::dec, mergeVDriftHistosByStation::file, filename_, i, j, LogDebug, nChan_, nFrame_, and nQuad_.

269 {
270 
271  LogDebug("L1TDebug") << "Read " << nFrame_ << " frames" << std::endl;
272 
273  // write file
274  std::ofstream file( filename_ );
275 
276  file << "Board MP7_TEST" << std::endl;
277 
278  // quad/chan numbers
279  file << " Quad/Chan : ";
280  for ( unsigned i=0; i<nQuad_; ++i ) {
281  for ( unsigned j=0; j<nChan_; ++j ) {
282  file << " q" << i << "c" << j << " ";
283  }
284  }
285  file << std::endl;
286 
287  // link numbers
288  file << " Link : ";
289  for ( unsigned i=0; i<nQuad_; ++i ) {
290  for ( unsigned j=0; j<nChan_; ++j ) {
291  file << " " << (i*nChan_)+j << " ";
292  }
293  }
294 
295  file << std::endl;
296 
297  // then the data
298  for ( unsigned iFrame=0; iFrame<nFrame_; ++iFrame ) {
299  file << "Frame " << std::dec << std::setw(4) << std::setfill('0') << iFrame << " : ";
300  for ( unsigned iQuad=0; iQuad<nQuad_; ++iQuad ) {
301  for ( unsigned iChan=0; iChan<nChan_; ++iChan ) {
302  unsigned iLink = (iQuad*nChan_)+iChan;
303  if (iLink<data_.size() && iFrame<data_.at(iLink).size()) {
304  file << std::hex << ::std::setw(1) << dataValid_.at(iFrame) << "v" << std::hex << std::setw(8) << std::setfill('0') << data_.at(iLink).at(iFrame) << " ";
305  }
306  else {
307  std::cerr << "Out of range : " << iLink << ", " << iFrame << std::endl;
308  }
309  }
310  }
311  file << std::endl;
312  }
313 
314  file.close();
315 
316 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
std::vector< std::vector< int > > data_
void L1TStage2InputPatternWriter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 352 of file L1TStage2InputPatternWriter.cc.

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

352  {
353  //The following says we do not know what parameters are allowed so do no validation
354  // Please change this to state exactly what you do use, even if it is no parameters
356  desc.setUnknown();
357  descriptions.addDefault(desc);
358 }
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 71 of file L1TStage2InputPatternWriter.cc.

Referenced by endJob(), and L1TStage2InputPatternWriter().

edm::EDGetToken L1TStage2InputPatternWriter::m_towerToken
private

Definition at line 69 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 74 of file L1TStage2InputPatternWriter.cc.

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

unsigned L1TStage2InputPatternWriter::nClearFrames_
private

Definition at line 79 of file L1TStage2InputPatternWriter.cc.

Referenced by analyze(), and L1TStage2InputPatternWriter().

unsigned L1TStage2InputPatternWriter::nFrame_
private

Definition at line 80 of file L1TStage2InputPatternWriter.cc.

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

unsigned L1TStage2InputPatternWriter::nHeaderFrames_
private

Definition at line 77 of file L1TStage2InputPatternWriter.cc.

Referenced by analyze(), and L1TStage2InputPatternWriter().

unsigned L1TStage2InputPatternWriter::nLink_
private

Definition at line 76 of file L1TStage2InputPatternWriter.cc.

Referenced by L1TStage2InputPatternWriter().

unsigned L1TStage2InputPatternWriter::nPayloadFrames_
private

Definition at line 78 of file L1TStage2InputPatternWriter.cc.

Referenced by analyze(), and L1TStage2InputPatternWriter().

unsigned L1TStage2InputPatternWriter::nQuad_
private

Definition at line 75 of file L1TStage2InputPatternWriter.cc.

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