Skip to content

Commit

Permalink
Remove duplicated code used to decode FED header and trailer informat…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
mommsen committed Dec 12, 2017
1 parent ef598b6 commit 1515c93
Show file tree
Hide file tree
Showing 59 changed files with 425 additions and 818 deletions.
4 changes: 2 additions & 2 deletions DQM/DTMonitorModule/src/DTDataIntegrityTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ void DTDataIntegrityTask::processFED(DTDDUData & data, const std::vector<DTROS25
//If L1A_ID error identify which ROS has wrong L1A
for (vector<DTROS25Data>::const_iterator rosControlData = rosData.begin();
rosControlData != rosData.end(); rosControlData++) { // loop over the ROS data
int ROSHeader_TTCCount = ((*rosControlData).getROSHeader().TTCEventCounter() + 1) % 0x1000000; // fix comparison in case of last counting bin in ROS /first one in DDU
unsigned int ROSHeader_TTCCount = ((*rosControlData).getROSHeader().TTCEventCounter() + 1) % 0x1000000; // fix comparison in case of last counting bin in ROS /first one in DDU
if( ROSHeader_TTCCount != header.lvl1ID() ) {
int ros = (*rosControlData).getROSID();
if(mode <= 2) hROSStatus->Fill(10,ros-1);
Expand All @@ -994,7 +994,7 @@ void DTDataIntegrityTask::processFED(DTDDUData & data, const std::vector<DTROS25
}

//1D HISTOS: EVENT LENGHT from trailer
int fedEvtLenght = trailer.lenght()*8;
int fedEvtLenght = trailer.eventSize()*8;
// if(fedEvtLenght > 16000) fedEvtLenght = 16000; // overflow bin
dduHistos["EventLenght"][code.getDDUID()]->Fill(fedEvtLenght);

Expand Down
1 change: 0 additions & 1 deletion DQM/EcalPreshowerMonitorModule/src/ESFEDIntegrityTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "DataFormats/FEDRawData/interface/FEDHeader.h"
#include "DataFormats/FEDRawData/interface/FEDTrailer.h"
#include "DataFormats/FEDRawData/interface/FEDNumbering.h"
#include "DataFormats/FEDRawData/src/fed_header.h"
#include "DataFormats/EcalRawData/interface/ESDCCHeaderBlock.h"
#include "DataFormats/EcalRawData/interface/ESKCHIPBlock.h"

Expand Down
1 change: 0 additions & 1 deletion DQM/EcalPreshowerMonitorModule/src/ESRawDataTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "DataFormats/FEDRawData/interface/FEDHeader.h"
#include "DataFormats/FEDRawData/interface/FEDTrailer.h"
#include "DataFormats/FEDRawData/interface/FEDNumbering.h"
#include "DataFormats/FEDRawData/src/fed_header.h"

#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/EcalDetId/interface/ESDetId.h"
Expand Down
3 changes: 1 addition & 2 deletions DQM/L1TMonitor/src/L1TMP7ZeroSupp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void L1TMP7ZeroSupp::analyze(const edm::Event& e, const edm::EventSetup& c) {
FEDTrailer trailer(data + (l1tRcd.size() - slinkTrailerSize_));

if (trailer.check()) {
edm::LogInfo("L1TDQM") << "Found SLink trailer:" << " Length " << trailer.lenght() << " CRC " << trailer.crc() << " Status " << trailer.evtStatus() << " Throttling bits " << trailer.ttsBits();
edm::LogInfo("L1TDQM") << "Found SLink trailer:" << " Length " << trailer.eventSize() << " CRC " << trailer.crc() << " Status " << trailer.evtStatus() << " Throttling bits " << trailer.ttsBits();
} else {
edm::LogWarning("L1TDQM") << "Did not find a SLink trailer!";
}
Expand Down Expand Up @@ -472,4 +472,3 @@ void L1TMP7ZeroSupp::analyze(const edm::Event& e, const edm::EventSetup& c) {
}
}
}

8 changes: 2 additions & 6 deletions DataFormats/DTDigi/interface/DTControlData.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "DataFormats/DTDigi/interface/DTDDUWords.h"
#include "DataFormats/FEDRawData/interface/FEDHeader.h"
#include "DataFormats/FEDRawData/interface/FEDTrailer.h"
#include "DataFormats/FEDRawData/src/fed_trailer.h"

#include <vector>

Expand Down Expand Up @@ -133,11 +132,8 @@ class DTDDUData {
theDDUStatusWord = word;
}
inline void checkCRCBit(const unsigned char* trailer) {
const fedt_struct* theTrailer(reinterpret_cast<const fedt_t*>(trailer));
if(((theTrailer->conscheck & 0x00000004) >> 2) == 1) {
crcErrorBitSet = true;
}
crcErrorBitSet = false;
const FEDTrailer fedTrailer(trailer);
crcErrorBitSet = fedTrailer.crcModified();
}

/// Getters
Expand Down
44 changes: 23 additions & 21 deletions DataFormats/FEDRawData/interface/FEDHeader.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#ifndef FEDRawData_FEDHeader_h
#define FEDRawData_FEDHeader_h
#ifndef DataFormats_FEDRawData_FEDHeader_h
#define DataFormats_FEDRawData_FEDHeader_h

/** \class FEDHeader
* TEMPORARY helper class to interpret/create FED header words.
* FIXME: will be replaced by the xdaq implementation.
* Helper class to interpret/create FED header words.
*
* \author N. Amapane - CERN
* \author N. Amapane - CERN, R. Mommsen - FNAL
*/

#include <cstdint>

struct fedh_struct;

class FEDHeader {
Expand All @@ -19,39 +20,40 @@ class FEDHeader {
~FEDHeader();

/// Event Trigger type identifier
int triggerType();
uint8_t triggerType() const;

/// Level-1 event number generated by the TTC system
int lvl1ID();
uint32_t lvl1ID() const;

/// The bunch crossing number
int bxID();
uint16_t bxID() const;

/// Identifier of the FED
int sourceID();
uint16_t sourceID() const;

/// Version identifier of the FED data format
int version();
uint8_t version() const;

/// 0 -> the current header word is the last one.
/// 1-> other header words can follow
/// 1-> other header words can follow
/// (always 1 for ECAL)
bool moreHeaders();
bool moreHeaders() const;

/// Check that the header is OK
bool check();
bool check() const;

/// Set all fields in the header
static void set(unsigned char* header,
int evt_ty,
int lvl1_ID,
int bx_ID,
int source_ID,
int version=0,
bool H=false);
uint8_t triggerType,
uint32_t lvl1ID,
uint16_t bxID,
uint16_t sourceID,
uint8_t version=0,
bool moreHeaders=false);

static const uint32_t length;

private:
const fedh_struct* theHeader;
};
#endif

#endif // DataFormats_FEDRawData_FEDHeader_h
61 changes: 37 additions & 24 deletions DataFormats/FEDRawData/interface/FEDTrailer.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#ifndef FEDRawData_FEDTrailer_h
#define FEDRawData_FEDTrailer_h
#ifndef DataFormats_FEDRawData_FEDTrailer_h
#define DataFormats_FEDRawData_FEDTrailer_h

/** \class FEDTrailer
* TEMPORARY helper class to interpret/create FED trailer words.
* FIXME: will be replaced by the xdaq implementation
* Helper class to interpret/create FED trailer words.
*
* \author N. Amapane - CERN
* \author N. Amapane - CERN, R. Mommsen - FNAL
*/

#include <cstdint>

struct fedt_struct;

class FEDTrailer {
Expand All @@ -17,38 +18,50 @@ class FEDTrailer {

/// Destructor
virtual ~FEDTrailer();

/// The length of the event fragment counted in 64-bit words including header and trailer
int lenght();
uint32_t eventSize() const;

/// Cyclic Redundancy Code of the event fragment including header and trailer
int crc();
uint16_t crc() const;

/// Event fragment status information
int evtStatus();
uint8_t evtStatus() const;

/// Current value of the Trigger Throttling System bits
uint8_t ttsBits() const;

/// Current value of the Trigger Throttling System bitsAQ).
int ttsBits();

/// 0 -> the current trailer word is the last one.
/// 1-> other trailer words can follow
/// (always 0 for ECAL)
bool moreTrailers();
/// 1 -> other trailer words can follow
bool moreTrailers() const;

/// True if the CRC value has been modified by the S-link sender card
bool crcModified() const;

/// True if the FRL has detected a transmission error over the s-link cable
bool slinkError() const;

// Check that the trailer is OK
bool check();
/// True if the FED_ID given by the FED is not the one expected by the FRL
bool wrongFedId() const;

/// Check that the trailer is OK
bool check() const;

/// Return the word containing the consistency checks
uint32_t conscheck() const;

/// Set all fields in the trailer
static void set(unsigned char* trailer,
int evt_lgth,
int crc,
int evt_stat,
int tts,
bool T=false);
uint32_t lenght,
uint16_t crc,
uint8_t evt_stat,
uint8_t tts,
bool moreTrailers=false);

static const uint32_t length;

private:
const fedt_struct* theTrailer;

};
#endif

#endif // DataFormats_FEDRawData_FEDTrailer_h
83 changes: 45 additions & 38 deletions DataFormats/FEDRawData/src/FEDHeader.cc
Original file line number Diff line number Diff line change
@@ -1,70 +1,77 @@
/** \file
*
* \author N. Amapane - CERN
* \author N. Amapane - CERN, R. Mommsen - FNAL
*/

#include <DataFormats/FEDRawData/interface/FEDHeader.h>
#include "fed_header.h"
#include "DataFormats/FEDRawData/interface/FEDHeader.h"
#include "DataFormats/FEDRawData/src/fed_header.h"

FEDHeader::FEDHeader(const unsigned char* header) :

FEDHeader::FEDHeader(const unsigned char* header) :
theHeader(reinterpret_cast<const fedh_t*>(header)) {}


FEDHeader::~FEDHeader(){}
FEDHeader::~FEDHeader() {}


int FEDHeader::triggerType(){
return ((theHeader->eventid & FED_EVTY_MASK) >> FED_EVTY_SHIFT);
uint8_t FEDHeader::triggerType() const {
return FED_EVTY_EXTRACT(theHeader->eventid);
}

int FEDHeader::lvl1ID(){
return (theHeader->eventid & FED_LVL1_MASK);

uint32_t FEDHeader::lvl1ID() const {
return FED_LVL1_EXTRACT(theHeader->eventid);
}

int FEDHeader::bxID(){
return ((theHeader->sourceid & FED_BXID_MASK) >> FED_BXID_SHIFT);

uint16_t FEDHeader::bxID() const {
return FED_BXID_EXTRACT(theHeader->sourceid);
}

int FEDHeader::sourceID(){
return ((theHeader->sourceid & FED_SOID_MASK) >> FED_SOID_SHIFT);

uint16_t FEDHeader::sourceID() const {
return FED_SOID_EXTRACT(theHeader->sourceid);
}

int FEDHeader::version(){
return ((theHeader->sourceid & FED_VERSION_MASK) >> FED_VERSION_SHIFT);

uint8_t FEDHeader::version() const {
return FED_VERSION_EXTRACT(theHeader->sourceid);
}

bool FEDHeader::moreHeaders(){
return ((theHeader->sourceid & FED_MORE_HEADERS)!=0);

bool FEDHeader::moreHeaders() const {
return ( FED_MORE_HEADERS_EXTRACT(theHeader->sourceid) != 0 );
}


void FEDHeader::set(unsigned char* header,
int evt_ty,
int lvl1_ID,
int bx_ID,
int source_ID,
int version,
bool H){
uint8_t triggerType,
uint32_t lvl1ID,
uint16_t bxID,
uint16_t sourceID,
uint8_t version,
bool moreHeaders) {

// FIXME: should check that input ranges are OK!!!
fedh_t* h = reinterpret_cast<fedh_t*>(header);
h->eventid =
( FED_HCTRLID & FED_HCTRLID_MASK) |
( ( evt_ty << FED_EVTY_SHIFT) & FED_EVTY_MASK ) |
( ( lvl1_ID << FED_LVL1_SHIFT) & FED_LVL1_MASK );
h->eventid =
(FED_SLINK_START_MARKER << FED_HCTRLID_SHIFT) |
( (triggerType << FED_EVTY_SHIFT ) & FED_EVTY_MASK ) |
( (lvl1ID << FED_LVL1_SHIFT ) & FED_LVL1_MASK );

h->sourceid =
( ( bx_ID << FED_BXID_SHIFT) & FED_BXID_MASK ) |
( ( source_ID << FED_SOID_SHIFT) & FED_SOID_MASK ) |
( ( version << FED_VERSION_SHIFT) & FED_VERSION_MASK );
if (H) h->sourceid |= FED_MORE_HEADERS;

( (bxID << FED_BXID_SHIFT ) & FED_BXID_MASK ) |
( (sourceID << FED_SOID_SHIFT ) & FED_SOID_MASK ) |
( (version << FED_VERSION_SHIFT) & FED_VERSION_MASK );

if (moreHeaders)
h->sourceid |= (FED_MORE_HEADERS_WIDTH << FED_MORE_HEADERS_SHIFT);
}

bool FEDHeader::check() {
// ...may report with finer detail
bool result = true;
result &= ((theHeader->eventid & FED_HCTRLID_MASK) == FED_HCTRLID);

return result;
bool FEDHeader::check() const {
return ( FED_HCTRLID_EXTRACT(theHeader->eventid) == FED_SLINK_START_MARKER );
}


const uint32_t FEDHeader::length = sizeof(fedh_t);

0 comments on commit 1515c93

Please sign in to comment.