51 #include <boost/algorithm/string/replace.hpp> 60 cout <<
"Constructing a MagGeoBuilderFromDDD" << endl;
75 int ivolumes = volumes.size();
76 int isurfaces = ivolumes * 6;
82 set<const void*> ptrs;
84 handles::const_iterator
first = volumes.begin();
85 handles::const_iterator
last = volumes.end();
87 for (handles::const_iterator
i = first;
i !=
last; ++
i) {
88 if (
int((*i)->shape()) > 4)
90 for (
int side = 0; side < 6; ++side) {
91 int references = (*i)->references(side);
92 if ((*i)->isPlaneMatched(side)) {
94 bool firstOcc = (ptrs.insert(&((*i)->surface(side)))).
second;
96 iref_ass += references;
98 cout <<
"*** Only 1 ref, vol: " << (*i)->volumeno <<
" # " << (*i)->copyno <<
" side: " << side << endl;
101 iref_nass += references;
102 if (references > 1) {
103 cout <<
"*** Ref_nass >1 " << endl;
108 iunique = ptrs.size();
110 cout <<
" volumes " << ivolumes << endl
111 <<
" surfaces " << isurfaces << endl
112 <<
" assigned " << iassigned << endl
113 <<
" unique " << iunique << endl
114 <<
" iref_ass " << iref_ass << endl
115 <<
" iref_nass " << iref_nass << endl;
123 cout <<
"**********************************************************" << endl;
126 map<string, MagProviderInterpol*> bInterpolators;
127 map<string, MagProviderInterpol*> eInterpolators;
140 while (go && doSubDets) {
148 <<
" Neither the top node, nor any child node of the DDCompactView is \"MAGF\" but the top node is instead \"" 149 << topNodeName <<
"\"";
157 <<
" rotation: " << fv.
rotation() << endl;
164 cout << endl <<
"Name: " << name << endl <<
" " << fv.
geoHistory() << endl;
194 TableFileMap::const_iterator itable =
theGridFiles->find(key);
201 string magFile = (*itable).second.first;
204 conv << setfill(
'0') << setw(3) << v->
volumeno <<
" " << setw(2)
206 conv >> svol >> ssec;
207 boost::replace_all(magFile,
"[v]", svol);
208 boost::replace_all(magFile,
"[s]", ssec);
209 int masterSector = (*itable).second.second;
210 if (masterSector == 0)
216 <<
"ERROR: no table spec found for V " << v->
volumeno <<
":" << v->
copyno;
230 if ((fabs(Z) < 647. || (R > 350. && fabs(Z) < 662.)) &&
231 !(fabs(Z) > 480 && R < 172)
237 cout <<
" (Barrel)" << endl;
249 cout <<
" (Endcaps)" << endl;
261 cout <<
"Number of volumes (barrel): " <<
bVolumes.size() << endl
262 <<
"Number of volumes (endcap): " <<
eVolumes.size() << endl;
263 cout <<
"**********************************************************" << endl;
273 cout <<
"-----------------------" << endl;
274 cout <<
"SUMMARY: Barrel " << endl;
277 cout << endl <<
"SUMMARY: Endcaps " << endl;
279 cout <<
"-----------------------" << endl;
295 cout <<
" R layers: " << rmin <<
" " << rmax << endl;
300 for (handles::const_iterator
i = first;
i !=
last; ++
i) {
301 hisR.
fill((*i)->RN());
303 vector<float> rClust = hisR.
clusterize(resolution);
305 handles::const_iterator ringStart =
first;
306 handles::const_iterator separ =
first;
308 for (
unsigned int i = 0;
i < rClust.size() - 1; ++
i) {
310 cout <<
" Layer at RN = " << rClust[
i];
311 float rSepar = (rClust[
i] + rClust[
i + 1]) / 2.
f;
312 while ((*separ)->RN() < rSepar)
316 layers.push_back(thislayer);
321 cout <<
" Layer at RN = " << rClust.back();
323 layers.push_back(thislayer);
327 cout <<
"Barrel: Found " << rClust.size() <<
" clusters in R, " << layers.size() <<
" layers " << endl << endl;
334 float phireso = 0.05;
338 hisPhi.
fill((*i)->minPhi());
340 vector<float> phiClust = hisPhi.
clusterize(phireso);
341 int nESectors = phiClust.size();
342 if (
debug && (nESectors % 12) != 0)
343 cout <<
"ERROR: unexpected # of sectors: " << nESectors << endl;
350 float lastBinPhi = phiClust.back();
351 handles::reverse_iterator ri =
eVolumes.rbegin();
352 while ((*ri)->center().phi() > lastBinPhi) {
358 handles::iterator newbeg = ri.base();
364 for (
int i = 0;
i < nESectors; ++
i) {
366 cout <<
" Sector at phi = " << (*(
eVolumes.begin() + ((
i)*offset)))->center().phi() << endl;
369 for (handles::const_iterator iv =
eVolumes.begin() + ((
i)*offset); iv !=
eVolumes.begin() + ((
i + 1) * offset);
371 if (secCopyNo >= 0 && (*iv)->copyno != secCopyNo)
372 cout <<
"ERROR: volume copyno" << (*iv)->name <<
":" << (*iv)->copyno
373 <<
" differs from others in same sectors " << secCopyNo << endl;
374 secCopyNo = (*iv)->copyno;
382 cout <<
"Endcap: Found " << sectors.size() <<
" sectors " << endl;
425 for (vector<bLayer>::const_iterator ilay = layers.begin(); ilay != layers.end(); ++ilay) {
426 mBLayers.push_back((*ilay).buildMagBLayer());
430 cout <<
"*** BARREL ********************************************" << endl
431 <<
"Number of different volumes = " << bVolCount << endl
432 <<
"Number of interpolators built = " << bInterpolators.size() << endl
433 <<
"Number of MagBLayers built = " <<
mBLayers.size() << endl;
443 for (vector<eSector>::const_iterator isec = sectors.begin(); isec != sectors.end(); ++isec) {
444 mESectors.push_back((*isec).buildMagESector());
448 cout <<
"*** ENDCAP ********************************************" << endl
449 <<
"Number of different volumes = " << eVolCount << endl
450 <<
"Number of interpolators built = " << eInterpolators.size() << endl
451 <<
"Number of MagESector built = " <<
mESectors.size() << endl;
459 for (handles::const_iterator vol = volumes.begin(); vol != volumes.end(); ++vol) {
461 if (interpolators.find((*vol)->magFile) != interpolators.end()) {
462 mp = interpolators[(*vol)->magFile];
465 <<
"No interpolator found for file " << (*vol)->magFile <<
" vol: " << (*vol)->volumeno <<
"\n" 466 << interpolators.size() << endl;
471 int key = ((*vol)->volumeno) * 100 + (*vol)->copyno;
474 key = ((*vol)->volumeno) * 100;
482 edm::LogInfo(
"MagneticField|VolumeBasedMagneticFieldESProducer")
483 <<
"Applying scaling factor " << sf <<
" to " << (*vol)->volumeno <<
"[" << (*vol)->copyno <<
"] (key:" << key
490 if ((*vol)->copyno == (*vol)->masterSector) {
494 (*vol)->magVolume->setIsIron((*vol)->isIron());
497 (*vol)->magVolume->volumeNo = (*vol)->volumeno;
498 (*vol)->magVolume->copyno = (*vol)->copyno;
503 map<string, MagProviderInterpol*>& interpolators) {
512 cout <<
"***WARNING wrong sector? " << endl;
527 cerr <<
"MagGeoBuilderFromDDD: exception in reading table; " << exc.
what() << endl;
558 interpolators.erase(vol->
magFile);
570 if (grid !=
nullptr) {
572 cout <<
"Grid has 3 dimensions " 573 <<
" number of nodes is " << sizes.
w <<
" " << sizes.
h <<
" " << sizes.
d << endl;
577 size_t dumpCount = 0;
578 for (
int j = 0;
j < sizes.
h;
j++) {
579 for (
int k = 0;
k < sizes.
d;
k++) {
580 for (
int i = 0;
i < sizes.
w;
i++) {
582 if (!tempVolume.inside(lp, tolerance)) {
583 if (++dumpCount < 2) {
585 cout <<
"GRID ERROR: " <<
i <<
" " <<
j <<
" " <<
k <<
" local: " << lp <<
" global: " << gp
586 <<
" R= " << gp.perp() <<
" phi=" << gp.phi() << endl;
593 cout <<
"Volume:" << vol->
volumeno <<
" : Number of grid points outside the MagVolume: " << dumpCount <<
"/" 594 << sizes.
w * sizes.
h * sizes.
d << endl;
601 cout <<
"--------------------------------------------------" << endl;
602 cout <<
" inside(center) test" << endl;
603 for (handles::const_iterator vol = volumes.begin(); vol != volumes.end(); ++vol) {
604 for (handles::const_iterator
i = volumes.begin();
i != volumes.end(); ++
i) {
608 if ((*i)->magVolume->inside((*vol)->center())) {
609 cout <<
"*** ERROR: center of V " << (*vol)->volumeno <<
":" << (*vol)->copyno <<
" is inside V " 610 << (*i)->volumeno <<
":" << (*i)->copyno << endl;
614 if ((*vol)->magVolume->inside((*vol)->center())) {
615 cout <<
"V " << (*vol)->volumeno <<
" OK " << endl;
617 cout <<
"*** ERROR: center of volume is not inside it, " << (*vol)->volumeno << endl;
620 cout <<
"--------------------------------------------------" << endl;
628 vector<MagVolume6Faces*>
v;
631 v.push_back((*i)->magVolume);
637 vector<MagVolume6Faces*>
v;
640 v.push_back((*i)->magVolume);
661 if (keys.size() != values.size()) {
663 <<
"Invalid field scaling parameters 'scalingVolumes' and 'scalingFactors' ";
665 for (
unsigned int i = 0;
i < keys.size(); ++
i) {
void summary(magneticfield::handles &volumes)
std::vector< MagBLayer * > mBLayers
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
MagGeoBuilderFromDDD::volumeHandle volumeHandle
const char * what() const override
static HepMC::IO_HEPEVT conv
ROOT::Math::Plane3D::Vector Vector
magneticfield::handles eVolumes
Geom::Phi< T > phi() const
std::vector< MagBLayer * > barrelLayers() const
Get barrel layers.
GloballyPositioned< float >::LocalPoint LocalPoint
char const * what() const override
Compact representation of the geometrical detector hierarchy.
unsigned short volumeno
volume number
unsigned short copyno
copy number
std::vector< MagVolume6Faces * > barrelVolumes() const
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
U second(std::pair< T, U > const &p)
virtual ~MagGeoBuilderFromDDD()
Destructor.
virtual void build(const DDCompactView &cpv)
std::vector< float > clusterize(float resolution)
magneticfield::handles bVolumes
std::vector< BaseVolumeHandle * > handles
int masterSector
The sector for which an interpolator for this class of volumes should be built.
std::vector< MagESector * > endcapSectors() const
Get endcap layers.
static MFGrid * build(const std::string &name, const GloballyPositioned< float > &vol)
Build interpolator for a binary grid file.
Point3DBase< T, GlobalTag > PositionType
const DDTranslation & translation() const
The absolute translation of the current node.
const GlobalPoint & center() const
Return the center of the volume.
MagGeoBuilderFromDDD(std::string tableSet_, int geometryVersion, bool debug=false)
Constructor.
const magneticfield::TableFileMap * theGridFiles
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
bool firstChild()
set the current node to the first child ...
GloballyPositioned< float >::GlobalPoint GlobalPoint
void buildInterpolator(const volumeHandle *vol, std::map< std::string, MagProviderInterpol * > &interpolators)
void buildMagVolumes(const magneticfield::handles &volumes, std::map< std::string, MagProviderInterpol * > &interpolators)
bool nextSibling()
set the current node to the next sibling ...
void setScaling(const std::vector< int > &keys, const std::vector< double > &values)
const GloballyPositioned< float > * placement() const
Position and rotation.
std::vector< MagVolume6Faces * > endcapVolumes() const
void testInside(magneticfield::handles &volumes)
const RotationType & rotation() const
std::string fullPath() const
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the expanded-view.
std::vector< MagESector * > mESectors
std::map< int, std::pair< std::string, int > > TableFileMap
const PositionType & position() const
Provides an exploded view of the detector (tree-view)
std::map< int, double > theScalingFactors
def rotate(angle, cx=0, cy=0)
const std::string & name() const
Returns the name.
std::string magFile
Name of magnetic field table file.
void ownsFieldProvider(bool o)
void setGridFiles(const magneticfield::TableFileMap &gridFiles)
std::vector< VolumeSide > sides() const override
The surfaces and they orientation, as required to build a MagVolume.