Commit 69269ed9 authored by Sarah Seif El Nasr's avatar Sarah Seif El Nasr
Browse files

Hacked CMnoise

parent 15ea401b
Pipeline #3519639 failed with stages
in 10 minutes and 16 seconds
......@@ -606,13 +606,13 @@ void DQMHistogramPedeNoise::fitSCurves()
// Get rough midpoint & width
double cMid = (cFirst1 + cFirstNon0) * 0.5;
double cWidth = (cFirst1 - cFirstNon0) * 0.5;
// double cWidth = (cFirst1 - cFirstNon0) * 0.5;
cFit->SetParameter(0, cMid);
cFit->SetParameter(1, cWidth);
cFit->SetParameter(1, 8.);
// Fit
channelSCurve->Fit(cFit, "RQ+0");
channelSCurve->Fit(cFit, "RQ+");
theChipThresholdAndNoise->getChannel<ThresholdAndNoise>(cChannel).fThreshold = cFit->GetParameter(0);
theChipThresholdAndNoise->getChannel<ThresholdAndNoise>(cChannel).fNoise = cFit->GetParameter(1);
......
......@@ -20,7 +20,6 @@
#include <time.h>
#include <uhal/uhal.hpp>
#include <algorithm>
uint8_t cLpGBTI2CHack = true;
// #pragma GCC diagnostic ignored "-Wpedantic"
using namespace Ph2_HwDescription;
......@@ -5845,7 +5844,7 @@ bool D19cFWInterface::WriteFERegister(Ph2_HwDescription::Chip* pChip, uint16_t p
std::lock_guard<std::recursive_mutex> theGuard(fMutex);
auto cLinkId = pChip->getOpticalId();
uint8_t cMasterId = ((pChip->getHybridId() % 2) == 0) ? 2 : 0;
if(cLpGBTI2CHack && cMasterId == 0) cMasterId = 1;
if(fLpGBTI2CHack && cMasterId == 0) cMasterId = 1;
// LOG (INFO) << BOLDGREEN << "Writing FE register on link " << +cLinkId << RESET;
LOG(DEBUG) << BOLDBLUE << " Writing 0x" << std::hex << +pRegisterValue << std::dec << " to [0x" << std::hex << +pRegisterAddress << std::dec << "]" << RESET;
......@@ -5922,7 +5921,7 @@ uint8_t D19cFWInterface::ReadFERegister(Ph2_HwDescription::Chip* pChip, uint16_t
std::lock_guard<std::recursive_mutex> theGuard(fMutex);
auto cLinkId = pChip->getOpticalId();
uint8_t cMasterId = ((pChip->getHybridId() % 2) == 0) ? 2 : 0;
if(cLpGBTI2CHack && cMasterId == 0) cMasterId = 1;
if(fLpGBTI2CHack && cMasterId == 0) cMasterId = 1;
// LOG (INFO) << BOLDGREEN << "Reading FE register on link " << +cLinkId << RESET;
uint8_t cChipId = (pChip->getFrontEndType() == FrontEndType::CIC || pChip->getFrontEndType() == FrontEndType::CIC2) ? 0 : pChip->getId();
......
......@@ -137,7 +137,11 @@ class D19cFWInterface : public BeBoardFWInterface
int fResetAttempts;
void Align_out();
bool fLpGBTI2CHack = false;
public:
void useI2CPatch(bool use = true) {fLpGBTI2CHack = use;}
/*!
*
* \brief Constructor of the Cbc3Fc7FWInterface class
......
......@@ -179,8 +179,14 @@ void FileParser::parseBeBoard(pugi::xml_node pBeBordNode, BeBoardFWMap& pBeBoard
std::string cId = cBeBoardConnectionNode.attribute("id").value();
std::string cUri = cBeBoardConnectionNode.attribute("uri").value();
std::string cAddressTable = expandEnvironmentVariables(cBeBoardConnectionNode.attribute("address_table").value());
bool useI2Cpatch = false;
if(cBeBoardConnectionNode.attribute("useI2Cpatch")) useI2Cpatch = cBeBoardConnectionNode.attribute("useI2Cpatch").as_int();
if(cBeBoard->getBoardType() == BoardType::D19C) { pBeBoardFWMap[cBeBoard->getId()] = new D19cFWInterface(cId.c_str(), cUri.c_str(), cAddressTable.c_str()); }
if(cBeBoard->getBoardType() == BoardType::D19C)
{
pBeBoardFWMap[cBeBoard->getId()] = new D19cFWInterface(cId.c_str(), cUri.c_str(), cAddressTable.c_str());
static_cast<D19cFWInterface*>(pBeBoardFWMap[cBeBoard->getId()])->useI2CPatch(useI2Cpatch);
}
else if(cBeBoard->getBoardType() == BoardType::RD53)
pBeBoardFWMap[cBeBoard->getId()] = new RD53FWInterface(cId.c_str(), cUri.c_str(), cAddressTable.c_str());
......
......@@ -2,7 +2,7 @@
<HwDescription>
<BeBoard Id="0" boardType="D19C" eventType="VR2S" linkReset="1">
<!-- B598 skeleton -->
<connection id="board" uri="chtcp-2.0://localhost:10203?target=192.168.0.12:50001" address_table="file://settings/address_tables/uDTC_OT_address_table.xml" />
<connection id="board" uri="chtcp-2.0://localhost:10203?target=192.168.0.12:50001" address_table="file://settings/address_tables/uDTC_OT_address_table.xml" useI2Cpatch="0"/>
<CDCE configure="0" clockRate="320"/>
<OpticalGroup Id="0" FMCId="0">
......@@ -193,11 +193,11 @@
<Settings>
<!--PedestalEqualization-->
<Setting name="Nevents">100</Setting>
<Setting name="Nevents">10000</Setting>
<Setting name="HoleMode">0</Setting>
<Setting name="VerificationLoop">1</Setting>
<Setting name="MaskChannelsFromOtherGroups">0</Setting>
<Setting name="FitSCurves">0</Setting>
<Setting name="FitSCurves">1</Setting>
<Setting name="PlotSCurves">1</Setting>
<Setting name="PedestalEqualizationPulseAmplitude">0</Setting>
<Setting name="PedeNoisePulseAmplitude">0</Setting>
......
......@@ -172,7 +172,8 @@ int main(int argc, char* argv[])
}
else
{
cVisitor.setThreshold(cManualVcth);
cTool.setSameDac("Threshold", cManualVcth);
// cVisitor.setThreshold(cManualVcth);
cTool.accept(cVisitor); // Do this for all CBCs
LOG(INFO) << BOLDRED << "CBC" << i << ": set threshold manually to " << cManualVcth << RESET;
}
......
......@@ -788,6 +788,12 @@ int main(int argc, char* argv[])
cShortFinder.waitForRunToBeCompleted();
cShortFinder.Stop();
}
do
{
std::cout << '\n' << "Press a key to continue...";
} while (std::cin.get() != '\n');
cTool.PrintRegCount();
cTool.dumpConfigFiles();
cTool.SaveResults();
......
This diff is collapsed.
......@@ -121,6 +121,7 @@ void Tool::Inherit(const Tool* pTool)
fChipHistMap = pTool->fChipHistMap;
fHybridHistMap = pTool->fHybridHistMap;
fBeBoardHistMap = pTool->fBeBoardHistMap;
fOpticalGroupHistMap = pTool->fOpticalGroupHistMap;
#endif
fTestGroupChannelMap = pTool->fTestGroupChannelMap;
fSkipMaskedChannels = pTool->fSkipMaskedChannels;
......@@ -211,6 +212,16 @@ void Tool::SoftDestroy()
}
}
fBeBoardHistMap.clear();
for(auto chip: fOpticalGroupHistMap)
{
for(auto hist: chip.second)
{
delete hist.second;
hist.second = nullptr;
}
}
fOpticalGroupHistMap.clear();
#endif
fTestGroupChannelMap.clear();
}
......@@ -304,6 +315,34 @@ void Tool::bookHistogram(HybridContainer* pHybrid, std::string pName, TObject* p
#endif
}
void Tool::bookHistogram(OpticalGroupContainer* opticalGroup, std::string pName, TObject* pObject)
{
TH1* tmpHistogramPointer = dynamic_cast<TH1*>(pObject);
if(tmpHistogramPointer != nullptr) tmpHistogramPointer->SetDirectory(0);
// find or create map<string,TOBject> for specific CBC
auto cBeBoardHistMap = fOpticalGroupHistMap.find(opticalGroup);
if(cBeBoardHistMap == std::end(fOpticalGroupHistMap))
{
LOG(INFO) << "Histo Map for Hybrid " << int(opticalGroup->getId()) << " does not exist - creating ";
std::map<std::string, TObject*> cTempHybridMap;
fOpticalGroupHistMap[opticalGroup] = cTempHybridMap;
cBeBoardHistMap = fOpticalGroupHistMap.find(opticalGroup);
}
// find histogram with given name: if it exists, delete the object, if not create
auto cHisto = cBeBoardHistMap->second.find(pName);
if(cHisto != std::end(cBeBoardHistMap->second)) cBeBoardHistMap->second.erase(cHisto);
cBeBoardHistMap->second[pName] = pObject;
#ifdef __HTTP__
if(fHttpServer) fHttpServer->Register("/Histograms", pObject);
#endif
}
void Tool::bookHistogram(BoardContainer* pBeBoard, std::string pName, TObject* pObject)
{
TH1* tmpHistogramPointer = dynamic_cast<TH1*>(pObject);
......@@ -402,6 +441,31 @@ TObject* Tool::getHist(BoardContainer* pBeBoard, std::string pName)
}
}
TObject* Tool::getHist(OpticalGroupContainer* opticalGroup, std::string pName)
{
auto cBeBoardHistMap = fOpticalGroupHistMap.find(opticalGroup);
if(cBeBoardHistMap == std::end(fOpticalGroupHistMap))
{
LOG(ERROR) << RED << "Error: could not find the Histograms for Hybrid " << int(opticalGroup->getId()) << RESET;
return nullptr;
}
else
{
auto cHisto = cBeBoardHistMap->second.find(pName);
if(cHisto == std::end(cBeBoardHistMap->second))
{
LOG(ERROR) << RED << "Error: could not find the Histogram with the name " << pName << RESET;
return nullptr;
}
else
return cHisto->second;
}
}
void Tool::WriteRootFile()
{
if((fResultFile != nullptr) && (fResultFile->IsOpen() == true)) fResultFile->Write();
......@@ -420,6 +484,16 @@ void Tool::SaveResults()
fResultFile->cd();
}
for(const auto& cOpticalGroup: fOpticalGroupHistMap)
{
fResultFile->cd();
for(const auto& cHist: cOpticalGroup.second) cHist.second->Write(cHist.second->GetName(), TObject::kOverwrite);
fResultFile->cd();
}
// Now per FE
for(const auto& cHybrid: fHybridHistMap)
{
......
......@@ -49,6 +49,7 @@ class Tool : public Ph2_System::SystemController
using ChipHistogramMap = std::map<ChipContainer*, std::map<std::string, TObject*>>;
using HybridHistogramMap = std::map<HybridContainer*, std::map<std::string, TObject*>>;
using BeBoardHistogramMap = std::map<BoardContainer*, std::map<std::string, TObject*>>;
using OpticalGroupHistMap = std::map<OpticalGroupContainer*, std::map<std::string, TObject*>>;
using CanvasMap = std::map<BaseContainer*, TCanvas*>;
#endif
......@@ -84,10 +85,12 @@ class Tool : public Ph2_System::SystemController
void fillSummaryTree(TString cParameter, Double_t cValue);
void bookHistogram(ChipContainer* pChip, std::string pName, TObject* pObject);
void bookHistogram(HybridContainer* pHybrid, std::string pName, TObject* pObject);
void bookHistogram(OpticalGroupContainer* pOpticalGroup, std::string pName, TObject* pObject);
void bookHistogram(BoardContainer* pBeBoard, std::string pName, TObject* pObject);
TObject* getHist(ChipContainer* pChip, std::string pName);
TObject* getHist(HybridContainer* pHybrid, std::string pName);
TObject* getHist(OpticalGroupContainer* pOpticalGroup, std::string pName);
TObject* getHist(BoardContainer* pBeBoard, std::string pName);
void WriteRootFile();
......@@ -355,6 +358,7 @@ class Tool : public Ph2_System::SystemController
ChipHistogramMap fChipHistMap;
HybridHistogramMap fHybridHistMap;
BeBoardHistogramMap fBeBoardHistMap;
OpticalGroupHistMap fOpticalGroupHistMap;
TTree* fSummaryTree; /*< TTree for summary of results*/
static TString fSummaryTreeParameter;
static Double_t fSummaryTreeValue;
......
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