Project
Loading...
Searching...
No Matches
WaveformCalibParam.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
12#include <TH1.h>
13#include <TFile.h>
14#include <TDirectory.h>
15#include "Framework/Logger.h"
17
18using namespace o2::zdc;
19
21{
22 if (shape.size() > 0) {
23 printf("Shape min at bin %d/%lu\n", ampMinID, shape.size());
24 } else {
25 printf("No data\n");
26 }
27}
28
30{
31 for (int i = 0; i < NChannels; i++) {
32 printf("%s ", channelName(i));
33 channels[i].print();
34 }
35}
36
38{
39 for (int isig = 0; isig < NChannels; isig++) {
40 float entries = data.getEntries(isig);
41 int peak = data.mPeak;
42 if (entries > 0) {
43 int ifirst = data.getFirstValid(isig);
44 int ilast = data.getLastValid(isig);
45 channels[isig].ampMinID = peak - ifirst;
46 for (int ip = ifirst; ip <= ilast; ip++) {
47 channels[isig].shape.push_back(data.mWave[isig].mData[ip] / entries);
48 }
49 }
50 }
51}
52
53//______________________________________________________________________________
54int WaveformCalibParam::saveDebugHistos(const std::string fn) const
55{
56 TDirectory* cwd = gDirectory;
57 TFile* f = new TFile(fn.data(), "recreate");
58 if (f->IsZombie()) {
59 LOG(error) << "Cannot create file: " << fn;
60 return 1;
61 }
62 for (int32_t is = 0; is < NChannels; is++) {
63 auto& channel = channels[is];
64 auto& shape = channel.shape;
65 int nbx = shape.size();
66 int iamin = channel.ampMinID;
67 if (nbx > 0) {
68 TString n = TString::Format("h%d", is);
69 TString t = TString::Format("Waveform %d %s", is, ChannelNames[is].data());
70 TH1F h(n, t, nbx, -0.5 - iamin, nbx - iamin - 0.5);
71 for (int ibx = 0; ibx < nbx; ibx++) {
72 h.SetBinContent(ibx + 1, shape[ibx]);
73 }
74 h.SetEntries(1);
75 h.Write("", TObject::kOverwrite);
76 }
77 }
78 f->Close();
79 cwd->cd();
80 return 0;
81}
int32_t i
Waveform calibration data.
Class for time synchronization of RawReader instances.
GLdouble n
Definition glcorearb.h:1982
GLdouble f
Definition glcorearb.h:310
GLboolean * data
Definition glcorearb.h:298
constexpr int NChannels
Definition Constants.h:65
constexpr const char * channelName(int channel)
Definition Constants.h:318
constexpr std::string_view ChannelNames[]
Definition Constants.h:147
WaveformCalibChParam channels[NChannels]
void assign(const WaveformCalibData &data)
int saveDebugHistos(const std::string fn) const
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"