Commit 517727d8 authored by Basil Schneider's avatar Basil Schneider
Browse files

Adding binary which uses the new FW scans

parent 86f466b0
#include <cstring>
#include "../HWDescription/Cbc.h"
#include "../HWDescription/Module.h"
#include "../HWDescription/BeBoard.h"
#include "../HWInterface/CbcInterface.h"
#include "../HWInterface/BeBoardInterface.h"
#include "../HWDescription/Definition.h"
#include "../tools/FwScans.h"
#include "../Utils/argvparser.h"
#include "TROOT.h"
#include "TApplication.h"
#include "../Utils/Timer.h"
using namespace Ph2_HwDescription;
using namespace Ph2_HwInterface;
using namespace Ph2_System;
using namespace CommandLineProcessing;
INITIALIZE_EASYLOGGINGPP
int main ( int argc, char* argv[] )
{
//configure the logger
el::Configurations conf ("settings/logger.conf");
el::Loggers::reconfigureAllLoggers (conf);
ArgvParser cmd;
// init
cmd.setIntroductoryDescription ( "CMS Ph2_ACF calibration routine using K. Uchida's algorithm or a fast algorithm" );
// error codes
cmd.addErrorCode ( 0, "Success" );
cmd.addErrorCode ( 1, "Error" );
// options
cmd.setHelpOption ( "h", "help", "Print this help page" );
cmd.defineOption ( "file", "Hw Description File . Default value: settings/Calibration8CBC.xml", ArgvParser::OptionRequiresValue /*| ArgvParser::OptionRequired*/ );
cmd.defineOptionAlternative ( "file", "f" );
cmd.defineOption ( "output", "Output Directory . Default value: Results", ArgvParser::OptionRequiresValue /*| ArgvParser::OptionRequired*/ );
cmd.defineOptionAlternative ( "output", "o" );
cmd.defineOption ( "noise", "Perform noise scan after Offset tuning", ArgvParser::NoOptionAttribute );
cmd.defineOptionAlternative ( "noise", "n" );
cmd.defineOption ( "antenna", "perform latency scan with antenna on UIB [1-4 to select an individual group, 0 for all]", ArgvParser::OptionRequiresValue );
cmd.defineOption ( "potentiometer", "value to program on potentiometer [0x00 - 0x3FF. 1 DAC unit is equivalent to ~ 5 mV and the value at 0 has been measured to be ~-2.4 V]", ArgvParser::OptionRequiresValue );
cmd.defineOption ( "testPulse", "Perform FE equialization using the on-chip calibration pulse [provide amplitude of TP in DAC units]", ArgvParser::OptionRequiresValue );
cmd.defineOptionAlternative ( "testPulse", "t" );
cmd.defineOption ( "reconstruct", "Reconstuct signal amplitude using 2D scan [threshold and latency] : pass as an argument the step size in time [up to 1 ns resolution]", ArgvParser::OptionRequiresValue );
cmd.defineOptionAlternative ( "reconstruct", "r" );
cmd.defineOption ( "batch", "Run the application in batch mode", ArgvParser::NoOptionAttribute );
cmd.defineOptionAlternative ( "batch", "b" );
int result = cmd.parse ( argc, argv );
if ( result != ArgvParser::NoParserError )
{
LOG (INFO) << cmd.parseErrorDescription ( result );
exit ( 1 );
}
// now query the parsing results
std::string cHWFile = ( cmd.foundOption ( "file" ) ) ? cmd.optionValue ( "file" ) : "settings/Calibration8CBC.xml";
std::string cDirectory = ( cmd.foundOption ( "output" ) ) ? cmd.optionValue ( "output" ) : "Results/";
cDirectory += "FwScans";
// what flags amd I using
bool batchMode = ( cmd.foundOption ( "batch" ) ) ? true : false;
bool cNoiseScan = ( cmd.foundOption ("noise") ) ? true : false;
bool cReconstruct = ( cmd.foundOption ("reconstruct") ) ? true : false;
bool cAntenna = (cmd.foundOption ("antenna") )? true : false;
// options
int cTestPotential = ( cmd.foundOption ( "testPulse" ) ) ? convertAnyInt ( cmd.optionValue ( "testPulse" ).c_str() ) : 0;
int cTimeStep = ( cmd.foundOption ( "reconstruct" ) ) ? convertAnyInt ( cmd.optionValue ( "reconstruct" ).c_str() ) : 5;
int cAntennaGroup = ( cmd.foundOption ( "antenna" ) ) ? convertAnyInt ( cmd.optionValue ( "antenna" ).c_str() ) : -1;
int cAntennaPotential = ( cmd.foundOption ( "potentiometer" ) ) ? convertAnyInt ( cmd.optionValue ( "potentiometer" ).c_str() ) : 0xD8;
TApplication cApp ( "Root Application", &argc, argv );
if ( batchMode ) gROOT->SetBatch ( true );
else TQObject::Connect ( "TCanvas", "Closed()", "TApplication", &cApp, "Terminate()" );
Timer t;
//create a genereic Tool Object, I can then construct all other tools from that using the Inherit() method
//this tool stays on the stack and lives until main finishes - all other tools will update the HWStructure from cTool
Tool cTool;
std::stringstream outp;
cTool.InitializeHw ( cHWFile, outp );
cTool.InitializeSettings ( cHWFile, outp );
LOG (INFO) << outp.str();
outp.str ("");
cTool.ConfigureHw ();
cTool.CreateResultDirectory ( cDirectory );
cTool.InitResultFile ( "FwScanResults" );
cTool.StartHttpServer();
t.start();
// now create a calibration object
FwScans cFwScans;
cFwScans.Inherit (&cTool);
//second parameter disables stub logic on CBC3
cFwScans.Initialise ( true );
// equalize offsets using d19c fw counters
t.start();
cFwScans.fwEqualization(cTestPotential);
cFwScans.fwSetThresholds();
t.stop();
t.show ( "Time to tune the offsets in the system: " );
if (cNoiseScan)
{
t.start();
cFwScans.fwSCurves(cTestPotential);
t.stop();
t.show ( "Time to Calibrate the system: " );
}
if( cReconstruct )
{
t.start();
if( cAntenna )
cFwScans.fwAntenna(cAntennaGroup , cAntennaPotential, 10 );
else if( cTestPotential > 0 )
cFwScans.fwTP(cTestPotential, 10, cTimeStep );
t.stop();
t.show ( "Time to Reconstruct the signal: " );
}
cFwScans.writeObjects();
cFwScans.dumpConfigFiles();
cTool.SaveResults();
cTool.CloseResultFile();
cTool.Destroy();
if ( !batchMode ) cApp.Run();
return 0;
}
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