Skip to content

Commit

Permalink
TRD: Implementation of DCS Chamber Status processing and DPs update (A…
Browse files Browse the repository at this point in the history
…liceO2Group#12319)

* TRD: implementation of DCS Chamber Status processing

* TRD: run type DP removed from processing

* TRD: changed alias of Env DPs, merged with Cavern DPs

* TRD: changed default value of min number of ChamberStatus/CFGtag for updated to 522

* TRD: removed reset of ChamberStatus/CFGtag info map after CCDB upload

* TRD: voltage variation trigger for CCDB redefined as configurable, default value of 1V

* TRD: changes after run test
List of changes:
  - changed type of CCDB object of chamberStatus and CFGtag from unordered maps to arrays
  - removed processing and update of trd_envTemp
  - set validity of chamberStatus and CFGtag 30 seconds before processing timestamp
  - minor changes to read DCS entries macro
  - turn off alarm/warn logic, set everything as warn

* TRD: formatting
  • Loading branch information
leo-barreto authored Dec 1, 2023
1 parent 0493ad2 commit 1b18b37
Show file tree
Hide file tree
Showing 6 changed files with 489 additions and 89 deletions.
63 changes: 55 additions & 8 deletions Detectors/TRD/calibration/include/TRDCalibration/DCSProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,60 @@ class DCSProcessor
bool updateCurrentsDPsCCDB();
bool updateEnvDPsCCDB();
bool updateRunDPsCCDB();
// LB: new DPs for Fed
bool updateFedChamberStatusDPsCCDB();
bool updateFedCFGtagDPsCCDB();

// signal that the CCDB object for the voltages should be updated due to change exceeding threshold
bool shouldUpdateVoltages() const { return mShouldUpdateVoltages; }
bool shouldUpdateRun() const { return mShouldUpdateRun; }
// LB: Only update ChamberStatus/CFGtag if both conditions are met (complete DPs and new run)
bool shouldUpdateFedChamberStatus() const { return mFedChamberStatusCompleteDPs && mFirstRunEntryForFedChamberStatusUpdate; }
bool shouldUpdateFedCFGtag() const { return mFedCFGtagCompleteDPs && mFirstRunEntryForFedCFGtagUpdate; }
// LB: Env DPs have no alias pattern, processor uses this function to identify if alias is Env
bool isAliasFromEnvDP(const char* dpalias) const
{
std::vector<std::string> envaliases = {"CavernTemperature", "temperature_P2_external", "AtmosPressure", "UXC2Humidity"};
for (const auto& envalias : envaliases) {
if (std::strstr(dpalias, envalias.c_str()) != nullptr) {
return true;
}
}
return false;
}

// allow access to the CCDB objects from DPL processor
CcdbObjectInfo& getccdbGasDPsInfo() { return mCcdbGasDPsInfo; }
CcdbObjectInfo& getccdbVoltagesDPsInfo() { return mCcdbVoltagesDPsInfo; }
CcdbObjectInfo& getccdbCurrentsDPsInfo() { return mCcdbCurrentsDPsInfo; }
CcdbObjectInfo& getccdbEnvDPsInfo() { return mCcdbEnvDPsInfo; }
CcdbObjectInfo& getccdbRunDPsInfo() { return mCcdbRunDPsInfo; }
CcdbObjectInfo& getccdbFedChamberStatusDPsInfo() { return mCcdbFedChamberStatusDPsInfo; }
CcdbObjectInfo& getccdbFedCFGtagDPsInfo() { return mCcdbFedCFGtagDPsInfo; }
const std::unordered_map<DPID, TRDDCSMinMaxMeanInfo>& getTRDGasDPsInfo() const { return mTRDDCSGas; }
const std::unordered_map<DPID, float>& getTRDVoltagesDPsInfo() const { return mTRDDCSVoltages; }
const std::unordered_map<DPID, TRDDCSMinMaxMeanInfo>& getTRDCurrentsDPsInfo() const { return mTRDDCSCurrents; }
const std::unordered_map<DPID, TRDDCSMinMaxMeanInfo>& getTRDEnvDPsInfo() const { return mTRDDCSEnv; }
const std::unordered_map<DPID, int>& getTRDRunDPsInfo() const { return mTRDDCSRun; }
const std::array<int, constants::MAXCHAMBER>& getTRDFedChamberStatusDPsInfo() const { return mTRDDCSFedChamberStatus; }
const std::array<string, constants::MAXCHAMBER>& getTRDFedCFGtagDPsInfo() const { return mTRDDCSFedCFGtag; }

// settings
void setCurrentTS(TFType tf) { mCurrentTS = tf; }
void setVerbosity(int v) { mVerbosity = v; }
void setMaxCounterAlarmFed(int alarmfed) { mFedAlarmCounterMax = alarmfed; }
void setFedMinimunDPsForUpdate(int minupdatefed) { mFedMinimunDPsForUpdate = minupdatefed; }
void setUVariationTriggerForUpdate(float utrigger) { mUVariationTriggerForUpdate = utrigger; }

// reset methods
void clearGasDPsInfo();
void clearVoltagesDPsInfo();
void clearCurrentsDPsInfo();
void clearEnvDPsInfo();
void clearRunDPsInfo();
// LB: new DPs for Fed
void clearFedChamberStatusDPsInfo();
void clearFedCFGtagDPsInfo();

// helper functions
int getChamberIdFromAlias(const char* alias) const;
Expand All @@ -100,14 +127,11 @@ class DCSProcessor
std::unordered_map<DPID, TRDDCSMinMaxMeanInfo> mTRDDCSGas; ///< gas DPs (CO2, O2, H20 and from the chromatograph CO2, N2, Xe)
std::unordered_map<DPID, TRDDCSMinMaxMeanInfo> mTRDDCSCurrents; ///< anode and drift currents
std::unordered_map<DPID, float> mTRDDCSVoltages; ///< anode and drift voltages
std::unordered_map<DPID, TRDDCSMinMaxMeanInfo> mTRDDCSEnv; ///< environment parameters (temperatures, pressures)
std::unordered_map<DPID, int> mTRDDCSRun; ///< run number and run type
// TODO
// Possibly add CFG tag and chamber status here?
// Or send errors to the InfoLogger in case CFG tag mismatches are detected for chamber which have the same FSM state?
// For this I need more information on the chamber status - which status indicates all good and included in data taking?
// not TODO
// I don't think the FED ENV temperature is needed at analysis level at any point in time so I am leaving it out for now
std::unordered_map<DPID, TRDDCSMinMaxMeanInfo> mTRDDCSEnv; ///< environment parameters (temperatures, pressures, humidity)
std::unordered_map<DPID, int> mTRDDCSRun; ///< run number (run type ignored)
// LB: new DPs for Fed
std::array<int, constants::MAXCHAMBER> mTRDDCSFedChamberStatus; ///< fed chamber status
std::array<string, constants::MAXCHAMBER> mTRDDCSFedCFGtag; ///< fed config tag

// helper variables
std::unordered_map<DPID, bool> mPids; ///< flag for each DP whether it has been processed at least once
Expand All @@ -117,24 +141,47 @@ class DCSProcessor
CcdbObjectInfo mCcdbCurrentsDPsInfo;
CcdbObjectInfo mCcdbEnvDPsInfo;
CcdbObjectInfo mCcdbRunDPsInfo;
// LB: new DPs for Fed
CcdbObjectInfo mCcdbFedChamberStatusDPsInfo;
CcdbObjectInfo mCcdbFedCFGtagDPsInfo;

TFType mGasStartTS; ///< the time stamp of the first TF which was processesd for the current GAS CCDB object
TFType mVoltagesStartTS; ///< the time stamp of the first TF which was processesd for the current voltages CCDB object
TFType mCurrentsStartTS; ///< the time stamp of the first TF which was processesd for the current voltages CCDB object
TFType mEnvStartTS;
TFType mRunStartTS;
TFType mRunEndTS;
// LB: new DPs for Fed
TFType mFedChamberStatusStartTS;
TFType mFedCFGtagStartTS;
TFType mCurrentTS{0}; ///< the time stamp of the TF currently being processed
bool mGasStartTSset{false};
bool mVoltagesStartTSSet{false};
bool mCurrentsStartTSSet{false};
bool mEnvStartTSSet{false};
bool mRunStartTSSet{false};
// LB: new DPs for Fed
bool mFedChamberStatusStartTSSet{false};
bool mFedCFGtagStartTSSet{false};
std::bitset<constants::MAXCHAMBER> mVoltageSet{};
bool mShouldUpdateVoltages{false};
bool mShouldUpdateRun{false};
// LB: FedChamberStatus and FedCFGtag logic
bool mFedChamberStatusCompleteDPs{false};
bool mFedCFGtagCompleteDPs{false};
bool mFirstRunEntryForFedChamberStatusUpdate{false};
bool mFirstRunEntryForFedCFGtagUpdate{false};
int mCurrentRunNumber{-1};
int mFedChamberStatusAlarmCounter{0};
int mFedCFGtagAlarmCounter{0};
// LB: for testing runNo object, turned off for now
// int mFinishedRunNumber;

// settings
int mVerbosity{0};
int mFedAlarmCounterMax{1};
int mFedMinimunDPsForUpdate{522};
float mUVariationTriggerForUpdate{1.0};

ClassDefNV(DCSProcessor, 0);
};
Expand Down
24 changes: 18 additions & 6 deletions Detectors/TRD/calibration/macros/makeTRDCCDBEntryForDCS.C
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,27 @@ int makeTRDCCDBEntryForDCS(const std::string url = "http://localhost:8080")
std::vector<std::string> aliasesFloat;
std::vector<std::string> aliasesInt;
std::vector<std::string> aliasesString;

