CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends
MagGeoBuilderFromDDD Class Reference

#include <MagGeoBuilderFromDDD.h>

Classes

class  bLayer
 
class  bRod
 
class  bSector
 
class  bSlab
 
class  eLayer
 
class  eSector
 
struct  ExtractAbsZ
 
struct  ExtractPhi
 
struct  ExtractPhiMax
 
struct  ExtractR
 
struct  ExtractRN
 
struct  ExtractZ
 
struct  LessDPhi
 
struct  LessZ
 
class  volumeHandle
 

Public Member Functions

std::vector< MagBLayer * > barrelLayers () const
 Get barrel layers. More...
 
std::vector< MagESector * > endcapSectors () const
 Get endcap layers. More...
 
 MagGeoBuilderFromDDD (std::string version_, bool debug=false, bool overrideMasterSector=false)
 
float maxR () const
 
float maxZ () const
 
void setScaling (std::vector< int > keys, std::vector< double > values)
 
virtual ~MagGeoBuilderFromDDD ()
 Destructor. More...
 

Private Types

typedef std::vector
< volumeHandle * > 
handles
 
typedef
ConstReferenceCountingPointer
< Surface
RCPS
 
typedef std::unary_function
< const volumeHandle *, double > 
uFcn
 

Private Member Functions

std::vector< MagVolume6Faces * > barrelVolumes () const
 
virtual void build (const DDCompactView &cpv)
 
void buildInterpolator (const volumeHandle *vol, std::map< std::string, MagProviderInterpol * > &interpolators)
 
void buildMagVolumes (const handles &volumes, std::map< std::string, MagProviderInterpol * > &interpolators)
 
std::vector< MagVolume6Faces * > endcapVolumes () const
 
void summary (handles &volumes)
 
void testInside (handles &volumes)
 

Private Attributes

handles bVolumes
 
handles eVolumes
 
std::vector< MagBLayer * > mBLayers
 
std::vector< MagESector * > mESectors
 
bool overrideMasterSector
 
std::map< int, double > theScalingFactors
 
std::string version
 

Static Private Attributes

static bool debug
 

Friends

class MagGeometry
 
class magneticfield::AutoMagneticFieldESProducer
 
class magneticfield::VolumeBasedMagneticFieldESProducer
 
class TestMagVolume
 

Detailed Description

Parse the XML magnetic geometry, build individual volumes and match their shared surfaces. Build MagVolume6Faces and organise them in a hierarchical structure. Build MagGeometry out of it.

Date:
2009/01/21 12:05:14
Revision:
1.11
Author
N. Amapane - INFN Torino

Definition at line 32 of file MagGeoBuilderFromDDD.h.

Member Typedef Documentation

typedef std::vector<volumeHandle*> MagGeoBuilderFromDDD::handles
private

Definition at line 78 of file MagGeoBuilderFromDDD.h.

Definition at line 60 of file MagGeoBuilderFromDDD.h.

typedef std::unary_function<const volumeHandle*, double> MagGeoBuilderFromDDD::uFcn
private

Definition at line 106 of file MagGeoBuilderFromDDD.h.

Constructor & Destructor Documentation

MagGeoBuilderFromDDD::MagGeoBuilderFromDDD ( std::string  version_,
bool  debug = false,
bool  overrideMasterSector = false 
)

Constructor. overrideMasterSector is a hack to allow switching between phi-symmetric maps and maps with sector-specific tables. It won't be necessary anymore once the geometry is decoupled from the specification of tables, ie when tables will come from the DB.

Definition at line 60 of file MagGeoBuilderFromDDD.cc.

References gather_cfg::cout, and debug.

60  :
61  version (version_),
62  overrideMasterSector(overrideMasterSector_)
63 {
64  debug = debug_;
65  if (debug) cout << "Constructing a MagGeoBuilderFromDDD" <<endl;
66 }
tuple cout
Definition: gather_cfg.py:41
MagGeoBuilderFromDDD::~MagGeoBuilderFromDDD ( )
virtual

Destructor.

Definition at line 68 of file MagGeoBuilderFromDDD.cc.

References bVolumes, eVolumes, and i.

68  {
69  for (handles::const_iterator i=bVolumes.begin();
70  i!=bVolumes.end(); ++i){
71  delete (*i);
72  }
73 
74  for (handles::const_iterator i=eVolumes.begin();
75  i!=eVolumes.end(); ++i){
76  delete (*i);
77  }
78 }
int i
Definition: DBlmapReader.cc:9

