CMS 3D CMS Logo

SymmetricLayerFinder.cc
Go to the documentation of this file.
1 #include "SymmetricLayerFinder.h"
6 
7 #include <algorithm>
8 #include <cmath>
9 
10 using namespace std;
11 
13  ConstFDLI middle =
14  find_if(flc.begin(), flc.end(), [](const GeometricSearchDet* a) { return a->position().z() >= 0.0; });
15 
16  FDLC leftLayers = FDLC(flc.begin(), middle);
17  FDLC rightLayers = FDLC(middle, flc.end());
18  vector<PairType> foundPairs;
19 
20  for (FDLI i = leftLayers.begin(); i != leftLayers.end(); i++) {
21  const ForwardDetLayer* partner = mirrorPartner(*i, rightLayers);
22  //if ( partner == 0) throw DetLogicError("Assymmetric forward layers in Tracker");
23  if (partner == nullptr)
24  throw cms::Exception("SymmetricLayerFinder", "Assymmetric forward layers in Tracker");
25 
26  foundPairs.push_back(make_pair(*i, partner));
27  }
28 
29  // fill the map
30  for (vector<PairType>::iterator ipair = foundPairs.begin(); ipair != foundPairs.end(); ipair++) {
31  theForwardMap[ipair->first] = ipair->second;
32  theForwardMap[ipair->second] = ipair->first;
33  }
34 }
35 
36 const ForwardDetLayer* SymmetricLayerFinder::mirrorPartner(const ForwardDetLayer* layer, const FDLC& rightLayers) {
37  auto mirrorImage = [=](const ForwardDetLayer* a) -> bool {
38  auto zdiff = a->position().z() + layer->position().z();
39  auto rdiff = a->specificSurface().innerRadius() - layer->specificSurface().innerRadius();
40 
41  // equality based on z position and inner radius
42  return std::abs(zdiff) < 2.f && std::abs(rdiff) < 1.f; // units are cm
43  };
44 
45  ConstFDLI result = find_if(rightLayers.begin(), rightLayers.end(), mirrorImage);
46  if (result == rightLayers.end())
47  return nullptr;
48  else
49  return *result;
50 }
51 
53  FDLC result;
54  for (ConstFDLI i = input.begin(); i != input.end(); i++) {
55  result.push_back(mirror(*i));
56  }
57  return result;
58 }
SymmetricLayerFinder(const FDLC &)
const ForwardDetLayer * mirror(const ForwardDetLayer *layer)
static std::string const input
Definition: EdmProvDump.cc:50
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const ForwardDetLayer * mirrorPartner(const ForwardDetLayer *layer, const FDLC &rightLayers)
double a
Definition: hdecay.h:119
std::vector< const ForwardDetLayer * > FDLC
FDLC::const_iterator ConstFDLI