// Gas DPs
aliasesFloat.insert(aliasesFloat.end(), {"trd_gasCO2", "trd_gasH2O", "trd_gasO2"});
aliasesFloat.insert(aliasesFloat.end(), {"trd_gaschromatographCO2", "trd_gaschromatographN2", "trd_gaschromatographXe"});

// Current and Voltages DPs
aliasesFloat.insert(aliasesFloat.end(), {"trd_hvAnodeImon[00..539]", "trd_hvAnodeUmon[00..539]", "trd_hvDriftImon[00..539]", "trd_hvDriftUmon[00..539]"});
aliasesFloat.insert(aliasesFloat.end(), {"trd_aliEnvTempCavern", "trd_aliEnvTempP2"});
aliasesFloat.insert(aliasesFloat.end(), {"trd_aliEnvPressure00", "trd_aliEnvPressure01", "trd_aliEnvPressure02"});
aliasesInt.insert(aliasesInt.end(), {"trd_runNo", "trd_runType"});
// aliasesFloat.insert(aliasesFloat.end(), {"trd_cavernHumidity", "trd_fedEnvTemp[00..539]"});
// aliasesInt.insert(aliasesInt.end(), {"trd_fedChamberStatus[00..539]"});
// aliasesString.insert(aliasesString.end(), {"trd_fedCFGtag[00..539]"});