Member Function Documentation

vector< MagBLayer * > MagGeoBuilderFromDDD::barrelLayers ( ) const

Get barrel layers.

Definition at line 640 of file MagGeoBuilderFromDDD.cc.

References mBLayers.

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

640  {
641  return mBLayers;
642 }
std::vector< MagBLayer * > mBLayers
vector< MagVolume6Faces * > MagGeoBuilderFromDDD::barrelVolumes ( ) const
private

Definition at line 648 of file MagGeoBuilderFromDDD.cc.

References bVolumes, i, and v.

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

648  {
649  vector<MagVolume6Faces*> v;
650  v.reserve(bVolumes.size());
651  for (handles::const_iterator i=bVolumes.begin();
652  i!=bVolumes.end(); ++i){
653  v.push_back((*i)->magVolume);
654  }
655  return v;
656 }
int i
Definition: DBlmapReader.cc:9
mathSSE::Vec4< T > v
void MagGeoBuilderFromDDD::build ( const DDCompactView cpv)
privatevirtual

Definition at line 126 of file MagGeoBuilderFromDDD.cc.

References buildInterpolator(), buildMagVolumes(), bVolumes, MagGeoBuilderFromDDD::volumeHandle::center(), ClusterizingHistogram::clusterize(), MagGeoBuilderFromDDD::volumeHandle::copyno, gather_cfg::cout, debug, eVolumes, edm::hlt::Exception, f, ClusterizingHistogram::fill(), first, DDExpandedView::firstChild(), DDExpandedView::geoHistory(), i, prof2calltree::last, DDExpandedView::logicalPart(), MagGeoBuilderFromDDD::volumeHandle::magFile, MagGeoBuilderFromDDD::volumeHandle::masterSector, mBLayers, mESectors, DDName::name(), mergeVDriftHistosByStation::name, DDBase< N, C >::name(), DDExpandedView::nextSibling(), evf::evtn::offset(), overrideMasterSector, PV3DBase< T, PVType, FrameType >::perp(), precomputed_value_sort(), dttmaxenums::R, dtT0WireCalibration_cfg::resolution, DDExpandedView::rotation(), mergeVDriftHistosByStation::sectors, findQualityFiles::size, summary(), testInside(), DDExpandedView::translation(), v, Gflash::Z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

