CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
magneticfield::bLayer Class Reference

#include <bLayer.h>

Public Member Functions

 bLayer (handles::const_iterator begin, handles::const_iterator end, bool debugFlag=false)
 Constructor from list of volumes. More...
 
MagBLayerbuildMagBLayer () const
 Construct the MagBLayer upon request. More...
 
double minR () const
 Return sector at i (handling periodicity) More...
 
const float RN () const
 Distance from center along normal of sectors. More...
 
const handlesvolumes () const
 Return the list of all volumes. More...
 
 ~bLayer ()=default
 Destructor. More...
 

Private Member Functions

int bin (int i) const
 

Private Attributes

const bool debug
 
MagBLayermlayer
 
std::vector< bSectorsectors
 
int size
 
handles theVolumes
 

Detailed Description

Definition at line 17 of file bLayer.h.

Constructor & Destructor Documentation

◆ bLayer()

bLayer::bLayer ( handles::const_iterator  begin,
handles::const_iterator  end,
bool  debugFlag = false 
)

Constructor from list of volumes.

Definition at line 20 of file bLayer.cc.

21  : size(end - begin), theVolumes(begin, end), mlayer(nullptr), debug(debugFlag) {
22  // Sort in phi
24 
25  if (debug) {
26  std::cout << " elements: " << theVolumes.size() << " unique volumes: ";
27  printUniqueNames(theVolumes.begin(), theVolumes.end());
28  }
29 
30  // Find sectors in phi
31  handles::iterator secBegin = theVolumes.begin();
32  handles::iterator secEnd = secBegin;
33  int binOffset = 0;
34 
35  const Surface& refSurf = (*secBegin)->surface(outer);
36 
37  int newbegin = 0;
38  int newend = 0;
39 
40  // A sector is made of several volumes in R, and, for planar layers
41  // (box and traps) also in phi, so it might cross the -phi boundary.
42  // For those, we have to look for the end of first sector and rotate the
43  // vector of volumes.
44  // ASSUMPTION: all volumes in a layer must be of compatible type.
45 
46  if (size == 1) { // Only one volume; this is the case for barrel
47  // cylinders.
48  // FIXME sectors.push_back(bSector(theVolumes.begin(),theVolumes.end());
49  if (debug)
50  std::cout << " Sector is just one volume." << std::endl;
51 
52  } else if (size == 12 || // In this case, each volume is a sector.
53  (((*secBegin)->shape() != DDSolidShape::ddtrap) && (*secBegin)->shape() != DDSolidShape::ddbox)) {
54  secEnd = secBegin + size / 12;
55 
56  } else { // there are more than one volume per sector.
57  float tolerance = 0.025; // 250 micron
58  do {
59  if (debug)
60  std::cout << (*secBegin)->name << " " << (*secBegin)->copyno << std::endl;
61  ++secBegin;
62  } while (
63  (secBegin != theVolumes.end()) &&
64  (*secBegin)->sameSurface(
65  refSurf,
66  outer,
67  tolerance)); // This works only if outer surface is a plane, otherwise sameSurface returns always true!
68 
69  secEnd = secBegin;
70  secBegin = theVolumes.begin() + bin((secEnd - theVolumes.begin()) - size / 12);
71  ;
72  newend = secEnd - theVolumes.begin();
73  newbegin = secBegin - theVolumes.begin();
74 
75  // Rotate the begin of the first sector to the vector beginning.
76  rotate(theVolumes.begin(), secBegin, theVolumes.end());
77  secBegin = theVolumes.begin();
78  secEnd = secBegin + size / 12;
79 
80  // Test it is correct...
81  if (!((*secBegin)->sameSurface((*(secEnd - 1))->surface(outer), outer, tolerance))) {
82  std::cout << "*** ERROR: Big mess while looking for sectors " << (*secBegin)->name << " " << (*secBegin)->copyno
83  << " " << (*(secEnd - 1))->name << " " << (*(secEnd - 1))->copyno << std::endl;
84  }
85  }
86 
87  if (debug) {
88  std::cout << " First sector: volumes " << secEnd - theVolumes.begin() << " from " << newbegin
89  << " (phi = " << (*secBegin)->center().phi() << ") "
90  << " to " << newend << " (phi = " << (*secEnd)->center().phi() << ") "
91  << " # " << (*secBegin)->copyno << " ";
92  std::cout << GlobalVector(refSurf.rotation().zx(), refSurf.rotation().zy(), refSurf.rotation().zz()) << std::endl;
93  }
94 
95  if (size != 1) { // Build the 12 sectors
96  int offset = size / 12;
97  sectors.resize(12);
98  for (int i = 0; i < 12; ++i) {
99  int isec = (i + binOffset) % 12;
100  sectors[isec >= 0 ? isec : isec + 12] =
101  bSector(theVolumes.begin() + ((i)*offset), theVolumes.begin() + ((i + 1) * offset), debug);
102  }
103  }
104 
105  if (debug)
106  std::cout << "-----------------------" << std::endl;
107 }

References bin(), gather_cfg::cout, ddbox, ddtrap, debug, mps_fire::i, hltrates_dqm_sourceclient-live_cfg::offset, SurfaceOrientation::outer, precomputed_value_sort(), magneticfield::printUniqueNames(), svgfig::rotate(), GloballyPositioned< T >::rotation(), sectors, size, theVolumes, tolerance, TkRotation< T >::zx(), TkRotation< T >::zy(), and TkRotation< T >::zz().

