Skip to content

Commit bce6d29

Browse files
cortesepalibuildshahor02
authored
ZDC FIX digitization, add noise calibration, add option to prescale reconstruction (#9802)
* WIP * WIP * Data format for noise calibration * WIP * WIP * WIP * WIP * WIP * FIX - Skip duplicated channels in digit2raw * Metafile creation for output file * clang-format * Please consider the following formatting changes * cleanup * WIP * hbfIni in o2-zdc-digits-read * WIP * Option to reconstruct a fraction of total time frames * Transmission of histograms using subspecs * Transmission of histograms using subspecs * Fix compilation errror * More explicit reject logic * dummy commit to trigger CI * New debug histogram * New debug histogram * clang-format Co-authored-by: ALICE Action Bot <alibuild@cern.ch> Co-authored-by: Ruben Shahoyan <shahor02@users.noreply.github.com>
1 parent d942423 commit bce6d29

42 files changed

Lines changed: 1790 additions & 111 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Detectors/ZDC/base/include/ZDCBase/Constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ const std::string CCDBPathWaveformCalib = "ZDC/Calib/WaveformCalib";
257257
const std::string CCDBPathWaveformCalibConfig = "ZDC/Calib/WaveformCalibConfig";
258258
const std::string CCDBPathBaselineCalib = "ZDC/Calib/BaselineCalib";
259259
const std::string CCDBPathBaselineCalibConfig = "ZDC/Calib/BaselineCalibConfig";
260+
const std::string CCDBPathNoiseCalib = "ZDC/Calib/NoiseCalib";
260261

261262
enum Ped { PedND = 0,
262263
PedEv = 1,

Detectors/ZDC/calib/CMakeLists.txt

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

1212
o2_add_library(ZDCCalib
1313
SOURCES
14+
src/NoiseCalibData.cxx
15+
src/NoiseCalibEPN.cxx
16+
src/NoiseCalibEPNSpec.cxx
17+
src/NoiseCalib.cxx
18+
src/NoiseCalibSpec.cxx
1419
src/BaselineCalibData.cxx
1520
src/BaselineCalibConfig.cxx
1621
src/BaselineCalibEPN.cxx
@@ -61,6 +66,7 @@ o2_add_library(ZDCCalib
6166

6267
o2_target_root_dictionary(ZDCCalib
6368
HEADERS
69+
include/ZDCCalib/NoiseCalibData.h
6470
include/ZDCCalib/BaselineCalibData.h
6571
include/ZDCCalib/BaselineCalibConfig.h
6672
include/ZDCCalib/InterCalibData.h
@@ -98,6 +104,16 @@ o2_add_executable(baselinecalib-workflow
98104
SOURCES src/zdc-baselinecalib-workflow.cxx
99105
PUBLIC_LINK_LIBRARIES O2::ZDCWorkflow O2::ZDCCalib O2::DetectorsCalibration)
100106

107+
o2_add_executable(noisecalib-epn-workflow
108+
COMPONENT_NAME zdc
109+
SOURCES src/zdc-noisecalib-epn-workflow.cxx
110+
PUBLIC_LINK_LIBRARIES O2::ZDCWorkflow O2::ZDCCalib O2::DetectorsCalibration)
111+
112+
o2_add_executable(noisecalib-workflow
113+
COMPONENT_NAME zdc
114+
SOURCES src/zdc-noisecalib-workflow.cxx
115+
PUBLIC_LINK_LIBRARIES O2::ZDCWorkflow O2::ZDCCalib O2::DetectorsCalibration)
116+
101117
o2_add_executable(tdccalib-epn-workflow
102118
COMPONENT_NAME zdc
103119
SOURCES src/zdc-tdccalib-epn-workflow.cxx

Detectors/ZDC/calib/include/ZDCCalib/CalibParamZDC.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "CommonUtils/ConfigurableParam.h"
1616
#include "CommonUtils/ConfigurableParamHelper.h"
1717
#include "ZDCBase/Constants.h"
18+
#include <string>
1819

1920
/// \file CalibParamZDC.h
2021
/// \brief ZDC calibration common parameters
@@ -25,7 +26,10 @@ namespace o2
2526
namespace zdc
2627
{
2728
struct CalibParamZDC : public o2::conf::ConfigurableParamHelper<CalibParamZDC> {
28-
int debug_output = -1; // Debug output
29+
bool rootOutput = true; // Debug output
30+
std::string outputDir = "./"; // ROOT files output directory
31+
std::string metaFileDir = "/dev/null"; // Metafile output directory
32+
std::string descr; // Calibration description
2933
void print();
3034
O2ParamDef(CalibParamZDC, "CalibParamZDC");
3135
};

Detectors/ZDC/calib/include/ZDCCalib/InterCalib.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ class InterCalib
7676
void setVerbosity(int v) { mVerbosity = v; }
7777
int getVerbosity() const { return mVerbosity; }
7878

79-
void setSaveDebugHistos() { mSaveDebugHistos = true; }
80-
void setDontSaveDebugHistos() { mSaveDebugHistos = false; }
81-
8279
static constexpr const char* mHUncN[2 * NH] = {"hZNAS", "hZPAS", "hZNCS", "hZPCS", "hZEM2", "hZNAC", "hZPAC", "hZNCC", "hZPCC", "hZEM1"};
8380
static constexpr const char* mHUncT[2 * NH] = {"ZNA sum", "ZPA sum", "ZNC sum", "ZPC sum", "ZEM2", "ZNA TC", "ZPA TC", "ZNC TC", "ZPC TC", "ZEM1"};
8481
static constexpr const char* mCUncN[NH] = {"cZNA", "cZPA", "cZNC", "cZPC", "cZEM"};
@@ -92,7 +89,6 @@ class InterCalib
9289
std::array<std::unique_ptr<TMinuit>, NH> mMn{};
9390
InterCalibData mData;
9491
bool mInitDone = false;
95-
bool mSaveDebugHistos = false;
9692
int32_t mVerbosity = DbgMinimal;
9793
static std::mutex mMtx; /// mutex for critical section
9894
double mPar[NH][NPAR] = {0};
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 <memory>
13+
#include <gsl/span>
14+
#include "ZDCBase/Constants.h"
15+
#include "CommonDataFormat/FlatHisto1D.h"
16+
#include "ZDCBase/ModuleConfig.h"
17+
#include "ZDCCalib/NoiseCalibData.h"
18+
#include "ZDCReconstruction/NoiseParam.h"
19+
#include "CCDB/CcdbObjectInfo.h"
20+
#ifndef ALICEO2_ZDC_NOISECALIB_H
21+
#define ALICEO2_ZDC_NOISECALIB_H
22+
namespace o2
23+
{
24+
namespace zdc
25+
{
26+
class NoiseCalib
27+
{
28+
using CcdbObjectInfo = o2::ccdb::CcdbObjectInfo;
29+
30+
public:
31+
NoiseCalib() = default;
32+
int init();
33+
void setModuleConfig(const ModuleConfig* moduleConfig) { mModuleConfig = moduleConfig; };
34+
const ModuleConfig* getModuleConfig() { return mModuleConfig; };
35+
void clear();
36+
// int process(const o2::zdc::NoiseCalibSummaryData& data);
37+
int process(const o2::zdc::NoiseCalibSummaryData* data);
38+
void add(int ih, o2::dataformats::FlatHisto1D<double>& h1);
39+
int endOfRun();
40+
int saveDebugHistos(const std::string fn = "ZDCNoiseCalib.root");
41+
42+
CcdbObjectInfo& getCcdbObjectInfo() { return mInfo; }
43+
44+
void setVerbosity(int v) { mVerbosity = v; }
45+
int getVerbosity() const { return mVerbosity; }
46+
47+
NoiseCalibData& getData() { return mData; }
48+
NoiseParam& getParam() { return mParam; }
49+
std::array<o2::dataformats::FlatHisto1D<double>*, NChannels> mH{};
50+
51+
private:
52+
NoiseCalibData mData;
53+
NoiseParam mParam;
54+
bool mInitDone = false;
55+
const ModuleConfig* mModuleConfig = nullptr; /// Trigger/readout configuration object
56+
int32_t mVerbosity = DbgMinimal;
57+
CcdbObjectInfo mInfo; /// CCDB Info
58+
};
59+
} // namespace zdc
60+
} // namespace o2
61+
62+
#endif
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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 ZDC_NOISECALIB_DATA_H
13+
#define ZDC_NOISECALIB_DATA_H
14+
15+
#include "Framework/Logger.h"
16+
#include "ZDCBase/Constants.h"
17+
#include <array>
18+
#include <vector>
19+
#include <map>
20+
#include <gsl/span>
21+
22+
/// \file NoiseCalibData.h
23+
/// \brief Format of noise calibration intermediate data
24+
/// \author pietro.cortese@cern.ch
25+
26+
namespace o2
27+
{
28+
namespace zdc
29+
{
30+
31+
// Messageable representation of noise calibration data
32+
struct NoiseCalibBinData {
33+
NoiseCalibBinData() = default;
34+
NoiseCalibBinData(uint8_t myid, uint32_t myibin, uint32_t mycont)
35+
{
36+
ibin = (myid << 24) | (myibin & 0x00ffffff);
37+
cont = mycont;
38+
}
39+
uint32_t ibin = 0xff000000; /// Encoded channel ID / bin number
40+
uint32_t cont = 0; /// Channel counts
41+
inline uint32_t id() const
42+
{ // Channel id
43+
return (ibin >> 24);
44+
}
45+
inline uint32_t bin() const
46+
{ // Bin number
47+
return (ibin & 0x00ffffff);
48+
}
49+
inline uint32_t counts() const
50+
{ // Channel counts
51+
return cont;
52+
}
53+
void print() const
54+
{
55+
LOGF(info, "NoiseCalibBinData ch=%2u bin=%4u cont=%u", id(), bin(), counts());
56+
}
57+
ClassDefNV(NoiseCalibBinData, 1);
58+
};
59+
60+
// Container of the messageable representation of noise calibration data
61+
struct NoiseCalibSummaryData {
62+
NoiseCalibSummaryData() = default;
63+
uint64_t mCTimeBeg = 0; /// Time of processed time frame
64+
uint64_t mCTimeEnd = 0; /// Time of processed time frame
65+
bool mOverflow = false; /// Overflow of one channel
66+
std::array<bool, NChannels> mOverflowCh{}; /// Channel overflow information
67+
std::vector<NoiseCalibBinData> mData; /// Data of not empty bins
68+
void clear();
69+
void print() const;
70+
ClassDefNV(NoiseCalibSummaryData, 1);
71+
};
72+
73+
// Working representation of noise channel data
74+
struct NoiseCalibChData {
75+
NoiseCalibChData() = default;
76+
// Variance intermediate data are uint32_t and sparse (~25% channels are filled)
77+
// and histogram limits are not known in advance -> use map
78+
std::map<uint32_t, uint32_t> mData; /// Map histogram container
79+
bool mOverflow = false; /// Overflow flag (cannot accept more data)
80+
uint64_t getEntries() const;
81+
uint32_t getMaxBin() const;
82+
int getStat(uint64_t& en, double& mean, double& var) const;
83+
inline bool isOverflow() { return mOverflow; };
84+
void clear();
85+
ClassDefNV(NoiseCalibChData, 1);
86+
};
87+
88+
// Working representation of noise data
89+
struct NoiseCalibData {
90+
NoiseCalibData() = default;
91+
92+
uint64_t mCTimeBeg = 0; /// Time of processed time frame
93+
uint64_t mCTimeEnd = 0; /// Time of processed time frame
94+
bool mOverflow = false; /// Overflow at least one ZDC channel
95+
96+
NoiseCalibChData mHisto[NChannels]; /// Sparse histogram of single channels
97+
NoiseCalibSummaryData mSummary; /// Serialized data to be dispatched
98+
99+
NoiseCalibData& operator+=(const NoiseCalibData& other);
100+
NoiseCalibData& operator=(const NoiseCalibSummaryData& s);
101+
// NoiseCalibData& operator+=(const NoiseCalibSummaryData& s);
102+
NoiseCalibData& operator+=(const NoiseCalibSummaryData* s);
103+
104+
inline void addEntry(int isig, uint32_t val)
105+
{
106+
if (!mHisto[isig].mOverflow) {
107+
int ibin = 0x00ffffff;
108+
// Overflow in bin number
109+
if (val < 0x00ffffff) {
110+
ibin = val;
111+
}
112+
// Overflow in data
113+
if (mHisto[isig].mData[ibin] < 0xffffffff) {
114+
mHisto[isig].mData[ibin]++;
115+
} else {
116+
mHisto[isig].mOverflow = true;
117+
mOverflow = true;
118+
}
119+
}
120+
}
121+
122+
uint64_t getEntries(int is) const;
123+
uint32_t getMaxBin(int is) const;
124+
int getStat(int is, uint64_t& en, double& mean, double& var) const;
125+
void print() const;
126+
void clear();
127+
void setCreationTime(uint64_t ctime);
128+
void setN(int n);
129+
NoiseCalibSummaryData& getSummary();
130+
int saveDebugHistos(const std::string fn);
131+
ClassDefNV(NoiseCalibData, 1);
132+
};
133+
134+
} // namespace zdc
135+
} // namespace o2
136+
137+
#endif
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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 <memory>
13+
#include <gsl/span>
14+
#include "ZDCBase/Constants.h"
15+
#include "CommonDataFormat/FlatHisto1D.h"
16+
#include "ZDCBase/ModuleConfig.h"
17+
#include "DataFormatsZDC/BCData.h"
18+
#include "DataFormatsZDC/ChannelData.h"
19+
#include "ZDCReconstruction/RecoParamZDC.h"
20+
#include "ZDCCalib/NoiseCalibData.h"
21+
#ifndef ALICEO2_ZDC_NOISECALIBEPN_H
22+
#define ALICEO2_ZDC_NOISECALIBEPN_H
23+
namespace o2
24+
{
25+
namespace zdc
26+
{
27+
class NoiseCalibEPN
28+
{
29+
public:
30+
NoiseCalibEPN() = default;
31+
int init();
32+
void setModuleConfig(const ModuleConfig* moduleConfig) { mModuleConfig = moduleConfig; };
33+
const ModuleConfig* getModuleConfig() { return mModuleConfig; };
34+
void clear(int ih = -1);
35+
int process(const gsl::span<const o2::zdc::BCData>& bcdata, const gsl::span<const o2::zdc::ChannelData>& chdata);
36+
int endOfRun();
37+
int saveDebugHistos(const std::string fn = "ZDCNoiseCalibEPN.root");
38+
void setSaveDebugHistos() { mSaveDebugHistos = true; }
39+
void setDontSaveDebugHistos() { mSaveDebugHistos = false; }
40+
void setVerbosity(int val) { mVerbosity = val; }
41+
NoiseCalibData mData;
42+
NoiseCalibData& getData() { return mData; }
43+
std::array<o2::dataformats::FlatHisto1D<double>*, NChannels> mH{};
44+
45+
private:
46+
bool mInitDone = false;
47+
bool mSaveDebugHistos = false;
48+
const ModuleConfig* mModuleConfig = nullptr; ///< Trigger/readout configuration object
49+
const RecoParamZDC* mRopt = nullptr;
50+
uint32_t mChMask[NChannels] = {0}; ///< Identify all channels in readout pattern
51+
int32_t mVerbosity = DbgMinimal;
52+
};
53+
} // namespace zdc
54+
} // namespace o2
55+
56+
#endif
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
/// @file InterCalibEPNSpec.h
13+
/// @brief ZDC intercalibration pre-processing on EPN
14+
/// @author pietro.cortese@cern.ch
15+
16+
#ifndef O2_ZDC_NOISECALIBEPN_SPEC
17+
#define O2_ZDC_NOISECALIBEPN_SPEC
18+
19+
#include <TStopwatch.h>
20+
#include "Framework/Logger.h"
21+
#include "Framework/DataProcessorSpec.h"
22+
#include "Framework/DataAllocator.h"
23+
#include "Framework/DataSpecUtils.h"
24+
#include "Framework/Task.h"
25+
#include "CommonUtils/NameConf.h"
26+
#include "ZDCCalib/NoiseCalibData.h"
27+
#include "ZDCCalib/NoiseCalibEPN.h"
28+
29+
namespace o2
30+
{
31+
namespace zdc
32+
{
33+
34+
class NoiseCalibEPNSpec : public o2::framework::Task
35+
{
36+
public:
37+
NoiseCalibEPNSpec();
38+
NoiseCalibEPNSpec(const int verbosity);
39+
~NoiseCalibEPNSpec() override = default;
40+
void init(o2::framework::InitContext& ic) final;
41+
void updateTimeDependentParams(o2::framework::ProcessingContext& pc);
42+
void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final;
43+
void run(o2::framework::ProcessingContext& pc) final;
44+
void endOfStream(o2::framework::EndOfStreamContext& ec) final;
45+
46+
private:
47+
int mVerbosity = DbgZero; // Verbosity level
48+
bool mInitialized = false; // Connect once to CCDB during initialization
49+
NoiseCalibEPN mWorker; // Noise calibration object
50+
TStopwatch mTimer;
51+
};
52+
53+
framework::DataProcessorSpec getNoiseCalibEPNSpec();
54+
55+
} // namespace zdc
56+
} // namespace o2
57+
58+
#endif

0 commit comments

Comments
 (0)