// FED DPs
aliasesInt.insert(aliasesInt.end(), {"trd_chamberStatus[00..539]"});
aliasesString.insert(aliasesString.end(), {"trd_CFGtag[00..539]"});

// Environment DPs
aliasesFloat.insert(aliasesFloat.end(), {"CavernTemperature", "temperature_P2_external"});
aliasesFloat.insert(aliasesFloat.end(), {"CavernAtmosPressure", "SurfaceAtmosPressure", "CavernAtmosPressure2"});
aliasesFloat.insert(aliasesFloat.end(), {"UXC2Humidity"});

// Run DPs
aliasesInt.insert(aliasesInt.end(), {"trd_fed_runNo"});

// Ignorded DPs: trd_fed_runType, trd_envTemp[00..539], trd_gasOverpressure*

DPID dpidTmp;
for (const auto& ali : o2::dcs::expandAliases(aliasesFloat)) {
Expand Down
74 changes: 61 additions & 13 deletions Detectors/TRD/calibration/macros/readTRDDCSentries.C
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
#include <bitset>
#endif

void readTRDDCSentries(std::string ccdb = "http://localhost:8080", long ts = -1)
void readTRDDCSentries(std::string ccdb = "http://localhost:8080", long ts = -1, bool printGas = true, bool printChamber = true,
bool printI = true, bool printU = true, bool printEnv = true)
{

auto& ccdbmgr = o2::ccdb::BasicCCDBManager::instance();
ccdbmgr.setURL(ccdb.c_str()); // comment out this line to read from production CCDB instead of a local one, or adapt ccdb string
if (ts < 0) {
ts = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
std::cout << "Timestamp: " << ts << std::endl;
}
ccdbmgr.setTimestamp(ts);

Expand All @@ -44,21 +46,67 @@ void readTRDDCSentries(std::string ccdb = "http://localhost:8080", long ts = -1)
std::cout << std::endl;

// now, access the actual calibration object from CCDB
auto cal = ccdbmgr.get<unordered_map<o2::dcs::DataPointIdentifier, o2::trd::TRDDCSMinMaxMeanInfo>>("TRD/Calib/DCSDPsGas");
// Access Gas DPs
if (printGas) {
auto calgas = ccdbmgr.get<unordered_map<o2::dcs::DataPointIdentifier, o2::trd::TRDDCSMinMaxMeanInfo>>("TRD/Calib/DCSDPsGas");

std::cout << "Printing a single object from the map (trd_gasCO2):" << std::endl;
o2::dcs::DataPointIdentifier dpid; // used as key to access the map
o2::dcs::DataPointIdentifier::FILL(dpid, "trd_gasCO2", o2::dcs::DeliveryType::DPVAL_DOUBLE);
auto obj = cal->at(dpid);
obj.print();
std::cout << std::endl;
// LB: use this as template for reading only a single object
// std::cout << "Printing a single object from the map (trd_gasCO2):" << std::endl;
// o2::dcs::DataPointIdentifier dpid; // used as key to access the map
// o2::dcs::DataPointIdentifier::FILL(dpid, "trd_gasCO2", o2::dcs::DeliveryType::DPVAL_DOUBLE);
// auto obj = calgas->at(dpid);
// obj.print();
// std::cout << std::endl;

std::cout << "And lastly print all objects from the map, together with their DataPointIdentifier:" << std::endl;
for (const auto& entry : *cal) {
std::cout << entry.first << std::endl;
entry.second.print();
std::cout << "Print all objects from the map (DCSDPsGas), together with their DataPointIdentifier:" << std::endl;
for (const auto& entry : *calgas) {
std::cout << entry.first << std::endl;
entry.second.print();
std::cout << std::endl;
}
}

// Access ChamberStatus and CFGtag DPs
if (printChamber) {
auto calchamberstatus = ccdbmgr.get<std::array<int, o2::trd::constants::MAXCHAMBER>>("TRD/Calib/DCSDPsFedChamberStatus");
auto calcfgtag = ccdbmgr.get<std::array<std::string, o2::trd::constants::MAXCHAMBER>>("TRD/Calib/DCSDPsFedCFGtag");
std::cout << "Print all objects from the chambers (DCSDPsFedChamberStatus and DCSDPsFedCFGtag), together with their chamber ID:" << std::endl;
for (int i = 0; i < o2::trd::constants::MAXCHAMBER; i++) {
std::cout << "Chamber ID = " << i << ",\tstatus = " << (*calchamberstatus)[i] << ",\tcfgtag = " << (*calcfgtag)[i] << std::endl;
}
std::cout << std::endl;
}

// Access Current DPs
if (printI) {
auto cali = ccdbmgr.get<unordered_map<o2::dcs::DataPointIdentifier, o2::trd::TRDDCSMinMaxMeanInfo>>("TRD/Calib/DCSDPsI");
std::cout << "Print all objects from the map (DCSDPsI), together with their DataPointIdentifier:" << std::endl;
for (const auto& entry : *cali) {
std::cout << entry.first << std::endl;
entry.second.print();
std::cout << std::endl;
}
}

// Access Voltages DPs
if (printU) {
auto calu = ccdbmgr.get<unordered_map<o2::dcs::DataPointIdentifier, float>>("TRD/Calib/DCSDPsU");
std::cout << "Print all objects from the map (DCSDPsU), together with their DataPointIdentifier:" << std::endl;
for (const auto& entry : *calu) {
std::cout << "id = " << entry.first << ",\tvalue = " << entry.second << std::endl;
}
}

// Access Env DPs
if (printEnv) {
auto calenv = ccdbmgr.get<unordered_map<o2::dcs::DataPointIdentifier, o2::trd::TRDDCSMinMaxMeanInfo>>("TRD/Calib/DCSDPsEnv");
std::cout << "Print all objects from the map (DCSDPsEnv), together with their DataPointIdentifier:" << std::endl;
for (const auto& entry : *calenv) {
std::cout << entry.first << std::endl;
entry.second.print();
std::cout << std::endl;
}
}
std::cout << std::endl;

return;
}
Loading

0 comments on commit 1b18b37

Please sign in to comment.