From 3ee022a5404370d1c9742475445abe74e2a9ba42 Mon Sep 17 00:00:00 2001 From: Fabio Ravera <fabio.ravera@cern.ch> Date: Wed, 17 Jan 2024 11:51:08 -0600 Subject: [PATCH 1/2] Improved runCalibration help message --- MessageUtils | 2 +- miniDAQ/CombinedCalibrationFactory.cc | 76 ++++++++++--------- miniDAQ/CombinedCalibrationFactory.h | 63 +++++++++++++-- miniDAQ/MiddlewareMessageHandler.cc | 18 ++++- .../templateCalibrationHeader.txt | 2 + .../templateCalibrationImplementation.txt | 2 + pythonUtils/Ph2_ACF_StateMachine.py | 16 +++- pythonUtils/PythonController.py | 12 ++- src/runCalibration.cc | 19 ++++- src/supervisor.cc | 17 ++++- src/testShep.cc | 2 - tools/CBCPulseShape.cc | 2 + tools/CBCPulseShape.h | 2 + tools/CalibrationExample.cc | 2 + tools/CalibrationExample.h | 2 + tools/ConfigureOnly.cc | 7 +- tools/ConfigureOnly.h | 2 + tools/LatencyScan.cc | 2 + tools/LatencyScan.h | 2 + tools/OTTemperature.cc | 2 + tools/OTTemperature.h | 2 + tools/OTalignLpGBTinputs.cc | 2 + tools/OTalignLpGBTinputs.h | 2 + tools/PSPhysics.cc | 2 + tools/PSPhysics.h | 2 + tools/PedeNoise.cc | 2 + tools/PedeNoise.h | 2 + tools/PedestalEqualization.cc | 2 + tools/PedestalEqualization.h | 2 + tools/Physics2S.cc | 2 + tools/Physics2S.h | 2 + tools/TuneLpGBTVref.cc | 2 + tools/TuneLpGBTVref.h | 2 + 33 files changed, 221 insertions(+), 57 deletions(-) diff --git a/MessageUtils b/MessageUtils index 5d849e267..0bab9baf5 160000 --- a/MessageUtils +++ b/MessageUtils @@ -1 +1 @@ -Subproject commit 5d849e2670a7fa06c5fdad2dfc95605a6a6db3a2 +Subproject commit 0bab9baf522e3aa119a3cbd30b1d003ca59d2ed5 diff --git a/miniDAQ/CombinedCalibrationFactory.cc b/miniDAQ/CombinedCalibrationFactory.cc index f1869b22b..9a99d02d0 100644 --- a/miniDAQ/CombinedCalibrationFactory.cc +++ b/miniDAQ/CombinedCalibrationFactory.cc @@ -40,47 +40,51 @@ using namespace MessageUtils; CombinedCalibrationFactory::CombinedCalibrationFactory() { // Common calibrations - Register<TuneLpGBTVref>("tunelpgbtvref"); - Register<ConfigureOnly>("configureonly"); + Register<TuneLpGBTVref>("Common", "tunelpgbtvref"); + Register<ConfigureOnly>("Common", "configureonly"); // OT calibrations - Register<OTVTRXLightOff>("vtrxoff"); - Register<OTalignLpGBTinputs>("OTalignLpGBTinputs"); - Register<LinkAlignmentOT, CicFEAlignment>("alignment"); - Register<LinkAlignmentOT, CicFEAlignment, PedestalEqualization>("calibration"); - Register<LinkAlignmentOT, CicFEAlignment, PedestalEqualization, BeamTestCheck>("takedata"); // will be used in future version of GIPHT - Register<LinkAlignmentOT, CicFEAlignment, PedestalEqualization, KIRA>("calibrationandkira"); - Register<LinkAlignmentOT, CicFEAlignment, PedestalEqualization, PedeNoise, KIRA>("calibrationandpedenoiseandkira"); // will be used in future version of GIPHT - Register<OTTemperature, PSAlignment, LinkAlignmentOT, CicFEAlignment, PedeNoise, OTTemperature>("pedenoise"); - Register<TuneLpGBTVref, OTTemperature, PSAlignment, LinkAlignmentOT, CicFEAlignment, PedestalEqualization, PedeNoise, OTTemperature>("calibrationandpedenoise"); - Register<LinkAlignmentOT, CicFEAlignment, CalibrationExample>("calibrationexample"); - Register<LinkAlignmentOT, CicFEAlignment, CBCPulseShape>("cbcpulseshape"); - Register<LinkAlignmentOT, CicFEAlignment, LatencyScan>("otlatency"); + Register<OTVTRXLightOff>("Outer Tracker", "vtrxoff"); + Register<OTalignLpGBTinputs>("Outer Tracker", "OTalignLpGBTinputs"); + Register<LinkAlignmentOT, CicFEAlignment>("Outer Tracker", "alignment"); + Register<LinkAlignmentOT, CicFEAlignment, PedestalEqualization>("Outer Tracker", "calibration"); + Register<LinkAlignmentOT, CicFEAlignment, PedestalEqualization, BeamTestCheck>("Outer Tracker", "takedata"); // will be used in future version of GIPHT + Register<LinkAlignmentOT, CicFEAlignment, PedestalEqualization, KIRA>("Outer Tracker", "calibrationandkira"); + Register<LinkAlignmentOT, CicFEAlignment, PedestalEqualization, PedeNoise, KIRA>("Outer Tracker", "calibrationandpedenoiseandkira"); // will be used in future version of GIPHT + Register<OTTemperature, PSAlignment, LinkAlignmentOT, CicFEAlignment, PedeNoise, OTTemperature>("Outer Tracker", "pedenoise"); + Register<TuneLpGBTVref, OTTemperature, PSAlignment, LinkAlignmentOT, CicFEAlignment, PedestalEqualization, PedeNoise, OTTemperature>("Outer Tracker", "calibrationandpedenoise"); + Register<LinkAlignmentOT, CicFEAlignment, CalibrationExample>("Outer Tracker", "calibrationexample"); + Register<LinkAlignmentOT, CicFEAlignment, LatencyScan>("Outer Tracker", "otlatency"); + + // 2S specific calibrations + Register<LinkAlignmentOT, CicFEAlignment, CBCPulseShape>("2S Module", "cbcpulseshape"); + Register<Physics2S>("2S Module", "physics2s"); + + // PS specific calibrations + Register<PSPhysics>("PS Module", "psphysics"); // IT calibrations - Register<PixelAlive>("pixelalive"); - Register<PixelAlive>("noise"); - Register<SCurve>("scurve"); - Register<Gain>("gain"); - Register<GainOptimization>("gainopt"); - Register<ThrEqualization>("threqu"); - Register<ThrMinimization>("thrmin"); - Register<ThrAdjustment>("thradj"); - Register<Latency>("latency"); - Register<InjectionDelay>("injdelay"); - Register<ClockDelay>("clockdelay"); - Register<Physics>("physics"); - Register<PSPhysics>("psphysics"); - Register<Physics2S>("physics2s"); - Register<DataTransmissionTest>("datatrtest"); + Register<PixelAlive>("Inner Tracker", "pixelalive"); + Register<PixelAlive>("Inner Tracker", "noise"); + Register<SCurve>("Inner Tracker", "scurve"); + Register<Gain>("Inner Tracker", "gain"); + Register<GainOptimization>("Inner Tracker", "gainopt"); + Register<ThrEqualization>("Inner Tracker", "threqu"); + Register<ThrMinimization>("Inner Tracker", "thrmin"); + Register<ThrAdjustment>("Inner Tracker", "thradj"); + Register<Latency>("Inner Tracker", "latency"); + Register<InjectionDelay>("Inner Tracker", "injdelay"); + Register<ClockDelay>("Inner Tracker", "clockdelay"); + Register<Physics>("Inner Tracker", "physics"); + Register<DataTransmissionTest>("Inner Tracker", "datatrtest"); } CombinedCalibrationFactory::~CombinedCalibrationFactory() { - for(auto& element: fCalibrationMap) + for(auto& calibrationListPerHardware : fCalibrationMap) { - delete element.second; - element.second = nullptr; + delete calibrationListPerHardware.second.second; + calibrationListPerHardware.second.second = nullptr; } fCalibrationMap.clear(); } @@ -89,7 +93,7 @@ Tool* CombinedCalibrationFactory::createCombinedCalibration(const std::string& c { try { - return fCalibrationMap.at(calibrationName)->Create(); + return fCalibrationMap.at(calibrationName).second->Create(); } catch(const std::exception& theException) { @@ -100,10 +104,10 @@ Tool* CombinedCalibrationFactory::createCombinedCalibration(const std::string& c return nullptr; } -std::vector<std::string> CombinedCalibrationFactory::getAvailableCalibrations() const +std::map<std::string, std::map<std::string, std::vector<std::pair<std::string, std::string>>>> CombinedCalibrationFactory::getAvailableCalibrations() const { - std::vector<std::string> listOfCalibrations; + std::map<std::string, std::map<std::string, std::vector<std::pair<std::string, std::string>>>> listOfCalibrations; - for(const auto& element: fCalibrationMap) { listOfCalibrations.emplace_back(element.first); } + for(const auto& element: fCalibrationMap) { listOfCalibrations[element.second.first][element.first] = element.second.second->fSubCalibrationAndDescriptionList; } return listOfCalibrations; } diff --git a/miniDAQ/CombinedCalibrationFactory.h b/miniDAQ/CombinedCalibrationFactory.h index c07160bbe..ebd03612a 100644 --- a/miniDAQ/CombinedCalibrationFactory.h +++ b/miniDAQ/CombinedCalibrationFactory.h @@ -14,13 +14,66 @@ class BaseCreator BaseCreator() {} virtual ~BaseCreator() {} virtual Tool* Create() const = 0; + std::vector<std::pair<std::string, std::string>> fSubCalibrationAndDescriptionList {}; }; +template<typename T> +std::string getClassName() +{ + int32_t status; + std::string className = abi::__cxa_demangle(typeid(T).name(), 0, 0, &status); + return className; +} + +namespace CombinedCalibrationFactory_detail +{ + template <typename> + struct sfinae_true : std::true_type{}; + + template <typename T> + static auto test_calibrationDescription(int) -> sfinae_true<decltype(T::fCalibrationDescription)>; + template <typename> + static auto test_calibrationDescription(long) -> std::false_type; +} + +template <typename T> +struct has_calibrationDescription : decltype(CombinedCalibrationFactory_detail::test_calibrationDescription<T>(0)) +{}; + +template<typename T, bool hasCalibrationDescription> +struct GetCalibrationDescription +{ + std::pair<std::string, std::string> operator()() {return std::make_pair(getClassName<T>(), "");} +}; + +template<typename T> +struct GetCalibrationDescription<T, true> +{ + std::pair<std::string, std::string> operator()() {return std::make_pair(getClassName<T>(), T::fCalibrationDescription);} +}; + +template<typename T> +void getFullDescription(std::vector<std::pair<std::string, std::string>>& theFullCalibrationDescription) +{ + GetCalibrationDescription<T, has_calibrationDescription<T>::value> theGetCalibrationDescription; + std::pair<std::string, std::string> theCalibrationDescription = theGetCalibrationDescription(); + theFullCalibrationDescription.push_back(theCalibrationDescription); +} + +template<typename T, typename U, typename... Args> +void getFullDescription(std::vector<std::pair<std::string, std::string>>& theFullCalibrationDescription) +{ + GetCalibrationDescription<T, has_calibrationDescription<T>::value> theGetCalibrationDescription; + std::pair<std::string, std::string> theCalibrationDescription = theGetCalibrationDescription(); + theFullCalibrationDescription.push_back(theCalibrationDescription); + getFullDescription<U, Args...>(theFullCalibrationDescription); +} + template <typename... Args> class Creator : public BaseCreator { public: - Creator() {} + Creator() {getFullDescription<Args...>(fSubCalibrationAndDescriptionList);} virtual ~Creator() {} Tool* Create() const override { return new CombinedCalibration<Args...>(); }; // ################################################## @@ -37,22 +90,22 @@ class CombinedCalibrationFactory ~CombinedCalibrationFactory(); template <typename... Args> - void Register(const std::string& calibrationTag) + void Register(const std::string& hardwareType, const std::string& calibrationTag) { if(fCalibrationMap.count(calibrationTag)) { std::cerr << "calibrationTag " << calibrationTag << " already exists, aborting..." << std::endl; abort(); } - fCalibrationMap[calibrationTag] = new Creator<Args...>; + fCalibrationMap[calibrationTag] = std::make_pair(hardwareType, new Creator<Args...>); } Tool* createCombinedCalibration(const std::string& calibrationName) const; - std::vector<std::string> getAvailableCalibrations() const; + std::map<std::string, std::map<std::string, std::vector<std::pair<std::string, std::string>>>> getAvailableCalibrations() const; private: - std::map<std::string, BaseCreator*> fCalibrationMap; + std::map<std::string, std::pair<std::string, BaseCreator*>> fCalibrationMap; }; #endif diff --git a/miniDAQ/MiddlewareMessageHandler.cc b/miniDAQ/MiddlewareMessageHandler.cc index e037e1f7c..06d2b27ce 100644 --- a/miniDAQ/MiddlewareMessageHandler.cc +++ b/miniDAQ/MiddlewareMessageHandler.cc @@ -170,7 +170,23 @@ std::string MiddlewareMessageHandler::calibrationList(const std::string& message MessageUtils::CalibrationListReplyMessage theCalibrationList; theCalibrationList.mutable_reply_type()->set_type(MessageUtils::ReplyType::SUCCESS); - for(const auto& theCalibrationPair: fMiddlewareStateMachine.getCombinedCalibrationFactory().getAvailableCalibrations()) { theCalibrationList.add_calibration(theCalibrationPair); } + for(const auto& calibrationHardware: fMiddlewareStateMachine.getCombinedCalibrationFactory().getAvailableCalibrations()) + { + auto theCalibrationPerHardwareTypeListMessage = theCalibrationList.add_calibrationperhardwaretype(); + theCalibrationPerHardwareTypeListMessage->set_hardwaretype(calibrationHardware.first); + + for(const auto& theCalibrationList : calibrationHardware.second) + { + auto theCalibrationListMessage = theCalibrationPerHardwareTypeListMessage->add_calibrationinfo(); + theCalibrationListMessage->set_calibrationname(theCalibrationList.first); + for(const auto& theSubCalibrationList : theCalibrationList.second) + { + auto theSubCalibrationListMessage = theCalibrationListMessage->add_subcalibrationinfo(); + theSubCalibrationListMessage->set_subcalibrationname(theSubCalibrationList.first); + theSubCalibrationListMessage->set_subcalibrationdescription(theSubCalibrationList.second); + } + } + } return serializeMessage(theCalibrationList); } diff --git a/pythonUtils/CalibrationTemplates/templateCalibrationHeader.txt b/pythonUtils/CalibrationTemplates/templateCalibrationHeader.txt index 3a946482c..fdbf2cee7 100644 --- a/pythonUtils/CalibrationTemplates/templateCalibrationHeader.txt +++ b/pythonUtils/CalibrationTemplates/templateCalibrationHeader.txt @@ -33,6 +33,8 @@ class CLASS_NAME_TEMPLATE : public Tool void Resume() override; void Reset(); + static std::string fCalibrationDescription; + private: // diff --git a/pythonUtils/CalibrationTemplates/templateCalibrationImplementation.txt b/pythonUtils/CalibrationTemplates/templateCalibrationImplementation.txt index e1bfa818b..7ac2d429e 100644 --- a/pythonUtils/CalibrationTemplates/templateCalibrationImplementation.txt +++ b/pythonUtils/CalibrationTemplates/templateCalibrationImplementation.txt @@ -5,6 +5,8 @@ using namespace Ph2_HwDescription; using namespace Ph2_HwInterface; using namespace Ph2_System; +std::string CLASS_NAME_TEMPLATE::fCalibrationDescription = "Insert brief calibration description here"; + CLASS_NAME_TEMPLATE::CLASS_NAME_TEMPLATE() : Tool() {} CLASS_NAME_TEMPLATE::~CLASS_NAME_TEMPLATE() {} diff --git a/pythonUtils/Ph2_ACF_StateMachine.py b/pythonUtils/Ph2_ACF_StateMachine.py index a1b42766c..7e565fc24 100644 --- a/pythonUtils/Ph2_ACF_StateMachine.py +++ b/pythonUtils/Ph2_ACF_StateMachine.py @@ -263,7 +263,17 @@ class StateMachine(object): return "FAILED" theCalibrationListReply = Reply.CalibrationListReplyMessage() theCalibrationListReply.ParseFromString(replyBuffer) - listOfCalibrations = [] - for calibration in theCalibrationListReply.calibration: - listOfCalibrations.append(calibration) + listOfCalibrations = {} + for calibrationPerHardware in theCalibrationListReply.calibrationPerHardwareType: + hardwareType = calibrationPerHardware.hardwareType + calibrationListPerHardware = {} + for calibration in calibrationPerHardware.calibrationInfo: + calibrationName = calibration.calibrationName + subCalibrationList = [] + for subCalibration in calibration.subCalibrationInfo: + subCalibrationName = subCalibration.subCalibrationName + subCalibrationDescription = subCalibration.subCalibrationDescription + subCalibrationList.append([subCalibrationName, subCalibrationDescription]) + calibrationListPerHardware[calibrationName] = subCalibrationList + listOfCalibrations[hardwareType] = calibrationListPerHardware return listOfCalibrations diff --git a/pythonUtils/PythonController.py b/pythonUtils/PythonController.py index 86ecc04df..85e0141c0 100644 --- a/pythonUtils/PythonController.py +++ b/pythonUtils/PythonController.py @@ -29,9 +29,17 @@ def getNewRunNumber(): ###########OPTIONS theStateMachine = Ph2_ACF_StateMachine.StateMachine() listOfCalibration = theStateMachine.getCalibrationList() + listOfCalibrationPrint = "" -for calibration in listOfCalibration: - listOfCalibrationPrint = listOfCalibrationPrint + calibration + "\n" +for hardwareType, calibrationListPerHardware in listOfCalibration.items(): + listOfCalibrationPrint = listOfCalibrationPrint + "--------------------------------------------------------------------------\n"; + listOfCalibrationPrint = listOfCalibrationPrint + "\033[1m\033[32m" + hardwareType + "\033[0m" + "\n" + for calibrationName, subCalibrationList in calibrationListPerHardware.items(): + listOfCalibrationPrint = listOfCalibrationPrint + "\033[1m\033[34m" + "\t" + calibrationName + "\033[0m" + "\n" + for subCalibration in subCalibrationList: + listOfCalibrationPrint = listOfCalibrationPrint + "\t\t" + subCalibration[0] + if subCalibration[1] != "": listOfCalibrationPrint = listOfCalibrationPrint + ": " + subCalibration[1] + listOfCalibrationPrint = listOfCalibrationPrint + "\n" parser = argparse.ArgumentParser(description='Command line parser of skim options', formatter_class=RawTextHelpFormatter) parser.add_argument('-f', dest='configurationFile', help='xml configuration file', required = True) diff --git a/src/runCalibration.cc b/src/runCalibration.cc index 94b237040..bd0ffcf15 100644 --- a/src/runCalibration.cc +++ b/src/runCalibration.cc @@ -88,8 +88,23 @@ int main(int argc, char* argv[]) cmd.defineOptionAlternative("file", "f"); std::string calibrationHelpMessage = "Calibration to run. List of available calibrations:\n"; - for(const auto& calibration: theMiddlewareStateMachine.getCombinedCalibrationFactory().getAvailableCalibrations()) calibrationHelpMessage += (calibration + "\n"); - + for(const auto& calibrationList : theMiddlewareStateMachine.getCombinedCalibrationFactory().getAvailableCalibrations()) + { + std::cout << "--------------------------------------------------------------------------" << std::endl; + std::cout << BOLDGREEN << calibrationList.first << RESET << std::endl; + for(const auto& calibration : calibrationList.second) + { + std::cout << BOLDBLUE << "\t" << calibration.first << RESET << std::endl; + for(const auto& subCalibration : calibration.second) + { + std::cout << "\t\t" << subCalibration.first; + if(subCalibration.second != "") std::cout << ": " << subCalibration.second; + std::cout << std::endl; + } + } + std::cout << "--------------------------------------------------------------------------" << std::endl; + } + cmd.defineOption("calibration", calibrationHelpMessage, ArgvParser::OptionRequiresValue | ArgvParser::OptionRequired); cmd.defineOptionAlternative("calibration", "c"); diff --git a/src/supervisor.cc b/src/supervisor.cc index 598494b49..09a12fc03 100644 --- a/src/supervisor.cc +++ b/src/supervisor.cc @@ -132,7 +132,22 @@ int main(int argc, char* argv[]) std::string calibrationHelpMessage = "Calibration to run. List of available calibrations:\n"; CombinedCalibrationFactory theCombinedCalibrationFactory; - for(const auto& calibration: theCombinedCalibrationFactory.getAvailableCalibrations()) calibrationHelpMessage += (calibration + "\n"); + for(const auto& calibrationList : theCombinedCalibrationFactory.getAvailableCalibrations()) + { + std::cout << "--------------------------------------------------------------------------" << std::endl; + std::cout << BOLDGREEN << calibrationList.first << RESET << std::endl; + for(const auto& calibration : calibrationList.second) + { + std::cout << BOLDBLUE << "\t" << calibration.first << RESET << std::endl; + for(const auto& subCalibration : calibration.second) + { + std::cout << "\t\t" << subCalibration.first; + if(subCalibration.second != "") std::cout << ": " << subCalibration.second; + std::cout << std::endl; + } + } + std::cout << "--------------------------------------------------------------------------" << std::endl; + } cmd.defineOption("calibration", calibrationHelpMessage, ArgvParser::OptionRequiresValue | ArgvParser::OptionRequired); cmd.defineOptionAlternative("calibration", "c"); diff --git a/src/testShep.cc b/src/testShep.cc index 72ed55960..2ee3a12f2 100644 --- a/src/testShep.cc +++ b/src/testShep.cc @@ -85,8 +85,6 @@ int main(int argc, char* argv[]) cmd.defineOptionAlternative("file", "f"); std::string calibrationHelpMessage = "Calibration to run. List of available calibrations:\n"; - // CombinedCalibrationFactory theCombinedCalibrationFactory; - // for(const auto& calibration: theCombinedCalibrationFactory.getAvailableCalibrations()) calibrationHelpMessage += (calibration + "\n"); cmd.defineOption("calibration", calibrationHelpMessage, ArgvParser::OptionRequiresValue | ArgvParser::OptionRequired); cmd.defineOptionAlternative("calibration", "c"); diff --git a/tools/CBCPulseShape.cc b/tools/CBCPulseShape.cc index 0847c599b..5816d1315 100644 --- a/tools/CBCPulseShape.cc +++ b/tools/CBCPulseShape.cc @@ -13,6 +13,8 @@ using namespace Ph2_HwDescription; using namespace Ph2_HwInterface; +std::string CBCPulseShape::fCalibrationDescription = "Run multiple SCurve with injection changing sampling point to reconstruct pulse shape"; + CBCPulseShape::CBCPulseShape() : PedeNoise() {} CBCPulseShape::~CBCPulseShape() {} diff --git a/tools/CBCPulseShape.h b/tools/CBCPulseShape.h index 1a8d1108e..f1627a7b2 100644 --- a/tools/CBCPulseShape.h +++ b/tools/CBCPulseShape.h @@ -32,6 +32,8 @@ class CBCPulseShape : public PedeNoise // State machine void Running() override; void Stop(void) override; + + static std::string fCalibrationDescription; private: uint16_t fInitialLatency{0}; diff --git a/tools/CalibrationExample.cc b/tools/CalibrationExample.cc index 7b9fcc7e6..b5325eed4 100644 --- a/tools/CalibrationExample.cc +++ b/tools/CalibrationExample.cc @@ -9,6 +9,8 @@ using namespace Ph2_HwDescription; using namespace Ph2_HwInterface; +std::string CalibrationExample::fCalibrationDescription = "Run a simple occupancy measurement"; + CalibrationExample::CalibrationExample() : Tool(), fEventsPerPoint(0) {} CalibrationExample::~CalibrationExample() {} diff --git a/tools/CalibrationExample.h b/tools/CalibrationExample.h index 992cd0d19..edbe1a0a3 100644 --- a/tools/CalibrationExample.h +++ b/tools/CalibrationExample.h @@ -35,6 +35,8 @@ class CalibrationExample : public Tool void Running() override; void Stop(void) override; + static std::string fCalibrationDescription; + private: uint32_t fEventsPerPoint; diff --git a/tools/ConfigureOnly.cc b/tools/ConfigureOnly.cc index a103ab11e..7e99d2b02 100644 --- a/tools/ConfigureOnly.cc +++ b/tools/ConfigureOnly.cc @@ -1,14 +1,13 @@ #include "tools/ConfigureOnly.h" #include "System/RegisterHelper.h" +std::string ConfigureOnly::fCalibrationDescription = "Run only configuration step"; + ConfigureOnly::ConfigureOnly() : Tool() {} ConfigureOnly::~ConfigureOnly() {} -void ConfigureOnly::Running() -{ - // fRegisterHelper->dumpBeBoardRegisterIntoXml("Results/outputTest.xml"); -} +void ConfigureOnly::Running() {} void ConfigureOnly::Stop() {} diff --git a/tools/ConfigureOnly.h b/tools/ConfigureOnly.h index e75b2ef4b..9c7795a3a 100644 --- a/tools/ConfigureOnly.h +++ b/tools/ConfigureOnly.h @@ -13,6 +13,8 @@ class ConfigureOnly : public Tool void Stop() override; void Pause() override; void Resume() override; + + static std::string fCalibrationDescription; }; #endif \ No newline at end of file diff --git a/tools/LatencyScan.cc b/tools/LatencyScan.cc index 5953ce683..33fe078a4 100644 --- a/tools/LatencyScan.cc +++ b/tools/LatencyScan.cc @@ -9,6 +9,8 @@ #include "Utils/Occupancy.h" #include "Utils/SSAChannelGroupHandler.h" +std::string LatencyScan::fCalibrationDescription = "Run latency scan"; + LatencyScan::LatencyScan() : Tool() {} LatencyScan::~LatencyScan() {} diff --git a/tools/LatencyScan.h b/tools/LatencyScan.h index 0c29d89c0..777e6068d 100644 --- a/tools/LatencyScan.h +++ b/tools/LatencyScan.h @@ -58,6 +58,8 @@ class LatencyScan : public Tool void Pause() override; void Resume() override; + static std::string fCalibrationDescription; + protected: void cleanContainerMap(); void initializeRecycleBin() { fRecycleBin.setDetectorContainer(fDetectorContainer); } diff --git a/tools/OTTemperature.cc b/tools/OTTemperature.cc index 53648c43c..d4ddf9409 100644 --- a/tools/OTTemperature.cc +++ b/tools/OTTemperature.cc @@ -3,6 +3,8 @@ using namespace Ph2_HwDescription; using namespace Ph2_HwInterface; using namespace Ph2_System; +std::string OTTemperature::fCalibrationDescription = "Read Module temperatures"; + OTTemperature::OTTemperature() : OTTool() {} OTTemperature::~OTTemperature() {} diff --git a/tools/OTTemperature.h b/tools/OTTemperature.h index b1528a32d..10fc1a671 100644 --- a/tools/OTTemperature.h +++ b/tools/OTTemperature.h @@ -41,6 +41,8 @@ class OTTemperature : public OTTool uint8_t TuneLpGBTVref(); void LoopReadout(bool pLoopReadout) { fLoopReadout = pLoopReadout; } + static std::string fCalibrationDescription; + protected: private: bool fLoopReadout{false}; diff --git a/tools/OTalignLpGBTinputs.cc b/tools/OTalignLpGBTinputs.cc index 20a606047..d1cddbd52 100644 --- a/tools/OTalignLpGBTinputs.cc +++ b/tools/OTalignLpGBTinputs.cc @@ -6,6 +6,8 @@ using namespace Ph2_HwDescription; using namespace Ph2_HwInterface; using namespace Ph2_System; +std::string OTalignLpGBTinputs::fCalibrationDescription = "Optimize LpGBT Rx phases to properly decode the inputs from the CICs"; + OTalignLpGBTinputs::OTalignLpGBTinputs() : Tool() {} OTalignLpGBTinputs::~OTalignLpGBTinputs() {} diff --git a/tools/OTalignLpGBTinputs.h b/tools/OTalignLpGBTinputs.h index 18f63dc09..2ad054751 100644 --- a/tools/OTalignLpGBTinputs.h +++ b/tools/OTalignLpGBTinputs.h @@ -33,6 +33,8 @@ class OTalignLpGBTinputs : public Tool void Resume() override; void Reset(); + static std::string fCalibrationDescription; + private: void AlignLpGBTInputs(); diff --git a/tools/PSPhysics.cc b/tools/PSPhysics.cc index 087e55f3b..e83356f31 100644 --- a/tools/PSPhysics.cc +++ b/tools/PSPhysics.cc @@ -23,6 +23,8 @@ using namespace Ph2_HwDescription; using namespace Ph2_HwInterface; +std::string PSPhysics::fCalibrationDescription = "Take data"; + void PSPhysics::ConfigureCalibration() { PSAlignment cPSAlignment; diff --git a/tools/PSPhysics.h b/tools/PSPhysics.h index 3365f5f31..03361b384 100644 --- a/tools/PSPhysics.h +++ b/tools/PSPhysics.h @@ -40,6 +40,8 @@ class PSPhysics : public Tool // void fillDataContainer(BoardContainer* const& cBoard, Ph2_HwInterface::Event* event); void fillDataContainer(BoardContainer* const& cBoard, const std::vector<Ph2_HwInterface::Event*> eventList); + static std::string fCalibrationDescription; + private: // DetectorDataContainer fPSSyncContainer ; DetectorDataContainer fStubContainer; diff --git a/tools/PedeNoise.cc b/tools/PedeNoise.cc index 4daad1648..6239268b5 100644 --- a/tools/PedeNoise.cc +++ b/tools/PedeNoise.cc @@ -19,6 +19,8 @@ #include "DQMUtils/DQMHistogramPedeNoise.h" #endif +std::string PedeNoise::fCalibrationDescription = "Measure noise and Pedestal/pulse peak, set threshold at 5 sigma from the pedestal and run occupancy measurement"; + PedeNoise::PedeNoise() : Tool() {} PedeNoise::~PedeNoise() { clearDataMembers(); } diff --git a/tools/PedeNoise.h b/tools/PedeNoise.h index 3c7c6ef1e..8fe3d26be 100644 --- a/tools/PedeNoise.h +++ b/tools/PedeNoise.h @@ -47,6 +47,8 @@ class PedeNoise : public Tool void Resume() override; void Reset(); + static std::string fCalibrationDescription; + protected: void measureSCurves(uint16_t pStripStartValue = 0, uint16_t pPixelStartValue = 0); void findPedestal(bool forceAllChannels = false); diff --git a/tools/PedestalEqualization.cc b/tools/PedestalEqualization.cc index 1b187b36c..c0669b66d 100644 --- a/tools/PedestalEqualization.cc +++ b/tools/PedestalEqualization.cc @@ -14,6 +14,8 @@ using namespace Ph2_System; using namespace Ph2_HwDescription; using namespace Ph2_HwInterface; +std::string PedestalEqualization::fCalibrationDescription = "Equalize the pedestal/threshold for all channels"; + PedestalEqualization::PedestalEqualization() : Tool() {} PedestalEqualization::~PedestalEqualization() {} diff --git a/tools/PedestalEqualization.h b/tools/PedestalEqualization.h index 76220e3ba..ed0024b6e 100644 --- a/tools/PedestalEqualization.h +++ b/tools/PedestalEqualization.h @@ -40,6 +40,8 @@ class PedestalEqualization : public Tool void Pause() override; void Resume() override; void Reset(); + + static std::string fCalibrationDescription; private: std::vector<EventType> fEventTypes; diff --git a/tools/Physics2S.cc b/tools/Physics2S.cc index 43e2b8254..3a0463d46 100644 --- a/tools/Physics2S.cc +++ b/tools/Physics2S.cc @@ -21,6 +21,8 @@ using namespace Ph2_HwDescription; using namespace Ph2_HwInterface; +std::string Physics2S::fCalibrationDescription = "Take data"; + void Physics2S::ConfigureCalibration() { // ####################### diff --git a/tools/Physics2S.h b/tools/Physics2S.h index e69ba1ec4..92843185e 100644 --- a/tools/Physics2S.h +++ b/tools/Physics2S.h @@ -43,6 +43,8 @@ class Physics2S : public Tool // void fillDataContainer(BoardContainer* const& cBoard); void fillDataContainer(BoardContainer* cBoard, const std::vector<Ph2_HwInterface::Event*> eventList); + static std::string fCalibrationDescription; + private: // DetectorDataContainer f2SDataContainer; DetectorDataContainer fStubContainer; diff --git a/tools/TuneLpGBTVref.cc b/tools/TuneLpGBTVref.cc index 32057f683..d6f125921 100644 --- a/tools/TuneLpGBTVref.cc +++ b/tools/TuneLpGBTVref.cc @@ -1,6 +1,8 @@ #include "tools/TuneLpGBTVref.h" #include "System/RegisterHelper.h" +std::string TuneLpGBTVref::fCalibrationDescription = "Tune Vref value for LpGBT calibration"; + TuneLpGBTVref::TuneLpGBTVref() : Tool() {} TuneLpGBTVref::~TuneLpGBTVref() {} diff --git a/tools/TuneLpGBTVref.h b/tools/TuneLpGBTVref.h index 1c56dd380..4e29d3881 100644 --- a/tools/TuneLpGBTVref.h +++ b/tools/TuneLpGBTVref.h @@ -15,6 +15,8 @@ class TuneLpGBTVref : public Tool void Pause() override; void Resume() override; + static std::string fCalibrationDescription; + private: void reset(); void tuneVref(); -- GitLab From f97d2ee7066001adf876cafa6bd9c7c3d22012bb Mon Sep 17 00:00:00 2001 From: Fabio Ravera <fabio.ravera@cern.ch> Date: Wed, 17 Jan 2024 12:04:42 -0600 Subject: [PATCH 2/2] Run formatAll --- miniDAQ/CombinedCalibrationFactory.cc | 2 +- miniDAQ/CombinedCalibrationFactory.h | 49 ++++++++++++++------------- miniDAQ/MiddlewareMessageHandler.cc | 4 +-- src/runCalibration.cc | 8 ++--- src/supervisor.cc | 8 ++--- tools/CBCPulseShape.h | 2 +- tools/CalibrationExample.h | 2 +- tools/PedestalEqualization.h | 2 +- 8 files changed, 40 insertions(+), 37 deletions(-) diff --git a/miniDAQ/CombinedCalibrationFactory.cc b/miniDAQ/CombinedCalibrationFactory.cc index 9a99d02d0..90974ff32 100644 --- a/miniDAQ/CombinedCalibrationFactory.cc +++ b/miniDAQ/CombinedCalibrationFactory.cc @@ -81,7 +81,7 @@ CombinedCalibrationFactory::CombinedCalibrationFactory() CombinedCalibrationFactory::~CombinedCalibrationFactory() { - for(auto& calibrationListPerHardware : fCalibrationMap) + for(auto& calibrationListPerHardware: fCalibrationMap) { delete calibrationListPerHardware.second.second; calibrationListPerHardware.second.second = nullptr; diff --git a/miniDAQ/CombinedCalibrationFactory.h b/miniDAQ/CombinedCalibrationFactory.h index ebd03612a..a7f75dbf1 100644 --- a/miniDAQ/CombinedCalibrationFactory.h +++ b/miniDAQ/CombinedCalibrationFactory.h @@ -13,58 +13,61 @@ class BaseCreator public: BaseCreator() {} virtual ~BaseCreator() {} - virtual Tool* Create() const = 0; - std::vector<std::pair<std::string, std::string>> fSubCalibrationAndDescriptionList {}; + virtual Tool* Create() const = 0; + std::vector<std::pair<std::string, std::string>> fSubCalibrationAndDescriptionList{}; }; -template<typename T> +template <typename T> std::string getClassName() { int32_t status; - std::string className = abi::__cxa_demangle(typeid(T).name(), 0, 0, &status); + std::string className = abi::__cxa_demangle(typeid(T).name(), 0, 0, &status); return className; } namespace CombinedCalibrationFactory_detail { - template <typename> - struct sfinae_true : std::true_type{}; +template <typename> +struct sfinae_true : std::true_type +{ +}; - template <typename T> - static auto test_calibrationDescription(int) -> sfinae_true<decltype(T::fCalibrationDescription)>; - template <typename> - static auto test_calibrationDescription(long) -> std::false_type; -} +template <typename T> +static auto test_calibrationDescription(int) -> sfinae_true<decltype(T::fCalibrationDescription)>; +template <typename> +static auto test_calibrationDescription(long) -> std::false_type; +} // namespace CombinedCalibrationFactory_detail template <typename T> struct has_calibrationDescription : decltype(CombinedCalibrationFactory_detail::test_calibrationDescription<T>(0)) -{}; +{ +}; -template<typename T, bool hasCalibrationDescription> +template <typename T, bool hasCalibrationDescription> struct GetCalibrationDescription { - std::pair<std::string, std::string> operator()() {return std::make_pair(getClassName<T>(), "");} + std::pair<std::string, std::string> operator()() { return std::make_pair(getClassName<T>(), ""); } }; -template<typename T> +template <typename T> struct GetCalibrationDescription<T, true> { - std::pair<std::string, std::string> operator()() {return std::make_pair(getClassName<T>(), T::fCalibrationDescription);} + std::pair<std::string, std::string> operator()() { return std::make_pair(getClassName<T>(), T::fCalibrationDescription); } }; -template<typename T> +template <typename T> void getFullDescription(std::vector<std::pair<std::string, std::string>>& theFullCalibrationDescription) { - GetCalibrationDescription<T, has_calibrationDescription<T>::value> theGetCalibrationDescription; - std::pair<std::string, std::string> theCalibrationDescription = theGetCalibrationDescription(); + GetCalibrationDescription<T, has_calibrationDescription<T>::value> theGetCalibrationDescription; + std::pair<std::string, std::string> theCalibrationDescription = theGetCalibrationDescription(); theFullCalibrationDescription.push_back(theCalibrationDescription); } -template<typename T, typename U, typename... Args> +template <typename T, typename U, typename... Args> void getFullDescription(std::vector<std::pair<std::string, std::string>>& theFullCalibrationDescription) { - GetCalibrationDescription<T, has_calibrationDescription<T>::value> theGetCalibrationDescription; - std::pair<std::string, std::string> theCalibrationDescription = theGetCalibrationDescription(); + GetCalibrationDescription<T, has_calibrationDescription<T>::value> theGetCalibrationDescription; + std::pair<std::string, std::string> theCalibrationDescription = theGetCalibrationDescription(); theFullCalibrationDescription.push_back(theCalibrationDescription); getFullDescription<U, Args...>(theFullCalibrationDescription); } @@ -73,7 +76,7 @@ template <typename... Args> class Creator : public BaseCreator { public: - Creator() {getFullDescription<Args...>(fSubCalibrationAndDescriptionList);} + Creator() { getFullDescription<Args...>(fSubCalibrationAndDescriptionList); } virtual ~Creator() {} Tool* Create() const override { return new CombinedCalibration<Args...>(); }; // ################################################## diff --git a/miniDAQ/MiddlewareMessageHandler.cc b/miniDAQ/MiddlewareMessageHandler.cc index 06d2b27ce..6b881e231 100644 --- a/miniDAQ/MiddlewareMessageHandler.cc +++ b/miniDAQ/MiddlewareMessageHandler.cc @@ -175,11 +175,11 @@ std::string MiddlewareMessageHandler::calibrationList(const std::string& message auto theCalibrationPerHardwareTypeListMessage = theCalibrationList.add_calibrationperhardwaretype(); theCalibrationPerHardwareTypeListMessage->set_hardwaretype(calibrationHardware.first); - for(const auto& theCalibrationList : calibrationHardware.second) + for(const auto& theCalibrationList: calibrationHardware.second) { auto theCalibrationListMessage = theCalibrationPerHardwareTypeListMessage->add_calibrationinfo(); theCalibrationListMessage->set_calibrationname(theCalibrationList.first); - for(const auto& theSubCalibrationList : theCalibrationList.second) + for(const auto& theSubCalibrationList: theCalibrationList.second) { auto theSubCalibrationListMessage = theCalibrationListMessage->add_subcalibrationinfo(); theSubCalibrationListMessage->set_subcalibrationname(theSubCalibrationList.first); diff --git a/src/runCalibration.cc b/src/runCalibration.cc index bd0ffcf15..a94d50aa7 100644 --- a/src/runCalibration.cc +++ b/src/runCalibration.cc @@ -88,14 +88,14 @@ int main(int argc, char* argv[]) cmd.defineOptionAlternative("file", "f"); std::string calibrationHelpMessage = "Calibration to run. List of available calibrations:\n"; - for(const auto& calibrationList : theMiddlewareStateMachine.getCombinedCalibrationFactory().getAvailableCalibrations()) + for(const auto& calibrationList: theMiddlewareStateMachine.getCombinedCalibrationFactory().getAvailableCalibrations()) { std::cout << "--------------------------------------------------------------------------" << std::endl; std::cout << BOLDGREEN << calibrationList.first << RESET << std::endl; - for(const auto& calibration : calibrationList.second) + for(const auto& calibration: calibrationList.second) { std::cout << BOLDBLUE << "\t" << calibration.first << RESET << std::endl; - for(const auto& subCalibration : calibration.second) + for(const auto& subCalibration: calibration.second) { std::cout << "\t\t" << subCalibration.first; if(subCalibration.second != "") std::cout << ": " << subCalibration.second; @@ -104,7 +104,7 @@ int main(int argc, char* argv[]) } std::cout << "--------------------------------------------------------------------------" << std::endl; } - + cmd.defineOption("calibration", calibrationHelpMessage, ArgvParser::OptionRequiresValue | ArgvParser::OptionRequired); cmd.defineOptionAlternative("calibration", "c"); diff --git a/src/supervisor.cc b/src/supervisor.cc index 09a12fc03..80b91cb51 100644 --- a/src/supervisor.cc +++ b/src/supervisor.cc @@ -132,14 +132,14 @@ int main(int argc, char* argv[]) std::string calibrationHelpMessage = "Calibration to run. List of available calibrations:\n"; CombinedCalibrationFactory theCombinedCalibrationFactory; - for(const auto& calibrationList : theCombinedCalibrationFactory.getAvailableCalibrations()) + for(const auto& calibrationList: theCombinedCalibrationFactory.getAvailableCalibrations()) { std::cout << "--------------------------------------------------------------------------" << std::endl; std::cout << BOLDGREEN << calibrationList.first << RESET << std::endl; - for(const auto& calibration : calibrationList.second) + for(const auto& calibration: calibrationList.second) { std::cout << BOLDBLUE << "\t" << calibration.first << RESET << std::endl; - for(const auto& subCalibration : calibration.second) + for(const auto& subCalibration: calibration.second) { std::cout << "\t\t" << subCalibration.first; if(subCalibration.second != "") std::cout << ": " << subCalibration.second; @@ -147,7 +147,7 @@ int main(int argc, char* argv[]) } } std::cout << "--------------------------------------------------------------------------" << std::endl; - } + } cmd.defineOption("calibration", calibrationHelpMessage, ArgvParser::OptionRequiresValue | ArgvParser::OptionRequired); cmd.defineOptionAlternative("calibration", "c"); diff --git a/tools/CBCPulseShape.h b/tools/CBCPulseShape.h index f1627a7b2..10c93863b 100644 --- a/tools/CBCPulseShape.h +++ b/tools/CBCPulseShape.h @@ -32,7 +32,7 @@ class CBCPulseShape : public PedeNoise // State machine void Running() override; void Stop(void) override; - + static std::string fCalibrationDescription; private: diff --git a/tools/CalibrationExample.h b/tools/CalibrationExample.h index edbe1a0a3..845ba796c 100644 --- a/tools/CalibrationExample.h +++ b/tools/CalibrationExample.h @@ -36,7 +36,7 @@ class CalibrationExample : public Tool void Stop(void) override; static std::string fCalibrationDescription; - + private: uint32_t fEventsPerPoint; diff --git a/tools/PedestalEqualization.h b/tools/PedestalEqualization.h index ed0024b6e..1cce6ca04 100644 --- a/tools/PedestalEqualization.h +++ b/tools/PedestalEqualization.h @@ -40,7 +40,7 @@ class PedestalEqualization : public Tool void Pause() override; void Resume() override; void Reset(); - + static std::string fCalibrationDescription; private: -- GitLab