CMS 3D CMS Logo

MagBLayer.cc
Go to the documentation of this file.
1 // #include "Utilities/Configuration/interface/Architecture.h"
2 
3 /*
4  * See header file for a description of this class.
5  *
6  * \author N. Amapane - INFN Torino
7  */
8 
14 
16 
17 #include <iostream>
18 
19 using namespace std;
20 
21 MagBLayer::MagBLayer(vector<MagBSector*>& sectors, double rMin) :
22  theSectors(sectors),
23  theSingleVolume(nullptr),
24  theRMin(rMin),
25  theBinFinder(nullptr)
26 {
27  // TOFIX
28 // if (verbose.debugOut) cout << "Building MagBLayer with " << theSectors.size()
29 // << " sectors, minR " << theRMin << endl;
30  //FIXME: PeriodicBinFinderInPhi gets *center* of first bin
31  theBinFinder = new PeriodicBinFinderInPhi<float>(theSectors.front()->minPhi()+Geom::pi()/12.,12);
32 
33 }
34 
36 MagBLayer::MagBLayer(MagVolume* aVolume, double rMin) :
38  theRMin(rMin),
40 {
41  // TOFIX
42 // if (verbose.debugOut) cout << "Building MagBLayer with " << 0
43 // << " sectors, minR " << theRMin << endl;
44 }
45 
46 
47 
49  delete theBinFinder;
50 
51  delete theSingleVolume;
52 
53  for (vector<MagBSector *>::const_iterator isec = theSectors.begin();
54  isec != theSectors.end(); ++isec) {
55  delete (*isec);
56  }
57 }
58 
59 
60 const MagVolume* MagBLayer::findVolume(const GlobalPoint & gp, double tolerance) const {
61  const MagVolume * result = nullptr;
62 
63  //In case the layer is composed of a single volume...
64  if (theSingleVolume) {
65  // TOFIX
66 // if (verbose.debugOut) cout << " Trying the unique volume " << endl;
67  if (theSingleVolume->inside(gp, tolerance)) {
68  result = theSingleVolume;
69  // TOFIX
70 // if (verbose.debugOut) cout << "***In unique bsector"
71 // << (result==0? " failed " : " OK ") <<endl;
72  }
73  return result;
74  }
75 
76  // Normal cases - query the sectors.
77 
78  Geom::Phi<float> phi = gp.phi();
79 
80  // FIXME assume sectors are sorted in phi!
81  int bin= theBinFinder->binIndex(phi);
82  // TOFIX
83  if (verbose::debugOut) cout << " Trying sector at phi " << theSectors[bin]->minPhi()
84  << " " << phi << endl ;
85  result = theSectors[bin]->findVolume(gp, tolerance);
86  // TOFIX
87  if (verbose::debugOut) cout << "***In guessed bsector"
88  << (result==nullptr? " failed " : " OK ") <<endl;
89 
90  if (result==nullptr) { // If fails, can be in previous bin.
91  // TOFIX
92  if (verbose::debugOut) cout << " Trying sector at phi "
93  << theSectors[theBinFinder->binIndex(bin-1)]->minPhi()
94  << " " << phi << endl ;
95 
96  result = theSectors[theBinFinder->binIndex(bin-1)]->findVolume(gp, tolerance);
97  // TOFIX
98  if (verbose::debugOut) cout << "***In previous bsector"
99  << (result==nullptr? " failed " : " OK ") <<endl;
100 
101  }
102  return result;
103 
104 }
105 
106 
107 
double theRMin
Definition: MagBLayer.h:46
PeriodicBinFinderInPhi< float > * theBinFinder
Definition: MagBLayer.h:48
const MagVolume * findVolume(const GlobalPoint &gp, double tolerance) const
Find the volume containing a point, with a given tolerance.
Definition: MagBLayer.cc:60
const double tolerance
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
int binIndex(T phi) const override
returns an index in the valid range for the bin that contains phi
MagBLayer(std::vector< MagBSector * > &sectors, double rMin)
Constructor.
Definition: MagBLayer.cc:21
#define nullptr
virtual bool inside(const GlobalPoint &gp, double tolerance=0.) const =0
bin
set the eta bin as selection string.
std::vector< MagBSector * > theSectors
Definition: MagBLayer.h:44
MagVolume * theSingleVolume
Definition: MagBLayer.h:45
static constexpr bool debugOut
Definition: MagVerbosity.h:17
constexpr double pi()
Definition: Pi.h:31
virtual ~MagBLayer()
Destructor.
Definition: MagBLayer.cc:48