16#include "boost/format.hpp"
17#include <boost/geometry.hpp>
32#include <fmt/format.h>
50 if (creator ==
nullptr) {
56void CathodeSegmentation::fillRtree()
60 for (
auto padGroupIndex = 0; padGroupIndex < mPadGroups.size();
62 mPadGroupIndex2CatPadIndexIndex.push_back(catPadIndex);
63 auto& pg = mPadGroups[padGroupIndex];
64 auto& pgt = mPadGroupTypes[pg.mPadGroupTypeId];
65 double dx{mPadSizes[pg.mPadSizeId].first};
66 double dy{mPadSizes[pg.mPadSizeId].second};
67 for (
int ix = 0; ix < pgt.getNofPadsX(); ++ix) {
68 for (
int iy = 0; iy < pgt.getNofPadsY(); ++iy) {
69 if (pgt.id(ix, iy) >= 0) {
71 double xmin = ix * dx + pg.mX;
72 double xmax = (ix + 1) * dx + pg.mX;
73 double ymin = iy * dy + pg.mY;
74 double ymax = (iy + 1) * dy + pg.mY;
76 mRtree.insert(std::make_pair(
81 mCatPadIndex2PadGroupIndex.push_back(padGroupIndex);
82 mCatPadIndex2PadGroupTypeFastIndex.push_back(pgt.fastIndex(ix, iy));
90std::set<int>
getUnique(
const std::vector<PadGroup>& padGroups)
94 for (
auto& pg : padGroups) {
101void dump(
const std::string &
msg,
const std::vector<int> &
v)
103 std::cout <<
msg <<
" of size " <<
v.size() <<
" : ";
106 std::cout << boost::format(
"%3d") %
value <<
",";
113 int segType,
bool isBendingPlane, std::vector<PadGroup> padGroups,
114 std::vector<PadGroupType> padGroupTypes,
115 std::vector<std::pair<float, float>> padSizes)
118 mPadGroups{
std::move(padGroups)},
120 mPadGroupTypes{
std::move(padGroupTypes)},
121 mPadSizes{
std::move(padSizes)},
122 mCatPadIndex2PadGroupIndex{},
123 mCatPadIndex2PadGroupTypeFastIndex{},
124 mPadGroupIndex2CatPadIndexIndex{},
125 mDualSampaId2CatPadIndices{}
128 for (
auto dualSampaId : mDualSampaIds) {
129 mDualSampaId2CatPadIndices.emplace(dualSampaId, catPadIndices(dualSampaId));
133std::vector<int> CathodeSegmentation::catPadIndices(
int dualSampaId)
const
137 for (
auto padGroupIndex = 0; padGroupIndex < mPadGroups.size();
139 if (mPadGroups[padGroupIndex].mFECId == dualSampaId) {
140 const auto& pgt = mPadGroupTypes[mPadGroups[padGroupIndex].mPadGroupTypeId];
141 const auto& i1 = mPadGroupIndex2CatPadIndexIndex[padGroupIndex];
142 for (
auto i = i1;
i < i1 + pgt.getNofPads(); ++
i) {
152 auto it = mDualSampaId2CatPadIndices.find(dualSampaId);
153 if (it == mDualSampaId2CatPadIndices.end()) {
163 std::vector<CathodeSegmentation::Value> result_n;
164 mRtree.query(boost::geometry::index::intersects(
166 std::back_inserter(result_n));
167 std::vector<int> catPadIndices;
168 for (
auto&
r : result_n) {
169 catPadIndices.push_back(
r.second);
171 return catPadIndices;
175 int catPadIndex)
const
179 double dx =
padSizeX(catPadIndex) / 2.0;
180 double dy =
padSizeY(catPadIndex) / 2.0;
186 pads.erase(std::remove(begin(pads),
end(pads), catPadIndex),
end(pads));
192 return catPadIndex >= 0 && catPadIndex < static_cast<int>(mCatPadIndex2PadGroupIndex.size());
195double CathodeSegmentation::squaredDistance(
int catPadIndex,
double x,
200 return px * px + py * py;
205 const double epsilon{1E-4};
209 double dmin{std::numeric_limits<double>::max()};
212 for (
auto i = 0;
i < pads.size(); ++
i) {
213 double d{squaredDistance(pads[
i],
x,
y)};
215 catPadIndex = pads[
i];
223const PadGroup& CathodeSegmentation::padGroup(
int catPadIndex)
const
225 return gsl::at(mPadGroups, mCatPadIndex2PadGroupIndex[catPadIndex]);
228const PadGroupType& CathodeSegmentation::padGroupType(
int catPadIndex)
const
230 return gsl::at(mPadGroupTypes, padGroup(catPadIndex).mPadGroupTypeId);
234 int dualSampaChannel)
const
236 auto it = mDualSampaId2CatPadIndices.find(dualSampaId);
237 if (it == mDualSampaId2CatPadIndices.end()) {
240 const auto& padIndices = it->second;
241 for (
const auto& catPadIndex : padIndices) {
242 if (padGroupType(catPadIndex)
243 .
id(mCatPadIndex2PadGroupTypeFastIndex[catPadIndex]) ==
253 auto& pg = padGroup(catPadIndex);
254 auto& pgt = padGroupType(catPadIndex);
256 (pgt.ix(mCatPadIndex2PadGroupTypeFastIndex[catPadIndex]) + 0.5) *
257 mPadSizes[pg.mPadSizeId].first;
262 auto& pg = padGroup(catPadIndex);
263 auto& pgt = padGroupType(catPadIndex);
265 (pgt.iy(mCatPadIndex2PadGroupTypeFastIndex[catPadIndex]) + 0.5) *
266 mPadSizes[pg.mPadSizeId].second;
271 return mPadSizes[padGroup(catPadIndex).
mPadSizeId].first;
276 return mPadSizes[padGroup(catPadIndex).
mPadSizeId].second;
281 return padGroup(catPadIndex).
mFECId;
286 return padGroupType(catPadIndex)
287 .
id(mCatPadIndex2PadGroupTypeFastIndex[catPadIndex]);
290std::ostream&
operator<<(std::ostream& out,
const std::pair<float, float>& p)
292 out << p.first <<
"," << p.second;
297void dump(std::ostream& out,
const std::string&
msg,
const std::vector<T>&
v,
302 for (
auto i = 0;
i <
n; ++
i) {
311 os <<
"segType " <<
seg.mSegType <<
"-" << (
seg.mIsBendingPlane ?
"B" :
"NB");
313 os << boost::format(
" %3d PG %2d PGT %2d PS\n") %
seg.mPadGroups.size() %
314 seg.mPadGroupTypes.size() %
seg.mPadSizes.size();
316 dump(os,
"PG",
seg.mPadGroups,
seg.mPadGroups.size());
317 dump(os,
"PGT",
seg.mPadGroupTypes,
seg.mPadGroupTypes.size());
318 dump(os,
"PS",
seg.mPadSizes,
seg.mPadSizes.size());
o2::mch::mapping::CathodeSegmentation seg
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
int findPadByFEE(int dualSampaId, int dualSampaChannel) const
int padDualSampaId(int catPadIndex) const
int findPadByPosition(double x, double y) const
std::vector< int > getNeighbouringCatPadIndices(int catPadIndex) const
double padPositionY(int catPadIndex) const
double padSizeX(int catPadIndex) const
static constexpr int InvalidCatPadIndex
boost::geometry::model::point< double, 2, boost::geometry::cs::cartesian > Point
bool isValid(int catPadIndex) const
std::vector< int > getCatPadIndices(int dualSampaId) const
Return the list of catPadIndices for the pads of the given dual sampa.
boost::geometry::model::box< Point > Box
CathodeSegmentation(int segType, bool isBendingPlane, std::vector< PadGroup > padGroups, std::vector< PadGroupType > padGroupTypes, std::vector< std::pair< float, float > > padSizes)
double padPositionX(int catPadIndex) const
double padSizeY(int catPadIndex) const
int padDualSampaChannel(int catPadIndex) const
GLsizei const GLfloat * value
constexpr std::array< std::string_view, BasicOp::Conditional+1 > mapping
a map between BasicOp and tokens in string expressions
CathodeSegmentationCreator getCathodeSegmentationCreator(int segType)
CathodeSegmentation * createCathodeSegmentation(int detElemId, bool isBendingPlane)
int detElemId2SegType(int detElemId)
void dump(std::ostream &out, const std::string &msg, const std::vector< T > &v, int n)
CathodeSegmentation *(*)(bool) CathodeSegmentationCreator
std::set< int > getUnique(const std::vector< PadGroup > &padGroups)
std::ostream & operator<<(std::ostream &out, const std::pair< float, float > &p)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
int id(int fastIndex) const
uint64_t const void const *restrict const msg