Commit b8568e90 authored by Georg Auzinger's avatar Georg Auzinger
Browse files

Merge branch 'Dev' into 'Dev'

Dev

See merge request !52
parents cc5d36f5 c7b3ae5e
......@@ -185,9 +185,11 @@ namespace Ph2_System {
std::string cFileName;
if ( !cFilePrefix.empty() )
if ( !cFilePrefix.empty() ){
if (cFilePrefix.at(cFilePrefix.length()-1) != '/')
cFilePrefix.append("/");
cFileName = cFilePrefix + expandEnvironmentVariables (cCbcNode.attribute ( "configfile" ).value() );
else cFileName = expandEnvironmentVariables (cCbcNode.attribute ( "configfile" ).value() );
} else cFileName = expandEnvironmentVariables (cCbcNode.attribute ( "configfile" ).value() );
Cbc* cCbc = new Cbc ( pModule->getBeId(), pModuleNode.attribute ( "FMCId" ).as_int(), pModuleNode.attribute ( "FeId" ).as_int(), cCbcNode.attribute ( "Id" ).as_int(), cFileName );
......
......@@ -62,6 +62,9 @@ int main ( int argc, char* argv[] )
cmd.defineOption ( "batch", "Run the application in batch mode", ArgvParser::NoOptionAttribute );
cmd.defineOptionAlternative ( "batch", "b" );
cmd.defineOption ( "noTDC", "Ignore TDC values", ArgvParser::NoOptionAttribute );
cmd.defineOptionAlternative ( "noTDC", "T" );
int result = cmd.parse ( argc, argv );
if ( result != ArgvParser::NoParserError )
......@@ -76,6 +79,7 @@ int main ( int argc, char* argv[] )
bool cStubLatency = ( cmd.foundOption ( "stublatency" ) ) ? true : false;
bool cSignal = ( cmd.foundOption ( "signal" ) ) ? true : false;
bool cNoise = ( cmd.foundOption ( "noise" ) ) ? true : false;
bool cNoTdc = ( cmd.foundOption ( "noTDC" ) ) ? true : false;
std::string cDirectory = ( cmd.foundOption ( "output" ) ) ? cmd.optionValue ( "output" ) : "Results/";
if ( !cNoise ) cDirectory += "Commissioning";
......@@ -114,10 +118,10 @@ int main ( int argc, char* argv[] )
{
LatencyScan cLatencyScan;
cLatencyScan.Inherit (&cTool);
cLatencyScan.Initialize (cStartLatency, cLatencyRange );
cLatencyScan.Initialize (cStartLatency, cLatencyRange, cNoTdc );
// Here comes our Part:
if ( cLatency ) cLatencyScan.ScanLatency ( cStartLatency, cLatencyRange );
if ( cLatency ) cLatencyScan.ScanLatency ( cStartLatency, cLatencyRange, cNoTdc );
if ( cStubLatency ) cLatencyScan.ScanStubLatency ( cStartLatency, cLatencyRange );
}
......
#include "LatencyScan.h"
void LatencyScan::Initialize (uint32_t pStartLatency, uint32_t pLatencyRange)
void LatencyScan::Initialize (uint32_t pStartLatency, uint32_t pLatencyRange, bool bNoTdc)
{
for ( auto& cBoard : fBoardVector )
{
......@@ -22,20 +22,26 @@ void LatencyScan::Initialize (uint32_t pStartLatency, uint32_t pLatencyRange)
if ( cObj ) delete cObj;
TH1F* cLatHist = new TH1F ( cName, Form ( "Latency FE%d; Latency; # of Hits", cFeId ), (pLatencyRange ) * fTDCBins, pStartLatency , pStartLatency + (pLatencyRange ) * fTDCBins );
//modify the axis labels
uint32_t pLabel = pStartLatency;
for (uint32_t cLatency = pStartLatency; cLatency < pStartLatency + pLatencyRange; ++cLatency)
{
for (uint32_t cPhase = 0; cPhase < fTDCBins; ++cPhase)
{
int cBin = convertLatencyPhase (pStartLatency, cLatency, cPhase);
cLatHist->GetXaxis()->SetBinLabel (cBin, Form ("%d+%d", cLatency, cPhase) );
}
}
cLatHist->GetXaxis()->SetTitle (Form ("Signal timing (reverse time) [TriggerLatency*%d+TDC]", fTDCBins) );
TH1F* cLatHist;
if (bNoTdc){
cLatHist = new TH1F ( cName, Form ( "Latency FE%d; Latency; # of Hits", cFeId ), (pLatencyRange ) , pStartLatency , pStartLatency + (pLatencyRange ) );
cLatHist->GetXaxis()->SetTitle ("Signal timing [TriggerLatency]" );
} else {
cLatHist = new TH1F ( cName, Form ( "Latency FE%d; Latency; # of Hits", cFeId ), (pLatencyRange ) * fTDCBins, pStartLatency , pStartLatency + (pLatencyRange ) * fTDCBins );
//modify the axis labels
uint32_t pLabel = pStartLatency;
for (uint32_t cLatency = pStartLatency; cLatency < pStartLatency + pLatencyRange; ++cLatency)
{
for (uint32_t cPhase = 0; cPhase < fTDCBins; ++cPhase)
{
int cBin = convertLatencyPhase (pStartLatency, cLatency, cPhase);
cLatHist->GetXaxis()->SetBinLabel (cBin, Form ("%d+%d", cLatency, cPhase) );
}
}
cLatHist->GetXaxis()->SetTitle (Form ("Signal timing (reverse time) [TriggerLatency*%d+TDC]", fTDCBins) );
}
cLatHist->SetFillColor ( 4 );
cLatHist->SetFillStyle ( 3001 );
bookHistogram ( cFe, "module_latency", cLatHist );
......@@ -55,7 +61,7 @@ void LatencyScan::Initialize (uint32_t pStartLatency, uint32_t pLatencyRange)
LOG (INFO) << "Histograms and Settings initialised." ;
}
std::map<Module*, uint8_t> LatencyScan::ScanLatency ( uint8_t pStartLatency, uint8_t pLatencyRange )
std::map<Module*, uint8_t> LatencyScan::ScanLatency ( uint8_t pStartLatency, uint8_t pLatencyRange, bool bNoTdc )
{
// This is not super clean but should work
// Take the default VCth which should correspond to the pedestal and add 8 depending on the mode to exclude noise
......@@ -82,7 +88,6 @@ std::map<Module*, uint8_t> LatencyScan::ScanLatency ( uint8_t pStartLatency, uin
cWriter.setRegister ( "TriggerLatency", cLat );
this->accept ( cWriter );
// Take Data for all Modules
for ( BeBoard* pBoard : fBoardVector )
{
......@@ -91,7 +96,7 @@ std::map<Module*, uint8_t> LatencyScan::ScanLatency ( uint8_t pStartLatency, uin
const std::vector<Event*>& events = fBeBoardInterface->GetEvents ( pBoard );
// Loop over Events from this Acquisition
countHitsLat ( pBoard, events, "module_latency", cLat, pStartLatency );
countHitsLat ( pBoard, events, "module_latency", cLat, pStartLatency, bNoTdc );
}
// done counting hits for all FE's, now update the Histograms
......@@ -202,7 +207,7 @@ std::map<Module*, uint8_t> LatencyScan::ScanStubLatency ( uint8_t pStartLatency,
////////////////////////////////////// PRIVATE METHODS //////////////////////////////////////
int LatencyScan::countHitsLat ( BeBoard* pBoard, const std::vector<Event*> pEventVec, std::string pHistName, uint8_t pParameter, uint32_t pStartLatency)
int LatencyScan::countHitsLat ( BeBoard* pBoard, const std::vector<Event*> pEventVec, std::string pHistName, uint8_t pParameter, uint32_t pStartLatency, bool pNoTdc)
{
std::string cBoardType = pBoard->getBoardType();
uint32_t cTotalHits = 0;
......@@ -234,8 +239,7 @@ int LatencyScan::countHitsLat ( BeBoard* pBoard, const std::vector<Event*> pEve
if (cTDCVal != 0 && cBoardType == "GLIB") cTDCVal -= 5;
else if (cTDCVal != 0 && cBoardType == "CTA") cTDCVal -= 3;
if (cTDCVal > 8 ) LOG (INFO) << "ERROR, TDC value not within expected range - normalized value is " << +cTDCVal << " - original Value was " << +cEvent->GetTDC() << "; not considering this Event!" << std::endl;
if (!pNoTdc && cTDCVal > 8) LOG (INFO) << "ERROR, TDC value not within expected range - normalized value is " << +cTDCVal << " - original Value was " << +cEvent->GetTDC() << "; not considering this Event!" << std::endl;
else
{
for ( auto cCbc : cFe->fCbcVector )
......@@ -250,7 +254,7 @@ int LatencyScan::countHitsLat ( BeBoard* pBoard, const std::vector<Event*> pEve
//now I have the number of hits in this particular event for all CBCs and the TDC value
uint32_t cBin = convertLatencyPhase (pStartLatency, cFillVal, cTDCVal);
cTmpHist->Fill ( cBin, cHitCounter);
cTmpHist->Fill ( pNoTdc ? pParameter : cBin, cHitCounter);
cHitSum += cHitCounter;
}
}
......
......@@ -41,12 +41,12 @@ class LatencyScan : public Tool
{
public:
void Initialize (uint32_t pStartLatency, uint32_t pLatencyRange);
std::map<Module*, uint8_t> ScanLatency ( uint8_t pStartLatency = 0, uint8_t pLatencyRange = 20 );
void Initialize (uint32_t pStartLatency, uint32_t pLatencyRange, bool bNoTdc);
std::map<Module*, uint8_t> ScanLatency ( uint8_t pStartLatency = 0, uint8_t pLatencyRange = 20, bool pNoTdc = false );
std::map<Module*, uint8_t> ScanStubLatency ( uint8_t pStartLatency = 0, uint8_t pLatencyRange = 20 );
private:
int countHitsLat ( BeBoard* pBoard, const std::vector<Event*> pEventVec, std::string pHistName, uint8_t pParameter, uint32_t pStartLatency );
int countHitsLat ( BeBoard* pBoard, const std::vector<Event*> pEventVec, std::string pHistName, uint8_t pParameter, uint32_t pStartLatency, bool pNoTdc );
int countHits ( Module* pFe, const Event* pEvent, std::string pHistName, uint8_t pParameter );
int countStubs ( Module* pFe, const Event* pEvent, std::string pHistName, uint8_t pParameter );
void updateHists ( std::string pHistName, bool pFinal );
......
#include "uhal/log/log.hpp"
#include "SignalScan.h"
......@@ -80,8 +81,14 @@ void SignalScan::ScanSignal (int pSignalScanLength)
while (cTotalEvents < fNevents)
{
fBeBoardInterface->ReadData ( pBoard, fNevents );
try{
fBeBoardInterface->ReadNEvents ( pBoard, fNevents );
} catch (uhal::exception::exception& e){
LOG(ERROR)<< e.what();
updateHists ( "module_signal", false );
output.close();
return;
}
const std::vector<Event*>& events = fBeBoardInterface->GetEvents ( pBoard );
cTotalEvents += events.size();
......@@ -139,7 +146,7 @@ void SignalScan::ScanSignal (int pSignalScanLength)
LOG (INFO) << "Recorded " << cTotalEvents << " Events" ;
updateHists ( "module_signal", false );
}
}//while events
fBeBoardInterface->Stop (pBoard);
......
Markdown is supported
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