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 tableSet_, 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
 
int geometryVersion
 
std::vector< MagBLayer * > mBLayers
 
std::vector< MagESector * > mESectors
 
bool overrideMasterSector
 
std::string tableSet
 
std::map< int, double > theScalingFactors
 

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:
2010/10/13 15:26:09
Revision:
1.13
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  tableSet_,
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  tableSet (tableSet_),
62  geometryVersion(0),
63  overrideMasterSector(overrideMasterSector_)
64 {
65  debug = debug_;
66  if (debug) cout << "Constructing a MagGeoBuilderFromDDD" <<endl;
67 }
tuple cout
Definition: gather_cfg.py:121
MagGeoBuilderFromDDD::~MagGeoBuilderFromDDD ( )
virtual

Destructor.

Definition at line 69 of file MagGeoBuilderFromDDD.cc.

References bVolumes, eVolumes, and i.

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

Member Function Documentation

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

Get barrel layers.

Definition at line 628 of file MagGeoBuilderFromDDD.cc.

References mBLayers.

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

628  {
629  return mBLayers;
630 }
std::vector< MagBLayer * > mBLayers
vector< MagVolume6Faces * > MagGeoBuilderFromDDD::barrelVolumes ( ) const
private

Definition at line 636 of file MagGeoBuilderFromDDD.cc.

References bVolumes, i, and v.

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

636  {
637  vector<MagVolume6Faces*> v;
638  v.reserve(bVolumes.size());
639  for (handles::const_iterator i=bVolumes.begin();
640  i!=bVolumes.end(); ++i){
641  v.push_back((*i)->magVolume);
642  }
643  return v;
644 }
int i
Definition: DBlmapReader.cc:9
mathSSE::Vec4< T > v
void MagGeoBuilderFromDDD::build ( const DDCompactView cpv)
privatevirtual

Definition at line 127 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(), Geom::fpi(), Geom::ftwoPi(), 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, dtDQMClient_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().

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

Definition at line 490 of file MagGeoBuilderFromDDD.cc.

References MFGridFactory::build(), MagGeoBuilderFromDDD::volumeHandle::center(), dtNoiseDBValidation_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(), makeMuonMisalignmentScenario::rot, GloballyPositioned< T >::rotation(), MagGeoBuilderFromDDD::volumeHandle::shape(), MagGeoBuilderFromDDD::volumeHandle::sides(), tableSet, MagGeoBuilderFromDDD::volumeHandle::toExpand(), Dimensions::w, MagException::what(), and cms::Exception::what().

Referenced by build().

490  {
491 
492  // Phi of the master sector
493  double masterSectorPhi = (vol->masterSector-1)*Geom::pi()/6.;
494 
495  if (debug) {
496  cout << "Building interpolator from "
497  << vol->name << " copyno " << vol->copyno
498  << " at " << vol->center()
499  << " phi: " << vol->center().phi()
500  << " file: " << vol->magFile
501  << endl;
502 
503  if ( fabs(vol->center().phi() - masterSectorPhi) > Geom::pi()/9.) {
504  cout << "***WARNING wrong sector? " << endl;
505  }
506  }
507 
508  if (tableSet == "fake") {
509  interpolators[vol->magFile] = new magneticfield::FakeInterpolator();
510  return;
511  }
512 
513  string fullPath;
514 
515  try {
516  edm::FileInPath mydata("MagneticField/Interpolation/data/"+tableSet+"/"+vol->magFile);
517  fullPath = mydata.fullPath();
518  } catch (edm::Exception& exc) {
519  cerr << "MagGeoBuilderFromDDD: exception in reading table; " << exc.what() << endl;
520  if (!debug) throw;
521  return;
522  }
523 
524 
525  try{
526  if (vol->toExpand()){
527  //FIXME: see discussion on mergeCylinders above.
528 // interpolators[vol->magFile] =
529 // MFGridFactory::build( fullPath, *(vol->placement()), vol->minPhi(), vol->maxPhi());
530  } else {
531  // If the table is in "local" coordinates, must create a reference
532  // frame that is appropriately rotated along the CMS Z axis.
533 
534  GloballyPositioned<float> rf = *(vol->placement());
535 
536  if (vol->masterSector != 1) {
538 
539  GloballyPositioned<float>::RotationType rot(Vector(0,0,1), -masterSectorPhi);
540  Vector vpos(vol->placement()->position());
541 
542 
543  rf = GloballyPositioned<float>(GloballyPositioned<float>::PositionType(rot.multiplyInverse(vpos)), vol->placement()->rotation()*rot);
544  }
545 
546  interpolators[vol->magFile] =
547  MFGridFactory::build( fullPath, rf);
548  }
549  } catch (MagException& exc) {
550  cout << exc.what() << endl;
551  interpolators.erase(vol->magFile);
552  if (!debug) throw;
553  return;
554  }
555 
556 
557  if (debug) {
558  // Check that all grid points of the interpolator are inside the volume.
559  const MagVolume6Faces tempVolume(vol->placement()->position(),
560  vol->placement()->rotation(),
561  vol->shape(),
562  vol->sides(),
563  interpolators[vol->magFile]);
564 
565  const MFGrid* grid = dynamic_cast<const MFGrid*>(interpolators[vol->magFile]);
566  if (grid!=0) {
567 
568  Dimensions sizes = grid->dimensions();
569  cout << "Grid has 3 dimensions "
570  << " number of nodes is " << sizes.w << " " << sizes.h
571  << " " << sizes.d << endl;
572 
573  const double tolerance = 0.03;
574 
575 
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++) {
580  MFGrid::LocalPoint lp = grid->nodePosition( i, j, k);
581  if (! tempVolume.inside(lp, tolerance)) {
582  if (++dumpCount < 2) {
583  MFGrid::GlobalPoint gp = tempVolume.toGlobal(lp);
584  cout << "GRID ERROR: " << i << " " << j << " " << k
585  << " local: " << lp
586  << " global: " << gp
587  << " R= " << gp.perp() << " phi=" << gp.phi() << endl;
588  }
589  }
590  }
591  }
592  }
593 
594  cout << vol->name << " : Number of grid points outside the MagVolume: " << dumpCount << "/" << sizes.w*sizes.h*sizes.d << endl;
595  }
596  }
597 }
virtual char const * what() const
Definition: Exception.cc:141
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
Definition: MFGrid.h:31
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:121
void MagGeoBuilderFromDDD::buildMagVolumes ( const handles volumes,
std::map< std::string, MagProviderInterpol * > &  interpolators 
)
private

