Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-12 03:09:41

0001 #include "SimpleForwardNavigableLayer.h"
0002 
0003 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
0004 #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
0005 #include "TrackingTools/DetLayers/interface/DetLayerException.h"
0006 
0007 #include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
0008 #include "DataFormats/GeometrySurface/interface/BoundDisk.h"
0009 
0010 #include "TrackingTools/DetLayers/interface/TkLayerLess.h"
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 #include "FWCore/Utilities/interface/Likely.h"
0013 
0014 using namespace std;
0015 
0016 SimpleForwardNavigableLayer::SimpleForwardNavigableLayer(const ForwardDetLayer* detLayer,
0017                                                          const BDLC& outerBL,
0018                                                          const FDLC& outerFL,
0019                                                          const MagneticField* field,
0020                                                          float epsilon,
0021                                                          bool checkCrossingSide)
0022     : SimpleNavigableLayer(field, epsilon, checkCrossingSide),
0023       theDetLayer(detLayer),
0024       theOuterBarrelLayers(outerBL),
0025       theInnerBarrelLayers(0),
0026       theOuterForwardLayers(outerFL),
0027       theInnerForwardLayers(0),
0028       theOuterLayers(0),
0029       theInnerLayers(0) {
0030   // put barrel and forward layers together
0031   theOuterLayers.reserve(outerBL.size() + outerFL.size());
0032   for (ConstBDLI bl = outerBL.begin(); bl != outerBL.end(); bl++)
0033     theOuterLayers.push_back(*bl);
0034   for (ConstFDLI fl = outerFL.begin(); fl != outerFL.end(); fl++)
0035     theOuterLayers.push_back(*fl);
0036 
0037   // sort the outer layers
0038   sort(theOuterLayers.begin(), theOuterLayers.end(), TkLayerLess());
0039   sort(theOuterForwardLayers.begin(), theOuterForwardLayers.end(), TkLayerLess());
0040   sort(theOuterBarrelLayers.begin(), theOuterBarrelLayers.end(), TkLayerLess());
0041 }
0042 
0043 vector<const DetLayer*> SimpleForwardNavigableLayer::nextLayers(NavigationDirection dir) const {
0044   vector<const DetLayer*> result;
0045 
0046   // the order is the one in which layers
0047   // should be checked for a reasonable trajectory
0048 
0049   if (dir == insideOut) {
0050     return theOuterLayers;
0051   } else {
0052     return theInnerLayers;
0053   }
0054 
0055   return result;
0056 }
0057 
0058 vector<const DetLayer*> SimpleForwardNavigableLayer::nextLayers(const FreeTrajectoryState& fts,
0059                                                                 PropagationDirection dir) const {
0060   // This method contains the sequence in which the layers are tested.
0061   // The iteration stops as soon as a layer contains the propagated state
0062   // within epsilon
0063 
0064   vector<const DetLayer*> result;
0065 
0066   FreeTrajectoryState ftsWithoutErrors = (fts.hasError()) ? FreeTrajectoryState(fts.parameters()) : fts;
0067 
0068   auto const position = fts.position();
0069   auto const momentum = fts.momentum();
0070 
0071   //establish whether the tracks is crossing the tracker from outer layers to inner ones
0072   //or from inner to outer
0073   float zpos = position.z();
0074   bool isInOutTrackFWD = momentum.z() * zpos > 0;
0075   GlobalVector transversePosition(position.x(), position.y(), 0);
0076   bool isInOutTrackBarrel = (transversePosition.dot(momentum) > 0);
0077 
0078   //establish whether inner or outer layers are crossed after propagation, according
0079   //to BOTH propagationDirection AND track momentum
0080   bool dirOppositeXORisInOutTrackBarrel =
0081       (!(dir == oppositeToMomentum) && isInOutTrackBarrel) || ((dir == oppositeToMomentum) && !isInOutTrackBarrel);
0082   bool dirOppositeXORisInOutTrackFWD =
0083       (!(dir == oppositeToMomentum) && isInOutTrackFWD) || ((dir == oppositeToMomentum) && !isInOutTrackFWD);
0084   //bool dirOppositeXORisInOutTrack = ( !(dir == oppositeToMomentum) && isInOutTrack) || ( (dir == oppositeToMomentum) && !isInOutTrack);
0085 
0086   if LIKELY (dirOppositeXORisInOutTrackFWD && dirOppositeXORisInOutTrackBarrel) {  //standard tracks
0087     wellInside(ftsWithoutErrors, dir, theOuterLayers, result);
0088   } else if (!dirOppositeXORisInOutTrackFWD && !dirOppositeXORisInOutTrackBarrel) {  // !dirOppositeXORisInOutTrack
0089     wellInside(ftsWithoutErrors, dir, theInnerLayers, result);
0090   } else if (!dirOppositeXORisInOutTrackFWD && dirOppositeXORisInOutTrackBarrel) {
0091     wellInside(ftsWithoutErrors, dir, theInnerForwardLayers.begin(), theInnerForwardLayers.end(), result);
0092     wellInside(ftsWithoutErrors, dir, theOuterBarrelLayers.begin(), theOuterBarrelLayers.end(), result);
0093   } else {
0094     wellInside(ftsWithoutErrors, dir, theInnerBarrelLayers.begin(), theInnerBarrelLayers.end(), result);
0095     wellInside(ftsWithoutErrors, dir, theOuterForwardLayers.begin(), theOuterForwardLayers.end(), result);
0096   }
0097 
0098   return result;
0099 }
0100 
0101 vector<const DetLayer*> SimpleForwardNavigableLayer::compatibleLayers(NavigationDirection dir) const {
0102   edm::LogError("TkNavigation") << "ERROR: compatibleLayers() method used without all reachableLayers are set";
0103   throw DetLayerException("compatibleLayers() method used without all reachableLayers are set");
0104   return vector<const DetLayer*>();
0105 }
0106 
0107 void SimpleForwardNavigableLayer::setDetLayer(const DetLayer* dl) {
0108   cerr << "Warning: SimpleForwardNavigableLayer::setDetLayer called." << endl << "This should never happen!" << endl;
0109 }
0110 
0111 void SimpleForwardNavigableLayer::setInwardLinks(const BDLC& innerBL, const FDLC& innerFL, TkLayerLess sorter) {
0112   theInnerBarrelLayers = innerBL;
0113   theInnerForwardLayers = innerFL;
0114 
0115   theInnerLayers.clear();
0116   theInnerLayers.reserve(innerBL.size() + innerFL.size());
0117   for (ConstBDLI bl = innerBL.begin(); bl != innerBL.end(); bl++)
0118     theInnerLayers.push_back(*bl);
0119   for (ConstFDLI fl = innerFL.begin(); fl != innerFL.end(); fl++)
0120     theInnerLayers.push_back(*fl);
0121 
0122   // sort the inner layers
0123   sort(theInnerLayers.begin(), theInnerLayers.end(), sorter);
0124   sort(theInnerForwardLayers.begin(), theInnerForwardLayers.end(), sorter);
0125   sort(theInnerBarrelLayers.begin(), theInnerBarrelLayers.end(), sorter);
0126 }
0127 
0128 void SimpleForwardNavigableLayer::setAdditionalLink(const DetLayer* additional, NavigationDirection direction) {
0129   const ForwardDetLayer* fadditional = dynamic_cast<const ForwardDetLayer*>(additional);
0130   const BarrelDetLayer* badditional = dynamic_cast<const BarrelDetLayer*>(additional);
0131   if (badditional) {
0132     if (direction == insideOut) {
0133       theOuterBarrelLayers.push_back(badditional);
0134       theOuterLayers.push_back(badditional);
0135       return;
0136     }
0137     theInnerBarrelLayers.push_back(badditional);
0138     theInnerLayers.push_back(badditional);
0139     return;
0140   } else if (fadditional) {
0141     if (direction == insideOut) {
0142       theOuterForwardLayers.push_back(fadditional);
0143       theOuterLayers.push_back(badditional);
0144       return;
0145     }
0146     theInnerForwardLayers.push_back(fadditional);
0147     theInnerLayers.push_back(badditional);
0148     return;
0149   }
0150   edm::LogError("TkNavigation") << "trying to add neither a ForwardDetLayer nor a BarrelDetLayer";
0151   return;
0152 }