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!

Author
N. Amapane - INFN Torino

Definition at line 17 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 19 of file bLayer.cc.

References bin(), gather_cfg::cout, ddbox, ddtrap, MagGeoBuilderFromDDD::debug, i, hltrates_dqm_sourceclient-live_cfg::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().

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

Destructor.

Definition at line 114 of file bLayer.cc.

114 {}

Member Function Documentation

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

Definition at line 116 of file bLayer.cc.

References findQualityFiles::size.

Referenced by bLayer().

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

Construct the MagBLayer upon request.

Definition at line 138 of file bLayer.cc.

References gather_cfg::cout, MagGeoBuilderFromDDD::debug, i, HLT_25ns10e33_v2_cff::minR, mergeVDriftHistosByStation::sectors, and findQualityFiles::size.

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

Return sector at i (handling periodicity)

Min R (conservative guess).

Definition at line 128 of file bLayer.cc.

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

Distance from center along normal of sectors.

Definition at line 26 of file bLayer.h.

References theVolumes.

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

Return the list of all volumes.

Definition at line 31 of file bLayer.h.

References theVolumes.

31 {return theVolumes;}

Member Data Documentation

MagBLayer* MagGeoBuilderFromDDD::bLayer::mlayer
mutableprivate

Definition at line 55 of file bLayer.h.

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

Definition at line 52 of file bLayer.h.

Referenced by bLayer().

int MagGeoBuilderFromDDD::bLayer::size
private

Definition at line 47 of file bLayer.h.

Referenced by cuy.FindIssue::__init__(), and bLayer().

handles MagGeoBuilderFromDDD::bLayer::theVolumes
private

Definition at line 53 of file bLayer.h.

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