#include <DTSpyReader.h>
Public Member Functions | |
uint64_t | dmaUnpack (const uint32_t *dmaData, bool &isData) |
pre-unpack the data if read via DMA | |
DTSpyReader (const edm::ParameterSet &pset) | |
Constructor. | |
virtual int | fillRawData (edm::EventID &eID, edm::Timestamp &tstamp, FEDRawDataCollection *&data) |
Generate and fill FED raw data for a full event. | |
bool | isHeader (uint64_t word, bool dataTag) |
check for a 64 bits word to be a DDU header | |
bool | isTrailer (uint64_t word, bool dataTag, int wordCount) |
check for a 64 bits word to be a DDU trailer | |
void | swap (uint64_t &word) |
swapping the lsBits with the msBits | |
virtual | ~DTSpyReader () |
Destructor. | |
Private Attributes | |
int | dduID |
bool | debug |
edm::EventNumber_t | eventNumber |
DTSpy * | mySpy |
edm::RunNumber_t | runNumber |
Static Private Attributes | |
static const int | dduWordLength = 8 |
Read DT ROS8 raw data files
Definition at line 23 of file DTSpyReader.h.
DTSpyReader::DTSpyReader | ( | const edm::ParameterSet & | pset | ) |
Constructor.
connecting to XDAQ note ("0.0.0.0" = localhost)
Definition at line 33 of file DTSpyReader.cc.
References DTCtcp::Connect(), gather_cfg::cout, dduID, debug, edm::ParameterSet::getUntrackedParameter(), and mySpy.
: runNumber(1), eventNumber(0) { // instatiating Sandro's spy (My name is Bond, Sandro Bond) mySpy = new DTSpy(); string connectionParameters = pset.getUntrackedParameter<string>("connectionParameters"); mySpy->Connect(connectionParameters.c_str(),10000); cout<<endl; cout<<"DT Local DAQ online spy. Connected to IP "<<connectionParameters.c_str() <<". Waiting for the data to be flushed"<<endl; cout<<endl; debug = pset.getUntrackedParameter<bool>("debug",false); dduID = pset.getUntrackedParameter<int32_t>("dduID",770); // NOT needed }
DTSpyReader::~DTSpyReader | ( | ) | [virtual] |
uint64_t DTSpyReader::dmaUnpack | ( | const uint32_t * | dmaData, |
bool & | isData | ||
) |
pre-unpack the data if read via DMA
Definition at line 141 of file DTSpyReader.cc.
Referenced by fillRawData().
{ uint32_t unpackedData[2] = {0, 0}; // adjust 4 32-bits words into 2 32-bits words unpackedData[0] |= dmaData[3] & 0x3ffff; unpackedData[0] |= (dmaData[2] << 18 ) & 0xfffc0000; unpackedData[1] |= (dmaData[2] >> 14 ) & 0x0f; unpackedData[1] |= (dmaData[1] << 4 ) & 0x3ffff0; unpackedData[1] |= (dmaData[0] << 22 ) & 0xffc00000; isData = ( dmaData[0] >> 10 ) & 0x01; //printf ("Lower part: %x \n", unpackedData[0]); //printf ("Upper part: %x \n", unpackedData[1]); // push_back to a 64 word uint64_t dduWord = ( uint64_t(unpackedData[1]) << 32 ) | unpackedData[0]; return dduWord; }
int DTSpyReader::fillRawData | ( | edm::EventID & | eID, |
edm::Timestamp & | tstamp, | ||
FEDRawDataCollection *& | data | ||
) | [virtual] |
Generate and fill FED raw data for a full event.
Implements DaqBaseReader.
Definition at line 58 of file DTSpyReader.cc.
References filterCSVwithJSON::copy, gather_cfg::cout, FEDRawData::data(), dduID, dduWordLength, debug, dmaUnpack(), eventNumber, FEDRawDataCollection::FEDData(), DTSpy::getEventPointer(), DTSpy::getNextBuffer(), DTSpy::getRunNo(), isHeader(), isTrailer(), mySpy, FEDRawData::resize(), runNumber, DTSpy::setlastPointer(), and swap().
{ // ask for a new buffer mySpy->getNextBuffer(); // get the pointer to the beginning of the buffer const char * rawDTData = mySpy->getEventPointer(); const uint32_t * rawDTData32 = reinterpret_cast<const uint32_t*>(rawDTData); // instantiate the FEDRawDataCollection data = new FEDRawDataCollection(); vector<uint64_t> eventData; uint64_t word = 0; int wordCount = 0; int wordCountCheck = 0; bool headerTag = false; bool dataTag = true; // Advance at long-word steps until the trailer is reached. // Skipped whatever else is in the buffer (e.g. another event..) while ( !isTrailer(word, dataTag, wordCount) ) { // dma gets 4 32-bits words and create a 64 bit one word = dmaUnpack(rawDTData32, dataTag); // look for the DDU header if (isHeader(word,dataTag)) headerTag=true; // check whether the first word is a DDU header if ( wordCountCheck > 0 && !headerTag && debug) cout<<"[DTSpyReader]: WARNING: header still not found!!"<<endl; // from now on fill the eventData with the ROS data if (headerTag) { // swapping only the 32 bits words if (dataTag) swap(word); // WARNING also the ddu status words have been swapped! // Control the correct interpretation in DDUUnpacker eventData.push_back(word); wordCount++; } // advancing by 4 32-bits words rawDTData32 += 4; // counting the total number of group of 128 bits (=4*32) in the buffer wordCountCheck++; } // Setting the Event ID runNumber = mySpy->getRunNo(); eID = EventID( runNumber, 1U, eventNumber); // eventDataSize = (Number Of Words)* (Word Size) int eventDataSize = eventData.size()*dduWordLength; if (debug) cout<<" DDU ID = "<<dduID<<endl; FEDRawData& fedRawData = data->FEDData( dduID ); fedRawData.resize(eventDataSize); copy(reinterpret_cast<unsigned char*>(&eventData[0]), reinterpret_cast<unsigned char*>(&eventData[0]) + eventDataSize, fedRawData.data()); mySpy->setlastPointer( (char*) rawDTData32 ); return true; }
bool DTSpyReader::isHeader | ( | uint64_t | word, |
bool | dataTag | ||
) |
check for a 64 bits word to be a DDU header
Definition at line 162 of file DTSpyReader.cc.
References FEDHeader::check(), dduID, eventNumber, and FEDHeader::sourceID().
Referenced by fillRawData().
{ bool it_is = false; FEDHeader candidate(reinterpret_cast<const unsigned char*>(&word)); if ( candidate.check() ) { // if ( candidate.check() && !dataTag) { it_is = true; dduID = candidate.sourceID(); eventNumber++; } return it_is; }
bool DTSpyReader::isTrailer | ( | uint64_t | word, |
bool | dataTag, | ||
int | wordCount | ||
) |
check for a 64 bits word to be a DDU trailer
Definition at line 176 of file DTSpyReader.cc.
References FEDTrailer::check(), and FEDTrailer::lenght().
Referenced by fillRawData().
{ bool it_is = false; FEDTrailer candidate(reinterpret_cast<const unsigned char*>(&word)); if ( candidate.check() ) { // if ( candidate.check() && !dataTag) { if ( wordCount == candidate.lenght()) it_is = true; } return it_is; }
void DTSpyReader::swap | ( | uint64_t & | word | ) |
swapping the lsBits with the msBits
Definition at line 131 of file DTSpyReader.cc.
References twoNibble64::lsBits, and twoNibble64::msBits.
Referenced by fillRawData().
{ twoNibble64* newWorld = reinterpret_cast<twoNibble64*>(&word); uint32_t msBits_tmp = newWorld->msBits; newWorld->msBits = newWorld->lsBits; newWorld->lsBits = msBits_tmp; }
int DTSpyReader::dduID [private] |
Definition at line 59 of file DTSpyReader.h.
Referenced by DTSpyReader(), fillRawData(), and isHeader().
const int DTSpyReader::dduWordLength = 8 [static, private] |
Definition at line 61 of file DTSpyReader.h.
Referenced by fillRawData().
bool DTSpyReader::debug [private] |
Definition at line 58 of file DTSpyReader.h.
Referenced by DTSpyReader(), and fillRawData().
edm::EventNumber_t DTSpyReader::eventNumber [private] |
Definition at line 56 of file DTSpyReader.h.
Referenced by fillRawData(), and isHeader().
DTSpy* DTSpyReader::mySpy [private] |
Definition at line 53 of file DTSpyReader.h.
Referenced by DTSpyReader(), fillRawData(), and ~DTSpyReader().
edm::RunNumber_t DTSpyReader::runNumber [private] |
Definition at line 55 of file DTSpyReader.h.
Referenced by fillRawData().