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
l1t::AMCDumpToRaw Class Reference
Inheritance diagram for l1t::AMCDumpToRaw:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 AMCDumpToRaw (const edm::ParameterSet &)
 
 ~AMCDumpToRaw ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- 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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void beginJob () override
 
virtual void endJob () override
 
void formatAMC (amc13::Packet &amc13, const std::vector< uint32_t > &load32)
 
void formatRaw (edm::Event &iEvent, amc13::Packet &amc13, FEDRawData &fed_data)
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
void readEvent (std::vector< uint32_t > &load32)
 

Private Attributes

int boardId_
 
int evType_
 
int fedId_
 
std::ifstream file_
 
std::string filename_
 
int fwVer_
 
int iAmc_
 
int slinkHeaderSize_
 
int slinkTrailerSize_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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

Definition at line 51 of file AMCDumpToRaw.cc.

Constructor & Destructor Documentation

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

Definition at line 101 of file AMCDumpToRaw.cc.

101  :
102  filename_(iConfig.getUntrackedParameter<std::string>("filename", "data.txt")),
103  fedId_(iConfig.getUntrackedParameter<int>("fedId", 1)),
104  iAmc_(iConfig.getUntrackedParameter<int>("iAmc", 1)),
105  boardId_(iConfig.getUntrackedParameter<int>("boardId", 1)),
106  evType_(iConfig.getUntrackedParameter<int>("eventType", 1)),
107  fwVer_(iConfig.getUntrackedParameter<int>("fwVersion", 1)),
108  slinkHeaderSize_(iConfig.getUntrackedParameter<int>("lenSlinkHeader", 8)),
109  slinkTrailerSize_(iConfig.getUntrackedParameter<int>("lenSlinkTrailer", 8))
110 {
111 
112  produces<FEDRawDataCollection>();
113 
114 }
T getUntrackedParameter(std::string const &, T const &) const
std::string filename_
Definition: AMCDumpToRaw.cc:77
AMCDumpToRaw::~AMCDumpToRaw ( )

Definition at line 117 of file AMCDumpToRaw.cc.

118 {
119 
120  // do anything here that needs to be done at desctruction time
121  // (e.g. close files, deallocate resources etc.)
122 
123 }

Member Function Documentation

void AMCDumpToRaw::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 233 of file AMCDumpToRaw.cc.

References file_, filename_, and recoMuon::in.

234 {
235 
236  // open VME file
237  file_.open(filename_.c_str(), std::ios::in);
238  if(!file_.good()) { edm::LogInfo("TextToDigi") << "Failed to open ASCII file " << filename_ << std::endl; }
239 
240 
241 }
std::string filename_
Definition: AMCDumpToRaw.cc:77
std::ifstream file_
Definition: AMCDumpToRaw.cc:76
void AMCDumpToRaw::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 246 of file AMCDumpToRaw.cc.

References file_.

247 {
248 
249  file_.close();
250 
251 }
std::ifstream file_
Definition: AMCDumpToRaw.cc:76
void AMCDumpToRaw::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 287 of file AMCDumpToRaw.cc.

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

287  {
288  //The following says we do not know what parameters are allowed so do no validation
289  // Please change this to state exactly what you do use, even if it is no parameters
291  desc.setUnknown();
292  descriptions.addDefault(desc);
293 }
void addDefault(ParameterSetDescription const &psetDescription)
void AMCDumpToRaw::formatAMC ( amc13::Packet amc13,
const std::vector< uint32_t > &  load32 
)
private

Definition at line 182 of file AMCDumpToRaw.cc.

References amc13::Packet::add(), boardId_, i, iAmc_, and LogDebug.

Referenced by produce().

