Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Modules/FIT/FDD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ target_sources(O2QcFDD PRIVATE
src/CFDEffCheck.cxx
src/OutOfBunchCollCheck.cxx
src/TriggersSwVsTcmCheck.cxx
)
src/OutOfBunchCollFeeModulesCheck.cxx)

target_include_directories(
O2QcFDD
Expand All @@ -37,6 +37,7 @@ add_root_dictionary(O2QcFDD
include/FDD/CFDEffCheck.h
include/FDD/OutOfBunchCollCheck.h
include/FDD/TriggersSwVsTcmCheck.h
include/FDD/OutOfBunchCollFeeModulesCheck.h
LINKDEF include/FDD/LinkDef.h)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/FDD
Expand Down
2 changes: 1 addition & 1 deletion Modules/FIT/FDD/include/FDD/DigitQcTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class DigitQcTask final : public TaskInterface
std::unique_ptr<TH2F> mHistPmTcmAverageTimeC;
std::unique_ptr<TH1F> mHistTriggersSw;
std::unique_ptr<TH2F> mHistTriggersSoftwareVsTCM;

std::unique_ptr<TH2F> mHistBcVsFeeForVtxTrg;
// Hashed maps
static const size_t mapSize = 256;
const std::array<std::vector<double>, mapSize> mHashedBitBinPos; // map with bit position for 1 byte trg signal, for 1 Dim hists;
Expand Down
1 change: 1 addition & 0 deletions Modules/FIT/FDD/include/FDD/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
#pragma link C++ class o2::quality_control_modules::fdd::CFDEffCheck + ;
#pragma link C++ class o2::quality_control_modules::fdd::OutOfBunchCollCheck + ;
#pragma link C++ class o2::quality_control_modules::fdd::TriggersSwVsTcmCheck + ;
#pragma link C++ class o2::quality_control_modules::fdd::OutOfBunchCollFeeModulesCheck + ;
#endif
47 changes: 47 additions & 0 deletions Modules/FIT/FDD/include/FDD/OutOfBunchCollFeeModulesCheck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2023 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#ifndef QC_MODULE_FDD_OUTOFBUNCHCOLLFEEMODULESCHECK_H
#define QC_MODULE_FDD_OUTOFBUNCHCOLLFEEMODULESCHECK_H

#include "QualityControl/CheckInterface.h"

#include "FDDBase/Constants.h"
#include "CommonConstants/LHCConstants.h"

#include <string>

namespace o2::quality_control_modules::fdd
{

class OutOfBunchCollFeeModulesCheck : public o2::quality_control::checker::CheckInterface
{
public:
OutOfBunchCollFeeModulesCheck() = default;
~OutOfBunchCollFeeModulesCheck() override = default;

void configure() override;
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
std::string getAcceptedType() override;

ClassDefOverride(OutOfBunchCollFeeModulesCheck, 1);

private:
float mThreshWarning;
float mThreshError;
float mFractionOutOfBunchColl = 0;
constexpr static std::size_t sBCperOrbit = o2::constants::lhc::LHCMaxBunches;
};

} // namespace o2::quality_control_modules::fdd

#endif // QC_MODULE_FDD_OUTOFBUNCHCOLLFEEMODULESCHECK_H
6 changes: 5 additions & 1 deletion Modules/FIT/FDD/include/FDD/PostProcTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "QualityControl/DatabaseInterface.h"
#include "CCDB/CcdbApi.h"
#include "CommonConstants/LHCConstants.h"
#include "DataFormatsFDD/LookUpTable.h"

#include "FDDBase/Constants.h"
#include "DataFormatsFDD/ChannelData.h"
Expand Down Expand Up @@ -88,10 +89,13 @@ class PostProcTask final : public quality_control::postprocessing::PostProcessin
// if storage size matters it can be replaced with TH1
// and TH2 can be created based on it on the fly, but only TH1 would be stored
std::unique_ptr<TH2F> mHistBcPattern;
std::unique_ptr<TH2F> mHistBcPatternFee;
std::unique_ptr<TH2F> mHistBcTrgOutOfBunchColl;

std::unique_ptr<TH2F> mHistBcFeeOutOfBunchCollForVtxTrg;
std::map<unsigned int, TH1D*> mMapTrgHistBC;

std::array<uint8_t, sNCHANNELS_PM> mChID2PMhash; // map chID->hashed PM value
std::map<std::string, uint8_t> mMapFEE2hash;
int mLowTimeThreshold{ -192 };
int mUpTimeThreshold{ 192 };
double mLowAmpSat;
Expand Down
8 changes: 8 additions & 0 deletions Modules/FIT/FDD/src/DigitQcTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,11 @@ void DigitQcTask::initialize(o2::framework::InitContext& /*ctx*/)

mHistBCvsFEEmodules = std::make_unique<TH2F>("BCvsFEEmodules", "BC vs FEE module;BC;FEE", sBCperOrbit, 0, sBCperOrbit, mapFEE2hash.size(), 0, mapFEE2hash.size());
mHistOrbitVsFEEmodules = std::make_unique<TH2F>("OrbitVsFEEmodules", "Orbit vs FEE module;Orbit;FEE", sOrbitsPerTF, 0, sOrbitsPerTF, mapFEE2hash.size(), 0, mapFEE2hash.size());
mHistBcVsFeeForVtxTrg = std::make_unique<TH2F>("BCvsFEEmodulesForVtxTrg", "BC vs FEE module for Vertex trigger;BC;FEE", sBCperOrbit, 0, sBCperOrbit, mapFEE2hash.size(), 0, mapFEE2hash.size());
for (const auto& entry : mapFEE2hash) {
mHistBCvsFEEmodules->GetYaxis()->SetBinLabel(entry.second + 1, entry.first.c_str());
mHistOrbitVsFEEmodules->GetYaxis()->SetBinLabel(entry.second + 1, entry.first.c_str());
mHistBcVsFeeForVtxTrg->GetYaxis()->SetBinLabel(entry.second + 1, entry.first.c_str());
}
/// ak1
mHistTimeSum2Diff = std::make_unique<TH2F>("timeSumVsDiff", "time A/C side: sum VS diff;(TOC-TOA)/2 [ns];(TOA+TOC)/2 [ns]", 2000, -52.08, 52.08, 2000, -52.08, 52.08); // range of 52.08 ns = 4000*13.02ps = 4000 channels
Expand Down Expand Up @@ -408,6 +410,8 @@ void DigitQcTask::initialize(o2::framework::InitContext& /*ctx*/)
getObjectsManager()->setDefaultDrawOptions(mHistAmp2Ch.get(), "COLZ");
getObjectsManager()->startPublishing(mHistBCvsFEEmodules.get());
getObjectsManager()->setDefaultDrawOptions(mHistBCvsFEEmodules.get(), "COLZ");
getObjectsManager()->startPublishing(mHistBcVsFeeForVtxTrg.get());
getObjectsManager()->setDefaultDrawOptions(mHistBcVsFeeForVtxTrg.get(), "COLZ");
getObjectsManager()->startPublishing(mHistOrbitVsTrg.get());
getObjectsManager()->setDefaultDrawOptions(mHistOrbitVsTrg.get(), "COLZ");
getObjectsManager()->startPublishing(mHistOrbitVsFEEmodules.get());
Expand Down Expand Up @@ -460,6 +464,7 @@ void DigitQcTask::startOfActivity(const Activity& activity)
mHistBCvsFEEmodules->Reset();
mHistOrbitVsTrg->Reset();
mHistOrbitVsFEEmodules->Reset();
mHistBcVsFeeForVtxTrg->Reset();
mHistTriggersCorrelation->Reset();
mHistCycleDuration->Reset();
mHistCycleDurationNTF->Reset();
Expand Down Expand Up @@ -718,6 +723,8 @@ void DigitQcTask::monitorData(o2::framework::ProcessingContext& ctx)
for (const auto& feeHash : setFEEmodules) {
mHistBCvsFEEmodules->Fill(static_cast<double>(digit.getIntRecord().bc), static_cast<double>(feeHash));
mHistOrbitVsFEEmodules->Fill(static_cast<double>(digit.getIntRecord().orbit % sOrbitsPerTF), static_cast<double>(feeHash));
if (digit.mTriggers.getVertex())
mHistBcVsFeeForVtxTrg->Fill(static_cast<double>(digit.getIntRecord().bc), static_cast<double>(feeHash));
}

if (isTCM && digit.mTriggers.getDataIsValid() && !digit.mTriggers.getOutputsAreBlocked()) {
Expand Down Expand Up @@ -946,6 +953,7 @@ void DigitQcTask::reset()
mHistCycleDurationRange->Reset();
mHistBCvsTrg->Reset();
mHistBCvsFEEmodules->Reset();
mHistBcVsFeeForVtxTrg->Reset();
mHistOrbitVsTrg->Reset();
mHistOrbitVsFEEmodules->Reset();
mHistPmTcmNchA->Reset();
Expand Down
156 changes: 156 additions & 0 deletions Modules/FIT/FDD/src/OutOfBunchCollFeeModulesCheck.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// Copyright 2023 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#include "FDD/OutOfBunchCollFeeModulesCheck.h"
#include "QualityControl/MonitorObject.h"
#include "QualityControl/Quality.h"
#include "QualityControl/QcInfoLogger.h"
#include "DataFormatsParameters/GRPLHCIFData.h"

// ROOT
#include <TH1.h>
#include <TH2.h>
#include <TPaveText.h>
#include <TLine.h>
#include <TList.h>

#include <map>
#include <algorithm>
#include <DataFormatsQualityControl/FlagReasons.h>

using namespace std;
using namespace o2::quality_control;

namespace o2::quality_control_modules::fdd
{

void OutOfBunchCollFeeModulesCheck::configure()
{
if (auto param = mCustomParameters.find("thresholdWarning"); param != mCustomParameters.end()) {
mThreshWarning = stof(param->second);
ILOG(Debug, Support) << "configure() : using thresholdWarning = " << mThreshWarning << ENDM;
} else {
mThreshWarning = 1e-3;
ILOG(Debug, Support) << "configure() : using default thresholdWarning = " << mThreshWarning << ENDM;
}

if (auto param = mCustomParameters.find("thresholdError"); param != mCustomParameters.end()) {
mThreshError = stof(param->second);
ILOG(Debug, Support) << "configure() : using thresholdError = " << mThreshError << ENDM;
} else {
mThreshError = 0.1;
ILOG(Debug, Support) << "configure() : using default thresholdError = " << mThreshError << ENDM;
}

if (mThreshError < mThreshWarning) {
ILOG(Debug, Support) << "thresholdError lower than thresholdWarning. Swaping values." << ENDM;
std::swap(mThreshError, mThreshWarning);
}
}

Quality OutOfBunchCollFeeModulesCheck::check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap)
{
Quality result = Quality::Null;

for (auto& [moName, mo] : *moMap) {
(void)moName;
if (mo->getName().find("OutOfBunchColl_BCvsFeeModules") != std::string::npos) {
auto* histogram = dynamic_cast<TH2*>(mo->getObject());

if (!histogram) {
ILOG(Error, Support) << "check(): MO " << mo->getName() << " not found" << ENDM;
result.addReason(FlagReasonFactory::Unknown(), "MO " + mo->getName() + " not found");
result.set(Quality::Null);
return result;
}

std::vector<float> allCollPerFeeModule(mo->getMetadataMap().size() + 1, 0);
for (auto metainfo : mo->getMetadataMap()) {
int bin = 0;
float value = 0;
try {
bin = std::stoi(metainfo.first);
value = std::stof(metainfo.second);
allCollPerFeeModule[bin] = value;
} catch (const std::invalid_argument& e) {
ILOG(Warning, Support) << "Could not get value for key " << metainfo.first << ENDM;
continue;
}
}

// Calculate out-of-bunch-coll fraction for Fee Modules
for (int binY = 1; binY <= histogram->GetNbinsY(); binY++) {
auto outOfBcCollisions = histogram->Integral(1, sBCperOrbit, binY, binY);
float fraction = 0;
if (allCollPerFeeModule[binY]) {
fraction = outOfBcCollisions / allCollPerFeeModule[binY];
}

if (fraction > mFractionOutOfBunchColl) {
mFractionOutOfBunchColl = fraction;
}
}

// Check the biggest fraction of out-of-bunch-coll
if (mFractionOutOfBunchColl > mThreshError) {
result.set(Quality::Bad);
result.addReason(FlagReasonFactory::Unknown(),
Form("Fraction of out of bunch collisions (%.2e) is above \"Error\" threshold (%.2e)",
mFractionOutOfBunchColl, mThreshError));
} else if (mFractionOutOfBunchColl > mThreshWarning) {
result.set(Quality::Medium);
result.addReason(FlagReasonFactory::Unknown(),
Form("Fraction of out of bunch collisions (%.2e) is above \"Warning\" threshold (%.2e)",
mFractionOutOfBunchColl, mThreshWarning));
} else {
result.set(Quality::Good);
}
}
}

return result;
}

std::string OutOfBunchCollFeeModulesCheck::getAcceptedType() { return "TH2"; }

void OutOfBunchCollFeeModulesCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
{
if (mo->getName().find("OutOfBunchColl_BCvsFeeModules") != std::string::npos) {
auto* histogram = dynamic_cast<TH2*>(mo->getObject());

if (!histogram) {
ILOG(Error, Support) << "beautify(): MO " << mo->getName() << " not found" << ENDM;
return;
}

TPaveText* msg = new TPaveText(0.1, 0.85, 0.9, 0.9, "NDC");
histogram->GetListOfFunctions()->Add(msg);
msg->SetName(Form("%s_msg", mo->GetName()));
msg->Clear();
if (checkResult.isWorseThan(Quality::Good)) {
msg->AddText(checkResult.getReasons()[0].second.c_str());
}
int color = kWhite;
if (checkResult == Quality::Good) {
color = kGreen + 1;
msg->AddText(">> Quality::Good <<");
} else if (checkResult == Quality::Medium) {
color = kOrange - 1;
msg->AddText(">> Quality::Medium <<");
} else if (checkResult == Quality::Bad) {
color = kRed;
msg->AddText(">> Quality::Bad <<");
}
msg->SetFillColor(color);
}
}

} // namespace o2::quality_control_modules::fdd
Comment thread
arvindkhuntia marked this conversation as resolved.
Loading