Skip to content

Commit ce53239

Browse files
committed
add treatment of TOF DRM Errors
1 parent d569998 commit ce53239

File tree

6 files changed

+134
-0
lines changed

6 files changed

+134
-0
lines changed

DataFormats/Detectors/TOF/include/DataFormatsTOF/Diagnostic.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ class Diagnostic
4444
uint32_t fillEmptyTOF(uint32_t frequency = 1) { return fill(1, frequency); }
4545
static ULong64_t getEmptyCrateKey(int crate);
4646
static ULong64_t getNoisyChannelKey(int channel);
47+
static ULong64_t getDRMKey(int crate) { return 1000000 + crate * 1000; }
48+
static ULong64_t getDRMerrorKey(int crate, int error) { return getDRMKey(crate) + error; }
49+
uint32_t getFrequencyDRM(int crate) const { return getFrequency(getDRMKey(crate)); }
50+
uint32_t getFrequencyDRMerror(int crate, int error) const { return getFrequency(getDRMerrorKey(crate, error)); }
51+
uint32_t fillDRM(int crate, uint32_t frequency) { return fill(getDRMKey(crate), frequency); }
52+
uint32_t fillDRMerror(int crate, int error, uint32_t frequency) { return fill(getDRMerrorKey(crate, error), frequency); }
53+
4754
static ULong64_t getTRMKey(int crate, int trm);
4855
void print(bool longFormat = false) const;
4956
void clear() { mVector.clear(); }

Detectors/TOF/base/include/TOFBase/CalibTOFapi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "DataFormatsTOF/Diagnostic.h"
2525
#include "DataFormatsTOF/TOFFEElightInfo.h"
2626

27+
class TH2F;
28+
2729
namespace o2
2830
{
2931
namespace tof
@@ -38,6 +40,8 @@ class CalibTOFapi
3840
using CcdbApi = o2::ccdb::CcdbApi;
3941

4042
public:
43+
static o2::tof::Diagnostic doDRMerrCalibFromQCHisto(const TH2F* histo, const char* file_output_name);
44+
4145
void resetDia();
4246
CalibTOFapi() = default;
4347
CalibTOFapi(const std::string url);

Detectors/TOF/base/src/CalibTOFapi.cxx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,40 @@
1111

1212
#include "TOFBase/CalibTOFapi.h"
1313
#include <fairlogger/Logger.h> // for LOG
14+
#include <TH2F.h>
1415

1516
using namespace o2::tof;
1617

1718
ClassImp(o2::tof::CalibTOFapi);
1819

20+
o2::tof::Diagnostic CalibTOFapi::doDRMerrCalibFromQCHisto(const TH2F* histo, const char* file_output_name)
21+
{
22+
// 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)
23+
// 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
24+
o2::tof::Diagnostic drmDia;
25+
26+
for (int j = 1; j <= 72; j++) {
27+
drmDia.fillDRM(j - 1, histo->GetBinContent(1, j));
28+
for (int i = 2; i <= histo->GetXaxis()->GetNbins(); i++) {
29+
if (histo->GetBinContent(1, j)) {
30+
if (histo->GetBinContent(i, j) > 0) {
31+
drmDia.fillDRMerror(j - 1, i - 1, histo->GetBinContent(i, j));
32+
}
33+
}
34+
}
35+
}
36+
37+
TFile* fo = new TFile(file_output_name, "RECREATE");
38+
fo->WriteObjectAny(&drmDia, drmDia.Class_Name(), "ccdb_object");
39+
fo->Close();
40+
LOG(info) << "DRM error ccdb object created in " << file_output_name << " with this content";
41+
drmDia.print(true);
42+
43+
return drmDia;
44+
}
45+
46+
//______________________________________________________________________
47+
1948
void CalibTOFapi::resetDia()
2049
{
2150
memset(mEmptyCrateProb, 0., Geo::kNCrate * 4);

Detectors/TOF/prototyping/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ o2_add_test_root_macro(findLabels.C
3232
O2::TOFBase
3333
LABELS tof)
3434

35+
o2_add_test_root_macro(makeDRMobj_tof.C
36+
PUBLIC_LINK_LIBRARIES O2::DataFormatsTOF
37+
O2::TOFBase
38+
LABELS tof)
39+
40+
o2_add_test_root_macro(checkDRMobj_tof.C
41+
PUBLIC_LINK_LIBRARIES O2::DataFormatsTOF
42+
O2::TOFBase
43+
LABELS tof)
44+
3545
o2_add_test_root_macro(findTOFclusterFromLabel.C
3646
PUBLIC_LINK_LIBRARIES O2::DataFormatsTOF
3747
O2::SimulationDataFormat
@@ -59,3 +69,8 @@ o2_add_test_root_macro(macroEvTime.C
5969
PUBLIC_LINK_LIBRARIES O2::TOFBase
6070
O2::TOFReconstruction
6171
LABELS tof)
72+
73+
install(
74+
FILES makeDRMobj_tof.C
75+
checkDRMobj_tof.C
76+
DESTINATION share/macro/)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#if !defined(__CLING__) || defined(__ROOTCLING__)
13+
#include "TFile.h"
14+
#include "TH2F.h"
15+
#include "TOFBase/CalibTOFapi.h"
16+
#endif
17+
18+
void checkDRMobj_tof(const char* fname = "ccdb.root")
19+
{
20+
TFile* f = new TFile(fname);
21+
22+
TH2F* hErrors = new TH2F("hDRMerrors", ";error code; frequency", 30, 0, 30, 72, 0, 72);
23+
24+
o2::tof::Diagnostic* drmDia = (o2::tof::Diagnostic*)f->Get("ccdb_object");
25+
26+
for (int j = 1; j <= 72; j++) {
27+
uint32_t patternRDH = o2::tof::Diagnostic::getDRMKey(j - 1);
28+
for (int i = 1; i <= hErrors->GetXaxis()->GetNbins(); i++) {
29+
uint32_t pattern = o2::tof::Diagnostic::getDRMerrorKey(j - 1, i - 1);
30+
if (drmDia->getFrequency(patternRDH)) {
31+
hErrors->SetBinContent(i, j, drmDia->getFrequency(pattern) * 1. / drmDia->getFrequency(patternRDH));
32+
}
33+
}
34+
}
35+
36+
TCanvas* c = new TCanvas();
37+
c->cd(1);
38+
hErrors->Draw("colz");
39+
40+
drmDia->print(true);
41+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#if !defined(__CLING__) || defined(__ROOTCLING__)
13+
#include "TFile.h"
14+
#include "TH2F.h"
15+
#include "TOFBase/CalibTOFapi.h"
16+
#endif
17+
18+
void makeDRMobj_tof(const char* inputfile = "TObject_1764607157510.root", bool dummy = false)
19+
{
20+
TFile* f = new TFile(inputfile);
21+
TH2F* h = (TH2F*)f->Get("ccdb_object");
22+
23+
o2::tof::Diagnostic drmDia;
24+
25+
if (!dummy) {
26+
drmDia = o2::tof::CalibTOFapi::doDRMerrCalibFromQCHisto(h, "ccdb.root");
27+
return;
28+
}
29+
30+
// continue if dummy
31+
for (int j = 1; j <= 72; j++) {
32+
drmDia.fill(o2::tof::Diagnostic::getDRMKey(j - 1));
33+
}
34+
35+
TFile* fo = new TFile("ccdb.root", "RECREATE");
36+
fo->WriteObjectAny(&drmDia, drmDia.Class_Name(), "ccdb_object");
37+
fo->Close();
38+
}

0 commit comments

Comments
 (0)