Go to the documentation of this file.00001
00007 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
00008 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00009
00010 #include "DataFormats/GeometryCommonDetAlgo/interface/ErrorFrameTransformer.h"
00011 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
00012 #include "DataFormats/TrackingRecHit/interface/AlignmentPositionError.h"
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014
00015 #include "FWCore/Utilities/interface/Exception.h"
00016
00017 #include <map>
00018
00019 typedef MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer;
00020 typedef MuonTransientTrackingRecHit::RecHitContainer MuonRecHitContainer;
00021
00022
00023 MuonTransientTrackingRecHit::MuonTransientTrackingRecHit(const GeomDet* geom, const TrackingRecHit* rh) :
00024 GenericTransientTrackingRecHit(geom,*rh){}
00025
00026 MuonTransientTrackingRecHit::MuonTransientTrackingRecHit(const MuonTransientTrackingRecHit& other ) :
00027 GenericTransientTrackingRecHit(other.det(), *(other.hit())) {}
00028
00029
00030 LocalVector MuonTransientTrackingRecHit::localDirection() const {
00031
00032 if (dynamic_cast<const RecSegment*>(hit()) )
00033 return dynamic_cast<const RecSegment*>(hit())->localDirection();
00034 else return LocalVector(0.,0.,0.);
00035
00036 }
00037
00038 LocalError MuonTransientTrackingRecHit::localDirectionError() const {
00039
00040 if (dynamic_cast<const RecSegment*>(hit()))
00041 return dynamic_cast<const RecSegment*>(hit())->localDirectionError();
00042 else return LocalError(0.,0.,0.);
00043
00044 }
00045
00046 GlobalVector MuonTransientTrackingRecHit::globalDirection() const
00047 {
00048 return (det()->surface().toGlobal(localDirection()));
00049 }
00050
00051 GlobalError MuonTransientTrackingRecHit::globalDirectionError() const
00052 {
00053 return ErrorFrameTransformer().transform( localDirectionError(), (det()->surface()));
00054 }
00055
00056
00057 AlgebraicSymMatrix MuonTransientTrackingRecHit::parametersError() const {
00058
00059 AlgebraicSymMatrix err = GenericTransientTrackingRecHit::parametersError();
00060
00061 if (det()->alignmentPositionError() != 0) {
00062
00063 LocalError lape = ErrorFrameTransformer().transform(det()->alignmentPositionError()->globalError(), det()->surface());
00064
00065
00066 if(err.num_row() == 1) err[0][0] += lape.xx();
00067 else{
00068 AlgebraicSymMatrix lapeMatrix(5,0);
00069 lapeMatrix[3][3] = lape.xx();
00070 lapeMatrix[3][4] = lape.xy();
00071 lapeMatrix[4][4] = lape.yy();
00072
00073 AlgebraicSymMatrix lapeMatrixProj = lapeMatrix.similarity(projectionMatrix());
00074
00075 if(err.num_row() != lapeMatrixProj.num_row())
00076 throw cms::Exception("MuonTransientTrackingRecHit::parametersError")
00077 <<"Discrepancy between alignment error matrix and error matrix: APE "
00078 << lapeMatrixProj.num_row()
00079 << ", error matrix " << err.num_row()
00080 << std::endl;
00081
00082 err += lapeMatrixProj;
00083 }
00084 }
00085 return err;
00086 }
00087
00088 double MuonTransientTrackingRecHit::chi2() const
00089 {
00090 if (dynamic_cast<const RecSegment*>(hit()))
00091 return dynamic_cast<const RecSegment*>(hit())->chi2();
00092 else return 0.;
00093 }
00094
00095 int MuonTransientTrackingRecHit::degreesOfFreedom() const
00096 {
00097 if (dynamic_cast<const RecSegment*>(hit()))
00098 return dynamic_cast<const RecSegment*>(hit())->degreesOfFreedom();
00099 else return 0;
00100 }
00101
00102 bool MuonTransientTrackingRecHit::isDT() const{
00103 return (geographicalId().subdetId() == MuonSubdetId::DT);
00104 }
00105
00106 bool MuonTransientTrackingRecHit::isCSC() const{
00107 return (geographicalId().subdetId() == MuonSubdetId::CSC);
00108 }
00109
00110 bool MuonTransientTrackingRecHit::isRPC() const{
00111 return (geographicalId().subdetId() == MuonSubdetId::RPC);
00112 }
00113
00114
00115
00116 TransientTrackingRecHit::ConstRecHitContainer MuonTransientTrackingRecHit::transientHits() const{
00117
00118 ConstRecHitContainer theSubTransientRecHits;
00119
00120
00121 std::vector<const TrackingRecHit*> ownRecHits = recHits();
00122
00123 if(ownRecHits.size() == 0){
00124 theSubTransientRecHits.push_back(this);
00125 return theSubTransientRecHits;
00126 }
00127
00128
00129 std::vector<const GeomDet *> geomDets = det()->components();
00130
00131 if(isDT() && dimension() == 2 && ownRecHits.front()->dimension() == 1
00132 && (geomDets.size() == 3 || geomDets.size() == 2) ){
00133
00134 std::vector<const GeomDet *> subGeomDets;
00135
00136 int sl = 1;
00137 for(std::vector<const GeomDet *>::const_iterator geoDet = geomDets.begin();
00138 geoDet != geomDets.end(); ++geoDet){
00139 if(sl != 3){
00140 std::vector<const GeomDet *> tmp = (*geoDet)->components();
00141 std::copy(tmp.begin(),tmp.end(),back_inserter(subGeomDets));
00142 }
00143 ++sl;
00144 }
00145 geomDets.clear();
00146 geomDets = subGeomDets;
00147 }
00148
00149
00150 std::map<DetId,const GeomDet*> gemDetMap;
00151
00152 for (std::vector<const GeomDet*>::const_iterator subDet = geomDets.begin();
00153 subDet != geomDets.end(); ++subDet)
00154 gemDetMap[ (*subDet)->geographicalId() ] = *subDet;
00155
00156 std::map<DetId,const GeomDet*>::iterator gemDetMap_iter;
00157
00158
00159 for (std::vector<const TrackingRecHit*>::const_iterator rechit = ownRecHits.begin();
00160 rechit != ownRecHits.end(); ++rechit){
00161
00162 gemDetMap_iter = gemDetMap.find( (*rechit)->geographicalId() );
00163
00164 if(gemDetMap_iter != gemDetMap.end() )
00165 theSubTransientRecHits.push_back(new MuonTransientTrackingRecHit(gemDetMap_iter->second,
00166 *rechit) );
00167 else if( (*rechit)->geographicalId() == det()->geographicalId() )
00168 theSubTransientRecHits.push_back(new MuonTransientTrackingRecHit(det(),
00169 *rechit) );
00170 }
00171 return theSubTransientRecHits;
00172
00173 }