Project
Loading...
Searching...
No Matches
TPCPressureTemperatureSpec.cxx
Go to the documentation of this file.
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
16
18#include "Framework/Task.h"
24
25using namespace o2::framework;
26
27namespace o2
28{
29namespace tpc
30{
31
33{
34 public:
35 PressureTemperatureDevice(std::shared_ptr<o2::base::GRPGeomRequest> req) : mCCDBRequest(req){};
37 {
39 const int intInterval = ic.options().get<int>("fit-interval");
40 mPTHelper.setFitIntervalTemp(intInterval * 1000);
41 const bool enableDebugTree = ic.options().get<bool>("enable-root-output");
42 if (enableDebugTree) {
43 mStreamer = std::make_unique<o2::utils::TreeStreamRedirector>("pt.root", "recreate");
44 }
45 };
46
48 {
49 if (mStreamer) {
50 mStreamer->Close();
51 }
52 }
53
55 {
57 mPTHelper.extractCCDBInputs(pc);
58 const auto orbitResetTimeMS = o2::base::GRPGeomHelper::instance().getOrbitResetTimeMS();
59 const auto firstTFOrbit = pc.services().get<o2::framework::TimingInfo>().firstTForbit;
60 const uint64_t timestamp = orbitResetTimeMS + firstTFOrbit * o2::constants::lhc::LHCOrbitMUS * 0.001;
61 mPTHelper.sendPTForTS(pc, timestamp);
62
63 if (mStreamer) {
64 const float pressure = mPTHelper.getPressure(timestamp);
65 const auto temp = mPTHelper.getTemperature(timestamp);
66 (*mStreamer) << "pt"
67 << "pressure=" << pressure
68 << "temperatureA=" << temp.first
69 << "temperatureC=" << temp.second
70 << "time=" << timestamp
71 << "\n";
72 }
73 }
74
75 void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final
76 {
78 mPTHelper.accountCCDBInputs(matcher, obj);
79 }
80
81 private:
83 std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
84 std::unique_ptr<o2::utils::TreeStreamRedirector> mStreamer;
85};
86
88{
89 std::vector<InputSpec> inputs;
90 std::vector<OutputSpec> outputs;
91 o2::header::DataDescription dataDescription;
92
95
96 auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(true, // orbitResetTime
97 false, // GRPECS=true for nHBF per TF
98 false, // GRPLHCIF
99 false, // GRPMagField
100 false, // askMatLUT
102 inputs);
103 return DataProcessorSpec{
104 "tpc-pressure-temperature",
105 inputs,
106 outputs,
107 AlgorithmSpec{adaptFromTask<PressureTemperatureDevice>(ccdbRequest)},
108 Options{
109 {"enable-root-output", VariantType::Bool, false, {"Enable root-files output writers"}},
110 {"fit-interval", VariantType::Int, 300, {"interval in seconds for which to e.g. perform fits of the temperature sensors"}}} // end Options
111 };
112}
113
114} // end namespace tpc
115} // end namespace o2
Helper for geometry and GRP related CCDB requests.
Helper class to extract pressure and temperature.
auto getOrbitResetTimeMS() const
void checkUpdates(o2::framework::ProcessingContext &pc)
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
PressureTemperatureDevice(std::shared_ptr< o2::base::GRPGeomRequest > req)
void endOfStream(EndOfStreamContext &eos) final
This is invoked whenever we have an EndOfStream event.
void init(o2::framework::InitContext &ic) final
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void run(o2::framework::ProcessingContext &pc) final
dataformats::Pair< float, float > getTemperature(const uint64_t timestamp) const
get temperature for given time stamp in ms
static void requestCCDBInputs(std::vector< o2::framework::InputSpec > &inputs)
void extractCCDBInputs(o2::framework::ProcessingContext &pc) const
trigger checking for CCDB objects
void sendPTForTS(o2::framework::ProcessingContext &pc, const uint64_t timestamp) const
send temperature and pressure for given time stamp
void setFitIntervalTemp(const int fitIntervalMS)
set fit interval range for temperature in ms
float getPressure(const uint64_t timestamp) const
get pressure for given time stamp in ms
bool accountCCDBInputs(const o2::framework::ConcreteDataMatcher &matcher, void *obj)
check for new CCDB objects
static void setOutputs(std::vector< o2::framework::OutputSpec > &outputs)
define outputs in case pressure and temperature will be send
constexpr double LHCOrbitMUS
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
o2::framework::DataProcessorSpec getTPCPressureTemperatureSpec()
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...