Skip to content

Commit 9fa9124

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

File tree

7 files changed

+180
-7
lines changed

7 files changed

+180
-7
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: 17 additions & 5 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,10 +40,12 @@ 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);
44-
CalibTOFapi(long timestamp, o2::dataformats::CalibLHCphaseTOF* phase, o2::dataformats::CalibTimeSlewingParamTOF* slew, Diagnostic* dia = nullptr) : mTimeStamp(timestamp), mLHCphase(phase), mSlewParam(slew), mDiaFreq(dia) {}
48+
CalibTOFapi(long timestamp, o2::dataformats::CalibLHCphaseTOF* phase, o2::dataformats::CalibTimeSlewingParamTOF* slew, Diagnostic* dia = nullptr, Diagnostic* diaDRM = nullptr) : mTimeStamp(timestamp), mLHCphase(phase), mSlewParam(slew), mDiaFreq(dia), mDiaDRMFreq(diaDRM) {}
4549
~CalibTOFapi()
4650
{
4751
if (mLHCphase) {
@@ -53,6 +57,9 @@ class CalibTOFapi
5357
if (mDiaFreq) {
5458
// delete mDiaFreq;
5559
}
60+
if (mDiaDRMFreq) {
61+
// delete mDiaDRMFreq;
62+
}
5663
}
5764

5865
void setTimeStamp(long t)
@@ -69,6 +76,8 @@ class CalibTOFapi
6976
void readTimeSlewingParamFromFile(const char* filename);
7077
void readDiagnosticFrequencies();
7178
void loadDiagnosticFrequencies();
79+
void readDiagnosticDRMFrequencies();
80+
void loadDiagnosticDRMFrequencies();
7281
void readActiveMap();
7382
void loadActiveMap(TOFFEElightInfo* fee);
7483
void writeLHCphase(LhcPhase* phase, std::map<std::string, std::string> metadataLHCphase, uint64_t minTimeSTamp, uint64_t maxTimeStamp);
@@ -89,6 +98,8 @@ class CalibTOFapi
8998
void setLhcPhase(LhcPhase* obj) { mLHCphase = obj; }
9099
Diagnostic* getDiagnostic() { return mDiaFreq; }
91100
void setDiagnostic(Diagnostic* obj) { mDiaFreq = obj; }
101+
Diagnostic* getDiagnosticDRM() { return mDiaDRMFreq; }
102+
void setDiagnosticDRM(Diagnostic* obj) { mDiaDRMFreq = obj; }
92103

93104
int getNoisyThreshold() const { return mNoisyThreshold; }
94105
void setNoisyThreshold(int val) { mNoisyThreshold = val; }
@@ -104,10 +115,11 @@ class CalibTOFapi
104115
bool checkTRMPolicy(int mask) const;
105116

106117
private:
107-
long mTimeStamp; ///< timeStamp for queries
108-
LhcPhase* mLHCphase = nullptr; ///< object for LHC phase
109-
SlewParam* mSlewParam = nullptr; ///< object for timeslewing (containing info also for offset and problematic)
110-
Diagnostic* mDiaFreq = nullptr; ///< object for Diagnostic Frequency
118+
long mTimeStamp; ///< timeStamp for queries
119+
LhcPhase* mLHCphase = nullptr; ///< object for LHC phase
120+
SlewParam* mSlewParam = nullptr; ///< object for timeslewing (containing info also for offset and problematic)
121+
Diagnostic* mDiaFreq = nullptr; ///< object for Diagnostic Frequency
122+
Diagnostic* mDiaDRMFreq = nullptr; ///< object for Diagnostic Frequency
111123

112124
// info from diagnostic
113125
int mNoisyThreshold = 1; ///< threshold to be noisy

Detectors/TOF/base/src/CalibTOFapi.cxx

Lines changed: 49 additions & 1 deletion
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);
@@ -116,11 +145,23 @@ void CalibTOFapi::readDiagnosticFrequencies()
116145
{
117146
auto& mgr = CcdbManager::instance();
118147
long timems = long(mTimeStamp) * 1000;
119-
LOG(info) << "TOF get Diagnostics with timestamp (ms) = " << timems;
148+
LOG(info) << "TOF get TRM Diagnostics with timestamp (ms) = " << timems;
120149
mDiaFreq = mgr.getForTimeStamp<Diagnostic>("TOF/Calib/Diagnostic", timems);
121150

122151
loadDiagnosticFrequencies();
123152
}
153+
154+
//______________________________________________________________________
155+
156+
void CalibTOFapi::readDiagnosticDRMFrequencies()
157+
{
158+
auto& mgr = CcdbManager::instance();
159+
long timems = long(mTimeStamp) * 1000;
160+
LOG(info) << "TOF get DRM Diagnostics with timestamp (ms) = " << timems;
161+
mDiaFreq = mgr.getForTimeStamp<Diagnostic>("TOF/Calib/TRMerrors", timems);
162+
163+
loadDiagnosticDRMFrequencies();
164+
}
124165
//______________________________________________________________________
125166

