From 570e54dc3cc8ab12cf1de48b75b6b286235fafa0 Mon Sep 17 00:00:00 2001 From: Dmitri Peresunko Date: Sat, 19 Mar 2022 21:42:46 +0300 Subject: [PATCH 1/2] ccdb path fixed --- .../Detectors/PHOS/include/DataFormatsPHOS/Cluster.h | 2 +- Detectors/PHOS/calib/src/PHOSBadMapCalibDevice.cxx | 6 +++--- Detectors/PHOS/calib/src/PHOSRunbyrunCalibrator.cxx | 4 ++-- Detectors/PHOS/reconstruction/src/Clusterer.cxx | 3 --- Detectors/PHOS/workflow/src/CellConverterSpec.cxx | 2 +- Detectors/PHOS/workflow/src/ClusterizerSpec.cxx | 4 ++-- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Cluster.h b/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Cluster.h index c9969ca12e4d9..50426be3b6bab 100644 --- a/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Cluster.h +++ b/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Cluster.h @@ -63,7 +63,7 @@ class Cluster void setDispersion(float d) { mDispersion = d; } float getDistanceToBadChannel() const { return mDistToBadChannel; } - void getElipsAxis(float lambdaShort, float lambdaLong) const + void getElipsAxis(float& lambdaShort, float& lambdaLong) const { lambdaShort = mLambdaShort; lambdaLong = mLambdaLong; diff --git a/Detectors/PHOS/calib/src/PHOSBadMapCalibDevice.cxx b/Detectors/PHOS/calib/src/PHOSBadMapCalibDevice.cxx index c0501bf1e12ab..31fb78d1dedd5 100644 --- a/Detectors/PHOS/calib/src/PHOSBadMapCalibDevice.cxx +++ b/Detectors/PHOS/calib/src/PHOSBadMapCalibDevice.cxx @@ -135,13 +135,13 @@ void PHOSBadMapCalibDevice::sendOutput(DataAllocator& output) std::string flName = o2::ccdb::CcdbApi::generateFileName("BadMap"); std::string kind; if (mMode == 0) { // Occupancy - kind = "PHS/Calib/BadMapOcc"; + kind = "PHS/BadMap/Occ"; } if (mMode == 1) { // Chi2 - kind = "PHS/Calib/BadMapChi"; + kind = "PHS/BadMap/Chi"; } if (mMode == 2) { // Pedestals - kind = "PHS/Calib/BadMapPed"; + kind = "PHS/BadMap/Ped"; } std::map md; o2::ccdb::CcdbObjectInfo info(kind, "BadMap", flName, md, mRunStartTime, mValidityTime); diff --git a/Detectors/PHOS/calib/src/PHOSRunbyrunCalibrator.cxx b/Detectors/PHOS/calib/src/PHOSRunbyrunCalibrator.cxx index dcadb84e9f7db..99770db2afae1 100644 --- a/Detectors/PHOS/calib/src/PHOSRunbyrunCalibrator.cxx +++ b/Detectors/PHOS/calib/src/PHOSRunbyrunCalibrator.cxx @@ -68,7 +68,7 @@ void PHOSRunbyrunSlot::fill(const gsl::span& clusters, const gsl: auto& ccdbManager = o2::ccdb::BasicCCDBManager::instance(); ccdbManager.setURL(o2::base::NameConf::getCCDBServer()); LOG(info) << " set-up CCDB " << o2::base::NameConf::getCCDBServer(); - mBadMap = std::make_unique(*(ccdbManager.get("PHS/BadMap"))); + mBadMap = std::make_unique(*(ccdbManager.get("PHS/Calib/BadMap"))); if (!mBadMap) { // was not read from CCDB, but expected LOG(fatal) << "Can not read BadMap from CCDB, you may use --not-use-ccdb option to create default bad map"; @@ -287,4 +287,4 @@ double PHOSRunbyrunCalibrator::CBSignal(double* x, double* par) double PHOSRunbyrunCalibrator::bg(double* x, double* par) { return par[0] + par[1] * x[0] + par[2] * x[0] * x[0]; -} \ No newline at end of file +} diff --git a/Detectors/PHOS/reconstruction/src/Clusterer.cxx b/Detectors/PHOS/reconstruction/src/Clusterer.cxx index 0ba4e26c40dd8..f97c9f6fcab60 100644 --- a/Detectors/PHOS/reconstruction/src/Clusterer.cxx +++ b/Detectors/PHOS/reconstruction/src/Clusterer.cxx @@ -131,10 +131,7 @@ void Clusterer::processCells(gsl::span cells, gsl::span("PHS/BadMap"); + mBadMap = ccdbManager.get("PHS/Calib/BadMap"); if (!mBadMap) { LOG(fatal) << "[PHOSCellConverter - run] can not get Bad Map"; } diff --git a/Detectors/PHOS/workflow/src/ClusterizerSpec.cxx b/Detectors/PHOS/workflow/src/ClusterizerSpec.cxx index 5e8ed00b91d67..e9cb881f21168 100644 --- a/Detectors/PHOS/workflow/src/ClusterizerSpec.cxx +++ b/Detectors/PHOS/workflow/src/ClusterizerSpec.cxx @@ -43,8 +43,8 @@ void ClusterizerSpec::init(framework::InitContext& ctx) ccdbManager.setURL(o2::base::NameConf::getCCDBServer()); LOG(info) << " set-up CCDB " << o2::base::NameConf::getCCDBServer(); - BadChannelsMap* badMap = ccdbManager.get("PHS/BadMap"); - CalibParams* calibParams = ccdbManager.get("PHS/Calib"); + BadChannelsMap* badMap = ccdbManager.get("PHS/Calib/BadMap"); + CalibParams* calibParams = ccdbManager.get("PHS/Calib/CalibParams"); if (badMap) { mClusterizer.setBadMap(badMap); } else { From 45175a0b4dcadf422eca51d64d76641c90dab6c2 Mon Sep 17 00:00:00 2001 From: Dmitri Peresunko Date: Wed, 23 Mar 2022 20:55:02 +0300 Subject: [PATCH 2/2] Validity range fix; debug info added --- .../calib/src/PHOSHGLGRatioCalibDevice.cxx | 3 +- .../calib/src/PHOSPedestalCalibDevice.cxx | 28 +++++++++++++++++-- .../calib/src/PHOSRunbyrunCalibDevice.cxx | 8 ++++-- .../PHOS/reconstruction/src/Clusterer.cxx | 5 ++++ .../src/StandaloneAODProducerSpec.cxx | 2 +- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/Detectors/PHOS/calib/src/PHOSHGLGRatioCalibDevice.cxx b/Detectors/PHOS/calib/src/PHOSHGLGRatioCalibDevice.cxx index 4016bceef9426..9ac6f26e66864 100644 --- a/Detectors/PHOS/calib/src/PHOSHGLGRatioCalibDevice.cxx +++ b/Detectors/PHOS/calib/src/PHOSHGLGRatioCalibDevice.cxx @@ -45,7 +45,8 @@ void PHOSHGLGRatioCalibDevice::run(o2::framework::ProcessingContext& ctx) // scan Cells stream, collect HG/LG pairs if (mRunStartTime == 0) { - mRunStartTime = o2::header::get(ctx.inputs().get("cellTriggerRecords").header)->startTime; + const auto ref = ctx.inputs().getFirstValid(true); + mRunStartTime = DataRefUtils::getHeader(ref)->creation; // approximate time in ms } if (mStatistics <= 0) { // skip the rest of the run diff --git a/Detectors/PHOS/calib/src/PHOSPedestalCalibDevice.cxx b/Detectors/PHOS/calib/src/PHOSPedestalCalibDevice.cxx index c93b9aed0f693..193f607590b83 100644 --- a/Detectors/PHOS/calib/src/PHOSPedestalCalibDevice.cxx +++ b/Detectors/PHOS/calib/src/PHOSPedestalCalibDevice.cxx @@ -32,7 +32,9 @@ void PHOSPedestalCalibDevice::init(o2::framework::InitContext& ic) { mStatistics = ic.options().get("statistics"); // desired number of events - + LOG(info) << "PHOS pedestal init: will collect " << mStatistics << " events"; + LOG(info) << "mUseCCDB (try to get current object) = " << mUseCCDB; + LOG(info) << "mForceUpdate (update CCDB anyway) =" << mForceUpdate; // Create histograms for mean and RMS short n = o2::phos::Mapping::NCHANNELS - 1792; mMeanHG.reset(new TH2F("MeanHighGain", "MeanHighGain", n, 1792.5, n + 1792.5, 100, 0., 100.)); @@ -43,14 +45,19 @@ void PHOSPedestalCalibDevice::init(o2::framework::InitContext& ic) void PHOSPedestalCalibDevice::run(o2::framework::ProcessingContext& ctx) { - // scan Cells stream, collect mean and RMS then calculateaverage and post + // scan Cells stream, collect mean and RMS then calculate average and post + if (mRunStartTime == 0) { - mRunStartTime = o2::header::get(ctx.inputs().get("cellTriggerRecords").header)->startTime; + const auto ref = ctx.inputs().getFirstValid(true); + mRunStartTime = DataRefUtils::getHeader(ref)->creation; // approximate time in ms } if (mStatistics <= 0) { // skip the rest of the run return; } + if (mStatistics % 100 == 0) { + LOG(info) << mStatistics << " left to produce calibration"; + } auto cells = ctx.inputs().get>("cells"); LOG(debug) << "[PHOSPedestalCalibDevice - run] Received " << cells.size() << " cells, running calibration ..."; auto cellsTR = ctx.inputs().get>("cellTriggerRecords"); @@ -70,6 +77,7 @@ void PHOSPedestalCalibDevice::run(o2::framework::ProcessingContext& ctx) --mStatistics; } if (mStatistics <= 0) { + LOG(info) << "Start calculating pedestals"; calculatePedestals(); checkPedestals(); sendOutput(ctx.outputs()); @@ -107,6 +115,19 @@ void PHOSPedestalCalibDevice::sendOutput(DataAllocator& output) header::DataHeader::SubSpecificationType subSpec{(header::DataHeader::SubSpecificationType)0}; output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "PHOS_Pedestal", subSpec}, *image.get()); output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "PHOS_Pedestal", subSpec}, info); + // Now same for DCS as vector + std::vector dcsPedestals(2 * (o2::phos::Mapping::NCHANNELS - 1792)); + // copy HG then LG pedestals + for (short absId = 1793; absId <= o2::phos::Mapping::NCHANNELS; absId++) { + dcsPedestals.emplace_back(mPedestals->getHGPedestal(absId)); + } + for (short absId = 1793; absId <= o2::phos::Mapping::NCHANNELS; absId++) { + dcsPedestals.emplace_back(mPedestals->getLGPedestal(absId)); + } + auto imageDCS = o2::ccdb::CcdbApi::createObjectImage(&dcsPedestals, &info); + header::DataHeader::SubSpecificationType subSpec1{(header::DataHeader::SubSpecificationType)1}; + output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "PHOS_Pedestal", subSpec1}, *imageDCS.get()); + output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "PHOS_Pedestal", subSpec1}, info); } // Anyway send change to QC LOG(info) << "[PHOSPedestalCalibDevice - run] Sending QC "; @@ -137,6 +158,7 @@ void PHOSPedestalCalibDevice::calculatePedestals() mPedestals->setLGRMS(cellId, a); pr->Delete(); } + LOG(info) << "Pedestals calculated"; } void PHOSPedestalCalibDevice::checkPedestals() diff --git a/Detectors/PHOS/calib/src/PHOSRunbyrunCalibDevice.cxx b/Detectors/PHOS/calib/src/PHOSRunbyrunCalibDevice.cxx index f585947674f75..62af45df16903 100644 --- a/Detectors/PHOS/calib/src/PHOSRunbyrunCalibDevice.cxx +++ b/Detectors/PHOS/calib/src/PHOSRunbyrunCalibDevice.cxx @@ -32,6 +32,10 @@ void PHOSRunbyrunCalibDevice::init(o2::framework::InitContext& ic) } void PHOSRunbyrunCalibDevice::run(o2::framework::ProcessingContext& pc) { + if (mRunStartTime == 0) { + const auto ref = pc.inputs().getFirstValid(true); + mRunStartTime = DataRefUtils::getHeader(ref)->creation; // approximate time in ms + } auto tfcounter = o2::header::get(pc.inputs().get("clusters").header)->startTime; // is this the timestamp of the current TF? auto clusters = pc.inputs().get>("clusters"); auto cluTR = pc.inputs().get>("cluTR"); @@ -68,10 +72,10 @@ void PHOSRunbyrunCalibDevice::endOfStream(o2::framework::EndOfStreamContext& ec) << mRunByRun[4] << "+-" << mRunByRun[5] << ", " << mRunByRun[6] << "+-" << mRunByRun[7]; } - //TODO! Send mRunByRun for QC and trending plots + // TODO! Send mRunByRun for QC and trending plots // - //Get ready for next run + // Get ready for next run mCalibrator->initOutput(); // reset the outputs once they are already sent } bool PHOSRunbyrunCalibDevice::checkFitResult() diff --git a/Detectors/PHOS/reconstruction/src/Clusterer.cxx b/Detectors/PHOS/reconstruction/src/Clusterer.cxx index f97c9f6fcab60..52d4354aa786a 100644 --- a/Detectors/PHOS/reconstruction/src/Clusterer.cxx +++ b/Detectors/PHOS/reconstruction/src/Clusterer.cxx @@ -145,6 +145,7 @@ void Clusterer::makeClusters(std::vector& clusters, std::vectorgetFirstCluEl() << " last=" << cluelements.size(); // Unfold overlapped clusters // Split clusters with several local maxima if necessary @@ -624,10 +626,12 @@ char Clusterer::getNumberOfLocalMax(Cluster& clu, std::vector& cluel mIsLocalMax.reserve(clu.getMultiplicity()); uint32_t iFirst = clu.getFirstCluEl(), iLast = clu.getLastCluEl(); + LOG(debug) << "getNumberOfLocalMax: iFirst=" << iFirst << " iLast=" << iLast << " elements=" << cluel.size(); for (uint32_t i = iFirst; i < iLast; i++) { mIsLocalMax.push_back(cluel[i].energy > cluSeed); } + LOG(debug) << "mIsLocalMax size=" << mIsLocalMax.size(); for (uint32_t i = iFirst; i < iLast - 1; i++) { for (int j = i + 1; j < iLast; j++) { @@ -649,6 +653,7 @@ char Clusterer::getNumberOfLocalMax(Cluster& clu, std::vector& cluel } // digit j } // digit i + LOG(debug) << " Filled mIsLocalMax"; int iDigitN = 0; for (int i = 0; i < mIsLocalMax.size(); i++) { if (mIsLocalMax[i]) { diff --git a/Detectors/PHOS/workflow/src/StandaloneAODProducerSpec.cxx b/Detectors/PHOS/workflow/src/StandaloneAODProducerSpec.cxx index d84f40458de43..194be62803fa0 100644 --- a/Detectors/PHOS/workflow/src/StandaloneAODProducerSpec.cxx +++ b/Detectors/PHOS/workflow/src/StandaloneAODProducerSpec.cxx @@ -91,9 +91,9 @@ void StandaloneAODProducerSpec::run(ProcessingContext& pc) c.getEnergy(), // lnAmplitude (dummy value) (c.getType() == TRU2x2) ? 0 : 1, // triggerBits 0:L0 2x2, 1: L1 4x4 0); // caloType 0: PHOS - continue; } + // TODO: should bad map be applied here? Unrecoverable loss of channels: special loose map? // short absId = c.getAbsId(); // if (isBadChannel(absId)) { // continue;