127 {
128 // DDCompactView cpv;
129  DDExpandedView fv(cpva);
130 
131  if (debug) cout << "**********************************************************" <<endl;
132 
133  // The actual field interpolators
134  map<string, MagProviderInterpol*> bInterpolators;
135  map<string, MagProviderInterpol*> eInterpolators;
136 
137  // Counter of different volumes
138  int bVolCount = 0;
139  int eVolCount = 0;
140 
141  if (fv.logicalPart().name().name()!="MAGF") {
142  std::string topNodeName(fv.logicalPart().name().name());
143 
144  //see if one of the children is MAGF
145  bool doSubDets = fv.firstChild();
146 
147  bool go=true;
148  while(go&& doSubDets) {
149  if (fv.logicalPart().name().name()=="MAGF")
150  break;
151  else
152  go = fv.nextSibling();
153  }
154  if (!go) {
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<<"\"";
156  }
157  }
158  // Loop over MAGF volumes and create volumeHandles.
159  if (debug) { cout << endl << "*** MAGF: " << fv.geoHistory() << endl
160  << "translation: " << fv.translation() << endl
161  << " rotation: " << fv.rotation() << endl;
162  }
163 
164  bool doSubDets = fv.firstChild();
165  while (doSubDets){
166 
167  string name = fv.logicalPart().name().name();
168  if (debug) cout << endl << "Name: " << name << endl
169  << " " << fv.geoHistory() <<endl;
170 
171  // FIXME: special handling of version 85l_030919. This version is no
172  // longer supported and special handling for it may not work
173  // anymore - it will eventually be removed.
174  // Build only the z-negative volumes, assuming symmetry
175  if (name.substr(2,2)=="ZP") {
176  doSubDets = fv.nextSibling();
177  continue;
178  }
179 
180  // FIXME: single-volyme cylinders - this is feature has been removed
181  // and should be revisited.
182  // bool mergeCylinders=false;
183 
184  // If true, In the barrel, cylinders sectors will be skipped to build full
185  // cylinders out of sector copyno #1.
186  bool expand = false;
187 
188 // if (mergeCylinders) {
189 // if (name == "V_ZN_1"
190 // || name == "V_ZN_2") {
191 // if (debug && fv.logicalPart().solid().shape()!=ddtubs) {
192 // cout << "ERROR: MagGeoBuilderFromDDD::build: volume " << name
193 // << " should be a cylinder" << endl;
194 // }
195 // if(fv.copyno()==1) {
196 // expand = true;
197 // } else {
198 // //cout << "... to be skipped: "
199 // // << name << " " << fv.copyno() << endl;
200 // }
201 // }
202 // }
203 
204  volumeHandle* v = new volumeHandle(fv, expand);
205  //FIXME: overrideMasterSector is a hack to allow switching between
206  // phi-symmetric maps and maps with sector-specific tables.
207  // It won't be necessary anymore once the geometry is decoupled from
208  // the specification of tables, ie when tables will come from the DB.
209  if (overrideMasterSector && v->masterSector!=1) {
210  v->masterSector=1;
211  std::string::size_type ibeg, iend;
212  ibeg = (v->magFile).rfind('/');
213  iend = (v->magFile).size();
214  v->magFile = (v->magFile).substr(ibeg+1,iend-ibeg-1);
215  }
216 
217  // Select volumes, build volume handles.
218  float Z = v->center().z();
219  float R = v->center().perp();
220 
221  // v 85l: Barrel is everything up to |Z| = 661.0, excluding
222  // volume #7, centered at 6477.5
223  // v 1103l: same numbers work fine. #16 instead of #7, same coords;
224  // see comment below for V6,7
225  //ASSUMPTION: no misalignment is applied to mag volumes.
226  //FIXME: implement barrel/endcap flags as DDD SpecPars.
227  if ((fabs(Z)<647. || (R>350. && fabs(Z)<662.)) &&
228  !(fabs(Z)>480 && R<172) // in 1103l we place V_6 and V_7 in the
229  // endcaps to preserve nice layer structure
230  // in the barrel. This does not hurt in v85l
231  // where there is a single V1
232  ) { // Barrel
233  if (debug) cout << " (Barrel)" <<endl;
234  bVolumes.push_back(v);
235 
236 
237  // Build the interpolator of the "master" volume (the one which is
238  // not replicated in phi)
239  // ASSUMPTION: copyno == sector.
240  // Note this is not the case for obsolete grid_85l_030919 -
241  // In case in future models this should no more be the case, can
242  // implement secotor numbers as SpecPars in the XML
243  if (v->copyno==v->masterSector) {
244  buildInterpolator(v, bInterpolators);
245  ++bVolCount;
246  }
247  } else { // Endcaps
248  if (debug) cout << " (Endcaps)" <<endl;
249  eVolumes.push_back(v);
250  if (v->copyno==v->masterSector) {
251  buildInterpolator(v, eInterpolators);
252  ++eVolCount;
253  }
254  }
255 
256  doSubDets = fv.nextSibling(); // end of loop over MAGF
257  }
258 
259  if (debug) {
260  cout << "Number of volumes (barrel): " << bVolumes.size() <<endl
261  << "Number of volumes (endcap): " << eVolumes.size() <<endl;
262  cout << "**********************************************************" <<endl;
263  }
264 
265  // Now all volumeHandles are there, and parameters for each of the planes
266  // are calculated.
267 
268  //----------------------------------------------------------------------
269  // Print summary information
270 
271  if (debug) {
272  cout << "-----------------------" << endl;
273  cout << "SUMMARY: Barrel " << endl;
274  summary(bVolumes);
275 
276  cout << endl << "SUMMARY: Endcaps " << endl;
277  summary(eVolumes);
278  cout << "-----------------------" << endl;
279  }
280 
281 
282  //----------------------------------------------------------------------
283  // Find barrel layers.
284 
285  vector<bLayer> layers; // the barrel layers
286  precomputed_value_sort(bVolumes.begin(), bVolumes.end(), ExtractRN());
287 
288  // Find the layers (in R)
289  const float resolution = 1.; // cm
290  float rmin = bVolumes.front()->RN()-resolution;
291  float rmax = bVolumes.back()->RN()+resolution;
292  ClusterizingHistogram hisR( int((rmax-rmin)/resolution) + 1, rmin, rmax);
293 
294  if (debug) cout << " R layers: " << rmin << " " << rmax << endl;
295 
296  handles::const_iterator first = bVolumes.begin();
297  handles::const_iterator last = bVolumes.end();
298 
299  for (handles::const_iterator i=first; i!=last; ++i){
300  hisR.fill((*i)->RN());
301  }
302  vector<float> rClust = hisR.clusterize(resolution);
303 
304  handles::const_iterator ringStart = first;
305  handles::const_iterator separ = first;
306 
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;
311 
312  bLayer thislayer(ringStart, separ);
313  layers.push_back(thislayer);
314  ringStart = separ;
315  }
316  {
317  if (debug) cout << " Layer at RN = " << rClust.back();
318  bLayer thislayer(separ, last);
319  layers.push_back(thislayer);
320  }
321 
322  if (debug) cout << "Barrel: Found " << rClust.size() << " clusters in R, "
323  << layers.size() << " layers " << endl << endl;
324 
325 
326  //----------------------------------------------------------------------
327  // Find endcap sectors
328 
329  vector<eSector> sectors; // the endcap sectors
330  precomputed_value_sort(eVolumes.begin(), eVolumes.end(), ExtractPhi());
331 
332 
333  // ASSUMPTION: There are 12 sectors and each sector is 30 deg wide.
334  for (int i = 0; i<12; ++i) {
335  int offset = eVolumes.size()/12;
336  // int isec = (i+binOffset)%12;
337  if (debug) cout << " Sector at phi = "
338  << (*(eVolumes.begin()+((i)*offset)))->center().phi()
339  << endl;
340  sectors.push_back(eSector(eVolumes.begin()+((i)*offset),
341  eVolumes.begin()+((i+1)*offset)));
342  }
343 
344  if (debug) cout << "Endcap: Found "
345  << sectors.size() << " sectors " << endl;
346 
347 
348  //----------------------------------------------------------------------
349  // Match surfaces.
350 
351 // cout << "------------------" << endl << "Now associating planes..." << endl;
352 
353 // // Loop on layers
354 // for (vector<bLayer>::const_iterator ilay = layers.begin();
355 // ilay!= layers.end(); ++ilay) {
356 // cout << "On Layer: " << ilay-layers.begin() << " RN: " << (*ilay).RN()
357 // <<endl;
358 
359 // // Loop on wheels
360 // for (vector<bWheel>::const_iterator iwheel = (*ilay).wheels.begin();
361 // iwheel != (*ilay).wheels.end(); ++iwheel) {
362 // cout << " On Wheel: " << iwheel- (*ilay).wheels.begin()<< " Z: "
363 // << (*iwheel).minZ() << " " << (*iwheel).maxZ() << " "
364 // << ((*iwheel).minZ()+(*iwheel).maxZ())/2. <<endl;
365 
366 // // Loop on sectors.
367 // for (int isector = 0; isector<12; ++isector) {
368 // // FIXME: create new constructor...
369 // bSectorNavigator navy(layers,
370 // ilay-layers.begin(),
371 // iwheel-(*ilay).wheels.begin(),isector);
372 
373 // const bSector & isect = (*iwheel).sector(isector);
374 
375 // isect.matchPlanes(navy); //FIXME refcount
376 // }
377 // }
378 // }
379 
380 
381  //----------------------------------------------------------------------
382  // Build MagVolumes and the MagGeometry hierarchy.
383 
384  //--- Barrel
385 
386  // Build MagVolumes and associate interpolators to them
387  buildMagVolumes(bVolumes, bInterpolators);
388 
389  // Build MagBLayers
390  for (vector<bLayer>::const_iterator ilay = layers.begin();
391  ilay!= layers.end(); ++ilay) {
392  mBLayers.push_back((*ilay).buildMagBLayer());
393  }
394 
395  if (debug) {
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;
400 
401  testInside(bVolumes); // FIXME: all volumes should be checked in one go.
402  }
403 
404  //--- Endcap
405  // Build MagVolumes and associate interpolators to them
406  buildMagVolumes(eVolumes, eInterpolators);
407 
408  // Build the MagESectors
409  for (vector<eSector>::const_iterator isec = sectors.begin();
410  isec!= sectors.end(); ++isec) {
411  mESectors.push_back((*isec).buildMagESector());
412  }
413 
414  if (debug) {
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;
419 
420  testInside(eVolumes); // FIXME: all volumes should be checked in one go.
421  }
422 }
const double Z[kNumberCalorimeter]
std::vector< MagBLayer * > mBLayers
int i
Definition: DBlmapReader.cc:9
uint16_t size_type
void summary(handles &volumes)
void testInside(handles &volumes)
double f[11][100]
unsigned int offset(bool)
bool first
Definition: L1TdeRCT.cc:79
void buildInterpolator(const volumeHandle *vol, std::map< std::string, MagProviderInterpol * > &interpolators)
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr)
tuple cout
Definition: gather_cfg.py:41
std::vector< MagESector * > mESectors
Provides an exploded view of the detector (tree-view)
void buildMagVolumes(const handles &volumes, std::map< std::string, MagProviderInterpol * > &interpolators)
tuple size
Write out results.
mathSSE::Vec4< T > v
void MagGeoBuilderFromDDD::buildInterpolator ( const volumeHandle vol,
std::map< std::string, MagProviderInterpol * > &  interpolators 
)
private

