ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
InDetDD::VolumeSplitter Class Reference

#include <VolumeSplitter.h>

Collaboration diagram for InDetDD::VolumeSplitter:

Public Member Functions

 VolumeSplitter ()
 
 ~VolumeSplitter ()
 
const std::vector< const ServiceVolume * > & splitAll (const Zone &zone, const std::vector< const ServiceVolume * > &)
 
void split (const Zone &zone, const ServiceVolume &origVolume)
 
const std::vector< const ServiceVolume * > & getVolumes () const
 
void takeOwnership ()
 

Private Member Functions

Ray makeRay (const ServiceVolume &origVolume)
 
void makeVolumes (const Zone *zone, const ServiceVolume &origVolume)
 
void splitVolume (const Zone *zone, const ServiceVolume &vol)
 
void adjustR (const ServiceVolume &param, ServiceVolume *paramNew)
 

Private Attributes

bool m_ownVolumes
 
double m_epsilon
 
std::vector< const ServiceVolume * > m_volumes
 

Detailed Description

Definition at line 16 of file VolumeSplitter.h.

Constructor & Destructor Documentation

◆ VolumeSplitter()

InDetDD::VolumeSplitter::VolumeSplitter ( )

Definition at line 14 of file VolumeSplitter.cxx.

15  : m_ownVolumes(true),
16  m_epsilon(0.0001 * Gaudi::Units::mm)
17  {}

◆ ~VolumeSplitter()

InDetDD::VolumeSplitter::~VolumeSplitter ( )

Definition at line 19 of file VolumeSplitter.cxx.

19  {
20  if (m_ownVolumes) {
21  for (std::vector<const ServiceVolume*>::iterator iter = m_volumes.begin(); iter != m_volumes.end(); ++iter) {
22  delete *iter;
23  }
24  }
25  }

Member Function Documentation

◆ adjustR()

void InDetDD::VolumeSplitter::adjustR ( const ServiceVolume param,
ServiceVolume paramNew 
)
private

Definition at line 155 of file VolumeSplitter.cxx.

155  {
156  double z1 = param.zmin();
157  double z2 = param.zmax();
158  double z1New = paramNew->zmin();
159  double z2New = paramNew->zmax();
160  double rmin1 = param.rmin();
161  double rmin2 = param.rmin2();
162  double rmax1 = param.rmax();
163  double rmax2 = param.rmax2();
164 
165  // Make sure z1 < z2
166  // as r1, r2 order assumes this
167  if (z1 > z2) std::swap(z1, z2);
168  if (z1New > z2New) std::swap(z1New, z2New);
169 
170  // Avoid divide by zero.
171  if (z1 == z2) return;
172 
173  if (z1 != z1New || z2 != z2New) {
174  if (rmin2 > 0 && rmax2 > 0 && (rmin1 != rmin2 || rmax1 != rmax2)) {
175  double slopeMin = (rmin2 - rmin1) / (z2 - z1);
176  double slopeMax = (rmax2 - rmax1) / (z2 - z1);
177 
178  double rmin1New = (z1New - z1) * slopeMin + rmin1;
179  double rmin2New = (z2New - z1) * slopeMin + rmin1;
180 
181  double rmax1New = (z1New - z1) * slopeMax + rmax1;
182  double rmax2New = (z2New - z1) * slopeMax + rmax1;
183 
184  paramNew->setRmin(rmin1New);
185  paramNew->setRmax(rmax1New);
186  paramNew->setRmin2(rmin2New);
187  paramNew->setRmax2(rmax2New);
188  }
189  }
190  }

◆ getVolumes()

const std::vector<const ServiceVolume *>& InDetDD::VolumeSplitter::getVolumes ( ) const
inline

Definition at line 23 of file VolumeSplitter.h.

23 {return m_volumes;}

◆ makeRay()

Ray InDetDD::VolumeSplitter::makeRay ( const ServiceVolume origVolume)
private

Definition at line 41 of file VolumeSplitter.cxx.

