Skip to content

Commit 2b16b65

Browse files
committed
dev:ctpcfg to CCDB
1 parent 77c3b98 commit 2b16b65

File tree

11 files changed

+67
-34
lines changed

11 files changed

+67
-34
lines changed

DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,14 @@ std::ostream& operator<<(std::ostream& in, const CTPConfiguration& conf);
208208
struct CtpCfg
209209
{
210210
CtpCfg() = default;
211-
std::string filename = "/home/alice/trigger/DBCTP/ctp.cfg";
212-
CtpCfg readAndSave();
211+
std::string filename = "ctp.cfg";
212+
CtpCfg readAndSave(std::string& path);
213213
uint32_t TFOrbits = 0;
214214
int ccdb = -1; // -1 means def constructor was called
215215
uint32_t orbitShift = 0;
216216
uint32_t irInputs_1_24 = 0;
217217
uint32_t irInputs_25_48 = 0;
218+
ClassDefNV(CtpCfg, 1)
218219
};
219220
} // namespace ctp
220221
} // namespace o2

DataFormats/Detectors/CTP/src/Configuration.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,9 +1177,9 @@ int CTPInputsConfiguration::getInputIndexFromName(std::string& name)
11771177
return 0xff;
11781178
}
11791179

1180-
CtpCfg CtpCfg::readAndSave()
1180+
CtpCfg CtpCfg::readAndSave(std::string& path)
11811181
{
1182-
std::ifstream ctpcfg(filename);
1182+
std::ifstream ctpcfg(path+filename);
11831183
if (ctpcfg.is_open()) {
11841184
std::string line;
11851185
while (std::getline(ctpcfg, line)) {

DataFormats/Detectors/CTP/src/DataFormatsCTPLinkDef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,6 @@
5555
#pragma link C++ class o2::ctp::TriggerOffsetsParam + ;
5656
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::ctp::TriggerOffsetsParam> + ;
5757

58+
#pragma link C++ class o2::ctp::CtpCfg +;
59+
5860
#endif

Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ class RawDataDecoder
8989
int mErrorTCR = 0;
9090
int mErrorMax = 5;
9191
bool mStickyError = false;
92-
std::array<uint64_t,o2::ctp::CTP_NCLASSES> mClassErrorsA;
93-
std::array<uint64_t,o2::ctp::CTP_NCLASSES> mClassErrorsB; // from inputs
94-
std::array<uint64_t,o2::ctp::CTP_NCLASSES> mClassCountersA;
95-
std::array<uint64_t,o2::ctp::CTP_NCLASSES> mClassCountersB; // from inputs
92+
std::array<uint64_t,o2::ctp::CTP_NCLASSES> mClassErrorsA{};
93+
std::array<uint64_t,o2::ctp::CTP_NCLASSES> mClassErrorsB{}; // from inputs
94+
std::array<uint64_t,o2::ctp::CTP_NCLASSES> mClassCountersA{};
95+
std::array<uint64_t,o2::ctp::CTP_NCLASSES> mClassCountersB{}; // from inputs
9696
int mLostDueToShift = 0;
9797
CTPConfiguration mCTPConfig;
9898
};

Detectors/CTP/reconstruction/src/RawDataDecoder.cxx

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,12 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector<o2
298298
if (mCTPConfig.getRunNumber() != 0) {
299299
trgclassmask = mCTPConfig.getTriggerClassMaskWInputs();
300300
trgclassmaskNOTRGDet = mCTPConfig.getTriggerClassMaskWInputsNoTrgDets();
301+
//mCTPConfig.printStream(std::cout);
301302
}
302-
// std::cout << "trgclassmask:" << std::hex << trgclassmask << std::dec << std::endl;
303+
//std::cout << "trgclassmask:" << std::hex << trgclassmask << std::dec << std::endl;
303304
ret = shiftInputs(digitsMap, digits, mTFOrbit);
304-
if (mCheckConsistency) {
305+
//if (mCheckConsistency) {
306+
if(1) {
305307
ret = checkReadoutConsistentncy(digits, trgclassmask, trgclassmaskNOTRGDet);
306308
}
307309
}
@@ -596,47 +598,63 @@ int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digit
596598
//
597599
int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector<CTPDigit>& digits, uint64_t trgclassmask, uint64_t trgclassmaskNoTrgDet)
598600
{
601+
LOG(debug) << "Checking readout";
599602
int ret = 0;
600603
static int nerror = 0;
601604
for (auto const& digit : digits) {
602605
// if class mask => inps
603606
for (int i = 0; i < digit.CTPClassMask.size(); i++) {
604-
if (digit.CTPClassMask[i] & trgclassmask) {
607+
bool trgcls = trgclassmask & (1ull << i);
608+
if (digit.CTPClassMask[i] & trgcls) {
605609
const CTPClass* cls = mCTPConfig.getCTPClassFromHWIndex(i);
606610
if (cls == nullptr) {
607-
if(nerror < mErrorMax)
611+
if(nerror < mErrorMax) {
608612
LOG(error) << "Class mask index not found in CTP config:" << i;
613+
nerror++;
614+
}
609615
ret = 128;
610616
continue;
611617
}
612618
mClassCountersA[i]++;
619+
if( cls->descriptor == nullptr)
620+
continue;
613621
uint64_t clsinpmask = cls->descriptor->getInputsMask();
614622
uint64_t diginpmask = digit.CTPInputMask.to_ullong();
615623
if (!((clsinpmask & diginpmask) == clsinpmask)) {
616-
if(nerror < mErrorMax)
617-
LOG(error) << "CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask;
624+
if(nerror < mErrorMax) {
625+
LOG(error) << "Cls=>Inps: CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask;
626+
nerror++;
627+
}
618628
mClassErrorsA[i]++;
619629
ret = 128;
620630
}
621631
}
622632
}
623633
// if inps => class mask
624634
for (auto const& cls : mCTPConfig.getCTPClasses()) {
635+
//cls.printStream(std::cout);
636+
if(cls.descriptor == nullptr)
637+
continue;
625638
uint64_t clsinpmask = cls.descriptor->getInputsMask(); // class definition
626639
uint64_t diginpmask = digit.CTPInputMask.to_ullong();
627640
uint64_t digclsmask = digit.CTPClassMask.to_ullong();
628641
if ((clsinpmask & diginpmask) == clsinpmask) {
629-
if ((cls.classMask & digclsmask) == 0) {
630-
int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance().customOffset[o2::detectors::DetID::CTP];
631-
int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance().L0_L1_classes - 1;
632-
offset = o2::constants::lhc::LHCMaxBunches - offset;
633-
if (digit.intRecord.bc < offset) {
634-
if((nerror < mErrorMax) && (cls.classMask & ~trgclassmaskNoTrgDet))
635-
LOG(error) << "CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit;
636-
mClassErrorsB[cls.getIndex()]++;
637-
ret = 256;
638-
} else {
639-
mLostDueToShift++;
642+
if(cls.classMask & trgclassmask) {
643+
mClassCountersB[cls.getIndex()]++;
644+
if ((cls.classMask & digclsmask) == 0) {
645+
int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance().customOffset[o2::detectors::DetID::CTP];
646+
int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance().L0_L1_classes - 1;
647+
offset = o2::constants::lhc::LHCMaxBunches - offset;
648+
if (digit.intRecord.bc < offset) {
649+
if((nerror < mErrorMax) && (cls.classMask & ~trgclassmaskNoTrgDet)){
650+
LOG(info) << "Inp=>Cls: CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit;
651+
nerror++;
652+
}
653+
mClassErrorsB[cls.getIndex()]++;
654+
ret = 256;
655+
} else {
656+
mLostDueToShift++;
657+
}
640658
}
641659
}
642660
}

Detectors/CTP/workflow/src/RawDecoderSpec.cxx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,20 @@ void RawDecoderSpec::endOfStream(framework::EndOfStreamContext& ec)
6969
o0 = TFOrbits[i];
7070
}
7171
std::cout << std::endl;
72+
LOG(info) << " Lost due to the shift:" << mDecoder.getLostDueToShift();
7273
LOG(info) << "Number of missing TF:" << nmiss << std::endl;
73-
LOG(info) << "# of IR errors:" << mDecoder.getErrorIR() << " TCR errors:" << mDecoder.getErrorTCR() << std::endl;
74+
if(mDecoder.getErrorIR() || mDecoder.getErrorTCR())
75+
LOG(error) << "# of IR errors:" << mDecoder.getErrorIR() << " TCR errors:" << mDecoder.getErrorTCR() << std::endl;
7476
std::array<uint64_t, o2::ctp::CTP_NCLASSES> clsA = mDecoder.getClassCountersA();
7577
std::array<uint64_t, o2::ctp::CTP_NCLASSES> clsB = mDecoder.getClassCountersB();
7678
std::array<uint64_t, o2::ctp::CTP_NCLASSES> clsEA = mDecoder.getClassErrorsA();
7779
std::array<uint64_t, o2::ctp::CTP_NCLASSES> clsEB = mDecoder.getClassErrorsB();
7880

7981
for(int i = 0; i < o2::ctp::CTP_NCLASSES; i ++){
8082
bool print = clsA[i] > 0 || clsB[i] > 0 || clsEA[i] > 0 || clsEB[i] > 0;
81-
LOG(important) << "CLASS:" << i << " A:" << clsA[i] << " B:" << clsB[i] << " EA:" << clsEA[i] << " EB:" << clsEB[i];
83+
if(clsEA[i])
84+
LOG(error) << " Class without inputs:";
85+
LOG(important) << "CLASS:" << i << " Cls=>Inp:" << clsA[i] << " Inp=>Cls:" << clsB[i] << " ErrorsCls=>Inps:" << clsEA[i] << " MissingInps=>Cls:" << clsEB[i];
8286
}
8387
}
8488
void RawDecoderSpec::run(framework::ProcessingContext& ctx)

Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class CTPRunManager : public ctpCCDBManager
7272
int mEOX = 0; // redundancy check
7373
int mNew = 1; // 1 - no CCDB: used for QC
7474
int mQCWritePeriod = 3; // Time in 10secs between two writes to QCCD
75-
ClassDefNV(CTPRunManager, 7);
75+
ClassDefNV(CTPRunManager, 8);
7676
};
7777
} // namespace ctp
7878
} // namespace o2

Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ctpCCDBManager
3535
CTPRunScalers getScalersFromCCDB(long timestamp, std::string, bool& ok);
3636
static void setCCDBHost(std::string host) { mCCDBHost = host; };
3737
static void setQCDBHost(std::string host) { mQCDBHost = host; };
38+
void setCtpCfgDir(std::string& ctpcfgdir) { mCtpCfgDir = ctpcfgdir; };
3839

3940
protected:
4041
/// Database constants
@@ -48,6 +49,8 @@ class ctpCCDBManager
4849
const std::string mCCDBPathSoxOrbit = "CTP/Calib/FirstRunOrbit";
4950
const std::string mCCDBPathOrbitReset = "CTP/Calib/OrbitReset";
5051
const std::string mCCDBPathCtpCfg = "CTP/Config/CtpCfg";
52+
std::string mCtpCfgDir;
53+
5154
ClassDefNV(ctpCCDBManager, 2);
5255
};
5356
} // namespace ctp

