Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:32

0001 #include "TrackingTools/DetLayers/interface/TkLayerLess.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 bool TkLayerLess::insideOutLess(const DetLayer* a, const DetLayer* b) const {
0006   if (a == b)
0007     return false;
0008 
0009   const BarrelDetLayer* bla = dynamic_cast<const BarrelDetLayer*>(a);
0010   const BarrelDetLayer* blb = dynamic_cast<const BarrelDetLayer*>(b);
0011 
0012   if (bla != nullptr && blb != nullptr) {  // barrel with barrel
0013     return bla->specificSurface().radius() < blb->specificSurface().radius();
0014   }
0015 
0016   const ForwardDetLayer* flb = dynamic_cast<const ForwardDetLayer*>(b);
0017 
0018   if (bla != nullptr && flb != nullptr) {  // barrel with forward
0019     return barrelForwardLess(bla, flb);
0020   }
0021 
0022   const ForwardDetLayer* fla = dynamic_cast<const ForwardDetLayer*>(a);
0023 
0024   if (fla != nullptr && flb != nullptr) {  //  forward with forward
0025     return fabs(fla->position().z()) < fabs(flb->position().z());
0026   }
0027   if (fla != nullptr && blb != nullptr) {  // forward with barrel
0028     return !barrelForwardLess(blb, fla);
0029   }
0030   //throw DetLogicError("TkLayerLess: arguments are not Barrel or Forward DetLayers");
0031   throw cms::Exception("TkLayerLess", "Arguments are not Barrel or Forward DetLayers");
0032 }
0033 
0034 bool TkLayerLess::barrelForwardLess(const BarrelDetLayer* bla, const ForwardDetLayer* flb) const {
0035   return bla->surface().bounds().length() / 2. < fabs(flb->position().z());
0036 }
0037 
0038 bool TkLayerLess::insideOutLessSigned(const DetLayer* a, const DetLayer* b) const {
0039   if (a == b)
0040     return false;
0041 
0042   const BarrelDetLayer* bla = dynamic_cast<const BarrelDetLayer*>(a);
0043   const BarrelDetLayer* blb = dynamic_cast<const BarrelDetLayer*>(b);
0044 
0045   if (bla != nullptr && blb != nullptr) {  // barrel with barrel
0046     return bla->specificSurface().radius() < blb->specificSurface().radius();
0047   }
0048 
0049   const ForwardDetLayer* flb = dynamic_cast<const ForwardDetLayer*>(b);
0050 
0051   if (bla != nullptr && flb != nullptr) {  // barrel with forward
0052     return barrelForwardLess(bla, flb);
0053   }
0054 
0055   const ForwardDetLayer* fla = dynamic_cast<const ForwardDetLayer*>(a);
0056 
0057   if (fla != nullptr && flb != nullptr) {                 //  forward with forward
0058     if (fla->position().z() * flb->position().z() > 0) {  // same z-sign
0059       //regular ordering when same sign
0060       LogDebug("BeamHaloTkLayerLess") << "reaching this: " << theFromLayerSign << " " << fla->position().z() << " "
0061                                       << flb->position().z();
0062       return (fabs(fla->position().z()) < fabs(flb->position().z()));
0063     } else {  //layers compared are not on the same z-side
0064       LogDebug("BeamHaloTkLayerLess") << "reaching this at least: " << theFromLayerSign << " " << fla->position().z()
0065                                       << " " << flb->position().z();
0066 
0067       if (theFromLayerSign * fla->position().z() > 0) {
0068         //"fla" and original layer are on the same side
0069         //say that fla is less than flb
0070         return false;
0071       } else {
0072         return true;
0073       }
0074     }
0075   }
0076   if (fla != nullptr && blb != nullptr) {  // forward with barrel
0077     return !barrelForwardLess(blb, fla);
0078   }
0079   throw cms::Exception("BeamHaloTkLayerLess", "Arguments are not Barrel or Forward DetLayers");
0080 }