|
| 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 | +/// |
| 13 | +/// \file CalibReductorTRD.cxx |
| 14 | +/// \author Salman Malik |
| 15 | +/// |
| 16 | + |
| 17 | +#include "TRD/CalibReductorTRD.h" |
| 18 | + |
| 19 | +#include <DataFormatsTRD/CalVdriftExB.h> |
| 20 | + |
| 21 | +namespace o2::quality_control_modules::trd |
| 22 | +{ |
| 23 | + |
| 24 | +void* CalibReductorTRD::getBranchAddress() |
| 25 | +{ |
| 26 | + return &mStats; |
| 27 | +} |
| 28 | + |
| 29 | +const char* CalibReductorTRD::getBranchLeafList() |
| 30 | +{ |
| 31 | + return Form("vdrift[%i]:vdriftmean/F:vdrifterr:exbmean/F:exberr", o2::trd::constants::MAXCHAMBER); |
| 32 | +} |
| 33 | + |
| 34 | +bool CalibReductorTRD::update(ConditionRetriever& retriever) |
| 35 | +{ |
| 36 | + if (auto retvdrift = retriever.retrieve<o2::trd::CalVdriftExB>()) { |
| 37 | + double sumVdrift = 0, sumSqVdrift = 0; |
| 38 | + double sumExb = 0, sumSqExb = 0; |
| 39 | + |
| 40 | + for (int i = 0; i < o2::trd::constants::MAXCHAMBER; i++) { |
| 41 | + mStats.vdrift[i] = retvdrift->getVdrift(i); |
| 42 | + sumVdrift += retvdrift->getVdrift(i); |
| 43 | + sumSqVdrift += retvdrift->getVdrift(i) * retvdrift->getVdrift(i); |
| 44 | + sumExb += retvdrift->getExB(i); |
| 45 | + sumSqExb += retvdrift->getExB(i) * retvdrift->getExB(i); |
| 46 | + } |
| 47 | + |
| 48 | + mStats.vdriftmean = sumVdrift / o2::trd::constants::MAXCHAMBER; |
| 49 | + mStats.vdrifterr = std::sqrt(sumSqVdrift / o2::trd::constants::MAXCHAMBER - mStats.vdriftmean * mStats.vdriftmean); |
| 50 | + |
| 51 | + mStats.exbmean = sumExb / o2::trd::constants::MAXCHAMBER; |
| 52 | + mStats.exberr = std::sqrt(sumSqExb / o2::trd::constants::MAXCHAMBER - mStats.exbmean * mStats.exbmean); |
| 53 | + |
| 54 | + return true; |
| 55 | + } |
| 56 | + return false; |
| 57 | +} |
| 58 | + |
| 59 | +} // namespace o2::quality_control_modules::trd |
0 commit comments