◆ ~bLayer()

magneticfield::bLayer::~bLayer ( )
default

Destructor.

Member Function Documentation

◆ bin()

int bLayer::bin ( int  i) const
private

Definition at line 109 of file bLayer.cc.

109  {
110  i = i % size;
111  return (i >= 0 ? i : i + size);
112 }

References mps_fire::i, and size.

Referenced by bLayer().

◆ buildMagBLayer()

MagBLayer * bLayer::buildMagBLayer ( ) const

Construct the MagBLayer upon request.

Definition at line 130 of file bLayer.cc.

130  {
131  if (mlayer == nullptr) {
132  // If we have only one volume, do not build any MagBSector.
133  if (sectors.empty()) {
134  if (debug && size != 0) {
135  std::cout << "ERROR: bLayer::buildMagBLayer, 0 sectors but " << size << " volumes" << std::endl;
136  }
137  // Technically we might have only one bSector built and we would
138  // not need a separate MagBLayer constructor...
139  mlayer = new MagBLayer(theVolumes.front()->magVolume, minR());
140  }
141 
142  // If we have several sectors, create the MagBSector
143  std::vector<MagBSector*> mSectors;
144  for (unsigned int i = 0; i < sectors.size(); ++i) {
145  mSectors.push_back(sectors[i].buildMagBSector());
146  }
147  mlayer = new MagBLayer(mSectors, minR());
148  }
149  return mlayer;
150 }

References gather_cfg::cout, debug, mps_fire::i, minR(), mlayer, sectors, size, and theVolumes.

◆ minR()

double bLayer::minR ( ) const

Return sector at i (handling periodicity)

Min R (conservative guess).

Definition at line 120 of file bLayer.cc.

120  {
121  // ASSUMPTION: a layer is only 1 volume thick (by construction).
122  return theVolumes.front()->minR();
123 }

References theVolumes.

Referenced by buildMagBLayer().

◆ RN()

const float magneticfield::bLayer::RN ( ) const
inline

Distance from center along normal of sectors.

Definition at line 26 of file bLayer.h.

26 { return theVolumes.front()->RN(); }

References theVolumes.

◆ volumes()

const handles& magneticfield::bLayer::volumes ( ) const
inline

Return the list of all volumes.

Definition at line 29 of file bLayer.h.

29 { return theVolumes; }

References theVolumes.

Member Data Documentation

◆ debug

const bool magneticfield::bLayer::debug
private

◆ mlayer

MagBLayer* magneticfield::bLayer::mlayer
mutableprivate

Definition at line 53 of file bLayer.h.

Referenced by buildMagBLayer().

◆ sectors

std::vector<bSector> magneticfield::bLayer::sectors
private

Definition at line 50 of file bLayer.h.

Referenced by bLayer(), and buildMagBLayer().

◆ size

int magneticfield::bLayer::size
private

◆ theVolumes

handles magneticfield::bLayer::theVolumes
private

Definition at line 51 of file bLayer.h.

Referenced by bLayer(), buildMagBLayer(), minR(), RN(), and volumes().

mps_fire.i
i
Definition: mps_fire.py:355
TkRotation::zy
T zy() const
Definition: extTkRotation.h:258
DDSolidShape::ddtrap
gather_cfg.cout
cout
Definition: gather_cfg.py:144
magneticfield::printUniqueNames
void printUniqueNames(handles::const_iterator begin, handles::const_iterator end, bool uniq=true)
Just for debugging...
Definition: printUniqueNames.cc:9
Surface
Definition: Surface.h:36
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
end
#define end
Definition: vmac.h:39
svgfig.rotate
def rotate(angle, cx=0, cy=0)
Definition: svgfig.py:705
magneticfield::bLayer::theVolumes
handles theVolumes
Definition: bLayer.h:51
magneticfield::bLayer::minR
double minR() const
Return sector at i (handling periodicity)
Definition: bLayer.cc:120
magneticfield::bLayer::size
int size
Definition: bLayer.h:45
magneticfield::bLayer::sectors
std::vector< bSector > sectors
Definition: bLayer.h:50
magneticfield::bLayer::mlayer
MagBLayer * mlayer
Definition: bLayer.h:53
magneticfield::bSector
Definition: bSector.h:17
tolerance
const double tolerance
Definition: HGCalGeomParameters.cc:27
magneticfield::ExtractPhi
Definition: BaseVolumeHandle.h:169
TkRotation::zz
T zz() const
Definition: extTkRotation.h:259
MagBLayer
Definition: MagBLayer.h:24
magneticfield::bLayer::bin
int bin(int i) const
Definition: bLayer.cc:109
magneticfield::bLayer::debug
const bool debug
Definition: bLayer.h:54
LaserTracksInput_cfi.debugFlag
debugFlag
Definition: LaserTracksInput_cfi.py:7
DDSolidShape::ddbox
GloballyPositioned::rotation
const RotationType & rotation() const
Definition: GloballyPositioned.h:38
SurfaceOrientation::outer
Definition: Surface.h:19
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
precomputed_value_sort
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
Definition: precomputed_value_sort.h:17
TkRotation::zx
T zx() const
Definition: extTkRotation.h:257
begin
#define begin
Definition: vmac.h:32