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 Attributes
MagGeoBuilderFromDDD::bSector Class Reference

#include <bSector.h>

Public Member Functions

 bSector ()
 Default ctor is needed to have arrays. More...
 
 bSector (handles::const_iterator begin, handles::const_iterator end)
 Constructor from list of volumes. More...
 
MagBSectorbuildMagBSector () const
 Construct the MagBSector upon request. More...
 
const handlesgetVolumes () const
 Return all volumes in this sector. More...
 
const float RN () const
 Distance from center along normal of sectors. More...
 
 ~bSector ()
 Destructor. More...
 

Private Attributes

MagBSectormsector
 
std::vector< bRodrods
 
handles volumes
 

Detailed Description

A sector of volumes in a barrel layer (i.e. only 1 element in R) One sector is composed of 1 or more rods.

Date:
2005/09/27 15:15:52
Revision:
1.2
Author
N. Amapane - INFN Torino

Definition at line 19 of file bSector.h.

Constructor & Destructor Documentation

MagGeoBuilderFromDDD::bSector::bSector ( )

Default ctor is needed to have arrays.

Definition at line 25 of file bSector.cc.

25 {}
MagGeoBuilderFromDDD::bSector::bSector ( handles::const_iterator  begin,
handles::const_iterator  end 
)

Constructor from list of volumes.

FIXME: (float) resolution; ??

Definition at line 30 of file bSector.cc.

References ClusterizingHistogram::clusterize(), gather_cfg::cout, MagGeoBuilderFromDDD::debug, f, ClusterizingHistogram::fill(), first, i, prof2calltree::last, MagGeoBuilderFromDDD::maxZ(), cmsRun_displayProdMFGeom_cfg::minZ, jptDQMConfig_cff::phiMax, jptDQMConfig_cff::phiMin, precomputed_value_sort(), MagGeoBuilderFromDDD::volumeHandle::printUniqueNames(), dtDQMClient_cfg::resolution, rods, and volumes.

