29 #include "CLHEP/Units/GlobalSystemOfUnits.h"
63 overrideMasterSector(overrideMasterSector_)
66 if (
debug)
cout <<
"Constructing a MagGeoBuilderFromDDD" <<endl;
70 for (handles::const_iterator
i=
bVolumes.begin();
75 for (handles::const_iterator
i=
eVolumes.begin();
84 int ivolumes = volumes.size();
85 int isurfaces = ivolumes*6;
91 set<const void *> ptrs;
93 handles::const_iterator
first = volumes.begin();
94 handles::const_iterator
last = volumes.end();
96 for (handles::const_iterator
i=first;
i!=
last; ++
i){
97 if (
int((*i)->shape())>4)
continue;
98 for (
int side = 0; side < 6; ++side) {
99 int references = (*i)->references(side);
100 if ((*i)->isPlaneMatched(side)) {
102 bool firstOcc = (ptrs.insert(&((*i)->surface(side)))).
second;
103 if (firstOcc) iref_ass+=references;
105 cout <<
"*** Only 1 ref, vol: " << (*i)->name <<
" # "
106 << (*i)->copyno <<
" side: " << side << endl;
109 iref_nass+=references;
111 cout <<
"*** Ref_nass >1 " <<endl;
116 iunique = ptrs.size();
118 cout <<
" volumes " << ivolumes << endl
119 <<
" surfaces " << isurfaces << endl
120 <<
" assigned " << iassigned << endl
121 <<
" unique " << iunique << endl
122 <<
" iref_ass " << iref_ass << endl
123 <<
" iref_nass " << iref_nass << endl;
132 if (
debug)
cout <<
"**********************************************************" <<endl;
135 map<string, MagProviderInterpol*> bInterpolators;
136 map<string, MagProviderInterpol*> eInterpolators;
149 while(go&& doSubDets) {
156 throw cms::Exception(
"NoMAGFinDDD")<<
" Neither the top node, nor any child node of the DDCompactView is \"MAGF\" but the top node is instead \""<<topNodeName<<
"\"";
162 <<
" rotation: " << fv.
rotation() << endl;
169 if (
debug)
cout << endl <<
"Name: " << name << endl
204 ibeg = (v->
magFile).rfind(
'/');
219 if ((fabs(Z)<647. || (R>350. && fabs(Z)<662.)) &&
220 !(fabs(Z)>480 && R<172)
252 cout <<
"Number of volumes (barrel): " <<
bVolumes.size() <<endl
253 <<
"Number of volumes (endcap): " <<
eVolumes.size() <<endl;
254 cout <<
"**********************************************************" <<endl;
264 cout <<
"-----------------------" << endl;
265 cout <<
"SUMMARY: Barrel " << endl;
268 cout << endl <<
"SUMMARY: Endcaps " << endl;
270 cout <<
"-----------------------" << endl;
277 vector<bLayer> layers;
286 if (
debug)
cout <<
" R layers: " << rmin <<
" " << rmax << endl;
291 for (handles::const_iterator
i=first;
i!=
last; ++
i){
292 hisR.
fill((*i)->RN());
294 vector<float> rClust = hisR.
clusterize(resolution);
296 handles::const_iterator ringStart =
first;
297 handles::const_iterator separ =
first;
299 for (
unsigned int i=0;
i<rClust.size() - 1; ++
i) {
300 if (
debug)
cout <<
" Layer at RN = " << rClust[
i];
301 float rSepar = (rClust[
i] + rClust[
i+1])/2.
f;
302 while ((*separ)->RN() < rSepar) ++separ;
304 bLayer thislayer(ringStart, separ);
305 layers.push_back(thislayer);
309 if (
debug)
cout <<
" Layer at RN = " << rClust.back();
310 bLayer thislayer(separ, last);
311 layers.push_back(thislayer);
314 if (
debug)
cout <<
"Barrel: Found " << rClust.size() <<
" clusters in R, "
315 << layers.size() <<
" layers " << endl << endl;
323 float phireso = 0.05;
328 hisPhi.
fill((*i)->minPhi());
330 vector<float> phiClust = hisPhi.
clusterize(phireso);
331 int nESectors = phiClust.size();
332 if (
debug && (nESectors%12)!=0)
cout <<
"ERROR: unexpected # of sectors: " << nESectors << endl;
338 for (
int i = 0;
i<nESectors; ++
i) {
341 << (*(
eVolumes.begin()+((
i)*offset)))->center().phi()
348 << sectors.size() <<
" sectors " << endl;
393 for (vector<bLayer>::const_iterator ilay = layers.begin();
394 ilay!= layers.end(); ++ilay) {
395 mBLayers.push_back((*ilay).buildMagBLayer());
399 cout <<
"*** BARREL ********************************************" << endl
400 <<
"Number of different volumes = " << bVolCount << endl
401 <<
"Number of interpolators built = " << bInterpolators.size() << endl
402 <<
"Number of MagBLayers built = " <<
mBLayers.size() << endl;
412 for (vector<eSector>::const_iterator isec = sectors.begin();
413 isec!= sectors.end(); ++isec) {
414 mESectors.push_back((*isec).buildMagESector());
418 cout <<
"*** ENDCAP ********************************************" << endl
419 <<
"Number of different volumes = " << eVolCount << endl
420 <<
"Number of interpolators built = " << eInterpolators.size() << endl
421 <<
"Number of MagESector built = " <<
mESectors.size() << endl;
430 for (handles::const_iterator vol=volumes.begin(); vol!=volumes.end();
433 if (interpolators.find((*vol)->magFile)!=interpolators.end()) {
434 mp = interpolators[(*vol)->magFile];
436 cout <<
"No interpolator found for file " << (*vol)->magFile
437 <<
" vol: " << (*vol)->name << endl;
438 cout << interpolators.size() <<endl;
445 string name = (*vol)->name;
446 name.erase(0,name.rfind(
'_')+1);
456 int key = volNum*100+(*vol)->copyno;
467 edm::LogInfo(
"MagneticField|VolumeBasedMagneticFieldESProducer") <<
"Applying scaling factor " << sf <<
" to "<< (*vol)->name <<
"["<< (*vol)->copyno <<
"] (key:" << key <<
")" << endl;
477 if ((*vol)->copyno==(*vol)->masterSector) {
481 (*vol)->magVolume->setIsIron((*vol)->isIron());
484 (*vol)->magVolume->name = (*vol)->name;
485 (*vol)->magVolume->copyno = (*vol)->copyno;
496 cout <<
"Building interpolator from "
498 <<
" at " << vol->
center()
504 cout <<
"***WARNING wrong sector? " << endl;
519 cerr <<
"MagGeoBuilderFromDDD: exception in reading table; " << exc.
what() << endl;
551 interpolators.erase(vol->
magFile);
569 cout <<
"Grid has 3 dimensions "
570 <<
" number of nodes is " << sizes.
w <<
" " << sizes.
h
571 <<
" " << sizes.
d << endl;
573 const double tolerance = 0.03;
576 size_t dumpCount = 0;
577 for (
int j=0;
j < sizes.
h;
j++) {
578 for (
int k=0;
k < sizes.
d;
k++) {
579 for (
int i=0;
i < sizes.
w;
i++) {
581 if (! tempVolume.inside(lp, tolerance)) {
582 if (++dumpCount < 2) {
584 cout <<
"GRID ERROR: " <<
i <<
" " <<
j <<
" " <<
k
587 <<
" R= " << gp.perp() <<
" phi=" << gp.phi() << endl;
594 cout << vol->
name <<
" : Number of grid points outside the MagVolume: " << dumpCount <<
"/" << sizes.
w*sizes.
h*sizes.
d << endl;
603 cout <<
"--------------------------------------------------" << endl;
604 cout <<
" inside(center) test" << endl;
605 for (handles::const_iterator vol=volumes.begin(); vol!=volumes.end();
607 for (handles::const_iterator
i=volumes.begin();
i!=volumes.end();
609 if ((*
i)==(*vol))
continue;
611 if ((*i)->magVolume->inside((*vol)->center())) {
612 cout <<
"*** ERROR: center of " << (*vol)->name <<
" is inside "
613 << (*i)->name <<endl;
617 if ((*vol)->magVolume->inside((*vol)->center())) {
618 cout << (*vol)->name <<
" OK " << endl;
620 cout <<
"*** ERROR: center of volume is not inside it, "
621 << (*vol)->name << endl;
624 cout <<
"--------------------------------------------------" << endl;
637 vector<MagVolume6Faces*>
v;
639 for (handles::const_iterator
i=
bVolumes.begin();
641 v.push_back((*i)->magVolume);
647 vector<MagVolume6Faces*>
v;
649 for (handles::const_iterator
i=
eVolumes.begin();
651 v.push_back((*i)->magVolume);
671 std::vector<double>
values)
673 if (keys.size() != values.size()) {
674 throw cms::Exception(
"InvalidParameter") <<
"Invalid field scaling parameters 'scalingVolumes' and 'scalingFactors' ";
676 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.
MagGeoBuilderFromDDD(std::string tableSet_, bool debug=false, bool overrideMasterSector=false)
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.
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)