17 using namespace SurfaceOrientation;
19 using namespace magneticfield;
26 : volumes(begin, end), msector(nullptr),
debug(debugVal) {
28 cout <<
" Sector at Phi " <<
volumes.front()->center().phi() <<
" " <<
volumes.back()->center().phi() << endl;
32 cout <<
" Rod at: 0 elements: " << end - begin <<
" unique volumes: ";
53 float phiTmp =
static_cast<float>(
volumes.back()->maxPhi()) - static_cast<float>(phi0) +
resolution;
58 cout <<
", phi0 = " << phi0 <<
", volumes.back()->maxPhi() = " <<
volumes.back()->maxPhi();
59 cout <<
", phiMin = " << phiMin << endl <<
"phiMax = " <<
phiMax;
60 cout <<
", int((phiMax - phiMin) / resolution) + 1 = " << int((phiMax - phiMin) / resolution) + 1 << endl;
67 for (handles::const_iterator
i = first;
i !=
last; ++
i) {
68 hisPhi.
fill((*i)->maxPhi() - phi0);
70 vector<float> phiClust = hisPhi.
clusterize(resolution);
73 cout <<
" Found " << phiClust.size() <<
" clusters in Phi, "
76 handles::const_iterator rodStart =
first;
77 handles::const_iterator separ =
first;
79 float DZ = (*max_element(first, last,
LessZ()))->
maxZ() - (*min_element(first, last,
LessZ()))->minZ();
82 for (
unsigned int i = 0;
i < phiClust.size(); ++
i) {
84 if (
i < phiClust.size() - 1) {
85 phiSepar = (phiClust[
i] + phiClust[
i + 1]) / 2.
f;
90 cout <<
" cluster " <<
i <<
" phisepar " << phiSepar << endl;
91 while (separ < last && (*separ)->maxPhi() - phi0 < phiSepar) {
92 DZ1 += ((*separ)->maxZ() - (*separ)->minZ());
94 cout <<
" " << (*separ)->name <<
" " << (*separ)->maxPhi() - phi0 <<
" " << (*separ)->maxZ() <<
" "
95 << (*separ)->minZ() <<
" " << DZ1 << endl;
101 if (fabs(DZ - DZ1) > 0.001 && fabs(DZ - DZ1) < 0.5) {
103 cout <<
"*** WARNING: Z lenght mismatch by " << DZ - DZ1 <<
" " << DZ <<
" " << DZ1 << endl;
105 if (fabs(DZ - DZ1) > 0.25) {
107 cout <<
" Incomplete, use also next cluster: " << DZ <<
" " << DZ1 <<
" " << DZ - DZ1 << endl;
110 }
else if (DZ1 > DZ + 0.05) {
111 cout <<
" *** ERROR: bSector finding messed up." << endl;
116 cout <<
" Rod at: " << phiClust[
i] <<
" elements: " << separ - rodStart <<
" unique volumes: ";
127 cout <<
" *** ERROR: bSector has no rods " << DZ <<
" " << DZ1 << endl;
129 cout <<
"-----------------------" << endl;
135 vector<MagBRod*> mRods;
136 for (vector<bRod>::const_iterator rod =
rods.begin(); rod !=
rods.end(); ++rod) {
137 mRods.push_back((*rod).buildMagBRod());
void printUniqueNames(handles::const_iterator begin, handles::const_iterator end, bool uniq=true)
Just for debugging...
std::vector< float > clusterize(float resolution)
MagBSector * buildMagBSector() const
Construct the MagBSector upon request.
bSector()
Default ctor is needed to have arrays.
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
constexpr valType make0To2pi(valType angle)