29 #include "CLHEP/Units/GlobalSystemOfUnits.h"
62 overrideMasterSector(overrideMasterSector_)
65 if (
debug)
cout <<
"Constructing a MagGeoBuilderFromDDD" <<endl;
69 for (handles::const_iterator
i=
bVolumes.begin();
74 for (handles::const_iterator
i=
eVolumes.begin();
83 int ivolumes = volumes.size();
84 int isurfaces = ivolumes*6;
90 set<const void *> ptrs;
92 handles::const_iterator
first = volumes.begin();
93 handles::const_iterator
last = volumes.end();
95 for (handles::const_iterator
i=first;
i!=
last; ++
i){
96 if (
int((*i)->shape())>4)
continue;
97 for (
int side = 0; side < 6; ++side) {
98 int references = (*i)->references(side);
99 if ((*i)->isPlaneMatched(side)) {
101 bool firstOcc = (ptrs.insert(&((*i)->surface(side)))).
second;
102 if (firstOcc) iref_ass+=references;
104 cout <<
"*** Only 1 ref, vol: " << (*i)->name <<
" # "
105 << (*i)->copyno <<
" side: " << side << endl;
108 iref_nass+=references;
110 cout <<
"*** Ref_nass >1 " <<endl;
115 iunique = ptrs.size();
117 cout <<
" volumes " << ivolumes << endl
118 <<
" surfaces " << isurfaces << endl
119 <<
" assigned " << iassigned << endl
120 <<
" unique " << iunique << endl
121 <<
" iref_ass " << iref_ass << endl
122 <<
" iref_nass " << iref_nass << endl;
131 if (
debug)
cout <<
"**********************************************************" <<endl;
134 map<string, MagProviderInterpol*> bInterpolators;
135 map<string, MagProviderInterpol*> eInterpolators;
148 while(go&& doSubDets) {
155 throw cms::Exception(
"NoMAGFinDDD")<<
" Neither he top node, nor any child node of the DDCompactView is \"MAGF\" but the top node is instead \""<<topNodeName<<
"\"";
161 <<
" rotation: " << fv.
rotation() << endl;
168 if (
debug)
cout << endl <<
"Name: " << name << endl
175 if (name.substr(2,2)==
"ZP") {
212 ibeg = (v->
magFile).rfind(
'/');
227 if ((fabs(Z)<647. || (R>350. && fabs(Z)<662.)) &&
228 !(fabs(Z)>480 && R<172)
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;
285 vector<bLayer> layers;
294 if (
debug)
cout <<
" R layers: " << rmin <<
" " << rmax << endl;
299 for (handles::const_iterator
i=first;
i!=
last; ++
i){
300 hisR.
fill((*i)->RN());
302 vector<float> rClust = hisR.
clusterize(resolution);
304 handles::const_iterator ringStart =
first;
305 handles::const_iterator separ =
first;
307 for (
unsigned int i=0;
i<rClust.size() - 1; ++
i) {
308 if (
debug)
cout <<
" Layer at RN = " << rClust[
i];
309 float rSepar = (rClust[
i] + rClust[
i+1])/2.
f;
310 while ((*separ)->RN() < rSepar) ++separ;
312 bLayer thislayer(ringStart, separ);
313 layers.push_back(thislayer);
317 if (
debug)
cout <<
" Layer at RN = " << rClust.back();
318 bLayer thislayer(separ, last);
319 layers.push_back(thislayer);
322 if (
debug)
cout <<
"Barrel: Found " << rClust.size() <<
" clusters in R, "
323 << layers.size() <<
" layers " << endl << endl;
334 for (
int i = 0;
i<12; ++
i) {
338 << (*(
eVolumes.begin()+((
i)*offset)))->center().phi()
345 << sectors.size() <<
" sectors " << endl;
390 for (vector<bLayer>::const_iterator ilay = layers.begin();
391 ilay!= layers.end(); ++ilay) {
392 mBLayers.push_back((*ilay).buildMagBLayer());
396 cout <<
"*** BARREL ********************************************" << endl
397 <<
"Number of different volumes = " << bVolCount << endl
398 <<
"Number of interpolators built = " << bInterpolators.size() << endl
399 <<
"Number of MagBLayers built = " <<
mBLayers.size() << endl;
409 for (vector<eSector>::const_iterator isec = sectors.begin();
410 isec!= sectors.end(); ++isec) {
411 mESectors.push_back((*isec).buildMagESector());
415 cout <<
"*** ENDCAP ********************************************" << endl
416 <<
"Number of different volumes = " << eVolCount << endl
417 <<
"Number of interpolators built = " << eInterpolators.size() << endl
418 <<
"Number of MagESector built = " <<
mESectors.size() << endl;
427 for (handles::const_iterator vol=volumes.begin(); vol!=volumes.end();
430 if (interpolators.find((*vol)->magFile)!=interpolators.end()) {
431 mp = interpolators[(*vol)->magFile];
433 cout <<
"No interpolator found for file " << (*vol)->magFile
434 <<
" vol: " << (*vol)->name << endl;
435 cout << interpolators.size() <<endl;
442 string name = (*vol)->name;
443 name.erase(0,name.rfind(
'_')+1);
453 int key = volNum*100+(*vol)->copyno;
464 edm::LogInfo(
"MagneticField|VolumeBasedMagneticFieldESProducer") <<
"Applying scaling factor " << sf <<
" to "<< (*vol)->name <<
"["<< (*vol)->copyno <<
"] (key:" << key <<
")" << endl;
474 if ((*vol)->copyno==(*vol)->masterSector) {
478 (*vol)->magVolume->setIsIron((*vol)->isIron());
481 (*vol)->magVolume->name = (*vol)->name;
482 (*vol)->magVolume->copyno = (*vol)->copyno;
503 if (
version==
"grid_85l_030919") {
508 cout <<
"Building interpolator from "
510 <<
" at " << vol->
center()
516 cout <<
"***WARNING wrong sector? " << endl;
531 cerr <<
"MagGeoBuilderFromDDD: exception in reading table; " << exc.
what() << endl;
563 interpolators.erase(vol->
magFile);
581 cout <<
"Grid has 3 dimensions "
582 <<
" number of nodes is " << sizes.
w <<
" " << sizes.
h
583 <<
" " << sizes.
d << endl;
585 const double tolerance = 0.03;
589 for (
int j=0;
j < sizes.
h;
j++) {
590 for (
int k=0;
k < sizes.
d;
k++) {
591 for (
int i=0;
i < sizes.
w;
i++) {
593 if (! tempVolume.inside(lp, tolerance)) {
594 if (++dumpCount < 2) {
596 cout <<
"GRID ERROR: " <<
i <<
" " <<
j <<
" " <<
k
599 <<
" R= " << gp.perp() <<
" phi=" << gp.phi() << endl;
606 cout << vol->
name <<
" : Number of grid points outside the MagVolume: " << dumpCount <<
"/" << sizes.
w*sizes.
h*sizes.
d << endl;
615 cout <<
"--------------------------------------------------" << endl;
616 cout <<
" inside(center) test" << endl;
617 for (handles::const_iterator vol=volumes.begin(); vol!=volumes.end();
619 for (handles::const_iterator
i=volumes.begin();
i!=volumes.end();
621 if ((*
i)==(*vol))
continue;
623 if ((*i)->magVolume->inside((*vol)->center())) {
624 cout <<
"*** ERROR: center of " << (*vol)->name <<
" is inside "
625 << (*i)->name <<endl;
629 if ((*vol)->magVolume->inside((*vol)->center())) {
630 cout << (*vol)->name <<
" OK " << endl;
632 cout <<
"*** ERROR: center of volume is not inside it, "
633 << (*vol)->name << endl;
636 cout <<
"--------------------------------------------------" << endl;
649 vector<MagVolume6Faces*>
v;
651 for (handles::const_iterator
i=
bVolumes.begin();
653 v.push_back((*i)->magVolume);
659 vector<MagVolume6Faces*>
v;
661 for (handles::const_iterator
i=
eVolumes.begin();
663 v.push_back((*i)->magVolume);
673 if (
version==
"grid_85l_030919")
return 1000.;
684 std::vector<double>
values)
686 if (keys.size() != values.size()) {
687 throw cms::Exception(
"InvalidParameter") <<
"Invalid field scaling parameters 'scalingVolumes' and 'scalingFactors' ";
689 for (
unsigned int i=0;
i<keys.size(); ++
i) {
const double Z[kNumberCalorimeter]
virtual char const * what() const
std::vector< MagBLayer * > mBLayers
std::vector< volumeHandle * > handles
const GloballyPositioned< float > * placement() const
FIXME: currently returns max RN (to be fixed?). Used by: bLayer::maxR()
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
ROOT::Math::Plane3D::Vector Vector
std::vector< VolumeSide > sides() const
The surfaces and they orientation, as required to build a MagVolume.
Geom::Phi< T > phi() const
std::vector< MagBLayer * > barrelLayers() const
Get barrel layers.
MagGeoBuilderFromDDD(std::string version_, bool debug=false, bool overrideMasterSector=false)
const GlobalPoint & center() const
Return the center of the volume.
GloballyPositioned< float >::LocalPoint LocalPoint
std::string name
Name of the volume.
type of data representation of DDCompactView
DDSolidShape shape() const
Shape of the solid.
void summary(handles &volumes)
std::vector< MagVolume6Faces * > barrelVolumes() const
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
bool overrideMasterSector
U second(std::pair< T, U > const &p)
virtual ~MagGeoBuilderFromDDD()
Destructor.
virtual void build(const DDCompactView &cpv)
std::vector< float > clusterize(float resolution)
virtual const char * what() const
void testInside(handles &volumes)
void setScaling(std::vector< int > keys, std::vector< double > values)
std::string magFile
Name of magnetic field table file.
std::vector< MagESector * > endcapSectors() const
Get endcap layers.
unsigned int offset(bool)
static MFGrid * build(const std::string &name, const GloballyPositioned< float > &vol)
Build interpolator for a binary grid file.
const DDTranslation & translation() const
The absolute translation of the current node.
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)
bool nextSibling()
set the current node to the next sibling ...
Point3DBase< T, GlobalTag > PositionType
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr)
std::vector< MagVolume6Faces * > endcapVolumes() const
const RotationType & rotation() const
int masterSector
The sector for which an interpolator for this class of volumes should be built.
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the expanded-view.
std::string fullPath() const
std::vector< MagESector * > mESectors
const PositionType & position() const
Provides an exploded view of the detector (tree-view)
std::map< int, double > theScalingFactors
void buildMagVolumes(const handles &volumes, std::map< std::string, MagProviderInterpol * > &interpolators)
const std::string & name() const
Returns the name.
tuple size
Write out results.
void ownsFieldProvider(bool o)