16#include "boost/format.hpp"
17#include <boost/geometry.hpp>
48 if (creator ==
nullptr) {
54void CathodeSegmentation::fillRtree()
58 for (
auto padGroupIndex = 0; padGroupIndex < mPadGroups.size(); ++padGroupIndex) {
59 mPadGroupIndex2CatPadIndexIndex.push_back(catPadIndex);
60 auto& pg = mPadGroups[padGroupIndex];
61 auto& pgt = mPadGroupTypes[pg.mPadGroupTypeId];
62 double dx{mPadSizes[pg.mPadSizeId].first};
63 double dy{mPadSizes[pg.mPadSizeId].second};
64 for (
int ix = 0; ix < pgt.getNofPadsX(); ++ix) {
65 for (
int iy = 0; iy < pgt.getNofPadsY(); ++iy) {
66 if (pgt.id(ix, iy) >= 0) {
68 double xmin = ix * dx + pg.mX;
69 double xmax = (ix + 1) * dx + pg.mX;
70 double ymin = iy * dy + pg.mY;
71 double ymax = (iy + 1) * dy + pg.mY;
73 mRtree.insert(std::make_pair(
76 mCatPadIndex2PadGroupIndex.push_back(padGroupIndex);
77 mCatPadIndex2PadGroupTypeFastIndex.push_back(pgt.fastIndex(ix, iy));
85std::set<int>
getUnique(
const std::vector<PadGroup>& padGroups)
89 for (
auto& pg : padGroups) {
96void dump(
const std::string &
msg,
const std::vector<int> &
v)
98 std::cout <<
msg <<
" of size " <<
v.size() <<
" : ";
101 std::cout << boost::format(
"%3d") %
value <<
",";
108 std::vector<PadGroupType> padGroupTypes, std::vector<std::pair<float, float>> padSizes)
111 mPadGroups{
std::move(padGroups)},
113 mPadGroupTypes{
std::move(padGroupTypes)},
114 mPadSizes{
std::move(padSizes)},
115 mCatPadIndex2PadGroupIndex{},
116 mCatPadIndex2PadGroupTypeFastIndex{},
117 mPadGroupIndex2CatPadIndexIndex{}
126 for (
auto padGroupIndex = 0; padGroupIndex < mPadGroups.size(); ++padGroupIndex) {
127 if (mPadGroups[padGroupIndex].mFECId == dualSampaId) {
128 auto& pgt = mPadGroupTypes[mPadGroups[padGroupIndex].mPadGroupTypeId];
129 auto i1 = mPadGroupIndex2CatPadIndexIndex[padGroupIndex];
130 for (
auto i = i1;
i < i1 + pgt.getNofPads(); ++
i) {
141 std::vector<CathodeSegmentation::Value> result_n;
143 std::back_inserter(result_n));
144 std::vector<int> catPadIndexs;
145 for (
auto&
r : result_n) {
146 catPadIndexs.push_back(
r.second);
155 double dx =
padSizeX(catPadIndex) / 2.0;
156 double dy =
padSizeY(catPadIndex) / 2.0;
161 pads.erase(std::remove(begin(pads),
end(pads), catPadIndex),
end(pads));
167 return catPadIndex >= 0 && catPadIndex < static_cast<int>(mCatPadIndex2PadGroupIndex.size());
170double CathodeSegmentation::squaredDistance(
int catPadIndex,
double x,
double y)
const
174 return px * px + py * py;
179 const double epsilon{1E-4};
182 double dmin{std::numeric_limits<double>::max()};
185 for (
auto i = 0;
i < pads.size(); ++
i) {
186 double d{squaredDistance(pads[
i],
x,
y)};
188 catPadIndex = pads[
i];
196const PadGroup& CathodeSegmentation::padGroup(
int catPadIndex)
const {
return gsl::at(mPadGroups, mCatPadIndex2PadGroupIndex[catPadIndex]); }
198const PadGroupType& CathodeSegmentation::padGroupType(
int catPadIndex)
const
200 return gsl::at(mPadGroupTypes, padGroup(catPadIndex).mPadGroupTypeId);
206 if (padGroupType(catPadIndex).
id(mCatPadIndex2PadGroupTypeFastIndex[catPadIndex]) == dualSampaChannel) {
215 auto& pg = padGroup(catPadIndex);
216 auto& pgt = padGroupType(catPadIndex);
217 return pg.mX + (pgt.ix(mCatPadIndex2PadGroupTypeFastIndex[catPadIndex]) + 0.5) * mPadSizes[pg.mPadSizeId].first;
222 auto& pg = padGroup(catPadIndex);
223 auto& pgt = padGroupType(catPadIndex);
224 return pg.mY + (pgt.iy(mCatPadIndex2PadGroupTypeFastIndex[catPadIndex]) + 0.5) * mPadSizes[pg.mPadSizeId].second;
235 return padGroupType(catPadIndex).
id(mCatPadIndex2PadGroupTypeFastIndex[catPadIndex]);
238std::ostream&
operator<<(std::ostream& out,
const std::pair<float, float>& p)
240 out << p.first <<
"," << p.second;
245void dump(std::ostream& out,
const std::string&
msg,
const std::vector<T>&
v,
int n)
249 for (
auto i = 0;
i <
n; ++
i) {
258 os <<
"segType " <<
seg.mSegType <<
"-" << (
seg.mIsBendingPlane ?
"B" :
"NB");
260 os << boost::format(
" %3d PG %2d PGT %2d PS\n") %
seg.mPadGroups.size() %
seg.mPadGroupTypes.size() %
261 seg.mPadSizes.size();
263 dump(os,
"PG",
seg.mPadGroups,
seg.mPadGroups.size());
264 dump(os,
"PGT",
seg.mPadGroupTypes,
seg.mPadGroupTypes.size());
265 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
std::vector< int > getCatPadIndexs(int dualSampaIds) const
Return the list of catPadIndexs for the pads of the given dual sampa.
double padSizeY(int catPadIndex) const
bool isValid(int catPadIndex) const
std::vector< int > getNeighbouringCatPadIndexs(int catPadIndex) const
Return the list of catPadIndexs of the pads which are neighbours to catPadIndex.
double padPositionY(int catPadIndex) const
double padPositionX(int catPadIndex) const
CathodeSegmentation(int segType, bool isBendingPlane, std::vector< PadGroup > padGroups, std::vector< PadGroupType > padGroupTypes, std::vector< std::pair< float, float > > padSizes)
boost::geometry::model::box< Point > Box
int findPadByPosition(double x, double y) const
int padDualSampaId(int catPadIndex) const
boost::geometry::model::point< double, 2, boost::geometry::cs::cartesian > Point
double padSizeX(int catPadIndex) const
static constexpr int InvalidCatPadIndex
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
CathodeSegmentation *(*)(bool) CathodeSegmentationCreator
void dump(std::ostream &out, const std::string &msg, const std::vector< T > &v, int n)
std::set< int > getUnique(const std::vector< PadGroup > &padGroups)
int detElemId2SegType(int detElemId)
CathodeSegmentation * createCathodeSegmentation(int detElemId, bool isBendingPlane)
CathodeSegmentationCreator getCathodeSegmentationCreator(int segType)
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