Definition at line 487 of file MagGeoBuilderFromDDD.cc.

References MFGridFactory::build(), MagGeoBuilderFromDDD::volumeHandle::center(), benchmark_cfg::cerr, MagGeoBuilderFromDDD::volumeHandle::copyno, gather_cfg::cout, Dimensions::d, debug, edm::FileInPath::fullPath(), Dimensions::h, i, j, gen::k, MagGeoBuilderFromDDD::volumeHandle::magFile, MagGeoBuilderFromDDD::volumeHandle::masterSector, MagGeoBuilderFromDDD::volumeHandle::name, PV3DBase< T, PVType, FrameType >::phi(), Geom::pi(), MagGeoBuilderFromDDD::volumeHandle::placement(), GloballyPositioned< T >::position(), GloballyPositioned< T >::rotation(), MagGeoBuilderFromDDD::volumeHandle::shape(), MagGeoBuilderFromDDD::volumeHandle::sides(), MagGeoBuilderFromDDD::volumeHandle::toExpand(), version, Dimensions::w, MagException::what(), cms::Exception::what(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by build().

487  {
488 
489 
490  // FIXME: special handling of version 85l_030919. This version is no
491  // longer supported and special handling for it may not work
492  // anymore - it will eventually be removed.
493  // In version grid_85l_030919, interpolators should be built only
494  // for volumes on NEGATIVE z
495  // (Z symmetry in field tables)
496  if (version=="grid_85l_030919" && vol->center().z()>0) return;
497 
498  // Phi of the master sector
499  double masterSectorPhi = (vol->masterSector-1)*Geom::pi()/6.;
500  //FIXME: special handling of version 85l_030919 (see FIXME above).
501  // In ver. grid_85l_030919, the master sector was sector 4
502  // (along Y axis).
503  if (version=="grid_85l_030919") {
504  masterSectorPhi=Geom::pi()/2.;
505  }
506 
507  if (debug) {
508  cout << "Building interpolator from "
509  << vol->name << " copyno " << vol->copyno
510  << " at " << vol->center()
511  << " phi: " << vol->center().phi()
512  << " file: " << vol->magFile
513  << endl;
514 
515  if ( fabs(vol->center().phi() - masterSectorPhi) > Geom::pi()/9.) {
516  cout << "***WARNING wrong sector? " << endl;
517  }
518  }
519 
520  if (version == "fake") {
521  interpolators[vol->magFile] = new magneticfield::FakeInterpolator();
522  return;
523  }
524 
525  string fullPath;
526 
527  try {
528  edm::FileInPath mydata("MagneticField/Interpolation/data/"+version+"/"+vol->magFile);
529  fullPath = mydata.fullPath();
530  } catch (edm::Exception& exc) {
531  cerr << "MagGeoBuilderFromDDD: exception in reading table; " << exc.what() << endl;
532  if (!debug) throw;
533  return;
534  }
535 
536 
537  try{
538  if (vol->toExpand()){
539  //FIXME: see discussion on mergeCylinders above.
540 // interpolators[vol->magFile] =
541 // MFGridFactory::build( fullPath, *(vol->placement()), vol->minPhi(), vol->maxPhi());
542  } else {
543  // If the table is in "local" coordinates, must create a reference
544  // frame that is appropriately rotated along the CMS Z axis.
545 
546  GloballyPositioned<float> rf = *(vol->placement());
547 
548  if (vol->masterSector != 1) {
550 
551  GloballyPositioned<float>::RotationType rot(Vector(0,0,1), -masterSectorPhi);
552  Vector vpos(vol->placement()->position());
553 
554 
555  rf = GloballyPositioned<float>(GloballyPositioned<float>::PositionType(rot.multiplyInverse(vpos)), vol->placement()->rotation()*rot);
556  }
557 
558  interpolators[vol->magFile] =
559  MFGridFactory::build( fullPath, rf);
560  }
561  } catch (MagException& exc) {
562  cout << exc.what() << endl;
563  interpolators.erase(vol->magFile);
564  if (!debug) throw;
565  return;
566  }
567 
568 
569  if (debug) {
570  // Check that all grid points of the interpolator are inside the volume.
571  const MagVolume6Faces tempVolume(vol->placement()->position(),
572  vol->placement()->rotation(),
573  vol->shape(),
574  vol->sides(),
575  interpolators[vol->magFile]);
576 
577  const MFGrid3D* grid = dynamic_cast<const MFGrid3D*>(interpolators[vol->magFile]);
578  if (grid!=0) {
579 
580  Dimensions sizes = grid->dimensions();
581  cout << "Grid has 3 dimensions "
582  << " number of nodes is " << sizes.w << " " << sizes.h
583  << " " << sizes.d << endl;
584 
585  const double tolerance = 0.03;
586 
587 
588  int dumpCount = 0;
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++) {
592  MFGrid::LocalPoint lp = grid->nodePosition( i, j, k);
593  if (! tempVolume.inside(lp, tolerance)) {
594  if (++dumpCount < 2) {
595  MFGrid::GlobalPoint gp = tempVolume.toGlobal(lp);
596  cout << "GRID ERROR: " << i << " " << j << " " << k
597  << " local: " << lp
598  << " global: " << gp
599  << " R= " << gp.perp() << " phi=" << gp.phi() << endl;
600  }
601  }
602  }
603  }
604  }
605 
606  cout << vol->name << " : Number of grid points outside the MagVolume: " << dumpCount << "/" << sizes.w*sizes.h*sizes.d << endl;
607  }
608  }
609 }
virtual char const * what() const
Definition: Exception.cc:97
int i
Definition: DBlmapReader.cc:9
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:28
GloballyPositioned< float >::LocalPoint LocalPoint
Definition: MFGrid.h:36
int w
Definition: MFGrid.h:19
virtual const char * what() const
Definition: MagExceptions.cc:6
int j
Definition: DBlmapReader.cc:9
static MFGrid * build(const std::string &name, const GloballyPositioned< float > &vol)
Build interpolator for a binary grid file.
int k[5][pyjets_maxn]
GloballyPositioned< float >::GlobalPoint GlobalPoint
Definition: MFGrid.h:34
int d
Definition: MFGrid.h:21
int h
Definition: MFGrid.h:20
Point3DBase< T, GlobalTag > PositionType
double pi()
Definition: Pi.h:31
tuple cout
Definition: gather_cfg.py:41
void MagGeoBuilderFromDDD::buildMagVolumes ( const handles volumes,
std::map< std::string, MagProviderInterpol * > &  interpolators 
)
private

