Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:13

0001 /** \file GEMCSCSegment.cc
0002  *
0003  *  Based on CSCSegment class
0004  *  \author Raffaella Radogna
0005  */
0006 
0007 #include "DataFormats/GEMRecHit/interface/GEMCSCSegment.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include <iostream>
0010 
0011 namespace {
0012   // Get CSCDetId from one of the rechits, but then remove the layer part so it's a _chamber_ id
0013   inline DetId buildDetId(CSCDetId id) { return CSCDetId(id.endcap(), id.station(), id.ring(), id.chamber(), 0); }
0014 }  // namespace
0015 
0016 class ProjectionMatrixDiag {
0017   // Aider class to make the return of the projection Matrix thread-safe
0018 protected:
0019   AlgebraicMatrix theProjectionMatrix;
0020 
0021 public:
0022   ProjectionMatrixDiag() : theProjectionMatrix(4, 5, 0) {
0023     theProjectionMatrix[0][1] = 1;
0024     theProjectionMatrix[1][2] = 1;
0025     theProjectionMatrix[2][3] = 1;
0026     theProjectionMatrix[3][4] = 1;
0027   }
0028   const AlgebraicMatrix& getMatrix() const { return (theProjectionMatrix); }
0029 };
0030 
0031 GEMCSCSegment::GEMCSCSegment(const CSCSegment* csc_segment,
0032                              const std::vector<const GEMRecHit*> gem_rhs,
0033                              LocalPoint origin,
0034                              LocalVector direction,
0035                              AlgebraicSymMatrix errors,
0036                              double chi2)
0037     :
0038 
0039       RecSegment(buildDetId(csc_segment->cscDetId())),
0040       theOrigin(origin),
0041       theLocalDirection(direction),
0042       theCovMatrix(errors),
0043       theChi2(chi2) {
0044   for (unsigned int i = 0; i < gem_rhs.size(); ++i) {
0045     theGEMRecHits.push_back((*gem_rhs[i]));
0046   }
0047   theCSCSegment = *csc_segment;
0048   // LogDebug
0049   edm::LogVerbatim("GEMCSCSegment")
0050       << "[GEMCSCSegment :: ctor] CSCDetId: " << csc_segment->cscDetId()
0051       << " CSC RecHits: " << csc_segment->specificRecHits().size() << " GEM RecHits: " << gem_rhs.size()
0052       << "\n"  //  << " Fit chi2: "<<chi2<<" Position: "<<origin<<" Direction: "<<direction
0053       << "    CSC Segment Details: \n"
0054       << *csc_segment << "\n"
0055       << " GEMCSC Segment Details: \n"
0056       << *this << "\n"
0057       << "[GEMCSCSegment :: ctor] ------------------------------------------------------------";
0058 }
0059 
0060 GEMCSCSegment::~GEMCSCSegment() {}
0061 
0062 std::vector<const TrackingRecHit*> GEMCSCSegment::recHits() const {
0063   std::vector<const TrackingRecHit*> pointersOfRecHits;
0064   for (std::vector<GEMRecHit>::const_iterator irh = theGEMRecHits.begin(); irh != theGEMRecHits.end(); ++irh) {
0065     pointersOfRecHits.push_back(&(*irh));
0066   }
0067   for (std::vector<CSCRecHit2D>::const_iterator irh = theCSCSegment.specificRecHits().begin();
0068        irh != theCSCSegment.specificRecHits().end();
0069        ++irh) {
0070     pointersOfRecHits.push_back(&(*irh));
0071   }
0072   return pointersOfRecHits;
0073 }
0074 
0075 std::vector<TrackingRecHit*> GEMCSCSegment::recHits() {
0076   std::vector<TrackingRecHit*> pointersOfRecHits;
0077   for (std::vector<GEMRecHit>::iterator irh = theGEMRecHits.begin(); irh != theGEMRecHits.end(); ++irh) {
0078     pointersOfRecHits.push_back(&(*irh));
0079   }
0080   return pointersOfRecHits;
0081 }
0082 
0083 LocalError GEMCSCSegment::localPositionError() const {
0084   return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]);
0085 }
0086 
0087 LocalError GEMCSCSegment::localDirectionError() const {
0088   return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]);
0089 }
0090 
0091 AlgebraicVector GEMCSCSegment::parameters() const {
0092   // For consistency with DT, CSC and what we require for the TrackingRecHit interface,
0093   // the order of the parameters in the returned vector should be (dx/dz, dy/dz, x, z)
0094 
0095   AlgebraicVector result(4);
0096   if (theLocalDirection.z() != 0) {
0097     result[0] = theLocalDirection.x() / theLocalDirection.z();
0098     result[1] = theLocalDirection.y() / theLocalDirection.z();
0099   }
0100   result[2] = theOrigin.x();
0101   result[3] = theOrigin.y();
0102   return result;
0103 }
0104 
0105 AlgebraicMatrix GEMCSCSegment::projectionMatrix() const {
0106   static const ProjectionMatrixDiag theProjectionMatrix;
0107   return (theProjectionMatrix.getMatrix());
0108 }
0109 
0110 std::ostream& operator<<(std::ostream& os, const GEMCSCSegment& seg) {
0111   os << "GEMCSCSegment: local pos = " << seg.localPosition() << " posErr = (" << sqrt(seg.localPositionError().xx())
0112      << "," << sqrt(seg.localPositionError().yy()) << "0,)\n"
0113      << "            dir = " << seg.localDirection() << " dirErr = (" << sqrt(seg.localDirectionError().xx()) << ","
0114      << sqrt(seg.localDirectionError().yy()) << "0,)\n"
0115      << "            chi2/ndf = "
0116      << ((seg.degreesOfFreedom() != 0) ? (seg.chi2() / double(seg.degreesOfFreedom())) : 0.0)
0117      << " #rechits = " << seg.nRecHits();
0118   return os;
0119 }