16 #include "TDecompChol.h"
24 int subs[4] = { 3, 4, 1, 2 };
25 for (
int i=0;
i<4;
i++)
for (
int j=0;
j<4;
j++) cov44(
i,
j) = cov55( subs[
i], subs[
j] );
38 std::vector<TrajectoryMeasurement> measurements = traj->
measurements();
39 for (std::vector<TrajectoryMeasurement>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
74 m_dt2[chamberId]->addResidual(&tsos, hit);
83 m_dt13[chamberId]->addResidual(&tsos, hit);
92 if (cscDetId.
layer() == 0)
continue;
103 m_csc[chamberId]->addResidual(&tsos, hit);
135 for (std::vector<reco::MuonChamberMatch>::const_iterator chamberMatch =
muon->
matches().begin();
136 chamberMatch !=
muon->
matches().end(); chamberMatch++)
138 if (chamberMatch->id.det() !=
DetId::Muon )
continue;
140 for (std::vector<reco::MuonSegmentMatch>::const_iterator segMatch = chamberMatch->segmentMatches.begin();
141 segMatch != chamberMatch->segmentMatches.end(); ++segMatch)
149 const DTChamberId chamberId(chamberMatch->id.rawId());
153 if (segment == 0)
continue;
155 if ( segment->
hasPhi() && fabs(chamberMatch->x - segMatch->x) > maxResidual )
continue;
156 if ( segment->
hasZed() && fabs(chamberMatch->y - segMatch->y) > maxResidual )
continue;
170 else std::cout<<
"multi segment match to tmuon: dt2 -- should not happen!"<<std::endl;
171 m_dt2[chamberId]->setSegmentResidual(&(*chamberMatch), &(*segMatch));
180 else std::cout<<
"multi segment match to tmuon: dt13 -- should not happen!"<<std::endl;
181 m_dt13[chamberId]->setSegmentResidual(&(*chamberMatch), &(*segMatch));
187 const CSCDetId cscDetId(chamberMatch->id.rawId());
188 const CSCDetId chamberId(cscDetId.chamberId());
190 if ( fabs(chamberMatch->x - segMatch->x) > maxResidual )
continue;
199 else std::cout<<
"multi segment match to tmuon: csc -- should not happen!"<<std::endl;
200 m_csc[chamberId]->setSegmentResidual(&(*chamberMatch), &(*segMatch));
210 for (std::map<DetId,MuonChamberResidual*>::const_iterator residual =
m_dt13.begin(); residual !=
m_dt13.end(); ++residual) {
211 delete residual->second;
213 for (std::map<DetId,MuonChamberResidual*>::const_iterator residual =
m_dt2.begin(); residual !=
m_dt2.end(); ++residual) {
214 delete residual->second;
216 for (std::map<DetId,MuonChamberResidual*>::const_iterator residual =
m_csc.begin(); residual !=
m_csc.end(); ++residual) {
217 delete residual->second;
257 return m_dt2[chamberId];
261 return m_csc[chamberId];
270 std::cout<<
"MuonResidualsFromTrack:: cov initial:"<<std::endl;
274 std::cout<<
"MuonResidualsFromTrack:: cov does not exist!"<<std::endl;
279 std::cout<<
"MuonResidualsFromTrack:: cov before:"<<std::endl;
286 r_err =
m_csc[chamberId]->residual_error();
287 result(0,0) += r_err*r_err;
288 r_err =
m_csc[chamberId]->resslope_error();
289 result(2,2) += r_err*r_err;
293 r_err =
m_dt13[chamberId]->residual_error();
294 result(0,0) += r_err*r_err;
295 r_err =
m_dt13[chamberId]->resslope_error();
296 result(2,2) += r_err*r_err;
300 r_err =
m_dt2[chamberId]->residual_error();
301 result(1,1) += r_err*r_err;
302 r_err =
m_dt2[chamberId]->resslope_error();
303 result(3,3) += r_err*r_err;
305 std::cout<<
"MuonResidualsFromTrack:: cov after:"<<std::endl;
314 TMatrixDSym cov44 =
covMatrix(chamberId);
317 TDecompChol decomp(cov44);
318 bool ok = decomp.Invert(result);
319 std::cout<<
"MuonResidualsFromTrack:: corr after:"<<std::endl;
322 if (!ok){
std::cout<<
"MuonResidualsFromTrack:: cov inversion failed!"<<std::endl;}
332 TDecompChol decomp(corr44);
333 bool ok = decomp.Decompose();
334 result = decomp.GetU();
336 std::cout<<
"MuonResidualsFromTrack:: corr cholesky after:"<<std::endl;
339 if (!ok){
std::cout<<
"MuonResidualsFromTrack:: corr decomposition failed!"<<std::endl;}
std::vector< DetId > m_chamberIds
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
const reco::Track * track
virtual TrackRef innerTrack() const
TrajectoryStateOnSurface forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
bool isTrackerMuon() const
LocalPoint localPosition() const
std::map< DetId, MuonChamberResidual * > m_dt2
TMatrixDSym covMatrix(DetId chamberId)
std::map< DetId, MuonChamberResidual * > m_csc
ConstRecHitPointer recHit() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
LocalError positionError() const
static const unsigned int BestInStationByDR
bool isNonnull() const
Checks for non-null.
DataContainer const & measurements() const
MuonResidualsFromTrack(edm::ESHandle< GlobalTrackingGeometry > globalGeometry, const Trajectory *traj, const reco::Track *trk, AlignableNavigator *navigator, double maxResidual)
TMatrixDSym corrMatrix(DetId chamberId)
const AlgebraicSymMatrix55 & matrix() const
bool hasPhi() const
Does it have the Phi projection?
const LocalTrajectoryError & localError() const
double normalizedChi2() const
int superlayer() const
Return the superlayer number (deprecated method name)
bool hasZed() const
Does it have the Z projection?
~MuonResidualsFromTrack()
std::map< DetId, TMatrixDSym > m_trkCovMatrix
virtual LocalError localPositionError() const =0
TMatrixD choleskyCorrMatrix(DetId chamberId)
double trackerRedChi2() const
std::vector< MuonChamberMatch > & matches()
get muon matching information
void addTrkCovMatrix(DetId, TrajectoryStateOnSurface &)
static const unsigned int BelongsToTrackByDR
DetId geographicalId() const
T const * get() const
Returns C++ pointer to the item.
virtual LocalPoint localPosition() const =0
std::map< DetId, MuonChamberResidual * > m_dt13
AlignableDetOrUnitPtr alignableFromDetId(const DetId &detid)
Returns AlignableDetOrUnitPtr corresponding to given DetId.
TrajectoryStateOnSurface backwardPredictedState() const
Access to backward predicted state (from smoother)
TrajectoryStateCombiner m_tsoscomb
MuonChamberResidual * chamberResidual(DetId chamberId, int type)