17#include <fairlogger/Logger.h>
41 const float kMaxCut = 10.;
42 const float kMinCut = 0.1;
44 if (mMethod % 2 == 0) {
46 std::string
filename = mPath +
"CPVGains.root";
48 TH2F* spectra =
nullptr;
50 spectra =
static_cast<TH2F*
>(
f.Get(
"Gains"));
53 LOG(error) <<
"ERROR: can not read histo Gains from file " <<
filename.data();
56 float meanOccupancy = spectra->Integral() / spectra->GetNbinsX();
57 short nBadChannels = 0;
58 float improvedOccupancy = meanOccupancy;
61 meanOccupancy = improvedOccupancy;
62 improvedOccupancy = 0;
64 for (
unsigned short i = spectra->GetNbinsX(); --
i;) {
65 float a = spectra->Integral(
i + 1,
i + 1, 1, 1024);
66 if (
a > kMaxCut * meanOccupancy + 1 ||
a < kMinCut * meanOccupancy - 1 ||
a == 0) {
67 if (mBadMap->isChannelGood(
i)) {
68 mBadMap->addBadChannel(
i);
72 improvedOccupancy +=
a;
77 improvedOccupancy /= ngood;
79 }
while (nBadChannels > 0);
86 std::string
filename = mPath +
"CPVPedestals.root";
88 TH2F* pedestals =
nullptr;
90 pedestals =
static_cast<TH2F*
>(
f.Get(
"Mean"));
93 LOG(error) <<
"ERROR: can not read histo Mean from file " <<
filename.data();
96 TH1D* proj = pedestals->ProjectionY(
"m");
97 float meanPed = proj->GetMean();
98 float rmsPed = proj->GetRMS();
100 short nBadChannels = 0;
101 float improvedMean = meanPed, improvedRMS = rmsPed;
104 meanPed = improvedMean;
105 rmsPed = improvedRMS;
109 for (
unsigned short i = pedestals->GetNbinsX(); --
i;) {
110 TH1D* pr = pedestals->ProjectionY(Form(
"proj%d",
i),
i + 1,
i + 1);
111 float prMean = pr->GetMean();
112 float prRMS = pr->GetRMS();
114 if (prMean > kMaxCut * meanPed || prMean < kMinCut * meanPed || prMean == 0 ||
115 prRMS > kMaxCut * rmsPed || prRMS < kMinCut * rmsPed) {
116 if (mBadMap->isChannelGood(
i)) {
117 mBadMap->addBadChannel(
i);
121 improvedMean += prMean;
122 improvedRMS += prRMS;
127 improvedMean /= ngood;
128 improvedRMS /= ngood;
130 }
while (nBadChannels > 0);
145 LOG(info) <<
"[CPVBadMapCalibDevice - endOfStream]";
154 if (mUpdateCCDB || mForceUpdate) {
160 info.
setPath(
"CPV/Calib/BadChannelMap");
164 time_t now =
time(
nullptr);
167 std::map<std::string, std::string> md;
170 LOG(info) <<
"Sending object CPV/Calib/BadChannelMap";
208 std::vector<o2::framework::OutputSpec> outputs;
212 outputs.emplace_back(
"CPV",
"BADMAPCHANGE", 0, o2::framework::Lifetime::Sporadic);
217 o2::framework::adaptFromTask<CPVBadMapCalibDevice>(useCCDB, forceUpdate,
path, method),
Utils and constants for calibration and related workflows.
static std::string generateFileName(const std::string &inp)
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
void setStartValidityTimestamp(long start)
void setFileName(const std::string &nm)
void setPath(const std::string &path)
void setEndValidityTimestamp(long end)
void setObjectType(const std::string &tp)
void setMetaData(const std::map< std::string, std::string > &md)
static constexpr long INFINITE_TIMESTAMP
CCDB container for bad (masked) channels in CPV.
void init(o2::framework::InitContext &ic) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void run(o2::framework::ProcessingContext &pc) final
void sendOutput(DataAllocator &output)
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
ServiceRegistryRef services()
The services registry associated with this processing context.
GLsizei const GLchar *const * path
GLboolean GLboolean GLboolean GLboolean a
o2::framework::DataProcessorSpec getBadMapCalibSpec(bool useCCDB, bool forceUpdate, std::string path, short method)
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"