Definition at line 425 of file MagGeoBuilderFromDDD.cc.

References gather_cfg::cout, combine::key, mergeVDriftHistosByStation::name, MagVolume::ownsFieldProvider(), GloballyPositioned< T >::position(), GloballyPositioned< T >::rotation(), and theScalingFactors.

Referenced by build().

425  {
426  // Build all MagVolumes setting the MagProviderInterpol
427  for (handles::const_iterator vol=volumes.begin(); vol!=volumes.end();
428  ++vol){
429  const MagProviderInterpol* mp = 0;
430  if (interpolators.find((*vol)->magFile)!=interpolators.end()) {
431  mp = interpolators[(*vol)->magFile];
432  } else {
433  cout << "No interpolator found for file " << (*vol)->magFile
434  << " vol: " << (*vol)->name << endl;
435  cout << interpolators.size() <<endl;
436  }
437 
438 
439  // Get the volume number from the volume name.
440  // ASSUMPTION: volume names ends with "_NUM" where NUM is the volume number
441  int volNum;
442  string name = (*vol)->name;
443  name.erase(0,name.rfind('_')+1);
444  stringstream str;
445  str << name;
446  str >> volNum;
447 
448 
449  // ASSUMPTION: copyno == sector.
450  // Note this is not the case for obsolete grid_85l_030919 -
451  // In case in future models this should no more be the case, can
452  // implement secotor numbers as SpecPars in the XML
453  int key = volNum*100+(*vol)->copyno;
454  map<int, double>::const_iterator isf = theScalingFactors.find(key);
455  if (isf == theScalingFactors.end()) {
456  key = volNum*100;
457  isf = theScalingFactors.find(key);
458  }
459 
460  double sf = 1.;
461  if (isf != theScalingFactors.end()) {
462  sf = (*isf).second;
463 
464  edm::LogInfo("MagneticField|VolumeBasedMagneticFieldESProducer") << "Applying scaling factor " << sf << " to "<< (*vol)->name << "["<< (*vol)->copyno << "] (key:" << key << ")" << endl;
465  }
466 
467  const GloballyPositioned<float> * gpos = (*vol)->placement();
468  (*vol)->magVolume = new MagVolume6Faces(gpos->position(),
469  gpos->rotation(),
470  (*vol)->shape(),
471  (*vol)->sides(),
472  mp, sf);
473 
474  if ((*vol)->copyno==(*vol)->masterSector) {
475  (*vol)->magVolume->ownsFieldProvider(true);
476  }
477 
478  (*vol)->magVolume->setIsIron((*vol)->isIron());
479 
480  // The name and sector of the volume are saved for debug purposes only. They may be removed at some point...
481  (*vol)->magVolume->name = (*vol)->name;
482  (*vol)->magVolume->copyno = (*vol)->copyno;
483  }
484 }
list key
Definition: combine.py:13
const RotationType & rotation() const
tuple cout
Definition: gather_cfg.py:41
const PositionType & position() const
std::map< int, double > theScalingFactors
void ownsFieldProvider(bool o)
Definition: MagVolume.h:53
vector< MagESector * > MagGeoBuilderFromDDD::endcapSectors ( ) const

