Project
Loading...
Searching...
No Matches
IDCGroupingParameter.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
13#include "Framework/Logger.h"
15#include <boost/property_tree/ptree.hpp>
16#include <cassert>
17#include <stdexcept>
18
19using namespace o2::tpc;
22
23void o2::tpc::ParameterIDCGroup::setGroupingParameterFromString(const std::string sgroupPads, const std::string sgroupRows, const std::string sgroupLastRowsThreshold, const std::string sgroupLastPadsThreshold)
24{
25 auto vgroupPads = o2::RangeTokenizer::tokenize<int>(sgroupPads);
26 auto vgroupRows = o2::RangeTokenizer::tokenize<int>(sgroupRows);
27 auto vgroupLastRowsThreshold = o2::RangeTokenizer::tokenize<int>(sgroupLastRowsThreshold);
28 auto vgroupLastPadsThreshold = o2::RangeTokenizer::tokenize<int>(sgroupLastPadsThreshold);
29
30 if (vgroupPads.size() == 1) {
31 vgroupPads = std::vector<int>(Mapper::NREGIONS, vgroupPads.front());
32 } else if (vgroupPads.size() != Mapper::NREGIONS) {
33 LOGP(error, "wrong number of parameters inserted for groupPads (n={}). Number should be 1 or {}", vgroupPads.size(), Mapper::NREGIONS);
34 }
35
36 if (vgroupRows.size() == 1) {
37 vgroupRows = std::vector<int>(Mapper::NREGIONS, vgroupRows.front());
38 } else if (vgroupRows.size() != Mapper::NREGIONS) {
39 LOGP(error, "wrong number of parameters inserted for groupRows (n={}). Number should be 1 or {}", vgroupRows.size(), Mapper::NREGIONS);
40 }
41
42 if (vgroupLastRowsThreshold.size() == 1) {
43 vgroupLastRowsThreshold = std::vector<int>(Mapper::NREGIONS, vgroupLastRowsThreshold.front());
44 } else if (vgroupLastRowsThreshold.size() != Mapper::NREGIONS) {
45 LOGP(error, "wrong number of parameters inserted for groupLastRowsThreshold (n={}). Number should be 1 or {}", vgroupLastRowsThreshold.size(), Mapper::NREGIONS);
46 }
47
48 if (vgroupLastPadsThreshold.size() == 1) {
49 vgroupLastPadsThreshold = std::vector<int>(Mapper::NREGIONS, vgroupLastPadsThreshold.front());
50 } else if (vgroupLastPadsThreshold.size() != Mapper::NREGIONS) {
51 LOGP(error, "wrong number of parameters inserted for groupLastPadsThreshold (n={}). Number should be 1 or {}", vgroupLastPadsThreshold.size(), Mapper::NREGIONS);
52 }
53
54 for (int i = 0; i < Mapper::NREGIONS; ++i) {
55 o2::conf::ConfigurableParam::setValue<unsigned char>("TPCIDCGroupParam", fmt::format("groupPads[{}]", i).data(), vgroupPads[i]);
56 o2::conf::ConfigurableParam::setValue<unsigned char>("TPCIDCGroupParam", fmt::format("groupRows[{}]", i).data(), vgroupRows[i]);
57 o2::conf::ConfigurableParam::setValue<unsigned char>("TPCIDCGroupParam", fmt::format("groupLastRowsThreshold[{}]", i).data(), vgroupLastRowsThreshold[i]);
58 o2::conf::ConfigurableParam::setValue<unsigned char>("TPCIDCGroupParam", fmt::format("groupLastPadsThreshold[{}]", i).data(), vgroupLastPadsThreshold[i]);
59 }
60}
61
62unsigned int o2::tpc::ParameterIDCGroup::getTotalGroupPadsSectorEdgesHelper(unsigned int groupPadsSectorEdges)
63{
64 if (groupPadsSectorEdges == 0) {
65 return 0;
66 }
67 return (groupPadsSectorEdges % 10) + getTotalGroupPadsSectorEdgesHelper(groupPadsSectorEdges / 10);
68}
69
70unsigned int o2::tpc::ParameterIDCGroup::getGroupedPadsSectorEdgesHelper(unsigned int groupPadsSectorEdges)
71{
72 if (groupPadsSectorEdges == 0) {
73 return 0;
74 }
75 return 1 + getGroupedPadsSectorEdgesHelper(groupPadsSectorEdges / 10);
76}
77
79{
80 const auto groupPadsSectorEdgesTmp = groupPadsSectorEdges % 10;
81 switch (groupPadsSectorEdgesTmp) {
82 case static_cast<unsigned int>(EdgePadGroupingMethod::NO):
83 case static_cast<unsigned int>(EdgePadGroupingMethod::ROWS):
84 return static_cast<EdgePadGroupingMethod>(groupPadsSectorEdgesTmp);
85 default:
86 throw std::invalid_argument("Wrong type for EdgePadGroupingMethod can either be NO or ROWS");
87 }
88}
89
90unsigned int o2::tpc::ParameterIDCGroup::getPadsInGroupSectorEdgesHelper(unsigned int groupPadsSectorEdges, const unsigned int group)
91{
92 return groupPadsSectorEdges / static_cast<int>(std::pow(10, group)) % 10;
93}
#define O2ParamImpl(classname)
int32_t i
Definition of the parameter for the grouping of the IDCs.
Helper function to tokenize sequences and ranges of integral numbers.
static constexpr unsigned int NREGIONS
total number of regions in one sector
Definition Mapper.h:527
GLboolean * data
Definition glcorearb.h:298
GLboolean GLuint group
Definition glcorearb.h:3991
Global TPC definitions and constants.
Definition SimTraits.h:167
@ NO
no grouping in row direction
@ ROWS
grouping in row direction
struct for setting the parameters for the grouping of IDCs
static void setGroupingParameterFromString(const std::string sgroupPads, const std::string sgroupRows, const std::string sgroupLastRowsThreshold, const std::string sgroupLastPadsThreshold)
static EdgePadGroupingMethod getEdgePadGroupingType(unsigned int groupPadsSectorEdges)