CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes
magneticfield::BaseVolumeHandle Class Referenceabstract

#include <BaseVolumeHandle.h>

Inheritance diagram for magneticfield::BaseVolumeHandle:
MagGeoBuilderFromDDD::volumeHandle magneticfield::volumeHandle

Public Types

typedef Surface::GlobalPoint GlobalPoint
 
typedef Surface::LocalPoint LocalPoint
 
typedef Surface::LocalVector LocalVector
 
typedef SurfaceOrientation::GlobalFace Sides
 

Public Member Functions

 BaseVolumeHandle (bool expand2Pi=false, bool debugVal=false)
 
 BaseVolumeHandle (const BaseVolumeHandle &v)=delete
 
const GlobalPointcenter () const
 Return the center of the volume. More...
 
bool isIron () const
 Temporary hack to pass information on material. Will eventually be replaced! More...
 
bool isPlaneMatched (int which_side) const
 if the specified surface has been matched. More...
 
Geom::Phi< float > maxPhi () const
 Maximum value of phi covered by the volume. More...
 
double maxZ () const
 
Geom::Phi< float > minPhi () const
 Minimum value of phi covered by the volume. More...
 
double minR () const
 Minimum R for any point within the volume. More...
 
double minZ () const
 Z limits. More...
 
const GloballyPositioned< float > * placement () const
 Position and rotation. More...
 
int references (int which_side) const
 
const double RN () const
 Distance of (x,y) plane from origin. More...
 
bool sameSurface (const Surface &s1, Sides which_side, float tolerance=0.01)
 Find out if two surfaces are the same physical surface. More...
 
bool setSurface (const Surface &s1, Sides which_side)
 Assign a shared surface perorming sanity checks. More...
 
virtual DDSolidShape shape () const =0
 Shape of the solid. More...
 
virtual std::vector< VolumeSidesides () const =0
 The surfaces and they orientation, as required to build a MagVolume. More...
 
const Surfacesurface (int which_side) const
 Get the current surface on specified side. More...
 
const Surfacesurface (Sides which_side) const
 
bool toExpand () const
 
virtual ~BaseVolumeHandle ()
 

Public Attributes

unsigned short copyno
 copy number More...
 
std::string magFile
 Name of magnetic field table file. More...
 
MagVolume6FacesmagVolume
 Pointer to the final MagVolume (must be set from outside) More...
 
int masterSector
 The sector for which an interpolator for this class of volumes should be built. More...
 
std::string name
 Name of the volume. More...
 
unsigned short volumeno
 volume number More...
 

Protected Types

typedef ConstReferenceCountingPointer< SurfaceRCPS
 

Protected Member Functions

void buildPhiZSurf (double startPhi, double deltaPhi, double zhalf, double rCentr)
 

Protected Attributes

GlobalPoint center_
 
const bool debug
 
bool expand
 
bool isAssigned [6]
 
bool isIronFlag
 
GloballyPositioned< float > * refPlane
 
RCPS surfaces [6]
 
Geom::Phi< float > thePhiMin
 
double theRMax
 
double theRMin
 
double theRN
 

Detailed Description

Definition at line 22 of file BaseVolumeHandle.h.

Member Typedef Documentation

Definition at line 24 of file BaseVolumeHandle.h.

Definition at line 25 of file BaseVolumeHandle.h.

Definition at line 26 of file BaseVolumeHandle.h.

Definition at line 117 of file BaseVolumeHandle.h.

Definition at line 27 of file BaseVolumeHandle.h.

Constructor & Destructor Documentation

BaseVolumeHandle::BaseVolumeHandle ( bool  expand2Pi = false,
bool  debugVal = false 
)

Definition at line 26 of file BaseVolumeHandle.cc.

27  : magVolume(nullptr),
28  masterSector(1),
29  theRN(0.),
30  theRMin(0.),
31  theRMax(0.),
32  refPlane(nullptr),
33  expand(expand2Pi),
34  isIronFlag(false),
35  debug(debugVal) {}
GloballyPositioned< float > * refPlane
int masterSector
The sector for which an interpolator for this class of volumes should be built.
MagVolume6Faces * magVolume
Pointer to the final MagVolume (must be set from outside)
magneticfield::BaseVolumeHandle::BaseVolumeHandle ( const BaseVolumeHandle v)
delete
BaseVolumeHandle::~BaseVolumeHandle ( )
virtual