Get endcap layers.

Definition at line 644 of file MagGeoBuilderFromDDD.cc.

References mESectors.

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

644  {
645  return mESectors;
646 }
std::vector< MagESector * > mESectors
vector< MagVolume6Faces * > MagGeoBuilderFromDDD::endcapVolumes ( ) const
private

Definition at line 658 of file MagGeoBuilderFromDDD.cc.

References eVolumes, i, and v.

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

658  {
659  vector<MagVolume6Faces*> v;
660  v.reserve(eVolumes.size());
661  for (handles::const_iterator i=eVolumes.begin();
662  i!=eVolumes.end(); ++i){
663  v.push_back((*i)->magVolume);
664  }
665  return v;
666 }
int i
Definition: DBlmapReader.cc:9
mathSSE::Vec4< T > v
float MagGeoBuilderFromDDD::maxR ( ) const

Definition at line 669 of file MagGeoBuilderFromDDD.cc.

References version.

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

669  {
670  //FIXME: should get it from the actual geometry - MAGF is an option,
671  // but that is not changed together the geometry itself
672  // (it lives in cmsMagneticField.xml in CMSCommonData)
673  if (version=="grid_85l_030919") return 1000.;
674  else return 900.;
675 }
float MagGeoBuilderFromDDD::maxZ ( ) const

