17#include <TDirectory.h>
19#include <TPaveStats.h>
32 if (mInterCalibConfig ==
nullptr) {
33 LOG(fatal) <<
"o2::zdc::InterCalibEPN: missing configuration object";
40 if (opt.debugOutput ==
true) {
45 auto* cfg = mInterCalibConfig;
48 for(
int ih=0; ih<
NH; ih++){
65 const gsl::span<const o2::zdc::ZDCEnergy>& Energy,
66 const gsl::span<const o2::zdc::ZDCTDCData>& TDCData,
67 const gsl::span<const uint16_t>& Info)
76 ev.
init(RecBC, Energy, TDCData, Info);
80 for (uint16_t info : decodedInfo) {
81 uint8_t ch = (info >> 10) & 0x1f;
82 uint16_t code = info & 0x03ff;
132 if (
x < -(mInterCalibConfig->
xcut_ZPA)) {
166 for (
int ih = 0; ih <
NH; ih++) {
170 if (mSaveDebugHistos) {
182 THnSparse* hs = (THnSparse*)gROOT->FindObject(hname);
184 LOGF(error,
"Not found: %s\n", hname);
187 if (!hs->InheritsFrom(THnSparse::Class())) {
188 LOGF(error,
"Not a THnSparse: %s\n", hname);
194 if (hn.EqualTo(
"hZNA")) {
196 }
else if (hn.EqualTo(
"hZPA")) {
198 }
else if (hn.EqualTo(
"hZNC")) {
200 }
else if (hn.EqualTo(
"hZPC")) {
202 }
else if (hn.EqualTo(
"hZEM")) {
204 }
else if (hn.EqualTo(
"hZNI")) {
206 }
else if (hn.EqualTo(
"hZPI")) {
208 }
else if (hn.EqualTo(
"hZPAX")) {
210 }
else if (hn.EqualTo(
"hZPCX")) {
213 LOGF(error,
"Not recognized histogram name: %s\n", hname);
217 const int32_t dim = 6;
220 int64_t nb = hs->GetNbins();
222 LOGF(info,
"Histogram %s has %ld bins\n", hname, nb);
223 double cutl = mInterCalibConfig->
cutLow[ih];
224 double cuth = mInterCalibConfig->
cutHigh[ih];
226 for (int64_t
i = 0;
i < nb;
i++) {
227 double cont = hs->GetBinContent(
i,
bins);
231 for (int32_t d = 0; d < dim; ++d) {
232 x[d] = hs->GetAxis(d)->GetBinCenter(
bins[d]);
234 if (TMath::Nint(
x[5] - ic) == 0 &&
x[0] > cutl &&
x[0] < cuth) {
240 LOGF(info,
"Trigger class selection %d and %d bins %g events and cuts (%g:%g): %ld", ic, nn, contt, cutl, cuth);
248 if (ih >= 0 && ih <
NH) {
252 for (int32_t ii = ihstart; ii < ihstop; ii++) {
253 for (int32_t
i = 0;
i <
NPAR;
i++) {
254 for (int32_t
j = 0;
j <
NPAR;
j++) {
269 constexpr double minfty = -std::numeric_limits<double>::infinity();
271 if (tc < mInterCalibConfig->cutLow[ih] || tc > mInterCalibConfig->
cutHigh[ih]) {
275 if (t1 < mInterCalibConfig->towerCutLow_ZPA[0] || t2 < mInterCalibConfig->towerCutLow_ZPA[1] || t3 < mInterCalibConfig->towerCutLow_ZPA[2] || t4 < mInterCalibConfig->towerCutLow_ZPA[3]) {
283 if (t1 < mInterCalibConfig->towerCutLow_ZPC[0] || t2 < mInterCalibConfig->towerCutLow_ZPC[1] || t3 < mInterCalibConfig->towerCutLow_ZPC[2] || t4 < mInterCalibConfig->towerCutLow_ZPC[3]) {
290 double val[
NPAR] = {tc,
t1, t2, t3, t4, 1};
291 if (tc > minfty &&
t1 > minfty && t2 > minfty && t3 > minfty && t4 > minfty) {
292 for (int32_t
i = 0;
i <
NPAR;
i++) {
293 for (int32_t
j =
i;
j <
NPAR;
j++) {
301 if (
mH[ih] !=
nullptr) {
302 mH[ih]->fill(sumquad,
w);
304 if (
mH[ih +
NH] !=
nullptr) {
307 mC[ih]->fill(
val[0], sumquad,
w);
313 TDirectory* cwd = gDirectory;
314 TFile*
f =
new TFile(fn.data(),
"recreate");
316 LOG(error) <<
"Cannot create file: " << fn;
319 for (int32_t ih = 0; ih < (2 *
NH); ih++) {
323 p->Write(
"", TObject::kOverwrite);
326 for (int32_t ih = 0; ih <
NH; ih++) {
330 p->Write(
"", TObject::kOverwrite);
ZDC calibration common parameters.
Intercalibration intermediate data.
static const CalibParamZDC & Instance()
static constexpr int HidZPC
static constexpr int HidZPI
static constexpr int HidZNA
std::array< o2::dataformats::FlatHisto2D< float > *, NH > mC
int saveDebugHistos(const std::string fn="ZDCInterCalibEPN.root")
static constexpr int HidZNI
static constexpr int HidZEM
int process(const gsl::span< const o2::zdc::BCRecData > &bcrec, const gsl::span< const o2::zdc::ZDCEnergy > &energy, const gsl::span< const o2::zdc::ZDCTDCData > &tdc, const gsl::span< const uint16_t > &info)
static constexpr int HidZPAX
void setSaveDebugHistos()
static constexpr int HidZPCX
static constexpr int NPAR
static constexpr int HidZPA
static constexpr int HidZNC
void cumulate(int ih, double tc, double t1, double t2, double t3, double t4, double w)
std::array< o2::dataformats::FlatHisto1D< float > *, 2 *NH > mH
static constexpr const char * mHUncT[2 *NH]
static constexpr const char * mHUncN[2 *NH]
static constexpr const char * mCUncT[NH]
static constexpr const char * mCUncN[NH]
GLubyte GLubyte GLubyte GLubyte w
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
constexpr uint32_t MaskZNA
constexpr uint32_t MaskAllZNA
constexpr uint32_t MaskZNC
constexpr uint32_t MaskAllZPA
constexpr uint32_t MaskZEM
constexpr uint32_t MaskZPA
constexpr uint32_t MaskAllZPC
constexpr uint32_t MaskAllZNC
constexpr uint32_t MaskZPC
uint16_t bc
bunch crossing ID of interaction
double towerCutHigh_ZPA[4]
double towerCutHigh_ZPC[4]
double mSum[NH][NPAR][NPAR]
ZNA, ZPA, ZNC, ZPC, ZEM, ZNI, ZPI, ZPAX, ZPCX.
uint64_t mCTimeEnd
Time of processed time frame.
static constexpr const char * DN[NH]
Time of processed time frame.
uint64_t mCTimeBeg
Cumulated sums.
void centroidZPA(float &x, float &rms)
std::vector< float > TDCVal[NTDCChannels]
signal in ZDCs
BCRecData mCurB
End of sequence.
float EZDC(uint8_t ich) const
uint32_t ezdcDecoded
pattern of channels acquired
void init(const std::vector< o2::zdc::BCRecData > *RecBC, const std::vector< o2::zdc::ZDCEnergy > *Energy, const std::vector< o2::zdc::ZDCTDCData > *TDCData, const std::vector< uint16_t > *Info)
Trigger mask for printout.
const std::vector< uint16_t > & getDecodedInfo()
void centroidZPC(float &x, float &rms)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"