forked from cms-sw/cmssw
/
bSlab.cc
58 lines (48 loc) · 1.99 KB
/
bSlab.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* \file
* See header file for a description of this class.
*
* \author N. Amapane - INFN Torino
*/
#include "bSlab.h"
#include "MagneticField/VolumeGeometry/interface/MagVolume6Faces.h"
#include "MagneticField/Layers/interface/MagBSlab.h"
#include "Utilities/General/interface/precomputed_value_sort.h"
#include <iostream>
using namespace SurfaceOrientation;
using namespace std;
using namespace magneticfield;
bSlab::bSlab(handles::const_iterator begin, handles::const_iterator end, bool debugVal)
: volumes(begin, end), mslab(nullptr), debug(debugVal) {
if (volumes.size() > 1) {
// Sort volumes by dphi i.e. phi(j)-phi(i) > 0 if j>1.
precomputed_value_sort(volumes.begin(), volumes.end(), ExtractPhiMax(), LessDPhi());
if (debug)
cout << " Slab has " << volumes.size() << " volumes" << endl;
// Check that all volumes have the same dZ
handles::const_iterator i = volumes.begin();
float Zmax = (*i)->surface(zplus).position().z();
float Zmin = (*i)->surface(zminus).position().z();
for (++i; i != volumes.end(); ++i) {
const float epsilon = 0.001;
if (fabs(Zmax - (*i)->surface(zplus).position().z()) > epsilon ||
fabs(Zmin - (*i)->surface(zminus).position().z()) > epsilon) {
if (debug)
cout << "*** WARNING: slabs Z coords not matching: D_Zmax = "
<< fabs(Zmax - (*i)->surface(zplus).position().z())
<< " D_Zmin = " << fabs(Zmin - (*i)->surface(zminus).position().z()) << endl;
}
}
}
}
Geom::Phi<float> bSlab::minPhi() const { return volumes.front()->minPhi(); }
Geom::Phi<float> bSlab::maxPhi() const { return volumes.back()->maxPhi(); }
MagBSlab* bSlab::buildMagBSlab() const {
if (mslab == nullptr) {
vector<MagVolume*> mVols;
for (handles::const_iterator vol = volumes.begin(); vol != volumes.end(); ++vol) {
mVols.push_back((*vol)->magVolume);
}
mslab = new MagBSlab(mVols, volumes.front()->surface(zminus).position().z()); //FIXME
}
return mslab;
}