41  {
42  double zmin = origVolume.zmin();
43  double zmax = origVolume.zmax();
44  double rmin = origVolume.rmin();
45  double rmax = origVolume.rmax();
46 
47  if (zmax < zmin) std::swap(zmin, zmax);
48  if (rmax < rmin) std::swap(rmin, rmax);
49 
50  bool horizontal = (std::abs(zmax - zmin) > std::abs(rmax - rmin));
51  if (horizontal) {
52  double rmid = 0.5 * (rmin + rmax);
53  return Ray(Point(zmin, rmid), Point(zmax, rmid));
54  } else {
55  double zmid = 0.5 * (zmin + zmax);
56  return Ray(Point(zmid, rmin), Point(zmid, rmax));
57  }
58  }

◆ makeVolumes()

void InDetDD::VolumeSplitter::makeVolumes ( const Zone zone,
const ServiceVolume origVolume 
)
private

Definition at line 61 of file VolumeSplitter.cxx.

61  {
62  // See if its a symmetric volume
63  if (origVolume.zsymm()) {
64  ServiceVolume param1(origVolume);
65  ServiceVolume param2(origVolume);
66  param1.addLabel("A");
67  param1.setNeedsRotation(false);
68  param2.addLabel("C");
69  param2.setZmin(-origVolume.zmax());
70  param2.setZmax(-origVolume.zmin());
71  param2.setNeedsRotation(origVolume.needsRotation());
72  splitVolume(zone, param1);
73  splitVolume(zone, param2);
74  } else {
75  ServiceVolume param1(origVolume);
76  param1.setNeedsRotation(false);
77  splitVolume(zone, param1);
78  }
79  }

◆ split()

void InDetDD::VolumeSplitter::split ( const Zone zone,
const ServiceVolume origVolume 
)

Definition at line 36 of file VolumeSplitter.cxx.

36  {
37  makeVolumes(&zone, origVolume);
38  }

◆ splitAll()

const std::vector< const ServiceVolume * > & InDetDD::VolumeSplitter::splitAll ( const Zone zone,
const std::vector< const ServiceVolume * > &  origVolumeList 
)

Definition at line 28 of file VolumeSplitter.cxx.

28  {
29  for (unsigned int i = 0; i < origVolumeList.size(); ++i) {
30  split(zone, *(origVolumeList[i]));
31  }
32  return m_volumes;
33  }

◆ splitVolume()

void InDetDD::VolumeSplitter::splitVolume ( const Zone zone,
const ServiceVolume vol 
)
private

Definition at line 82 of file VolumeSplitter.cxx.

82  {
83  Ray ray = makeRay(param);
84  SegmentSplitter splitter;
85  const SegmentList& segments = splitter.split(zone, ray);
86 
87  //std::cout << "Segments: " << std::endl;
88  //segments.print();
89 
90  double volumeTotal = 0;
91 
92  std::vector<ServiceVolume* > tmpServiceVec;
93  tmpServiceVec.reserve(segments.size());
94  for (unsigned int i = 0; i < segments.size(); ++i) {
95  const Segment& seg = segments.getSegment(i);
96  ServiceVolume* paramNew = new ServiceVolume(param);
97 
98  if (segments.horizontal()) {
99  if (param.splittableInZ()) {
100  paramNew->setZmin(seg.zmin());
101  paramNew->setZmax(seg.zmax());
102  // If z changed adjust r in cone like volumes
103  adjustR(param, paramNew);
104  } else if (i == 1) {
105  std::cout << "Volume " << param.fullLabel() << " cannot be split in Z" << std::endl;
106  }
107  } else {
108  // vertical
109  if (param.splittableInR()) {
110  paramNew->setRmin(seg.rmin());
111  paramNew->setRmax(seg.rmax());
112  } else if (i == 1) {
113  std::cout << "Volume " << param.fullLabel() << " cannot be split in R" << std::endl;
114  }
115  }
116 
117  if (seg.rotated()) {
118  // Often the -ve endcap region is created as the +ve endcap and then rotated. Therefore we have to reflect the z
119  // coords.
120  // Also have to turn off the needsRotation flag in case it was set.
121  //std::cout << "Segment " << i << " rotated " << paramNew->zmin() << " " << paramNew->zmax() <<std::endl;
122  double zminTmp = paramNew->zmin();
123  paramNew->setZmin(-paramNew->zmax());
124  paramNew->setZmax(-zminTmp);
125  paramNew->setNeedsRotation(false);
126  //std::cout << "After adjusted " << paramNew->zmin() << " " << paramNew->zmax() <<std::endl;
127  }
128 
129  if (param.splittableInZ()) {
130  paramNew->reduceSize(m_epsilon); // safety gap between volumes
131  }
132 
133  paramNew->setRegion(seg.label());
134  tmpServiceVec.push_back(paramNew);
135 
136  paramNew->getShape();
137  volumeTotal += paramNew->volume();
138  //std::cout << i << ": volume: " << paramNew->volume() << std::endl;
139  }
140  //std::cout << "Total volume: " << volumeTotal << std::endl;
141  for (unsigned int i = 0; i < segments.size(); ++i) {
142  ServiceVolume* paramNew = tmpServiceVec[i];
143  if (segments.size() > 1) {
144  std::ostringstream ostr;
145  ostr << "_" << i + 1;
146  paramNew->addLabel(ostr.str());
147  }
148  paramNew->setOrigVolume(volumeTotal);
149  m_volumes.push_back(paramNew);
150  }
151  }