Definition at line 677 of file MagGeoBuilderFromDDD.cc.

Referenced by MagGeoBuilderFromDDD::bSector::bSector(), and magneticfield::VolumeBasedMagneticFieldESProducer::produce().

677  {
678  //FIXME: should get it from the actual geometry - see above
679  return 1600.;
680 }
void MagGeoBuilderFromDDD::setScaling ( std::vector< int >  keys,
std::vector< double >  values 
)

Set scaling factors for individual volumes. "keys" is a vector of 100*volume number + sector (sector 0 = all sectors) "values" are the corresponding scaling factors

Definition at line 683 of file MagGeoBuilderFromDDD.cc.

References edm::hlt::Exception, i, and theScalingFactors.

Referenced by magneticfield::VolumeBasedMagneticFieldESProducer::produce().

685 {
686  if (keys.size() != values.size()) {
687  throw cms::Exception("InvalidParameter") << "Invalid field scaling parameters 'scalingVolumes' and 'scalingFactors' ";
688  }
689  for (unsigned int i=0; i<keys.size(); ++i) {
691  }
692 }
int i
Definition: DBlmapReader.cc:9
std::map< int, double > theScalingFactors
void MagGeoBuilderFromDDD::summary ( handles volumes)
private

Definition at line 81 of file MagGeoBuilderFromDDD.cc.

References gather_cfg::cout, first, i, prof2calltree::last, and edm::second().

Referenced by build().