126167
void CalibTOFapi::loadDiagnosticFrequencies()
@@ -210,6 +251,13 @@ void CalibTOFapi::loadDiagnosticFrequencies()
210251

211252
//______________________________________________________________________
212253

254+
void CalibTOFapi::loadDiagnosticDRMFrequencies()
255+
{
256+
mDiaDRMFreq->print();
257+
}
258+
259+
//______________________________________________________________________
260+
213261
void CalibTOFapi::writeLHCphase(LhcPhase* phase, std::map<std::string, std::string> metadataLHCphase, uint64_t minTimeStamp, uint64_t maxTimeStamp)
214262
{
215263

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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
if (dummy) {
21+
o2::tof::Diagnostic drmDia;
22+
for (int j = 1; j <= 72; j++) {
23+
drmDia.fill(o2::tof::Diagnostic::getDRMKey(j - 1));
24+
}
25+
26+
TFile* fo = new TFile("ccdb.root", "RECREATE");
27+
fo->WriteObjectAny(&drmDia, drmDia.Class_Name(), "ccdb_object");
28+
fo->Close();
29+
30+
return;
31+
}
32+
33+
TFile* f = new TFile(inputfile);
34+
TH2F* h = (TH2F*)f->Get("ccdb_object");
35+
36+
o2::tof::Diagnostic drmDia;
37+
38+
drmDia = o2::tof::CalibTOFapi::doDRMerrCalibFromQCHisto(h, "ccdb.root");
39+
}

