Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
0002 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include "DataFormats/GeometrySurface/interface/SimpleDiskBounds.h"
0005 #include "DataFormats/GeometrySurface/interface/BoundingBox.h"
0006 #include "FWCore/Utilities/interface/Likely.h"
0007 
0008 using namespace std;
0009 
0010 ForwardDetLayer::~ForwardDetLayer() {}
0011 
0012 //--- Extension of the interface
0013 void ForwardDetLayer::setSurface(BoundDisk* cp) { theDisk = cp; }
0014 
0015 bool ForwardDetLayer::contains(const Local3DPoint& p) const { return surface().bounds().inside(p); }
0016 
0017 void ForwardDetLayer::initialize() { setSurface(computeSurface()); }
0018 
0019 BoundDisk* ForwardDetLayer::computeSurface() {
0020   LogDebug("DetLayers") << "ForwaLayer::computeSurface callded";
0021   vector<const GeomDet*> comps = basicComponents();
0022 
0023   vector<const GeomDet*>::const_iterator ifirst = comps.begin();
0024   vector<const GeomDet*>::const_iterator ilast = comps.end();
0025 
0026   // Find extension in R
0027   float theRmin = components().front()->position().perp();
0028   float theRmax = theRmin;
0029   float theZmin = components().back()->position().z();
0030   float theZmax = theZmin;
0031   for (vector<const GeomDet*>::const_iterator deti = ifirst; deti != ilast; deti++) {
0032     vector<GlobalPoint> corners = BoundingBox().corners(dynamic_cast<const Plane&>((**deti).surface()));
0033     for (vector<GlobalPoint>::const_iterator ic = corners.begin(); ic != corners.end(); ic++) {
0034       float r = ic->perp();
0035       LogDebug("DetLayers") << "corner.perp(): " << r;
0036       float z = ic->z();
0037       theRmin = min(theRmin, r);
0038       theRmax = max(theRmax, r);
0039       theZmin = min(theZmin, z);
0040       theZmax = max(theZmax, z);
0041     }
0042 
0043     // in addition to the corners we have to check the middle of the
0044     // det +/- length/2
0045     // , since the min (max) radius for typical fw dets is reached there
0046 
0047     float rdet = (**deti).position().perp();
0048     float len = (**deti).surface().bounds().length();
0049     float width = (**deti).surface().bounds().width();
0050 
0051     GlobalVector xAxis = (**deti).toGlobal(LocalVector(1, 0, 0));
0052     GlobalVector yAxis = (**deti).toGlobal(LocalVector(0, 1, 0));
0053     GlobalVector perpDir = GlobalVector((**deti).position() - GlobalPoint(0, 0, (**deti).position().z()));
0054 
0055     double xAxisCos = xAxis.unit().dot(perpDir.unit());
0056     double yAxisCos = yAxis.unit().dot(perpDir.unit());
0057 
0058     LogDebug("DetLayers") << "in ForwardDetLayer::computeSurface(),xAxisCos,yAxisCos: " << xAxisCos << " , "
0059                           << yAxisCos;
0060     LogDebug("DetLayers") << "det pos.perp,length,width: " << rdet << " , " << len << " , " << width;
0061 
0062     if (fabs(xAxisCos) > fabs(yAxisCos)) {
0063       theRmin = min(theRmin, rdet - width / 2.F);
0064       theRmax = max(theRmax, rdet + width / 2.F);
0065     } else {
0066       theRmin = min(theRmin, rdet - len / 2.F);
0067       theRmax = max(theRmax, rdet + len / 2.F);
0068     }
0069   }
0070 
0071   LogDebug("DetLayers") << "creating SimpleDiskBounds with r range" << theRmin << " " << theRmax << " and z range "
0072                         << theZmin << " " << theZmax;
0073 
0074   // By default the forward layers are positioned around the z axis of the
0075   // global frame, and the axes of their local frame coincide with
0076   // those of the global grame (z along the disk axis)
0077   float zPos = (theZmax + theZmin) / 2.;
0078   PositionType pos(0., 0., zPos);
0079   RotationType rot;
0080 
0081   return new BoundDisk(pos, rot, new SimpleDiskBounds(theRmin, theRmax, theZmin - zPos, theZmax - zPos));
0082 }
0083 
0084 pair<bool, TrajectoryStateOnSurface> ForwardDetLayer::compatible(const TrajectoryStateOnSurface& ts,
0085                                                                  const Propagator& prop,
0086                                                                  const MeasurementEstimator&) const {
0087   if UNLIKELY (theDisk == nullptr)
0088     edm::LogError("DetLayers") << "ERROR: BarrelDetLayer::compatible() is used before the layer surface is initialized";
0089   // throw an exception? which one?
0090 
0091   TrajectoryStateOnSurface myState = prop.propagate(ts, specificSurface());
0092   if UNLIKELY (!myState.isValid())
0093     return make_pair(false, myState);
0094 
0095   // check z;  (are we sure?????)
0096   // auto z = myState.localPosition().z();
0097   // if ( z<bounds().minZ | z>bounds().maxZ) return make_pair( false, myState);
0098 
0099   // check r
0100   auto r2 = myState.localPosition().perp2();
0101   if ((r2 > rmin() * rmin()) & (r2 < rmax() * rmax()))
0102     return make_pair(true, myState);
0103 
0104   // take into account the thickness of the layer
0105   float deltaR = 0.5f * bounds().thickness() * myState.localDirection().perp() / std::abs(myState.localDirection().z());
0106 
0107   // and take into account the error on the predicted state
0108   const float nSigma = 3.;
0109   if (myState.hasError()) {
0110     LocalError err = myState.localError().positionError();
0111     // ignore correlation for the moment...
0112     deltaR += nSigma * sqrt(err.xx() + err.yy());
0113   }
0114 
0115   // check r again;
0116   auto ri2 = std::max(rmin() - deltaR, 0.f);
0117   ri2 *= ri2;
0118   auto ro2 = rmax() + deltaR;
0119   ro2 *= ro2;
0120   return make_pair((r2 > ri2) & (r2 < ro2), myState);
0121 }