Definition at line 428 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().

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

References mESectors.

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

632  {
633  return mESectors;
634 }
std::vector< MagESector * > mESectors
vector< MagVolume6Faces * > MagGeoBuilderFromDDD::endcapVolumes ( ) const
private

Definition at line 646 of file MagGeoBuilderFromDDD.cc.

References eVolumes, i, and v.

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

646  {
647  vector<MagVolume6Faces*> v;
648  v.reserve(eVolumes.size());
649  for (handles::const_iterator i=eVolumes.begin();
650  i!=eVolumes.end(); ++i){
651  v.push_back((*i)->magVolume);
652  }
653  return v;
654 }
int i
Definition: DBlmapReader.cc:9
mathSSE::Vec4< T > v
float MagGeoBuilderFromDDD::maxR ( ) const

Definition at line 657 of file MagGeoBuilderFromDDD.cc.

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

657  {
658  //FIXME: should get it from the actual geometry - MAGF is an option,
659  // but that is not changed together the geometry itself
660  // (it lives in cmsMagneticField.xml in CMSCommonData)
661  return 900.;
662 }
float MagGeoBuilderFromDDD::maxZ ( ) const

Definition at line 664 of file MagGeoBuilderFromDDD.cc.

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

664  {
665  //FIXME: should get it from the actual geometry - see above
666  return 1600.;
667 }
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 670 of file MagGeoBuilderFromDDD.cc.

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

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

672 {
673  if (keys.size() != values.size()) {
674  throw cms::Exception("InvalidParameter") << "Invalid field scaling parameters 'scalingVolumes' and 'scalingFactors' ";
675  }
676  for (unsigned int i=0; i<keys.size(); ++i) {
678  }
679 }
int i
Definition: DBlmapReader.cc:9
std::map< int, double > theScalingFactors
void MagGeoBuilderFromDDD::summary ( handles volumes)
private

Definition at line 82 of file MagGeoBuilderFromDDD.cc.

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

Referenced by build().

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

Definition at line 601 of file MagGeoBuilderFromDDD.cc.

References gather_cfg::cout, and i.

Referenced by build().

601  {
602  // test inside() for all volumes.
603  cout << "--------------------------------------------------" << endl;
604  cout << " inside(center) test" << endl;
605  for (handles::const_iterator vol=volumes.begin(); vol!=volumes.end();
606  ++vol){
607  for (handles::const_iterator i=volumes.begin(); i!=volumes.end();
608  ++i){
609  if ((*i)==(*vol)) continue;
610  //if ((*i)->magVolume == 0) continue;
611  if ((*i)->magVolume->inside((*vol)->center())) {
612  cout << "*** ERROR: center of " << (*vol)->name << " is inside "
613  << (*i)->name <<endl;
614  }
615  }
616 
617  if ((*vol)->magVolume->inside((*vol)->center())) {
618  cout << (*vol)->name << " OK " << endl;
619  } else {
620  cout << "*** ERROR: center of volume is not inside it, "
621  << (*vol)->name << endl;
622  }
623  }
624  cout << "--------------------------------------------------" << endl;
625 }
int i
Definition: DBlmapReader.cc:9
tuple cout
Definition: gather_cfg.py:121

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().

int MagGeoBuilderFromDDD::geometryVersion
private

Definition at line 128 of file MagGeoBuilderFromDDD.h.

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 132 of file MagGeoBuilderFromDDD.h.

Referenced by build().

std::string MagGeoBuilderFromDDD::tableSet
private

Definition at line 127 of file MagGeoBuilderFromDDD.h.

Referenced by buildInterpolator().

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

Definition at line 130 of file MagGeoBuilderFromDDD.h.

Referenced by buildMagVolumes(), and setScaling().