diff --git a/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/CalibParams.h b/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/CalibParams.h index 4b26d1f8a878e..abb9c60957187 100644 --- a/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/CalibParams.h +++ b/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/CalibParams.h @@ -51,7 +51,7 @@ class CalibParams /// \brief Set High Gain energy calibration coefficient /// \param cellID Absolute ID of cell /// \param c is the calibration coefficient - void setGain(short cellID, float c) { mGainCalib[cellID - OFFSET] = c; } + void setGain(short cellID, float c) { mGainCalib.at(cellID - OFFSET) = c; } /// \brief Set High Gain energy calibration coefficients for one module in the form of 2D histogram /// \param 2D(64,56) histogram with calibration coefficients @@ -67,7 +67,7 @@ class CalibParams /// \brief Set High Gain to Low Gain ratio /// \param cellID Absolute ID of cell /// \param r is the calibration coefficient - void setHGLGRatio(short cellID, float r) { mHGLGRatio[cellID - OFFSET] = r; } + void setHGLGRatio(short cellID, float r) { mHGLGRatio.at(cellID - OFFSET) = r; } /// \brief Set High Gain to Low Gain ratio for one module in the form of 2D histogram /// \param 2D(64,56) histogram with High Gain to Low Gain ratio @@ -83,7 +83,7 @@ class CalibParams /// \brief Set High Gain time calibration coefficient /// \param cellID Absolute ID of cell /// \param t is the calibration coefficient - void setHGTimeCalib(short cellID, float t) { mHGTimeCalib[cellID - OFFSET] = t; } + void setHGTimeCalib(short cellID, float t) { mHGTimeCalib.at(cellID - OFFSET) = t; } /// \brief Set High Gain time calibration coefficients for one module in the form of 2D histogram /// \param 2D(64,56) histogram with calibration coefficients @@ -99,7 +99,7 @@ class CalibParams /// \brief Set time calibration coefficient /// \param cellID Absolute ID of cell /// \param t is the calibration coefficient - void setLGTimeCalib(short cellID, float t) { mLGTimeCalib[cellID - OFFSET] = t; } + void setLGTimeCalib(short cellID, float t) { mLGTimeCalib.at(cellID - OFFSET) = t; } /// \brief Set Low Gain time calibration coefficients for one module in the form of 2D histogram /// \param 2D(64,56) histogram with calibration coefficients @@ -108,7 +108,7 @@ class CalibParams bool setLGTimeCalib(TH2* h, char module); private: - static constexpr short NCHANNELS = 14337; ///< Number of channels starting from 1 + static constexpr short NCHANNELS = 12544; ///< Number of channels = 14336-1792 static constexpr short OFFSET = 1793; ///< Non-existing channels 56*64*0.5+1 std::array mGainCalib; ///< Container for the gain calibration coefficients std::array mHGLGRatio; ///< Container for the High Gain to Low Gain ratios diff --git a/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Pedestals.h b/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Pedestals.h index 0162d1ae60ae7..db0834a40ef83 100644 --- a/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Pedestals.h +++ b/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Pedestals.h @@ -36,7 +36,7 @@ class Pedestals // module numbering: // start from module 0 (non-existing), 1 (half-module), 2 (bottom),... 4(highest) // absId: - // start from 1 till 5*64*56. Numbering in each module starts at bottom left and first go in z direction: + // start from 1 till 5*64*56 =14336. Numbering in each module starts at bottom left and first go in z direction: // 56 112 3584 // ... ... ... // 1 57 ...3529 @@ -56,7 +56,7 @@ class Pedestals /// \brief Get pedestal /// \param cellID Absolute ID of cell /// \return pedestal for the cell - short getHGPedestal(short cellID) const { return short(mHGPedestals.at(cellID - OFFSET)); } + short getHGPedestal(short cellID) const { return short(mHGPedestals[cellID - OFFSET]); } /// \brief Set pedestal /// \param cellID Absolute ID of cell @@ -66,7 +66,7 @@ class Pedestals /// \brief Get pedestal /// \param cellID Absolute ID of cell /// \return pedestal for the cell - short getLGPedestal(short cellID) const { return short(mLGPedestals.at(cellID - OFFSET)); } + short getLGPedestal(short cellID) const { return short(mLGPedestals[cellID - OFFSET]); } /// \brief Set pedestal /// \param cellID Absolute ID of cell @@ -86,7 +86,7 @@ class Pedestals /// \brief Get pedestal RMS /// \param cellID Absolute ID of cell /// \return pedestal RMS for the cell - float getHGRMS(short cellID) const { return float(mHGRMS.at(cellID - OFFSET)) / RMSCOMPRESS; } + float getHGRMS(short cellID) const { return float(mHGRMS[cellID - OFFSET]) / RMSCOMPRESS; } /// \brief Set pedestal RMS /// \param cellID Absolute ID of cell @@ -96,7 +96,7 @@ class Pedestals /// \brief Get pedestal /// \param cellID Absolute ID of cell /// \return pedestal RMS for the LG cell - float getLGRMS(short cellID) const { return float(mLGRMS.at(cellID - OFFSET)) / RMSCOMPRESS; } + float getLGRMS(short cellID) const { return float(mLGRMS[cellID - OFFSET]) / RMSCOMPRESS; } /// \brief Set LG pedestal RMS /// \param cellID Absolute ID of cell @@ -104,7 +104,7 @@ class Pedestals void setLGRMS(short cellID, float c) { mLGRMS[cellID - OFFSET] = static_cast(c * RMSCOMPRESS); } private: - static constexpr short NCHANNELS = 14337; ///< Number of channels starting from 1 + static constexpr short NCHANNELS = 12544; ///< Number of channels = 14336-1792 static constexpr short OFFSET = 1793; ///< Non-existing channels 56*64*1.5+1 static constexpr short RMSCOMPRESS = 50; ///< Conversion to store float RMS in range ~[0..5] in uchar std::array mHGPedestals; ///< Container for HG pedestals diff --git a/DataFormats/Detectors/PHOS/src/TriggerMap.cxx b/DataFormats/Detectors/PHOS/src/TriggerMap.cxx index 1bd6113041d9c..02ec3a2d710d9 100644 --- a/DataFormats/Detectors/PHOS/src/TriggerMap.cxx +++ b/DataFormats/Detectors/PHOS/src/TriggerMap.cxx @@ -22,24 +22,44 @@ using namespace o2::phos; TriggerMap::TriggerMap(int param) : mVersion(param) { - if (mVersion >= mParamDescr.size()) { - LOG(ERROR) << "impossible parameterization " << mVersion; + // create default object + // empty (all channels good) bad maps and + // uniform turn-on curves for DDLs + mParamDescr.emplace_back("TestDefault"); + std::array, NDDL> a; + for (int iDDL = 0; iDDL < NDDL; iDDL++) { + a[iDDL].fill(0); + a[iDDL][0] = 1.; //only one step + a[iDDL][1] = 4.; //threshold + a[iDDL][2] = 0.5; //width + } + mParamSets.emplace_back(a); + mCurrentSet = mParamSets[0]; + mVersion = 0; +} + +void TriggerMap::addTurnOnCurvesParams(std::string_view versionName, std::array, 14>& params) +{ + mParamDescr.emplace_back(versionName); + mParamSets.emplace_back(params); +} + +void TriggerMap::setTurnOnCurvesVestion(int v) +{ + if (v >= mParamDescr.size()) { + LOG(ERROR) << "impossible parameterization " << v; LOG(ERROR) << "Available are:"; for (int i = 0; i < mParamDescr.size(); i++) { LOG(ERROR) << i << " : " << mParamDescr[i]; } + LOG(ERROR) << " keep current " << mParamDescr[mVersion]; return; } + mVersion = v; LOG(INFO) << "Will use parameterization " << mParamDescr[mVersion]; mCurrentSet = mParamSets[mVersion]; } -void TriggerMap::addTurnOnCurvesParams(std::string_view versionName, std::array, 14>& params) -{ - mParamDescr.emplace_back(versionName); - mParamSets.emplace_back(params); -} - bool TriggerMap::selectTurnOnCurvesParams(std::string_view versionName) { mVersion = 0; diff --git a/Detectors/PHOS/base/include/PHOSBase/Mapping.h b/Detectors/PHOS/base/include/PHOSBase/Mapping.h index e5345d7046241..ce24572a02e6a 100644 --- a/Detectors/PHOS/base/include/PHOSBase/Mapping.h +++ b/Detectors/PHOS/base/include/PHOSBase/Mapping.h @@ -38,7 +38,7 @@ class Mapping kWrongAbsId, kWrongCaloFlag, kNotInitialized }; - static constexpr short NCHANNELS = 14337; ///< Number of channels starting from 1 + static constexpr short NCHANNELS = 14336; ///< Number of channels starting from 1 static constexpr short NHWPERDDL = 2048; ///< Number of HW addressed per DDL static constexpr short NMaxHWAddress = 3929; ///< Maximal HW address (size of array) static constexpr short NDDL = 14; ///< Total number of DDLs diff --git a/Detectors/PHOS/base/src/Geometry.cxx b/Detectors/PHOS/base/src/Geometry.cxx index b57fcc47853b8..31cbcd842aaed 100644 --- a/Detectors/PHOS/base/src/Geometry.cxx +++ b/Detectors/PHOS/base/src/Geometry.cxx @@ -24,12 +24,12 @@ ClassImp(Geometry); // 56 112 3584 // ... ... ... // 1 57 ...3529 -// relid[3]: (module number[0...3], iphi[1...64], iz[1...56]) +// relid[3]: (module number[1...4], iphi[1...64], iz[1...56]) // -// Then TRU channels go 112 per branch, 2 branches per ddl +// Then TRU channels go from 1 to 112 per branch, 2 branches per ddl // absId = getTotalNCells() + TRUabsId ; // relId for TRU -// relid: [DDL id=0..13] [x in 2x2 system: 0..7] [z in 2x2 system 0..27] TODO: verify with real TRU data!!! +// relid: [DDL id=0..13] [x in 2x2 system: 1..8] [z in 2x2 system 1..28] TODO: verify with real TRU data!!! // these initialisations are needed for a singleton Geometry* Geometry::sGeom = nullptr; @@ -71,36 +71,37 @@ bool Geometry::absToRelNumbering(short absId, char* relid) // relid[2] = Column number inside a PHOS module (Phi coordinate) const short nZ = 56; // nStripZ * nCellsZInStrip const short nPhi = 64; // nStripZ * nCellsZInStrip - - short phosmodulenumber = (absId - 1) / (nZ * nPhi); + absId--; + short phosmodulenumber = absId / (nZ * nPhi); relid[0] = phosmodulenumber + 1; absId -= phosmodulenumber * nPhi * nZ; - relid[1] = 1 + (absId - 1) / nZ; - relid[2] = absId - (relid[1] - 1) * nZ; + relid[1] = 1 + absId / nZ; + relid[2] = absId - (relid[1] - 1) * nZ + 1; return true; } bool Geometry::truAbsToRelNumbering(short truId, char* relid) { //convert trigger cell Id to + truId--; relid[0] = truId / 224; //2*112 channels // DDL id truId = truId % 224; - relid[1] = truId % 8; // x index in TRU internal 2x2 coordinate system - relid[2] = truId / 8; // z index in TRU internal 2x2 coordinate system + relid[1] = 1 + truId % 8; // x index in TRU internal 2x2 coordinate system + relid[2] = 1 + truId / 8; // z index in TRU internal 2x2 coordinate system return true; } short Geometry::truRelToAbsNumbering(const char* relId) { - return relId[0] * 224 + // the offset of PHOS modules - relId[1] + // the offset along phi - relId[2] * 8; // the offset along z + return relId[0] * 224 + // the offset of PHOS modules + relId[1] - 1 + // the offset along phi + (relId[2] - 1) * 8; // the offset along z } bool Geometry::truRelId2RelId(const char* truRelId, char* relId) { relId[0] = 1 + (truRelId[0] + 2) / 4; - relId[1] = ((truRelId[0] + 2) % 4) * 16 + truRelId[1] * 2 + 1; - relId[2] = truRelId[2] * 2 + 1; + relId[1] = ((truRelId[0] + 2) % 4) * 16 + truRelId[1] * 2 - 1; + relId[2] = truRelId[2] * 2 - 1; return true; } short Geometry::relPosToTruId(char mod, float x, float z, short& ddl) @@ -108,7 +109,7 @@ short Geometry::relPosToTruId(char mod, float x, float z, short& ddl) //tranform local cluster coordinates to truId char relid[3] = {mod, static_cast(ceil(x / CELLSTEP + 32.5)), static_cast(ceil(z / CELLSTEP + 28.5))}; ddl = (mod - 1) * 4 + relid[1] / 16 - 2; - char truid[3] = {static_cast(ddl), static_cast((relid[1] % 16) / 2), static_cast(relid[2] / 2)}; + char truid[3] = {static_cast(ddl), static_cast(1 + ((relid[1] - 1) % 16) / 2), static_cast(1 + (relid[2] - 1) / 2)}; return truRelToAbsNumbering(truid); } diff --git a/Detectors/PHOS/base/src/Mapping.cxx b/Detectors/PHOS/base/src/Mapping.cxx index d9d142062e437..b8df3ae3817ea 100644 --- a/Detectors/PHOS/base/src/Mapping.cxx +++ b/Detectors/PHOS/base/src/Mapping.cxx @@ -108,8 +108,8 @@ Mapping::ErrorStatus Mapping::absIdTohw(short absId, short caloFlag, short& ddl, return kNotInitialized; } - ddl = mAbsToHW[absId][caloFlag][0]; - hwAddr = mAbsToHW[absId][caloFlag][1]; + ddl = mAbsToHW[absId - 1][caloFlag][0]; + hwAddr = mAbsToHW[absId - 1][caloFlag][1]; return kOK; } //_______________________________________________________ @@ -205,8 +205,8 @@ Mapping::ErrorStatus Mapping::setMapping() mAbsId[ddl][hwAddress] = absId; mCaloFlag[ddl][hwAddress] = (CaloFlag)caloFlag; - mAbsToHW[absId][caloFlag][0] = ddl; - mAbsToHW[absId][caloFlag][1] = hwAddress; + mAbsToHW[absId - 1][caloFlag][0] = ddl; + mAbsToHW[absId - 1][caloFlag][1] = hwAddress; } fIn.close(); } //RCU diff --git a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSPedestalCalibDevice.h b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSPedestalCalibDevice.h index 82fb3a518fceb..bb77c4278c3bc 100644 --- a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSPedestalCalibDevice.h +++ b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSPedestalCalibDevice.h @@ -47,19 +47,18 @@ class PHOSPedestalCalibDevice : public o2::framework::Task private: bool mUseCCDB = false; - bool mForceUpdate = false; /// Update CCDB even if difference to current is large - bool mUpdateCCDB = true; /// set is close to current and can update it - static constexpr short kMinorChange = 10; /// ignore if number of channels changed smaller than... - long mRunStartTime = 0; /// start time of the run (sec) - std::string mCCDBPath{"http://ccdb-test.cern.ch:8080"}; /// CCDB path to retrieve current CCDB objects for comparison - std::unique_ptr mPedestals; //! Final calibration object - std::unique_ptr mOldPed; //! Pedestals currently stored in CCDB for comparisoin - std::unique_ptr mMeanHG; //! Mean values in High Gain channels - std::unique_ptr mMeanLG; //! RMS of values in High Gain channels - std::unique_ptr mRMSHG; //! Mean values in Low Gain channels - std::unique_ptr mRMSLG; //! RMS of values in Low Gain channels - std::array mPedHGDiff; //! Pedestal variation wrt previous map - std::array mPedLGDiff; //! Pedestal variation wrt previous map + bool mForceUpdate = false; /// Update CCDB even if difference to current is large + bool mUpdateCCDB = true; /// set is close to current and can update it + static constexpr short kMinorChange = 10; /// ignore if number of channels changed smaller than... + long mRunStartTime = 0; /// start time of the run (sec) + std::string mCCDBPath{"http://ccdb-test.cern.ch:8080"}; /// CCDB path to retrieve current CCDB objects for comparison + std::unique_ptr mPedestals; //! Final calibration object + std::unique_ptr mOldPed; //! Pedestals currently stored in CCDB for comparisoin + std::unique_ptr mMeanHG; //! Mean values in High Gain channels + std::unique_ptr mMeanLG; //! RMS of values in High Gain channels + std::unique_ptr mRMSHG; //! Mean values in Low Gain channels + std::unique_ptr mRMSLG; //! RMS of values in Low Gain channels + std::array mPedDiff; //! Pedestal variation wrt previous map }; o2::framework::DataProcessorSpec getPedestalCalibSpec(bool useCCDB, bool forceUpdate, std::string path); diff --git a/Detectors/PHOS/calib/src/PHOSHGLGRatioCalibDevice.cxx b/Detectors/PHOS/calib/src/PHOSHGLGRatioCalibDevice.cxx index a8a728619f256..997d082277a4f 100644 --- a/Detectors/PHOS/calib/src/PHOSHGLGRatioCalibDevice.cxx +++ b/Detectors/PHOS/calib/src/PHOSHGLGRatioCalibDevice.cxx @@ -30,8 +30,8 @@ void PHOSHGLGRatioCalibDevice::init(o2::framework::InitContext& ic) { //Create histograms for mean and RMS - short n = o2::phos::Mapping::NCHANNELS; - mhRatio.reset(new TH2F("HGLGRatio", "HGLGRatio", n, 0.5, n + 0.5, 100, 10., 20.)); + short n = o2::phos::Mapping::NCHANNELS - 1792; + mhRatio.reset(new TH2F("HGLGRatio", "HGLGRatio", n, 1792.5, n + 1792.5, 100, 10., 20.)); mCalibParams.reset(new CalibParams()); } @@ -115,7 +115,7 @@ void PHOSHGLGRatioCalibDevice::calculateRatios() } tmp->Fit(fitFunc, "QL0", "", 0., 20.); float a = fitFunc->GetParameter(1); - mCalibParams->setHGLGRatio(i - 1, a); //absId starts from 0 + mCalibParams->setHGLGRatio(i, a); //absId starts from 0 tmp->Delete(); } } @@ -174,7 +174,7 @@ void PHOSHGLGRatioCalibDevice::sendOutput(DataAllocator& output) { // extract CCDB infos and calibration objects, convert it to TMemFile and send them to the output - if (mUseCCDB && (mUpdateCCDB || mForceUpdate)) { + if (mUpdateCCDB || mForceUpdate) { // prepare all info to be sent to CCDB auto flName = o2::ccdb::CcdbApi::generateFileName("CalibParams"); std::map md; @@ -193,27 +193,21 @@ void PHOSHGLGRatioCalibDevice::sendOutput(DataAllocator& output) } //Anyway send change to QC LOG(INFO) << "[PHOSHGLGRatioCalibDevice - sendOutput] Sending QC "; - if (mUseCCDB) { //can get previous calibration - output.snapshot(o2::framework::Output{"PHS", "HGLGRATIODIFF", 0, o2::framework::Lifetime::Timeframe}, mRatioDiff); - } + output.snapshot(o2::framework::Output{"PHS", "CALIBDIFF", 0, o2::framework::Lifetime::Timeframe}, mRatioDiff); } DataProcessorSpec o2::phos::getHGLGRatioCalibSpec(bool useCCDB, bool forceUpdate, std::string path) { std::vector inputs; - inputs.emplace_back("cells", o2::header::gDataOriginPHS, "CELLS", 0, o2::framework::Lifetime::Timeframe); - inputs.emplace_back("cellTriggerRecords", o2::header::gDataOriginPHS, "CELLTRIGREC", 0, o2::framework::Lifetime::Timeframe); + inputs.emplace_back("cells", ConcreteDataTypeMatcher{o2::header::gDataOriginPHS, "CELLS"}, o2::framework::Lifetime::Timeframe); + inputs.emplace_back("cellTriggerRecords", ConcreteDataTypeMatcher{o2::header::gDataOriginPHS, "CELLTRIGREC"}, o2::framework::Lifetime::Timeframe); using clbUtils = o2::calibration::Utils; std::vector outputs; - if (useCCDB) { - outputs.emplace_back( - ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBPayload, "PHOS_HGLGratio"}); - outputs.emplace_back( - ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBWrapper, "PHOS_HGLGratio"}); - outputs.emplace_back("PHS", "HGLGRATIODIFF", 0, o2::framework::Lifetime::Timeframe); - } + outputs.emplace_back(o2::header::gDataOriginPHS, "CALIBDIFF", 0, o2::framework::Lifetime::Timeframe); + outputs.emplace_back(ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBPayload, "PHOS_HGLGratio"}); + outputs.emplace_back(ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBWrapper, "PHOS_HGLGratio"}); return o2::framework::DataProcessorSpec{"HGLGRatioCalibSpec", inputs, outputs, diff --git a/Detectors/PHOS/calib/src/PHOSPedestalCalibDevice.cxx b/Detectors/PHOS/calib/src/PHOSPedestalCalibDevice.cxx index 19d9d9fd1f570..84a73bd25bc60 100644 --- a/Detectors/PHOS/calib/src/PHOSPedestalCalibDevice.cxx +++ b/Detectors/PHOS/calib/src/PHOSPedestalCalibDevice.cxx @@ -29,11 +29,11 @@ void PHOSPedestalCalibDevice::init(o2::framework::InitContext& ic) { //Create histograms for mean and RMS - short n = o2::phos::Mapping::NCHANNELS; - mMeanHG.reset(new TH2F("MeanHighGain", "MeanHighGain", n, 0.5, n + 0.5, 100, 0., 100.)); - mMeanLG.reset(new TH2F("MeanLowGain", "MeanLowGain", n, 0.5, n + 0.5, 100, 0., 100.)); - mRMSHG.reset(new TH2F("RMSHighGain", "RMSHighGain", n, 0.5, n + 0.5, 100, 0., 10.)); - mRMSLG.reset(new TH2F("RMSLowGain", "RMSLowGain", n, 0.5, n + 0.5, 100, 0., 10.)); + short n = o2::phos::Mapping::NCHANNELS - 1792; + mMeanHG.reset(new TH2F("MeanHighGain", "MeanHighGain", n, 1792.5, n + 1792.5, 100, 0., 100.)); + mMeanLG.reset(new TH2F("MeanLowGain", "MeanLowGain", n, 1792.5, n + 1792.5, 100, 0., 100.)); + mRMSHG.reset(new TH2F("RMSHighGain", "RMSHighGain", n, 1792.5, n + 1792.5, 100, 0., 10.)); + mRMSLG.reset(new TH2F("RMSLowGain", "RMSLowGain", n, 1792.5, n + 1792.5, 100, 0., 10.)); } void PHOSPedestalCalibDevice::run(o2::framework::ProcessingContext& ctx) @@ -76,7 +76,7 @@ void PHOSPedestalCalibDevice::sendOutput(DataAllocator& output) { // extract CCDB infos and calibration objects, convert it to TMemFile and send them to the output - if (mUseCCDB && (mUpdateCCDB || mForceUpdate)) { + if (mUpdateCCDB || mForceUpdate) { // prepare all info to be sent to CCDB auto flName = o2::ccdb::CcdbApi::generateFileName("Pedestals"); std::map md; @@ -95,34 +95,31 @@ void PHOSPedestalCalibDevice::sendOutput(DataAllocator& output) } //Anyway send change to QC LOG(INFO) << "[PHOSPedestalCalibDevice - run] Sending QC "; - if (mUseCCDB) { //can get previous calibration - output.snapshot(o2::framework::Output{"PHS", "PEDDIFF", 0, o2::framework::Lifetime::Timeframe}, mPedHGDiff); - output.snapshot(o2::framework::Output{"PHS", "PEDDIFF", 0, o2::framework::Lifetime::Timeframe}, mPedLGDiff); - } + output.snapshot(o2::framework::Output{"PHS", "CALIBDIFF", 0, o2::framework::Lifetime::Timeframe}, mPedDiff); } void PHOSPedestalCalibDevice::calculatePedestals() { - mPedestals.reset(new Pedestals()); //Calculate mean of pedestal distributions for (unsigned short i = mMeanHG->GetNbinsX(); i > 0; i--) { TH1D* pr = mMeanHG->ProjectionY(Form("proj%d", i), i, i); float a = pr->GetMean(); - mPedestals->setHGPedestal(i - 1, std::min(255, int(a))); + short cellId = static_cast(mMeanHG->GetXaxis()->GetBinCenter(i)); + mPedestals->setHGPedestal(cellId, std::min(255, int(a))); pr->Delete(); pr = mMeanLG->ProjectionY(Form("projLG%d", i), i, i); a = pr->GetMean(); - mPedestals->setLGPedestal(i - 1, std::min(255, int(a))); + mPedestals->setLGPedestal(cellId, std::min(255, int(a))); pr->Delete(); pr = mRMSHG->ProjectionY(Form("projRMS%d", i), i, i); a = pr->GetMean(); - mPedestals->setHGRMS(i - 1, a); + mPedestals->setHGRMS(cellId, a); pr->Delete(); pr = mRMSLG->ProjectionY(Form("projRMSLG%d", i), i, i); a = pr->GetMean(); - mPedestals->setLGRMS(i - 1, a); + mPedestals->setLGRMS(cellId, a); pr->Delete(); } } @@ -151,17 +148,17 @@ void PHOSPedestalCalibDevice::checkPedestals() int nChanged = 0; for (short i = o2::phos::Mapping::NCHANNELS; i > 1792; i--) { short dp = mPedestals->getHGPedestal(i) - currentPedestals->getHGPedestal(i); - mPedHGDiff[i] = dp; + mPedDiff[i] = dp; if (abs(dp) > 1) { //not a fluctuation nChanged++; } dp = mPedestals->getLGPedestal(i) - currentPedestals->getLGPedestal(i); - mPedLGDiff[i] = dp; + mPedDiff[i + o2::phos::Mapping::NCHANNELS] = dp; if (abs(dp) > 1) { //not a fluctuation nChanged++; } } - LOG(INFO) << nChanged << "channels changed more that 1 ADC channel"; + LOG(INFO) << nChanged << " channels changed more that 1 ADC channel"; if (nChanged > kMinorChange) { //serious change, do not update CCDB automatically, use "force" option to overwrite LOG(ERROR) << "too many channels changed: " << nChanged << " (threshold not more than " << kMinorChange << ")"; if (!mForceUpdate) { @@ -177,18 +174,14 @@ o2::framework::DataProcessorSpec o2::phos::getPedestalCalibSpec(bool useCCDB, bo { std::vector inputs; - inputs.emplace_back("cells", o2::header::gDataOriginPHS, "CELLS", 0, o2::framework::Lifetime::Timeframe); - inputs.emplace_back("cellTriggerRecords", o2::header::gDataOriginPHS, "CELLTRIGREC", 0, o2::framework::Lifetime::Timeframe); + inputs.emplace_back("cells", ConcreteDataTypeMatcher{o2::header::gDataOriginPHS, "CELLS"}, o2::framework::Lifetime::Timeframe); + inputs.emplace_back("cellTriggerRecords", ConcreteDataTypeMatcher{o2::header::gDataOriginPHS, "CELLTRIGREC"}, o2::framework::Lifetime::Timeframe); using clbUtils = o2::calibration::Utils; std::vector outputs; - if (useCCDB) { - outputs.emplace_back( - ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBPayload, "PHOS_Pedestal"}); - outputs.emplace_back( - ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBWrapper, "PHOS_Pedestal"}); - outputs.emplace_back("PHS", "PEDDIFF", 0, o2::framework::Lifetime::Timeframe); - } + outputs.emplace_back(o2::header::gDataOriginPHS, "CALIBDIFF", 0, o2::framework::Lifetime::Timeframe); + outputs.emplace_back(ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBPayload, "PHOS_Pedestal"}); + outputs.emplace_back(ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBWrapper, "PHOS_Pedestal"}); return o2::framework::DataProcessorSpec{"PedestalCalibSpec", inputs, outputs, diff --git a/Detectors/PHOS/reconstruction/src/Clusterer.cxx b/Detectors/PHOS/reconstruction/src/Clusterer.cxx index af9dda111121c..cbb11217b5e31 100644 --- a/Detectors/PHOS/reconstruction/src/Clusterer.cxx +++ b/Detectors/PHOS/reconstruction/src/Clusterer.cxx @@ -81,12 +81,12 @@ void Clusterer::process(gsl::span digits, gsl::span cells, gsl::span ctr, @@ -133,13 +133,12 @@ void Clusterer::processCells(gsl::span cells, gsl::span& clusters, std::vector& cluelements) diff --git a/Detectors/PHOS/simulation/src/Digitizer.cxx b/Detectors/PHOS/simulation/src/Digitizer.cxx index 22655e7c94e2e..59ede259e6827 100644 --- a/Detectors/PHOS/simulation/src/Digitizer.cxx +++ b/Detectors/PHOS/simulation/src/Digitizer.cxx @@ -162,12 +162,12 @@ void Digitizer::processHits(const std::vector* hits, const std::vectorisGood2x2(tileId)) { @@ -210,8 +210,8 @@ void Digitizer::processHits(const std::vector* hits, const std::vectorisGood4x4(tileId)) { @@ -240,7 +240,6 @@ void Digitizer::processHits(const std::vector* hits, const std::vector PHOSSimParams::Instance().mZSthreshold) { digitsOut.push_back(mArrayD[i]); diff --git a/Detectors/PHOS/workflow/src/RawToCellConverterSpec.cxx b/Detectors/PHOS/workflow/src/RawToCellConverterSpec.cxx index e867ba8faf266..81251c2865206 100644 --- a/Detectors/PHOS/workflow/src/RawToCellConverterSpec.cxx +++ b/Detectors/PHOS/workflow/src/RawToCellConverterSpec.cxx @@ -100,7 +100,28 @@ void RawToCellConverterSpec::run(framework::ProcessingContext& ctx) mOutputFitChi.clear(); } - for (const auto& rawData : framework::InputRecordWalker(ctx.inputs())) { + // if we see requested data type input with 0xDEADBEEF subspec and 0 payload this means that the "delayed message" + // mechanism created it in absence of real data from upstream. Processor should send empty output to not block the workflow + std::vector dummy{o2::framework::InputSpec{"dummy", o2::framework::ConcreteDataMatcher{"PHS", o2::header::gDataDescriptionRawData, 0xDEADBEEF}}}; + for (const auto& ref : framework::InputRecordWalker(ctx.inputs(), dummy)) { + const auto dh = o2::framework::DataRefUtils::getHeader(ref); + if (dh->payloadSize == 0) { // send empty output + mOutputCells.clear(); + ctx.outputs().snapshot(o2::framework::Output{"PHS", "CELLS", 0, o2::framework::Lifetime::Timeframe}, mOutputCells); + mOutputTriggerRecords.clear(); + ctx.outputs().snapshot(o2::framework::Output{"PHS", "CELLTRIGREC", 0, o2::framework::Lifetime::Timeframe}, mOutputTriggerRecords); + mOutputHWErrors.clear(); + ctx.outputs().snapshot(o2::framework::Output{"PHS", "RAWHWERRORS", 0, o2::framework::Lifetime::Timeframe}, mOutputHWErrors); + if (mFillChi2) { + mOutputFitChi.clear(); + ctx.outputs().snapshot(o2::framework::Output{"PHS", "CELLFITQA", 0, o2::framework::Lifetime::Timeframe}, mOutputFitChi); + } + return; //empty TF, nothing to process + } + } + + std::vector inputFilter{o2::framework::InputSpec{"filter", o2::framework::ConcreteDataTypeMatcher{"PHS", "RAWDATA"}, o2::framework::Lifetime::Timeframe}}; + for (const auto& rawData : framework::InputRecordWalker(ctx.inputs(), inputFilter)) { o2::phos::RawReaderMemory rawreader(o2::framework::DataRefUtils::as(rawData)); @@ -237,7 +258,9 @@ void RawToCellConverterSpec::run(framework::ProcessingContext& ctx) o2::framework::DataProcessorSpec o2::phos::reco_workflow::getRawToCellConverterSpec(int flpId) { std::vector inputs; - inputs.emplace_back("RAWDATA", o2::framework::ConcreteDataTypeMatcher{"PHS", "RAWDATA"}, o2::framework::Lifetime::Timeframe); + inputs.emplace_back("RAWDATA", o2::framework::ConcreteDataTypeMatcher{"PHS", "RAWDATA"}, o2::framework::Lifetime::Optional); + //receive at least 1 guaranteed input (which will allow to acknowledge the TF) + inputs.emplace_back("STFDist", "FLP", "DISTSUBTIMEFRAME", 0, o2::framework::Lifetime::Timeframe); std::vector outputs; outputs.emplace_back("PHS", "CELLS", flpId, o2::framework::Lifetime::Timeframe); diff --git a/Steer/DigitizerWorkflow/src/PHOSDigitizerSpec.cxx b/Steer/DigitizerWorkflow/src/PHOSDigitizerSpec.cxx index 6152b6c3a6ce3..e45cf87bf5b56 100644 --- a/Steer/DigitizerWorkflow/src/PHOSDigitizerSpec.cxx +++ b/Steer/DigitizerWorkflow/src/PHOSDigitizerSpec.cxx @@ -135,7 +135,7 @@ void DigitizerSpec::run(framework::ProcessingContext& pc) retrieveHits("PHSHit", source, entry); part++; if (part == eventParts[collID].end() && isLastStream) { //last stream, copy digits directly to output vector - mDigitizer.processHits(mHits, mDigitsFinal, mDigitsOut, mLabels, collID, source, dt); + mDigitizer.processHits(mHits, mDigitsFinal, mDigitsOut, mLabels, entry, source, dt); mDigitsFinal.clear(); //finalyze previous event and clean // Add trigger record @@ -143,7 +143,7 @@ void DigitizerSpec::run(framework::ProcessingContext& pc) indexStart = mDigitsOut.size(); } else { //Fill intermediate digitvector mDigitsTmp.swap(mDigitsFinal); - mDigitizer.processHits(mHits, mDigitsTmp, mDigitsFinal, mLabels, collID, source, dt); + mDigitizer.processHits(mHits, mDigitsTmp, mDigitsFinal, mLabels, entry, source, dt); mDigitsTmp.clear(); } }