Detectors/CTP/workflowScalers/src/RunManager.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void CTPRunManager::init()
8787
LOG(info) << "QCDB writing every:" << mQCWritePeriod << " 10 secs";
8888
LOG(info) << "CCDB host:" << mCCDBHost;
8989
LOG(info) << "CTP vNew cfg:" << mNew;
90+
LOG(info) << "ctp.cfg dir:" << mCtpCfgDir;
9091
LOG(info) << "CTPRunManager initialised.";
9192
}
9293
int CTPRunManager::loadRun(const std::string& cfg)
@@ -106,7 +107,7 @@ int CTPRunManager::loadRun(const std::string& cfg)
106107
timeStamp = (tt * 1000.);
107108
LOG(info) << "Timestamp file:" << timeStamp;
108109
cfgmod = cfg.substr(pos, cfg.size());
109-
LOG(info) << "ctpcfg: using ctp time";
110+
LOG(info) << "ctpconfig: using ctp time";
110111
}
111112
}
112113
CTPActiveRun* activerun = new CTPActiveRun;
@@ -122,7 +123,8 @@ int CTPRunManager::loadRun(const std::string& cfg)
122123
//
123124
mRunsLoaded[runnumber] = activerun;
124125
saveRunConfigToCCDB(&activerun->cfg, timeStamp);
125-
saveCtpCfg(runnumber, timeStamp);
126+
if(mCtpCfgDir != "none")
127+
saveCtpCfg(runnumber, timeStamp);
126128
return 0;
127129
}
128130
int CTPRunManager::setRunConfigBK(uint32_t runNumber, const std::string& cfg)

