Project
Loading...
Searching...
No Matches
EMCALChannelData.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 CHANNEL_DATA_H_
19#define CHANNEL_DATA_H_
20
23// #include "CommonUtils/BoostHistogramUtils.h"
24// #include "EMCALCalib/BadChannelMap.h"
25// #include "EMCALCalib/TimeCalibrationParams.h"
31#include "EMCALBase/Geometry.h"
32// #include "CCDB/CcdbObjectInfo.h"
33
34// #include "Framework/Logger.h"
35// #include "CommonUtils/MemFileHelper.h"
36// #include "CCDB/CcdbApi.h"
37// #include "DetectorsCalibration/Utils.h"
38#include <boost/histogram.hpp>
39#include <boost/histogram/ostream.hpp>
40// #include <boost/format.hpp>
41
42#include <thread>
43
44// #include <array>
45
46namespace o2
47{
48namespace emcal
49{
51
53{
54 // using Slot = o2::calibration::TimeSlot<o2::emcal::EMCALChannelData>;
55 using Cells = o2::emcal::Cell;
56 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>>>;
58
59 public:
60 // NCELLS includes DCal, treat as one calibration
63
64 EMCALChannelData() : mNBins(EMCALCalibParams::Instance().nBinsEnergyAxis_bc), mRange(EMCALCalibParams::Instance().maxValueEnergyAxis_bc), mNBinsTime(EMCALCalibParams::Instance().nBinsTimeAxis_bc), mRangeTimeLow(EMCALCalibParams::Instance().rangeTimeAxisLow_bc), mRangeTimeHigh(EMCALCalibParams::Instance().rangeTimeAxisHigh_bc), mNThreads(EMCALCalibParams::Instance().nThreads_bc)
65 {
66
67 // NCELLS includes DCal, treat as one calibration
69 int NCELLS = mGeometry->GetNCells();
70
71 mVecNEntriesInHisto.resize(mNThreads);
72 mHisto.resize(mNThreads);
73 mHistoTime.resize(mNThreads);
74 for (size_t i = 0; i < mNThreads; ++i) {
75 mHisto[i] = boost::histogram::make_histogram(boost::histogram::axis::regular<>(mNBins, 0., mRange), boost::histogram::axis::regular<>(NCELLS, -0.5, NCELLS - 0.5));
76 mHistoTime[i] = boost::histogram::make_histogram(boost::histogram::axis::regular<>(mNBinsTime, mRangeTimeLow, mRangeTimeHigh), boost::histogram::axis::regular<>(NCELLS, -0.5, NCELLS - 0.5));
77 mVecNEntriesInHisto[i] = 0;
78 }
79 }
80
81 ~EMCALChannelData() = default;
82
88 void PrintStream(std::ostream& stream) const;
90 void print();
92 void fill(const gsl::span<const o2::emcal::Cell> data);
94 void merge(EMCALChannelData* prev);
95 // int findBin(float v) const;
97 bool hasEnoughData() const;
99 const boostHisto& getHisto()
100 {
101 // set the summed histogram to one of the existing histograms
102 mHistoSummed = mHisto[0];
103 // reset the histogram
104 mHistoSummed.reset();
105 // Sum up all entries
106 for (const auto& h : mHisto) {
107 mHistoSummed += h;
108 }
109 return mHistoSummed;
110 }
111
113 void setHisto(boostHisto hist, int nthr = 0) { mHisto[nthr] = hist; }
114
116 const boostHisto& getHistoTime()
117 {
118 mHistoTimeSummed = mHistoTime[0];
119 mHistoTimeSummed.reset();
120 for (const auto& h : mHistoTime) {
121 mHistoTimeSummed += h;
122 }
123 return mHistoTimeSummed;
124 }
125
127 void setHistoTime(boostHisto hist, int nthr = 0) { mHistoTime[nthr] = hist; }
128
133 void analyzeSlot();
134
135 float getRange() const { return mRange; }
136 void setRange(float r) { mRange = r; }
137
138 int getNbins() const { return mNBins; }
139 void setNbins(int nb) { mNBins = nb; }
140
141 int getNEvents() const { return mEvents; }
142 void setNEvents(int nevt) { mEvents = nevt; }
143
144 long unsigned int getNEntriesInHisto() const { return mNEntriesInHisto; }
145 void setNEntriesInHisto(long unsigned int n) { mNEntriesInHisto = n; }
146 void addEntriesInHisto(long unsigned int n) { mNEntriesInHisto += n; }
147
149 {
150 mGainCalibFactors = calibFactors;
151 for (unsigned int i = 0; i < mArrGainCalibFactors.size(); ++i) {
152 mArrGainCalibFactors[i] = mGainCalibFactors->getGainCalibFactors(i);
153 }
154 mApplyGainCalib = true;
155 }
156
157 private:
158 float mRange = 10;
159 int mNBins = 1000;
160 size_t mNThreads = 1;
161 std::vector<boostHisto> mHisto;
162 boostHisto mHistoSummed;
163 int mNBinsTime = 1000;
164 float mRangeTimeLow = -500;
165 float mRangeTimeHigh = 500;
166 std::vector<boostHisto> mHistoTime;
167 boostHisto mHistoTimeSummed;
168 int mEvents = 0;
169 long unsigned int mNEntriesInHisto = 0;
170 std::vector<long unsigned int> mVecNEntriesInHisto;
171 boostHisto mEsumHisto;
172 boostHisto mEsumHistoScaled;
173 boostHisto mCellAmplitude;
174 bool mTest = false;
175 BadChannelMap mOutputBCM;
176 bool mApplyGainCalib = false;
177 o2::emcal::GainCalibrationFactors* mGainCalibFactors;
178 std::array<double, 17664> mArrGainCalibFactors;
179 std::shared_ptr<EMCALCalibExtractor> mCalibExtractor;
180
181 ClassDefNV(EMCALChannelData, 1);
182};
186std::ostream& operator<<(std::ostream& in, const EMCALChannelData& emcdata);
187
188} // end namespace emcal
189} // end namespace o2
190
191#endif /*CHANNEL_DATA_H_ */
int32_t i
Use the EMCal Calibration.
Perform the EMCAL bad channel calibration.
Class for time synchronization of RawReader instances.
CCDB container for masked cells in EMCAL.
EMCAL compressed cell information.
Definition Cell.h:59
o2::emcal::Geometry * mGeometry
void analyzeSlot()
Peform the calibration and flag the bad channel map Average energy per hit histogram is fitted with a...
void setHistoTime(boostHisto hist, int nthr=0)
Set new calibration histogram with timing info.
void setNEntriesInHisto(long unsigned int n)
void PrintStream(std::ostream &stream) const
Print relevant info for EMCALChannelData on a given stream.
long unsigned int getNEntriesInHisto() const
void addEntriesInHisto(long unsigned int n)
void merge(EMCALChannelData *prev)
Merge the data of two slots.
void fill(const gsl::span< const o2::emcal::Cell > data)
Fill the container with the cell ID and amplitude.
const boostHisto & getHistoTime()
Get current calibration histogram with time information.
void print()
Print a useful message about the container.
void setHisto(boostHisto hist, int nthr=0)
Set new calibration histogram.
const boostHisto & getHisto()
Get current calibration histogram.
bool hasEnoughData() const
Check if enough stataistics was accumulated to perform calibration.
void setGainCalibFactors(o2::emcal::GainCalibrationFactors *calibFactors)
CCDB container for the gain calibration factors.
float getGainCalibFactors(unsigned short iCell) const
Get the gain calibration factor for a certain cell.
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
GLboolean r
Definition glcorearb.h:1233
GLuint GLuint stream
Definition glcorearb.h:1806
std::ostream & operator<<(std::ostream &stream, const Cell &cell)
Stream operator for EMCAL cell.
Definition Cell.cxx:355
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 ...