Skip to content

Commit f93504a

Browse files
aphecetcheshahor02
authored andcommitted
[MRRTF-146] MCH: Introduce CSV version of the Bad Channel List
In addition the MCH calibration code was reorganized / renamed. For instance the PedestalCalibrator was renamed BadChannelCalibrator as the calibration output is about bad channel map, not about pedestal. Some more renaming will have to be performed in stages, in order not to break the QC : renamed methods are first marked deprecated here in O2, they will then have to be renamed in QC and finally removed from O2. In addition some members are temporarily added to match the expectation from QC, but they will be removed soon. Also removed custom DsChannelGroup class, which was nothing more than a vector of DsChannelId (but keep the include for the moment, again not to break the current QC) The upload logic has been changed : we use **either** EOS or enough stat. But not both, to avoid to risk having, in case we ask for "enough stat", the last entry (the EOS one) be below the stat (as the framework is not checking for stat in this case)
1 parent b5e441d commit f93504a

33 files changed

+1233
-721
lines changed

DataFormats/Detectors/MUON/MCH/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ o2_add_library(DataFormatsMCH
1515
src/CTF.cxx
1616
src/ROFRecord.cxx
1717
src/Cluster.cxx
18+
src/DsChannelId.cxx
1819
PUBLIC_LINK_LIBRARIES O2::CommonDataFormat
1920
O2::DetectorsCommonDataFormats)
2021

DataFormats/Detectors/MUON/MCH/include/DataFormatsMCH/DsChannelGroup.h

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -18,67 +18,13 @@
1818
#define ALICEO2_MCH_DSCHANNELGROUP_H_
1919

2020
#include <vector>
21-
#include "Rtypes.h"
21+
#include "DataFormatsMCH/DsChannelId.h"
2222

23-
namespace o2
23+
namespace o2::mch
2424
{
25-
namespace mch
26-
{
27-
28-
/// Unique 32-bit identifier of a DulaSampa channel. The ID is generated from the following indexes:
29-
/// - the unique ID of the corresponding solar board
30-
/// - the index of the DulaSampa board within the Solar board, from 0 to 39
31-
/// - the channel number, from 0 to 63
32-
class DsChannelId
33-
{
34-
public:
35-
DsChannelId() = default;
36-
DsChannelId(uint32_t channelId) : mChannelId(channelId) {}
37-
DsChannelId(uint16_t solarId, uint8_t dsId, uint8_t channel)
38-
{
39-
set(solarId, dsId, channel);
40-
}
41-
42-
static uint32_t make(uint16_t solarId, uint8_t dsId, uint8_t channel)
43-
{
44-
uint32_t id = (static_cast<uint32_t>(solarId) << 16) +
45-
(static_cast<uint32_t>(dsId) << 8) + channel;
46-
return id;
47-
}
48-
49-
void set(uint16_t solarId, uint8_t dsId, uint8_t channel)
50-
{
51-
mChannelId = DsChannelId::make(solarId, dsId, channel);
52-
}
53-
54-
uint16_t getSolarId() const { return static_cast<uint16_t>((mChannelId >> 16) & 0xFFFF); }
55-
uint8_t getDsId() const { return static_cast<uint8_t>((mChannelId >> 8) & 0xFF); }
56-
uint8_t getChannel() const { return static_cast<uint8_t>(mChannelId & 0xFF); }
57-
58-
private:
59-
uint32_t mChannelId{0};
60-
61-
ClassDefNV(DsChannelId, 1); // class for MCH readout channel
62-
};
63-
64-
/// A group of DualSampa channels, implemented as a vector of 32-bit channel identifiers
65-
class DsChannelGroup
66-
{
67-
public:
68-
DsChannelGroup() = default;
69-
70-
const std::vector<DsChannelId>& getChannels() const { return mChannels; }
71-
std::vector<DsChannelId>& getChannels() { return mChannels; }
72-
73-
void reset() { mChannels.clear(); }
74-
75-
private:
76-
std::vector<DsChannelId> mChannels;
7725

78-
ClassDefNV(DsChannelGroup, 1); // class for MCH bad channels list
79-
};
26+
using DsChannelGroup = std::vector<DsChannelId>;
8027

81-
} // end namespace mch
82-
} // end namespace o2
28+
} // namespace o2::mch
8329

