Skip to content

Commit 582b5e4

Browse files
authored
[R3C-465] MCH: pedestals calibration workflow (#5627)
* [MCH] introduced workflow for pedestals analysis This workflow processes pedestal data, builds the list of bad/noisy channels and stores the list in the CCDB. * [MCH] added output for sending the pedestal values to the QC A "MCH/PEDESTALS" output spec has been added, which allows to send the computed pedestal mean/rms values to a downstream DPL device, for example to the QC. The QC in this case can simply plot and checks the pre-computed pedestals, without having to re-process the raw data.
1 parent 709c48a commit 582b5e4

19 files changed

+1512
-2
lines changed

DataFormats/Detectors/MUON/MCH/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ o2_add_library(DataFormatsMCH
1414

1515
o2_target_root_dictionary(DataFormatsMCH
1616
HEADERS include/DataFormatsMCH/ROFRecord.h
17-
include/DataFormatsMCH/TrackMCH.h)
17+
include/DataFormatsMCH/TrackMCH.h
18+
include/DataFormatsMCH/DsChannelGroup.h)
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \file DsChannleGroup.h
12+
/// \brief Implementation of a group of DualSampa channels
13+
///
14+
/// \author Andrea Ferrero, CEA-Saclay
15+
16+
#ifndef ALICEO2_MCH_DSCHANNELGROUP_H_
17+
#define ALICEO2_MCH_DSCHANNELGROUP_H_
18+
19+
#include <vector>
20+
#include "Rtypes.h"
21+
22+
namespace o2
23+
{
24+
namespace mch
25+
{
26+
27+
/// Unique 32-bit identifier of a DulaSampa channel. The ID is generated from the following indexes:
28+
/// - the unique ID of the corresponding solar board
29+
/// - the index of the DulaSampa board within the Solar board, from 0 to 39
30+
/// - the channel number, from 0 to 63
31+
class DsChannelId
32+
{
33+
public:
34+
DsChannelId() = default;
35+
DsChannelId(uint32_t channelId) : mChannelId(channelId) {}
36+
DsChannelId(uint16_t solarId, uint8_t dsId, uint8_t channel)
37+
{
38+
set(solarId, dsId, channel);
39+
}
40+
41+
static uint32_t make(uint16_t solarId, uint8_t dsId, uint8_t channel)
42+
{
43+
uint32_t id = (static_cast<uint32_t>(solarId) << 16) +
44+
(static_cast<uint32_t>(dsId) << 8) + channel;
45+
return id;
46+
}
47+
48+
void set(uint16_t solarId, uint8_t dsId, uint8_t channel)
49+
{
50+
mChannelId = DsChannelId::make(solarId, dsId, channel);
51+
}
52+
53+
uint16_t getSolarId() const { return static_cast<uint16_t>((mChannelId >> 16) & 0xFFFF); }
54+
uint8_t getDsId() const { return static_cast<uint8_t>((mChannelId >> 8) & 0xFF); }
55+
uint8_t getChannel() const { return static_cast<uint8_t>(mChannelId & 0xFF); }
56+
57+
private:
58+
uint32_t mChannelId{0};
59+
60+
ClassDefNV(DsChannelId, 1); // class for MCH readout channel
61+
};
62+
63+
/// A group of DualSampa channels, implemented as a vector of 32-bit channel identifiers
64+
class DsChannelGroup
65+
{
66+
public:
67+
DsChannelGroup() = default;
68+
69+
const std::vector<DsChannelId>& getChannels() const { return mChannels; }
70+
std::vector<DsChannelId>& getChannels() { return mChannels; }
71+
72+
void reset() { mChannels.clear(); }
73+
74+
private:
75+
std::vector<DsChannelId> mChannels;
76+
77+
ClassDefNV(DsChannelGroup, 1); // class for MCH bad channels list
78+
};
79+
80+
} // end namespace mch
81+
} // end namespace o2
82+
83+
#endif /* ALICEO2_MCH_DSCHANNELGROUP_H_ */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@
1616

1717
#pragma link C++ class o2::mch::ROFRecord + ;
1818
#pragma link C++ class o2::mch::TrackMCH + ;
19+
#pragma link C++ class o2::mch::DsChannelId + ;
20+
#pragma link C++ class o2::mch::DsChannelGroup + ;
1921
#endif

Detectors/MUON/MCH/Base/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ o2_add_library(MCHBase
1717
PUBLIC_LINK_LIBRARIES ROOT::Core FairRoot::Base FairMQ::FairMQ ms_gsl::ms_gsl)
1818

1919
o2_target_root_dictionary(MCHBase
20-
HEADERS include/MCHBase/Digit.h)
20+
HEADERS include/MCHBase/Digit.h include/MCHBase/DecoderError.h)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/** @file DecoderError.h
12+
* C++ definition of a decoder error
13+
* @author Andrea Ferrero, CEE-Saclay
14+
*/
15+
16+
#ifndef ALICEO2_MCH_BASE_DECODERERROR_H_
17+
#define ALICEO2_MCH_BASE_DECODERERROR_H_
18+
19+
#include "Rtypes.h"
20+
21+
namespace o2
22+
{
23+
namespace mch
24+
{
25+
26+
// \class DecoderError
27+
/// \brief MCH decoder error implementation
28+
class DecoderError
29+
{
30+
public:
31+
DecoderError() = default;
32+
33+
DecoderError(int solarid, int dsid, int chip, uint32_t error) : mSolarID(solarid), mChipID(dsid * 2 + chip), mError(error) {}
34+
~DecoderError() = default;
35+
36+
uint16_t getSolarID() const { return mSolarID; }
37+
uint8_t getDsID() const { return mChipID / 2; }
38+
uint8_t getChip() const { return mChipID % 2; }
39+
40+
uint32_t getError() const { return mError; }
41+
42+
private:
43+
uint16_t mSolarID;
44+
uint8_t mChipID;
45+
uint32_t mError;
46+
47+
ClassDefNV(DecoderError, 1);
48+
}; //class DecoderError
49+
50+
} //namespace mch
51+
} //namespace o2
52+
#endif // ALICEO2_MCH_BASE_DECODERERROR_H_

