Skip to content

Commit b413f9d

Browse files
author
Sofia Tomassini
committed
[TOF] adding Post Processing Luminometer
1 parent 2af8981 commit b413f9d

File tree

4 files changed

+233
-0
lines changed

4 files changed

+233
-0
lines changed

Modules/TOF/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ target_sources(O2QcTOF
2323
src/PostProcessDiagnosticPerCrate.cxx
2424
src/PostProcessHitMap.cxx
2525
src/PostProcessingLostOrbits.cxx
26+
src/PostProcessingLuminometer.cxx
2627
# Trending
2728
src/TrendingHits.cxx
2829
src/TrendingRate.cxx
@@ -80,6 +81,7 @@ add_root_dictionary(O2QcTOF
8081
include/TOF/PostProcessDiagnosticPerCrate.h
8182
include/TOF/PostProcessHitMap.h
8283
include/TOF/PostProcessingLostOrbits.h
84+
include/TOF/PostProcessingLuminometer.h
8385
# Trending
8486
include/TOF/TrendingHits.h
8587
include/TOF/TrendingRate.h

Modules/TOF/include/TOF/LinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#pragma link C++ class o2::quality_control_modules::tof::PostProcessDiagnosticPerCrate + ;
2424
#pragma link C++ class o2::quality_control_modules::tof::PostProcessHitMap + ;
2525
#pragma link C++ class o2::quality_control_modules::tof::PostProcessingLostOrbits + ;
26+
#pragma link C++ class o2::quality_control_modules::tof::PostProcessingLuminometer + ;
2627
// Trending
2728
#pragma link C++ class o2::quality_control_modules::tof::TrendingHits + ;
2829
#pragma link C++ class o2::quality_control_modules::tof::TrendingRate + ;
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
///
13+
/// \file PostProcessingLuminometer.h
14+
/// \author Francesca Ercolessi francesca.ercolessi@cern.ch
15+
///
16+
17+
#ifndef QUALITYCONTROL_POSTPROCESSINGLUMINOMETER_H
18+
#define QUALITYCONTROL_POSTPROCESSINGLUMINOMETER_H
19+
20+
#include "QualityControl/PostProcessingInterface.h"
21+
#include "QualityControl/DatabaseInterface.h"
22+
23+
class TH1F;
24+
25+
namespace o2::quality_control_modules::tof
26+
{
27+
28+
/// \brief Post processing to monitor lost orbits in TimeFrame
29+
/// \author Francesca Ercolessi francesca.ercolessi@cern.ch
30+
class PostProcessingLuminometer final : public quality_control::postprocessing::PostProcessingInterface
31+
{
32+
public:
33+
/// \brief Constructor
34+
PostProcessingLuminometer() = default;
35+
/// \brief Destructor
36+
~PostProcessingLuminometer() override;
37+
38+
/// \brief Configuration of a post-processing task.
39+
/// Configuration of a post-processing task. Can be overridden if user wants to retrieve the configuration of the task.
40+
/// \param config ConfigurationInterface with prefix set to ""
41+
virtual void configure(const boost::property_tree::ptree& config) override;
42+
/// \brief Initialization of a post-processing task.
43+
/// Initialization of a post-processing task. User receives a Trigger which caused the initialization and a service
44+
/// registry with singleton interfaces.
45+
/// \param trigger Trigger which caused the initialization, for example Trigger::SOR
46+
/// \param services Interface containing optional interfaces, for example DatabaseInterface
47+
void initialize(quality_control::postprocessing::Trigger, framework::ServiceRegistryRef) override;
48+
/// \brief Update of a post-processing task.
49+
/// Update of a post-processing task. User receives a Trigger which caused the update and a service
50+
/// registry with singleton interfaces.
51+
/// \param trigger Trigger which caused the initialization, for example Trigger::Period
52+
/// \param services Interface containing optional interfaces, for example DatabaseInterface
53+
void update(quality_control::postprocessing::Trigger, framework::ServiceRegistryRef) override;
54+
/// \brief Finalization of a post-processing task.
55+
/// Finalization of a post-processing task. User receives a Trigger which caused the finalization and a service
56+
/// registry with singleton interfaces.
57+
/// \param trigger Trigger which caused the initialization, for example Trigger::EOR
58+
/// \param services Interface containing optional interfaces, for example DatabaseInterface
59+
void finalize(quality_control::postprocessing::Trigger, framework::ServiceRegistryRef) override;
60+
61+
private:
62+
o2::quality_control::repository::DatabaseInterface* mDatabase = nullptr;
63+
std::string mCCDBPath = "TOF/MO/TaskDigits/";
64+
std::string mMOEfficiency = "OrbitVsCrate";
65+
std::string mMOActiveChannels = "HitMap";
66+
std::string mMOMultiplicity = "Multiplicity/Integrated";
67+
std::shared_ptr<TH1F> mHistoOrbitsInTFEfficiency = nullptr;
68+
std::shared_ptr<TH1F> mHistoLuminometer = nullptr;
69+
int mBins = 1100;
70+
float mMaxRange = 1.1;
71+
float mActiveThr = 1;
72+
};
73+
74+
} // namespace o2::quality_control_modules::tof
75+
76+
#endif // QUALITYCONTROL_POSTPROCESSINGLuminometer_H
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
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+
///
13+
/// \file PostProcessingLuminometer.cxx
14+
/// \author Francesca Ercolessi francesca.ercolessi@cern.ch
15+
///
16+
17+
#include "TOF/PostProcessingLuminometer.h"
18+
#include "QualityControl/QcInfoLogger.h"
19+
#include "QualityControl/DatabaseInterface.h"
20+
21+
#include "TOF/Utils.h"
22+
23+
#include <TH1F.h>
24+
#include <TH2F.h>
25+
#include <boost/property_tree/ptree.hpp>
26+
27+
using namespace o2::quality_control::postprocessing;
28+
29+
namespace o2::quality_control_modules::tof
30+
{
31+
32+
PostProcessingLuminometer::~PostProcessingLuminometer()
33+
{
34+
}
35+
36+
void PostProcessingLuminometer::configure(const boost::property_tree::ptree& config)
37+
{
38+
if (const auto& customConfigs = config.get_child_optional("qc.postprocessing." + getID() + ".customization"); customConfigs.has_value()) {
39+
for (const auto& customConfig : customConfigs.value()) { // Plot configuration
40+
if (const auto& customNames = customConfig.second.get_child_optional("name"); customNames.has_value()) {
41+
if (customConfig.second.get<std::string>("name") == "Nbins") {
42+
mBins = customConfig.second.get<int>("value");
43+
ILOG(Info, Support) << "Setting Nbins to " << mBins << ENDM;
44+
} else if (customConfig.second.get<std::string>("name") == "MaxValue") {
45+
mMaxRange = customConfig.second.get<float>("value");
46+
ILOG(Info, Support) << "Setting Nbins to " << mMaxRange << ENDM;
47+
} else if (customConfig.second.get<std::string>("name") == "CCDBPath") {
48+
mCCDBPath = customConfig.second.get<std::string>("value");
49+
ILOG(Info, Support) << "Setting CCDBPath to " << mCCDBPath << ENDM;
50+
} else if (customConfig.second.get<std::string>("name") == "ActiveThr") {
51+
mActiveThr = customConfig.second.get<float>("value");
52+
ILOG(Info, Support) << "Setting mActiveThr to " << mActiveThr << ENDM;
53+
}
54+
}
55+
}
56+
}
57+
}
58+
59+
void PostProcessingLuminometer::initialize(Trigger, framework::ServiceRegistryRef services)
60+
{
61+
float bin_width = mMaxRange / mBins;
62+
mHistoOrbitsInTFEfficiency.reset();
63+
mHistoOrbitsInTFEfficiency = std::make_shared<TH1F>("OrbitsInTFEfficiency", "Fraction of orbits in TF;Fraction of orbits in TF; Counts x n_{crates} ", mBins, bin_width / 2, mMaxRange + bin_width / 2);
64+
getObjectsManager()->startPublishing(mHistoOrbitsInTFEfficiency.get());
65+
66+
mHistoLuminometer.reset();
67+
mHistoLuminometer = std::make_shared<TH1F>("Luminometer", "Luminometer; ; hit_{TOF}/(eff_{RO}f_{active}) ", 1000, 0., 10000);
68+
getObjectsManager()->startPublishing(mHistoLuminometer.get());
69+
70+
mDatabase = &services.get<o2::quality_control::repository::DatabaseInterface>();
71+
}
72+
73+
void PostProcessingLuminometer::update(Trigger t, framework::ServiceRegistryRef)
74+
{
75+
ILOG(Info, Support) << "Trigger type is: " << t.triggerType << ", the timestamp is " << t.timestamp << ENDM;
76+
77+
if (mHistoOrbitsInTFEfficiency) {
78+
mHistoOrbitsInTFEfficiency->Reset();
79+
}
80+
if (mHistoLuminometer){
81+
mHistoLuminometer->Reset();
82+
}
83+
84+
TH1F* tempPerCrateHisto[72]; // 72 crates
85+
for (int i = 0; i < 72; i++) { // loop over crates
86+
tempPerCrateHisto[i] = nullptr;
87+
}
88+
89+
auto moEfficiency = mDatabase->retrieveMO(mCCDBPath, mMOEfficiency, t.timestamp, t.activity);
90+
auto moActiveChannels = mDatabase->retrieveMO(mCCDBPath, mMOActiveChannels, t.timestamp, t.activity);
91+
auto moMultiplicity = mDatabase->retrieveMO(mCCDBPath, mMOMultiplicity, t.timestamp, t.activity);
92+
93+
float ROeff = 1.;
94+
float hitMult = 0.;
95+
float activeCh = 1.;
96+
97+
// Readout efficiency
98+
TH2F* moHEfficiency = static_cast<TH2F*>(moEfficiency ? moEfficiency->getObject() : nullptr);
99+
if (moHEfficiency) {
100+
ILOG(Info, Support) << "Found MO " << mMOEfficiency << " in path " << mCCDBPath << ENDM;
101+
for (int i = 0; i < 72; i++) { // loop over crates
102+
tempPerCrateHisto[i] = (TH1F*)moHEfficiency->ProjectionY(Form("hPerCrate%i", i), i + 1, i + 1);
103+
mHistoOrbitsInTFEfficiency->Fill(tempPerCrateHisto[i]->Integral() / (32.f * 3.f)); // 32 orbits in Time Frame, 3 readout windows per orbit
104+
}
105+
} else {
106+
ILOG(Warning) << "Did not find MO " << mMOEfficiency << " in path " << mCCDBPath << ENDM;
107+
}
108+
109+
if (mHistoOrbitsInTFEfficiency) {
110+
ROeff = mHistoOrbitsInTFEfficiency->GetMean();
111+
}
112+
113+
// Active channels
114+
TH2F* moHActiveChannels = static_cast<TH2F*>(moActiveChannels ? moActiveChannels->getObject() : nullptr);
115+
if (moHActiveChannels) {
116+
ILOG(Info, Support) << "Found MO " << mMOActiveChannels << " in path " << mCCDBPath << ENDM;
117+
118+
int counterAll = 0;
119+
int counterActive = 0;
120+
121+
for (int i = 1; i <= moHActiveChannels->GetNbinsX(); i++) {
122+
for (int j = 1; j <= moHActiveChannels->GetNbinsY(); j++) {
123+
counterAll++;
124+
125+
if (moHActiveChannels->GetBinContent(i,j)>mActiveThr){
126+
counterActive++;
127+
}
128+
}
129+
}
130+
131+
activeCh = (float)counterActive/counterAll;
132+
} else {
133+
ILOG(Warning) << "Did not find MO " << mMOActiveChannels << " in path " << mCCDBPath << ENDM;
134+
}
135+
136+
// Multiplicity
137+
TH1F* moHMultiplicity = static_cast<TH1F*>(moMultiplicity ? moMultiplicity->getObject() : nullptr);
138+
if (moHMultiplicity) {
139+
ILOG(Info, Support) << "Found MO " << mMOMultiplicity << " in path " << mCCDBPath << ENDM;
140+
hitMult = moHMultiplicity->GetMean();
141+
} else {
142+
ILOG(Warning) << "Did not find MO " << mMOMultiplicity << " in path " << mCCDBPath << ENDM;
143+
}
144+
145+
mHistoLuminometer->Fill(hitMult/(activeCh*ROeff));
146+
}
147+
148+
void PostProcessingLuminometer::finalize(Trigger, framework::ServiceRegistryRef)
149+
{
150+
// Only if you don't want it to be published after finalisation.
151+
getObjectsManager()->stopPublishing(mHistoLuminometer.get());
152+
}
153+
154+
} // namespace o2::quality_control_modules::tof

0 commit comments

Comments
 (0)