Project
Loading...
Searching...
No Matches
ElmbMeasurement.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 <iostream>
13
14#include "TMath.h"
16
17using namespace o2::emcal;
18
20{
21 values.resize(NElmbSensors);
22 values_prev.resize(NElmbSensors, -1);
23 mELMBdata.resize(NElmbSensors);
24}
25
27{
28
29 for (int iPT = 0; iPT < NElmbSensors; iPT++) {
30 values[iPT].clear();
31 }
32 mELMBdata.clear();
33
34 mELMBdata.resize(NElmbSensors); // check why the capacity is 0 after clear()!!!
35}
36
38{
39 int Npoints = 0;
40 float val_last = 0;
41 double mean = 0;
42 double mean2 = 0;
43 double rms = 0.;
44 double max = 0;
45 double min = 1000;
46
47 for (int iPT = 0; iPT < NElmbSensors; iPT++) {
48 Npoints = 0;
49 mean = 0;
50 mean2 = 0;
51 max = 0;
52 min = 1000;
53 rms = 0;
54 val_last = values_prev[iPT];
55
56 // std::cout<< iPT << " : ";
57 for (auto vPT : values[iPT]) {
58 // std::cout << vPT << ", ";
59 Npoints++;
60 mean += vPT;
61 mean2 += vPT * vPT;
62 if (max < vPT) {
63 max = vPT;
64 }
65 if (min > vPT) {
66 min = vPT;
67 }
68 val_last = (float)vPT;
69 }
70 // std::cout << std::endl;
71
72 if (Npoints == 0) {
73 mean = (double)values_prev[iPT];
74 } else if (Npoints > 1) {
75 mean2 /= Npoints;
76 mean /= Npoints;
77 rms = mean2 - mean * mean;
78 rms /= (Npoints - 1);
79 rms = TMath::Sqrt(rms);
80 }
81
82 values_prev[iPT] = val_last;
83 mELMBdata[iPT] = std::make_tuple(Npoints, (float)mean, (float)rms, (float)min, (float)max);
84 }
85}
GLenum GLsizei GLsizei GLint * values
Definition glcorearb.h:1576
const int NElmbSensors
Definition ElmbData.h:24
constexpr size_t min
constexpr size_t max