Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:51

0001 #include "SymmetricLayerFinder.h"
0002 #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
0003 #include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
0004 #include "DataFormats/GeometrySurface/interface/BoundDisk.h"
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 
0007 #include <algorithm>
0008 #include <cmath>
0009 
0010 using namespace std;
0011 
0012 SymmetricLayerFinder::SymmetricLayerFinder(const FDLC& flc) {
0013   ConstFDLI middle =
0014       find_if(flc.begin(), flc.end(), [](const GeometricSearchDet* a) { return a->position().z() >= 0.0; });
0015 
0016   FDLC leftLayers = FDLC(flc.begin(), middle);
0017   FDLC rightLayers = FDLC(middle, flc.end());
0018   vector<PairType> foundPairs;
0019 
0020   for (FDLI i = leftLayers.begin(); i != leftLayers.end(); i++) {
0021     const ForwardDetLayer* partner = mirrorPartner(*i, rightLayers);
0022     //if ( partner == 0) throw DetLogicError("Assymmetric forward layers in Tracker");
0023     if (partner == nullptr)
0024       throw cms::Exception("SymmetricLayerFinder", "Assymmetric forward layers in Tracker");
0025 
0026     foundPairs.push_back(make_pair(*i, partner));
0027   }
0028 
0029   // fill the map
0030   for (vector<PairType>::iterator ipair = foundPairs.begin(); ipair != foundPairs.end(); ipair++) {
0031     theForwardMap[ipair->first] = ipair->second;
0032     theForwardMap[ipair->second] = ipair->first;
0033   }
0034 }
0035 
0036 const ForwardDetLayer* SymmetricLayerFinder::mirrorPartner(const ForwardDetLayer* layer, const FDLC& rightLayers) {
0037   auto mirrorImage = [=](const ForwardDetLayer* a) -> bool {
0038     auto zdiff = a->position().z() + layer->position().z();
0039     auto rdiff = a->specificSurface().innerRadius() - layer->specificSurface().innerRadius();
0040 
0041     // equality based on z position and inner radius
0042     return std::abs(zdiff) < 2.f && std::abs(rdiff) < 1.f;  // units are cm
0043   };
0044 
0045   ConstFDLI result = find_if(rightLayers.begin(), rightLayers.end(), mirrorImage);
0046   if (result == rightLayers.end())
0047     return nullptr;
0048   else
0049     return *result;
0050 }
0051 
0052 SymmetricLayerFinder::FDLC SymmetricLayerFinder::mirror(const FDLC& input) {
0053   FDLC result;
0054   for (ConstFDLI i = input.begin(); i != input.end(); i++) {
0055     result.push_back(mirror(*i));
0056   }
0057   return result;
0058 }