Commit 6112fe00 authored by Georg Auzinger's avatar Georg Auzinger
Browse files

implemented easylogging in all executables in /miniDAQ and seems to work ok

parent c241504f
......@@ -70,7 +70,7 @@ void DQMHistogrammer::bookHistos (const Ph2_HwInterface::EventDataMap& evmap)
uint32_t feId = (cKey >> 8) & 0x00FF;
uint32_t cbcId = cKey & 0xFF;
std::cout << " fedId " << feId << " cbcId " << cbcId << " Columns " << nColumn_ << " nCbc " << nCbc << std::endl;
LOG (INFO) << " fedId " << feId << " cbcId " << cbcId << " Columns " << nColumn_ << " nCbc " << nCbc ;
if (nColumn_ == 1 && cbcId > 1) continue;
......@@ -103,7 +103,7 @@ void DQMHistogrammer::bookHistos (const Ph2_HwInterface::EventDataMap& evmap)
if ( (nCbc % 8) == 0) nbin = 8 * 127;
std::cout << " nCbc " << nCbc << " nbin " << nbin << std::endl;
LOG (DEBUG) << " nCbc " << nCbc << " nbin " << nbin ;
dut0HitProfH_ = new TH2I ( "evenSensor_hitprofile", "Even Sensor Hitmap", nbin, 0.5, nbin + 0.5, nColumn_, -0.5, nColumn_ - 0.5);
dut1HitProfH_ = new TH2I ( "oddSensor_hitprofile", "Odd Sensor Hitmap", nbin, 0.5, nbin + 0.5, nColumn_, -0.5, nColumn_ - 0.5);
......
......@@ -22,35 +22,40 @@ using namespace Ph2_HwInterface;
using namespace Ph2_System;
using namespace CommandLineProcessing;
INITIALIZE_EASYLOGGINGPP
//Class used to process events acquired by a parallel acquisition
class AcqVisitor: public HwInterfaceVisitor
{
int cN;
public:
AcqVisitor()
{
cN = 0;
}
//void init(std::ofstream* pfSave, bool bText);
virtual void visit ( const Ph2_HwInterface::Event& pEvent )
{
cN++;
std::cout << ">>> Event #" << cN << std::endl;
std::cout << pEvent << std::endl;
}
};
void syntax ( int argc )
{
if ( argc > 4 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
else if ( argc < 3 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
else return;
}
//class AcqVisitor: public HwInterfaceVisitor
//{
//int cN;
//public:
//AcqVisitor()
//{
//cN = 0;
//}
////void init(std::ofstream* pfSave, bool bText);
//virtual void visit ( const Ph2_HwInterface::Event& pEvent )
//{
//cN++;
//std::cout << ">>> Event #" << cN << std::endl;
//std::cout << pEvent << std::endl;
//}
//};
//void syntax ( int argc )
//{
//if ( argc > 4 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
//else if ( argc < 3 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
//else return;
//}
std::string getFileName()
{
//configure the logger
el::Configurations conf ("settings/logger.conf");
el::Loggers::reconfigureAllLoggers (conf);
std::string line;
std::fstream cFile;
int cRunNumber;
......@@ -71,7 +76,7 @@ std::string getFileName()
cFile.close();
}
else
std::cout << "File not opened!" << std::endl;
LOG (WARNING) << "File not opened!" ;
}
else
{
......@@ -118,7 +123,7 @@ int main ( int argc, char* argv[] )
if ( result != ArgvParser::NoParserError )
{
std::cout << cmd.parseErrorDescription ( result );
LOG (INFO) << cmd.parseErrorDescription ( result );
exit ( 1 );
}
......@@ -135,61 +140,67 @@ int main ( int argc, char* argv[] )
cSystemController.addFileHandler ( cOutputFile, 'w' );
cSystemController.InitializeHw ( cHWFile );
cSystemController.ConfigureHw ( std::cout );
std::stringstream outp;
cSystemController.InitializeHw ( cHWFile, outp );
outp.str ("");
cSystemController.ConfigureHw (outp);
LOG (INFO) << outp.str();
BeBoard* pBoard = cSystemController.fBoardVector.at ( 0 );
//if ( cmd.foundOption ( "parallel" ) )
//{
//uint32_t nbPacket = pBoard->getReg ( "pc_commands.CBC_DATA_PACKET_NUMBER" ), nbAcq = pEventsperVcth / ( nbPacket + 1 ) + ( pEventsperVcth % ( nbPacket + 1 ) != 0 ? 1 : 0 );
//std::cout << "Packet number=" << nbPacket << ", Nb events=" << pEventsperVcth << " -> Nb acquisition iterations=" << nbAcq << std::endl;
//AcqVisitor visitor;
//std::cout << "Press Enter to start the acquisition, press Enter again to stop i" << std::endl;
//std::cin.ignore();
//cSystemController.fBeBoardInterface->StartThread ( pBoard, nbAcq, &visitor );
//std::cin.ignore();
//cSystemController.fBeBoardInterface->StopThread ( pBoard );
//uint32_t nbPacket = pBoard->getReg ( "pc_commands.CBC_DATA_PACKET_NUMBER" ), nbAcq = pEventsperVcth / ( nbPacket + 1 ) + ( pEventsperVcth % ( nbPacket + 1 ) != 0 ? 1 : 0 );
//std::cout << "Packet number=" << nbPacket << ", Nb events=" << pEventsperVcth << " -> Nb acquisition iterations=" << nbAcq << std::endl;
//AcqVisitor visitor;
//std::cout << "Press Enter to start the acquisition, press Enter again to stop i" << std::endl;
//std::cin.ignore();
//cSystemController.fBeBoardInterface->StartThread ( pBoard, nbAcq, &visitor );
//std::cin.ignore();
//cSystemController.fBeBoardInterface->StopThread ( pBoard );
//}
//else
//{
// make event counter start at 1 as does the L1A counter
uint32_t cN = 1;
uint32_t cNthAcq = 0;
uint32_t count = 0;
// make event counter start at 1 as does the L1A counter
uint32_t cN = 1;
uint32_t cNthAcq = 0;
uint32_t count = 0;
cSystemController.fBeBoardInterface->Start ( pBoard );
cSystemController.fBeBoardInterface->Start ( pBoard );
while ( cN <= pEventsperVcth )
{
uint32_t cPacketSize = cSystemController.fBeBoardInterface->ReadData ( pBoard, false );
while ( cN <= pEventsperVcth )
{
uint32_t cPacketSize = cSystemController.fBeBoardInterface->ReadData ( pBoard, false );
if ( cN + cPacketSize >= pEventsperVcth )
cSystemController.fBeBoardInterface->Stop ( pBoard );
if ( cN + cPacketSize >= pEventsperVcth )
cSystemController.fBeBoardInterface->Stop ( pBoard );
const std::vector<Event*>& events = cSystemController.GetEvents ( pBoard );
const std::vector<Event*>& events = cSystemController.GetEvents ( pBoard );
for ( auto& ev : events )
{
count++;
cN++;
for ( auto& ev : events )
{
count++;
cN++;
if ( cmd.foundOption ( "dqm" ) )
if ( cmd.foundOption ( "dqm" ) )
{
if ( count % atoi ( cmd.optionValue ( "dqm" ).c_str() ) == 0 )
{
if ( count % atoi ( cmd.optionValue ( "dqm" ).c_str() ) == 0 )
{
std::cout << ">>> Event #" << count << std::endl;
std::cout << *ev << std::endl;
}
LOG (INFO) << ">>> Event #" << count ;
outp.str ("");
outp << *ev << std::endl;
LOG (INFO) << outp.str();
}
if ( count % 100 == 0 )
std::cout << ">>> Recorded Event #" << count << std::endl;
}
cNthAcq++;
if ( count % 100 == 0 )
LOG (INFO) << ">>> Recorded Event #" << count ;
}
cNthAcq++;
}
//}
cSystemController.Destroy();
}
......@@ -25,6 +25,8 @@ using namespace Ph2_System;
using namespace CommandLineProcessing;
INITIALIZE_EASYLOGGINGPP
void tokenize ( const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters )
{
// Skip delimiters at beginning.
......@@ -50,13 +52,19 @@ void dumpEvents ( const std::vector<Event*>& elist )
{
for ( int i = 0; i < elist.size(); i++ )
{
std::cout << "Event index: " << i + 1 << std::endl;
std::cout << *elist[i] << std::endl;
LOG (INFO) << "Event index: " << i + 1 << std::endl;
std::stringstream outp;
outp << *elist[i] << std::endl;
LOG (INFO) << outp.str();
}
}
int main ( int argc, char* argv[] )
{
//configure the logger
el::Configurations conf ("settings/logger.conf");
el::Loggers::reconfigureAllLoggers (conf);
ArgvParser cmd;
// init
......@@ -108,7 +116,7 @@ int main ( int argc, char* argv[] )
if ( result != ArgvParser::NoParserError )
{
std::cout << cmd.parseErrorDescription ( result ) << std::endl;
LOG (INFO) << cmd.parseErrorDescription ( result );
exit ( 1 );
}
......@@ -117,14 +125,14 @@ int main ( int argc, char* argv[] )
if ( rawFilename.empty() )
{
std::cerr << "Error, no binary file provided. Quitting" << std::endl;
LOG (ERROR) << "Error, no binary file provided. Quitting" ;
exit ( 2 );
}
// Check if the file can be found
if ( ! boost::filesystem::exists ( rawFilename ) )
{
std::cerr << "Error!! binary file " << rawFilename << " not found, exiting!" << std::endl;
LOG (ERROR) << "Error!! binary file " << rawFilename << " not found, exiting!";
exit ( 3 );
}
......@@ -132,7 +140,7 @@ int main ( int argc, char* argv[] )
if ( cbcTypeEvtSizeMap.find ( cbcType ) == cbcTypeEvtSizeMap.end() )
{
std::cerr << "Wrong CBC type specified!!!!" << std::endl;
LOG (ERROR) << "Wrong CBC type specified!!!!";
exit ( 4 );
}
......@@ -154,9 +162,11 @@ int main ( int argc, char* argv[] )
cHWFile += "/";
cHWFile += cbcTypeEvtSizeMap[cbcType].second;
std::cout << "HWfile=" << cHWFile << std::endl;
LOG (INFO) << "HWfile=" << cHWFile;
//dqmh->parseHWxml ( cHWFile );
dqmh->InitializeHw ( cHWFile );
std::ofstream outp;
dqmh->InitializeHw ( cHWFile, outp );
LOG (INFO) << outp;
//dqmh->fParser.parseHW (cHWFile, fBeBoardFWMap, fBoardVector, os);
const BeBoard* pBoard = dqmh->getBoard ( 0 );
......@@ -194,10 +204,9 @@ int main ( int argc, char* argv[] )
const std::vector<Event*>& evlist = d.GetEvents ( pBoard );
dqmh->fillHistos (evlist, ntotevt);
ntotevt += nEvents;
std::cout << "eventSize = " << eventSize
<< ", eventsRead = " << nEvents
<< ", totalEventsRead = " << ntotevt
<< std::endl;
LOG (INFO) << "eventSize = " << eventSize
<< ", eventsRead = " << nEvents
<< ", totalEventsRead = " << ntotevt;
if ( !dqmh->getFileHandler()->file_open() ) break;
}
......@@ -229,7 +238,7 @@ int main ( int argc, char* argv[] )
// now read back the Root file and publish the histograms on the DQM page
RootWeb::makeDQMmonitor ( dqmFilename, cDirBasePath, runLabel );
std::cout << "Saving root file to " << dqmFilename << " and webpage to " << cDirBasePath << std::endl;
LOG (INFO) << "Saving root file to " << dqmFilename << " and webpage to " << cDirBasePath ;
}
else dumpEvents ( elist );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment