CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  * $Date: 2007/01/18 19:05:39 $
7  * $Revision: 1.3 $
8  * \author N. Amapane - INFN Torino
9  */
10 
16 
18 
19 #include <iostream>
20 
21 using namespace std;
22 
23 MagBLayer::MagBLayer(vector<MagBSector*>& sectors, double rMin) :
24  theSectors(sectors),
25  theSingleVolume(0),
26  theRMin(rMin),
27  theBinFinder(0)
28 {
29  // TOFIX
30 // if (verbose.debugOut) cout << "Building MagBLayer with " << theSectors.size()
31 // << " sectors, minR " << theRMin << endl;
32  //FIXME: PeriodicBinFinderInPhi gets *center* of first bin
33  theBinFinder = new PeriodicBinFinderInPhi<float>(theSectors.front()->minPhi()+Geom::pi()/12.,12);
34 
35 }
36 
38 MagBLayer::MagBLayer(MagVolume* aVolume, double rMin) :
39  theSingleVolume(0),
40  theRMin(rMin),
41  theBinFinder(0)
42 {
43  // TOFIX
44 // if (verbose.debugOut) cout << "Building MagBLayer with " << 0
45 // << " sectors, minR " << theRMin << endl;
46 }
47 
48 
49 
51  delete theBinFinder;
52 
53  delete theSingleVolume;
54 
55  for (vector<MagBSector *>::const_iterator isec = theSectors.begin();
56  isec != theSectors.end(); ++isec) {
57  delete (*isec);
58  }
59 }
60 
61 
62 MagVolume* MagBLayer::findVolume(const GlobalPoint & gp, double tolerance) const {
63  MagVolume * result = 0;
64 
65  //In case the layer is composed of a single volume...
66  if (theSingleVolume) {
67  // TOFIX
68 // if (verbose.debugOut) cout << " Trying the unique volume " << endl;
69  if (theSingleVolume->inside(gp, tolerance)) {
70  result = theSingleVolume;
71  // TOFIX
72 // if (verbose.debugOut) cout << "***In unique bsector"
73 // << (result==0? " failed " : " OK ") <<endl;
74  }
75  return result;
76  }
77 
78  // Normal cases - query the sectors.
79 
80  Geom::Phi<float> phi = gp.phi();
81 
82  // FIXME assume sectors are sorted in phi!
83  int bin= theBinFinder->binIndex(phi);
84  // TOFIX
85  if (verbose::debugOut) cout << " Trying sector at phi " << theSectors[bin]->minPhi()
86  << " " << phi << endl ;
87  result = theSectors[bin]->findVolume(gp, tolerance);
88  // TOFIX
89  if (verbose::debugOut) cout << "***In guessed bsector"
90  << (result==0? " failed " : " OK ") <<endl;
91 
92  if (result==0) { // If fails, can be in previous bin.
93  // TOFIX
94  if (verbose::debugOut) cout << " Trying sector at phi "
95  << theSectors[theBinFinder->binIndex(bin-1)]->minPhi()
96  << " " << phi << endl ;
97 
98  result = theSectors[theBinFinder->binIndex(bin-1)]->findVolume(gp, tolerance);
99  // TOFIX
100  if (verbose::debugOut) cout << "***In previous bsector"
101  << (result==0? " failed " : " OK ") <<endl;
102 
103  }
104  return result;
105 
106 }
107 
108 
109 
PeriodicBinFinderInPhi< float > * theBinFinder
Definition: MagBLayer.h:50
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
MagBLayer(std::vector< MagBSector * > &sectors, double rMin)
Constructor.
Definition: MagBLayer.cc:23
MagVolume * findVolume(const GlobalPoint &gp, double tolerance) const
Find the volume containing a point, with a given tolerance.
Definition: MagBLayer.cc:62
static bool debugOut
Definition: MagVerbosity.h:14
virtual int binIndex(T phi) const
returns an index in the valid range for the bin that contains phi
virtual bool inside(const GlobalPoint &gp, double tolerance=0.) const =0
tuple result
Definition: query.py:137
std::vector< MagBSector * > theSectors
Definition: MagBLayer.h:46
double pi()
Definition: Pi.h:31
MagVolume * theSingleVolume
Definition: MagBLayer.h:47
tuple cout
Definition: gather_cfg.py:41
virtual ~MagBLayer()
Destructor.
Definition: MagBLayer.cc:50
Definition: DDAxes.h:10