84-
#endif /* ALICEO2_MCH_DSCHANNELGROUP_H_ */
30+
#endif
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
#ifndef O2_DATAFORMATS_MCH_DS_CHANNEL_ID_H_
13+
#define O2_DATAFORMATS_MCH_DS_CHANNEL_ID_H_
14+
15+
#include "Rtypes.h"
16+
#include <cstdint>
17+
#include <string>
18+
19+
namespace o2::mch
20+
{
21+
/// Unique 32-bit identifier of a DualSampa channel. The ID is generated from the following indexes:
22+
/// - the unique ID of the corresponding solar board
23+
/// - the index of the DualSampa board within the Solar board, from 0 to 39
24+
/// - the channel number, from 0 to 63
25+
class DsChannelId
26+
{
27+
public:
28+
DsChannelId() = default;
29+
DsChannelId(uint32_t channelId) : mChannelId(channelId) {}
30+
DsChannelId(uint16_t solarId, uint8_t dsId, uint8_t channel)
31+
{
32+
set(solarId, dsId, channel);
33+
}
34+
35+
static uint32_t make(uint16_t solarId, uint8_t dsId, uint8_t channel)
36+
{
37+
uint32_t id = (static_cast<uint32_t>(solarId) << 16) +
38+
(static_cast<uint32_t>(dsId) << 8) + channel;
39+
return id;
40+
}
41+
42+
void set(uint16_t solarId, uint8_t dsId, uint8_t channel)
43+
{
44+
mChannelId = DsChannelId::make(solarId, dsId, channel);
45+
}
46+
47+
uint16_t getSolarId() const { return static_cast<uint16_t>((mChannelId >> 16) & 0xFFFF); }
48+
uint8_t getDsId() const { return static_cast<uint8_t>((mChannelId >> 8) & 0xFF); }
49+
uint8_t getChannel() const { return static_cast<uint8_t>(mChannelId & 0xFF); }
50+
51+
std::string asString() const;
52+
53+
private:
54+
uint32_t mChannelId{0};
55+
56+
ClassDefNV(DsChannelId, 1); // class for MCH readout channel
57+
};
58+
} // namespace o2::mch
59+
#endif