◆ takeOwnership()

void InDetDD::VolumeSplitter::takeOwnership ( )
inline

Definition at line 25 of file VolumeSplitter.h.

25 {m_ownVolumes = false;}

Member Data Documentation

◆ m_epsilon

double InDetDD::VolumeSplitter::m_epsilon
private

Definition at line 33 of file VolumeSplitter.h.

◆ m_ownVolumes

bool InDetDD::VolumeSplitter::m_ownVolumes
private

Definition at line 32 of file VolumeSplitter.h.

◆ m_volumes

std::vector<const ServiceVolume *> InDetDD::VolumeSplitter::m_volumes
private

Definition at line 34 of file VolumeSplitter.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
ServiceVolume
Definition: InDetServMatGeoModel/src/ServiceVolume.h:14
Trk::TrackState::Segment
@ Segment
Definition: TrackStateDefs.h:37
PixelAthClusterMonAlgCfg.zmin
zmin
Definition: PixelAthClusterMonAlgCfg.py:176
InDetDD::VolumeSplitter::adjustR
void adjustR(const ServiceVolume &param, ServiceVolume *paramNew)
Definition: VolumeSplitter.cxx:155
InDetDD::VolumeSplitter::splitVolume
void splitVolume(const Zone *zone, const ServiceVolume &vol)
Definition: VolumeSplitter.cxx:82
InDetDD::VolumeSplitter::m_ownVolumes
bool m_ownVolumes
Definition: VolumeSplitter.h:32
lumiFormat.i
int i
Definition: lumiFormat.py:92
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:176
InDetDD::VolumeSplitter::makeRay
Ray makeRay(const ServiceVolume &origVolume)
Definition: VolumeSplitter.cxx:41
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
InDetDD::VolumeSplitter::m_epsilon
double m_epsilon
Definition: VolumeSplitter.h:33
python.draw_obj.zone
def zone(nx, ny)
Definition: draw_obj.py:288
InDetDD::VolumeSplitter::m_volumes
std::vector< const ServiceVolume * > m_volumes
Definition: VolumeSplitter.h:34
ChargedTracksWeightFilter::Spline::Point
Linear spline representation of a function used to calculate weights.
Definition: ChargedTracksWeightFilter.h:28
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
InDetDD::VolumeSplitter::split
void split(const Zone &zone, const ServiceVolume &origVolume)
Definition: VolumeSplitter.cxx:36
InDetDD::VolumeSplitter::makeVolumes
void makeVolumes(const Zone *zone, const ServiceVolume &origVolume)
Definition: VolumeSplitter.cxx:61