Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ class Diagnostic
uint32_t fillEmptyTOF(uint32_t frequency = 1) { return fill(1, frequency); }
static ULong64_t getEmptyCrateKey(int crate);
static ULong64_t getNoisyChannelKey(int channel);
static ULong64_t getDRMKey(int crate) { return 1000000 + crate * 1000; }
static ULong64_t getDRMerrorKey(int crate, int error) { return getDRMKey(crate) + error; }
uint32_t getFrequencyDRM(int crate) const { return getFrequency(getDRMKey(crate)); }
uint32_t getFrequencyDRMerror(int crate, int error) const { return getFrequency(getDRMerrorKey(crate, error)); }
uint32_t fillDRM(int crate, uint32_t frequency) { return fill(getDRMKey(crate), frequency); }
uint32_t fillDRMerror(int crate, int error, uint32_t frequency) { return fill(getDRMerrorKey(crate, error), frequency); }

static ULong64_t getTRMKey(int crate, int trm);
void print(bool longFormat = false) const;
void clear() { mVector.clear(); }
Expand Down
4 changes: 4 additions & 0 deletions Detectors/TOF/base/include/TOFBase/CalibTOFapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "DataFormatsTOF/Diagnostic.h"
#include "DataFormatsTOF/TOFFEElightInfo.h"

class TH2F;

namespace o2
{
namespace tof
Expand All @@ -38,6 +40,8 @@ class CalibTOFapi
using CcdbApi = o2::ccdb::CcdbApi;

public:
static o2::tof::Diagnostic doDRMerrCalibFromQCHisto(const TH2F* histo, const char* file_output_name);

void resetDia();
CalibTOFapi() = default;
CalibTOFapi(const std::string url);
Expand Down
29 changes: 29 additions & 0 deletions Detectors/TOF/base/src/CalibTOFapi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,40 @@

#include "TOFBase/CalibTOFapi.h"
#include <fairlogger/Logger.h> // for LOG
#include <TH2F.h>

using namespace o2::tof;

ClassImp(o2::tof::CalibTOFapi);

o2::tof::Diagnostic CalibTOFapi::doDRMerrCalibFromQCHisto(const TH2F* histo, const char* file_output_name)
{
// this is a method which translate the QC output in qc/TOF/MO/TaskRaw/DRMCounter (TH2F) into a Diagnotic object for DRM (patter(crate, error), frequency)
// note that, differently from TRM errors, DRM ones are not stored in CTF by design (since very rare, as expected). Such an info is available only at the level of raw sync QC
o2::tof::Diagnostic drmDia;

for (int j = 1; j <= 72; j++) {
drmDia.fillDRM(j - 1, histo->GetBinContent(1, j));
for (int i = 2; i <= histo->GetXaxis()->GetNbins(); i++) {
if (histo->GetBinContent(1, j)) {
if (histo->GetBinContent(i, j) > 0) {
drmDia.fillDRMerror(j - 1, i - 1, histo->GetBinContent(i, j));
}
}
}
}

TFile* fo = new TFile(file_output_name, "RECREATE");
fo->WriteObjectAny(&drmDia, drmDia.Class_Name(), "ccdb_object");
fo->Close();
LOG(info) << "DRM error ccdb object created in " << file_output_name << " with this content";
drmDia.print(true);

return drmDia;
}

//______________________________________________________________________

void CalibTOFapi::resetDia()
{
memset(mEmptyCrateProb, 0., Geo::kNCrate * 4);
Expand Down
15 changes: 15 additions & 0 deletions Detectors/TOF/prototyping/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ o2_add_test_root_macro(findLabels.C
O2::TOFBase
LABELS tof)

o2_add_test_root_macro(makeDRMobj_tof.C
PUBLIC_LINK_LIBRARIES O2::DataFormatsTOF
O2::TOFBase
LABELS tof)

o2_add_test_root_macro(checkDRMobj_tof.C
PUBLIC_LINK_LIBRARIES O2::DataFormatsTOF
O2::TOFBase
LABELS tof)

o2_add_test_root_macro(findTOFclusterFromLabel.C
PUBLIC_LINK_LIBRARIES O2::DataFormatsTOF
O2::SimulationDataFormat
Expand Down Expand Up @@ -59,3 +69,8 @@ o2_add_test_root_macro(macroEvTime.C
PUBLIC_LINK_LIBRARIES O2::TOFBase
O2::TOFReconstruction
LABELS tof)

install(
FILES makeDRMobj_tof.C
checkDRMobj_tof.C
DESTINATION share/macro/)
41 changes: 41 additions & 0 deletions Detectors/TOF/prototyping/checkDRMobj_tof.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2019-2020 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.

#if !defined(__CLING__) || defined(__ROOTCLING__)
#include "TFile.h"
#include "TH2F.h"
#include "TOFBase/CalibTOFapi.h"
#endif

void checkDRMobj_tof(const char* fname = "ccdb.root")
{
TFile* f = new TFile(fname);

TH2F* hErrors = new TH2F("hDRMerrors", ";error code; frequency", 30, 0, 30, 72, 0, 72);

o2::tof::Diagnostic* drmDia = (o2::tof::Diagnostic*)f->Get("ccdb_object");

for (int j = 1; j <= 72; j++) {
uint32_t patternRDH = o2::tof::Diagnostic::getDRMKey(j - 1);
for (int i = 1; i <= hErrors->GetXaxis()->GetNbins(); i++) {
uint32_t pattern = o2::tof::Diagnostic::getDRMerrorKey(j - 1, i - 1);
if (drmDia->getFrequency(patternRDH)) {
hErrors->SetBinContent(i, j, drmDia->getFrequency(pattern) * 1. / drmDia->getFrequency(patternRDH));
}
}
}

TCanvas* c = new TCanvas();
c->cd(1);
hErrors->Draw("colz");

drmDia->print(true);
}
39 changes: 39 additions & 0 deletions Detectors/TOF/prototyping/makeDRMobj_tof.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2019-2020 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.

#if !defined(__CLING__) || defined(__ROOTCLING__)
#include "TFile.h"
#include "TH2F.h"
#include "TOFBase/CalibTOFapi.h"
#endif

void makeDRMobj_tof(const char* inputfile = "TObject_1764607157510.root", bool dummy = false)
{
if (dummy) {
o2::tof::Diagnostic drmDia;
for (int j = 1; j <= 72; j++) {
drmDia.fill(o2::tof::Diagnostic::getDRMKey(j - 1));
}

TFile* fo = new TFile("ccdb.root", "RECREATE");
fo->WriteObjectAny(&drmDia, drmDia.Class_Name(), "ccdb_object");
fo->Close();

return;
}

TFile* f = new TFile(inputfile);
TH2F* h = (TH2F*)f->Get("ccdb_object");

o2::tof::Diagnostic drmDia;

drmDia = o2::tof::CalibTOFapi::doDRMerrCalibFromQCHisto(h, "ccdb.root");
}
Loading