Detectors/MUON/MCH/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ add_subdirectory(Tracking)
1919
add_subdirectory(Raw)
2020
add_subdirectory(Workflow)
2121
add_subdirectory(Conditions)
22+
add_subdirectory(Calibration)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright CERN and copyright holders of ALICE O2. This software is distributed
2+
# under the terms of the GNU General Public License v3 (GPL Version 3), copied
3+
# verbatim in the file "COPYING".
4+
#
5+
# See http://alice-o2.web.cern.ch/license for full licensing information.
6+
#
7+
# In applying this license CERN does not waive the privileges and immunities
8+
# granted to it by virtue of its status as an Intergovernmental Organization or
9+
# submit itself to any jurisdiction.
10+
11+
o2_add_library(MCHCalibration
12+
SOURCES
13+
src/PedestalDigit.cxx
14+
src/PedestalProcessor.cxx
15+
src/MCHChannelCalibrator.cxx
16+
PUBLIC_LINK_LIBRARIES ms_gsl::ms_gsl O2::DetectorsCalibration O2::CCDB O2::MCHBase O2::MCHRawDecoder O2::DataFormatsMCH)
17+
18+
o2_target_root_dictionary(MCHCalibration
19+
HEADERS include/MCHCalibration/PedestalDigit.h include/MCHCalibration/PedestalProcessor.h include/MCHCalibration/MCHChannelCalibrator.h)
20+
21+
o2_add_executable(pedestals-decoding-workflow
22+
SOURCES src/pedestals-decoding-workflow.cxx
23+
COMPONENT_NAME mch
24+
PUBLIC_LINK_LIBRARIES Boost::program_options O2::Framework O2::DPLUtils O2::MCHCalibration)
25+
26+
o2_add_executable(mch-channel-calib-workflow
27+
COMPONENT_NAME calibration
28+
SOURCES src/channel-calib-workflow.cxx
29+
PUBLIC_LINK_LIBRARIES O2::Framework O2::MCHCalibration O2::DetectorsCalibration)
30+
31+
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \file MCHChannelCalibrator.h
12+
/// \brief Implementation of the MCH calibrator using pedestal data
13+
///
14+
/// \author Andrea Ferrero, CEA-Saclay
15+
16+
#ifndef MCH_CHANNEL_CALIBRATOR_H_
17+
#define MCH_CHANNEL_CALIBRATOR_H_
18+
19+
#include "DataFormatsMCH/DsChannelGroup.h"
20+
#include "DetectorsCalibration/TimeSlotCalibration.h"
21+
#include "DetectorsCalibration/TimeSlot.h"
22+
#include "CCDB/CcdbObjectInfo.h"
23+
#include "MCHCalibration/PedestalDigit.h"
24+
#include "MCHCalibration/PedestalProcessor.h"
25+
26+
#include <array>
27+
28+
namespace o2
29+
{
30+
namespace mch
31+
{
32+
namespace calibration
33+
{
34+
35+
/// Implementation of the processor that computes the mean and RMS of the channel-by-channel pedestals
36+
/// from the data corresponding to a time slot.
37+
/// In the MCH case the time slot has by default an infinite duration, therefore there is only a single
38+
/// set of pedestal values for each calibration run.
39+
class MCHChannelData
40+
{
41+
using Slot = o2::calibration::TimeSlot<o2::mch::calibration::MCHChannelData>;
42+
43+
public:
44+
MCHChannelData() = default;
45+
~MCHChannelData() = default;
46+
47+
void print() const;
48+
49+
/// function to update the pedestal values from the data of a single TimeFrame
50+
void fill(const gsl::span<const o2::mch::calibration::PedestalDigit> data);
51+
void merge(const MCHChannelData* prev);
52+
53+
/// function to access the table of computed pedestals for each readout channel
54+
const PedestalProcessor::PedestalsMap& getPedestals() { return mPedestalProcessor.getPedestals(); }
55+
56+
private:
57+
/// helper class that performs the actual computation of the pedestals from the input digits
58+
PedestalProcessor mPedestalProcessor;
59+
60+
ClassDefNV(MCHChannelData, 1);
61+
};
62+
63+
/// Implementation of a calibrator object that checks the computed mean and RMS of the pedestals and compares the
64+
/// values with user-supplied thresholds.
65+
/// The channels whose values exceed one of the thresholds are considered bad/noisy and they are stored into a
66+
/// "bad channels" list that is sent to the CDDB populator.
67+
class MCHChannelCalibrator final : public o2::calibration::TimeSlotCalibration<o2::mch::calibration::PedestalDigit, o2::mch::calibration::MCHChannelData>
68+
{
69+
using TFType = uint64_t;
70+
using Slot = o2::calibration::TimeSlot<o2::mch::calibration::MCHChannelData>;
71+
using BadChannelsVector = o2::mch::DsChannelGroup;
72+
using CcdbObjectInfo = o2::ccdb::CcdbObjectInfo;
73+
74+
public:
75+
struct ChannelPedestal {
76+
ChannelPedestal() = default;
77+
ChannelPedestal(o2::mch::DsChannelId chid, double mean, double rms) : mDsChId(chid), mPedMean(mean), mPedRms(rms) {}
78+
79+
o2::mch::DsChannelId mDsChId;
80+
double mPedMean{0};
81+
double mPedRms{0};
82+
};
83+
using PedestalsVector = std::vector<ChannelPedestal>;
84+
85+
MCHChannelCalibrator(float pedThreshold, float noiseThreshold) : mPedestalThreshold(pedThreshold), mNoiseThreshold(noiseThreshold), mTFStart(0xffffffffffffffff){};
86+
87+
~MCHChannelCalibrator() final = default;
88+
89+
bool hasEnoughData(const Slot& slot) const final;
90+
void initOutput() final;
91+
void finalizeSlot(Slot& slot) final;
92+
Slot& emplaceNewSlot(bool front, TFType tstart, TFType tend) final;
93+
void endOfStream();
94+
95+
const BadChannelsVector& getBadChannelsVector() const { return mBadChannelsVector; }
96+
const CcdbObjectInfo& getBadChannelsInfo() const { return mBadChannelsInfo; }
97+
CcdbObjectInfo& getBadChannelsInfo() { return mBadChannelsInfo; }
98+
99+
const PedestalsVector& getPedestalsVector() const { return mPedestalsVector; }
100+
101+
private:
102+
float mNoiseThreshold;
103+
float mPedestalThreshold;
104+
105+
TFType mTFStart;
106+
107+
// output
108+
BadChannelsVector mBadChannelsVector; /// vector containing the unique IDs of the bad/noisy channels
109+
CcdbObjectInfo mBadChannelsInfo; /// vector of CCDB Infos , each element is filled with the CCDB description of the accompanying BadChannelsVector object
110+
PedestalsVector mPedestalsVector;
111+
112+
ClassDefOverride(MCHChannelCalibrator, 1);
113+
};
114+
115+
} // end namespace calibration
116+
} // end namespace mch
117+
} // end namespace o2
118+
119+
#endif /* MCH_CHANNEL_CALIBRATOR_H_ */

0 commit comments

Comments
 (0)