|
| 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 SeparationPowerReductor.cxx |
| 14 | +// \author Marcel Lesch |
| 15 | +// |
| 16 | +#include "TPC/SeparationPowerReductor.h" |
| 17 | +#include "QualityControl/QcInfoLogger.h" |
| 18 | +#include <boost/algorithm/string.hpp> |
| 19 | +#include <string> |
| 20 | +#include <TCanvas.h> |
| 21 | +#include <TPaveText.h> |
| 22 | + |
| 23 | +namespace o2::quality_control_modules::tpc |
| 24 | +{ |
| 25 | + |
| 26 | +void* SeparationPowerReductor::getBranchAddress() |
| 27 | +{ |
| 28 | + return &mSeparationPower; |
| 29 | +} |
| 30 | + |
| 31 | +const char* SeparationPowerReductor::getBranchLeafList() |
| 32 | +{ |
| 33 | + return "meanPi/F:meanEl:separationPower"; |
| 34 | +} |
| 35 | + |
| 36 | +void SeparationPowerReductor::update(TObject* obj) |
| 37 | +{ |
| 38 | + // The values for the separation power are saved in a TPaveText inside a TCanvas 'obj'. |
| 39 | + if (obj) { |
| 40 | + if (auto canvas = static_cast<TCanvas*>(obj)) { |
| 41 | + if (auto blocText = static_cast<TPaveText*>(canvas->GetPrimitive("TPave"))) { |
| 42 | + mSeparationPower.meanPi = getValue((TText*)blocText->GetLineWith("Mean Pi:")); |
| 43 | + mSeparationPower.meanEl = getValue((TText*)blocText->GetLineWith("Mean El:")); |
| 44 | + mSeparationPower.separationPower = getValue((TText*)blocText->GetLineWith("separationPower:")); |
| 45 | + } |
| 46 | + } |
| 47 | + } else { |
| 48 | + ILOG(Error, Support) << "No 'obj' found." << ENDM; |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +float SeparationPowerReductor::getValue(TText* line) |
| 53 | +{ |
| 54 | + if (!line) { |
| 55 | + return 0.; |
| 56 | + } |
| 57 | + |
| 58 | + std::string text = static_cast<std::string>(line->GetTitle()); |
| 59 | + const std::size_t posEndType = text.find(":"); |
| 60 | + std::string quantity = text.substr(posEndType + 2, -1); // take string (excluding : and empty space) till end of line |
| 61 | + |
| 62 | + return stof(quantity); |
| 63 | +} |
| 64 | + |
| 65 | +} // namespace o2::quality_control_modules::tpc |
0 commit comments