Steer/DigitizerWorkflow/src/TOFDigitizerSpec.cxx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ class TOFDPLDigitizerTask : public o2::base::BaseDPLDigitizer
7777
mUpdateCCDB = true;
7878
return;
7979
}
80+
if (matcher == ConcreteDataMatcher("TOF", "DiagnosticDRM", 0)) {
81+
mUpdateCCDB = true;
82+
return;
83+
}
8084
if (matcher == ConcreteDataMatcher("TOF", "LHCphaseCal", 0)) {
8185
mUpdateCCDB = true;
8286
return;
@@ -127,6 +131,7 @@ class TOFDPLDigitizerTask : public o2::base::BaseDPLDigitizer
127131
const auto lhcPhaseIn = pc.inputs().get<o2::dataformats::CalibLHCphaseTOF*>("tofccdbLHCphase");
128132
const auto channelCalibIn = pc.inputs().get<o2::dataformats::CalibTimeSlewingParamTOF*>("tofccdbChannelCalib");
129133
const auto diagnosticIn = pc.inputs().get<o2::tof::Diagnostic*>("tofccdbDia");
134+
const auto diagnosticDRM = pc.inputs().get<o2::tof::Diagnostic*>("tofccdbDrm");
130135
const auto statusIn = pc.inputs().get<o2::tof::TOFFEElightInfo*>("tofccdbStatus");
131136
const auto tofParams = pc.inputs().get<o2::tof::ParameterCollection*>("tofccdbParams");
132137

@@ -165,10 +170,12 @@ class TOFDPLDigitizerTask : public o2::base::BaseDPLDigitizer
165170
o2::dataformats::CalibLHCphaseTOF* lhcPhase = new o2::dataformats::CalibLHCphaseTOF(std::move(*lhcPhaseIn));
166171
o2::dataformats::CalibTimeSlewingParamTOF* channelCalib = new o2::dataformats::CalibTimeSlewingParamTOF(std::move(*channelCalibIn));
167172
o2::tof::Diagnostic* diagnostic = new o2::tof::Diagnostic(std::move(*diagnosticIn));
173+
o2::tof::Diagnostic* diagnosticDRMerr = new o2::tof::Diagnostic(std::move(*diagnosticDRM));
168174
o2::tof::TOFFEElightInfo* status = new o2::tof::TOFFEElightInfo(std::move(*statusIn));
169175

170-
mCalibApi = new o2::tof::CalibTOFapi(long(0), lhcPhase, channelCalib, diagnostic);
176+
mCalibApi = new o2::tof::CalibTOFapi(long(0), lhcPhase, channelCalib, diagnostic, diagnosticDRMerr);
171177
mCalibApi->loadDiagnosticFrequencies();
178+
mCalibApi->loadDiagnosticDRMFrequencies();
172179
mCalibApi->loadActiveMap(status);
173180
mUpdateCCDB = false;
174181
} else { // update if necessary
@@ -178,9 +185,11 @@ class TOFDPLDigitizerTask : public o2::base::BaseDPLDigitizer
178185
o2::dataformats::CalibLHCphaseTOF* lhcPhase = new o2::dataformats::CalibLHCphaseTOF(*lhcPhaseIn);
179186
o2::dataformats::CalibTimeSlewingParamTOF* channelCalib = new o2::dataformats::CalibTimeSlewingParamTOF(*channelCalibIn);
180187
o2::tof::Diagnostic* diagnostic = new o2::tof::Diagnostic(std::move(*diagnosticIn));
188+
o2::tof::Diagnostic* diagnosticDRMerr = new o2::tof::Diagnostic(std::move(*diagnosticDRM));
181189
o2::tof::TOFFEElightInfo* status = new o2::tof::TOFFEElightInfo(std::move(*statusIn));
182190
mCalibApi = new o2::tof::CalibTOFapi(long(0), lhcPhase, channelCalib, diagnostic);
183191
mCalibApi->loadDiagnosticFrequencies();
192+
mCalibApi->loadDiagnosticDRMFrequencies();
184193
mCalibApi->loadActiveMap(status);
185194
mUpdateCCDB = false;
186195
} else {
@@ -205,6 +214,7 @@ class TOFDPLDigitizerTask : public o2::base::BaseDPLDigitizer
205214
if (mUseCCDB) {
206215
mCalibApi->setURL(mCCDBurl);
207216
mCalibApi->readDiagnosticFrequencies();
217+
mCalibApi->readDiagnosticDRMFrequencies();
208218
mCalibApi->readLHCphase();
209219
mCalibApi->readActiveMap();
210220
mCalibApi->readTimeSlewingParam();
@@ -319,6 +329,7 @@ DataProcessorSpec getTOFDigitizerSpec(int channel, bool useCCDB, bool mctruth, s
319329
if (useCCDB) {
320330
inputs.emplace_back("tofccdbStatus", "TOF", "StatusTOF", 0, Lifetime::Condition, ccdbParamSpec("TOF/Calib/FEELIGHT"));
321331
inputs.emplace_back("tofccdbDia", "TOF", "DiagnosticCal", 0, Lifetime::Condition, ccdbParamSpec("TOF/Calib/Diagnostic"));
332+
inputs.emplace_back("tofccdbDrm", "TOF", "DiagnosticDRM", 0, Lifetime::Condition, ccdbParamSpec("TOF/Calib/DRMerrors"));
322333
inputs.emplace_back("tofccdbLHCphase", "TOF", "LHCphaseCal", 0, Lifetime::Condition, ccdbParamSpec("TOF/Calib/LHCphase"));
323334
inputs.emplace_back("tofccdbChannelCalib", "TOF", "ChannelCalibCal", 0, Lifetime::Condition, ccdbParamSpec("TOF/Calib/ChannelCalib"));
324335
inputs.emplace_back("tofccdbParams", "TOF", "parameters", 0, Lifetime::Condition, ccdbParamSpec("TOF/Calib/Params"));

0 commit comments

Comments
 (0)