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), theSingleVolume(nullptr), theRMin(rMin), theBinFinder(nullptr) {
23  // LogTrace("MagGeometry") << "Building MagBLayer with " << theSectors.size()
24  // << " sectors, minR " << theRMin << endl;
25  //FIXME: PeriodicBinFinderInPhi gets *center* of first bin
26  theBinFinder = new PeriodicBinFinderInPhi<float>(theSectors.front()->minPhi() + Geom::pi() / 12., 12);
27 }
28 
30 MagBLayer::MagBLayer(MagVolume* aVolume, double rMin) : theSingleVolume(nullptr), theRMin(rMin), theBinFinder(nullptr) {
31  // LogTrace("MagGeometry") << "Building MagBLayer with " << 0
32  // << " sectors, minR " << theRMin << endl;
33 }
34 
36  delete theBinFinder;
37 
38  delete theSingleVolume;
39 
40  for (vector<MagBSector*>::const_iterator isec = theSectors.begin(); isec != theSectors.end(); ++isec) {
41  delete (*isec);
42  }
43 }
44 
45 const MagVolume* MagBLayer::findVolume(const GlobalPoint& gp, double tolerance) const {
46  const MagVolume* result = nullptr;
47 
48  //In case the layer is composed of a single volume...
49  if (theSingleVolume) {
50  // LogTrace("MagGeometry") << " Trying the unique volume " << endl;
53  // LogTrace("MagGeometry") << "***In unique bsector"
54  // << (result==0? " failed " : " OK ") <<endl;
55  }
56  return result;
57  }
58 
59  // Normal cases - query the sectors.
60 
61  Geom::Phi<float> phi = gp.phi();
62 
63  // FIXME assume sectors are sorted in phi!
64  int bin = theBinFinder->binIndex(phi);
65  LogTrace("MagGeometry") << " Trying sector at phi " << theSectors[bin]->minPhi() << " " << phi << endl;
66  result = theSectors[bin]->findVolume(gp, tolerance);
67  LogTrace("MagGeometry") << "***In guessed bsector" << (result == nullptr ? " failed " : " OK ") << endl;
68 
69  if (result == nullptr) { // If fails, can be in previous bin.
70  LogTrace("MagGeometry") << " Trying sector at phi " << theSectors[theBinFinder->binIndex(bin - 1)]->minPhi()
71  << " " << phi << endl;
72 
73  result = theSectors[theBinFinder->binIndex(bin - 1)]->findVolume(gp, tolerance);
74  LogTrace("MagGeometry") << "***In previous bsector" << (result == nullptr ? " failed " : " OK ") << endl;
75  }
76  return result;
77 }
MagVolume.h
Phi.h
PeriodicBinFinderInPhi.h
MessageLogger.h
MagBLayer::theSingleVolume
MagVolume * theSingleVolume
Definition: MagBLayer.h:46
MagBLayer::MagBLayer
MagBLayer(std::vector< MagBSector * > &sectors, double rMin)
Constructor.
Definition: MagBLayer.cc:21
MagBLayer.h
Geom::pi
constexpr double pi()
Definition: Pi.h:31
Point3DBase< float, GlobalTag >
MagVolume::inside
virtual bool inside(const GlobalPoint &gp, double tolerance=0.) const =0
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
MagVolume
Definition: MagVolume.h:13
tolerance
const double tolerance
Definition: HGCalGeomParameters.cc:29
Geom::Phi< float >
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
DDAxes::phi
MagBLayer::theSectors
std::vector< MagBSector * > theSectors
Definition: MagBLayer.h:45
std
Definition: JetResolutionObject.h:76
MagBLayer::~MagBLayer
virtual ~MagBLayer()
Destructor.
Definition: MagBLayer.cc:35
MagBSector.h
PeriodicBinFinderInPhi< float >
PeriodicBinFinderInPhi::binIndex
int binIndex(T phi) const override
returns an index in the valid range for the bin that contains phi
Definition: PeriodicBinFinderInPhi.h:25
photonAnalyzer_cfi.rMin
rMin
Definition: photonAnalyzer_cfi.py:90
mps_fire.result
result
Definition: mps_fire.py:311
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
volumeBasedMagneticField_160812_cfi.sectors
sectors
Definition: volumeBasedMagneticField_160812_cfi.py:59
MagBLayer::findVolume
const MagVolume * findVolume(const GlobalPoint &gp, double tolerance) const
Find the volume containing a point, with a given tolerance.
Definition: MagBLayer.cc:45
MagBLayer::theBinFinder
PeriodicBinFinderInPhi< float > * theBinFinder
Definition: MagBLayer.h:49