50 #include <boost/algorithm/string/replace.hpp> 59 cout <<
"Constructing a MagGeoBuilderFromDDD" << endl;
75 int isurfaces = ivolumes * 6;
81 set<const void*> ptrs;
86 for (handles::const_iterator
i =
first;
i !=
last; ++
i) {
87 if (
int((*i)->shape()) > 4)
89 for (
int side = 0; side < 6; ++side) {
90 int references = (*i)->references(side);
91 if ((*i)->isPlaneMatched(side)) {
93 bool firstOcc = (ptrs.insert(&((*i)->surface(side)))).
second;
95 iref_ass += references;
97 cout <<
"*** Only 1 ref, vol: " << (*i)->volumeno <<
" # " << (*i)->copyno <<
" side: " << side << endl;
100 iref_nass += references;
101 if (references > 1) {
102 cout <<
"*** Ref_nass >1 " << endl;
107 iunique = ptrs.size();
109 cout <<
" volumes " << ivolumes << endl
110 <<
" surfaces " << isurfaces << endl
111 <<
" assigned " << iassigned << endl
112 <<
" unique " << iunique << endl
113 <<
" iref_ass " << iref_ass << endl
114 <<
" iref_nass " << iref_nass << endl;
122 cout <<
"**********************************************************" << endl;
125 map<string, MagProviderInterpol*> bInterpolators;
126 map<string, MagProviderInterpol*> eInterpolators;
139 while (go && doSubDets) {
147 <<
" Neither the top node, nor any child node of the DDCompactView is \"MAGF\" but the top node is instead \"" 148 << topNodeName <<
"\"";
156 <<
" rotation: " << fv.
rotation() << endl;
192 int key = (
v->volumeno) * 100 +
v->copyno;
195 key = (
v->volumeno) * 100;
200 string magFile = (*itable).second.first;
203 conv << setfill(
'0') << setw(3) <<
v->volumeno <<
" " << setw(2)
205 conv >> svol >> ssec;
206 boost::replace_all(magFile,
"[v]", svol);
207 boost::replace_all(magFile,
"[s]", ssec);
208 int masterSector = (*itable).second.second;
209 if (masterSector == 0)
210 masterSector =
v->copyno;
211 v->magFile = magFile;
212 v->masterSector = masterSector;
215 <<
"ERROR: no table spec found for V " <<
v->volumeno <<
":" <<
v->copyno;
220 float Z =
v->center().z();
221 float R =
v->center().perp();
229 if ((fabs(
Z) < 647. || (
R > 350. && fabs(
Z) < 662.)) &&
230 !(fabs(
Z) > 480 &&
R < 172)
236 cout <<
" (Barrel)" << endl;
242 if (
v->copyno ==
v->masterSector) {
248 cout <<
" (Endcaps)" << endl;
250 if (
v->copyno ==
v->masterSector) {
260 cout <<
"Number of volumes (barrel): " <<
bVolumes.size() << endl
261 <<
"Number of volumes (endcap): " <<
eVolumes.size() << endl;
262 cout <<
"**********************************************************" << endl;
272 cout <<
"-----------------------" << endl;
273 cout <<
"SUMMARY: Barrel " << endl;
276 cout << endl <<
"SUMMARY: Endcaps " << endl;
278 cout <<
"-----------------------" << endl;
294 cout <<
" R layers: " << rmin <<
" " << rmax << endl;
299 for (handles::const_iterator
i =
first;
i !=
last; ++
i) {
300 hisR.
fill((*i)->RN());
304 handles::const_iterator ringStart =
first;
305 handles::const_iterator separ =
first;
307 for (
unsigned int i = 0;
i < rClust.size() - 1; ++
i) {
309 cout <<
" Layer at RN = " << rClust[
i];
310 float rSepar = (rClust[
i] + rClust[
i + 1]) / 2.
f;
311 while ((*separ)->RN() < rSepar)
315 layers.push_back(thislayer);
320 cout <<
" Layer at RN = " << rClust.back();
322 layers.push_back(thislayer);
326 cout <<
"Barrel: Found " << rClust.size() <<
" clusters in R, " <<
layers.size() <<
" layers " << endl << endl;
333 float phireso = 0.05;
337 hisPhi.
fill((*i)->minPhi());
339 vector<float> phiClust = hisPhi.
clusterize(phireso);
340 int nESectors = phiClust.size();
341 if (
debug && (nESectors % 12) != 0)
342 cout <<
"ERROR: unexpected # of sectors: " << nESectors << endl;
349 float lastBinPhi = phiClust.back();
350 handles::reverse_iterator ri =
eVolumes.rbegin();
351 while ((*ri)->center().phi() > lastBinPhi) {
357 handles::iterator newbeg = ri.base();
363 for (
int i = 0;
i < nESectors; ++
i) {
365 cout <<
" Sector at phi = " << (*(
eVolumes.begin() + ((
i)*
offset)))->center().phi() << endl;
370 if (secCopyNo >= 0 && (*iv)->copyno != secCopyNo)
371 cout <<
"ERROR: volume copyno" << (*iv)->name <<
":" << (*iv)->copyno
372 <<
" differs from others in same sectors " << secCopyNo << endl;
373 secCopyNo = (*iv)->copyno;
381 cout <<
"Endcap: Found " <<
sectors.size() <<
" sectors " << endl;
424 for (vector<bLayer>::const_iterator ilay =
layers.begin(); ilay !=
layers.end(); ++ilay) {
425 mBLayers.push_back((*ilay).buildMagBLayer());
429 cout <<
"*** BARREL ********************************************" << endl
430 <<
"Number of different volumes = " << bVolCount << endl
431 <<
"Number of interpolators built = " << bInterpolators.size() << endl
432 <<
"Number of MagBLayers built = " <<
mBLayers.size() << endl;
443 mESectors.push_back((*isec).buildMagESector());
447 cout <<
"*** ENDCAP ********************************************" << endl
448 <<
"Number of different volumes = " << eVolCount << endl
449 <<
"Number of interpolators built = " << eInterpolators.size() << endl
450 <<
"Number of MagESector built = " <<
mESectors.size() << endl;
458 for (handles::const_iterator vol =
volumes.begin(); vol !=
volumes.end(); ++vol) {
460 if (interpolators.find((*vol)->magFile) != interpolators.end()) {
461 mp = interpolators[(*vol)->magFile];
463 edm::LogError(
"MagGeoBuilder") <<
"No interpolator found for file " << (*vol)->magFile
464 <<
" vol: " << (*vol)->volumeno <<
"\n" 465 << interpolators.size() << endl;
470 int key = ((*vol)->volumeno) * 100 + (*vol)->copyno;
473 key = ((*vol)->volumeno) * 100;
481 edm::LogInfo(
"MagGeoBuilder") <<
"Applying scaling factor " << sf <<
" to " << (*vol)->volumeno <<
"[" 482 << (*vol)->copyno <<
"] (key:" <<
key <<
")" << endl;
488 if ((*vol)->copyno == (*vol)->masterSector) {
492 (*vol)->magVolume->setIsIron((*vol)->isIron());
495 (*vol)->magVolume->volumeNo = (*vol)->volumeno;
496 (*vol)->magVolume->copyno = (*vol)->copyno;
501 map<string, MagProviderInterpol*>& interpolators) {
510 cout <<
"***WARNING wrong sector? " << endl;
525 cerr <<
"MagGeoBuilderFromDDD: exception in reading table; " << exc.
what() << endl;
556 interpolators.erase(vol->
magFile);
568 if (
grid !=
nullptr) {
570 cout <<
"Grid has 3 dimensions " 571 <<
" number of nodes is " << sizes.
w <<
" " << sizes.
h <<
" " << sizes.
d << endl;
575 size_t dumpCount = 0;
576 for (
int j = 0;
j < sizes.
h;
j++) {
577 for (
int k = 0;
k < sizes.
d;
k++) {
578 for (
int i = 0;
i < sizes.
w;
i++) {
581 if (++dumpCount < 2) {
583 cout <<
"GRID ERROR: " <<
i <<
" " <<
j <<
" " <<
k <<
" local: " << lp <<
" global: " <<
gp 584 <<
" R= " <<
gp.perp() <<
" phi=" <<
gp.phi() << endl;
591 cout <<
"Volume:" << vol->
volumeno <<
" : Number of grid points outside the MagVolume: " << dumpCount <<
"/" 592 << sizes.
w * sizes.
h * sizes.
d << endl;
599 cout <<
"--------------------------------------------------" << endl;
600 cout <<
" inside(center) test" << endl;
601 for (handles::const_iterator vol =
volumes.begin(); vol !=
volumes.end(); ++vol) {
606 if ((*i)->magVolume->inside((*vol)->center())) {
607 cout <<
"*** ERROR: center of V " << (*vol)->volumeno <<
":" << (*vol)->copyno <<
" is inside V " 608 << (*i)->volumeno <<
":" << (*i)->copyno << endl;
612 if ((*vol)->magVolume->inside((*vol)->center())) {
613 cout <<
"V " << (*vol)->volumeno <<
" OK " << endl;
615 cout <<
"*** ERROR: center of volume is not inside it, " << (*vol)->volumeno << endl;
618 cout <<
"--------------------------------------------------" << endl;
626 vector<MagVolume6Faces*>
v;
629 v.push_back((*i)->magVolume);
635 vector<MagVolume6Faces*>
v;
638 v.push_back((*i)->magVolume);
661 <<
"Invalid field scaling parameters 'scalingVolumes' and 'scalingFactors' ";
663 for (
unsigned int i = 0;
i <
keys.size(); ++
i) {
void summary(magneticfield::handles &volumes)
std::vector< MagVolume6Faces * > barrelVolumes() const
std::vector< MagBLayer * > mBLayers
std::vector< MagESector * > endcapSectors() const
Get endcap layers.
MagGeoBuilderFromDDD::volumeHandle volumeHandle
const DDTranslation & translation() const
The absolute translation of the current node.
std::string fullPath() const
std::vector< MagBLayer * > barrelLayers() const
Get barrel layers.
ROOT::Math::Plane3D::Vector Vector
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the expanded-view.
magneticfield::handles eVolumes
Geom::Phi< T > phi() const
std::vector< VolumeSide > sides() const override
The surfaces and they orientation, as required to build a MagVolume.
GloballyPositioned< float >::LocalPoint LocalPoint
Log< level::Error, false > LogError
const GlobalPoint & center() const
Return the center of the volume.
Compact representation of the geometrical detector hierarchy.
unsigned short volumeno
volume number
unsigned short copyno
copy number
U second(std::pair< T, U > const &p)
virtual ~MagGeoBuilderFromDDD()
Destructor.
virtual void build(const DDCompactView &cpv)
const std::string & name() const
Returns the name.
std::vector< float > clusterize(float resolution)
void buildMagVolumes(const magneticfield::handles &volumes, std::map< std::string, MagProviderInterpol *> &interpolators)
magneticfield::handles bVolumes
std::vector< BaseVolumeHandle * > handles
const char * what() const override
int masterSector
The sector for which an interpolator for this class of volumes should be built.
static MFGrid * build(const std::string &name, const GloballyPositioned< float > &vol)
Build interpolator for a binary grid file.
Point3DBase< T, GlobalTag > PositionType
MagGeoBuilderFromDDD(std::string tableSet_, int geometryVersion, bool debug=false)
Constructor.
Log< level::Info, false > LogInfo
const magneticfield::TableFileMap * theGridFiles
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
void buildInterpolator(const volumeHandle *vol, std::map< std::string, MagProviderInterpol *> &interpolators)
const PositionType & position() const
std::vector< MagVolume6Faces * > endcapVolumes() const
bool firstChild()
set the current node to the first child ...
GloballyPositioned< float >::GlobalPoint GlobalPoint
bool nextSibling()
set the current node to the next sibling ...
void setScaling(const std::vector< int > &keys, const std::vector< double > &values)
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
void testInside(magneticfield::handles &volumes)
const RotationType & rotation() const
char const * what() const noexcept override
std::vector< MagESector * > mESectors
std::map< int, std::pair< std::string, int > > TableFileMap
Provides an exploded view of the detector (tree-view)
std::map< int, double > theScalingFactors
const GloballyPositioned< float > * placement() const
Position and rotation.
def rotate(angle, cx=0, cy=0)
std::string magFile
Name of magnetic field table file.
void ownsFieldProvider(bool o)
void setGridFiles(const magneticfield::TableFileMap &gridFiles)
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.