CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SymmetricLayerFinder.cc
Go to the documentation of this file.
7 
8 #include <functional>
9 #include <algorithm>
10 #include <cmath>
11 
12 using namespace std;
13 
15  public unary_function< const ForwardDetLayer*, bool> {
16 public:
17 
18  ForwardLayerMirrorImage( const ForwardDetLayer* layer) : theLayer(layer) {}
19 
20  bool operator()( const ForwardDetLayer* a) {
21  float zdiff = a->position().z() + theLayer->position().z();
22  float rdiff = a->specificSurface().innerRadius() -
23  theLayer->specificSurface().innerRadius();
24 
25  // equality based on z position and inner radius
26  if ( fabs( zdiff) < 1. && fabs( rdiff) < 1.) return true; // units are cm
27  else return false;
28  }
29 
30 private:
32 };
33 
35 {
36  ConstFDLI middle = find_if( flc.begin(), flc.end(), not1(DetBelowZ(0)));
37 
38  FDLC leftLayers = FDLC( flc.begin(), middle);
39  FDLC rightLayers = FDLC( middle, flc.end());
40  vector<PairType> foundPairs;
41 
42  for ( FDLI i = leftLayers.begin(); i != leftLayers.end(); i++) {
43  ForwardDetLayer* partner = mirrorPartner( *i, rightLayers);
44  //if ( partner == 0) throw DetLogicError("Assymmetric forward layers in Tracker");
45  if ( partner == 0) throw Genexception("Assymmetric forward layers in Tracker");
46 
47  foundPairs.push_back( make_pair( *i, partner));
48  }
49 
50  // fill the map
51  for ( vector<PairType>::iterator ipair = foundPairs.begin();
52  ipair != foundPairs.end(); ipair++) {
53  theForwardMap[ipair->first] = ipair->second;
54  theForwardMap[ipair->second] = ipair->first;
55  }
56 }
57 
59  const FDLC& rightLayers)
60 {
62  find_if( rightLayers.begin(), rightLayers.end(), ForwardLayerMirrorImage(layer));
63  if ( result == rightLayers.end()) return 0;
64  else return *result;
65 }
66 
69  FDLC result;
70  for ( ConstFDLI i = input.begin(); i != input.end(); i++) {
71  result.push_back( mirror(*i));
72  }
73  return result;
74 }
SymmetricLayerFinder(const FDLC &)
int i
Definition: DBlmapReader.cc:9
ForwardDetLayer * mirrorPartner(const ForwardDetLayer *layer, const FDLC &rightLayers)
const ForwardDetLayer * theLayer
std::vector< ForwardDetLayer * > FDLC
bool operator()(const ForwardDetLayer *a)
T z() const
Definition: PV3DBase.h:58
tuple result
Definition: query.py:137
virtual const BoundDisk & specificSurface() const
tuple input
Definition: collect_tpl.py:10
virtual const Surface::PositionType & position() const
Returns position of the surface.
double a
Definition: hdecay.h:121
float innerRadius() const
The inner radius of the disk.
Definition: BoundDisk.cc:6
ForwardDetLayer * mirror(const ForwardDetLayer *layer)
ForwardLayerMirrorImage(const ForwardDetLayer *layer)
FDLC::const_iterator ConstFDLI