Definition at line 37 of file BaseVolumeHandle.cc.

References refPlane.

37  {
38  if (refPlane != nullptr) {
39  delete refPlane;
40  refPlane = nullptr;
41  }
42 }
GloballyPositioned< float > * refPlane

Member Function Documentation

void BaseVolumeHandle::buildPhiZSurf ( double  startPhi,
double  deltaPhi,
double  zhalf,
double  rCentr 
)
protected

Definition at line 46 of file BaseVolumeHandle.cc.

References center_, funct::cos(), gather_cfg::cout, debug, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), SurfaceOrientation::phiminus, SurfaceOrientation::phiplus, refPlane, funct::sin(), surfaces, theRN, GloballyPositioned< T >::toGlobal(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), SurfaceOrientation::zminus, and SurfaceOrientation::zplus.

46  {
47  // This is 100% equal for cons and tubs!!!
48 
49  GlobalVector planeXAxis = refPlane->toGlobal(LocalVector(1, 0, 0));
50  GlobalVector planeYAxis = refPlane->toGlobal(LocalVector(0, 1, 0));
51  GlobalVector planeZAxis = refPlane->toGlobal(LocalVector(0, 0, 1));
52 
53  // Local Y axis of the faces at +-phi.
54  GlobalVector y_phiplus = refPlane->toGlobal(LocalVector(cos(startPhi + deltaPhi), sin(startPhi + deltaPhi), 0.));
55  GlobalVector y_phiminus = refPlane->toGlobal(LocalVector(cos(startPhi), sin(startPhi), 0.));
56 
57  Surface::RotationType rot_Z(planeXAxis, planeYAxis);
58  Surface::RotationType rot_phiplus(planeZAxis, y_phiplus);
59  Surface::RotationType rot_phiminus(planeZAxis, y_phiminus);
60 
61  GlobalPoint pos_zplus(center_.x(), center_.y(), center_.z() + zhalf);
62  GlobalPoint pos_zminus(center_.x(), center_.y(), center_.z() - zhalf);
63  // BEWARE: in this case, the origin for phiplus,phiminus surfaces is
64  // at radius R and not on a plane passing by center_ orthogonal to the radius.
65  GlobalPoint pos_phiplus(
66  refPlane->toGlobal(LocalPoint(rCentr * cos(startPhi + deltaPhi), rCentr * sin(startPhi + deltaPhi), 0.)));
67  GlobalPoint pos_phiminus(refPlane->toGlobal(LocalPoint(rCentr * cos(startPhi), rCentr * sin(startPhi), 0.)));
68  surfaces[zplus] = new Plane(pos_zplus, rot_Z);
69  surfaces[zminus] = new Plane(pos_zminus, rot_Z);
70  surfaces[phiplus] = new Plane(pos_phiplus, rot_phiplus);
71  surfaces[phiminus] = new Plane(pos_phiminus, rot_phiminus);
72 
73  if (debug) {
74  cout << "Actual Center at: " << center_ << " R " << center_.perp() << " phi " << center_.phi() << endl;
75  cout << "RN " << theRN << endl;
76 
77  cout << "pos_zplus " << pos_zplus << " " << pos_zplus.perp() << " " << pos_zplus.phi() << endl
78  << "pos_zminus " << pos_zminus << " " << pos_zminus.perp() << " " << pos_zminus.phi() << endl
79  << "pos_phiplus " << pos_phiplus << " " << pos_phiplus.perp() << " " << pos_phiplus.phi() << endl
80  << "pos_phiminus " << pos_phiminus << " " << pos_phiminus.perp() << " " << pos_phiminus.phi() << endl;
81 
82  cout << "y_phiplus " << y_phiplus << endl;
83  cout << "y_phiminus " << y_phiminus << endl;
84 
85  cout << "rot_Z " << surfaces[zplus]->toGlobal(LocalVector(0., 0., 1.)) << endl
86  << "rot_phi+ " << surfaces[phiplus]->toGlobal(LocalVector(0., 0., 1.)) << " phi "
87  << surfaces[phiplus]->toGlobal(LocalVector(0., 0., 1.)).phi() << endl
88  << "rot_phi- " << surfaces[phiminus]->toGlobal(LocalVector(0., 0., 1.)) << " phi "
89  << surfaces[phiminus]->toGlobal(LocalVector(0., 0., 1.)).phi() << endl;
90  }
91 
92  // // Check ordering.
93  if (debug) {
94  if (pos_zplus.z() < pos_zminus.z()) {
95  cout << "*** WARNING: pos_zplus < pos_zminus " << endl;
96  }
97  if (Geom::Phi<float>(pos_phiplus.phi() - pos_phiminus.phi()) < 0.) {
98  cout << "*** WARNING: pos_phiplus < pos_phiminus " << endl;
99  }
100  }
101 }
T perp() const
Definition: PV3DBase.h:69
Surface::LocalVector LocalVector
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T y() const
Definition: PV3DBase.h:60
Definition: Plane.h:16
GloballyPositioned< float > * refPlane
T z() const
Definition: PV3DBase.h:61
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
GlobalPoint toGlobal(const LocalPoint &lp) const
T x() const
Definition: PV3DBase.h:59
const Surface::GlobalPoint & BaseVolumeHandle::center ( ) const
bool magneticfield::BaseVolumeHandle::isIron ( ) const
inline

