CMS 3D CMS Logo

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

#include <bLayer.h>

Public Member Functions

 bLayer (handles::const_iterator begin, handles::const_iterator end)
 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 ()
 Destructor. More...
 

Private Member Functions

int bin (int i) const
 

Private Attributes

MagBLayermlayer
 
std::vector< bSectorsectors
 
int size
 
handles theVolumes
 

Detailed Description

A layer of barrel volumes. Holds a list of volumes and 12 sectors. It is assumed that the geometry is 12-fold periodic in phi!

Date:
2005/09/06 15:48:28
Revision:
1.1
Author
N. Amapane - INFN Torino

Definition at line 19 of file bLayer.h.

Constructor & Destructor Documentation

MagGeoBuilderFromDDD::bLayer::bLayer ( handles::const_iterator  begin,
handles::const_iterator  end 
)

Constructor from list of volumes.

Definition at line 21 of file bLayer.cc.

References bin(), gather_cfg::cout, ddbox, ddtrap, MagGeoBuilderFromDDD::debug, i, evf::evtn::offset(), SurfaceOrientation::outer, precomputed_value_sort(), MagGeoBuilderFromDDD::volumeHandle::printUniqueNames(), svgfig::rotate(), GloballyPositioned< T >::rotation(), sectors, size, theVolumes, TkRotation< T >::zx(), TkRotation< T >::zy(), and TkRotation< T >::zz().

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

Destructor.

Definition at line 116 of file bLayer.cc.

116 {}

Member Function Documentation

int MagGeoBuilderFromDDD::bLayer::bin ( int  i) const
private

Definition at line 118 of file bLayer.cc.

References findQualityFiles::size.

Referenced by bLayer().

118  {
119  i = i%size;
120  return (i>=0?i:i+size);
121 }
int i
Definition: DBlmapReader.cc:9
MagBLayer * MagGeoBuilderFromDDD::bLayer::buildMagBLayer ( ) const

Construct the MagBLayer upon request.

Definition at line 140 of file bLayer.cc.

References gather_cfg::cout, MagGeoBuilderFromDDD::debug, i, and findQualityFiles::size.

140  {
141  if (mlayer==0) {
142 
143  // If we have only one volume, do not build any MagBSector.
144  if (sectors.size()==0) {
145  if (MagGeoBuilderFromDDD::debug && size!=0) {
146  std::cout << "ERROR: bLayer::buildMagBLayer, 0 sectors but "
147  << size << " volumes" << std::endl;
148  }
149  // Technically we might have only one bSector built and we would
150  // not need a separate MagBLayer constructor...
151  mlayer = new MagBLayer(theVolumes.front()->magVolume, minR());
152  }
153 
154  // If we have several sectors, create the MagBSector
155  std::vector<MagBSector*> mSectors;
156  for (unsigned int i=0; i<sectors.size(); ++i) {
157  mSectors.push_back(sectors[i].buildMagBSector());
158  }
159  mlayer = new MagBLayer(mSectors, minR());
160  }
161  return mlayer;
162 }
int i
Definition: DBlmapReader.cc:9
std::vector< bSector > sectors
Definition: bLayer.h:54
tuple cout
Definition: gather_cfg.py:41
double minR() const
Return sector at i (handling periodicity)
Definition: bLayer.cc:130
double MagGeoBuilderFromDDD::bLayer::minR ( ) const

Return sector at i (handling periodicity)

Min R (conservative guess).

Definition at line 130 of file bLayer.cc.

130  {
131  // ASSUMPTION: a layer is only 1 volume thick (by construction).
132  return theVolumes.front()->minR();
133 }
const float MagGeoBuilderFromDDD::bLayer::RN ( ) const
inline

Distance from center along normal of sectors.

Definition at line 28 of file bLayer.h.

References theVolumes.

28  {
29  return theVolumes.front()->RN();
30  }
const handles& MagGeoBuilderFromDDD::bLayer::volumes ( ) const
inline

Return the list of all volumes.

Definition at line 33 of file bLayer.h.

References theVolumes.

33 {return theVolumes;}

Member Data Documentation

MagBLayer* MagGeoBuilderFromDDD::bLayer::mlayer
mutableprivate

Definition at line 57 of file bLayer.h.

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

Definition at line 54 of file bLayer.h.

Referenced by bLayer().

int MagGeoBuilderFromDDD::bLayer::size
private

Definition at line 49 of file bLayer.h.

Referenced by bLayer().

handles MagGeoBuilderFromDDD::bLayer::theVolumes
private

Definition at line 55 of file bLayer.h.

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