103 using namespace reco;
132 CLHEP::HepSymMatrix&,
147 void writeGlPosRcd(CLHEP::HepVector& d3);
148 inline double CLHEP_dot(
const CLHEP::HepVector&
a,
const CLHEP::HepVector&
b) {
149 return a(1) *
b(1) +
a(2) *
b(2) +
a(3) *
b(3);
155 void endJob()
override;
208 std::vector<AlignTransform>::const_iterator
273 : trackTags_(iConfig.getParameter<
edm::
InputTag>(
"tracks")),
274 muonTags_(iConfig.getParameter<
edm::
InputTag>(
"muons")),
275 gmuonTags_(iConfig.getParameter<
edm::
InputTag>(
"gmuons")),
276 smuonTags_(iConfig.getParameter<
edm::
InputTag>(
"smuons")),
277 propagator_(iConfig.getParameter<
string>(
"Propagator")),
279 cosmicMuonMode_(iConfig.getParameter<
bool>(
"cosmics")),
280 isolatedMuonMode_(iConfig.getParameter<
bool>(
"isolated")),
282 refitMuon_(iConfig.getParameter<
bool>(
"refitmuon")),
283 refitTrack_(iConfig.getParameter<
bool>(
"refittrack")),
285 rootOutFile_(iConfig.getUntrackedParameter<
string>(
"rootOutFile")),
286 txtOutFile_(iConfig.getUntrackedParameter<
string>(
"txtOutFile")),
287 writeDB_(iConfig.getUntrackedParameter<
bool>(
"writeDB")),
288 debug_(iConfig.getUntrackedParameter<
bool>(
"debug")),
290 #ifdef NO_FALSE_FALSE_MODE 293 <<
"Use from GlobalTrackerMuonAlignment_test_cfg.py.";
297 throw cms::Exception(
"BadConfig") <<
"Muon collection can be either cosmic or isolated! " 298 <<
"Please set only one to true.";
333 for (
int i = 0;
i <= 2;
i++) {
335 for (
int j = 0; j <= 2; j++) {
340 Grad = CLHEP::HepVector(6, 0);
341 Hess = CLHEP::HepSymMatrix(6, 0);
343 GradL = CLHEP::HepVector(6, 0);
344 HessL = CLHEP::HepSymMatrix(6, 0);
347 TDirectory* dirsave = gDirectory;
350 const bool oldAddDir = TH1::AddDirectoryStatus();
352 TH1::AddDirectory(
true);
356 TH1::AddDirectory(oldAddDir);
369 for (
int i = 0;
i <= 2;
i++)
370 for (
int j = 0; j <= 2; j++) {
373 InfI(
i, j) +=
Inf(
i, j);
375 bool ierr = !InfI.Invert();
378 std::cout <<
" Error inverse Inf matrix !!!!!!!!!!!" << std::endl;
381 for (
int i = 0;
i <= 2;
i++)
382 for (
int k = 0;
k <= 2;
k++)
387 CLHEP::HepVector d3 = CLHEP::solve(
Hess, -
Grad);
389 CLHEP::HepMatrix Errd3 =
Hess.inverse(iEr3);
392 std::cout <<
" endJob Error inverse Hess matrix !!!!!!!!!!!" << std::endl;
397 CLHEP::HepVector dLI = CLHEP::solve(
HessL, -
GradL);
399 CLHEP::HepMatrix ErrdLI =
HessL.inverse(iErI);
402 std::cout <<
" endJob Error inverse HessL matrix !!!!!!!!!!!" << std::endl;
409 std::cout <<
" ALCARECOMuAlCalIsolatedMu " << std::endl;
411 std::cout <<
" ALCARECOMuAlGlobalCosmics " << std::endl;
418 std::cout <<
" +- " <<
sqrt(InfI(0, 0)) <<
" " <<
sqrt(InfI(1, 1)) <<
" " <<
sqrt(InfI(2, 2)) << std::endl;
419 std::cout <<
" dG " << d3(1) <<
" " << d3(2) <<
" " << d3(3) <<
" " << d3(4) <<
" " << d3(5) <<
" " << d3(6)
422 std::cout <<
" +- " <<
sqrt(Errd3(1, 1)) <<
" " <<
sqrt(Errd3(2, 2)) <<
" " <<
sqrt(Errd3(3, 3)) <<
" " 423 <<
sqrt(Errd3(4, 4)) <<
" " <<
sqrt(Errd3(5, 5)) <<
" " <<
sqrt(Errd3(6, 6)) << std::endl;
424 std::cout <<
" dL " << dLI(1) <<
" " << dLI(2) <<
" " << dLI(3) <<
" " << dLI(4) <<
" " << dLI(5) <<
" " << dLI(6)
427 std::cout <<
" +- " <<
sqrt(ErrdLI(1, 1)) <<
" " <<
sqrt(ErrdLI(2, 2)) <<
" " <<
sqrt(ErrdLI(3, 3)) <<
" " 428 <<
sqrt(ErrdLI(4, 4)) <<
" " <<
sqrt(ErrdLI(5, 5)) <<
" " <<
sqrt(ErrdLI(6, 6)) << std::endl;
431 CLHEP::HepVector vectorToDb(6, 0), vectorErrToDb(6, 0);
435 for (
unsigned int i = 1;
i <= 6;
i++)
436 vectorErrToDb(
i) =
sqrt(ErrdLI(
i,
i));
445 std::cout <<
" outglobal.txt is not open !!!!!" << std::endl;
447 OutGlobalTxt << vectorToDb(1) <<
" " << vectorToDb(2) <<
" " << vectorToDb(3) <<
" " << vectorToDb(4) <<
" " 448 << vectorToDb(5) <<
" " << vectorToDb(6) <<
" muon Global.\n";
449 OutGlobalTxt << vectorErrToDb(1) <<
" " << vectorErrToDb(1) <<
" " << vectorErrToDb(1) <<
" " << vectorErrToDb(1)
450 <<
" " << vectorErrToDb(1) <<
" " << vectorErrToDb(1) <<
" errors.\n";
460 std::cout <<
" Write to the file outglobal.txt done " << std::endl;
472 double PI = 3.1415927;
473 histo =
new TH1F(
"Pt",
"pt", 1000, 0, 100);
474 histo2 =
new TH1F(
"P",
"P [GeV/c]", 400, 0., 400.);
475 histo2->GetXaxis()->SetTitle(
"momentum [GeV/c]");
476 histo3 =
new TH1F(
"outerLambda",
"#lambda outer", 100, -PI / 2., PI / 2.);
477 histo3->GetXaxis()->SetTitle(
"#lambda outer");
478 histo4 =
new TH1F(
"phi",
"#phi [rad]", 100, -PI, PI);
479 histo4->GetXaxis()->SetTitle(
"#phi [rad]");
480 histo5 =
new TH1F(
"Rmuon",
"inner muon hit R [cm]", 100, 0., 800.);
481 histo5->GetXaxis()->SetTitle(
"R of muon [cm]");
482 histo6 =
new TH1F(
"Zmuon",
"inner muon hit Z[cm]", 100, -1000., 1000.);
483 histo6->GetXaxis()->SetTitle(
"Z of muon [cm]");
484 histo7 =
new TH1F(
"(Pm-Pt)/Pt",
" (Pmuon-Ptrack)/Ptrack", 100, -2., 2.);
485 histo7->GetXaxis()->SetTitle(
"(Pmuon-Ptrack)/Ptrack");
486 histo8 =
new TH1F(
"chi muon-track",
"#chi^{2}(muon-track)", 1000, 0., 1000.);
487 histo8->GetXaxis()->SetTitle(
"#chi^{2} of muon w.r.t. propagated track");
488 histo11 =
new TH1F(
"distance muon-track",
"distance muon w.r.t track [cm]", 100, 0., 30.);
489 histo11->GetXaxis()->SetTitle(
"distance of muon w.r.t. track [cm]");
490 histo12 =
new TH1F(
"Xmuon-Xtrack",
"Xmuon-Xtrack [cm]", 200, -20., 20.);
491 histo12->GetXaxis()->SetTitle(
"Xmuon - Xtrack [cm]");
492 histo13 =
new TH1F(
"Ymuon-Ytrack",
"Ymuon-Ytrack [cm]", 200, -20., 20.);
493 histo13->GetXaxis()->SetTitle(
"Ymuon - Ytrack [cm]");
494 histo14 =
new TH1F(
"Zmuon-Ztrack",
"Zmuon-Ztrack [cm]", 200, -20., 20.);
495 histo14->GetXaxis()->SetTitle(
"Zmuon-Ztrack [cm]");
496 histo15 =
new TH1F(
"NXmuon-NXtrack",
"NXmuon-NXtrack [rad]", 200, -.1, .1);
497 histo15->GetXaxis()->SetTitle(
"N_{X}(muon)-N_{X}(track) [rad]");
498 histo16 =
new TH1F(
"NYmuon-NYtrack",
"NYmuon-NYtrack [rad]", 200, -.1, .1);
499 histo16->GetXaxis()->SetTitle(
"N_{Y}(muon)-N_{Y}(track) [rad]");
500 histo17 =
new TH1F(
"NZmuon-NZtrack",
"NZmuon-NZtrack [rad]", 200, -.1, .1);
501 histo17->GetXaxis()->SetTitle(
"N_{Z}(muon)-N_{Z}(track) [rad]");
502 histo18 =
new TH1F(
"expected error of Xinner",
"outer hit of inner tracker", 100, 0, .01);
503 histo18->GetXaxis()->SetTitle(
"expected error of Xinner [cm]");
504 histo19 =
new TH1F(
"expected error of Xmuon",
"inner hit of muon", 100, 0, .1);
505 histo19->GetXaxis()->SetTitle(
"expected error of Xmuon [cm]");
506 histo20 =
new TH1F(
"expected error of Xmuon-Xtrack",
"muon w.r.t. propagated track", 100, 0., 10.);
507 histo20->GetXaxis()->SetTitle(
"expected error of Xmuon-Xtrack [cm]");
508 histo21 =
new TH1F(
"pull of Xmuon-Xtrack",
"pull of Xmuon-Xtrack", 100, -10., 10.);
509 histo21->GetXaxis()->SetTitle(
"(Xmuon-Xtrack)/expected error");
510 histo22 =
new TH1F(
"pull of Ymuon-Ytrack",
"pull of Ymuon-Ytrack", 100, -10., 10.);
511 histo22->GetXaxis()->SetTitle(
"(Ymuon-Ytrack)/expected error");
512 histo23 =
new TH1F(
"pull of Zmuon-Ztrack",
"pull of Zmuon-Ztrack", 100, -10., 10.);
513 histo23->GetXaxis()->SetTitle(
"(Zmuon-Ztrack)/expected error");
514 histo24 =
new TH1F(
"pull of PXmuon-PXtrack",
"pull of PXmuon-PXtrack", 100, -10., 10.);
515 histo24->GetXaxis()->SetTitle(
"(P_{X}(muon)-P_{X}(track))/expected error");
516 histo25 =
new TH1F(
"pull of PYmuon-PYtrack",
"pull of PYmuon-PYtrack", 100, -10., 10.);
517 histo25->GetXaxis()->SetTitle(
"(P_{Y}(muon)-P_{Y}(track))/expected error");
518 histo26 =
new TH1F(
"pull of PZmuon-PZtrack",
"pull of PZmuon-PZtrack", 100, -10., 10.);
519 histo26->GetXaxis()->SetTitle(
"(P_{Z}(muon)-P_{Z}(track))/expected error");
520 histo27 =
new TH1F(
"N_x",
"Nx of tangent plane", 120, -1.1, 1.1);
521 histo27->GetXaxis()->SetTitle(
"normal vector projection N_{X}");
522 histo28 =
new TH1F(
"N_y",
"Ny of tangent plane", 120, -1.1, 1.1);
523 histo28->GetXaxis()->SetTitle(
"normal vector projection N_{Y}");
524 histo29 =
new TH1F(
"lenght of track",
"lenght of track", 200, 0., 400);
525 histo29->GetXaxis()->SetTitle(
"lenght of track [cm]");
526 histo30 =
new TH1F(
"lenght of muon",
"lenght of muon", 200, 0., 800);
527 histo30->GetXaxis()->SetTitle(
"lenght of muon [cm]");
529 histo31 =
new TH1F(
"local chi muon-track",
"#local chi^{2}(muon-track)", 1000, 0., 1000.);
530 histo31->GetXaxis()->SetTitle(
"#local chi^{2} of muon w.r.t. propagated track");
531 histo32 =
new TH1F(
"pull of Px/Pz local",
"pull of Px/Pz local", 100, -10., 10.);
532 histo32->GetXaxis()->SetTitle(
"local (Px/Pz(muon) - Px/Pz(track))/expected error");
533 histo33 =
new TH1F(
"pull of Py/Pz local",
"pull of Py/Pz local", 100, -10., 10.);
534 histo33->GetXaxis()->SetTitle(
"local (Py/Pz(muon) - Py/Pz(track))/expected error");
535 histo34 =
new TH1F(
"pull of X local",
"pull of X local", 100, -10., 10.);
536 histo34->GetXaxis()->SetTitle(
"local (Xmuon - Xtrack)/expected error");
537 histo35 =
new TH1F(
"pull of Y local",
"pull of Y local", 100, -10., 10.);
538 histo35->GetXaxis()->SetTitle(
"local (Ymuon - Ytrack)/expected error");
540 histo101 =
new TH2F(
"Rtr/mu vs Ztr/mu",
"hit of track/muon", 100, -800., 800., 100, 0., 600.);
541 histo101->GetXaxis()->SetTitle(
"Z of track/muon [cm]");
542 histo101->GetYaxis()->SetTitle(
"R of track/muon [cm]");
543 histo102 =
new TH2F(
"Ytr/mu vs Xtr/mu",
"hit of track/muon", 100, -600., 600., 100, -600., 600.);
544 histo102->GetXaxis()->SetTitle(
"X of track/muon [cm]");
545 histo102->GetYaxis()->SetTitle(
"Y of track/muon [cm]");
575 using namespace reco;
580 double PI = 3.1415927;
604 iEvent.
getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"TrackerOnly", tracks);
605 iEvent.
getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"StandAlone", muons);
606 iEvent.
getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"GlobalMuon", gmuons);
607 iEvent.
getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"SelectedMuons", smuons);
609 iEvent.
getByLabel(
"ALCARECOMuAlGlobalCosmics",
"TrackerOnly", tracks);
610 iEvent.
getByLabel(
"ALCARECOMuAlGlobalCosmics",
"StandAlone", muons);
611 iEvent.
getByLabel(
"ALCARECOMuAlGlobalCosmics",
"GlobalMuon", gmuons);
612 iEvent.
getByLabel(
"ALCARECOMuAlGlobalCosmics",
"SelectedMuons", smuons);
622 std::cout <<
" N tracks s/amu gmu selmu " << tracks->size() <<
" " << muons->size() <<
" " << gmuons->size() <<
" " 623 << smuons->size() << std::endl;
624 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
625 std::cout <<
" is isolatValid Matches " << itMuon->isIsolationValid() <<
" " << itMuon->isMatchesValid()
631 if (tracks->size() != 1)
633 if (muons->size() != 1)
635 if (gmuons->size() != 1)
637 if (smuons->size() != 1)
642 if (smuons->size() > 2)
644 if (tracks->size() != smuons->size())
646 if (muons->size() != smuons->size())
648 if (gmuons->size() != smuons->size())
693 <<
" angles " <<
iteratorMuonRcd->rotation().eulerAngles() << std::endl;
717 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
719 std::cout <<
" mu gM is GM Mu SaM tM " << itMuon->isGlobalMuon() <<
" " << itMuon->isMuon() <<
" " 720 << itMuon->isStandAloneMuon() <<
" " << itMuon->isTrackerMuon() <<
" " << std::endl;
734 GlobalPoint pointTrackOut = outerTrackTSOS.globalPosition();
735 float lenghtTrack = (pointTrackOut - pointTrackIn).
mag();
736 GlobalPoint pointMuonIn = innerMuTSOS.globalPosition();
738 float lenghtMuon = (pointMuonOut - pointMuonIn).
mag();
739 GlobalVector momentumTrackOut = outerTrackTSOS.globalMomentum();
741 float distanceInIn = (pointTrackIn - pointMuonIn).
mag();
742 float distanceInOut = (pointTrackIn - pointMuonOut).
mag();
743 float distanceOutIn = (pointTrackOut - pointMuonIn).
mag();
744 float distanceOutOut = (pointTrackOut - pointMuonOut).
mag();
747 std::cout <<
" pointTrackIn " << pointTrackIn << std::endl;
748 std::cout <<
" Out " << pointTrackOut <<
" lenght " << lenghtTrack << std::endl;
749 std::cout <<
" point MuonIn " << pointMuonIn << std::endl;
750 std::cout <<
" Out " << pointMuonOut <<
" lenght " << lenghtMuon << std::endl;
751 std::cout <<
" momeTrackIn Out " << momentumTrackIn <<
" " << momentumTrackOut << std::endl;
752 std::cout <<
" doi io ii oo " << distanceOutIn <<
" " << distanceInOut <<
" " << distanceInIn <<
" " 753 << distanceOutOut << std::endl;
756 if (lenghtTrack < 90.)
758 if (lenghtMuon < 300.)
760 if (momentumTrackIn.
mag() < 15. || momentumTrackOut.
mag() < 15.)
762 if (trackTT.charge() != muTT.charge())
766 std::cout <<
" passed lenght momentum cuts" << std::endl;
775 const Surface& refSurface = innerMuTSOS.surface();
777 Nl = tpMuLocal->normalVector();
781 const Plane* refPlane =
dynamic_cast<Plane*
>(surf);
785 std::cout <<
" Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 786 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
787 std::cout <<
" global " << Ng.
x() <<
" " << Ng.
y() <<
" " << Ng.
z() << std::endl;
788 std::cout <<
" lp " << Nlp.
x() <<
" " << Nlp.
y() <<
" " << Nlp.
z() << std::endl;
795 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
798 if (!extrapolationT.
isValid()) {
800 std::cout <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 813 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
814 GPm = innerMuTSOS.globalMomentum();
816 (outerTrackTSOS.globalPosition()).
y(),
817 (outerTrackTSOS.globalPosition()).
z());
827 if ((distanceOutIn <= distanceInOut) & (distanceOutIn <= distanceInIn) &
828 (distanceOutIn <= distanceOutOut)) {
830 std::cout <<
" ----- Out - In -----" << std::endl;
832 const Surface& refSurface = innerMuTSOS.surface();
834 Nl = tpMuGlobal->normalVector();
837 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
840 if (!extrapolationT.
isValid()) {
842 std::cout <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 848 std::cout <<
" extrapolationT.isValid " << extrapolationT.
isValid() << std::endl;
858 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
859 GPm = innerMuTSOS.globalMomentum();
861 (outerTrackTSOS.globalPosition()).
y(),
862 (outerTrackTSOS.globalPosition()).
z());
871 std::cout <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 872 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface)) << std::endl;
873 std::cout <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 874 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
878 else if ((distanceInOut <= distanceInIn) & (distanceInOut <= distanceOutIn) &
879 (distanceInOut <= distanceOutOut)) {
881 std::cout <<
" ----- In - Out -----" << std::endl;
885 Nl = tpMuGlobal->normalVector();
888 extrapolationT = oppositeSmPr.
propagate(innerTrackTSOS, refSurface);
890 if (!extrapolationT.
isValid()) {
892 std::cout <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 893 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid() << std::endl;
897 std::cout <<
" extrapolationT.isValid " << extrapolationT.
isValid() << std::endl;
920 std::cout <<
" propDirCh " << Chooser.operator()(*innerTrackTSOS.
freeState(), refSurface)
921 <<
" Ch == oppisite " 923 std::cout <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 924 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
928 else if ((distanceOutOut <= distanceInOut) & (distanceOutOut <= distanceInIn) &
929 (distanceOutOut <= distanceOutIn)) {
931 std::cout <<
" ----- Out - Out -----" << std::endl;
938 Nl = tpMuGlobal->normalVector();
941 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
943 if (!extrapolationT.
isValid()) {
945 std::cout <<
" !!!!!!!!! Catastrophe Out-Out extrapolationT.isValid " 946 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid() << std::endl;
950 std::cout <<
" extrapolationT.isValid " << extrapolationT.
isValid() << std::endl;
963 (outerTrackTSOS.globalPosition()).
y(),
964 (outerTrackTSOS.globalPosition()).
z());
972 std::cout <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 973 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface)) << std::endl;
974 std::cout <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 975 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
976 std::cout <<
" Nornal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 977 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
982 std::cout <<
" ------- !!!!!!!!!!!!!!! No proper Out - In \a\a\a\a\a\a\a" << std::endl;
988 if (tsosMuonIf == 0) {
990 std::cout <<
"No tsosMuon !!!!!!" << std::endl;
996 tsosMuon = muTT.innermostMeasurementState();
998 tsosMuon = muTT.outermostMeasurementState();
1007 float RelMomResidual = (Pm.
mag() - Pt.mag()) / (Pt.mag() + 1.e-6);
1017 float Rmuon = Rm.
perp();
1018 float Zmuon = Rm.
z();
1019 float alfa_x = atan2(Nl.
x(), Nl.
y()) * 57.29578;
1022 std::cout <<
" Nx Ny Nz alfa_x " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " << alfa_x << std::endl;
1028 for (
int i = 0;
i <= 5;
i++)
1029 chi_d += Vm(
i) * Vm(
i) / Cm(
i,
i);
1034 bool ierrLoc = !
m.Invert();
1035 if (ierrLoc &&
debug_ && info) {
1036 std::cout <<
" ==== Error inverting Local covariance matrix ==== " << std::endl;
1039 double chi_Loc = ROOT::Math::Similarity(Vml,
m);
1041 std::cout <<
" chi_Loc px/pz/err " << chi_Loc <<
" " << Vml(1) /
sqrt(Cml(1, 1)) << std::endl;
1090 if (Rmuon < 120. || Rmuon > 450.)
1092 if (Zmuon < -720. || Zmuon > 720.)
1097 std::cout <<
" .............. passed all cuts" << std::endl;
1105 CLHEP::HepSymMatrix covLoc(4, 0);
1106 for (
int i = 1;
i <= 4;
i++)
1107 for (
int j = 1; j <=
i; j++) {
1113 CLHEP::HepMatrix rotLoc(3, 3, 0);
1126 CLHEP::HepVector posLoc(3);
1134 std::cout <<
" Norm " << Nl << std::endl;
1135 std::cout <<
" posLoc " << posLoc.T() << std::endl;
1136 std::cout <<
" rotLoc " << rotLoc << std::endl;
1140 histo->Fill(itMuon->track()->pt());
1144 histo3->Fill((PI / 2. - itMuon->track()->outerTheta()));
1145 histo4->Fill(itMuon->track()->phi());
1148 histo7->Fill(RelMomResidual);
1158 if (fabs(Nl.
x()) < 0.98)
1160 if (fabs(Nl.
y()) < 0.98)
1162 if (fabs(Nl.
z()) < 0.98)
1168 if ((fabs(Nl.
x()) < 0.98) && (fabs(Nl.
y()) < 0.98) && (fabs(Nl.
z()) < 0.98)) {
1173 if (fabs(Nl.
x()) < 0.98)
1175 if (fabs(Nl.
y()) < 0.98)
1177 if (fabs(Nl.
z()) < 0.98)
1194 std::cout <<
" diag 0[ " << C0(0, 0) <<
" " << C0(1, 1) <<
" " << C0(2, 2) <<
" " << C0(3, 3) <<
" " << C0(4, 4)
1195 <<
" " << C0(5, 5) <<
" ]" << std::endl;
1196 std::cout <<
" diag e[ " << Ce(0, 0) <<
" " << Ce(1, 1) <<
" " << Ce(2, 2) <<
" " << Ce(3, 3) <<
" " << Ce(4, 4)
1197 <<
" " << Ce(5, 5) <<
" ]" << std::endl;
1198 std::cout <<
" diag 1[ " << C1(0, 0) <<
" " << C1(1, 1) <<
" " << C1(2, 2) <<
" " << C1(3, 3) <<
" " << C1(4, 4)
1199 <<
" " << C1(5, 5) <<
" ]" << std::endl;
1200 std::cout <<
" Rm " << Rm.
x() <<
" " << Rm.
y() <<
" " << Rm.
z() <<
" Pm " << Pm.
x() <<
" " << Pm.
y() <<
" " 1201 << Pm.
z() << std::endl;
1202 std::cout <<
" Rt " << Rt.x() <<
" " << Rt.y() <<
" " << Rt.z() <<
" Pt " << Pt.x() <<
" " << Pt.y() <<
" " 1203 << Pt.z() << std::endl;
1204 std::cout <<
" Nl*(Rm-Rt) " << Nl.
dot(Rm - Rt) << std::endl;
1205 std::cout <<
" resR " << resR.
x() <<
" " << resR.
y() <<
" " << resR.
z() <<
" resP " << resP.
x() <<
" " << resP.
y()
1206 <<
" " << resP.
z() << std::endl;
1207 std::cout <<
" Rm-t " << (Rm - Rt).
x() <<
" " << (Rm - Rt).
y() <<
" " << (Rm - Rt).
z() <<
" Pm-t " 1208 << (Pm -
Pt).
x() <<
" " << (Pm -
Pt).
y() <<
" " << (Pm -
Pt).
z() << std::endl;
1211 <<
" " <<
sqrt(Cm(4, 4)) <<
" " <<
sqrt(Cm(5, 5)) << std::endl;
1212 std::cout <<
" Pmuon Ptrack dP/Ptrack " << itMuon->outerTrack()->p() <<
" " << itMuon->track()->outerP() <<
" " 1213 << (itMuon->outerTrack()->p() - itMuon->track()->outerP()) / itMuon->track()->outerP() << std::endl;
1214 std::cout <<
" cov matrix " << std::endl;
1216 std::cout <<
" diag [ " << Cm(0, 0) <<
" " << Cm(1, 1) <<
" " << Cm(2, 2) <<
" " << Cm(3, 3) <<
" " << Cm(4, 4)
1217 <<
" " << Cm(5, 5) <<
" ]" << std::endl;
1221 for (
int i = 0;
i <= 5;
i++)
1223 for (
int i = 0;
i <= 5;
i++)
1224 for (
int j = 0; j <= 5; j++)
1225 Ro(
i, j) = Cm(
i, j) / Diag[
i] / Diag[j];
1226 std::cout <<
" correlation matrix " << std::endl;
1230 for (
int i = 0;
i <= 5;
i++)
1231 for (
int j = 0; j <= 5; j++)
1232 CmI(
i, j) = Cm(
i, j);
1234 bool ierr = !CmI.Invert();
1237 std::cout <<
" Error inverse covariance matrix !!!!!!!!!!!" << std::endl;
1240 std::cout <<
" inverse cov matrix " << std::endl;
1243 double chi = ROOT::Math::Similarity(Vm, CmI);
1244 std::cout <<
" chi chi_d " << chi <<
" " << chi_d << std::endl;
1253 using namespace edm;
1254 using namespace reco;
1259 double PI = 3.1415927;
1283 iEvent.
getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"TrackerOnly", tracks);
1284 iEvent.
getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"StandAlone", muons);
1285 iEvent.
getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"GlobalMuon", gmuons);
1286 iEvent.
getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"SelectedMuons", smuons);
1288 iEvent.
getByLabel(
"ALCARECOMuAlGlobalCosmics",
"TrackerOnly", tracks);
1289 iEvent.
getByLabel(
"ALCARECOMuAlGlobalCosmics",
"StandAlone", muons);
1290 iEvent.
getByLabel(
"ALCARECOMuAlGlobalCosmics",
"GlobalMuon", gmuons);
1291 iEvent.
getByLabel(
"ALCARECOMuAlGlobalCosmics",
"SelectedMuons", smuons);
1301 std::cout <<
" N tracks s/amu gmu selmu " << tracks->size() <<
" " << muons->size() <<
" " << gmuons->size() <<
" " 1302 << smuons->size() << std::endl;
1303 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
1304 std::cout <<
" is isolatValid Matches " << itMuon->isIsolationValid() <<
" " << itMuon->isMatchesValid()
1310 if (tracks->size() != 1)
1312 if (muons->size() != 1)
1314 if (gmuons->size() != 1)
1316 if (smuons->size() != 1)
1321 if (smuons->size() > 2)
1323 if (tracks->size() != smuons->size())
1325 if (muons->size() != smuons->size())
1327 if (gmuons->size() != smuons->size())
1377 <<
" angles " <<
iteratorMuonRcd->rotation().eulerAngles() << std::endl;
1401 std::cout <<
" ............... DEFINE FITTER ..................." << std::endl;
1405 theFitter =
new KFTrajectoryFitter(alongSmPr, *theUpdator, *theEstimator);
1407 theFitterOp =
new KFTrajectoryFitter(oppositeSmPr, *theUpdator, *theEstimator);
1416 std::cout <<
"get also the MuonTransientTrackingRecHitBuilder" 1418 std::cout <<
"get also the TransientTrackingRecHitBuilder" 1426 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
1428 std::cout <<
" mu gM is GM Mu SaM tM " << itMuon->isGlobalMuon() <<
" " << itMuon->isMuon() <<
" " 1429 << itMuon->isStandAloneMuon() <<
" " << itMuon->isTrackerMuon() <<
" " << std::endl;
1443 GlobalPoint pointTrackOut = outerTrackTSOS.globalPosition();
1444 float lenghtTrack = (pointTrackOut - pointTrackIn).
mag();
1445 GlobalPoint pointMuonIn = innerMuTSOS.globalPosition();
1447 float lenghtMuon = (pointMuonOut - pointMuonIn).
mag();
1448 GlobalVector momentumTrackOut = outerTrackTSOS.globalMomentum();
1450 float distanceInIn = (pointTrackIn - pointMuonIn).
mag();
1451 float distanceInOut = (pointTrackIn - pointMuonOut).
mag();
1452 float distanceOutIn = (pointTrackOut - pointMuonIn).
mag();
1453 float distanceOutOut = (pointTrackOut - pointMuonOut).
mag();
1456 std::cout <<
" pointTrackIn " << pointTrackIn << std::endl;
1457 std::cout <<
" Out " << pointTrackOut <<
" lenght " << lenghtTrack << std::endl;
1458 std::cout <<
" point MuonIn " << pointMuonIn << std::endl;
1459 std::cout <<
" Out " << pointMuonOut <<
" lenght " << lenghtMuon << std::endl;
1460 std::cout <<
" momeTrackIn Out " << momentumTrackIn <<
" " << momentumTrackOut << std::endl;
1461 std::cout <<
" doi io ii oo " << distanceOutIn <<
" " << distanceInOut <<
" " << distanceInIn <<
" " 1462 << distanceOutOut << std::endl;
1465 if (lenghtTrack < 90.)
1467 if (lenghtMuon < 300.)
1469 if (innerMuTSOS.globalMomentum().mag() < 5. || outerMuTSOS.
globalMomentum().
mag() < 5.)
1471 if (momentumTrackIn.
mag() < 15. || momentumTrackOut.
mag() < 15.)
1473 if (trackTT.charge() != muTT.charge())
1477 std::cout <<
" passed lenght momentum cuts" << std::endl;
1491 std::cout <<
" ------ Isolated (out-in) ----- " << std::endl;
1492 const Surface& refSurface = innerMuTSOS.surface();
1494 Nl = tpMuLocal->normalVector();
1498 const Plane* refPlane =
dynamic_cast<Plane*
>(surf);
1502 std::cout <<
" Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1503 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
1504 std::cout <<
" global " << Ng.
x() <<
" " << Ng.
y() <<
" " << Ng.
z() << std::endl;
1505 std::cout <<
" lp " << Nlp.
x() <<
" " << Nlp.
y() <<
" " << Nlp.
z() << std::endl;
1515 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
1518 if (trackFittedTSOS.
isValid())
1519 extrapolationT = alongSmPr.
propagate(trackFittedTSOS, refSurface);
1522 if (!extrapolationT.
isValid()) {
1524 std::cout <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 1537 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
1538 GPm = innerMuTSOS.globalMomentum();
1541 (outerTrackTSOS.globalPosition()).
y(),
1542 (outerTrackTSOS.globalPosition()).
z());
1555 if ((distanceOutIn <= distanceInOut) & (distanceOutIn <= distanceInIn) &
1556 (distanceOutIn <= distanceOutOut)) {
1558 std::cout <<
" ----- Out - In -----" << std::endl;
1560 const Surface& refSurface = innerMuTSOS.surface();
1562 Nl = tpMuGlobal->normalVector();
1567 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
1570 if (trackFittedTSOS.
isValid())
1571 extrapolationT = alongSmPr.
propagate(trackFittedTSOS, refSurface);
1574 if (!extrapolationT.
isValid()) {
1576 std::cout <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 1582 std::cout <<
" extrapolationT.isValid " << extrapolationT.
isValid() << std::endl;
1592 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
1593 GPm = innerMuTSOS.globalMomentum();
1595 (outerTrackTSOS.globalPosition()).
y(),
1596 (outerTrackTSOS.globalPosition()).
z());
1608 std::cout <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 1609 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface)) << std::endl;
1610 std::cout <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1611 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
1615 else if ((distanceInOut <= distanceInIn) & (distanceInOut <= distanceOutIn) &
1616 (distanceInOut <= distanceOutOut)) {
1618 std::cout <<
" ----- In - Out -----" << std::endl;
1622 Nl = tpMuGlobal->normalVector();
1627 extrapolationT = oppositeSmPr.
propagate(innerTrackTSOS, refSurface);
1630 if (trackFittedTSOS.
isValid())
1631 extrapolationT = oppositeSmPr.
propagate(trackFittedTSOS, refSurface);
1634 if (!extrapolationT.
isValid()) {
1636 std::cout <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 1637 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid() << std::endl;
1641 std::cout <<
" extrapolationT.isValid " << extrapolationT.
isValid() << std::endl;
1667 std::cout <<
" propDirCh " << Chooser.operator()(*innerTrackTSOS.
freeState(), refSurface)
1668 <<
" Ch == oppisite " 1670 std::cout <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1671 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
1675 else if ((distanceOutOut <= distanceInOut) & (distanceOutOut <= distanceInIn) &
1676 (distanceOutOut <= distanceOutIn)) {
1678 std::cout <<
" ----- Out - Out -----" << std::endl;
1685 Nl = tpMuGlobal->normalVector();
1688 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
1690 if (!extrapolationT.
isValid()) {
1692 std::cout <<
" !!!!!!!!! Catastrophe Out-Out extrapolationT.isValid " 1693 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid() << std::endl;
1697 std::cout <<
" extrapolationT.isValid " << extrapolationT.
isValid() << std::endl;
1710 (outerTrackTSOS.globalPosition()).
y(),
1711 (outerTrackTSOS.globalPosition()).
z());
1719 std::cout <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 1720 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface)) << std::endl;
1721 std::cout <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1722 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
1723 std::cout <<
" Nornal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1724 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
1729 std::cout <<
" ------- !!!!!!!!!!!!!!! No proper Out - In \a\a\a\a\a\a\a" << std::endl;
1735 if (tsosMuonIf == 0) {
1737 std::cout <<
"No tsosMuon !!!!!!" << std::endl;
1742 if (tsosMuonIf == 1)
1743 tsosMuon = muTT.innermostMeasurementState();
1745 tsosMuon = muTT.outermostMeasurementState();
1752 if (!trackFittedTSOS.
isValid()) {
1754 std::cout <<
" ================= trackFittedTSOS notValid !!!!!!!! " << std::endl;
1762 if (!muonFittedTSOS.
isValid()) {
1764 std::cout <<
" ================= muonFittedTSOS notValid !!!!!!!! " << std::endl;
1781 float RelMomResidual = (Pm.
mag() - Pt.mag()) / (Pt.mag() + 1.e-6);
1791 float Rmuon = Rm.
perp();
1792 float Zmuon = Rm.
z();
1793 float alfa_x = atan2(Nl.
x(), Nl.
y()) * 57.29578;
1796 std::cout <<
" Nx Ny Nz alfa_x " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " << alfa_x << std::endl;
1802 for (
int i = 0;
i <= 5;
i++)
1803 chi_d += Vm(
i) * Vm(
i) / Cm(
i,
i);
1808 bool ierrLoc = !
m.Invert();
1809 if (ierrLoc &&
debug_ && info) {
1810 std::cout <<
" ==== Error inverting Local covariance matrix ==== " << std::endl;
1813 double chi_Loc = ROOT::Math::Similarity(Vml,
m);
1815 std::cout <<
" chi_Loc px/pz/err " << chi_Loc <<
" " << Vml(1) /
sqrt(Cml(1, 1)) << std::endl;
1835 if (fabs(resR.
x()) > 20.)
1837 if (fabs(resR.
y()) > 20.)
1839 if (fabs(resR.
z()) > 20.)
1841 if (fabs(resR.
mag()) > 30.)
1843 if (fabs(resP.
x()) > 0.06)
1845 if (fabs(resP.
y()) > 0.06)
1847 if (fabs(resP.
z()) > 0.06)
1870 if (Rmuon < 120. || Rmuon > 450.)
1872 if (Zmuon < -720. || Zmuon > 720.)
1877 std::cout <<
" .............. passed all cuts" << std::endl;
1885 CLHEP::HepSymMatrix covLoc(4, 0);
1886 for (
int i = 1;
i <= 4;
i++)
1887 for (
int j = 1; j <=
i; j++) {
1893 CLHEP::HepMatrix rotLoc(3, 3, 0);
1906 CLHEP::HepVector posLoc(3);
1914 std::cout <<
" Norm " << Nl << std::endl;
1915 std::cout <<
" posLoc " << posLoc.T() << std::endl;
1916 std::cout <<
" rotLoc " << rotLoc << std::endl;
1920 histo->Fill(itMuon->track()->pt());
1924 histo3->Fill((PI / 2. - itMuon->track()->outerTheta()));
1925 histo4->Fill(itMuon->track()->phi());
1928 histo7->Fill(RelMomResidual);
1938 if (fabs(Nl.
x()) < 0.98)
1940 if (fabs(Nl.
y()) < 0.98)
1942 if (fabs(Nl.
z()) < 0.98)
1948 if ((fabs(Nl.
x()) < 0.98) && (fabs(Nl.
y()) < 0.98) && (fabs(Nl.
z()) < 0.98)) {
1953 if (fabs(Nl.
x()) < 0.98)
1955 if (fabs(Nl.
y()) < 0.98)
1957 if (fabs(Nl.
z()) < 0.98)
1974 std::cout <<
" diag 0[ " << C0(0, 0) <<
" " << C0(1, 1) <<
" " << C0(2, 2) <<
" " << C0(3, 3) <<
" " << C0(4, 4)
1975 <<
" " << C0(5, 5) <<
" ]" << std::endl;
1976 std::cout <<
" diag e[ " << Ce(0, 0) <<
" " << Ce(1, 1) <<
" " << Ce(2, 2) <<
" " << Ce(3, 3) <<
" " << Ce(4, 4)
1977 <<
" " << Ce(5, 5) <<
" ]" << std::endl;
1978 std::cout <<
" diag 1[ " << C1(0, 0) <<
" " << C1(1, 1) <<
" " << C1(2, 2) <<
" " << C1(3, 3) <<
" " << C1(4, 4)
1979 <<
" " << C1(5, 5) <<
" ]" << std::endl;
1980 std::cout <<
" Rm " << Rm.
x() <<
" " << Rm.
y() <<
" " << Rm.
z() <<
" Pm " << Pm.
x() <<
" " << Pm.
y() <<
" " 1981 << Pm.
z() << std::endl;
1982 std::cout <<
" Rt " << Rt.x() <<
" " << Rt.y() <<
" " << Rt.z() <<
" Pt " << Pt.x() <<
" " << Pt.y() <<
" " 1983 << Pt.z() << std::endl;
1984 std::cout <<
" Nl*(Rm-Rt) " << Nl.
dot(Rm - Rt) << std::endl;
1985 std::cout <<
" resR " << resR.
x() <<
" " << resR.
y() <<
" " << resR.
z() <<
" resP " << resP.
x() <<
" " << resP.
y()
1986 <<
" " << resP.
z() << std::endl;
1987 std::cout <<
" Rm-t " << (Rm - Rt).
x() <<
" " << (Rm - Rt).
y() <<
" " << (Rm - Rt).
z() <<
" Pm-t " 1988 << (Pm -
Pt).
x() <<
" " << (Pm -
Pt).
y() <<
" " << (Pm -
Pt).
z() << std::endl;
1991 <<
" " <<
sqrt(Cm(4, 4)) <<
" " <<
sqrt(Cm(5, 5)) << std::endl;
1992 std::cout <<
" Pmuon Ptrack dP/Ptrack " << itMuon->outerTrack()->p() <<
" " << itMuon->track()->outerP() <<
" " 1993 << (itMuon->outerTrack()->p() - itMuon->track()->outerP()) / itMuon->track()->outerP() << std::endl;
1994 std::cout <<
" cov matrix " << std::endl;
1996 std::cout <<
" diag [ " << Cm(0, 0) <<
" " << Cm(1, 1) <<
" " << Cm(2, 2) <<
" " << Cm(3, 3) <<
" " << Cm(4, 4)
1997 <<
" " << Cm(5, 5) <<
" ]" << std::endl;
2001 for (
int i = 0;
i <= 5;
i++)
2003 for (
int i = 0;
i <= 5;
i++)
2004 for (
int j = 0; j <= 5; j++)
2005 Ro(
i, j) = Cm(
i, j) / Diag[
i] / Diag[j];
2006 std::cout <<
" correlation matrix " << std::endl;
2010 for (
int i = 0;
i <= 5;
i++)
2011 for (
int j = 0; j <= 5; j++)
2012 CmI(
i, j) = Cm(
i, j);
2014 bool ierr = !CmI.Invert();
2017 std::cout <<
" Error inverse covariance matrix !!!!!!!!!!!" << std::endl;
2020 std::cout <<
" inverse cov matrix " << std::endl;
2023 double chi = ROOT::Math::Similarity(Vm, CmI);
2024 std::cout <<
" chi chi_d " << chi <<
" " << chi_d << std::endl;
2053 for (
int i = 0;
i <= 2;
i++) {
2054 if (Cm(
i,
i) > 1.
e-20)
2055 Wi(
i) = 1. / Cm(
i,
i);
2058 dR(
i) = R_m(
i) - R_t(
i);
2061 float PtN = P_t(0) * Norm(0) + P_t(1) * Norm(1) + P_t(2) * Norm(2);
2063 Jac(0, 0) = 1. - P_t(0) * Norm(0) / PtN;
2064 Jac(0, 1) = -P_t(0) * Norm(1) / PtN;
2065 Jac(0, 2) = -P_t(0) * Norm(2) / PtN;
2067 Jac(1, 0) = -P_t(1) * Norm(0) / PtN;
2068 Jac(1, 1) = 1. - P_t(1) * Norm(1) / PtN;
2069 Jac(1, 2) = -P_t(1) * Norm(2) / PtN;
2071 Jac(2, 0) = -P_t(2) * Norm(0) / PtN;
2072 Jac(2, 1) = -P_t(2) * Norm(1) / PtN;
2073 Jac(2, 2) = 1. - P_t(2) * Norm(2) / PtN;
2077 for (
int i = 0;
i <= 2;
i++)
2078 for (
int j = 0; j <= 2; j++) {
2083 for (
int k = 0;
k <= 2;
k++) {
2084 Itr(
i, j) += Jac(
k,
i) * Wi(
k) * Jac(
k, j);
2088 for (
int i = 0;
i <= 2;
i++)
2089 for (
int j = 0; j <= 2; j++) {
2096 for (
int i = 0;
i <= 2;
i++)
2097 for (
int k = 0;
k <= 2;
k++)
2098 Gtr(
i) +=
dR(
k) * Wi(
k) * Jac(
k,
i);
2099 for (
int i = 0;
i <= 2;
i++)
2104 std::cout <<
" N " << Norm << std::endl;
2105 std::cout <<
" P_t " << P_t << std::endl;
2106 std::cout <<
" (Pt*N) " << PtN << std::endl;
2108 std::cout <<
" +/- " << 1. /
sqrt(Wi(0)) <<
" " << 1. /
sqrt(Wi(1)) <<
" " << 1. /
sqrt(Wi(2)) <<
" " << std::endl;
2109 std::cout <<
" Jacobian dr/ddx " << std::endl;
2111 std::cout <<
" G-- " << Gtr << std::endl;
2140 CLHEP::HepSymMatrix
w(Nd, 0);
2141 for (
int i = 1;
i <= Nd;
i++)
2142 for (
int j = 1; j <= Nd; j++) {
2144 w(
i, j) = GCov(
i - 1, j - 1);
2147 if ((
i == j) && (
i <= 3) && (GCov(
i - 1, j - 1) < 1.
e-20))
2156 CLHEP::HepVector V(Nd), Rt(3),
Pt(3), Rm(3), Pm(3), Norm(3);
2169 Norm(1) = GNorm.
x();
2170 Norm(2) = GNorm.
y();
2171 Norm(3) = GNorm.
z();
2173 V = dsum(Rm - Rt, Pm -
Pt);
2178 CLHEP::HepMatrix Jac(Nd, Nd, 0);
2179 for (
int i = 1;
i <= 3;
i++)
2180 for (
int j = 1; j <= 3; j++) {
2181 Jac(
i, j) = Pm(
i) * Norm(j) / PmN;
2197 CLHEP::HepVector dsda(3);
2198 dsda(1) = (Norm(2) * Rm(3) - Norm(3) * Rm(2)) / PmN;
2199 dsda(2) = (Norm(3) * Rm(1) - Norm(1) * Rm(3)) / PmN;
2200 dsda(3) = (Norm(1) * Rm(2) - Norm(2) * Rm(1)) / PmN;
2203 Jac(1, 4) = Pm(1) * dsda(1);
2204 Jac(2, 4) = -Rm(3) + Pm(2) * dsda(1);
2205 Jac(3, 4) = Rm(2) + Pm(3) * dsda(1);
2207 Jac(1, 5) = Rm(3) + Pm(1) * dsda(2);
2208 Jac(2, 5) = Pm(2) * dsda(2);
2209 Jac(3, 5) = -Rm(1) + Pm(3) * dsda(2);
2211 Jac(1, 6) = -Rm(2) + Pm(1) * dsda(3);
2212 Jac(2, 6) = Rm(1) + Pm(2) * dsda(3);
2213 Jac(3, 6) = Pm(3) * dsda(3);
2215 CLHEP::HepSymMatrix W(Nd, 0);
2217 W = w.inverse(ierr);
2220 std::cout <<
" gradientGlobal: inversion of matrix w fail " << std::endl;
2224 CLHEP::HepMatrix W_Jac(Nd, Nd, 0);
2225 W_Jac = Jac.T() * W;
2227 CLHEP::HepVector grad3(Nd);
2230 CLHEP::HepMatrix hess3(Nd, Nd);
2231 hess3 = Jac.T() * W * Jac;
2237 CLHEP::HepVector d3I = CLHEP::solve(
Hess, -
Grad);
2239 CLHEP::HepMatrix Errd3I =
Hess.inverse(iEr3I);
2242 std::cout <<
" gradientGlobal error inverse Hess matrix !!!!!!!!!!!" << std::endl;
2246 std::cout <<
" dG " << d3I(1) <<
" " << d3I(2) <<
" " << d3I(3) <<
" " << d3I(4) <<
" " << d3I(5) <<
" " << d3I(6)
2249 std::cout <<
" +- " <<
sqrt(Errd3I(1, 1)) <<
" " <<
sqrt(Errd3I(2, 2)) <<
" " <<
sqrt(Errd3I(3, 3)) <<
" " 2250 <<
sqrt(Errd3I(4, 4)) <<
" " <<
sqrt(Errd3I(5, 5)) <<
" " <<
sqrt(Errd3I(6, 6)) << std::endl;
2253 #ifdef CHECK_OF_DERIVATIVES 2256 CLHEP::HepVector
d(3, 0),
a(3, 0);
2257 CLHEP::HepMatrix
T(3, 3, 1);
2259 CLHEP::HepMatrix Ti = T.T();
2263 double B =
CLHEP_dot((Rt - Ti * Rm + Ti *
d), Norm);
2266 CLHEP::HepVector r0(3, 0), p0(3, 0);
2267 r0 = Ti * Rm - Ti * d + s0 * (Ti * Pm) - Rt;
2270 double delta = 0.0001;
2281 B =
CLHEP_dot((Rt - Ti * Rm + Ti * d), Norm);
2284 CLHEP::HepVector
r(3, 0),
p(3, 0);
2285 r = Ti * Rm - Ti * d + s * (Ti * Pm) - Rt;
2288 std::cout <<
" s0 s num dsda(" << ii <<
") " << s0 <<
" " << s <<
" " << (s - s0) / delta <<
" " << dsda(ii) << endl;
2290 std::cout <<
" -- An d(r,p)/d(" << ii <<
") " << Jac(1, ii) <<
" " << Jac(2, ii) <<
" " << Jac(3, ii) <<
" " 2291 << Jac(4, ii) <<
" " << Jac(5, ii) <<
" " << Jac(6, ii) << std::endl;
2292 std::cout <<
" Nu d(r,p)/d(" << ii <<
") " << (
r(1) - r0(1)) / delta <<
" " << (
r(2) - r0(2)) / delta <<
" " 2293 << (
r(3) - r0(3)) / delta <<
" " << (
p(1) - p0(1)) / delta <<
" " << (
p(2) - p0(2)) / delta <<
" " 2294 << (
p(3) - p0(3)) / delta << std::endl;
2296 std::cout <<
" -- An d(r,p)/a(" << ii <<
") " << Jac(1, ii + 3) <<
" " << Jac(2, ii + 3) <<
" " << Jac(3, ii + 3)
2297 <<
" " << Jac(4, ii + 3) <<
" " << Jac(5, ii + 3) <<
" " << Jac(6, ii + 3) << std::endl;
2298 std::cout <<
" Nu d(r,p)/a(" << ii <<
") " << (
r(1) - r0(1)) / delta <<
" " << (
r(2) - r0(2)) / delta <<
" " 2299 << (
r(3) - r0(3)) / delta <<
" " << (
p(1) - p0(1)) / delta <<
" " << (
p(2) - p0(2)) / delta <<
" " 2300 << (
p(3) - p0(3)) / delta << std::endl;
2313 CLHEP::HepSymMatrix& covLoc,
2314 CLHEP::HepMatrix& rotLoc,
2315 CLHEP::HepVector&
R0,
2326 std::cout <<
" gradientLocal " << std::endl;
2345 CLHEP::HepVector Rt(3),
Pt(3), Rm(3), Pm(3), Norm(3);
2358 Norm(1) = GNorm.
x();
2359 Norm(2) = GNorm.
y();
2360 Norm(3) = GNorm.
z();
2362 CLHEP::HepVector V(4), Rml(3), Pml(3), Rtl(3), Ptl(3);
2370 Rml = rotLoc * (Rm -
R0);
2371 Rtl = rotLoc * (Rt -
R0);
2375 V(1) = LPRm(0) - Ptl(1) / Ptl(3);
2376 V(2) = LPRm(1) - Ptl(2) / Ptl(3);
2377 V(3) = LPRm(2) - Rtl(1);
2378 V(4) = LPRm(3) - Rtl(2);
2393 CLHEP::HepSymMatrix W = covLoc;
2399 std::cout <<
" gradientLocal: inversion of matrix W fail " << std::endl;
2411 CLHEP::HepMatrix JacToLoc(4, 6, 0);
2412 for (
int i = 1;
i <= 2;
i++)
2413 for (
int j = 1; j <= 3; j++) {
2414 JacToLoc(
i, j + 3) = (rotLoc(
i, j) - rotLoc(3, j) * Pml(
i) / Pml(3)) / Pml(3);
2415 JacToLoc(
i + 2, j) = rotLoc(
i, j);
2422 CLHEP::HepMatrix Jac(6, 6, 0);
2423 for (
int i = 1;
i <= 3;
i++)
2424 for (
int j = 1; j <= 3; j++) {
2425 Jac(
i, j) = Pm(
i) * Norm(j) / PmN;
2441 CLHEP::HepVector dsda(3);
2442 dsda(1) = (Norm(2) * Rm(3) - Norm(3) * Rm(2)) / PmN;
2443 dsda(2) = (Norm(3) * Rm(1) - Norm(1) * Rm(3)) / PmN;
2444 dsda(3) = (Norm(1) * Rm(2) - Norm(2) * Rm(1)) / PmN;
2447 Jac(1, 4) = Pm(1) * dsda(1);
2448 Jac(2, 4) = -Rm(3) + Pm(2) * dsda(1);
2449 Jac(3, 4) = Rm(2) + Pm(3) * dsda(1);
2451 Jac(1, 5) = Rm(3) + Pm(1) * dsda(2);
2452 Jac(2, 5) = Pm(2) * dsda(2);
2453 Jac(3, 5) = -Rm(1) + Pm(3) * dsda(2);
2455 Jac(1, 6) = -Rm(2) + Pm(1) * dsda(3);
2456 Jac(2, 6) = Rm(1) + Pm(2) * dsda(3);
2457 Jac(3, 6) = Pm(3) * dsda(3);
2460 CLHEP::HepMatrix JacCorLoc(4, 6, 0);
2461 JacCorLoc = JacToLoc * Jac;
2464 CLHEP::HepMatrix W_Jac(6, 4, 0);
2465 W_Jac = JacCorLoc.T() * W;
2467 CLHEP::HepVector gradL(6);
2470 CLHEP::HepMatrix hessL(6, 6);
2471 hessL = JacCorLoc.T() * W * JacCorLoc;
2476 CLHEP::HepVector dLI = CLHEP::solve(
HessL, -
GradL);
2478 CLHEP::HepMatrix ErrdLI =
HessL.inverse(iErI);
2481 std::cout <<
" gradLocal Error inverse Hess matrix !!!!!!!!!!!" << std::endl;
2485 std::cout <<
" dL " << dLI(1) <<
" " << dLI(2) <<
" " << dLI(3) <<
" " << dLI(4) <<
" " << dLI(5) <<
" " << dLI(6)
2488 std::cout <<
" +- " <<
sqrt(ErrdLI(1, 1)) <<
" " <<
sqrt(ErrdLI(2, 2)) <<
" " <<
sqrt(ErrdLI(3, 3)) <<
" " 2489 <<
sqrt(ErrdLI(4, 4)) <<
" " <<
sqrt(ErrdLI(5, 5)) <<
" " <<
sqrt(ErrdLI(6, 6)) << std::endl;
2502 if (GNorm.
z() > 0.95)
2503 std::cout <<
" Ecap1 N " << GNorm << std::endl;
2504 else if (GNorm.
z() < -0.95)
2505 std::cout <<
" Ecap2 N " << GNorm << std::endl;
2507 std::cout <<
" Barrel N " << GNorm << std::endl;
2508 std::cout <<
" JacCLo(i," << i <<
") = {" << JacCorLoc(1, i) <<
" " << JacCorLoc(2, i) <<
" " << JacCorLoc(3, i)
2509 <<
" " << JacCorLoc(4, i) <<
"}" << std::endl;
2510 std::cout <<
" rotLoc " << rotLoc << std::endl;
2511 std::cout <<
" position " << R0 << std::endl;
2512 std::cout <<
" Pm,l " << Pm.T() <<
" " << Pml(1) / Pml(3) <<
" " << Pml(2) / Pml(3) << std::endl;
2513 std::cout <<
" Pt,l " << Pt.T() <<
" " << Ptl(1) / Ptl(3) <<
" " << Ptl(2) / Ptl(3) << std::endl;
2514 std::cout <<
" V " << V.T() << std::endl;
2515 std::cout <<
" Cov \n" << covLoc << std::endl;
2516 std::cout <<
" W*Cov " << W * covLoc << std::endl;
2520 std::cout <<
" JacToLoc " << JacToLoc << std::endl;
2523 #ifdef CHECK_OF_JACOBIAN_CARTESIAN_TO_LOCAL 2525 CLHEP::HepVector V0(4, 0);
2526 V0(1) = Pml(1) / Pml(3) - Ptl(1) / Ptl(3);
2527 V0(2) = Pml(2) / Pml(3) - Ptl(2) / Ptl(3);
2528 V0(3) = Rml(1) - Rtl(1);
2529 V0(4) = Rml(2) - Rtl(2);
2532 CLHEP::HepVector V1(4, 0);
2535 Rml = rotLoc * (Rm -
R0);
2537 Pm(ii - 3) +=
delta;
2542 V1(1) = Pml(1) / Pml(3) - Ptl(1) / Ptl(3);
2543 V1(2) = Pml(2) / Pml(3) - Ptl(2) / Ptl(3);
2544 V1(3) = Rml(1) - Rtl(1);
2545 V1(4) = Rml(2) - Rtl(2);
2547 if (GNorm.
z() > 0.95)
2548 std::cout <<
" Ecap1 N " << GNorm << std::endl;
2549 else if (GNorm.
z() < -0.95)
2550 std::cout <<
" Ecap2 N " << GNorm << std::endl;
2552 std::cout <<
" Barrel N " << GNorm << std::endl;
2553 std::cout <<
" dldc Num (i," << ii <<
") " << (V1(1) - V0(1)) / delta <<
" " << (V1(2) - V0(2)) / delta <<
" " 2554 << (V1(3) - V0(3)) / delta <<
" " << (V1(4) - V0(4)) / delta << std::endl;
2555 std::cout <<
" dldc Ana (i," << ii <<
") " << JacToLoc(1, ii) <<
" " << JacToLoc(2, ii) <<
" " << JacToLoc(3, ii)
2556 <<
" " << JacToLoc(4, ii) << std::endl;
2568 CLHEP::HepVector
d(3, 0),
a(3, 0), Norm(3), Rm0(3), Pm0(3), Rm1(3), Pm1(3), Rmi(3), Pmi(3);
2590 if ((
d(1) == 0.) & (
d(2) == 0.) & (
d(3) == 0.) & (
a(1) == 0.) & (
a(2) == 0.) & (
a(3) == 0.)) {
2594 std::cout <<
" ...... without misalignment " << std::endl;
2608 CLHEP::HepMatrix
T(3, 3, 1);
2618 T(1, 2) =
c1 * s3 + s1 * s2 * c3;
2619 T(1, 3) = s1 * s3 -
c1 * s2 * c3;
2621 T(2, 2) =
c1 * c3 - s1 * s2 * s3;
2622 T(2, 3) = s1 * c3 +
c1 * s2 * s3;
2629 CLHEP::HepMatrix Ti = T.T();
2630 CLHEP::HepVector di = -Ti *
d;
2632 CLHEP::HepVector ex0(3, 0), ey0(3, 0), ez0(3, 0), ex(3, 0), ey(3, 0), ez(3, 0);
2640 CLHEP::HepVector TiN = Ti * Norm;
2646 Rm1(1) =
CLHEP_dot(ex, Rm0 + si * Pm0 - di);
2647 Rm1(2) =
CLHEP_dot(ey, Rm0 + si * Pm0 - di);
2648 Rm1(3) =
CLHEP_dot(ez, Rm0 + si * Pm0 - di);
2657 std::cout <<
" ----- Pm " << Pm << std::endl;
2658 std::cout <<
" T*Pm0 " << Pm1.T() << std::endl;
2662 CLHEP::HepVector Rml = Rm1(1) * ex + Rm1(2) * ey + Rm1(3) * ez + di;
2664 CLHEP::HepVector Rt0(3);
2671 CLHEP::HepVector Rl = Rml + sl * (Ti * Pm1);
2679 CLHEP::HepVector Dr = Ti * Rm1 - Ti * d + s * (Ti * Pm1) - Rm0;
2680 CLHEP::HepVector Dp = Ti * Pm1 - Pm0;
2682 CLHEP::HepVector TiR = Ti * Rm0 + di;
2683 CLHEP::HepVector Ri = T * TiR +
d;
2685 std::cout <<
" --TTi-0 " << (Ri - Rm0).
T() << std::endl;
2686 std::cout <<
" -- Dr " << Dr.T() << endl;
2687 std::cout <<
" -- Dp " << Dp.T() << endl;
2695 std::cout <<
" -- si sl s " << si <<
" " << sl <<
" " << s << std::endl;
2698 std::cout <<
" -- Rml-(Rm0+si*Pm0) " << (Rml - Rm0 - si * Pm0).
T() << std::endl;
2706 std::cout <<
" --Rl-0 " << (Rl - Rm0).
T() << std::endl;
2724 CLHEP::HepVector
d(3, 0),
a(3, 0), Norm(3), Rm0(3), Pm0(3), Rm1(3), Pm1(3), Rmi(3), Pmi(3);
2748 if ((
d(1) == 0.) & (
d(2) == 0.) & (
d(3) == 0.) & (
a(1) == 0.) & (
a(2) == 0.) & (
a(3) == 0.)) {
2757 std::cout <<
" ...... without misalignment " << std::endl;
2771 CLHEP::HepMatrix
T(3, 3, 1);
2781 T(1, 2) =
c1 * s3 + s1 * s2 * c3;
2782 T(1, 3) = s1 * s3 -
c1 * s2 * c3;
2784 T(2, 2) =
c1 * c3 - s1 * s2 * s3;
2785 T(2, 3) = s1 * c3 +
c1 * s2 * s3;
2793 CLHEP::HepMatrix Ti = T.T();
2794 CLHEP::HepVector di = -Ti *
d;
2796 CLHEP::HepVector ex0(3, 0), ey0(3, 0), ez0(3, 0), ex(3, 0), ey(3, 0), ez(3, 0);
2804 CLHEP::HepVector TiN = Ti * Norm;
2810 Rm1(1) =
CLHEP_dot(ex, Rm0 + si * Pm0 - di);
2811 Rm1(2) =
CLHEP_dot(ey, Rm0 + si * Pm0 - di);
2812 Rm1(3) =
CLHEP_dot(ez, Rm0 + si * Pm0 - di);
2822 CLHEP::HepMatrix Tl(3, 3, 0);
2836 CLHEP::HepVector
R0(3, 0), newR0(3, 0), newRl(3, 0), newPl(3, 0);
2841 newRl = Tl * (Rm1 -
R0);
2844 Vm(0) = newPl(1) / newPl(3);
2845 Vm(1) = newPl(2) / newPl(3);
2849 #ifdef CHECK_DERIVATIVES_LOCAL_VS_ANGLES 2857 CLHEP::HepVector Rm10 = Rm1, Pm10 = Pm1;
2859 CLHEP::HepMatrix newTl = Tl *
T;
2867 Rm1(1) =
CLHEP_dot(ex, Rm0 + si * Pm0 - di);
2868 Rm1(2) =
CLHEP_dot(ey, Rm0 + si * Pm0 - di);
2869 Rm1(3) =
CLHEP_dot(ez, Rm0 + si * Pm0 - di);
2872 newRl = Tl * (Rm1 -
R0);
2875 Vm(0) = newPl(1) / newPl(3);
2876 Vm(1) = newPl(2) / newPl(3);
2879 std::cout <<
" ========= dVm/da" << ii <<
" " << (Vm - Vm0) * (1. / del) << std::endl;
2885 std::cout <<
" ex " << (Tl.T() * ex0).
T() << std::endl;
2886 std::cout <<
" ey " << (Tl.T() * ey0).
T() << std::endl;
2887 std::cout <<
" ez " << (Tl.T() * ez0).
T() << std::endl;
2890 std::cout <<
" pxyz/p gl 0 " << (Pm0 / Pm0.norm()).
T() << std::endl;
2891 std::cout <<
" pxyz/p loc0 " << (Tl * Pm0 / (Tl * Pm0).norm()).
T() << std::endl;
2892 std::cout <<
" pxyz/p glob " << (Pm1 / Pm1.norm()).
T() << std::endl;
2893 std::cout <<
" pxyz/p loc " << (newPl / newPl.norm()).
T() << std::endl;
2897 std::cout <<
" ---- phi g0 g1 l0 l1 " << atan2(Pm0(2), Pm0(1)) <<
" " << atan2(Pm1(2), Pm1(1)) <<
" " 2898 << atan2((Tl * Pm0)(2), (Tl * Pm0)(1)) <<
" " << atan2(newPl(2), newPl(1)) << std::endl;
2899 std::cout <<
" ---- angl Gl Loc " << atan2(Pm1(2), Pm1(1)) - atan2(Pm0(2), Pm0(1)) <<
" " 2900 << atan2(newPl(2), newPl(1)) - atan2((Tl * Pm0)(2), (Tl * Pm0)(1)) <<
" " 2901 << atan2(newPl(3), newPl(2)) - atan2((Tl * Pm0)(3), (Tl * Pm0)(2)) <<
" " 2902 << atan2(newPl(1), newPl(3)) - atan2((Tl * Pm0)(1), (Tl * Pm0)(3)) <<
" " << std::endl;
2906 CLHEP::HepMatrix newTl(3, 3, 0);
2907 CLHEP::HepVector
R0(3, 0), newRl(3, 0), newPl(3, 0);
2908 newTl = Tl * Ti.T();
2909 newR0 = Ti *
R0 + di;
2911 std::cout <<
" N " << Norm.T() << std::endl;
2919 CLHEP::HepVector Rvc(3, 0), Pvc(3, 0), Rvg(3, 0), Pvg(3, 0);
2923 Pvc(1) = Pvc(3) * Vm(0);
2924 Pvc(2) = Pvc(3) * Vm(1);
2926 Rvg = newTl.T() * Rvc + newR0;
2927 Pvg = newTl.T() * Pvc;
2929 std::cout <<
" newPl " << newPl.T() << std::endl;
2930 std::cout <<
" Pvc " << Pvc.T() << std::endl;
2931 std::cout <<
" Rvg " << Rvg.T() << std::endl;
2932 std::cout <<
" Rm1 " << Rm1.T() << std::endl;
2933 std::cout <<
" Pvg " << Pvg.T() << std::endl;
2934 std::cout <<
" Pm1 " << Pm1.T() << std::endl;
2939 std::cout <<
" ----- Pm " << Pm << std::endl;
2940 std::cout <<
" T*Pm0 " << Pm1.T() << std::endl;
2944 CLHEP::HepVector Rml = Rm1(1) * ex + Rm1(2) * ey + Rm1(3) * ez + di;
2946 CLHEP::HepVector Rt0(3);
2953 CLHEP::HepVector Rl = Rml + sl * (Ti * Pm1);
2961 CLHEP::HepVector Dr = Ti * Rm1 - Ti * d + s * (Ti * Pm1) - Rm0;
2962 CLHEP::HepVector Dp = Ti * Pm1 - Pm0;
2964 CLHEP::HepVector TiR = Ti * Rm0 + di;
2965 CLHEP::HepVector Ri = T * TiR +
d;
2967 std::cout <<
" --TTi-0 " << (Ri - Rm0).
T() << std::endl;
2968 std::cout <<
" -- Dr " << Dr.T() << endl;
2969 std::cout <<
" -- Dp " << Dp.T() << endl;
2977 std::cout <<
" -- si sl s " << si <<
" " << sl <<
" " << s << std::endl;
2980 std::cout <<
" -- Rml-(Rm0+si*Pm0) " << (Rml - Rm0 - si * Pm0).
T() << std::endl;
2988 std::cout <<
" --Rl-0 " << (Rl - Rm0).
T() << std::endl;
3002 bool smooth =
false;
3005 std::cout <<
" ......... start of trackFitter ......... " << std::endl;
3006 if (
false && info) {
3008 this->
debugTrackHit(
" Tracker TransientTrack hits ", alongTTr);
3012 DetId trackDetId =
DetId(alongTr->innerDetId());
3013 for (
auto const&
hit : alongTr->recHits())
3018 for (
unsigned int ihit = recHitAlong.
size() - 1; ihit + 1 > 0; ihit--) {
3021 recHitAlong.
clear();
3024 std::cout <<
" ... Own recHit.size() " << recHit.
size() <<
" " << trackDetId.
rawId() << std::endl;
3028 for (
auto const&
hit : alongTr->recHits())
3032 std::cout <<
" ... recHitTrack.size() " << recHit.
size() <<
" " << trackDetId.
rawId() <<
" ======> recHitMu " 3041 std::cout <<
" ...along.... recHitMu.size() " << recHitMu.size() << std::endl;
3045 for (
unsigned int ihit = recHitMuAlong.size() - 1; ihit + 1 > 0; ihit--) {
3046 recHitMu.push_back(recHitMuAlong[ihit]);
3048 recHitMuAlong.clear();
3051 std::cout <<
" ...opposite... recHitMu.size() " << recHitMu.size() << std::endl;
3072 std::vector<Trajectory> trajVec;
3074 trajVec =
theFitter->fit(seedT, recHitMu, initialTSOS);
3076 trajVec =
theFitterOp->fit(seedT, recHitMu, initialTSOS);
3082 std::cout <<
" . . . . . trajVec.size() " << trajVec.size() << std::endl;
3083 if (!trajVec.empty())
3088 if (!trajVec.empty())
3089 trackFittedTSOS = trajVec[0].lastMeasurement().updatedState();
3091 std::vector<Trajectory> trajSVec;
3092 if (!trajVec.empty()) {
3099 std::cout <<
" . . . . trajSVec.size() " << trajSVec.size() << std::endl;
3100 if (!trajSVec.empty())
3101 this->
debugTrajectorySOSv(
"smoothed geom InnermostState", trajSVec[0].geometricalInnermostState());
3102 if (!trajSVec.empty())
3103 trackFittedTSOS = trajSVec[0].geometricalInnermostState();
3117 bool smooth =
false;
3120 std::cout <<
" ......... start of muonFitter ........" << std::endl;
3121 if (
false && info) {
3123 this->
debugTrackHit(
" Muon TransientTrack hits ", alongTTr);
3127 DetId trackDetId =
DetId(alongTr->innerDetId());
3128 for (
auto const&
hit : alongTr->recHits())
3133 for (
unsigned int ihit = recHitAlong.
size() - 1; ihit + 1 > 0; ihit--) {
3136 recHitAlong.
clear();
3139 std::cout <<
" ... Own recHit.size() DetId==Muon " << recHit.
size() <<
" " << trackDetId.
rawId() << std::endl;
3144 std::cout <<
" ...along.... recHitMu.size() " << recHitMu.size() << std::endl;
3148 for (
unsigned int ihit = recHitMuAlong.size() - 1; ihit + 1 > 0; ihit--) {
3149 recHitMu.push_back(recHitMuAlong[ihit]);
3151 recHitMuAlong.clear();
3154 std::cout <<
" ...opposite... recHitMu.size() " << recHitMu.size() << std::endl;
3175 std::vector<Trajectory> trajVec;
3177 trajVec =
theFitter->fit(seedT, recHitMu, initialTSOS);
3179 trajVec =
theFitterOp->fit(seedT, recHitMu, initialTSOS);
3185 std::cout <<
" . . . . . trajVec.size() " << trajVec.size() << std::endl;
3186 if (!trajVec.empty())
3191 if (!trajVec.empty())
3192 trackFittedTSOS = trajVec[0].lastMeasurement().updatedState();
3194 std::vector<Trajectory> trajSVec;
3195 if (!trajVec.empty()) {
3202 std::cout <<
" . . . . trajSVec.size() " << trajSVec.size() << std::endl;
3203 if (!trajSVec.empty())
3204 this->
debugTrajectorySOSv(
"smoothed geom InnermostState", trajSVec[0].geometricalInnermostState());
3205 if (!trajSVec.empty())
3206 trackFittedTSOS = trajSVec[0].geometricalInnermostState();
3213 std::cout <<
" ------- " << title <<
" --------" << std::endl;
3216 std::cout <<
" Hit " << nHit++ <<
" DetId " << (*i)->geographicalId().det();
3219 else if ((*i)->geographicalId().det() ==
DetId::Muon)
3223 if (!(*i)->isValid())
3224 std::cout <<
" not valid " << std::endl;
3232 std::cout <<
" ------- " << title <<
" --------" << std::endl;
3234 for (
auto const&
hit : alongTr->recHits()) {
3235 std::cout <<
" Hit " << nHit++ <<
" DetId " <<
hit->geographicalId().det();
3242 if (!
hit->isValid())
3243 std::cout <<
" not valid " << std::endl;
3251 std::cout <<
" --- " << title <<
" --- " << std::endl;
3253 std::cout <<
" Not valid !!!! " << std::endl;
3257 << trajSOS.
charge() << std::endl;
3277 std::cout <<
" --- " << title <<
" --- " << std::endl;
3279 std::cout <<
" Not valid !!!! " << std::endl;
3283 << trajSOS.
charge() << std::endl;
3304 <<
" ...... " << title <<
" ...... " << std::endl;
3306 std::cout <<
" Not valid !!!!!!!! " << std::endl;
3311 std::cout <<
" alongMomentum >>>>" << std::endl;
3313 std::cout <<
" oppositeToMomentum <<<<" << std::endl;
3318 std::cout <<
" . . . . . . . . . . . . . . . . . . . . . . . . . . . . \n" << std::endl;
3334 std::cout <<
" paramVector " << paramVec.T() << std::endl;
3336 CLHEP::Hep3Vector colX, colY, colZ;
3338 #ifdef NOT_EXACT_ROTATION_MATRIX 3339 colX = CLHEP::Hep3Vector(1., -paramVec(6), paramVec(5));
3340 colY = CLHEP::Hep3Vector(paramVec(6), 1., -paramVec(4));
3341 colZ = CLHEP::Hep3Vector(-paramVec(5), paramVec(4), 1.);
3346 colX = CLHEP::Hep3Vector(c2 * c3, -c2 * s3, s2);
3347 colY = CLHEP::Hep3Vector(
c1 * s3 + s1 * s2 * c3,
c1 * c3 - s1 * s2 * s3, -s1 * c2);
3348 colZ = CLHEP::Hep3Vector(s1 * s3 -
c1 * s2 * c3, s1 * c3 +
c1 * s2 * s3,
c1 * c2);
3351 CLHEP::HepVector param0(6, 0);
3361 CLHEP::HepEulerAngles angMuGlRcd =
iteratorMuonRcd->rotation().eulerAngles();
3363 std::cout <<
" Old muon Rcd Euler angles " << angMuGlRcd.phi() <<
" " << angMuGlRcd.theta() <<
" " 3364 << angMuGlRcd.psi() << std::endl;
3366 if ((angMuGlRcd.phi() == 0.) && (angMuGlRcd.theta() == 0.) && (angMuGlRcd.psi() == 0.) && (posMuGlRcd.x() == 0.) &&
3367 (posMuGlRcd.y() == 0.) && (posMuGlRcd.z() == 0.)) {
3368 std::cout <<
" New muon parameters are stored in Rcd" << std::endl;
3374 }
else if ((paramVec(1) == 0.) && (paramVec(2) == 0.) && (paramVec(3) == 0.) && (paramVec(4) == 0.) &&
3375 (paramVec(5) == 0.) && (paramVec(6) == 0.)) {
3376 std::cout <<
" Old muon parameters are stored in Rcd" << std::endl;
3381 std::cout <<
" New + Old muon parameters are stored in Rcd" << std::endl;
3382 CLHEP::Hep3Vector posMuGlRcdThis = CLHEP::Hep3Vector(paramVec(1), paramVec(2), paramVec(3));
3383 CLHEP::HepRotation rotMuGlRcdThis = CLHEP::HepRotation(colX, colY, colZ);
3384 CLHEP::Hep3Vector posMuGlRcdNew = rotMuGlRcdThis * posMuGlRcd + posMuGlRcdThis;
3385 CLHEP::HepRotation rotMuGlRcdNew = rotMuGlRcdThis * rotMuGlRcd;
3401 <<
tracker.rotation().eulerAngles() << std::endl;
3406 std::cout <<
" rotations angles around x,y,z " 3411 std::cout <<
"Ecal (" <<
ecal.rawId() <<
") at " <<
ecal.translation() <<
" " <<
ecal.rotation().eulerAngles()
3415 std::cout <<
"Hcal (" <<
hcal.rawId() <<
") at " <<
hcal.translation() <<
" " <<
hcal.rotation().eulerAngles()
3419 std::cout <<
"Calo (" << calo.rawId() <<
") at " << calo.translation() <<
" " << calo.rotation().eulerAngles()
3421 std::cout << calo.rotation() << std::endl;
3424 globalPositions->
m_align.push_back(muon);
3427 globalPositions->
m_align.push_back(calo);
3429 std::cout <<
"Uploading to the database..." << std::endl;
3434 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
3444 "GlobalPositionRcd");
const GlobalTrackingGeometry * trackingGeometry_
double CLHEP_dot(const CLHEP::HepVector &a, const CLHEP::HepVector &b)
edm::ESWatcher< GlobalPositionRcd > watchGlobalPositionRcd_
edm::ESHandle< GlobalTrackingGeometry > theTrackingGeometry
RecHitPointer build(const TrackingRecHit *p, edm::ESHandle< GlobalTrackingGeometry > trackingGeometry) const
Call the MuonTransientTrackingRecHit::specificBuild.
void debugTrajectorySOSv(const std::string, TrajectoryStateOnSurface)
KFTrajectorySmoother * theSmootherOp
virtual ConstReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
void gradientGlobalAlg(GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, AlgebraicSymMatrix66 &)
void gradientLocal(GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, CLHEP::HepSymMatrix &, CLHEP::HepMatrix &, CLHEP::HepVector &, AlgebraicVector4 &)
TrackCharge charge() const
const LocalTrajectoryParameters & localParameters() const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
GlobalVector normalVector() const
Sin< T >::type sin(const T &t)
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
KFTrajectoryFitter * theFitter
constexpr uint32_t rawId() const
get the raw id
const CartesianTrajectoryError cartesianError() const
CLHEP::HepVector MuGlAngle
void misalignMuon(GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &)
int bunchCrossing() const
std::vector< AlignTransform >::const_iterator iteratorHcalRcd
std::vector< ConstRecHitPointer > RecHitContainer
GlobalPoint globalPosition() const
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
void gradientGlobal(GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, AlgebraicSymMatrix66 &)
std::vector< AlignTransform > m_align
ROOT::Math::SVector< double, 6 > AlgebraicVector6
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
virtual TrajectoryContainer trajectories(const Trajectory &traj) const
TrajectoryStateOnSurface innermostMeasurementState() const
PropagationDirection const & direction() const
RecordProviders::iterator Itr
AlgebraicVector5 vector() const
const SurfaceType & surface() const
#define DEFINE_FWK_MODULE(type)
void debugTrackHit(const std::string, reco::TrackRef)
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
edm::ESWatcher< GlobalTrackingGeometryRecord > watchTrackingGeometry_
TrajectoryMeasurement const & lastMeasurement() const
FreeTrajectoryState const * freeState(bool withErrors=true) const
Cos< T >::type cos(const T &t)
KFTrajectoryFitter * theFitterOp
ROOT::Math::SVector< double, 3 > AlgebraicVector3
std::vector< AlignTransform >::const_iterator iteratorMuonRcd
void analyzeTrackTrajectory(const edm::Event &, const edm::EventSetup &)
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
const AlgebraicSymMatrix55 & matrix() const
const MagneticField * magneticField_
const LocalTrajectoryError & localError() const
static const std::string B
TrajectoryStateOnSurface outermostMeasurementState() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
trackingRecHit_iterator recHitsEnd() const
last iterator to RecHits
const AlgebraicSymMatrix66 & matrix() const
void misalignMuonL(GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, AlgebraicVector4 &, TrajectoryStateOnSurface &, TrajectoryStateOnSurface &)
void analyze(const edm::Event &, const edm::EventSetup &) override
GlobalTrackerMuonAlignment(const edm::ParameterSet &)
void writeGlPosRcd(CLHEP::HepVector &d3)
std::vector< AlignTransform >::const_iterator iteratorEcalRcd
~GlobalTrackerMuonAlignment() override
TrajectoryMeasurement const & firstMeasurement() const
void trackFitter(reco::TrackRef, reco::TransientTrack &, PropagationDirection, TrajectoryStateOnSurface &)
KFTrajectorySmoother * theSmoother
ROOT::Math::SVector< double, 5 > AlgebraicVector5
const GlobalTrajectoryParameters & globalParameters() const
const Alignments * globalPositionRcd_
GlobalTrackerMuonAlignment
const TransientTrackingRecHitBuilder * TTRHBuilder
edm::ESWatcher< IdealMagneticFieldRecord > watchMagneticFieldRecord_
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
bool check(const edm::EventSetup &iSetup)
GlobalVector globalMomentum() const
void debugTrajectory(const std::string, Trajectory &)
cond::Time_t currentTime() const
const RotationType & rotation() const
std::vector< AlignTransform >::const_iterator iteratorTrackerRcd
TrajectoryStateOnSurface const & updatedState() const
float pzSign() const
Sign of the z-component of the momentum in the local frame.
ROOT::Math::SVector< double, 4 > AlgebraicVector4
edm::ESWatcher< TrackingComponentsRecord > watchTrackingComponentsRecord_
const PositionType & position() const
void analyzeTrackTrack(const edm::Event &, const edm::EventSetup &)
trackingRecHit_iterator recHitsBegin() const
first iterator to RecHits
AlgebraicVector6 vector() const
void muonFitter(reco::TrackRef, reco::TransientTrack &, PropagationDirection, TrajectoryStateOnSurface &)
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33
MuonTransientTrackingRecHitBuilder * MuRHBuilder
Global3DVector GlobalVector
CLHEP::HepVector MuGlShift
void debugTrajectorySOS(const std::string, TrajectoryStateOnSurface &)