Temporary hack to pass information on material. Will eventually be replaced!

Definition at line 108 of file BaseVolumeHandle.h.

References isIronFlag.

bool magneticfield::BaseVolumeHandle::isPlaneMatched ( int  which_side) const
inline

if the specified surface has been matched.

Definition at line 55 of file BaseVolumeHandle.h.

References isAssigned.

55 { return isAssigned[which_side]; }
Geom::Phi<float> magneticfield::BaseVolumeHandle::maxPhi ( ) const
inline

Maximum value of phi covered by the volume.

Definition at line 85 of file BaseVolumeHandle.h.

References PV3DBase< T, PVType, FrameType >::phi(), SurfaceOrientation::phiplus, GloballyPositioned< T >::position(), and surface().

Referenced by magneticfield::ExtractPhiMax::operator()().

Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
const Surface & surface(int which_side) const
Get the current surface on specified side.
const PositionType & position() const
double magneticfield::BaseVolumeHandle::maxZ ( ) const
inline

Definition at line 91 of file BaseVolumeHandle.h.

References GloballyPositioned< T >::position(), surface(), PV3DBase< T, PVType, FrameType >::z(), and SurfaceOrientation::zplus.

const Surface & surface(int which_side) const
Get the current surface on specified side.
T z() const
Definition: PV3DBase.h:61
const PositionType & position() const
Geom::Phi<float> magneticfield::BaseVolumeHandle::minPhi ( ) const
inline

Minimum value of phi covered by the volume.

Definition at line 80 of file BaseVolumeHandle.h.

References thePhiMin.

80 { return thePhiMin; }
double magneticfield::BaseVolumeHandle::minR ( ) const
inline

Minimum R for any point within the volume.

Definition at line 94 of file BaseVolumeHandle.h.

References theRMin.

double magneticfield::BaseVolumeHandle::minZ ( ) const
inline

Z limits.

Definition at line 90 of file BaseVolumeHandle.h.

References GloballyPositioned< T >::position(), surface(), PV3DBase< T, PVType, FrameType >::z(), and SurfaceOrientation::zminus.

const Surface & surface(int which_side) const
Get the current surface on specified side.
T z() const
Definition: PV3DBase.h:61
const PositionType & position() const
const GloballyPositioned<float>* magneticfield::BaseVolumeHandle::placement ( ) const
inline

Position and rotation.

Definition at line 97 of file BaseVolumeHandle.h.

References refPlane, and sides().