DataFormats/Detectors/MUON/MCH/src/DataFormatsMCHLinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#pragma link C++ class std::vector < o2::mch::Cluster> + ;
2323
#pragma link C++ class o2::mch::DsChannelId + ;
2424
#pragma link C++ class o2::mch::DsChannelGroup + ;
25+
#pragma link C++ class std::vector < o2::mch::DsChannelId> + ;
2526
#pragma link C++ class o2::mch::Digit + ;
2627
#pragma link C++ class std::vector < o2::mch::Digit> + ;
2728
#pragma link C++ struct o2::mch::CTFHeader + ;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
#include "DataFormatsMCH/DsChannelGroup.h"
13+
14+
std::string o2::mch::DsChannelId() const
15+
{
16+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
#include "DataFormatsMCH/DsChannelGroup.h"
13+
#include <fmt/core.h>
14+
15+
namespace o2::mch
16+
{
17+
std::string DsChannelId::asString() const
18+
{
19+
return fmt::format("solarid {:4d} dsid {:4d} ch {:2d}",
20+
getSolarId(), getDsId(), getChannel());
21+
}
22+
} // namespace o2::mch

DataFormats/Detectors/MUON/MCH/src/convert-bad-channels.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ int convertRootToCSV(const std::string rootFileName)
2525
if (f->IsZombie()) {
2626
throw std::runtime_error("can not open " + rootFileName);
2727
}
28-
auto dsChannelGroup = reinterpret_cast<o2::mch::DsChannelGroup*>(f->Get("ccdb_object"));
29-
auto channels = dsChannelGroup->getChannels();
28+
auto& tinfo = typeid(std::vector<o2::mch::DsChannelId>*);
29+
TClass* cl = TClass::GetClass(tinfo);
30+
auto channels = static_cast<std::vector<o2::mch::DsChannelId>*>(f->GetObjectChecked("ccdb_object", cl));
3031

3132
std::cout << fmt::format("solarid,dsid,ch\n");
3233

33-
for (auto c : channels) {
34+
for (auto c : *channels) {
3435
std::cout << fmt::format("{},{},{}\n",
3536
c.getSolarId(), c.getDsId(), c.getChannel());
3637
}

Detectors/MUON/MCH/Calibration/CMakeLists.txt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,35 @@
1111

1212
o2_add_library(MCHCalibration
1313
SOURCES
14+
src/BadChannelCalibrationDevice.cxx
15+
src/BadChannelCalibrator.cxx
16+
src/BadChannelCalibratorParam.cxx
17+
src/PedestalChannel.cxx
18+
src/PedestalData.cxx
1419
src/PedestalDigit.cxx
15-
src/PedestalProcessor.cxx
16-
src/PedestalCalibrator.cxx
1720
PUBLIC_LINK_LIBRARIES Microsoft.GSL::GSL O2::DetectorsCalibration O2::CCDB O2::MCHBase O2::MCHRawDecoder O2::DataFormatsMCH)
1821

19-
o2_target_root_dictionary(MCHCalibration
20-
HEADERS include/MCHCalibration/PedestalDigit.h include/MCHCalibration/PedestalProcessor.h include/MCHCalibration/PedestalCalibrator.h)
22+
o2_target_root_dictionary(MCHCalibration HEADERS include/MCHCalibration/MCHChannelCalibrator.h
23+
include/MCHCalibration/BadChannelCalibrator.h
24+
include/MCHCalibration/BadChannelCalibratorParam.h
25+
include/MCHCalibration/PedestalDigit.h)
2126

2227
o2_add_executable(pedestal-decoding-workflow
2328
SOURCES src/pedestal-decoding-workflow.cxx
2429
COMPONENT_NAME mch
2530
PUBLIC_LINK_LIBRARIES Boost::program_options O2::Framework O2::DPLUtils O2::MCHCalibration)
2631

27-
o2_add_executable(mch-pedestal-calib-workflow
32+
o2_add_executable(mch-badchannel-calib-workflow
2833
COMPONENT_NAME calibration
29-
SOURCES src/pedestal-calib-workflow.cxx
34+
SOURCES src/badchannel-calib-workflow.cxx
3035
PUBLIC_LINK_LIBRARIES O2::Framework O2::MCHCalibration O2::DetectorsCalibration)
3136

37+
if(BUILD_TESTING)
3238

39+
o2_add_test(pedestal-data-iterator
40+
SOURCES test/testPedestalData.cxx
41+
COMPONENT_NAME mch
42+
LABELS "muon;mch"
43+
PUBLIC_LINK_LIBRARIES O2::MCHCalibration Boost::boost)
44+
45+
endif()
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<!-- doxy
2+
\page refDetectorsMUONMCHCalibration Calibration
3+
/doxy -->
4+
5+
# MCH Calibration
6+
7+
## Calibration type(s)
8+
9+
So far MCH has only one calibration : the bad channel map.
10+
11+
This bad channel map is computed from pedestal data taken in special
12+
calibration runs, where the actual zero suppression is disabled in the
13+
electronics, so we readout complete information from the detector and can
14+
compute the mean and sigma of the pedestal values for all the channels.
15+
16+
Once the pedestal means and sigmas are known, we declare some channels bad if
17+
their pedestal mean and/or sigma are outside of some limits (defined in
18+
`BadChannelCalibratorParam`, which is a `ConfigurableParam`, hence settable
19+
from the command-line using the `--configKeyValues` option of the workflow).
20+
21+
## Calibration object(s)
22+
23+
Two objects are produced by the calibration workflow (see below),
24+
distinguishable by the subspec they use :
25+
26+
- subspec 0 : a `std::vector` of `DsChannelId` that should end up in the
27+
regular CCDB. That object is/will be used for filtering digits during the
28+
reconstruction/simulation phase
29+
- subspec 1 : a `TObjString` wrapping a CSV containing the same information as
30+
above, that should end up in the DCS CDB. That object is meant to be used by
31+
DCS to configure the electronics.
32+
33+
## Calibration workflow
34+
35+
The calibration device executable is named
36+
`o2-calibration-mch-badchannel-calib-workflow` (spec name is
37+
`mch-badchannel-calibrator`). It can be configured using the
38+
[MCHBadChannelCalibratorParam](include/MCHCalibration/BadChannelCalibratorParam.h)
39+
keys.
40+
41+
By default the bad channel calibrator only computes the output object at the
42+
end-of-stream (EOS). To alleviate possible issues with EOS not working
43+
properly, one can set special key options to also compute after a given
44+
fraction of channels have reached enough statistics.
45+
46+
For instance (see also `test/example-mch-pedestal-calibration.sh`) :
47+
48+
```shell
49+
o2-raw-tf-reader-workflow --max-tf 10 --input-data \
50+
$HOME/alice/data/ped/StfBuilder-CH9R-pedestals-ul-with_gnd-without_HV-20210617 | \
51+
o2-mch-pedestal-decoding-workflow | \
52+
o2-calibration-mch-badchannel-calib-workflow \
53+
--configKeyValues="MCHBadChannelCalibratorParam.minRequiredNofEntriesPerChannel=100;MCHBadChannelCalibratorParam.minRequiredCalibratedFraction=0.5;MCHBadChannelCalibratorParam.onlyAtEndOfStream=false" | \
54+
o2-calibration-ccdb-populator-workflow \
55+
--ccdb-path http://localhost:6464 \
56+
--sspec-min 0 --sspec-max 0 | \
57+
o2-calibration-ccdb-populator-workflow \
58+
--ccdb-path localhost:8484 --sspec-max 1 --sspec-min 1 --name-extention dcs | \
59+
o2-qc \
60+
--config json://$HOME/cernbox/o2muon/qc/qc_configs/qc-pedestal.json | \
61+
o2-dpl-run \
62+
--run -b \
63+
> ped-calib.log
64+
```
65+
66+
In that example we instruct the calibrator to compute (and forward to the CCDB
67+
populator) the bad channel map when at least 50% of the channels have more than
68+
100 entries. Note that in this case, and depending of the run duration, several
69+
objects might be uploaded, while in the "normal" case
70+
(`onlyAtEndOfStream=true`) there will be only one (or two, if two populators
71+
are used) object will be uploaded.
72+

0 commit comments

Comments
 (0)