Commit 9192c937 authored by Sarah Seif El Nasr's avatar Sarah Seif El Nasr
Browse files

Antenna tester tool (s/w) debugged and now active in src/integratedtester.cc....

Antenna tester tool (s/w) debugged and now active in src/integratedtester.cc. Still requires confirmation of operation using the actual antenna.
parent 65cb1a6a
......@@ -50,7 +50,7 @@
<Settings>
<Setting name="TargetVcth">0x78</Setting>
<Setting name="TargetOffset">0x50</Setting>
<Setting name="Nevents">200</Setting>
<Setting name="Nevents">100</Setting>
<Setting name="TestPulsePotentiometer">0x00</Setting>
<Setting name="HoleMode">1</Setting>
<Setting name="VerificationLoop">1</Setting>
......
......@@ -15,12 +15,12 @@
<!--<Global_CBC_Register name="SelTestPulseDel&ChanGroup">0x00</Global_CBC_Register>-->
<CBC_Files path="./settings/" />
<CBC Id="0" configfile="Cbc_default_hole.txt" />
<CBC Id="1" configfile="Cbc_default_hole.txt" />
<!-- <CBC Id="0" configfile="Cbc_default_hole.txt" />
<CBC Id="1" configfile="Cbc_default_hole.txt" /> -->
<!--<CBC_Files path="./Results/Calibration_Hole_27-04-16_17:55/" />-->
<!--<CBC Id="0" configfile="FE0CBC0.txt" />-->
<!--<CBC Id="1" configfile="FE0CBC1.txt" />-->
<CBC_Files path="./Results/IntegratedTester_Hole_26-10-16_18:00/" />
<CBC Id="0" configfile="FE0CBC0.txt" />
<CBC Id="1" configfile="FE0CBC1.txt" />
</Module>
<!-- Commissioning Mode -->
<!-- set to 1 to enable commissioning mode -->
......
......@@ -12,7 +12,7 @@
<Global_CBC_Register name="VCth"> 0x78 </Global_CBC_Register>
<!--Global_CBC_Register name="TriggerLatency"> 0x0C </Global_CBC_Register-->
<CBC_Files path="./settings/"/>
<CBC_Files path="./Results/IntegratedTester_Hole_26-10-16_18:00/" />
<CBC Id="0" configfile="FE0CBC0.txt"/>
<CBC Id="1" configfile="FE0CBC1.txt"/>
......
......@@ -282,7 +282,11 @@ bool check_Shorts(Tool pTool , std::string pHWFile , uint32_t cMaxNumShorts)
cShortFinder.ChangeHWDescription ( pHWFile );
cShortFinder.ChangeSettings ( pHWFile );
cShortFinder.ConfigureHw();
//reload the calibration values for the CBCs
cShortFinder.ReconfigureRegisters();
// I don't think this is neccesary ... but here for now
cShortFinder.ConfigureVcth(0x78);
cShortFinder.Initialize();
cShortFinder.FindShorts();
cShortFinder.SaveResults();
......@@ -310,6 +314,9 @@ void perform_OccupancyMeasurment(Tool pTool , std::string pHWFile )
// re-configure CBC regsiters with values from the calibration
cHybridTester.ReconfigureCBCRegisters();
// I don't think this is neccesary ... but here for now
cHybridTester.ConfigureVcth(0x78);
// measure occupancy
cHybridTester.Measure();
// display noisy/dead channels
......@@ -331,22 +338,26 @@ void perform_OccupancyMeasurment(Tool pTool , std::string pHWFile )
void perform_AntennaOccupancyMeasurement(Tool pTool , std::string pHWFile )
{
LOG (INFO) << "Starting occupancy measurement using the antenna." ;
std::stringstream outp;
AntennaTester cAntennaTester;
cAntennaTester.Inherit (&pTool);
cAntennaTester.ChangeHWDescription ( pHWFile );
cAntennaTester.ChangeSettings ( pHWFile );
cAntennaTester.ConfigureHw();
//cAntennaTester.Initialize();
cAntennaTester.ConfigureHw(outp);
LOG (INFO) << outp.str();
cAntennaTester.Initialize();
// re-configure CBC regsiters with values from the calibration
//cAntennaTester.ReconfigureCBCRegisters();
cAntennaTester.ReconfigureCBCRegisters();
cAntennaTester.ConfigureVcth(0x78);
// measure occupancy
//cAntennaTester.Measure();
cAntennaTester.Measure();
// save results
// cAntennaTester.SaveResults();
cAntennaTester.SaveResults();
//char line[120];
//sprintf(line, "# Top Pad Occupancy = %.2f ± %.3f" , cHybridTester.GetMeanOccupancyTop() , cHybridTester.GetRMSOccupancyTop() );
//cHybridTester.AmmendReport(line);
......@@ -497,18 +508,20 @@ int main ( int argc, char* argv[] )
Timer tGlobal;
tGlobal.start();
Timer t;
// try and choose the hardware description files for the hybrid testers according to the number of CBCs
//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
std::stringstream outp;
Tool cTool;
cTool.InitializeHw ( cHWFile );
cTool.InitializeSettings ( cHWFile );
cTool.InitializeHw ( cHWFile , outp );
cTool.InitializeSettings ( cHWFile , outp );
cTool.CreateResultDirectory ( cDirectory );
cTool.InitResultFile ( "Summary" );
cTool.StartHttpServer();
cTool.ConfigureHw();
cTool.ConfigureHw(outp );
cTool.CreateReport();
LOG (INFO) << outp.str();
char line[120];
// perform current consumption test if --checkCurrents flag set in arguments passed to tester
if( cCurrents )
......@@ -576,8 +589,8 @@ int main ( int argc, char* argv[] )
// look for shorts on the DUT if --checkShorts flag set in arguments passed to tester
if( cShorts )
{
// if calibrate flag has not been set then make sure that the calibration is done before the occupancy
// measurement is performed!
//if calibrate flag has not been set then make sure that the calibration is done before the occupancy
//measurement is performed!
if( !cCalibrate)
{
LOG (INFO) << GREEN << "Calibrating CBCs before starting antenna test of the CBCs on the DUT." << rst ;
......@@ -591,7 +604,7 @@ int main ( int argc, char* argv[] )
}
LOG (INFO) << "Starting short(s) test." ;
cHWFile = "settings/HWDescription_" + std::to_string(cNumCBCs) + "CBC.xml";
cHWFile = "settings/HybridTest" + std::to_string(cNumCBCs) + "CBC.xml";
t.start();
bool shortFinder_passed = check_Shorts(cTool , cHWFile , cMaxNumShorts);
t.stop();
......@@ -628,7 +641,7 @@ int main ( int argc, char* argv[] )
cTool.AmmendReport( line);
t.show ( "Calibration of the DUT" );
}
cHWFile = "settings/HWDescription_" + std::to_string(cNumCBCs) + "CBC.xml";
cHWFile = "settings/HybridTest" + std::to_string(cNumCBCs) + "CBC.xml";
t.start();
perform_OccupancyMeasurment(cTool , cHWFile);
t.stop();
......@@ -642,8 +655,8 @@ int main ( int argc, char* argv[] )
if( cAntennaMeasurement )
{
// if calibrate flag has not been set then make sure that the calibration is done before the occupancy
// measurement is performed!
//if calibrate flag has not been set then make sure that the calibration is done before the occupancy
//measurement is performed!
if( !cCalibrate)
{
LOG (INFO) << GREEN << "Calibrating CBCs before starting antenna test of the CBCs on the DUT." << rst ;
......@@ -656,7 +669,7 @@ int main ( int argc, char* argv[] )
t.show ( "Calibration of the DUT" );
}
cHWFile = "settings/HWDescription_" + std::to_string(cNumCBCs) + "CBC.xml";
cHWFile = "settings/HybridTest" + std::to_string(cNumCBCs) + "CBC.xml";
t.start();
perform_AntennaOccupancyMeasurement(cTool , cHWFile);
t.stop();
......@@ -671,7 +684,7 @@ int main ( int argc, char* argv[] )
cTool.AmmendReport( line);
// have to destroy the tool at the end of the program
cTool.SaveResults();
//cTool.SaveResults(); // if this is here then you end up with 2 copies of all histograms and canvases in the root file ... so I've removed it
cTool.CloseResultFile();
cTool.Destroy();
}
......
......@@ -29,6 +29,9 @@ struct HistogramFiller : public HwDescriptionVisitor
void AntennaTester::Initialize()
{
gStyle->SetOptStat( 000000 );
fDataCanvas = new TCanvas( "fAntennaDataCanvas", "SingleStripEfficiency (w/ Antenna)", 1200, 800 );
fDataCanvas->Divide( 2 );
InitialiseSettings();
InitializeHists();
......@@ -134,13 +137,17 @@ void AntennaTester::writeGraphs()
{
fResultFile->cd();
UpdateHistsMerged();
fDataCanvas->Write ( fDataCanvas->GetName(), TObject::kOverwrite );
}
void AntennaTester::SaveResults()
{
LOG (INFO) << BOLDBLUE << "Results of Antenna scan written to " << fDirectoryName + "/Summary.root" << RESET;
writeGraphs();
//writeGraphs();
fResultFile->cd();
UpdateHistsMerged();
fHistTop->Write( fHistTop->GetName(), TObject::kOverwrite );
fHistBottom->Write( fHistBottom->GetName(), TObject::kOverwrite );
fDataCanvas->Write ( fDataCanvas->GetName(), TObject::kOverwrite );
LOG (INFO) << BOLDBLUE << "Results of Antenna scan written to " << fDirectoryName + "/Summary.root" << RESET;
}
......@@ -218,16 +225,18 @@ void AntennaTester::Measure()
}
}
fHistTopMerged->Scale( 100 / double_t( fTotalEvents ) );
fHistTopMerged->GetYaxis()->SetRangeUser( 0, 100 );
fHistBottomMerged->Scale( 100 / double_t( fTotalEvents ) );
fHistBottomMerged->GetYaxis()->SetRangeUser( 0, 100 );
UpdateHistsMerged();
cAntenna.close();
#endif
fHistTopMerged->Scale( 100 / double_t( fTotalEvents ) );
fHistTopMerged->GetYaxis()->SetRangeUser( 0, 100 );
fHistBottomMerged->Scale( 100 / double_t( fTotalEvents ) );
fHistBottomMerged->GetYaxis()->SetRangeUser( 0, 100 );
UpdateHistsMerged();
LOG (INFO) << BOLDGREEN << "Mean occupancy (measured w/ antenna) for the Top side: " << GetMeanOccupancyTop() << "%." << RESET ;
LOG (INFO) << BOLDGREEN << "Mean occupancy (measured w/ antenna) for the Botton side: " << GetMeanOccupancyBottom() << "%." << RESET ;
//TestChannels( fDecisionThreshold );
}
\ No newline at end of file
......@@ -54,6 +54,19 @@ class AntennaTester : public Tool
// function to reconfigure the CBC registers
// if pDirectoryName == "" then the values from the CBC calibration found in the Results directory (fDirectoryName) are used
void ReconfigureCBCRegisters(std::string pDirectoryName = "");
// configure only the Vcth value
void ConfigureVcth( uint8_t pVcth = 0x78 ){ CbcRegWriter cWriter ( fCbcInterface, "VCth", pVcth ); accept ( cWriter );};
/*!
*\brief return mean occupancy for (TOP) pads
*/
double GetMeanOccupancyTop(){return fHistTop->Integral()/(double)(fNCbc*127) ;};
/*!
*\brief return mean occupancy for (BOTTOM) pads
*/
double GetMeanOccupancyBottom(){return fHistBottom->Integral()/(double)(fNCbc*127) ;};
void SaveResults();
private :
......
......@@ -494,6 +494,24 @@ void Calibration::toggleOffset ( uint8_t pGroup, uint8_t pBit, bool pBegin )
}
}
// void Calibration::normalizeHists()
// {
// std::string cHistName = "Occupancy";
// for ( const auto& cCbc : fCbcHistMap )
// {
// // loop the map of string vs TObject
// auto cHist = cCbc.second.find ( cHistName );
// if ( cHist != std::end ( cCbc.second ) )
// {
// fOffsetCanvas->cd ( cCbc.first->getCbcId() + 1 );
// TH1F* cTmpHist = static_cast<TH1F*> ( cHist->second );
// cTmpHist->Scale(100.0/(fEventsPerPoint*3));
// cTmpHist->DrawCopy();
// }
// else LOG (INFO) << "Error, could not find Histogram with name " << cHistName ;
// }
// }
void Calibration::updateHists ( std::string pHistname )
{
// loop the CBCs
......@@ -568,6 +586,8 @@ void Calibration::writeGraphs()
{
fResultFile->cd();
// n
// Save hist maps for CBCs
//
//Tool::SaveResults();
......
......@@ -52,6 +52,7 @@ class Calibration : public Tool
void Initialise( bool pAllChan = false );
void FindVplus();
// offsets are found by taking pMultiple*fEvents triggers
void FindOffsets();
void SaveResults() {
writeGraphs();
......@@ -84,6 +85,10 @@ class Calibration : public Tool
void updateHists( std::string pHistname );
// normalize occupancy histograms : offsets were found by taking pMultiple*fEvents triggers
// therefore the normalization factor is 100./(pMultiple*fEventsPerPoint)
void normalizeHists();
void writeGraphs();
......
......@@ -75,7 +75,7 @@ void HybridTester::ReconfigureCBCRegisters(std::string pDirectoryName )
pRegFile = buffer;
cCbc->loadfRegMap(pRegFile);
fCbcInterface->ConfigureCbc ( cCbc );
std::cout << GREEN << "\t\t Successfully reconfigured CBC" << int ( cCbc->getCbcId() ) << "'s regsiters from " << pRegFile << " ." << RESET << std::endl;
LOG (INFO) << GREEN << "\t\t Successfully reconfigured CBC" << int ( cCbc->getCbcId() ) << "'s regsiters from " << pRegFile << " ." << RESET ;
}
}
......@@ -1246,9 +1246,9 @@ void HybridTester::SaveResults()
fHistOccupancyBottom->Write( fHistOccupancyBottom->GetName(), TObject::kOverwrite );
fSummaryCanvas->Write( fSummaryCanvas->GetName(), TObject::kOverwrite );
fResultFile->Write();
fResultFile->Close();
LOG (INFO) << std::endl << "Resultfile written correctly!" ;
//fResultFile->Write();
//fResultFile->Close();
LOG (INFO) << BOLDBLUE << "Results of occupancy measured written to " << fDirectoryName + "/Summary.root" << RESET ;
std::string cPdfName = fDirectoryName + "/HybridTestResults.pdf";
fDataCanvas->SaveAs( cPdfName.c_str() );
......
......@@ -120,10 +120,15 @@ class HybridTester : public Tool
*/
void SaveResults();
void ReconfigureCBCRegisters(std::string pDirectoryName = "");
/*!
* \brief re-configure only the Vcth value on the CBCs
*/
void ConfigureVcth( uint8_t pVcth = 0x78 ){ CbcRegWriter cWriter ( fCbcInterface, "VCth", pVcth ); accept ( cWriter ); };
void DisplayNoisyChannels(std::ostream& os = std::cout );
void DisplayDeadChannels(std::ostream& os = std::cout );
private:
uint32_t fNCbc; /*!< Number of CBCs in the Setup */
TCanvas* fDataCanvas; /*!<Canvas to output single-strip efficiency */
......
......@@ -26,6 +26,65 @@ struct HistogramFiller : public HwDescriptionVisitor
}
};
//Reload CBC registers from file found in results (fDirectoryName) directory .
//If no directory is found use the default files for the different operational modes found in Ph2_ACF/settings
void ShortFinder::ReconfigureRegisters()
{
bool cCheck;
bool cHoleMode;
auto cSetting = fSettingsMap.find ( "HoleMode" );
if ( cSetting != std::end ( fSettingsMap ) )
{
cCheck = true;
cHoleMode = ( cSetting->second == 1 ) ? true : false;
}
std::string cMode;
if ( cCheck )
{
if ( cHoleMode ) cMode = "hole";
else cMode = "electron";
}
for (auto& cBoard : fBoardVector)
{
fBeBoardInterface->CbcHardReset ( cBoard );
for (auto& cFe : cBoard->fModuleVector)
{
for (auto& cCbc : cFe->fCbcVector)
{
std::string pRegFile ;
if( fDirectoryName.empty() )
{
pRegFile = "settings/Cbc_default_" + cMode + ".txt";
}
else
{
char buffer[120];
sprintf(buffer, "%s/FE%dCBC%d.txt" , fDirectoryName.c_str() , cCbc->getFeId(), cCbc->getCbcId() );
pRegFile = buffer;
}
cCbc->loadfRegMap(pRegFile);
fCbcInterface->ConfigureCbc ( cCbc );
LOG (INFO) <<GREEN << "\t\t Successfully (re)configured CBC" << int ( cCbc->getCbcId() ) << "'s regsiters from " << pRegFile << " ." << RESET;
}
}
//CbcFastReset as per recommendation of Mark Raymond
fBeBoardInterface->CbcFastReset ( cBoard );
}
}
void ShortFinder::ConfigureVcth(uint8_t pVcth)
{
CbcRegWriter cWriter ( fCbcInterface, "VCth", pVcth );
accept ( cWriter );
}
void ShortFinder::writeGraphs()
{
fResultFile->cd();
......
......@@ -52,6 +52,13 @@ class ShortFinder : public Tool
// D'tor
~ShortFinder() {};
///Reload CBC registers from file found in results (fDirectoryName) directory .
//If no directory is found use the default files for the different operational modes found in Ph2_ACF/settings
void ReconfigureRegisters();
// configure only the Vcth value
void ConfigureVcth( uint8_t pVcth = 0x78 );
void Initialize();
void FindShorts(std::ostream& os = std::cout );
......
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