Referenced by magneticfield::MagGeoBuilder::buildInterpolator(), and MagGeoBuilderFromDDD::buildInterpolator().

97 { return refPlane; }
GloballyPositioned< float > * refPlane
int magneticfield::BaseVolumeHandle::references ( int  which_side) const
inline

Definition at line 57 of file BaseVolumeHandle.h.

57  { // FIXME!
58  /* return surfaces[which_side]->references(); */
59  return 0;
60  }
const double magneticfield::BaseVolumeHandle::RN ( ) const
inline

Distance of (x,y) plane from origin.

Definition at line 41 of file BaseVolumeHandle.h.

References sameSurface(), setSurface(), surface(), theRN, and tolerance.

Referenced by magneticfield::ExtractRN::operator()().

bool BaseVolumeHandle::sameSurface ( const Surface s1,
Sides  which_side,
float  tolerance = 0.01 
)

Find out if two surfaces are the same physical surface.

Definition at line 103 of file BaseVolumeHandle.cc.

References gather_cfg::cout, debug, Vector3DBase< T, FrameTag >::dot(), mag(), Plane::normalVector(), Cone::openingAngle(), p1, p2, GloballyPositioned< T >::position(), Cylinder::radius(), indexGen::s2, surfaces, tolerance, GloballyPositioned< T >::toLocal(), Cone::vertex(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by RN(), and setSurface().

103  {
104  //Check for null comparison
105  if (&s1 == (surfaces[which_side]).get()) {
106  if (debug)
107  cout << " sameSurface: OK (same ptr)" << endl;
108  return true;
109  }
110 
111  const float maxtilt = 0.999;
112 
113  const Surface &s2 = *(surfaces[which_side]);
114  // Try with a plane.
115  const Plane *p1 = dynamic_cast<const Plane *>(&s1);
116  if (p1 != nullptr) {
117  const Plane *p2 = dynamic_cast<const Plane *>(&s2);
118  if (p2 == nullptr) {
119  if (debug)
120  cout << " sameSurface: different types" << endl;
121  return false;
122  }
123 
124  if ((fabs(p1->normalVector().dot(p2->normalVector())) > maxtilt) &&
125  (fabs((p1->toLocal(p2->position())).z()) < tolerance)) {
126  if (debug)
127  cout << " sameSurface: OK " << fabs(p1->normalVector().dot(p2->normalVector())) << " "
128  << fabs((p1->toLocal(p2->position())).z()) << endl;
129  return true;
130  } else {
131  if (debug)
132  cout << " sameSurface: not the same: " << p1->normalVector() << p1->position() << endl
133  << " " << p2->normalVector() << p2->position() << endl
134  << fabs(p1->normalVector().dot(p2->normalVector())) << " " << (p1->toLocal(p2->position())).z() << endl;
135  return false;
136  }
137  }
138 
139  // Try with a cylinder.
140  const Cylinder *cy1 = dynamic_cast<const Cylinder *>(&s1);
141  if (cy1 != nullptr) {
142  const Cylinder *cy2 = dynamic_cast<const Cylinder *>(&s2);
143  if (cy2 == nullptr) {
144  if (debug)
145  cout << " sameSurface: different types" << endl;
146  return false;
147  }
148  // Assume axis is the same!
149  if (fabs(cy1->radius() - cy2->radius()) < tolerance) {
150  return true;
151  } else {
152  return false;
153  }
154  }
155 
156  // Try with a cone.
157  const Cone *co1 = dynamic_cast<const Cone *>(&s1);
158  if (co1 != nullptr) {
159  const Cone *co2 = dynamic_cast<const Cone *>(&s2);
160  if (co2 == nullptr) {
161  if (debug)
162  cout << " sameSurface: different types" << endl;
163  return false;
164  }
165  // FIXME
166  if (fabs(co1->openingAngle() - co2->openingAngle()) < maxtilt &&
167  (co1->vertex() - co2->vertex()).mag() < tolerance) {
168  return true;
169  } else {
170  return false;
171  }
172  }
173 
174  if (debug)
175  cout << " sameSurface: unknown surfaces..." << endl;
176  return false;
177 }
Definition: Cone.h:17
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const double tolerance
GlobalVector normalVector() const
Definition: Plane.h:41
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:99
Definition: Plane.h:16
GlobalPoint vertex() const
Global position of the cone vertex.
Definition: Cone.h:47
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:64
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:61
double p2[4]
Definition: TauolaWrapper.h:90
double p1[4]
Definition: TauolaWrapper.h:89
const PositionType & position() const
Geom::Theta< float > openingAngle() const
Angle of the cone.
Definition: Cone.h:50
bool BaseVolumeHandle::setSurface ( const Surface s1,
Sides  which_side 
)

Assign a shared surface perorming sanity checks.

Definition at line 179 of file BaseVolumeHandle.cc.

References copyno, gather_cfg::cout, debug, createfilelist::int, isAssigned, name, Plane::normalVector(), p1, p2, GloballyPositioned< T >::position(), indexGen::s2, sameSurface(), and surfaces.

Referenced by RN().

179  {
180  //Check for null assignment
181  if (&s1 == (surfaces[which_side]).get()) {
182  isAssigned[which_side] = true;
183  return true;
184  }
185 
186  if (!sameSurface(s1, which_side)) {
187  cout << "***ERROR: setSurface: trying to assign a surface that does not match destination surface. Skipping."
188  << endl;
189  const Surface &s2 = *(surfaces[which_side]);
190  //FIXME: Just planes for the time being!!!
191  const Plane *p1 = dynamic_cast<const Plane *>(&s1);
192  const Plane *p2 = dynamic_cast<const Plane *>(&s2);
193  if (p1 != nullptr && p2 != nullptr)
194  cout << p1->normalVector() << p1->position() << endl << p2->normalVector() << p2->position() << endl;
195  return false;
196  }
197 
198  if (isAssigned[which_side]) {
199  if (&s1 != (surfaces[which_side]).get()) {
200  cout << "*** WARNING BaseVolumeHandle::setSurface: trying to reassign a surface to a different surface instance"
201  << endl;
202  return false;
203  }
204  } else {
205  surfaces[which_side] = &s1;
206  isAssigned[which_side] = true;
207  if (debug)
208  cout << " Volume " << name << " # " << copyno << " Assigned: " << (int)which_side << endl;
209  return true;
210  }
211 
212  return false; // let the compiler be happy
213 }
GlobalVector normalVector() const
Definition: Plane.h:41
Definition: Plane.h:16
unsigned short copyno
copy number
double p2[4]
Definition: TauolaWrapper.h:90
std::string name
Name of the volume.
double p1[4]
Definition: TauolaWrapper.h:89
const PositionType & position() const
bool sameSurface(const Surface &s1, Sides which_side, float tolerance=0.01)
Find out if two surfaces are the same physical surface.
virtual DDSolidShape magneticfield::BaseVolumeHandle::shape ( ) const
pure virtual
virtual std::vector<VolumeSide> magneticfield::BaseVolumeHandle::sides ( ) const
pure virtual

The surfaces and they orientation, as required to build a MagVolume.

Implemented in magneticfield::volumeHandle, and MagGeoBuilderFromDDD::volumeHandle.

Referenced by placement().

const Surface & BaseVolumeHandle::surface ( int  which_side) const

Get the current surface on specified side.

Definition at line 217 of file BaseVolumeHandle.cc.

References surfaces.

Referenced by maxPhi(), maxZ(), minZ(), and RN().

217  {
218  assert(which_side >= 0 && which_side < 6);
219  return *(surfaces[which_side]);
220 }
const Surface & BaseVolumeHandle::surface ( Sides  which_side) const

Definition at line 215 of file BaseVolumeHandle.cc.

References surfaces.

215 { return *(surfaces[which_side]); }
bool magneticfield::BaseVolumeHandle::toExpand ( ) const
inline

Member Data Documentation

GlobalPoint magneticfield::BaseVolumeHandle::center_
protected
unsigned short magneticfield::BaseVolumeHandle::copyno
const bool magneticfield::BaseVolumeHandle::debug
protected
bool magneticfield::BaseVolumeHandle::expand
protected
bool magneticfield::BaseVolumeHandle::isAssigned[6]
protected
bool magneticfield::BaseVolumeHandle::isIronFlag
protected
std::string magneticfield::BaseVolumeHandle::magFile
MagVolume6Faces* magneticfield::BaseVolumeHandle::magVolume

Pointer to the final MagVolume (must be set from outside)

Definition at line 103 of file BaseVolumeHandle.h.

int magneticfield::BaseVolumeHandle::masterSector
std::string magneticfield::BaseVolumeHandle::name

Name of the volume.

Definition at line 63 of file BaseVolumeHandle.h.

Referenced by ElectronMVAID.ElectronMVAID::__call__(), FWLite.ElectronMVAID::__call__(), dirstructure.Directory::__create_pie_image(), DisplayManager.DisplayManager::__del__(), dqm_interfaces.DirID::__eq__(), dirstructure.Directory::__get_full_path(), dirstructure.Comparison::__get_img_name(), dataset.Dataset::__getDataType(), dataset.Dataset::__getFileInfoList(), dirstructure.Comparison::__make_image(), core.autovars.NTupleVariable::__repr__(), core.autovars.NTupleObjectType::__repr__(), core.autovars.NTupleObject::__repr__(), core.autovars.NTupleCollection::__repr__(), dirstructure.Directory::__repr__(), dqm_interfaces.DirID::__repr__(), dirstructure.Comparison::__repr__(), config.Service::__setattr__(), config.CFG::__str__(), counter.Counter::__str__(), average.Average::__str__(), FWLite.WorkingPoints::_reformat_cut_definitions(), core.autovars.NTupleObjectType::addSubObjects(), core.autovars.NTupleObjectType::addVariables(), core.autovars.NTupleObjectType::allVars(), dirstructure.Directory::calcStats(), validation.Sample::digest(), python.rootplot.utilities.Hist::divide(), python.rootplot.utilities.Hist::divide_wilson(), DisplayManager.DisplayManager::Draw(), core.autovars.NTupleVariable::fillBranch(), core.autovars.NTupleObject::fillBranches(), core.autovars.NTupleCollection::fillBranchesScalar(), core.autovars.NTupleCollection::fillBranchesVector(), core.autovars.NTupleCollection::get_cpp_declaration(), core.autovars.NTupleCollection::get_cpp_wrapper_class(), core.autovars.NTupleCollection::get_py_wrapper_class(), utils.StatisticalTest::get_status(), production_tasks.Task::getname(), dataset.CMSDataset::getPrimaryDatasetEntries(), dataset.PrivateDataset::getPrimaryDatasetEntries(), VIDSelectorBase.VIDSelectorBase::initialize(), core.autovars.NTupleVariable::makeBranch(), core.autovars.NTupleObject::makeBranches(), core.autovars.NTupleCollection::makeBranchesScalar(), core.autovars.NTupleCollection::makeBranchesVector(), dirstructure.Directory::print_report(), dataset.BaseDataset::printInfo(), dataset.Dataset::printInfo(), production_tasks.MonitorJobs::run(), setSurface(), python.rootplot.utilities.Hist::TGraph(), python.rootplot.utilities.Hist::TH1F(), Vispa.Views.PropertyView.Property::valueChanged(), magneticfield::volumeHandle::volumeHandle(), MagGeoBuilderFromDDD::volumeHandle::volumeHandle(), counter.Counter::write(), and average.Average::write().

GloballyPositioned<float>* magneticfield::BaseVolumeHandle::refPlane
protected
RCPS magneticfield::BaseVolumeHandle::surfaces[6]
protected
Geom::Phi<float> magneticfield::BaseVolumeHandle::thePhiMin
protected

Definition at line 134 of file BaseVolumeHandle.h.

Referenced by minPhi().

double magneticfield::BaseVolumeHandle::theRMax
protected
double magneticfield::BaseVolumeHandle::theRMin
protected
double magneticfield::BaseVolumeHandle::theRN
protected
unsigned short magneticfield::BaseVolumeHandle::volumeno