#include <MagneticField/GeomBuilder/src/bSector.h>
Public Member Functions | |
bSector (handles::const_iterator begin, handles::const_iterator end) | |
Constructor from list of volumes. | |
bSector () | |
Default ctor is needed to have arrays. | |
MagBSector * | buildMagBSector () const |
Construct the MagBSector upon request. | |
const handles & | getVolumes () const |
Return all volumes in this sector. | |
const float | RN () const |
Distance from center along normal of sectors. | |
~bSector () | |
Destructor. | |
Private Attributes | |
MagBSector * | msector |
std::vector< bRod > | rods |
handles | volumes |
only 1 element in R) One sector is composed of 1 or more rods.
Definition at line 19 of file bSector.h.
MagGeoBuilderFromDDD::bSector::bSector | ( | ) |
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(), GenMuonPlsPt100GeV_cfg::cout, MagGeoBuilderFromDDD::debug, lat::endl(), f, ClusterizingHistogram::fill(), first, i, prof2calltree::last, MagGeoBuilderFromDDD::maxZ(), precomputed_value_sort(), MagGeoBuilderFromDDD::volumeHandle::printUniqueNames(), rods, and volumes.
00031 : 00032 volumes(begin,end), 00033 msector(0) 00034 { 00035 if (MagGeoBuilderFromDDD::debug) cout << " Sector at Phi " << volumes.front()->center().phi() << " " 00036 << volumes.back()->center().phi() << endl; 00037 00038 if (volumes.size() == 1) { 00039 if (MagGeoBuilderFromDDD::debug) { 00040 cout << " Rod at: 0 elements: " << end-begin 00041 << " unique volumes: "; 00042 volumeHandle::printUniqueNames(begin,end); 00043 } 00044 rods.push_back(bRod(begin,end)); 00045 } else { 00046 // Clusterize in phi. Use bin edge so that complete clusters can be 00047 // easily found (not trivial using bin centers!) 00048 // Unfortunately this makes the result more sensitive to the 00049 // "resolution" parameter... 00050 // To avoid +-pi boundary problems, take phi distance from min phi. 00051 // Caveat of implicit conversions of Geom::Phi!!! 00052 00053 // Sort volumes in DELTA phi - i.e. phi(j)-phi(i) > 0 if j>1. 00054 precomputed_value_sort(volumes.begin(), volumes.end(), 00055 ExtractPhiMax(), LessDPhi()); 00056 00057 const Geom::Phi<float> resolution(0.01); // rad 00058 Geom::Phi<float> phi0 = volumes.front()->maxPhi(); 00059 float phiMin = -(float) resolution; 00060 float phiMax = volumes.back()->maxPhi() - phi0 + resolution; 00061 00062 ClusterizingHistogram hisPhi( int((phiMax-phiMin)/resolution) + 1, 00063 phiMin, phiMax); 00064 00065 handles::const_iterator first = volumes.begin(); 00066 handles::const_iterator last = volumes.end(); 00067 00068 for (handles::const_iterator i=first; i!=last; ++i){ 00069 hisPhi.fill((*i)->maxPhi()-phi0); 00070 } 00071 vector<float> phiClust = hisPhi.clusterize(resolution); 00072 00073 if (MagGeoBuilderFromDDD::debug) cout << " Found " << phiClust.size() << " clusters in Phi, " 00074 << " rods: " << endl; 00075 00076 handles::const_iterator rodStart = first; 00077 handles::const_iterator separ = first; 00078 00079 float DZ = (*max_element(first,last,LessZ()))->maxZ() - 00080 (*min_element(first,last,LessZ()))->minZ(); 00081 00082 float DZ1 = 0.; 00083 for (unsigned int i=0; i<phiClust.size(); ++i) { 00084 float phiSepar; 00085 if (i<phiClust.size()-1) { 00086 phiSepar = (phiClust[i] + phiClust[i+1])/2.f; 00087 } else { 00088 phiSepar = phiMax; 00089 } 00090 if (MagGeoBuilderFromDDD::debug) cout << " cluster " << i 00091 << " phisepar " << phiSepar <<endl; 00092 while (separ < last && (*separ)->maxPhi()-phi0 < phiSepar ) { 00093 DZ1 += ((*separ)->maxZ() - (*separ)->minZ()); 00094 if (MagGeoBuilderFromDDD::debug) cout << " " << (*separ)->name << " " 00095 << (*separ)->maxPhi()-phi0 << " " 00096 << (*separ)->maxZ() << " " << (*separ)->minZ() << " " 00097 << DZ1 << endl; 00098 ++separ; 00099 } 00100 00101 // FIXME: print warning for small discrepancies. Tolerance (below) 00102 // had to be increased since discrepancies sum to up to ~ 2 mm. 00103 if (fabs(DZ-DZ1) > 0.001 && fabs(DZ-DZ1) < 0.5) { 00104 if (MagGeoBuilderFromDDD::debug) cout << "*** WARNING: Z lenght mismatch by " << DZ-DZ1 00105 << " " << DZ << " " << DZ1 << endl; 00106 00107 } 00108 if (fabs(DZ-DZ1) > 0.25 ) { // FIXME hardcoded tolerance 00109 if (MagGeoBuilderFromDDD::debug) cout << " Incomplete, use also next cluster: " 00110 << DZ << " " << DZ1 << " " << DZ-DZ1 << endl; 00111 DZ1 = 0.; 00112 continue; 00113 } else if (DZ1>DZ+0.05) { // Wrong: went past max lenght // FIXME hardcoded tolerance 00114 cout << " *** ERROR: bSector finding messed up." << endl; 00115 volumeHandle::printUniqueNames(rodStart, separ); 00116 DZ1 = 0.; 00117 } else { 00118 if (MagGeoBuilderFromDDD::debug) { 00119 cout << " Rod at: " << phiClust[i] <<" elements: " 00120 << separ-rodStart << " unique volumes: "; 00121 volumeHandle::printUniqueNames(rodStart, separ); 00122 } 00123 00124 rods.push_back(bRod(rodStart, separ)); 00125 rodStart = separ; 00126 DZ1 = 0.; 00127 } 00128 } 00129 00130 if (MagGeoBuilderFromDDD::debug) cout << "-----------------------" << endl; 00131 00132 } 00133 }
MagGeoBuilderFromDDD::bSector::~bSector | ( | ) |
MagBSector * MagGeoBuilderFromDDD::bSector::buildMagBSector | ( | ) | const |
Construct the MagBSector upon request.
Definition at line 136 of file bSector.cc.
References msector, rods, and volumes.
00136 { 00137 if (msector==0) { 00138 vector<MagBRod*> mRods; 00139 for (vector<bRod>::const_iterator rod = rods.begin(); 00140 rod!=rods.end(); ++rod) { 00141 mRods.push_back((*rod).buildMagBRod()); 00142 } 00143 msector = new MagBSector(mRods, volumes.front()->minPhi()); //FIXME 00144 } 00145 return msector; 00146 }
const handles& MagGeoBuilderFromDDD::bSector::getVolumes | ( | ) | const [inline] |
const float MagGeoBuilderFromDDD::bSector::RN | ( | ) | const [inline] |
MagBSector* MagGeoBuilderFromDDD::bSector::msector [mutable, private] |
std::vector<bRod> MagGeoBuilderFromDDD::bSector::rods [private] |
Definition at line 43 of file bSector.h.
Referenced by bSector(), buildMagBSector(), getVolumes(), and RN().