81  {
82  // The final countdown.
83  int ivolumes = volumes.size(); // number of volumes
84  int isurfaces = ivolumes*6; // number of individual surfaces
85  int iassigned = 0; // How many have been assigned
86  int iunique = 0; // number of unique surfaces
87  int iref_ass = 0;
88  int iref_nass = 0;
89 
90  set<const void *> ptrs;
91 
92  handles::const_iterator first = volumes.begin();
93  handles::const_iterator last = volumes.end();
94 
95  for (handles::const_iterator i=first; i!=last; ++i){
96  if (int((*i)->shape())>4) continue; // FIXME: implement test for missing shapes...
97  for (int side = 0; side < 6; ++side) {
98  int references = (*i)->references(side);
99  if ((*i)->isPlaneMatched(side)) {
100  ++iassigned;
101  bool firstOcc = (ptrs.insert(&((*i)->surface(side)))).second;
102  if (firstOcc) iref_ass+=references;
103  if (references<2){
104  cout << "*** Only 1 ref, vol: " << (*i)->name << " # "
105  << (*i)->copyno << " side: " << side << endl;
106  }
107  } else {
108  iref_nass+=references;
109  if (references>1){
110  cout << "*** Ref_nass >1 " <<endl;
111  }
112  }
113  }
114  }
115  iunique = ptrs.size();
116 
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;
123 }
int i
Definition: DBlmapReader.cc:9
U second(std::pair< T, U > const &p)
bool first
Definition: L1TdeRCT.cc:79
tuple cout
Definition: gather_cfg.py:41
void MagGeoBuilderFromDDD::testInside ( handles volumes)
private

Definition at line 613 of file MagGeoBuilderFromDDD.cc.

References gather_cfg::cout, and i.

Referenced by build().

613  {
614  // test inside() for all volumes.
615  cout << "--------------------------------------------------" << endl;
616  cout << " inside(center) test" << endl;
617  for (handles::const_iterator vol=volumes.begin(); vol!=volumes.end();
618  ++vol){
619  for (handles::const_iterator i=volumes.begin(); i!=volumes.end();
620  ++i){
621  if ((*i)==(*vol)) continue;
622  //if ((*i)->magVolume == 0) continue;
623  if ((*i)->magVolume->inside((*vol)->center())) {
624  cout << "*** ERROR: center of " << (*vol)->name << " is inside "
625  << (*i)->name <<endl;
626  }
627  }
628 
629  if ((*vol)->magVolume->inside((*vol)->center())) {
630  cout << (*vol)->name << " OK " << endl;
631  } else {
632  cout << "*** ERROR: center of volume is not inside it, "
633  << (*vol)->name << endl;
634  }
635  }
636  cout << "--------------------------------------------------" << endl;
637 }
int i
Definition: DBlmapReader.cc:9
tuple cout
Definition: gather_cfg.py:41

Friends And Related Function Documentation

friend class MagGeometry
friend

Definition at line 69 of file MagGeoBuilderFromDDD.h.

Definition at line 71 of file MagGeoBuilderFromDDD.h.

Definition at line 70 of file MagGeoBuilderFromDDD.h.

friend class TestMagVolume
friend

Definition at line 68 of file MagGeoBuilderFromDDD.h.

Member Data Documentation

handles MagGeoBuilderFromDDD::bVolumes
private

Definition at line 119 of file MagGeoBuilderFromDDD.h.

Referenced by barrelVolumes(), build(), and ~MagGeoBuilderFromDDD().

bool MagGeoBuilderFromDDD::debug
staticprivate
handles MagGeoBuilderFromDDD::eVolumes
private

Definition at line 122 of file MagGeoBuilderFromDDD.h.

Referenced by build(), endcapVolumes(), and ~MagGeoBuilderFromDDD().

std::vector<MagBLayer*> MagGeoBuilderFromDDD::mBLayers
private

Definition at line 124 of file MagGeoBuilderFromDDD.h.

Referenced by barrelLayers(), and build().

std::vector<MagESector*> MagGeoBuilderFromDDD::mESectors
private

Definition at line 125 of file MagGeoBuilderFromDDD.h.

Referenced by build(), and endcapSectors().

bool MagGeoBuilderFromDDD::overrideMasterSector
private

Definition at line 131 of file MagGeoBuilderFromDDD.h.

Referenced by build().

std::map<int, double> MagGeoBuilderFromDDD::theScalingFactors
private

Definition at line 129 of file MagGeoBuilderFromDDD.h.

Referenced by buildMagVolumes(), and setScaling().

std::string MagGeoBuilderFromDDD::version
private

Definition at line 127 of file MagGeoBuilderFromDDD.h.

Referenced by buildInterpolator(), and maxR().