Project
Loading...
Searching...
No Matches
EMCALTimeCalibData.h
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
17
18#ifndef EMCAL_TIME_DATA_H_
19#define EMCAL_TIME_DATA_H_
20
24#include "EMCALBase/Geometry.h"
25#include "CCDB/CcdbObjectInfo.h"
29
30#include "Framework/Logger.h"
32#include "CCDB/CcdbApi.h"
34#include <boost/histogram.hpp>
35#include <boost/histogram/ostream.hpp>
36#include <boost/format.hpp>
37
38#include <array>
39#include <boost/histogram.hpp>
40namespace o2
41{
42namespace emcal
43{
44
46{
47 public:
49 using boostHisto = boost::histogram::histogram<std::tuple<boost::histogram::axis::regular<double, boost::use_default, boost::use_default, boost::use_default>, boost::histogram::axis::regular<double, boost::use_default, boost::use_default, boost::use_default>>>;
50
53
55 {
56
57 mNThreads = EMCALCalibParams::Instance().nThreads_tc;
58 mTimeHisto.resize(mNThreads);
59 mVecNEntriesInHisto.resize(mNThreads);
60 for (size_t i = 0; i < mNThreads; ++i) {
61 mTimeHisto[i] = boost::histogram::make_histogram(boost::histogram::axis::regular<>(EMCALCalibParams::Instance().nBinsTimeAxis_tc, EMCALCalibParams::Instance().minValueTimeAxis_tc, EMCALCalibParams::Instance().maxValueTimeAxis_tc), boost::histogram::axis::regular<>(NCELLS, -0.5, NCELLS - 0.5));
62 mVecNEntriesInHisto[i] = 0;
63 }
64 LOG(debug) << "initialize time histogram with " << NCELLS << " cells";
65 }
66
68
70 void fill(const gsl::span<const o2::emcal::Cell> data);
71
73 void merge(EMCALTimeCalibData* prev);
74
76 bool hasEnoughData() const;
77
79 void print();
80
82 void setNEvents(int nevt) { mEvents = nevt; }
84 void AddEvents(int nevt) { mEvents += nevt; }
86 int getNEvents() const { return mEvents; }
87
89 long unsigned int getNEntriesInHisto() const { return mNEntriesInHisto; }
91 void setNEntriesInHisto(long unsigned int n) { mNEntriesInHisto = n; }
93 void addNEntriesInHisto(long unsigned int n) { mNEntriesInHisto += n; }
94
97 {
98 // set the summed histogram to one of the existing histograms
99 mHistoSummed = mTimeHisto[0];
100 // reset the histogram
101 mHistoSummed.reset();
102 // Sum up all entries
103 for (const auto& h : mTimeHisto) {
104 mHistoSummed += h;
105 }
106 return mHistoSummed;
107 }
108
112 {
113 mGainCalibFactors = calibFactors;
114 mApplyGainCalib = true;
115 }
116
118 void setHisto(boostHisto hist) { mTimeHisto[0] = hist; }
119
121 void PrintStream(std::ostream& stream) const;
122
125
126 private:
127 unsigned int mNThreads = 1;
128 std::vector<boostHisto> mTimeHisto;
129 boostHisto mHistoSummed;
130 int mEvents = 0;
131 long unsigned int mNEntriesInHisto = 0;
132 std::vector<long unsigned int> mVecNEntriesInHisto;
133 bool mApplyGainCalib = false;
134 o2::emcal::GainCalibrationFactors* mGainCalibFactors;
135
136 ClassDefNV(EMCALTimeCalibData, 1);
137};
138
139} // end namespace emcal
140} // end namespace o2
141
142#endif /*EMCAL_TIME_DATA_H_ */
Utils and constants for calibration and related workflows.
int32_t i
std::ostringstream debug
Class for time synchronization of RawReader instances.
EMCAL compressed cell information.
Definition Cell.h:59
void setNEntriesInHisto(long unsigned int n)
Set the number of entries in histogram.
void setHisto(boostHisto hist)
Set new calibration histogram.
long unsigned int getNEntriesInHisto() const
Get the number of entries in histogram.
void print()
Print a useful message about the container.
void PrintStream(std::ostream &stream) const
print stream
void addNEntriesInHisto(long unsigned int n)
Add the number of entries in histogram.
int getNEvents() const
Get number of events currently available for calibration.
boost::histogram::histogram< std::tuple< boost::histogram::axis::regular< double, boost::use_default, boost::use_default, boost::use_default >, boost::histogram::axis::regular< double, boost::use_default, boost::use_default, boost::use_default > > > boostHisto
void setNEvents(int nevt)
Set number of events available for calibration.
void setGainCalibFactors(o2::emcal::GainCalibrationFactors *calibFactors)
Set gain calibration factors applied to the cell energy before filling the histograms.
o2::emcal::Geometry * mGeometry
void fill(const gsl::span< const o2::emcal::Cell > data)
Fill the container with the cell ID and amplitude and time information.
void merge(EMCALTimeCalibData *prev)
Merge the data of two slots.
void AddEvents(int nevt)
Add number of events available for calibration.
const boostHisto & getHisto()
Get current histogram.
bool hasEnoughData() const
Check if enough data for calibration has been accumulated.
o2::emcal::TimeCalibrationParams process()
Actual function where calibration is done. Has to be called in has enough data when enough data is th...
CCDB container for the gain calibration factors.
EMCAL geometry definition.
Definition Geometry.h:40
static Geometry * GetInstanceFromRunNumber(Int_t runNumber, const std::string_view="", const std::string_view mcname="TGeant3", const std::string_view mctitle="")
Instanciate geometry depending on the run number. Mostly used in analysis and MC anchors.
Definition Geometry.cxx:219
Int_t GetNCells() const
Definition Geometry.h:220
GLdouble n
Definition glcorearb.h:1982
GLboolean * data
Definition glcorearb.h:298
GLuint GLuint stream
Definition glcorearb.h:1806
boost::histogram::histogram< std::tuple< boost::histogram::axis::regular< double, boost::use_default, boost::use_default, boost::use_default >, boost::histogram::axis::integer<> >, boost::histogram::unlimited_storage< std::allocator< char > > > boostHisto
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"