Project
Loading...
Searching...
No Matches
PHOSTurnonCalibDevice.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
15#include "CCDB/CcdbApi.h"
16#include "CCDB/CcdbObjectInfo.h"
19
20#include "TF1.h"
21#include "TH1.h"
22#include "TGraphAsymmErrors.h"
23
24#include <fairlogger/Logger.h>
25#include <fstream> // std::ifstream
26
27using namespace o2::phos;
28
30{
32 // int slotL = ic.options().get<int>("tf-per-slot");
33 // int delay = ic.options().get<int>("max-delay");
34 mCalibrator.reset(new PHOSTurnonCalibrator());
35
36 // mCalibrator->setSlotLength(slotL);
37 // mCalibrator->setMaxSlotsDelay(delay);
38 mCalibrator->setUpdateAtTheEndOfRunOnly();
39}
41{
42 auto crTime = pc.services().get<o2::framework::TimingInfo>().creation;
43 if (mRunStartTime == 0 || crTime < mRunStartTime) {
44 mRunStartTime = crTime;
45 }
47 auto tfcounter = o2::header::get<o2::framework::DataProcessingHeader*>(pc.inputs().get("clusters").header)->startTime; // is this the timestamp of the current TF?
48 auto cells = pc.inputs().get<gsl::span<Cell>>("cells");
49 auto cellTR = pc.inputs().get<gsl::span<TriggerRecord>>("cellTriggerRecords");
50 auto clusters = pc.inputs().get<gsl::span<Cluster>>("clusters");
51 auto cluTR = pc.inputs().get<gsl::span<TriggerRecord>>("clusterTriggerRecords");
52
53 LOG(detail) << "[PHOSTurnonCalibDevice - run] Received " << cells.size() << " cells and " << clusters.size() << " clusters, running calibration";
54
55 mCalibrator->process(tfcounter, cells, cellTR, clusters, cluTR);
56}
57
59{
60 mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF);
61 mCalibrator->endOfStream();
62 mTriggerMap.reset(new TriggerMap(mCalibrator->getCalibration()));
63 if (checkFitResult()) {
64 // Calculate and send final object to CCDB
65 auto flName = o2::ccdb::CcdbApi::generateFileName("TriggerMap");
66 std::map<std::string, std::string> md;
67 o2::ccdb::CcdbObjectInfo info("PHS/Calib/TriggerMap", "TriggerMap", flName, md,
69 info.setMetaData(md);
70 auto image = o2::ccdb::CcdbApi::createObjectImage(mTriggerMap.get(), &info);
71
72 LOG(info) << "Sending object " << info.getPath() << "/" << info.getFileName()
73 << " of size " << image->size()
74 << " bytes, valid for " << info.getStartValidityTimestamp()
75 << " : " << info.getEndValidityTimestamp();
76
79 } else {
80 LOG(alarm) << "Incorrect fit results";
81 }
82 // //Send result to QC
83 // ec.outputs().snapshot(o2::framework::Output{"PHS", "TRIGMAPDIFF", 0}, mTrigMapDiff);
84 // ec.outputs().snapshot(o2::framework::Output{"PHS", "TURNONDIFF", 0}, mTurnOnDiff);
85}
86
88{
89
90 std::vector<InputSpec> inputs;
91 inputs.emplace_back("cells", o2::header::gDataOriginPHS, "CELLS", 0, o2::framework::Lifetime::Timeframe);
92 inputs.emplace_back("cellTriggerRecords", o2::header::gDataOriginPHS, "CELLTRIGREC", 0, o2::framework::Lifetime::Timeframe);
93 inputs.emplace_back("clusters", o2::header::gDataOriginPHS, "CLUSTERS", 0, o2::framework::Lifetime::Timeframe);
94 inputs.emplace_back("clusterTriggerRecords", o2::header::gDataOriginPHS, "CLUSTERTRIGREC", 0, o2::framework::Lifetime::Timeframe);
95 auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(true, // orbitResetTime
96 true, // GRPECS=true
97 false, // GRPLHCIF
98 false, // GRPMagField
99 false, // askMatLUT
101 inputs);
103 std::vector<OutputSpec> outputs;
104 outputs.emplace_back(clbUtils::gDataOriginCDBPayload, "PHOS_Turnon", 0, Lifetime::Sporadic);
105 outputs.emplace_back(clbUtils::gDataOriginCDBWrapper, "PHOS_Turnon", 0, Lifetime::Sporadic);
106 // stream for QC data
107 // outputs.emplace_back("PHS", "TRIGGERQC", 0, o2::framework::Lifetime::Timeframe);
108
109 return o2::framework::DataProcessorSpec{"PHOSTurnonCalibDevice",
110 inputs,
111 outputs,
112 o2::framework::adaptFromTask<PHOSTurnonCalibDevice>(useCCDB, ccdbRequest),
114}
Utils and constants for calibration and related workflows.
Device to calculate PHOS turn-on curves and trigger map.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static std::string generateFileName(const std::string &inp)
Definition CcdbApi.cxx:798
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
Definition CcdbApi.h:103
long getEndValidityTimestamp() const
const std::string & getPath() const
void setMetaData(const std::map< std::string, std::string > &md)
long getStartValidityTimestamp() const
const std::string & getFileName() const
static constexpr long YEAR
static constexpr long MINUTE
void snapshot(const Output &spec, T const &object)
decltype(auto) get(R binding, int part=0) const
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
void init(o2::framework::InitContext &ic) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void run(o2::framework::ProcessingContext &pc) final
GLeglImageOES image
Definition glcorearb.h:4021
constexpr o2::header::DataOrigin gDataOriginPHS
Definition DataHeader.h:574
constexpr TFType INFINITE_TF
Definition TimeSlot.h:30
std::vector< ConfigParamSpec > Options
o2::framework::DataProcessorSpec getPHOSTurnonCalibDeviceSpec(bool useCCDB)
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
Definition Utils.h:44
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
Definition Utils.h:43
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Cluster > clusters
std::vector< Cell > cells