Commit ce3a9bd2 authored by CMS Tracker Ph2 ACF's avatar CMS Tracker Ph2 ACF
Browse files

Merge branch 'Dev' into 'Dev'

Environment Variables expansion in HWDescription file

This was already pushed in the commit of 7-dec-2015 but was partially removed in the next one

See merge request !19
parents 4ddac014 007aa80b
......@@ -14,8 +14,6 @@
#include "BeBoardFWInterface.h"
#include "FpgaConfig.h"
#define DEV_FLAG 0
namespace Ph2_HwInterface
{
......
......@@ -209,8 +209,10 @@ namespace Ph2_HwInterface
// set the vector<uint32_t> as event buffer and let him know how many packets it contains
fData->Set( pBoard, cData , cNPackets, true );
if ( fSaveToFile )
if ( fSaveToFile ){
fFileHandler->set( cData );
fFileHandler->writeFile();
}
return cNPackets;
}
......@@ -294,7 +296,7 @@ namespace Ph2_HwInterface
cBlockSize = computeBlockSize( pBoard );
while ( runningAcquisition && ( nbMaxAcq == 0 || numAcq < nbMaxAcq ) )
{
ReadData( nullptr, numAcq, true );
ReadData( pBoard, numAcq, true );
for ( const Ph2_HwInterface::Event* cEvent = GetNextEvent( pBoard ); cEvent; cEvent = GetNextEvent( pBoard ) )
visitor->visit( *cEvent );
......
......@@ -87,7 +87,7 @@ bool RegManager::WriteReg( const std::string& pRegNode, const uint32_t& pVal )
if ( comp == pVal )
{
std::cout << "Values written correctly !" << comp << "=" << pVal << std::endl;
std::cout << "Values written correctly !" << pRegNode << "=" << pVal << std::endl;
return true;
}
......@@ -125,7 +125,7 @@ bool RegManager::WriteStackReg( const std::vector< std::pair<std::string, uint32
comp = static_cast<uint32_t>( reply );
if ( comp == v.second )
std::cout << "Values written correctly !" << comp << "=" << v.second << std::endl;
std::cout << "Values written correctly !" << v.first << "=" << v.second << std::endl;
}
if ( cNbErrors == 0 )
......@@ -222,7 +222,7 @@ uhal::ValWord<uint32_t> RegManager::ReadReg( const std::string& pRegNode )
if ( DEV_FLAG )
{
uint32_t read = ( uint32_t ) cValRead;
std::cout << "\nValue in register ID " << pRegNode << " : " << read << std::endl;
std::cout << "Value in register ID " << pRegNode << " : " << read << std::endl;
}
return cValRead;
......@@ -238,7 +238,7 @@ uhal::ValWord<uint32_t> RegManager::ReadAtAddress( uint32_t uAddr, uint32_t uMas
if ( DEV_FLAG )
{
uint32_t read = ( uint32_t ) cValRead;
std::cout << "\nValue at address " << std::hex << uAddr << std::dec << " : " << read << std::endl;
std::cout << "Value at address " << std::hex << uAddr << std::dec << " : " << read << std::endl;
}
return cValRead;
......@@ -254,7 +254,7 @@ uhal::ValVector<uint32_t> RegManager::ReadBlockReg( const std::string& pRegNode,
if ( DEV_FLAG )
{
std::cout << "\nValues in register block " << pRegNode << " : " << std::endl;
std::cout << "Values in register block " << pRegNode << " : " << std::endl;
//Use size_t and not an iterator as op[] only works with size_t type
for ( std::size_t i = 0; i != cBlockRead.size(); i++ )
......
all: Utils HWDescription HWInterface System tools RootWeb src miniDAQ
all: Utils HWDescription HWInterface System tools RootWeb Tracker src miniDAQ
libs: Utils HWDescription HWInterface System srcnoroot
libs: Utils HWDescription HWInterface System Tracker srcnoroot
#gui: Utils HWDescription HWInterface System tools src miniDAQ GUI
simple: Utils HWDescription HWInterface System tools RootWeb src miniDAQ
simple: Utils HWDescription HWInterface System tools RootWeb Tracker src miniDAQ
HWDescription::
$(MAKE) -C $@
......@@ -16,6 +16,8 @@ System::
$(MAKE) -C $@
tools::
$(MAKE) -C $@
Tracker::
$(MAKE) -C $@
srcnoroot::
$(MAKE) -C src noroot
src::
......@@ -40,6 +42,7 @@ clean:
(cd tools; make clean)
(cd RootWeb; make clean)
(cd miniDAQ; make clean)
(cd Tracker; make clean)
#(cd GUI; make clean)
#(cd GUI; make clean; cd GUI/Macros; make clean)
(cd doc; make clean)
......
......@@ -24,6 +24,7 @@ SystemController::SystemController()
SystemController::~SystemController()
{
delete fFileHandler;
for ( auto& el : fShelveVector )
delete el;
fShelveVector.clear();
......@@ -159,7 +160,8 @@ void SystemController::parseHWxml( const std::string& pFilename, std::ostream& o
os << BOLDCYAN << "|" << "----" << cBeBoardNode.name() << " " << cBeBoardNode.first_attribute().name() << " :" << cBeBoardNode.attribute( "Id" ).value() << RESET << std:: endl;
pugi::xml_node cBeBoardConnectionNode = cBeBoardNode.child("connection");
std::cout << BOLDBLUE << "|" << "----" << "Board Id: " << BOLDYELLOW << cBeBoardConnectionNode.attribute("id").value() << BOLDBLUE << " URI: " << BOLDYELLOW << cBeBoardConnectionNode.attribute("uri").value() << BOLDBLUE << " Address Table: " << BOLDYELLOW << cBeBoardConnectionNode.attribute("address_table").value() << RESET << std::endl;
std::string strAddrTable = expandEnvironmentVariables(cBeBoardConnectionNode.attribute("address_table").value());
std::cout << BOLDBLUE << "|" << "----" << "Board Id: " << BOLDYELLOW << cBeBoardConnectionNode.attribute("id").value() << BOLDBLUE << " URI: " << BOLDYELLOW << cBeBoardConnectionNode.attribute("uri").value() << BOLDBLUE << " Address Table: " << BOLDYELLOW << strAddrTable << RESET << std::endl;
cBeId = cBeBoardNode.attribute( "Id" ).as_int();
BeBoard* cBeBoard = new BeBoard( cShelveId, cBeId );
......@@ -182,10 +184,10 @@ void SystemController::parseHWxml( const std::string& pFilename, std::ostream& o
if ( !std::string( cBeBoardNode.attribute( "boardType" ).value() ).compare( std::string( "GLIB" ) ) )
fBeBoardFWMap[cBeBoard->getBeBoardIdentifier()] = new GlibFWInterface( cBeBoardConnectionNode.attribute( "id" ).value(), cBeBoardConnectionNode.attribute( "uri" ).value(), cBeBoardConnectionNode.attribute("address_table").value(), fFileHandler );
fBeBoardFWMap[cBeBoard->getBeBoardIdentifier()] = new GlibFWInterface( cBeBoardConnectionNode.attribute( "id" ).value(), cBeBoardConnectionNode.attribute( "uri" ).value(), strAddrTable.c_str(), fFileHandler );
else if ( !std::string( cBeBoardNode.attribute( "boardType" ).value() ).compare( std::string( "CTA" ) ) )
fBeBoardFWMap[cBeBoard->getBeBoardIdentifier()] = new CtaFWInterface( cBeBoardConnectionNode.attribute( "id" ).value(), cBeBoardConnectionNode.attribute( "uri" ).value(), cBeBoardConnectionNode.attribute("address_table").value(), fFileHandler );
fBeBoardFWMap[cBeBoard->getBeBoardIdentifier()] = new CtaFWInterface( cBeBoardConnectionNode.attribute( "id" ).value(), cBeBoardConnectionNode.attribute( "uri" ).value(), strAddrTable.c_str(), fFileHandler );
/*else
cBeBoardFWInterface = new OtherFWInterface();*/
......@@ -206,7 +208,7 @@ void SystemController::parseHWxml( const std::string& pFilename, std::ostream& o
fShelveVector[cNShelve]->getBoard( cBeId )->addModule( cModule );
pugi::xml_node cCbcPathPrefixNode = cModuleNode.child( "CBC_Files" );
std::string cFilePrefix = std::string( cCbcPathPrefixNode.attribute( "path" ).value() );
std::string cFilePrefix = expandEnvironmentVariables(std::string( cCbcPathPrefixNode.attribute( "path" ).value() ));
if ( !cFilePrefix.empty() ) os << GREEN << "|" << " " << "|" << " " << "|" << "----" << "CBC Files Path : " << cFilePrefix << RESET << std::endl;
// Iterate the CBC node
......@@ -217,8 +219,8 @@ void SystemController::parseHWxml( const std::string& pFilename, std::ostream& o
std::string cFileName;
if ( !cFilePrefix.empty() )
cFileName = cFilePrefix + cCbcNode.attribute( "configfile" ).value();
else cFileName = cCbcNode.attribute( "configfile" ).value();
cFileName = cFilePrefix + "/" + expandEnvironmentVariables(cCbcNode.attribute( "configfile" ).value());
else cFileName = expandEnvironmentVariables(cCbcNode.attribute( "configfile" ).value());
Cbc* cCbc = new Cbc( cShelveId, cBeId, cModuleNode.attribute( "FMCId" ).as_int(), cModuleNode.attribute( "FeId" ).as_int(), cCbcNode.attribute( "Id" ).as_int(), cFileName );
......@@ -452,4 +454,22 @@ void SystemController::parseSettingsjson( const std::string& pFilename, std::ost
os << RED << "Setting" << RESET << " --" << BOLDCYAN << cSetting.first << RESET << ":" << BOLDYELLOW << static_cast<int>( cSetting.second.get<double>() ) << RESET << std:: endl;
}
}
std::string SystemController::expandEnvironmentVariables( std::string s ) {
if( s.find( "${" ) == std::string::npos ) return s;
std::string pre = s.substr( 0, s.find( "${" ) );
std::string post = s.substr( s.find( "${" ) + 2 );
if( post.find( '}' ) == std::string::npos ) return s;
std::string variable = post.substr( 0, post.find( '}' ) );
std::string value = "";
post = post.substr( post.find( '}' ) + 1 );
if( getenv( variable.c_str() ) != NULL ) value = std::string( getenv( variable.c_str() ) );
return expandEnvironmentVariables( pre + value + post );
}
}
Objs = TrackerEvent.o ParamSet.o
CC = gcc
CXX = g++
CCFlags = -g -O1 -w -Wall -pedantic -fPIC -Wcpp
#DevFlags = -D__CBCDAQ_DEV__
DevFlags =
IncludeDirs = /opt/cactus/include ../ ../lib
IncludePaths = $(IncludeDirs:%=-I%)
LibraryDirs = /opt/cactus/include ../ ../lib
LibraryPaths = $(LibraryDirs:%=-L%)
ExternalObjects = $(LibraryPaths) -lPh2_Interface -lPh2_Description -lPh2_Utils
%.o: %.cc %.h
$(CXX) -std=c++11 $(DevFlags) $(CCFlags) $(UserCCFlags) $(CCDefines) $(IncludePaths) -c -o $@ $<
all: $(Objs)
$(CC) -std=c++11 -shared -o libPh2_Tracker.so $(Objs)
mv libPh2_Tracker.so ../lib
clean:
rm -f *.o
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include "ParamSet.h"
using namespace std;
ParamSet::ParamSet(const std::string& strFile){
loadParamValuePairsFromFile(strFile);
}
uint32_t ParamSet::setValue(const std::string& strName, uint32_t uVal){
mapIntValues[strName]=uVal;
return uVal;
}
void ParamSet::setValue(const std::string& strName, const std::string& strVal){
mapStrValues[strName]=strVal;
}
uint32_t ParamSet::getValue(const std::string& strName){
return mapIntValues[strName];
}
uint32_t ParamSet::getValueDef(const std::string& strName, uint32_t uDefault){
if (containsIntValue(strName))
return mapIntValues[strName];
else
return uDefault;
}
std::string ParamSet::getStrValue(const std::string& strName){
return mapStrValues[strName];
}
bool ParamSet::containsIntValue(const std::string& strName){
return mapIntValues.find(strName)!=mapIntValues.end();
}
bool ParamSet::containsStrValue(const std::string& strName){
return mapStrValues.find(strName)!=mapStrValues.end();
}
void ParamSet::removeIntValue(const std::string& strName){
mapIntValues.erase(strName);
}
/// Return parameter names and their value in a string with format <parameter 1>=<value 1>\n<parameter 2>=<value 2>\n...
std::string ParamSet::nameAndValuePairs(){
std::ostringstream ostream;
for (map<string, uint32_t>::const_iterator it=mapIntValues.begin(); it!=mapIntValues.end(); it++)
ostream<<it->first<<"="<<it->second<<endl;
for (map<string, string>::const_iterator it=mapStrValues.begin(); it!=mapStrValues.end(); it++)
ostream<<it->first<<"='"<<it->second<<"'"<<endl;
return ostream.str();
}
/// Read parameter and value pairs from a text file
bool ParamSet::loadParamValuePairsFromFile(const std::string& strFile){
ifstream fValues(strFile.c_str());
string strLig;
if (fValues.good()){
mapIntValues.clear();
mapStrValues.clear();
while (fValues.good()){
getline(fValues, strLig);
size_t iEqual=strLig.find('=');
if (iEqual!=string::npos && iEqual>0 && strLig.at(0)!='#'){
if (strLig[iEqual+1]=='\'')//string value
setValue(strLig.substr(0,iEqual), strLig.substr(iEqual+2, strLig.length()-iEqual-3).c_str());
else //Numeric value
setValue(strLig.substr(0,iEqual), (uint32_t)atol(strLig.substr(iEqual+1).c_str()));
}
}
fValues.close();
return true;
} else
return false;
}
///Delete all integer and string values
void ParamSet::clearValues(){
mapIntValues.clear();
mapStrValues.clear();
}
#ifndef __PARAMSET_H__
#define __PARAMSET_H__
#include <map>
#include <string>
/** Set of parameters whose values will be read from and written into a text file with format key=value
*/
class ParamSet{
public:
ParamSet(const std::string& strFile);
/// get a parameter value
uint32_t getValue(const std::string& strName);
/// Get a parameter integer value or the default value if there is no such parameter name
uint32_t getValueDef(const std::string& strName, uint32_t uDefault);
/// Get a parameter string value
std::string getStrValue(const std::string& strName);
/// Tell if an integer value exists
bool containsIntValue(const std::string& strName);
/// Tell if a string value exists
bool containsStrValue(const std::string& strName);
/// Remove an integer value
void removeIntValue(const std::string& strName);
///Set a parameter value (integer)
uint32_t setValue(const std::string& strName, uint32_t uVal);
///Set a parameter value (string)
void setValue(const std::string& strName, const std::string& strVal);
/// Return parameter names and their value in a string with format <parameter 1>=<value 1>\n<parameter 2>=<value 2>\n...
std::string nameAndValuePairs();
/// Read parameter and value pairs from a text file and write them into the board
bool loadParamValuePairsFromFile(const std::string& strFile);
/// Remove all values
void clearValues();
private:
///Internal values map
std::map <std::string, uint32_t> mapIntValues;
std::map <std::string, std::string> mapStrValues;
};
#endif
#define NB_STRIPS_CBC2 256
#define DAQ_TRAILER_SIZE 8
#define DAQ_HEADER_SIZE 8
#define IDX_DAQ_HEADER_FOV 0
#define IDX_DAQ_HEADER_SOURCE_LSB 1
#define IDX_DAQ_HEADER_SOURCE_MSB 2
#define IDX_DAQ_HEADER_BX 3
#define IDX_DAQ_HEADER_LV1_LSB 4
#define IDX_DAQ_HEADER_LV1_1 5
#define IDX_DAQ_HEADER_LV1_MSB 6
#define IDX_DAQ_HEADER_TYPE 7
#define IDX_DAQ_TRAILER_EOE 7
#define IDX_DAQ_TRAILER_LEN_MSB 6
#define IDX_DAQ_TRAILER_LEN_1 5
#define IDX_DAQ_TRAILER_LEN_LSB 4
#define IDX_DAQ_TRAILER_CRC_MSB 3
#define IDX_DAQ_TRAILER_CRC_LSB 2
#define IDX_DAQ_TRAILER_STAT 1
#define IDX_DAQ_TRAILER_TTS 0
#define BOE_1 0x5
#define EVENT_TYPE 0x01 //Physics trigger
#define SOURCE_FED_ID 0x33
#define FOV 0x00
#define EOE_1 0xA0
#define TTS_VALUE 0x70
#define SIZE_EVT 4
#define IDX_NUMBER_CBC 1
#define IDX_FORMAT 7
#define IDX_EVENT_TYPE 6
#define IDX_GLIB_STATUS 3
#define IDX_FRONT_END_STATUS 8
#define IDX_FRONT_END_STATUS_MSB 0
#define IDX_CBC_STATUS 16
#define FORMAT_VERSION 2
#define ZERO_SUPPRESSION 1
#define VIRGIN_RAW 2
#define GLIB_STATUS_REGISTERS 0
#define STREAMER_SPARSIFIED_MODE "zeroSuppressed"
#define STREAMER_ACQ_MODE "acqMode"
#define STREAMER_ACQ_MODE_FULLDEBUG 1
#define STREAMER_ACQ_MODE_CBCERROR 2
#define STREAMER_ACQ_MODE_SUMMARYERROR 0
#define STREAMER_ACQ_MODE_OLD 3
#define CONDITION_DATA_ENABLED "enabled_%02d"
#define CONDITION_DATA_FE_ID "FE_ID_%02d"
#define CONDITION_DATA_CBC "CBC_number_%02d"
#define CONDITION_DATA_PAGE "page_number_%02d"
#define CONDITION_DATA_REGISTER "I2C_register_%02d"
#define CONDITION_DATA_TYPE "data_type_%02d"
#define CONDITION_DATA_VALUE "value_%02d"
#define CONDITION_DATA_NAME "name_%02d"
#define NB_CONDITION_DATA 10
#include <boost/format.hpp>
#include "TrackerEvent.h"
using namespace std;
using namespace Ph2_HwDescription;
using namespace Ph2_HwInterface;
TrackerEvent::TrackerEvent( Event * pEvt, uint32_t nbCBC, uint32_t uFE, uint32_t uCBC, bool bFakeData, ParamSet* pPSet){
data_=NULL;
size_=0;
uint32_t uAcqMode = STREAMER_ACQ_MODE_FULLDEBUG;
bool bZeroSuppr=false;
if (pPSet){
uAcqMode=pPSet->getValueDef(STREAMER_ACQ_MODE, uAcqMode);
bZeroSuppr=(pPSet->getValueDef(STREAMER_SPARSIFIED_MODE, bZeroSuppr)!=0);
}
uint32_t nbBitsPayload=0, nbBitsCondition=0, nbBitsHeader = 128;//at least 2 64-bits words
uint32_t nbCondition = 0;
switch (uAcqMode){
case STREAMER_ACQ_MODE_FULLDEBUG:
nbBitsHeader+= 10 * nbCBC;
break;
case STREAMER_ACQ_MODE_CBCERROR:
nbBitsHeader+= nbCBC*2;
break;
}//+=0 if STREAMER_ACQ_MODE_SUMMARYERROR
//cout << "nbBitsHeader = " << nbBitsHeader << endl;
uint32_t nbFE=0, uFront=uFE;
while (uFront>0){//Count number of FE
if (uFront%2>0){
nbFE++;
}
uFront>>=1;
}
uint32_t nbCbcFe=nbCBC/nbFE;//nb of CBCs per FE
//cout << "nbFE = " << nbFE << endl;
if (bZeroSuppr){
for (uFront=0; uFront<nbFE;uFront++)
nbBitsPayload+= calcBitsForFE(pEvt, uFront, NULL, 0, nbCbcFe);
} else
nbBitsPayload=16 * nbFE + nbCBC*NB_STRIPS_CBC2;//Payload size (bits)
//cout << "bZeroSuppr = " << bZeroSuppr << ", nbBitsPayload = " << nbBitsPayload << endl;
nbBitsPayload+=64*4;//Stub data
//cout << "nbBitsPayload = " << nbBitsPayload << ", nbCBC = " << nbCBC << endl;
//Condition data
nbCondition = countConditionData(pPSet);
bool bConditionData=(nbCondition>0);
if (bConditionData)
nbBitsCondition=(nbCondition+1)*64;
nbBitsHeader=nbBitsHeader/64*64 + (nbBitsHeader%64>0 ? 64 :0);//padded to 64 bits
nbBitsPayload=nbBitsPayload/64*64 + (nbBitsPayload%64>0 ? 64 :0);//padded to 64 bits
size_=(nbBitsHeader + nbBitsPayload + nbBitsCondition)/8;
//cout<<"Tracker size (Bytes)= "<<nbBitsHeader/8<<"+"<<nbBitsPayload/8<<"= "<<size_<<endl;
data_=new char[getDaqSize()];
memset (data_, 0, getDaqSize());
fillTrackerHeader(pEvt, uFE, nbCBC, nbCBC/nbFE, uAcqMode, bZeroSuppr, bConditionData, bFakeData);
fillTrackerPayload(pEvt, nbFE, nbCBC, uCBC, nbBitsHeader, bZeroSuppr, bConditionData, nbCondition, pPSet);
if (bConditionData)
fillTrackerConditionData(pEvt, DAQ_HEADER_SIZE+(nbBitsHeader+nbBitsPayload)/8, nbFE, nbCBC, nbCondition, pPSet);
fillDaqHeaderAndTrailer(pEvt);
}
TrackerEvent::~TrackerEvent(){
delete data_;
}
uint32_t TrackerEvent::getDaqSize() const{
return DAQ_TRAILER_SIZE+DAQ_HEADER_SIZE+size_;
}
///Fill the tracker header
void TrackerEvent::fillTrackerHeader( Event* pEvt, uint64_t uFE, uint32_t nbCBC, uint32_t nbCbcFe, uint32_t uAcqMode, bool bZeroSuppr, bool bConditionData, bool bFakeData){
data_[DAQ_HEADER_SIZE+IDX_FORMAT] = FORMAT_VERSION<<4 | uAcqMode<<2 | (bZeroSuppr ? ZERO_SUPPRESSION : VIRGIN_RAW);//Data format version, Header format,
data_[DAQ_HEADER_SIZE+IDX_EVENT_TYPE] = (bConditionData ? 1 : 0)<<7 | (bFakeData ? 0 : 1)<<6 | (GLIB_STATUS_REGISTERS&0x3F000000)>>24;//Event type, DTC status registers
data_[DAQ_HEADER_SIZE+IDX_GLIB_STATUS+2]= (GLIB_STATUS_REGISTERS&0xFF0000)>>16;
data_[DAQ_HEADER_SIZE+IDX_GLIB_STATUS+1]= (GLIB_STATUS_REGISTERS&0xFF00)>>8;
data_[DAQ_HEADER_SIZE+IDX_GLIB_STATUS] = (GLIB_STATUS_REGISTERS&0xFF);
data_[DAQ_HEADER_SIZE+IDX_FRONT_END_STATUS_MSB] = 0;//(uFE>>64)&0xFF;//Front End status (72 bits but only 64 for now: temporary)
for (uint32_t uIdx=0; uIdx<8; uIdx++)
data_[DAQ_HEADER_SIZE+IDX_FRONT_END_STATUS+uIdx]=(uFE>>(uIdx*8))&0xFF;
//Total number of CBC chips
data_[DAQ_HEADER_SIZE+IDX_NUMBER_CBC+1] = (nbCBC&0xFF00)>>8;
data_[DAQ_HEADER_SIZE+IDX_NUMBER_CBC] = (nbCBC&0xFF);
uint32_t uChip, uStatus;
for (uChip = 0; uChip<nbCBC; uChip++)//CBC status in header
switch (uAcqMode){
case STREAMER_ACQ_MODE_FULLDEBUG://10 bits always over 2 bytes
uStatus = pEvt->PipelineAddress(uChip / nbCbcFe, uChip%nbCbcFe);
data_[DAQ_HEADER_SIZE+littleEndian8(IDX_CBC_STATUS + uChip*10/8)] |= uStatus>>((uChip*2+2)%10) & 0xFF;
data_[DAQ_HEADER_SIZE+littleEndian8(IDX_CBC_STATUS + uChip*10/8 + 1)] |= uStatus<<(8-(uChip*2+2)%10) & 0xFF;
break;
case STREAMER_ACQ_MODE_CBCERROR:
data_[DAQ_HEADER_SIZE+littleEndian8(IDX_CBC_STATUS + uChip/4/* *2/8 */)] |= pEvt->Error(uChip/nbCbcFe, uChip%nbCbcFe)<<(8-(uChip*2)%8);
break;
}//nothing if STREAMER_ACQ_MODE_SUMMARYERROR
}
void TrackerEvent::fillTrackerPayload(Event* pEvt, uint32_t nbFE, uint32_t nbCBC, uint32_t uCBC, uint32_t nbBitsHeader, bool bZeroSuppr, bool bCondition, uint32_t nbCondition, ParamSet* pPSet){
// Fill the tracker payload
uint32_t uIdxCbc=0, uOct, idxPayload, bitPayload= nbBitsHeader, uFront, uChip;
uint32_t nbCbcFe=nbCBC/nbFE;//nb of CBCs per FE
vector< uint8_t > cbcData;
for (uFront=0; uFront<nbFE; uFront++){
//cout<<"FE="<<uFront<<" @"<<idxPayload<<endl;
if (bZeroSuppr){
bitPayload+=(calcBitsForFE(pEvt, uFront, data_, bitPayload, nbCbcFe)+7)/8;
idxPayload=DAQ_HEADER_SIZE+(bitPayload+7)/8;
} else {
idxPayload=DAQ_HEADER_SIZE+nbBitsHeader/8+uFront*(nbCbcFe*NB_STRIPS_CBC2/8 + 2);
data_[littleEndian8(idxPayload++)]=(uCBC&0xFF00)>>8;
data_[littleEndian8(idxPayload++)]=(uCBC&0x00FF);
for (uChip=0; uChip<nbCbcFe; uChip++){
pEvt->GetCbcEvent(uFront, uChip, cbcData);
for (uOct=0; uOct<NB_STRIPS_CBC2/8; uOct++){
// Jonni: so we need to skip 2 CBC error bits and then 8 Pipeline Address Bits then we need to reconstruct nibbles from half nibbles
data_[littleEndian8(idxPayload)] = ((cbcData[uOct] << 2) & 0xfc) | (uOct==NB_STRIPS_CBC2/8-1 ? 0 : ((cbcData[uOct+1] >> 6) & 0x03));
reverseByte(data_[littleEndian8(idxPayload++)]);
}
//cout<<endl;
}
}//if zero suppressed
}//for Front End
//Stub Data
idxPayload=(idxPayload+7)/8*8;
// cout<<"idxStub="<<idxPayload<<endl;
for (uFront=0; uFront<nbFE; uFront++){//Stub bits
for (uChip=0; uChip<nbCbcFe; uChip++){
if (pEvt->StubBit(uFront, uChip))
data_[littleEndian8(idxPayload+7-uIdxCbc/8)] |= (1<<(uIdxCbc%8));
uIdxCbc++;
}
}
// idxPayload+=uChip/8 + 1;
}
void TrackerEvent::fillTrackerConditionData(Event* pEvt, uint32_t idxPayload, uint32_t nbFE, uint32_t nbCBC, uint32_t nbCondition, ParamSet* pPSet)
{//Condition data
// cout<<"idxNbCondition="<<idxPayload<<endl;
uint32_t uOct, uCond, uVal=0, uFront, uChip;
uint32_t nbCbcFe=nbCBC/nbFE;//nb of CBCs per FE
idxPayload+=4;
for (uOct=4; uOct<8; uOct++)//Nb of condition data in 64 bits
data_[littleEndian8(idxPayload++)]= (nbCondition>>(56-uOct*8))&0xFF;
// cout<<"idxCondition="<<idxPayload<<endl;
for (uCond=0 ; uCond<NB_CONDITION_DATA; uCond++){//Key
if (pPSet->getValue((boost::format(CONDITION_DATA_ENABLED)%uCond).str())==1){
data_[littleEndian8(idxPayload++)]=pPSet->getValue((boost::format(CONDITION_DATA_FE_ID)%uCond).str())&0xFF;
data_[littleEndian8(idxPayload++)]=((pPSet->getValue((boost::format(CONDITION_DATA_CBC)%uCond).str())&0x0F))
| ((pPSet->getValue((boost::format(CONDITION_DATA_PAGE)%uCond).str())&0x0F)<<4);
data_[littleEndian8(idxPayload++)]=pPSet->getValue((boost::format(CONDITION_DATA_REGISTER)%uCond).str())&0xFF;
data_[littleEndian8(idxPayload++)]=pPSet->getValue((boost::format(CONDITION_DATA_TYPE)%uCond).str())&0xFF;
switch(pPSet->getValue((boost::format(CONDITION_DATA_TYPE)%uCond).str())){//Value
case 3://Trigger phase (TDC)
uVal=pEvt->GetTDC();
break;
case 6://Error bits
uVal=0;
for (uFront=0; uFront<nbFE; uFront++)
for (uChip=0;uChip<nbCbcFe;uChip++)
uVal |= pEvt->Error(uFront, uChip)<<(uChip*2);
break;
case 7://CBC Status bits
uVal=0;
if (nbCBC<=4){
for (uFront=0; uFront<nbFE; uFront++)
for (uChip=0;uChip<nbCbcFe;uChip++) //temporary: All CBC status bits in one 32-bits value
uVal |= pEvt->PipelineAddress(uFront, uChip) << ((uFront*nbCbcFe+uChip)*8);
} else {
uFront=pPSet->getValue((boost::format(CONDITION_DATA_FE_ID)%uCond).str())&0xFF;
uChip=pPSet->getValue((boost::format(CONDITION_DATA_CBC)%uCond).str())&0x0F;
uVal = pEvt->PipelineAddress(uFront, uChip);
}
break;
default://Configuration parameter (I2C), Angle, High Voltage, Other Value
uVal=pPSet->getValue((boost::format(CONDITION_DATA_VALUE)%uCond).str());
break;
}//switch
for (uOct=0; uOct<4; uOct++)
data_[littleEndian8(idxPayload++)]= (uVal>>(24-uOct*8))&0xFF;
}
}//for
}
uint32_t TrackerEvent::calcBitsForFE(Event* pEvt, uint32_t uFront, char* dest, uint32_t bitDest, uint32_t nbCBC){
uint32_t uChip, uBit, nbCluster=0, uClusterSize, nbMax=63, uPos;
uint32_t nbBits=7;//FE header size for 2S modules