Detectors/CTP/workflowScalers/src/ctp-proxy.cxx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,14 @@
4646
#include "BookkeepingApi/BkpClient.h"
4747
using namespace o2::framework;
4848
using DetID = o2::detectors::DetID;
49-
InjectorFunction dcs2dpl(std::string& ccdbhost, std::string& bkhost, std::string& qchost, int qcwriteperiod)
49+
InjectorFunction dcs2dpl(std::string& ccdbhost, std::string& bkhost, std::string& qchost, int qcwriteperiod, std::string& ctpcfgdir)
5050
{
5151
auto runMgr = std::make_shared<o2::ctp::CTPRunManager>();
5252
runMgr->setCCDBHost(ccdbhost);
5353
runMgr->setBKHost(bkhost);
5454
runMgr->setQCDBHost(qchost);
5555
runMgr->setQCWritePeriod(qcwriteperiod);
56+
runMgr->setCtpCfgDir(ctpcfgdir);
5657
runMgr->init();
5758
// runMgr->setClient(client);
5859
return [runMgr](TimingInfo&, ServiceRegistryRef const& services, fair::mq::Parts& parts, ChannelRetriever channelRetriever, size_t newTimesliceId, bool& stop) -> bool {
@@ -78,6 +79,7 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
7879
workflowOptions.push_back(ConfigParamSpec{"ccdb-host", VariantType::String, "http://o2-ccdb.internal:8080", {"ccdb host"}});
7980
workflowOptions.push_back(ConfigParamSpec{"bk-host", VariantType::String, "none", {"bk host"}});
8081
workflowOptions.push_back(ConfigParamSpec{"qc-host", VariantType::String, "none", {"qc host"}});
82+
workflowOptions.push_back(ConfigParamSpec{"ctpcfg-dir", VariantType::String, "none", {"ctp.cfg file directory"}});
8183
workflowOptions.push_back(ConfigParamSpec{"qc-writeperiod", VariantType::Int, 30, {"Period of writing to QCDB in units of 10secs, default = 30 (5 mins)"}});
8284
}
8385

@@ -104,6 +106,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config)
104106
std::string bkhost = config.options().get<std::string>("bk-host");
105107
std::string qchost = config.options().get<std::string>("qc-host");
106108
int qcwriteperiod = config.options().get<int>("qc-writeperiod");
109+
std::string ctpcfgdir = config.options().get<std::string>("ctpcfg-dir");
107110
if (chan.empty()) {
108111
throw std::runtime_error("input channel is not provided");
109112
}
@@ -118,7 +121,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config)
118121
std::move(ctpCountersOutputs),
119122
// this is just default, can be overriden by --ctp-config-proxy '--channel-config..'
120123
chan.c_str(),
121-
dcs2dpl(ccdbhost, bkhost, qchost, qcwriteperiod));
124+
dcs2dpl(ccdbhost, bkhost, qchost, qcwriteperiod, ctpcfgdir));
122125
ctpProxy.labels.emplace_back(DataProcessorLabel{"input-proxy"});
123126
LOG(info) << "===> Proxy done";
124127
WorkflowSpec workflow;

0 commit comments

Comments
 (0)