Skip to content

Commit c1e9bca

Browse files
committed
TRD: assumed no duplicated DPs in Processor, changed variable names
1 parent d5011ff commit c1e9bca

2 files changed

Lines changed: 37 additions & 45 deletions

File tree

Detectors/TRD/calibration/include/TRDCalibration/DCSProcessor.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class DCSProcessor
7474
bool shouldUpdateVoltages() const { return mShouldUpdateVoltages; }
7575
bool shouldUpdateRun() const { return mShouldUpdateRun; }
7676
// LB: Only update ChamberStatus/CFGtag if both conditions are met (complete DPs and new run)
77-
bool shouldUpdateFedChamberStatus() const { return mFedChamberStatusCompleteDPs && mNewRunForFedChamberStatusUpdate; }
78-
bool shouldUpdateFedCFGtag() const { return mFedCFGtagCompleteDPs && mNewRunForFedCFGtagUpdate; }
77+
bool shouldUpdateFedChamberStatus() const { return mFedChamberStatusCompleteDPs && mFirstRunEntryForFedChamberStatusUpdate; }
78+
bool shouldUpdateFedCFGtag() const { return mFedCFGtagCompleteDPs && mFirstRunEntryForFedCFGtagUpdate; }
7979

8080
// allow access to the CCDB objects from DPL processor
8181
CcdbObjectInfo& getccdbGasDPsInfo() { return mCcdbGasDPsInfo; }
@@ -173,8 +173,8 @@ class DCSProcessor
173173
// LB: FedChamberStatus and FedCFGtag logic
174174
bool mFedChamberStatusCompleteDPs{false};
175175
bool mFedCFGtagCompleteDPs{false};
176-
bool mNewRunForFedChamberStatusUpdate{false};
177-
bool mNewRunForFedCFGtagUpdate{false};
176+
bool mFirstRunEntryForFedChamberStatusUpdate{false};
177+
bool mFirstRunEntryForFedCFGtagUpdate{false};
178178
int mCurrentRunNumber{-1};
179179
int mFedChamberStatusAlarmCounter{0};
180180
int mFedCFGtagAlarmCounter{0};

Detectors/TRD/calibration/src/DCSProcessor.cxx

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -43,57 +43,49 @@ int DCSProcessor::process(const gsl::span<const DPCOM> dps)
4343
LOG(info) << "\n\n\nProcessing new TF\n-----------------";
4444
}
4545

