Skip to content

Commit a8d3833

Browse files
authored
RecoQC FT0: changed amp-time hist (#2525)
1 parent 225c0c3 commit a8d3833

File tree

5 files changed

+186
-24
lines changed

5 files changed

+186
-24
lines changed

Modules/FIT/FT0/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ target_sources(O2QcFT0 PRIVATE src/AgingLaserTask.cxx
1111
src/OutOfBunchCollCheck.cxx
1212
src/MergedTreeCheck.cxx
1313
src/RecPointsQcTask.cxx
14-
src/ChannelGeometry.cxx)
14+
src/ChannelGeometry.cxx
15+
src/AmpTimeDistribution.cxx)
1516

1617
target_include_directories(
1718
O2QcFT0
@@ -43,6 +44,7 @@ add_root_dictionary(O2QcFT0
4344
include/FT0/MergedTreeCheck.h
4445
include/FT0/RecPointsQcTask.h
4546
include/FT0/ChannelGeometry.h
47+
include/FT0/AmpTimeDistribution.h
4648
LINKDEF include/FT0/LinkDef.h)
4749

4850
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/FT0
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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_FITAMPTIMEDISTRIBUTION_H
13+
#define O2_FITAMPTIMEDISTRIBUTION_H
14+
15+
#include "TH2F.h"
16+
17+
#include <string>
18+
#include <memory>
19+
#include <utility>
20+
#include <vector>
21+
22+
#include <span>
23+
24+
namespace o2::fit
25+
{
26+
27+
struct AmpTimeDistribution {
28+
AmpTimeDistribution() = default;
29+
AmpTimeDistribution(const std::string& name, const std::string& title, int nBins, double minRange, double maxRange, int binsInStep = 50, int binMax = 4095, int axis = 0);
30+
AmpTimeDistribution(const AmpTimeDistribution&);
31+
AmpTimeDistribution(AmpTimeDistribution&&) noexcept;
32+
AmpTimeDistribution& operator=(const AmpTimeDistribution&);
33+
AmpTimeDistribution& operator=(AmpTimeDistribution&&) noexcept;
34+
typedef float Content_t; // to template?
35+
typedef TH2F Hist2F_t;
36+
std::unique_ptr<Hist2F_t> mHist = nullptr;
37+
38+
void initHists(const std::string& name, const std::string& title, int nBins, double minRange, double maxRange, int binsInStep = 50, int binMax = 4095, int axis = 0);
39+
static std::vector<double> makeVaribleBins(const std::vector<std::pair<int, int>>& vecParams, int binMax = 4095);
40+
static std::vector<double> makeVaribleBins(int binsInStep = 50, int binMax = 4095);
41+
};
42+
43+
template <std::size_t NCHANNELS, std::size_t NADC>
44+
using AmpTimeDistributionDetector = std::array<std::array<AmpTimeDistribution, NCHANNELS>, NADC>;
45+
46+
} // namespace o2::fit
47+
#endif

Modules/FIT/FT0/include/FT0/RecPointsQcTask.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define QC_MODULE_FT0_FT0RECOQCTASK_H
2020

2121
#include <Framework/InputRecord.h>
22-
22+
#include <FT0/AmpTimeDistribution.h>
2323
#include "QualityControl/QcInfoLogger.h"
2424
#include <FT0Base/Geometry.h>
2525
#include <DataFormatsFT0/RecPoints.h>
@@ -46,7 +46,7 @@ namespace o2::quality_control_modules::ft0
4646

4747
class RecPointsQcTask final : public TaskInterface
4848
{
49-
static constexpr int NCHANNELS = o2::ft0::Geometry::Nchannels;
49+
static constexpr int sNCHANNELS = o2::ft0::Geometry::Nchannels;
5050

5151
public:
5252
/// \brief Constructor
@@ -62,8 +62,10 @@ class RecPointsQcTask final : public TaskInterface
6262
void endOfActivity(const Activity& activity) override;
6363
void reset() override;
6464
using Detector_t = o2::quality_control_modules::fit::detectorFIT::DetectorFT0;
65+
void initHists();
6566

6667
private:
68+
std::array<o2::fit::AmpTimeDistribution, sNCHANNELS> mArrAmpTimeDistribution;
6769
TList* mListHistGarbage;
6870
std::set<unsigned int> mSetAllowedChIDs;
6971
unsigned int mTrgPos_minBias;
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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 <FT0/AmpTimeDistribution.h>
13+
#include <cstring>
14+
15+
using namespace o2::fit;
16+
17+
AmpTimeDistribution::AmpTimeDistribution(const std::string& name, const std::string& title, int nBins, double minRange, double maxRange, int binsInStep, int binMax, int axis)
18+
{
19+
initHists(name, title, nBins, minRange, maxRange, binsInStep, binMax, axis);
20+
}
21+
22+
AmpTimeDistribution::AmpTimeDistribution(const AmpTimeDistribution& other)
23+
{
24+
if (other.mHist) {
25+
const std::string newName = std::string(other.mHist->GetName()) + "_Cloned";
26+
mHist = std::unique_ptr<AmpTimeDistribution::Hist2F_t>(dynamic_cast<AmpTimeDistribution::Hist2F_t*>(other.mHist->Clone(newName.c_str())));
27+
}
28+
}
29+
30+
AmpTimeDistribution::AmpTimeDistribution(AmpTimeDistribution&& other) noexcept : mHist(std::move(other.mHist))
31+
{
32+
}
33+
34+
AmpTimeDistribution& AmpTimeDistribution::operator=(const AmpTimeDistribution& other)
35+
{
36+
if (this != &other) {
37+
if (other.mHist) {
38+
const std::string newName = std::string(other.mHist->GetName()) + "_Cloned";
39+
mHist = std::unique_ptr<AmpTimeDistribution::Hist2F_t>(dynamic_cast<AmpTimeDistribution::Hist2F_t*>(other.mHist->Clone(newName.c_str())));
40+
} else {
41+
mHist.reset();
42+
}
43+
}
44+
return *this;
45+
}
46+
AmpTimeDistribution& AmpTimeDistribution::operator=(AmpTimeDistribution&& other) noexcept
47+
{
48+
if (this != &other) {
49+
mHist = std::move(other.mHist);
50+
}
51+
return *this;
52+
}
53+
54+
void AmpTimeDistribution::initHists(const std::string& name, const std::string& title, int nBins, double minRange, double maxRange, int binsInStep, int binMax, int axis)
55+
{
56+
const auto& varBins = makeVaribleBins(binsInStep, binMax);
57+
const int varNbins = varBins.size() - 1;
58+
if (axis == 0) {
59+
mHist = std::make_unique<AmpTimeDistribution::Hist2F_t>(name.c_str(), title.c_str(), varNbins, varBins.data(), nBins, minRange, maxRange);
60+
} else if (axis == 1) {
61+
mHist = std::make_unique<AmpTimeDistribution::Hist2F_t>(name.c_str(), title.c_str(), nBins, minRange, maxRange, varNbins, varBins.data());
62+
}
63+
}
64+
65+
std::vector<double> AmpTimeDistribution::makeVaribleBins(const std::vector<std::pair<int, int>>& vecParams, int binMax)
66+
{
67+
std::vector<double> vecLowEdgeBins{};
68+
int startBin{ 0 };
69+
auto makeBinRange = [&vec = vecLowEdgeBins, binMax](int startBin, int binWidth, int nBins) {
70+
const int endBin = startBin + binWidth * nBins;
71+
for (int iBin = startBin; iBin < endBin; iBin += binWidth) {
72+
vec.emplace_back(static_cast<double>(iBin));
73+
if (iBin > binMax) {
74+
break;
75+
}
76+
}
77+
return endBin;
78+
};
79+
for (const auto& entry : vecParams) {
80+
startBin = makeBinRange(startBin, entry.first, entry.second);
81+
}
82+
return vecLowEdgeBins;
83+
}
84+
85+
std::vector<double> AmpTimeDistribution::makeVaribleBins(int binsInStep, int binMax)
86+
{
87+
auto generateParams = [](int binsInStep, int binMax) {
88+
std::vector<std::pair<int, int>> vecParams{};
89+
int endBin{ 0 };
90+
int binWidth = 1;
91+
while (endBin < binMax) {
92+
vecParams.push_back({ binWidth, binsInStep });
93+
endBin += (binWidth * binsInStep);
94+
binWidth *= 2;
95+
}
96+
return vecParams;
97+
};
98+
return makeVaribleBins(generateParams(binsInStep, binMax), binMax);
99+
}

Modules/FIT/FT0/src/RecPointsQcTask.cxx

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
#include <DataFormatsFT0/ChannelData.h>
2626
#include <Framework/InputRecord.h>
2727
#include <vector>
28-
28+
#include "DataFormatsParameters/GRPLHCIFData.h"
2929
#include "FITCommon/HelperHist.h"
3030
#include "FITCommon/HelperCommon.h"
31-
31+
#include "DetectorsBase/GRPGeomHelper.h"
32+
#include "CommonDataFormat/BunchFilling.h"
3233
namespace o2::quality_control_modules::ft0
3334
{
3435

@@ -38,14 +39,23 @@ RecPointsQcTask::~RecPointsQcTask()
3839
{
3940
delete mListHistGarbage;
4041
}
42+
void RecPointsQcTask::initHists()
43+
{
44+
for (int iCh = 0; iCh < sNCHANNELS; iCh++) {
45+
const std::string name = fmt::format("hAmpVsTime_ch{}", iCh);
46+
const std::string title = fmt::format("Amp Vs Time channelID {}; Amp [ADC]; Time [ps]", iCh);
47+
mArrAmpTimeDistribution[iCh] = o2::fit::AmpTimeDistribution(name, title, 200, -2000., 2000., 50, 4095, 0); // in total 315 bins along x-axis
48+
getObjectsManager()->startPublishing(mArrAmpTimeDistribution[iCh].mHist.get());
49+
}
50+
}
4151

4252
void RecPointsQcTask::initialize(o2::framework::InitContext& /*ctx*/)
4353
{
4454
ILOG(Info, Support) << "@@@@initialize RecoQcTask" << ENDM; // QcInfoLogger is used. FairMQ logs will go to there as well.
4555

46-
mHistTime2Ch = std::make_unique<TH2F>("TimePerChannel", "Time vs Channel;Channel;Time [ps]", NCHANNELS, 0, NCHANNELS, 500, -2050, 2050);
56+
mHistTime2Ch = std::make_unique<TH2F>("TimePerChannel", "Time vs Channel;Channel;Time [ps]", sNCHANNELS, 0, sNCHANNELS, 500, -2050, 2050);
4757
mHistTime2Ch->SetOption("colz");
48-
mHistAmp2Ch = std::make_unique<TH2F>("AmpPerChannel", "Amplitude vs Channel;Channel;Amp [#ADC channels]", NCHANNELS, 0, NCHANNELS, 200, 0, 1000);
58+
mHistAmp2Ch = std::make_unique<TH2F>("AmpPerChannel", "Amplitude vs Channel;Channel;Amp [#ADC channels]", sNCHANNELS, 0, sNCHANNELS, 200, 0, 1000);
4959
mHistAmp2Ch->SetOption("colz");
5060
mHistCollTimeAC = std::make_unique<TH1F>("CollTimeAC", "(T0A+T0C)/2;ps", 100, -1000, 1000);
5161
mHistCollTimeA = std::make_unique<TH1F>("CollTimeA", "T0A;ps", 100, -1000, 1000);
@@ -87,15 +97,16 @@ void RecPointsQcTask::initialize(o2::framework::InitContext& /*ctx*/)
8797
mHistTimeA_perTrg = helper::registerHist<TH2F>(getObjectsManager(), PublicationPolicy::Forever, "COLZ", "TimeA_perTrg", "T0A per Trigger;Time [ps]; Trigger", binsTime, mMapTrgBits);
8898
mHistTimeC_perTrg = helper::registerHist<TH2F>(getObjectsManager(), PublicationPolicy::Forever, "COLZ", "TimeC_perTrg", "T0C per Trigger;Time [ps]; Trigger", binsTime, mMapTrgBits);
8999
mHistBC_perTriggers = helper::registerHist<TH2F>(getObjectsManager(), PublicationPolicy::Forever, "COLZ", "BC_perTriggers", "BC per Triggers;BC; Trigger", binsBC, mMapTrgBits);
90-
91-
for (const auto& chID : mSetAllowedChIDs) {
92-
auto pairHistAmpVsTime = mMapHistAmpVsTime.insert({ chID, new TH2F(Form("Amp_vs_time_channel%i", chID), Form("Amplitude vs time, channel %i;Amp;Time", chID), 1000, 0, 4000, 100, -1000, 1000) });
93-
if (pairHistAmpVsTime.second) {
94-
mListHistGarbage->Add(pairHistAmpVsTime.first->second);
95-
getObjectsManager()->startPublishing(pairHistAmpVsTime.first->second);
100+
/*
101+
for (const auto& chID : mSetAllowedChIDs) {
102+
auto pairHistAmpVsTime = mMapHistAmpVsTime.insert({ chID, new TH2F(Form("Amp_vs_time_channel%i", chID), Form("Amplitude vs time, channel %i;Amp;Time", chID), 1000, 0, 4000, 100, -1000, 1000) });
103+
if (pairHistAmpVsTime.second) {
104+
mListHistGarbage->Add(pairHistAmpVsTime.first->second);
105+
getObjectsManager()->startPublishing(pairHistAmpVsTime.first->second);
106+
}
96107
}
97-
}
98-
108+
*/
109+
initHists();
99110
ILOG(Info, Support) << "@@@ histos created" << ENDM;
100111
}
101112

@@ -114,9 +125,8 @@ void RecPointsQcTask::startOfActivity(const Activity& activity)
114125
mHistTimeA_perTrg->Reset();
115126
mHistTimeC_perTrg->Reset();
116127
mHistBC_perTriggers->Reset();
117-
118-
for (auto& entry : mMapHistAmpVsTime) {
119-
entry.second->Reset();
128+
for (int iCh = 0; iCh < sNCHANNELS; iCh++) {
129+
mArrAmpTimeDistribution[iCh].mHist->Reset();
120130
}
121131
}
122132

@@ -128,7 +138,9 @@ void RecPointsQcTask::monitorData(o2::framework::ProcessingContext& ctx)
128138
{
129139
auto chan = ctx.inputs().get<gsl::span<o2::ft0::ChannelDataFloat>>("channels");
130140
auto recpoints = ctx.inputs().get<gsl::span<o2::ft0::RecPoints>>("recpoints");
131-
141+
const auto& grplhcif = o2::base::GRPGeomHelper::instance().getGRPLHCIF();
142+
const auto& bcSchema = grplhcif ? grplhcif->getBunchFilling().getBCPattern() : o2::BunchFilling::Pattern{};
143+
const bool isPbPb = grplhcif ? grplhcif->getAtomicNumberB1() == 82 && grplhcif->getAtomicNumberB2() == 82 : false;
132144
for (const auto& recpoint : recpoints) {
133145
const auto bc = recpoint.getInteractionRecord().bc;
134146
int time[o2::ft0::Constants::sNCHANNELS_PM] = { 0 };
@@ -158,13 +170,14 @@ void RecPointsQcTask::monitorData(o2::framework::ProcessingContext& ctx)
158170
}
159171
}
160172
}
173+
const bool isMinBiasEvent = (isPbPb && minBias) || (!isPbPb && triggersignals.getVertex()); // for pp only vertex, for PbPb vrt && (CENT || SCENT)
161174
for (const auto& chData : channels) {
162175
time[chData.ChId] = chData.CFDTime;
163176
amp[chData.ChId] = chData.QTCAmpl;
164177
mHistTime2Ch->Fill(static_cast<Double_t>(chData.ChId), static_cast<Double_t>(chData.CFDTime));
165178
mHistAmp2Ch->Fill(static_cast<Double_t>(chData.ChId), static_cast<Double_t>(chData.QTCAmpl));
166-
if (mSetAllowedChIDs.find(static_cast<unsigned int>(chData.ChId)) != mSetAllowedChIDs.end() && minBias) { // ampt-time dependency is needed only for PbPb runs
167-
mMapHistAmpVsTime[chData.ChId]->Fill(chData.QTCAmpl, chData.CFDTime);
179+
if (bcSchema.test(bc) && isMinBiasEvent) { // ampt-time dependency
180+
mArrAmpTimeDistribution[chData.ChId].mHist->Fill(chData.QTCAmpl, chData.CFDTime);
168181
}
169182
}
170183
if (vertexTrigger) {
@@ -239,9 +252,8 @@ void RecPointsQcTask::reset()
239252
mHistTimeA_perTrg->Reset();
240253
mHistTimeC_perTrg->Reset();
241254
mHistBC_perTriggers->Reset();
242-
243-
for (auto& entry : mMapHistAmpVsTime) {
244-
entry.second->Reset();
255+
for (int iCh = 0; iCh < sNCHANNELS; iCh++) {
256+
mArrAmpTimeDistribution[iCh].mHist->Reset();
245257
}
246258
}
247259

0 commit comments

Comments
 (0)