31  :
32  volumes(begin,end),
33  msector(0)
34 {
35  if (MagGeoBuilderFromDDD::debug) cout << " Sector at Phi " << volumes.front()->center().phi() << " "
36  << volumes.back()->center().phi() << endl;
37 
38  if (volumes.size() == 1) {
40  cout << " Rod at: 0 elements: " << end-begin
41  << " unique volumes: ";
43  }
44  rods.push_back(bRod(begin,end));
45  } else {
46  // Clusterize in phi. Use bin edge so that complete clusters can be
47  // easily found (not trivial using bin centers!)
48  // Unfortunately this makes the result more sensitive to the
49  // "resolution" parameter...
50  // To avoid +-pi boundary problems, take phi distance from min phi.
51  // Caveat of implicit conversions of Geom::Phi!!!
52 
53  // Sort volumes in DELTA phi - i.e. phi(j)-phi(i) > 0 if j>1.
54  precomputed_value_sort(volumes.begin(), volumes.end(),
55  ExtractPhiMax(), LessDPhi());
56 
57  const Geom::Phi<float> resolution(0.01); // rad
58  Geom::Phi<float> phi0 = volumes.front()->maxPhi();
59  float phiMin = -(float) resolution;
60  float phiMax = volumes.back()->maxPhi() - phi0 + resolution;
61 
62  ClusterizingHistogram hisPhi( int((phiMax-phiMin)/resolution) + 1,
63  phiMin, phiMax);
64 
65  handles::const_iterator first = volumes.begin();
66  handles::const_iterator last = volumes.end();
67 
68  for (handles::const_iterator i=first; i!=last; ++i){
69  hisPhi.fill((*i)->maxPhi()-phi0);
70  }
71  vector<float> phiClust = hisPhi.clusterize(resolution);
72 
73  if (MagGeoBuilderFromDDD::debug) cout << " Found " << phiClust.size() << " clusters in Phi, "
74  << " rods: " << endl;
75 
76  handles::const_iterator rodStart = first;
77  handles::const_iterator separ = first;
78 
79  float DZ = (*max_element(first,last,LessZ()))->maxZ() -
80  (*min_element(first,last,LessZ()))->minZ();
81 
82  float DZ1 = 0.;
83  for (unsigned int i=0; i<phiClust.size(); ++i) {
84  float phiSepar;
85  if (i<phiClust.size()-1) {
86  phiSepar = (phiClust[i] + phiClust[i+1])/2.f;
87  } else {
88  phiSepar = phiMax;
89  }
90  if (MagGeoBuilderFromDDD::debug) cout << " cluster " << i
91  << " phisepar " << phiSepar <<endl;
92  while (separ < last && (*separ)->maxPhi()-phi0 < phiSepar ) {
93  DZ1 += ((*separ)->maxZ() - (*separ)->minZ());
94  if (MagGeoBuilderFromDDD::debug) cout << " " << (*separ)->name << " "
95  << (*separ)->maxPhi()-phi0 << " "
96  << (*separ)->maxZ() << " " << (*separ)->minZ() << " "
97  << DZ1 << endl;
98  ++separ;
99  }
100 
101  // FIXME: print warning for small discrepancies. Tolerance (below)
102  // had to be increased since discrepancies sum to up to ~ 2 mm.
103  if (fabs(DZ-DZ1) > 0.001 && fabs(DZ-DZ1) < 0.5) {
104  if (MagGeoBuilderFromDDD::debug) cout << "*** WARNING: Z lenght mismatch by " << DZ-DZ1
105  << " " << DZ << " " << DZ1 << endl;
106 
107  }
108  if (fabs(DZ-DZ1) > 0.25 ) { // FIXME hardcoded tolerance
109  if (MagGeoBuilderFromDDD::debug) cout << " Incomplete, use also next cluster: "
110  << DZ << " " << DZ1 << " " << DZ-DZ1 << endl;
111  DZ1 = 0.;
112  continue;
113  } else if (DZ1>DZ+0.05) { // Wrong: went past max lenght // FIXME hardcoded tolerance
114  cout << " *** ERROR: bSector finding messed up." << endl;
115  volumeHandle::printUniqueNames(rodStart, separ);
116  DZ1 = 0.;
117  } else {
119  cout << " Rod at: " << phiClust[i] <<" elements: "
120  << separ-rodStart << " unique volumes: ";
121  volumeHandle::printUniqueNames(rodStart, separ);
122  }
123 
124  rods.push_back(bRod(rodStart, separ));
125  rodStart = separ;
126  DZ1 = 0.;
127  }
128  }
129 
130  if (MagGeoBuilderFromDDD::debug) cout << "-----------------------" << endl;
131 
132  }
133 }
int i
Definition: DBlmapReader.cc:9
std::vector< bRod > rods
Definition: bSector.h:42
static void printUniqueNames(handles::const_iterator begin, handles::const_iterator end)
Just for debugging...
double f[11][100]
#define end
Definition: vmac.h:38
bool first
Definition: L1TdeRCT.cc:94
#define begin
Definition: vmac.h:31
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr)
tuple cout
Definition: gather_cfg.py:121
MagGeoBuilderFromDDD::bSector::~bSector ( )

Destructor.

Definition at line 27 of file bSector.cc.

27 {}

Member Function Documentation

MagBSector * MagGeoBuilderFromDDD::bSector::buildMagBSector ( ) const

Construct the MagBSector upon request.

Definition at line 136 of file bSector.cc.

136  {
137  if (msector==0) {
138  vector<MagBRod*> mRods;
139  for (vector<bRod>::const_iterator rod = rods.begin();
140  rod!=rods.end(); ++rod) {
141  mRods.push_back((*rod).buildMagBRod());
142  }
143  msector = new MagBSector(mRods, volumes.front()->minPhi()); //FIXME
144  }
145  return msector;
146 }
std::vector< bRod > rods
Definition: bSector.h:42
const handles& MagGeoBuilderFromDDD::bSector::getVolumes ( ) const
inline

Return all volumes in this sector.

Definition at line 36 of file bSector.h.

References volumes.

36 {return volumes;}
const float MagGeoBuilderFromDDD::bSector::RN ( ) const
inline

Distance from center along normal of sectors.

Definition at line 31 of file bSector.h.

References volumes.

31  {
32  return volumes.front()->RN();
33  }

Member Data Documentation

MagBSector* MagGeoBuilderFromDDD::bSector::msector
mutableprivate

Definition at line 44 of file bSector.h.

std::vector<bRod> MagGeoBuilderFromDDD::bSector::rods
private

Definition at line 42 of file bSector.h.

Referenced by bSector().

handles MagGeoBuilderFromDDD::bSector::volumes
private

Definition at line 43 of file bSector.h.

Referenced by bSector(), getVolumes(), and RN().