46-
if (mVerbosity > 1) {
47-
std::unordered_map<DPID, DPVAL> mapin;
48-
for (auto& it : dps) {
49-
mapin[it.id] = it.data;
50-
}
46+
// LB: setup counters for ChamberStatus/CFGtag logic
47+
int ChamberStatusDPsCounter = 0;
48+
int CFGtagDPsCounter = 0;
5149

52-
for (auto& it : mPids) {
53-
const auto& el = mapin.find(it.first);
54-
if (el == mapin.end()) {
55-
LOG(info) << "DP " << it.first << " not found in map";
56-
} else {
57-
LOG(info) << "DP " << it.first << " found in map";
58-
}
59-
}
60-
}
50+
std::unordered_map<DPID, DPVAL> mapin;
51+
for (auto& it : dps) {
52+
mapin[it.id] = it.data;
6153

62-
// LB: check if all ChamberStatus/CFGtag DPs were sent by using a vector and then
63-
// checking for duplicates, if new size is equal to 540 => all DPs were sent
64-
std::vector<DPID> allChamberStatusDPsid;
65-
std::vector<DPID> allCFGtagDPsid;
66-
for (const auto& it : dps) {
67-
auto& itid = it.id;
68-
if (std::strstr(itid.get_alias(), "trd_fedChamberStatus") != nullptr) {
69-
allChamberStatusDPsid.push_back(it.id);
70-
} else if (std::strstr(itid.get_alias(), "trd_fedCFGtag") != nullptr) {
71-
allCFGtagDPsid.push_back(it.id);
54+
// LB: check if all ChamberStatus/CFGtag DPs were sent in dps
55+
// if counter is equal to 540 => all DPs were sent
56+
if (std::strstr(it.id.get_alias(), "trd_fedChamberStatus") != nullptr) {
57+
ChamberStatusDPsCounter++;
58+
} else if (std::strstr(it.id.get_alias(), "trd_fedCFGtag") != nullptr) {
59+
CFGtagDPsCounter++;
7260
}
7361
}
7462

75-
// LB: If at least minimum number of DPs are sent, set ChamberStatus/CFGtag update variables to true
76-
auto ChamberStatusUniqueIterator = std::unique(allChamberStatusDPsid.begin(), allChamberStatusDPsid.end());
77-
auto CFGtagUniqueIterator = std::unique(allCFGtagDPsid.begin(), allCFGtagDPsid.end());
78-
int ChamberStatusUniqueDPsCounter = std::distance(allChamberStatusDPsid.begin(), ChamberStatusUniqueIterator);
79-
int CFGtagUniqueDPsCounter = std::distance(allCFGtagDPsid.begin(), CFGtagUniqueIterator);
80-
if (ChamberStatusUniqueDPsCounter >= mFedMinimunDPsForUpdate) {
63+
if (ChamberStatusDPsCounter >= mFedMinimunDPsForUpdate) {
8164
mFedChamberStatusCompleteDPs = true;
8265
if (mVerbosity > 1) {
8366
LOG(info) << "Minimum number of required DPs (" << mFedMinimunDPsForUpdate << ") for ChamberStatus update were found.";
8467
}
8568
}
86-
87-
if (CFGtagUniqueDPsCounter >= mFedMinimunDPsForUpdate) {
69+
if (CFGtagDPsCounter >= mFedMinimunDPsForUpdate) {
8870
mFedCFGtagCompleteDPs = true;
8971
if (mVerbosity > 1) {
9072
LOG(info) << "Minimum number of required DPs (" << mFedMinimunDPsForUpdate << ") for CFGtag update were found.";
9173
}
9274
}
75+
if (mVerbosity > 1) {
76+
LOG(info) << "Number of ChamberStatus DPs = " << ChamberStatusDPsCounter;
77+
LOG(info) << "Number of CFGtag DPs = " << CFGtagDPsCounter;
78+
}
9379

9480
if (mVerbosity > 1) {
95-
LOG(info) << "Number of ChamberStatus DPs = " << ChamberStatusUniqueDPsCounter;
96-
LOG(info) << "Number of CFGtag DPs = " << CFGtagUniqueDPsCounter;
81+
for (auto& it : mPids) {
82+
const auto& el = mapin.find(it.first);
83+
if (el == mapin.end()) {
84+
LOG(info) << "DP " << it.first << " not found in map";
85+
} else {
86+
LOG(info) << "DP " << it.first << " found in map";
87+
}
88+
}
9789
}
9890

9991
// now we process all DPs, one by one
@@ -246,8 +238,8 @@ int DCSProcessor::processDP(const DPCOM& dpcom)
246238
LOG(info) << "New run number " << o2::dcs::getValue<int32_t>(dpcom) << " differs from the old one " << mCurrentRunNumber;
247239
mShouldUpdateRun = true;
248240
// LB: two different flags as they reset separately, after upload of CCDB, for each object
249-
mNewRunForFedChamberStatusUpdate = true;
250-
mNewRunForFedCFGtagUpdate = true;
241+
mFirstRunEntryForFedChamberStatusUpdate = true;
242+
mFirstRunEntryForFedCFGtagUpdate = true;
251243
mRunEndTS = mCurrentTS;
252244
}
253245

@@ -271,7 +263,7 @@ int DCSProcessor::processDP(const DPCOM& dpcom)
271263
if (etime != mLastDPTimeStamps[dpid]) {
272264
if (dpInfoFedChamberStatus != o2::dcs::getValue<int>(dpcom)) {
273265
// If value changes after processing and DPs should not be updated, log change as warning (for now)
274-
if (mPids[dpid] && !(mFedChamberStatusCompleteDPs && mNewRunForFedChamberStatusUpdate)) {
266+
if (mPids[dpid] && !(mFedChamberStatusCompleteDPs && mFirstRunEntryForFedChamberStatusUpdate)) {
275267
// Issue an alarm if counter is lower than maximum, warning otherwise
276268
if (mFedChamberStatusAlarmCounter < mFedAlarmCounterMax) {
277269
LOG(alarm) << "ChamberStatus change " << dpid.get_alias() << " : " << dpInfoFedChamberStatus << " -> " << o2::dcs::getValue<int>(dpcom) << ", run = " << mCurrentRunNumber;
@@ -299,7 +291,7 @@ int DCSProcessor::processDP(const DPCOM& dpcom)
299291
if (etime != mLastDPTimeStamps[dpid]) {
300292
if (dpInfoFedCFGtag != o2::dcs::getValue<string>(dpcom)) {
301293
// If value changes after processing and DPs should not be updated, log change as warning (for now)
302-
if (mPids[dpid] && !(mFedCFGtagCompleteDPs && mNewRunForFedCFGtagUpdate)) {
294+
if (mPids[dpid] && !(mFedCFGtagCompleteDPs && mFirstRunEntryForFedCFGtagUpdate)) {
303295
// Issue an alarm if counter is lower than maximum, warning otherwise
304296
if (mFedCFGtagAlarmCounter < mFedAlarmCounterMax) {
305297
LOG(alarm) << "CFGtag change " << dpid.get_alias() << " : " << dpInfoFedCFGtag << " -> " << o2::dcs::getValue<string>(dpcom) << ", run = " << mCurrentRunNumber;
@@ -739,7 +731,7 @@ void DCSProcessor::clearFedChamberStatusDPsInfo()
739731
mTRDDCSFedChamberStatus.clear();
740732
mFedChamberStatusStartTSSet = false;
741733
mFedChamberStatusCompleteDPs = false;
742-
mNewRunForFedChamberStatusUpdate = false;
734+
mFirstRunEntryForFedChamberStatusUpdate = false;
743735
mFedChamberStatusAlarmCounter = 0;
744736
// reset the 'processed' flags for the fed DPs
745737
for (auto& it : mPids) {
@@ -756,8 +748,8 @@ void DCSProcessor::clearFedCFGtagDPsInfo()
756748
{
757749
mTRDDCSFedCFGtag.clear();
758750
mFedCFGtagStartTSSet = false;
759-
mFedChamberStatusCompleteDPs = false;
760-
mNewRunForFedChamberStatusUpdate = false;
751+
mFedCFGtagCompleteDPs = false;
752+
mFirstRunEntryForFedCFGtagUpdate = false;
761753
mFedCFGtagAlarmCounter = 0;
762754
// reset the 'processed' flags for the fed DPs
763755
for (auto& it : mPids) {

0 commit comments

Comments
 (0)