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 LocalError lape = det()->localAlignmentError();
00062 if (lape.valid()) {
00063
00064
00065 if(err.num_row() == 1) err[0][0] += lape.xx();
00066 else{
00067 AlgebraicSymMatrix lapeMatrix(5,0);
00068 lapeMatrix[3][3] = lape.xx();
00069 lapeMatrix[3][4] = lape.xy();
00070 lapeMatrix[4][4] = lape.yy();
00071
00072 AlgebraicSymMatrix lapeMatrixProj = lapeMatrix.similarity(projectionMatrix());
00073
00074 if(err.num_row() != lapeMatrixProj.num_row())
00075 throw cms::Exception("MuonTransientTrackingRecHit::parametersError")
00076 <<"Discrepancy between alignment error matrix and error matrix: APE "
00077 << lapeMatrixProj.num_row()
00078 << ", error matrix " << err.num_row()
00079 << std::endl;
00080
00081 err += lapeMatrixProj;
00082 }
00083 }
00084 return err;
00085 }
00086
00087 double MuonTransientTrackingRecHit::chi2() const
00088 {
00089 if (dynamic_cast<const RecSegment*>(hit()))
00090 return dynamic_cast<const RecSegment*>(hit())->chi2();
00091 else return 0.;
00092 }
00093
00094 int MuonTransientTrackingRecHit::degreesOfFreedom() const
00095 {
00096 if (dynamic_cast<const RecSegment*>(hit()))
00097 return dynamic_cast<const RecSegment*>(hit())->degreesOfFreedom();
00098 else return 0;
00099 }
00100
00101 bool MuonTransientTrackingRecHit::isDT() const{
00102 return (geographicalId().subdetId() == MuonSubdetId::DT);
00103 }
00104
00105 bool MuonTransientTrackingRecHit::isCSC() const{
00106 return (geographicalId().subdetId() == MuonSubdetId::CSC);
00107 }
00108
00109 bool MuonTransientTrackingRecHit::isRPC() const{
00110 return (geographicalId().subdetId() == MuonSubdetId::RPC);
00111 }
00112
00113
00114
00115 TransientTrackingRecHit::ConstRecHitContainer MuonTransientTrackingRecHit::transientHits() const{
00116
00117 ConstRecHitContainer theSubTransientRecHits;
00118
00119
00120 std::vector<const TrackingRecHit*> ownRecHits = recHits();
00121
00122 if(ownRecHits.size() == 0){
00123 theSubTransientRecHits.push_back(this);
00124 return theSubTransientRecHits;
00125 }
00126
00127
00128 std::vector<const GeomDet *> geomDets = det()->components();
00129
00130 if(isDT() && dimension() == 2 && ownRecHits.front()->dimension() == 1
00131 && (geomDets.size() == 3 || geomDets.size() == 2) ){
00132
00133 std::vector<const GeomDet *> subGeomDets;
00134
00135 int sl = 1;
00136 for(std::vector<const GeomDet *>::const_iterator geoDet = geomDets.begin();
00137 geoDet != geomDets.end(); ++geoDet){
00138 if(sl != 3){
00139 std::vector<const GeomDet *> tmp = (*geoDet)->components();
00140 std::copy(tmp.begin(),tmp.end(),back_inserter(subGeomDets));
00141 }
00142 ++sl;
00143 }
00144 geomDets.clear();
00145 geomDets = subGeomDets;
00146 }
00147
00148
00149 std::map<DetId,const GeomDet*> gemDetMap;
00150
00151 for (std::vector<const GeomDet*>::const_iterator subDet = geomDets.begin();
00152 subDet != geomDets.end(); ++subDet)
00153 gemDetMap[ (*subDet)->geographicalId() ] = *subDet;
00154
00155 std::map<DetId,const GeomDet*>::iterator gemDetMap_iter;
00156
00157
00158 for (std::vector<const TrackingRecHit*>::const_iterator rechit = ownRecHits.begin();
00159 rechit != ownRecHits.end(); ++rechit){
00160
00161 gemDetMap_iter = gemDetMap.find( (*rechit)->geographicalId() );
00162
00163 if(gemDetMap_iter != gemDetMap.end() )
00164 theSubTransientRecHits.push_back(new MuonTransientTrackingRecHit(gemDetMap_iter->second,
00165 *rechit) );
00166 else if( (*rechit)->geographicalId() == det()->geographicalId() )
00167 theSubTransientRecHits.push_back(new MuonTransientTrackingRecHit(det(),
00168 *rechit) );
00169 }
00170 return theSubTransientRecHits;
00171
00172 }