182  {
183 
184  // TODO this is an empty word to be replaced with a proper MP7
185  // header containing at least the firmware version
186 
187  std::vector<uint64_t> load64;
188  for (unsigned int i = 0; i < load32.size(); i += 2) {
189  uint64_t word = load32[i];
190  if (i + 1 < load32.size())
191  word |= static_cast<uint64_t>(load32[i + 1]) << 32;
192  load64.push_back(word);
193  }
194 
195  LogDebug("L1T") << "Creating AMC packet " << iAmc_;
196 
197  amc13.add(iAmc_, boardId_, 0, 0, 0, load64);
198 
199 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
unsigned long long uint64_t
Definition: Time.h:15
void add(unsigned int amc_no, unsigned int board, unsigned int lv1id, unsigned int orbit, unsigned int bx, const std::vector< uint64_t > &load)
Definition: AMC13Spec.cc:61
void AMCDumpToRaw::formatRaw ( edm::Event iEvent,
amc13::Packet amc13,
FEDRawData fed_data 
)
private

Definition at line 204 of file AMCDumpToRaw.cc.

References edm::EventBase::bunchCrossing(), evf::compute_crc(), FEDRawData::data(), edm::EventID::event(), evType_, fedId_, edm::EventBase::id(), LogDebug, FEDRawData::resize(), FEDTrailer::set(), FEDHeader::set(), amc13::Packet::size(), findQualityFiles::size, slinkHeaderSize_, slinkTrailerSize_, and amc13::Packet::write().

Referenced by produce().

205 {
206 
207  unsigned int size = slinkHeaderSize_ + slinkTrailerSize_ + amc13.size() * 8;
208  fed_data.resize(size);
209  unsigned char * payload = fed_data.data();
210  unsigned char * payload_start = payload;
211 
212  auto bxId = iEvent.bunchCrossing();
213  auto evtId = iEvent.id().event();
214 
215  LogDebug("L1T") << "Creating FEDRawData ID " << fedId_ << ", size " << size;
216 
217  FEDHeader header(payload);
218  header.set(payload, evType_, evtId, bxId, fedId_);
219 
220  amc13.write(iEvent, payload, slinkHeaderSize_, size - slinkHeaderSize_ - slinkTrailerSize_);
221 
222  payload += slinkHeaderSize_;
223  payload += amc13.size() * 8;
224 
225  FEDTrailer trailer(payload);
226  trailer.set(payload, size / 8, evf::compute_crc(payload_start, size), 0, 0);
227 
228 }
#define LogDebug(id)
EventNumber_t event() const
Definition: EventID.h:41
unsigned int size() const
Definition: AMC13Spec.cc:200
int bunchCrossing() const
Definition: EventBase.h:66
bool write(const edm::Event &ev, unsigned char *ptr, unsigned int skip, unsigned int size) const
Definition: AMC13Spec.cc:218
void resize(size_t newsize)
Definition: FEDRawData.cc:32
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:67
edm::EventID id() const
Definition: EventBase.h:60
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
tuple size
Write out results.
void AMCDumpToRaw::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 132 of file AMCDumpToRaw.cc.

References fedId_, formatAMC(), formatRaw(), LogDebug, edm::Event::put(), and readEvent().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

133 {
134  using namespace edm;
135 
136  // create AMC 13 packet
137  amc13::Packet amc13;
138 
139  std::vector<uint32_t> load32;
140 
141  readEvent(load32);
142 
143  formatAMC(amc13, load32);
144 
145  LogDebug("L1T") << "AMC13 size " << amc13.size();
146 
147  // prepare the raw data collection
148  std::auto_ptr<FEDRawDataCollection> raw_coll(new FEDRawDataCollection());
149  FEDRawData& fed_data = raw_coll->FEDData(fedId_);
150 
151  formatRaw(iEvent, amc13, fed_data);
152 
153  LogDebug("L1T") << "Packing FED ID " << fedId_ << " size " << fed_data.size();
154 
155  // put the collection in the event
156  iEvent.put(raw_coll);
157 
158 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
void readEvent(std::vector< uint32_t > &load32)
void formatAMC(amc13::Packet &amc13, const std::vector< uint32_t > &load32)
void formatRaw(edm::Event &iEvent, amc13::Packet &amc13, FEDRawData &fed_data)
void AMCDumpToRaw::readEvent ( std::vector< uint32_t > &  load32)
private

Definition at line 162 of file AMCDumpToRaw.cc.

References ztail::d, file_, geometryCSVtoXML::line, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by produce().

162  {
163 
164  // read file
166 
167  // while not encountering dumb errors
168  while (getline(file_, line) && !line.empty() ) {
169 
170  std::istringstream iss(line);
171  unsigned long d;
172  iss >> std::hex >> d;
173 
174  load32.push_back( d ) ;
175 
176  }
177 
178 }
tuple d
Definition: ztail.py:151
std::ifstream file_
Definition: AMCDumpToRaw.cc:76

Member Data Documentation

int l1t::AMCDumpToRaw::boardId_
private

Definition at line 82 of file AMCDumpToRaw.cc.

Referenced by formatAMC().

int l1t::AMCDumpToRaw::evType_
private

Definition at line 83 of file AMCDumpToRaw.cc.

Referenced by formatRaw().

int l1t::AMCDumpToRaw::fedId_
private

Definition at line 80 of file AMCDumpToRaw.cc.

Referenced by formatRaw(), and produce().

std::ifstream l1t::AMCDumpToRaw::file_
private

Definition at line 76 of file AMCDumpToRaw.cc.

Referenced by beginJob(), endJob(), and readEvent().

std::string l1t::AMCDumpToRaw::filename_
private

Definition at line 77 of file AMCDumpToRaw.cc.

Referenced by beginJob().

int l1t::AMCDumpToRaw::fwVer_
private

Definition at line 84 of file AMCDumpToRaw.cc.

int l1t::AMCDumpToRaw::iAmc_
private

Definition at line 81 of file AMCDumpToRaw.cc.

Referenced by formatAMC().

int l1t::AMCDumpToRaw::slinkHeaderSize_
private

Definition at line 85 of file AMCDumpToRaw.cc.

Referenced by formatRaw().

int l1t::AMCDumpToRaw::slinkTrailerSize_
private

Definition at line 86 of file AMCDumpToRaw.cc.

Referenced by formatRaw().