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;
213 std::vector<AlignTransform>::const_iterator
283 trackTags_(iConfig.getParameter<
edm::
InputTag>(
"tracks")),
284 muonTags_(iConfig.getParameter<
edm::
InputTag>(
"muons")),
285 gmuonTags_(iConfig.getParameter<
edm::
InputTag>(
"gmuons")),
286 smuonTags_(iConfig.getParameter<
edm::
InputTag>(
"smuons")),
287 cosmicMuonMode_(iConfig.getParameter<
bool>(
"cosmics")),
288 isolatedMuonMode_(iConfig.getParameter<
bool>(
"isolated")),
289 refitMuon_(iConfig.getParameter<
bool>(
"refitmuon")),
290 refitTrack_(iConfig.getParameter<
bool>(
"refittrack")),
291 rootOutFile_(iConfig.getUntrackedParameter<
string>(
"rootOutFile")),
292 txtOutFile_(iConfig.getUntrackedParameter<
string>(
"txtOutFile")),
293 writeDB_(iConfig.getUntrackedParameter<
bool>(
"writeDB")),
294 debug_(iConfig.getUntrackedParameter<
bool>(
"debug")),
296 #ifdef NO_FALSE_FALSE_MODE 299 <<
"Use from GlobalTrackerMuonAlignment_test_cfg.py.";
303 throw cms::Exception(
"BadConfig") <<
"Muon collection can be either cosmic or isolated! " 304 <<
"Please set only one to true.";
339 for (
int i = 0;
i <= 2;
i++) {
341 for (
int j = 0;
j <= 2;
j++) {
346 Grad = CLHEP::HepVector(6, 0);
347 Hess = CLHEP::HepSymMatrix(6, 0);
349 GradL = CLHEP::HepVector(6, 0);
350 HessL = CLHEP::HepSymMatrix(6, 0);
353 TDirectory* dirsave = gDirectory;
356 const bool oldAddDir = TH1::AddDirectoryStatus();
358 TH1::AddDirectory(
true);
362 TH1::AddDirectory(oldAddDir);
375 for (
int i = 0;
i <= 2;
i++)
376 for (
int j = 0;
j <= 2;
j++) {
381 bool ierr = !InfI.Invert();
384 std::cout <<
" Error inverse Inf matrix !!!!!!!!!!!" << std::endl;
387 for (
int i = 0;
i <= 2;
i++)
388 for (
int k = 0;
k <= 2;
k++)
393 CLHEP::HepVector d3 = CLHEP::solve(
Hess, -
Grad);
395 CLHEP::HepMatrix Errd3 =
Hess.inverse(iEr3);
398 std::cout <<
" endJob Error inverse Hess matrix !!!!!!!!!!!" << std::endl;
403 CLHEP::HepVector dLI = CLHEP::solve(
HessL, -
GradL);
405 CLHEP::HepMatrix ErrdLI =
HessL.inverse(iErI);
408 std::cout <<
" endJob Error inverse HessL matrix !!!!!!!!!!!" << std::endl;
415 std::cout <<
" ALCARECOMuAlCalIsolatedMu " << std::endl;
417 std::cout <<
" ALCARECOMuAlGlobalCosmics " << std::endl;
424 std::cout <<
" +- " <<
sqrt(InfI(0, 0)) <<
" " <<
sqrt(InfI(1, 1)) <<
" " <<
sqrt(InfI(2, 2)) << std::endl;
425 std::cout <<
" dG " << d3(1) <<
" " << d3(2) <<
" " << d3(3) <<
" " << d3(4) <<
" " << d3(5) <<
" " << d3(6)
428 std::cout <<
" +- " <<
sqrt(Errd3(1, 1)) <<
" " <<
sqrt(Errd3(2, 2)) <<
" " <<
sqrt(Errd3(3, 3)) <<
" " 429 <<
sqrt(Errd3(4, 4)) <<
" " <<
sqrt(Errd3(5, 5)) <<
" " <<
sqrt(Errd3(6, 6)) << std::endl;
430 std::cout <<
" dL " << dLI(1) <<
" " << dLI(2) <<
" " << dLI(3) <<
" " << dLI(4) <<
" " << dLI(5) <<
" " << dLI(6)
433 std::cout <<
" +- " <<
sqrt(ErrdLI(1, 1)) <<
" " <<
sqrt(ErrdLI(2, 2)) <<
" " <<
sqrt(ErrdLI(3, 3)) <<
" " 434 <<
sqrt(ErrdLI(4, 4)) <<
" " <<
sqrt(ErrdLI(5, 5)) <<
" " <<
sqrt(ErrdLI(6, 6)) << std::endl;
437 CLHEP::HepVector vectorToDb(6, 0), vectorErrToDb(6, 0);
441 for (
unsigned int i = 1;
i <= 6;
i++)
442 vectorErrToDb(
i) =
sqrt(ErrdLI(
i,
i));
451 std::cout <<
" outglobal.txt is not open !!!!!" << std::endl;
453 OutGlobalTxt << vectorToDb(1) <<
" " << vectorToDb(2) <<
" " << vectorToDb(3) <<
" " << vectorToDb(4) <<
" " 454 << vectorToDb(5) <<
" " << vectorToDb(6) <<
" muon Global.\n";
455 OutGlobalTxt << vectorErrToDb(1) <<
" " << vectorErrToDb(1) <<
" " << vectorErrToDb(1) <<
" " << vectorErrToDb(1)
456 <<
" " << vectorErrToDb(1) <<
" " << vectorErrToDb(1) <<
" errors.\n";
466 std::cout <<
" Write to the file outglobal.txt done " << std::endl;
478 double PI = 3.1415927;
479 histo =
new TH1F(
"Pt",
"pt", 1000, 0, 100);
480 histo2 =
new TH1F(
"P",
"P [GeV/c]", 400, 0., 400.);
481 histo2->GetXaxis()->SetTitle(
"momentum [GeV/c]");
482 histo3 =
new TH1F(
"outerLambda",
"#lambda outer", 100, -
PI / 2.,
PI / 2.);
483 histo3->GetXaxis()->SetTitle(
"#lambda outer");
484 histo4 =
new TH1F(
"phi",
"#phi [rad]", 100, -
PI,
PI);
485 histo4->GetXaxis()->SetTitle(
"#phi [rad]");
486 histo5 =
new TH1F(
"Rmuon",
"inner muon hit R [cm]", 100, 0., 800.);
487 histo5->GetXaxis()->SetTitle(
"R of muon [cm]");
488 histo6 =
new TH1F(
"Zmuon",
"inner muon hit Z[cm]", 100, -1000., 1000.);
489 histo6->GetXaxis()->SetTitle(
"Z of muon [cm]");
490 histo7 =
new TH1F(
"(Pm-Pt)/Pt",
" (Pmuon-Ptrack)/Ptrack", 100, -2., 2.);
491 histo7->GetXaxis()->SetTitle(
"(Pmuon-Ptrack)/Ptrack");
492 histo8 =
new TH1F(
"chi muon-track",
"#chi^{2}(muon-track)", 1000, 0., 1000.);
493 histo8->GetXaxis()->SetTitle(
"#chi^{2} of muon w.r.t. propagated track");
494 histo11 =
new TH1F(
"distance muon-track",
"distance muon w.r.t track [cm]", 100, 0., 30.);
495 histo11->GetXaxis()->SetTitle(
"distance of muon w.r.t. track [cm]");
496 histo12 =
new TH1F(
"Xmuon-Xtrack",
"Xmuon-Xtrack [cm]", 200, -20., 20.);
497 histo12->GetXaxis()->SetTitle(
"Xmuon - Xtrack [cm]");
498 histo13 =
new TH1F(
"Ymuon-Ytrack",
"Ymuon-Ytrack [cm]", 200, -20., 20.);
499 histo13->GetXaxis()->SetTitle(
"Ymuon - Ytrack [cm]");
500 histo14 =
new TH1F(
"Zmuon-Ztrack",
"Zmuon-Ztrack [cm]", 200, -20., 20.);
501 histo14->GetXaxis()->SetTitle(
"Zmuon-Ztrack [cm]");
502 histo15 =
new TH1F(
"NXmuon-NXtrack",
"NXmuon-NXtrack [rad]", 200, -.1, .1);
503 histo15->GetXaxis()->SetTitle(
"N_{X}(muon)-N_{X}(track) [rad]");
504 histo16 =
new TH1F(
"NYmuon-NYtrack",
"NYmuon-NYtrack [rad]", 200, -.1, .1);
505 histo16->GetXaxis()->SetTitle(
"N_{Y}(muon)-N_{Y}(track) [rad]");
506 histo17 =
new TH1F(
"NZmuon-NZtrack",
"NZmuon-NZtrack [rad]", 200, -.1, .1);
507 histo17->GetXaxis()->SetTitle(
"N_{Z}(muon)-N_{Z}(track) [rad]");
508 histo18 =
new TH1F(
"expected error of Xinner",
"outer hit of inner tracker", 100, 0, .01);
509 histo18->GetXaxis()->SetTitle(
"expected error of Xinner [cm]");
510 histo19 =
new TH1F(
"expected error of Xmuon",
"inner hit of muon", 100, 0, .1);
511 histo19->GetXaxis()->SetTitle(
"expected error of Xmuon [cm]");
512 histo20 =
new TH1F(
"expected error of Xmuon-Xtrack",
"muon w.r.t. propagated track", 100, 0., 10.);
513 histo20->GetXaxis()->SetTitle(
"expected error of Xmuon-Xtrack [cm]");
514 histo21 =
new TH1F(
"pull of Xmuon-Xtrack",
"pull of Xmuon-Xtrack", 100, -10., 10.);
515 histo21->GetXaxis()->SetTitle(
"(Xmuon-Xtrack)/expected error");
516 histo22 =
new TH1F(
"pull of Ymuon-Ytrack",
"pull of Ymuon-Ytrack", 100, -10., 10.);
517 histo22->GetXaxis()->SetTitle(
"(Ymuon-Ytrack)/expected error");
518 histo23 =
new TH1F(
"pull of Zmuon-Ztrack",
"pull of Zmuon-Ztrack", 100, -10., 10.);
519 histo23->GetXaxis()->SetTitle(
"(Zmuon-Ztrack)/expected error");
520 histo24 =
new TH1F(
"pull of PXmuon-PXtrack",
"pull of PXmuon-PXtrack", 100, -10., 10.);
521 histo24->GetXaxis()->SetTitle(
"(P_{X}(muon)-P_{X}(track))/expected error");
522 histo25 =
new TH1F(
"pull of PYmuon-PYtrack",
"pull of PYmuon-PYtrack", 100, -10., 10.);
523 histo25->GetXaxis()->SetTitle(
"(P_{Y}(muon)-P_{Y}(track))/expected error");
524 histo26 =
new TH1F(
"pull of PZmuon-PZtrack",
"pull of PZmuon-PZtrack", 100, -10., 10.);
525 histo26->GetXaxis()->SetTitle(
"(P_{Z}(muon)-P_{Z}(track))/expected error");
526 histo27 =
new TH1F(
"N_x",
"Nx of tangent plane", 120, -1.1, 1.1);
527 histo27->GetXaxis()->SetTitle(
"normal vector projection N_{X}");
528 histo28 =
new TH1F(
"N_y",
"Ny of tangent plane", 120, -1.1, 1.1);
529 histo28->GetXaxis()->SetTitle(
"normal vector projection N_{Y}");
530 histo29 =
new TH1F(
"lenght of track",
"lenght of track", 200, 0., 400);
531 histo29->GetXaxis()->SetTitle(
"lenght of track [cm]");
532 histo30 =
new TH1F(
"lenght of muon",
"lenght of muon", 200, 0., 800);
533 histo30->GetXaxis()->SetTitle(
"lenght of muon [cm]");
535 histo31 =
new TH1F(
"local chi muon-track",
"#local chi^{2}(muon-track)", 1000, 0., 1000.);
536 histo31->GetXaxis()->SetTitle(
"#local chi^{2} of muon w.r.t. propagated track");
537 histo32 =
new TH1F(
"pull of Px/Pz local",
"pull of Px/Pz local", 100, -10., 10.);
538 histo32->GetXaxis()->SetTitle(
"local (Px/Pz(muon) - Px/Pz(track))/expected error");
539 histo33 =
new TH1F(
"pull of Py/Pz local",
"pull of Py/Pz local", 100, -10., 10.);
540 histo33->GetXaxis()->SetTitle(
"local (Py/Pz(muon) - Py/Pz(track))/expected error");
541 histo34 =
new TH1F(
"pull of X local",
"pull of X local", 100, -10., 10.);
542 histo34->GetXaxis()->SetTitle(
"local (Xmuon - Xtrack)/expected error");
543 histo35 =
new TH1F(
"pull of Y local",
"pull of Y local", 100, -10., 10.);
544 histo35->GetXaxis()->SetTitle(
"local (Ymuon - Ytrack)/expected error");
546 histo101 =
new TH2F(
"Rtr/mu vs Ztr/mu",
"hit of track/muon", 100, -800., 800., 100, 0., 600.);
547 histo101->GetXaxis()->SetTitle(
"Z of track/muon [cm]");
548 histo101->GetYaxis()->SetTitle(
"R of track/muon [cm]");
549 histo102 =
new TH2F(
"Ytr/mu vs Xtr/mu",
"hit of track/muon", 100, -600., 600., 100, -600., 600.);
550 histo102->GetXaxis()->SetTitle(
"X of track/muon [cm]");
551 histo102->GetYaxis()->SetTitle(
"Y of track/muon [cm]");
581 using namespace reco;
586 double PI = 3.1415927;
610 iEvent.getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"TrackerOnly",
tracks);
611 iEvent.getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"StandAlone",
muons);
612 iEvent.getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"GlobalMuon", gmuons);
613 iEvent.getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"SelectedMuons", smuons);
615 iEvent.getByLabel(
"ALCARECOMuAlGlobalCosmics",
"TrackerOnly",
tracks);
616 iEvent.getByLabel(
"ALCARECOMuAlGlobalCosmics",
"StandAlone",
muons);
617 iEvent.getByLabel(
"ALCARECOMuAlGlobalCosmics",
"GlobalMuon", gmuons);
618 iEvent.getByLabel(
"ALCARECOMuAlGlobalCosmics",
"SelectedMuons", smuons);
628 std::cout <<
" N tracks s/amu gmu selmu " <<
tracks->size() <<
" " <<
muons->size() <<
" " << gmuons->size() <<
" " 629 << smuons->size() << std::endl;
630 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
631 std::cout <<
" is isolatValid Matches " << itMuon->isIsolationValid() <<
" " << itMuon->isMatchesValid()
639 if (
muons->size() != 1)
641 if (gmuons->size() != 1)
643 if (smuons->size() != 1)
648 if (smuons->size() > 2)
650 if (
tracks->size() != smuons->size())
652 if (
muons->size() != smuons->size())
654 if (gmuons->size() != smuons->size())
696 <<
" angles " <<
iteratorMuonRcd->rotation().eulerAngles() << std::endl;
719 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
721 std::cout <<
" mu gM is GM Mu SaM tM " << itMuon->isGlobalMuon() <<
" " << itMuon->isMuon() <<
" " 722 << itMuon->isStandAloneMuon() <<
" " << itMuon->isTrackerMuon() <<
" " << std::endl;
736 GlobalPoint pointTrackOut = outerTrackTSOS.globalPosition();
737 float lenghtTrack = (pointTrackOut - pointTrackIn).
mag();
738 GlobalPoint pointMuonIn = innerMuTSOS.globalPosition();
740 float lenghtMuon = (pointMuonOut - pointMuonIn).
mag();
741 GlobalVector momentumTrackOut = outerTrackTSOS.globalMomentum();
743 float distanceInIn = (pointTrackIn - pointMuonIn).
mag();
744 float distanceInOut = (pointTrackIn - pointMuonOut).
mag();
745 float distanceOutIn = (pointTrackOut - pointMuonIn).
mag();
746 float distanceOutOut = (pointTrackOut - pointMuonOut).
mag();
749 std::cout <<
" pointTrackIn " << pointTrackIn << std::endl;
750 std::cout <<
" Out " << pointTrackOut <<
" lenght " << lenghtTrack << std::endl;
751 std::cout <<
" point MuonIn " << pointMuonIn << std::endl;
752 std::cout <<
" Out " << pointMuonOut <<
" lenght " << lenghtMuon << std::endl;
753 std::cout <<
" momeTrackIn Out " << momentumTrackIn <<
" " << momentumTrackOut << std::endl;
754 std::cout <<
" doi io ii oo " << distanceOutIn <<
" " << distanceInOut <<
" " << distanceInIn <<
" " 755 << distanceOutOut << std::endl;
758 if (lenghtTrack < 90.)
760 if (lenghtMuon < 300.)
762 if (momentumTrackIn.
mag() < 15. || momentumTrackOut.
mag() < 15.)
764 if (trackTT.charge() != muTT.charge())
768 std::cout <<
" passed lenght momentum cuts" << std::endl;
777 const Surface& refSurface = innerMuTSOS.surface();
779 Nl = tpMuLocal->normalVector();
783 const Plane* refPlane =
dynamic_cast<Plane*
>(surf);
787 std::cout <<
" Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 788 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
789 std::cout <<
" global " << Ng.
x() <<
" " << Ng.
y() <<
" " << Ng.
z() << std::endl;
790 std::cout <<
" lp " << Nlp.
x() <<
" " << Nlp.
y() <<
" " << Nlp.
z() << std::endl;
797 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
800 if (!extrapolationT.
isValid()) {
802 std::cout <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 815 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
816 GPm = innerMuTSOS.globalMomentum();
818 (outerTrackTSOS.globalPosition()).
y(),
819 (outerTrackTSOS.globalPosition()).
z());
829 if ((distanceOutIn <= distanceInOut) & (distanceOutIn <= distanceInIn) &
830 (distanceOutIn <= distanceOutOut)) {
832 std::cout <<
" ----- Out - In -----" << std::endl;
834 const Surface& refSurface = innerMuTSOS.surface();
836 Nl = tpMuGlobal->normalVector();
839 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
842 if (!extrapolationT.
isValid()) {
844 std::cout <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 850 std::cout <<
" extrapolationT.isValid " << extrapolationT.
isValid() << std::endl;
860 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
861 GPm = innerMuTSOS.globalMomentum();
863 (outerTrackTSOS.globalPosition()).
y(),
864 (outerTrackTSOS.globalPosition()).
z());
873 std::cout <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 874 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface)) << std::endl;
875 std::cout <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 876 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
880 else if ((distanceInOut <= distanceInIn) & (distanceInOut <= distanceOutIn) &
881 (distanceInOut <= distanceOutOut)) {
883 std::cout <<
" ----- In - Out -----" << std::endl;
887 Nl = tpMuGlobal->normalVector();
890 extrapolationT = oppositeSmPr.
propagate(innerTrackTSOS, refSurface);
892 if (!extrapolationT.
isValid()) {
894 std::cout <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 895 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid() << std::endl;
899 std::cout <<
" extrapolationT.isValid " << extrapolationT.
isValid() << std::endl;
922 std::cout <<
" propDirCh " << Chooser.operator()(*innerTrackTSOS.
freeState(), refSurface)
923 <<
" Ch == oppisite " 925 std::cout <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 926 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
930 else if ((distanceOutOut <= distanceInOut) & (distanceOutOut <= distanceInIn) &
931 (distanceOutOut <= distanceOutIn)) {
933 std::cout <<
" ----- Out - Out -----" << std::endl;
940 Nl = tpMuGlobal->normalVector();
943 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
945 if (!extrapolationT.
isValid()) {
947 std::cout <<
" !!!!!!!!! Catastrophe Out-Out extrapolationT.isValid " 948 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid() << std::endl;
952 std::cout <<
" extrapolationT.isValid " << extrapolationT.
isValid() << std::endl;
965 (outerTrackTSOS.globalPosition()).
y(),
966 (outerTrackTSOS.globalPosition()).
z());
974 std::cout <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 975 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface)) << std::endl;
976 std::cout <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 977 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
978 std::cout <<
" Nornal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 979 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
984 std::cout <<
" ------- !!!!!!!!!!!!!!! No proper Out - In \a\a\a\a\a\a\a" << std::endl;
990 if (tsosMuonIf == 0) {
992 std::cout <<
"No tsosMuon !!!!!!" << std::endl;
998 tsosMuon = muTT.innermostMeasurementState();
1000 tsosMuon = muTT.outermostMeasurementState();
1009 float RelMomResidual = (Pm.
mag() - Pt.mag()) / (Pt.mag() + 1.e-6);
1019 float Rmuon = Rm.
perp();
1020 float Zmuon = Rm.
z();
1021 float alfa_x = atan2(Nl.
x(), Nl.
y()) * 57.29578;
1024 std::cout <<
" Nx Ny Nz alfa_x " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " << alfa_x << std::endl;
1030 for (
int i = 0;
i <= 5;
i++)
1031 chi_d += Vm(
i) * Vm(
i) / Cm(
i,
i);
1036 bool ierrLoc = !
m.Invert();
1038 std::cout <<
" ==== Error inverting Local covariance matrix ==== " << std::endl;
1041 double chi_Loc = ROOT::Math::Similarity(Vml,
m);
1043 std::cout <<
" chi_Loc px/pz/err " << chi_Loc <<
" " << Vml(1) /
sqrt(Cml(1, 1)) << std::endl;
1092 if (Rmuon < 120. || Rmuon > 450.)
1094 if (Zmuon < -720. || Zmuon > 720.)
1099 std::cout <<
" .............. passed all cuts" << std::endl;
1107 CLHEP::HepSymMatrix covLoc(4, 0);
1108 for (
int i = 1;
i <= 4;
i++)
1109 for (
int j = 1;
j <=
i;
j++) {
1115 CLHEP::HepMatrix rotLoc(3, 3, 0);
1128 CLHEP::HepVector posLoc(3);
1136 std::cout <<
" Norm " << Nl << std::endl;
1137 std::cout <<
" posLoc " << posLoc.T() << std::endl;
1138 std::cout <<
" rotLoc " << rotLoc << std::endl;
1142 histo->Fill(itMuon->track()->pt());
1146 histo3->Fill((
PI / 2. - itMuon->track()->outerTheta()));
1147 histo4->Fill(itMuon->track()->phi());
1150 histo7->Fill(RelMomResidual);
1160 if (fabs(Nl.
x()) < 0.98)
1162 if (fabs(Nl.
y()) < 0.98)
1164 if (fabs(Nl.
z()) < 0.98)
1170 if ((fabs(Nl.
x()) < 0.98) && (fabs(Nl.
y()) < 0.98) && (fabs(Nl.
z()) < 0.98)) {
1175 if (fabs(Nl.
x()) < 0.98)
1177 if (fabs(Nl.
y()) < 0.98)
1179 if (fabs(Nl.
z()) < 0.98)
1196 std::cout <<
" diag 0[ " << C0(0, 0) <<
" " << C0(1, 1) <<
" " << C0(2, 2) <<
" " << C0(3, 3) <<
" " << C0(4, 4)
1197 <<
" " << C0(5, 5) <<
" ]" << std::endl;
1198 std::cout <<
" diag e[ " << Ce(0, 0) <<
" " << Ce(1, 1) <<
" " << Ce(2, 2) <<
" " << Ce(3, 3) <<
" " << Ce(4, 4)
1199 <<
" " << Ce(5, 5) <<
" ]" << std::endl;
1200 std::cout <<
" diag 1[ " << C1(0, 0) <<
" " << C1(1, 1) <<
" " << C1(2, 2) <<
" " << C1(3, 3) <<
" " << C1(4, 4)
1201 <<
" " << C1(5, 5) <<
" ]" << std::endl;
1202 std::cout <<
" Rm " << Rm.
x() <<
" " << Rm.
y() <<
" " << Rm.
z() <<
" Pm " << Pm.
x() <<
" " << Pm.
y() <<
" " 1203 << Pm.
z() << std::endl;
1204 std::cout <<
" Rt " << Rt.x() <<
" " << Rt.y() <<
" " << Rt.z() <<
" Pt " << Pt.x() <<
" " << Pt.y() <<
" " 1205 << Pt.z() << std::endl;
1206 std::cout <<
" Nl*(Rm-Rt) " << Nl.
dot(Rm - Rt) << std::endl;
1207 std::cout <<
" resR " << resR.
x() <<
" " << resR.
y() <<
" " << resR.
z() <<
" resP " << resP.
x() <<
" " << resP.
y()
1208 <<
" " << resP.
z() << std::endl;
1209 std::cout <<
" Rm-t " << (Rm - Rt).
x() <<
" " << (Rm - Rt).
y() <<
" " << (Rm - Rt).
z() <<
" Pm-t " 1210 << (Pm - Pt).
x() <<
" " << (Pm - Pt).
y() <<
" " << (Pm - Pt).
z() << std::endl;
1213 <<
" " <<
sqrt(Cm(4, 4)) <<
" " <<
sqrt(Cm(5, 5)) << std::endl;
1214 std::cout <<
" Pmuon Ptrack dP/Ptrack " << itMuon->outerTrack()->p() <<
" " << itMuon->track()->outerP() <<
" " 1215 << (itMuon->outerTrack()->p() - itMuon->track()->outerP()) / itMuon->track()->outerP() << std::endl;
1216 std::cout <<
" cov matrix " << std::endl;
1218 std::cout <<
" diag [ " << Cm(0, 0) <<
" " << Cm(1, 1) <<
" " << Cm(2, 2) <<
" " << Cm(3, 3) <<
" " << Cm(4, 4)
1219 <<
" " << Cm(5, 5) <<
" ]" << std::endl;
1223 for (
int i = 0;
i <= 5;
i++)
1225 for (
int i = 0;
i <= 5;
i++)
1226 for (
int j = 0;
j <= 5;
j++)
1227 Ro(
i,
j) = Cm(
i,
j) / Diag[
i] / Diag[
j];
1228 std::cout <<
" correlation matrix " << std::endl;
1232 for (
int i = 0;
i <= 5;
i++)
1233 for (
int j = 0;
j <= 5;
j++)
1234 CmI(
i,
j) = Cm(
i,
j);
1236 bool ierr = !CmI.Invert();
1239 std::cout <<
" Error inverse covariance matrix !!!!!!!!!!!" << std::endl;
1242 std::cout <<
" inverse cov matrix " << std::endl;
1245 double chi = ROOT::Math::Similarity(Vm, CmI);
1246 std::cout <<
" chi chi_d " << chi <<
" " << chi_d << std::endl;
1255 using namespace edm;
1256 using namespace reco;
1261 double PI = 3.1415927;
1285 iEvent.getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"TrackerOnly",
tracks);
1286 iEvent.getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"StandAlone",
muons);
1287 iEvent.getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"GlobalMuon", gmuons);
1288 iEvent.getByLabel(
"ALCARECOMuAlCalIsolatedMu",
"SelectedMuons", smuons);
1290 iEvent.getByLabel(
"ALCARECOMuAlGlobalCosmics",
"TrackerOnly",
tracks);
1291 iEvent.getByLabel(
"ALCARECOMuAlGlobalCosmics",
"StandAlone",
muons);
1292 iEvent.getByLabel(
"ALCARECOMuAlGlobalCosmics",
"GlobalMuon", gmuons);
1293 iEvent.getByLabel(
"ALCARECOMuAlGlobalCosmics",
"SelectedMuons", smuons);
1303 std::cout <<
" N tracks s/amu gmu selmu " <<
tracks->size() <<
" " <<
muons->size() <<
" " << gmuons->size() <<
" " 1304 << smuons->size() << std::endl;
1305 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
1306 std::cout <<
" is isolatValid Matches " << itMuon->isIsolationValid() <<
" " << itMuon->isMatchesValid()
1314 if (
muons->size() != 1)
1316 if (gmuons->size() != 1)
1318 if (smuons->size() != 1)
1323 if (smuons->size() > 2)
1325 if (
tracks->size() != smuons->size())
1327 if (
muons->size() != smuons->size())
1329 if (gmuons->size() != smuons->size())
1376 <<
" angles " <<
iteratorMuonRcd->rotation().eulerAngles() << std::endl;
1399 std::cout <<
" ............... DEFINE FITTER ..................." << std::endl;
1403 theFitter =
new KFTrajectoryFitter(alongSmPr, *theUpdator, *theEstimator);
1405 theFitterOp =
new KFTrajectoryFitter(oppositeSmPr, *theUpdator, *theEstimator);
1413 std::cout <<
"get also the MuonTransientTrackingRecHitBuilder" 1415 std::cout <<
"get also the TransientTrackingRecHitBuilder" 1423 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
1425 std::cout <<
" mu gM is GM Mu SaM tM " << itMuon->isGlobalMuon() <<
" " << itMuon->isMuon() <<
" " 1426 << itMuon->isStandAloneMuon() <<
" " << itMuon->isTrackerMuon() <<
" " << std::endl;
1440 GlobalPoint pointTrackOut = outerTrackTSOS.globalPosition();
1441 float lenghtTrack = (pointTrackOut - pointTrackIn).
mag();
1442 GlobalPoint pointMuonIn = innerMuTSOS.globalPosition();
1444 float lenghtMuon = (pointMuonOut - pointMuonIn).
mag();
1445 GlobalVector momentumTrackOut = outerTrackTSOS.globalMomentum();
1447 float distanceInIn = (pointTrackIn - pointMuonIn).
mag();
1448 float distanceInOut = (pointTrackIn - pointMuonOut).
mag();
1449 float distanceOutIn = (pointTrackOut - pointMuonIn).
mag();
1450 float distanceOutOut = (pointTrackOut - pointMuonOut).
mag();
1453 std::cout <<
" pointTrackIn " << pointTrackIn << std::endl;
1454 std::cout <<
" Out " << pointTrackOut <<
" lenght " << lenghtTrack << std::endl;
1455 std::cout <<
" point MuonIn " << pointMuonIn << std::endl;
1456 std::cout <<
" Out " << pointMuonOut <<
" lenght " << lenghtMuon << std::endl;
1457 std::cout <<
" momeTrackIn Out " << momentumTrackIn <<
" " << momentumTrackOut << std::endl;
1458 std::cout <<
" doi io ii oo " << distanceOutIn <<
" " << distanceInOut <<
" " << distanceInIn <<
" " 1459 << distanceOutOut << std::endl;
1462 if (lenghtTrack < 90.)
1464 if (lenghtMuon < 300.)
1466 if (innerMuTSOS.globalMomentum().mag() < 5. || outerMuTSOS.
globalMomentum().
mag() < 5.)
1468 if (momentumTrackIn.
mag() < 15. || momentumTrackOut.
mag() < 15.)
1470 if (trackTT.charge() != muTT.charge())
1474 std::cout <<
" passed lenght momentum cuts" << std::endl;
1488 std::cout <<
" ------ Isolated (out-in) ----- " << std::endl;
1489 const Surface& refSurface = innerMuTSOS.surface();
1491 Nl = tpMuLocal->normalVector();
1495 const Plane* refPlane =
dynamic_cast<Plane*
>(surf);
1499 std::cout <<
" Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1500 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
1501 std::cout <<
" global " << Ng.
x() <<
" " << Ng.
y() <<
" " << Ng.
z() << std::endl;
1502 std::cout <<
" lp " << Nlp.
x() <<
" " << Nlp.
y() <<
" " << Nlp.
z() << std::endl;
1512 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
1515 if (trackFittedTSOS.
isValid())
1516 extrapolationT = alongSmPr.
propagate(trackFittedTSOS, refSurface);
1519 if (!extrapolationT.
isValid()) {
1521 std::cout <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 1534 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
1535 GPm = innerMuTSOS.globalMomentum();
1538 (outerTrackTSOS.globalPosition()).
y(),
1539 (outerTrackTSOS.globalPosition()).
z());
1552 if ((distanceOutIn <= distanceInOut) & (distanceOutIn <= distanceInIn) &
1553 (distanceOutIn <= distanceOutOut)) {
1555 std::cout <<
" ----- Out - In -----" << std::endl;
1557 const Surface& refSurface = innerMuTSOS.surface();
1559 Nl = tpMuGlobal->normalVector();
1564 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
1567 if (trackFittedTSOS.
isValid())
1568 extrapolationT = alongSmPr.
propagate(trackFittedTSOS, refSurface);
1571 if (!extrapolationT.
isValid()) {
1573 std::cout <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 1579 std::cout <<
" extrapolationT.isValid " << extrapolationT.
isValid() << std::endl;
1589 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
1590 GPm = innerMuTSOS.globalMomentum();
1592 (outerTrackTSOS.globalPosition()).
y(),
1593 (outerTrackTSOS.globalPosition()).
z());
1605 std::cout <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 1606 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface)) << std::endl;
1607 std::cout <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1608 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
1612 else if ((distanceInOut <= distanceInIn) & (distanceInOut <= distanceOutIn) &
1613 (distanceInOut <= distanceOutOut)) {
1615 std::cout <<
" ----- In - Out -----" << std::endl;
1619 Nl = tpMuGlobal->normalVector();
1624 extrapolationT = oppositeSmPr.
propagate(innerTrackTSOS, refSurface);
1627 if (trackFittedTSOS.
isValid())
1628 extrapolationT = oppositeSmPr.
propagate(trackFittedTSOS, refSurface);
1631 if (!extrapolationT.
isValid()) {
1633 std::cout <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 1634 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid() << std::endl;
1638 std::cout <<
" extrapolationT.isValid " << extrapolationT.
isValid() << std::endl;
1664 std::cout <<
" propDirCh " << Chooser.operator()(*innerTrackTSOS.
freeState(), refSurface)
1665 <<
" Ch == oppisite " 1667 std::cout <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1668 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
1672 else if ((distanceOutOut <= distanceInOut) & (distanceOutOut <= distanceInIn) &
1673 (distanceOutOut <= distanceOutIn)) {
1675 std::cout <<
" ----- Out - Out -----" << std::endl;
1682 Nl = tpMuGlobal->normalVector();
1685 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
1687 if (!extrapolationT.
isValid()) {
1689 std::cout <<
" !!!!!!!!! Catastrophe Out-Out extrapolationT.isValid " 1690 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid() << std::endl;
1694 std::cout <<
" extrapolationT.isValid " << extrapolationT.
isValid() << std::endl;
1707 (outerTrackTSOS.globalPosition()).
y(),
1708 (outerTrackTSOS.globalPosition()).
z());
1716 std::cout <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 1717 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface)) << std::endl;
1718 std::cout <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1719 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
1720 std::cout <<
" Nornal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1721 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578) << std::endl;
1726 std::cout <<
" ------- !!!!!!!!!!!!!!! No proper Out - In \a\a\a\a\a\a\a" << std::endl;
1732 if (tsosMuonIf == 0) {
1734 std::cout <<
"No tsosMuon !!!!!!" << std::endl;
1739 if (tsosMuonIf == 1)
1740 tsosMuon = muTT.innermostMeasurementState();
1742 tsosMuon = muTT.outermostMeasurementState();
1749 if (!trackFittedTSOS.
isValid()) {
1751 std::cout <<
" ================= trackFittedTSOS notValid !!!!!!!! " << std::endl;
1759 if (!muonFittedTSOS.
isValid()) {
1761 std::cout <<
" ================= muonFittedTSOS notValid !!!!!!!! " << std::endl;
1778 float RelMomResidual = (Pm.
mag() - Pt.mag()) / (Pt.mag() + 1.e-6);
1788 float Rmuon = Rm.
perp();
1789 float Zmuon = Rm.
z();
1790 float alfa_x = atan2(Nl.
x(), Nl.
y()) * 57.29578;
1793 std::cout <<
" Nx Ny Nz alfa_x " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " << alfa_x << std::endl;
1799 for (
int i = 0;
i <= 5;
i++)
1800 chi_d += Vm(
i) * Vm(
i) / Cm(
i,
i);
1805 bool ierrLoc = !
m.Invert();
1807 std::cout <<
" ==== Error inverting Local covariance matrix ==== " << std::endl;
1810 double chi_Loc = ROOT::Math::Similarity(Vml,
m);
1812 std::cout <<
" chi_Loc px/pz/err " << chi_Loc <<
" " << Vml(1) /
sqrt(Cml(1, 1)) << std::endl;
1832 if (fabs(resR.
x()) > 20.)
1834 if (fabs(resR.
y()) > 20.)
1836 if (fabs(resR.
z()) > 20.)
1838 if (fabs(resR.
mag()) > 30.)
1840 if (fabs(resP.
x()) > 0.06)
1842 if (fabs(resP.
y()) > 0.06)
1844 if (fabs(resP.
z()) > 0.06)
1867 if (Rmuon < 120. || Rmuon > 450.)
1869 if (Zmuon < -720. || Zmuon > 720.)
1874 std::cout <<
" .............. passed all cuts" << std::endl;
1882 CLHEP::HepSymMatrix covLoc(4, 0);
1883 for (
int i = 1;
i <= 4;
i++)
1884 for (
int j = 1;
j <=
i;
j++) {
1890 CLHEP::HepMatrix rotLoc(3, 3, 0);
1903 CLHEP::HepVector posLoc(3);
1911 std::cout <<
" Norm " << Nl << std::endl;
1912 std::cout <<
" posLoc " << posLoc.T() << std::endl;
1913 std::cout <<
" rotLoc " << rotLoc << std::endl;
1917 histo->Fill(itMuon->track()->pt());
1921 histo3->Fill((
PI / 2. - itMuon->track()->outerTheta()));
1922 histo4->Fill(itMuon->track()->phi());
1925 histo7->Fill(RelMomResidual);
1935 if (fabs(Nl.
x()) < 0.98)
1937 if (fabs(Nl.
y()) < 0.98)
1939 if (fabs(Nl.
z()) < 0.98)
1945 if ((fabs(Nl.
x()) < 0.98) && (fabs(Nl.
y()) < 0.98) && (fabs(Nl.
z()) < 0.98)) {
1950 if (fabs(Nl.
x()) < 0.98)
1952 if (fabs(Nl.
y()) < 0.98)
1954 if (fabs(Nl.
z()) < 0.98)
1971 std::cout <<
" diag 0[ " << C0(0, 0) <<
" " << C0(1, 1) <<
" " << C0(2, 2) <<
" " << C0(3, 3) <<
" " << C0(4, 4)
1972 <<
" " << C0(5, 5) <<
" ]" << std::endl;
1973 std::cout <<
" diag e[ " << Ce(0, 0) <<
" " << Ce(1, 1) <<
" " << Ce(2, 2) <<
" " << Ce(3, 3) <<
" " << Ce(4, 4)
1974 <<
" " << Ce(5, 5) <<
" ]" << std::endl;
1975 std::cout <<
" diag 1[ " << C1(0, 0) <<
" " << C1(1, 1) <<
" " << C1(2, 2) <<
" " << C1(3, 3) <<
" " << C1(4, 4)
1976 <<
" " << C1(5, 5) <<
" ]" << std::endl;
1977 std::cout <<
" Rm " << Rm.
x() <<
" " << Rm.
y() <<
" " << Rm.
z() <<
" Pm " << Pm.
x() <<
" " << Pm.
y() <<
" " 1978 << Pm.
z() << std::endl;
1979 std::cout <<
" Rt " << Rt.x() <<
" " << Rt.y() <<
" " << Rt.z() <<
" Pt " << Pt.x() <<
" " << Pt.y() <<
" " 1980 << Pt.z() << std::endl;
1981 std::cout <<
" Nl*(Rm-Rt) " << Nl.
dot(Rm - Rt) << std::endl;
1982 std::cout <<
" resR " << resR.
x() <<
" " << resR.
y() <<
" " << resR.
z() <<
" resP " << resP.
x() <<
" " << resP.
y()
1983 <<
" " << resP.
z() << std::endl;
1984 std::cout <<
" Rm-t " << (Rm - Rt).
x() <<
" " << (Rm - Rt).
y() <<
" " << (Rm - Rt).
z() <<
" Pm-t " 1985 << (Pm - Pt).
x() <<
" " << (Pm - Pt).
y() <<
" " << (Pm - Pt).
z() << std::endl;
1988 <<
" " <<
sqrt(Cm(4, 4)) <<
" " <<
sqrt(Cm(5, 5)) << std::endl;
1989 std::cout <<
" Pmuon Ptrack dP/Ptrack " << itMuon->outerTrack()->p() <<
" " << itMuon->track()->outerP() <<
" " 1990 << (itMuon->outerTrack()->p() - itMuon->track()->outerP()) / itMuon->track()->outerP() << std::endl;
1991 std::cout <<
" cov matrix " << std::endl;
1993 std::cout <<
" diag [ " << Cm(0, 0) <<
" " << Cm(1, 1) <<
" " << Cm(2, 2) <<
" " << Cm(3, 3) <<
" " << Cm(4, 4)
1994 <<
" " << Cm(5, 5) <<
" ]" << std::endl;
1998 for (
int i = 0;
i <= 5;
i++)
2000 for (
int i = 0;
i <= 5;
i++)
2001 for (
int j = 0;
j <= 5;
j++)
2002 Ro(
i,
j) = Cm(
i,
j) / Diag[
i] / Diag[
j];
2003 std::cout <<
" correlation matrix " << std::endl;
2007 for (
int i = 0;
i <= 5;
i++)
2008 for (
int j = 0;
j <= 5;
j++)
2009 CmI(
i,
j) = Cm(
i,
j);
2011 bool ierr = !CmI.Invert();
2014 std::cout <<
" Error inverse covariance matrix !!!!!!!!!!!" << std::endl;
2017 std::cout <<
" inverse cov matrix " << std::endl;
2020 double chi = ROOT::Math::Similarity(Vm, CmI);
2021 std::cout <<
" chi chi_d " << chi <<
" " << chi_d << std::endl;
2050 for (
int i = 0;
i <= 2;
i++) {
2051 if (Cm(
i,
i) > 1.
e-20)
2052 Wi(
i) = 1. / Cm(
i,
i);
2055 dR(
i) = R_m(
i) - R_t(
i);
2058 float PtN = P_t(0) * Norm(0) + P_t(1) * Norm(1) + P_t(2) * Norm(2);
2060 Jac(0, 0) = 1. - P_t(0) * Norm(0) / PtN;
2061 Jac(0, 1) = -P_t(0) * Norm(1) / PtN;
2062 Jac(0, 2) = -P_t(0) * Norm(2) / PtN;
2064 Jac(1, 0) = -P_t(1) * Norm(0) / PtN;
2065 Jac(1, 1) = 1. - P_t(1) * Norm(1) / PtN;
2066 Jac(1, 2) = -P_t(1) * Norm(2) / PtN;
2068 Jac(2, 0) = -P_t(2) * Norm(0) / PtN;
2069 Jac(2, 1) = -P_t(2) * Norm(1) / PtN;
2070 Jac(2, 2) = 1. - P_t(2) * Norm(2) / PtN;
2074 for (
int i = 0;
i <= 2;
i++)
2075 for (
int j = 0;
j <= 2;
j++) {
2080 for (
int k = 0;
k <= 2;
k++) {
2085 for (
int i = 0;
i <= 2;
i++)
2086 for (
int j = 0;
j <= 2;
j++) {
2093 for (
int i = 0;
i <= 2;
i++)
2094 for (
int k = 0;
k <= 2;
k++)
2095 Gtr(
i) +=
dR(
k) * Wi(
k) * Jac(
k,
i);
2096 for (
int i = 0;
i <= 2;
i++)
2101 std::cout <<
" N " << Norm << std::endl;
2102 std::cout <<
" P_t " << P_t << std::endl;
2103 std::cout <<
" (Pt*N) " << PtN << std::endl;
2105 std::cout <<
" +/- " << 1. /
sqrt(Wi(0)) <<
" " << 1. /
sqrt(Wi(1)) <<
" " << 1. /
sqrt(Wi(2)) <<
" " << std::endl;
2106 std::cout <<
" Jacobian dr/ddx " << std::endl;
2108 std::cout <<
" G-- " << Gtr << std::endl;
2137 CLHEP::HepSymMatrix
w(Nd, 0);
2138 for (
int i = 1;
i <= Nd;
i++)
2139 for (
int j = 1;
j <= Nd;
j++) {
2141 w(
i,
j) = GCov(
i - 1,
j - 1);
2144 if ((
i ==
j) && (
i <= 3) && (GCov(
i - 1,
j - 1) < 1.
e-20))
2153 CLHEP::HepVector
V(Nd), Rt(3), Pt(3), Rm(3), Pm(3), Norm(3);
2166 Norm(1) = GNorm.
x();
2167 Norm(2) = GNorm.
y();
2168 Norm(3) = GNorm.
z();
2170 V = dsum(Rm - Rt, Pm - Pt);
2175 CLHEP::HepMatrix Jac(Nd, Nd, 0);
2176 for (
int i = 1;
i <= 3;
i++)
2177 for (
int j = 1;
j <= 3;
j++) {
2178 Jac(
i,
j) = Pm(
i) * Norm(
j) / PmN;
2194 CLHEP::HepVector dsda(3);
2195 dsda(1) = (Norm(2) * Rm(3) - Norm(3) * Rm(2)) / PmN;
2196 dsda(2) = (Norm(3) * Rm(1) - Norm(1) * Rm(3)) / PmN;
2197 dsda(3) = (Norm(1) * Rm(2) - Norm(2) * Rm(1)) / PmN;
2200 Jac(1, 4) = Pm(1) * dsda(1);
2201 Jac(2, 4) = -Rm(3) + Pm(2) * dsda(1);
2202 Jac(3, 4) = Rm(2) + Pm(3) * dsda(1);
2204 Jac(1, 5) = Rm(3) + Pm(1) * dsda(2);
2205 Jac(2, 5) = Pm(2) * dsda(2);
2206 Jac(3, 5) = -Rm(1) + Pm(3) * dsda(2);
2208 Jac(1, 6) = -Rm(2) + Pm(1) * dsda(3);
2209 Jac(2, 6) = Rm(1) + Pm(2) * dsda(3);
2210 Jac(3, 6) = Pm(3) * dsda(3);
2212 CLHEP::HepSymMatrix W(Nd, 0);
2214 W =
w.inverse(ierr);
2217 std::cout <<
" gradientGlobal: inversion of matrix w fail " << std::endl;
2221 CLHEP::HepMatrix W_Jac(Nd, Nd, 0);
2222 W_Jac = Jac.T() * W;
2224 CLHEP::HepVector grad3(Nd);
2227 CLHEP::HepMatrix hess3(Nd, Nd);
2228 hess3 = Jac.T() * W * Jac;
2234 CLHEP::HepVector d3I = CLHEP::solve(
Hess, -
Grad);
2236 CLHEP::HepMatrix Errd3I =
Hess.inverse(iEr3I);
2239 std::cout <<
" gradientGlobal error inverse Hess matrix !!!!!!!!!!!" << std::endl;
2243 std::cout <<
" dG " << d3I(1) <<
" " << d3I(2) <<
" " << d3I(3) <<
" " << d3I(4) <<
" " << d3I(5) <<
" " << d3I(6)
2246 std::cout <<
" +- " <<
sqrt(Errd3I(1, 1)) <<
" " <<
sqrt(Errd3I(2, 2)) <<
" " <<
sqrt(Errd3I(3, 3)) <<
" " 2247 <<
sqrt(Errd3I(4, 4)) <<
" " <<
sqrt(Errd3I(5, 5)) <<
" " <<
sqrt(Errd3I(6, 6)) << std::endl;
2250 #ifdef CHECK_OF_DERIVATIVES 2253 CLHEP::HepVector
d(3, 0),
a(3, 0);
2254 CLHEP::HepMatrix
T(3, 3, 1);
2256 CLHEP::HepMatrix Ti =
T.T();
2260 double B =
CLHEP_dot((Rt - Ti * Rm + Ti *
d), Norm);
2263 CLHEP::HepVector r0(3, 0), p0(3, 0);
2264 r0 = Ti * Rm - Ti *
d + s0 * (Ti * Pm) - Rt;
2267 double delta = 0.0001;
2281 CLHEP::HepVector
r(3, 0),
p(3, 0);
2282 r = Ti * Rm - Ti *
d +
s * (Ti * Pm) - Rt;
2285 std::cout <<
" s0 s num dsda(" <<
ii <<
") " << s0 <<
" " <<
s <<
" " << (
s - s0) /
delta <<
" " << dsda(
ii) << endl;
2287 std::cout <<
" -- An d(r,p)/d(" <<
ii <<
") " << Jac(1,
ii) <<
" " << Jac(2,
ii) <<
" " << Jac(3,
ii) <<
" " 2288 << Jac(4,
ii) <<
" " << Jac(5,
ii) <<
" " << Jac(6,
ii) << std::endl;
2290 << (
r(3) - r0(3)) /
delta <<
" " << (
p(1) - p0(1)) /
delta <<
" " << (
p(2) - p0(2)) /
delta <<
" " 2291 << (
p(3) - p0(3)) /
delta << std::endl;
2293 std::cout <<
" -- An d(r,p)/a(" <<
ii <<
") " << Jac(1,
ii + 3) <<
" " << Jac(2,
ii + 3) <<
" " << Jac(3,
ii + 3)
2294 <<
" " << Jac(4,
ii + 3) <<
" " << Jac(5,
ii + 3) <<
" " << Jac(6,
ii + 3) << std::endl;
2296 << (
r(3) - r0(3)) /
delta <<
" " << (
p(1) - p0(1)) /
delta <<
" " << (
p(2) - p0(2)) /
delta <<
" " 2297 << (
p(3) - p0(3)) /
delta << std::endl;
2310 CLHEP::HepSymMatrix& covLoc,
2311 CLHEP::HepMatrix& rotLoc,
2312 CLHEP::HepVector&
R0,
2323 std::cout <<
" gradientLocal " << std::endl;
2342 CLHEP::HepVector Rt(3), Pt(3), Rm(3), Pm(3), Norm(3);
2355 Norm(1) = GNorm.
x();
2356 Norm(2) = GNorm.
y();
2357 Norm(3) = GNorm.
z();
2359 CLHEP::HepVector
V(4), Rml(3), Pml(3), Rtl(3), Ptl(3);
2367 Rml = rotLoc * (Rm -
R0);
2368 Rtl = rotLoc * (Rt -
R0);
2372 V(1) = LPRm(0) - Ptl(1) / Ptl(3);
2373 V(2) = LPRm(1) - Ptl(2) / Ptl(3);
2374 V(3) = LPRm(2) - Rtl(1);
2375 V(4) = LPRm(3) - Rtl(2);
2390 CLHEP::HepSymMatrix W = covLoc;
2396 std::cout <<
" gradientLocal: inversion of matrix W fail " << std::endl;
2408 CLHEP::HepMatrix JacToLoc(4, 6, 0);
2409 for (
int i = 1;
i <= 2;
i++)
2410 for (
int j = 1;
j <= 3;
j++) {
2411 JacToLoc(
i,
j + 3) = (rotLoc(
i,
j) - rotLoc(3,
j) * Pml(
i) / Pml(3)) / Pml(3);
2412 JacToLoc(
i + 2,
j) = rotLoc(
i,
j);
2419 CLHEP::HepMatrix Jac(6, 6, 0);
2420 for (
int i = 1;
i <= 3;
i++)
2421 for (
int j = 1;
j <= 3;
j++) {
2422 Jac(
i,
j) = Pm(
i) * Norm(
j) / PmN;
2438 CLHEP::HepVector dsda(3);
2439 dsda(1) = (Norm(2) * Rm(3) - Norm(3) * Rm(2)) / PmN;
2440 dsda(2) = (Norm(3) * Rm(1) - Norm(1) * Rm(3)) / PmN;
2441 dsda(3) = (Norm(1) * Rm(2) - Norm(2) * Rm(1)) / PmN;
2444 Jac(1, 4) = Pm(1) * dsda(1);
2445 Jac(2, 4) = -Rm(3) + Pm(2) * dsda(1);
2446 Jac(3, 4) = Rm(2) + Pm(3) * dsda(1);
2448 Jac(1, 5) = Rm(3) + Pm(1) * dsda(2);
2449 Jac(2, 5) = Pm(2) * dsda(2);
2450 Jac(3, 5) = -Rm(1) + Pm(3) * dsda(2);
2452 Jac(1, 6) = -Rm(2) + Pm(1) * dsda(3);
2453 Jac(2, 6) = Rm(1) + Pm(2) * dsda(3);
2454 Jac(3, 6) = Pm(3) * dsda(3);
2457 CLHEP::HepMatrix JacCorLoc(4, 6, 0);
2458 JacCorLoc = JacToLoc * Jac;
2461 CLHEP::HepMatrix W_Jac(6, 4, 0);
2462 W_Jac = JacCorLoc.T() * W;
2464 CLHEP::HepVector gradL(6);
2467 CLHEP::HepMatrix hessL(6, 6);
2468 hessL = JacCorLoc.T() * W * JacCorLoc;
2473 CLHEP::HepVector dLI = CLHEP::solve(
HessL, -
GradL);
2475 CLHEP::HepMatrix ErrdLI =
HessL.inverse(iErI);
2478 std::cout <<
" gradLocal Error inverse Hess matrix !!!!!!!!!!!" << std::endl;
2482 std::cout <<
" dL " << dLI(1) <<
" " << dLI(2) <<
" " << dLI(3) <<
" " << dLI(4) <<
" " << dLI(5) <<
" " << dLI(6)
2485 std::cout <<
" +- " <<
sqrt(ErrdLI(1, 1)) <<
" " <<
sqrt(ErrdLI(2, 2)) <<
" " <<
sqrt(ErrdLI(3, 3)) <<
" " 2486 <<
sqrt(ErrdLI(4, 4)) <<
" " <<
sqrt(ErrdLI(5, 5)) <<
" " <<
sqrt(ErrdLI(6, 6)) << std::endl;
2499 if (GNorm.
z() > 0.95)
2500 std::cout <<
" Ecap1 N " << GNorm << std::endl;
2501 else if (GNorm.
z() < -0.95)
2502 std::cout <<
" Ecap2 N " << GNorm << std::endl;
2504 std::cout <<
" Barrel N " << GNorm << std::endl;
2505 std::cout <<
" JacCLo(i," <<
i <<
") = {" << JacCorLoc(1,
i) <<
" " << JacCorLoc(2,
i) <<
" " << JacCorLoc(3,
i)
2506 <<
" " << JacCorLoc(4,
i) <<
"}" << std::endl;
2507 std::cout <<
" rotLoc " << rotLoc << std::endl;
2509 std::cout <<
" Pm,l " << Pm.T() <<
" " << Pml(1) / Pml(3) <<
" " << Pml(2) / Pml(3) << std::endl;
2510 std::cout <<
" Pt,l " << Pt.T() <<
" " << Ptl(1) / Ptl(3) <<
" " << Ptl(2) / Ptl(3) << std::endl;
2512 std::cout <<
" Cov \n" << covLoc << std::endl;
2513 std::cout <<
" W*Cov " << W * covLoc << std::endl;
2517 std::cout <<
" JacToLoc " << JacToLoc << std::endl;
2520 #ifdef CHECK_OF_JACOBIAN_CARTESIAN_TO_LOCAL 2522 CLHEP::HepVector V0(4, 0);
2523 V0(1) = Pml(1) / Pml(3) - Ptl(1) / Ptl(3);
2524 V0(2) = Pml(2) / Pml(3) - Ptl(2) / Ptl(3);
2525 V0(3) = Rml(1) - Rtl(1);
2526 V0(4) = Rml(2) - Rtl(2);
2529 CLHEP::HepVector V1(4, 0);
2532 Rml = rotLoc * (Rm -
R0);
2539 V1(1) = Pml(1) / Pml(3) - Ptl(1) / Ptl(3);
2540 V1(2) = Pml(2) / Pml(3) - Ptl(2) / Ptl(3);
2541 V1(3) = Rml(1) - Rtl(1);
2542 V1(4) = Rml(2) - Rtl(2);
2544 if (GNorm.
z() > 0.95)
2545 std::cout <<
" Ecap1 N " << GNorm << std::endl;
2546 else if (GNorm.
z() < -0.95)
2547 std::cout <<
" Ecap2 N " << GNorm << std::endl;
2549 std::cout <<
" Barrel N " << GNorm << std::endl;
2550 std::cout <<
" dldc Num (i," <<
ii <<
") " << (V1(1) - V0(1)) /
delta <<
" " << (V1(2) - V0(2)) /
delta <<
" " 2551 << (V1(3) - V0(3)) /
delta <<
" " << (V1(4) - V0(4)) /
delta << std::endl;
2552 std::cout <<
" dldc Ana (i," <<
ii <<
") " << JacToLoc(1,
ii) <<
" " << JacToLoc(2,
ii) <<
" " << JacToLoc(3,
ii)
2553 <<
" " << JacToLoc(4,
ii) << std::endl;
2565 CLHEP::HepVector
d(3, 0),
a(3, 0), Norm(3), Rm0(3), Pm0(3), Rm1(3), Pm1(3), Rmi(3), Pmi(3);
2587 if ((
d(1) == 0.) & (
d(2) == 0.) & (
d(3) == 0.) & (
a(1) == 0.) & (
a(2) == 0.) & (
a(3) == 0.)) {
2591 std::cout <<
" ...... without misalignment " << std::endl;
2605 CLHEP::HepMatrix
T(3, 3, 1);
2615 T(1, 2) =
c1 * s3 + s1 * s2 * c3;
2616 T(1, 3) = s1 * s3 -
c1 * s2 * c3;
2618 T(2, 2) =
c1 * c3 - s1 * s2 * s3;
2619 T(2, 3) = s1 * c3 +
c1 * s2 * s3;
2626 CLHEP::HepMatrix Ti =
T.T();
2627 CLHEP::HepVector di = -Ti *
d;
2629 CLHEP::HepVector ex0(3, 0), ey0(3, 0), ez0(3, 0), ex(3, 0), ey(3, 0), ez(3, 0);
2637 CLHEP::HepVector TiN = Ti * Norm;
2643 Rm1(1) =
CLHEP_dot(ex, Rm0 + si * Pm0 - di);
2644 Rm1(2) =
CLHEP_dot(ey, Rm0 + si * Pm0 - di);
2645 Rm1(3) =
CLHEP_dot(ez, Rm0 + si * Pm0 - di);
2654 std::cout <<
" ----- Pm " << Pm << std::endl;
2655 std::cout <<
" T*Pm0 " << Pm1.T() << std::endl;
2659 CLHEP::HepVector Rml = Rm1(1) * ex + Rm1(2) * ey + Rm1(3) * ez + di;
2661 CLHEP::HepVector Rt0(3);
2668 CLHEP::HepVector
Rl = Rml + sl * (Ti * Pm1);
2676 CLHEP::HepVector Dr = Ti * Rm1 - Ti *
d +
s * (Ti * Pm1) - Rm0;
2677 CLHEP::HepVector Dp = Ti * Pm1 - Pm0;
2679 CLHEP::HepVector TiR = Ti * Rm0 + di;
2680 CLHEP::HepVector Ri =
T * TiR +
d;
2682 std::cout <<
" --TTi-0 " << (Ri - Rm0).
T() << std::endl;
2683 std::cout <<
" -- Dr " << Dr.T() << endl;
2684 std::cout <<
" -- Dp " << Dp.T() << endl;
2692 std::cout <<
" -- si sl s " << si <<
" " << sl <<
" " <<
s << std::endl;
2695 std::cout <<
" -- Rml-(Rm0+si*Pm0) " << (Rml - Rm0 - si * Pm0).
T() << std::endl;
2703 std::cout <<
" --Rl-0 " << (
Rl - Rm0).
T() << std::endl;
2721 CLHEP::HepVector
d(3, 0),
a(3, 0), Norm(3), Rm0(3), Pm0(3), Rm1(3), Pm1(3), Rmi(3), Pmi(3);
2745 if ((
d(1) == 0.) & (
d(2) == 0.) & (
d(3) == 0.) & (
a(1) == 0.) & (
a(2) == 0.) & (
a(3) == 0.)) {
2754 std::cout <<
" ...... without misalignment " << std::endl;
2768 CLHEP::HepMatrix
T(3, 3, 1);
2778 T(1, 2) =
c1 * s3 + s1 * s2 * c3;
2779 T(1, 3) = s1 * s3 -
c1 * s2 * c3;
2781 T(2, 2) =
c1 * c3 - s1 * s2 * s3;
2782 T(2, 3) = s1 * c3 +
c1 * s2 * s3;
2790 CLHEP::HepMatrix Ti =
T.T();
2791 CLHEP::HepVector di = -Ti *
d;
2793 CLHEP::HepVector ex0(3, 0), ey0(3, 0), ez0(3, 0), ex(3, 0), ey(3, 0), ez(3, 0);
2801 CLHEP::HepVector TiN = Ti * Norm;
2807 Rm1(1) =
CLHEP_dot(ex, Rm0 + si * Pm0 - di);
2808 Rm1(2) =
CLHEP_dot(ey, Rm0 + si * Pm0 - di);
2809 Rm1(3) =
CLHEP_dot(ez, Rm0 + si * Pm0 - di);
2819 CLHEP::HepMatrix Tl(3, 3, 0);
2833 CLHEP::HepVector
R0(3, 0), newR0(3, 0), newRl(3, 0), newPl(3, 0);
2838 newRl = Tl * (Rm1 -
R0);
2841 Vm(0) = newPl(1) / newPl(3);
2842 Vm(1) = newPl(2) / newPl(3);
2846 #ifdef CHECK_DERIVATIVES_LOCAL_VS_ANGLES 2854 CLHEP::HepVector Rm10 = Rm1, Pm10 = Pm1;
2856 CLHEP::HepMatrix newTl = Tl *
T;
2864 Rm1(1) =
CLHEP_dot(ex, Rm0 + si * Pm0 - di);
2865 Rm1(2) =
CLHEP_dot(ey, Rm0 + si * Pm0 - di);
2866 Rm1(3) =
CLHEP_dot(ez, Rm0 + si * Pm0 - di);
2869 newRl = Tl * (Rm1 -
R0);
2872 Vm(0) = newPl(1) / newPl(3);
2873 Vm(1) = newPl(2) / newPl(3);
2876 std::cout <<
" ========= dVm/da" <<
ii <<
" " << (Vm - Vm0) * (1. / del) << std::endl;
2882 std::cout <<
" ex " << (Tl.T() * ex0).
T() << std::endl;
2883 std::cout <<
" ey " << (Tl.T() * ey0).
T() << std::endl;
2884 std::cout <<
" ez " << (Tl.T() * ez0).
T() << std::endl;
2887 std::cout <<
" pxyz/p gl 0 " << (Pm0 / Pm0.norm()).
T() << std::endl;
2888 std::cout <<
" pxyz/p loc0 " << (Tl * Pm0 / (Tl * Pm0).norm()).
T() << std::endl;
2889 std::cout <<
" pxyz/p glob " << (Pm1 / Pm1.norm()).
T() << std::endl;
2890 std::cout <<
" pxyz/p loc " << (newPl / newPl.norm()).
T() << std::endl;
2894 std::cout <<
" ---- phi g0 g1 l0 l1 " << atan2(Pm0(2), Pm0(1)) <<
" " << atan2(Pm1(2), Pm1(1)) <<
" " 2895 << atan2((Tl * Pm0)(2), (Tl * Pm0)(1)) <<
" " << atan2(newPl(2), newPl(1)) << std::endl;
2896 std::cout <<
" ---- angl Gl Loc " << atan2(Pm1(2), Pm1(1)) - atan2(Pm0(2), Pm0(1)) <<
" " 2897 << atan2(newPl(2), newPl(1)) - atan2((Tl * Pm0)(2), (Tl * Pm0)(1)) <<
" " 2898 << atan2(newPl(3), newPl(2)) - atan2((Tl * Pm0)(3), (Tl * Pm0)(2)) <<
" " 2899 << atan2(newPl(1), newPl(3)) - atan2((Tl * Pm0)(1), (Tl * Pm0)(3)) <<
" " << std::endl;
2903 CLHEP::HepMatrix newTl(3, 3, 0);
2904 CLHEP::HepVector
R0(3, 0), newRl(3, 0), newPl(3, 0);
2905 newTl = Tl * Ti.T();
2906 newR0 = Ti *
R0 + di;
2908 std::cout <<
" N " << Norm.T() << std::endl;
2916 CLHEP::HepVector Rvc(3, 0), Pvc(3, 0), Rvg(3, 0), Pvg(3, 0);
2920 Pvc(1) = Pvc(3) * Vm(0);
2921 Pvc(2) = Pvc(3) * Vm(1);
2923 Rvg = newTl.T() * Rvc + newR0;
2924 Pvg = newTl.T() * Pvc;
2926 std::cout <<
" newPl " << newPl.T() << std::endl;
2927 std::cout <<
" Pvc " << Pvc.T() << std::endl;
2928 std::cout <<
" Rvg " << Rvg.T() << std::endl;
2929 std::cout <<
" Rm1 " << Rm1.T() << std::endl;
2930 std::cout <<
" Pvg " << Pvg.T() << std::endl;
2931 std::cout <<
" Pm1 " << Pm1.T() << std::endl;
2936 std::cout <<
" ----- Pm " << Pm << std::endl;
2937 std::cout <<
" T*Pm0 " << Pm1.T() << std::endl;
2941 CLHEP::HepVector Rml = Rm1(1) * ex + Rm1(2) * ey + Rm1(3) * ez + di;
2943 CLHEP::HepVector Rt0(3);
2950 CLHEP::HepVector
Rl = Rml + sl * (Ti * Pm1);
2958 CLHEP::HepVector Dr = Ti * Rm1 - Ti *
d +
s * (Ti * Pm1) - Rm0;
2959 CLHEP::HepVector Dp = Ti * Pm1 - Pm0;
2961 CLHEP::HepVector TiR = Ti * Rm0 + di;
2962 CLHEP::HepVector Ri =
T * TiR +
d;
2964 std::cout <<
" --TTi-0 " << (Ri - Rm0).
T() << std::endl;
2965 std::cout <<
" -- Dr " << Dr.T() << endl;
2966 std::cout <<
" -- Dp " << Dp.T() << endl;
2974 std::cout <<
" -- si sl s " << si <<
" " << sl <<
" " <<
s << std::endl;
2977 std::cout <<
" -- Rml-(Rm0+si*Pm0) " << (Rml - Rm0 - si * Pm0).
T() << std::endl;
2985 std::cout <<
" --Rl-0 " << (
Rl - Rm0).
T() << std::endl;
2999 bool smooth =
false;
3002 std::cout <<
" ......... start of trackFitter ......... " << std::endl;
3003 if (
false &&
info) {
3005 this->
debugTrackHit(
" Tracker TransientTrack hits ", alongTTr);
3009 DetId trackDetId =
DetId(alongTr->innerDetId());
3010 for (
auto const&
hit : alongTr->recHits())
3015 for (
unsigned int ihit = recHitAlong.
size() - 1; ihit + 1 > 0; ihit--) {
3016 recHit.push_back(recHitAlong[ihit]);
3018 recHitAlong.
clear();
3021 std::cout <<
" ... Own recHit.size() " <<
recHit.size() <<
" " << trackDetId.
rawId() << std::endl;
3025 for (
auto const&
hit : alongTr->recHits())
3029 std::cout <<
" ... recHitTrack.size() " <<
recHit.size() <<
" " << trackDetId.
rawId() <<
" ======> recHitMu " 3038 std::cout <<
" ...along.... recHitMu.size() " << recHitMu.size() << std::endl;
3042 for (
unsigned int ihit = recHitMuAlong.size() - 1; ihit + 1 > 0; ihit--) {
3043 recHitMu.push_back(recHitMuAlong[ihit]);
3045 recHitMuAlong.clear();
3048 std::cout <<
" ...opposite... recHitMu.size() " << recHitMu.size() << std::endl;
3069 std::vector<Trajectory> trajVec;
3071 trajVec =
theFitter->fit(seedT, recHitMu, initialTSOS);
3073 trajVec =
theFitterOp->fit(seedT, recHitMu, initialTSOS);
3079 std::cout <<
" . . . . . trajVec.size() " << trajVec.size() << std::endl;
3080 if (!trajVec.empty())
3085 if (!trajVec.empty())
3086 trackFittedTSOS = trajVec[0].lastMeasurement().updatedState();
3088 std::vector<Trajectory> trajSVec;
3089 if (!trajVec.empty()) {
3096 std::cout <<
" . . . . trajSVec.size() " << trajSVec.size() << std::endl;
3097 if (!trajSVec.empty())
3098 this->
debugTrajectorySOSv(
"smoothed geom InnermostState", trajSVec[0].geometricalInnermostState());
3099 if (!trajSVec.empty())
3100 trackFittedTSOS = trajSVec[0].geometricalInnermostState();
3114 bool smooth =
false;
3117 std::cout <<
" ......... start of muonFitter ........" << std::endl;
3118 if (
false &&
info) {
3120 this->
debugTrackHit(
" Muon TransientTrack hits ", alongTTr);
3124 DetId trackDetId =
DetId(alongTr->innerDetId());
3125 for (
auto const&
hit : alongTr->recHits())
3130 for (
unsigned int ihit = recHitAlong.
size() - 1; ihit + 1 > 0; ihit--) {
3131 recHit.push_back(recHitAlong[ihit]);
3133 recHitAlong.
clear();
3136 std::cout <<
" ... Own recHit.size() DetId==Muon " <<
recHit.size() <<
" " << trackDetId.
rawId() << std::endl;
3141 std::cout <<
" ...along.... recHitMu.size() " << recHitMu.size() << std::endl;
3145 for (
unsigned int ihit = recHitMuAlong.size() - 1; ihit + 1 > 0; ihit--) {
3146 recHitMu.push_back(recHitMuAlong[ihit]);
3148 recHitMuAlong.clear();
3151 std::cout <<
" ...opposite... recHitMu.size() " << recHitMu.size() << std::endl;
3172 std::vector<Trajectory> trajVec;
3174 trajVec =
theFitter->fit(seedT, recHitMu, initialTSOS);
3176 trajVec =
theFitterOp->fit(seedT, recHitMu, initialTSOS);
3182 std::cout <<
" . . . . . trajVec.size() " << trajVec.size() << std::endl;
3183 if (!trajVec.empty())
3188 if (!trajVec.empty())
3189 trackFittedTSOS = trajVec[0].lastMeasurement().updatedState();
3191 std::vector<Trajectory> trajSVec;
3192 if (!trajVec.empty()) {
3199 std::cout <<
" . . . . trajSVec.size() " << trajSVec.size() << std::endl;
3200 if (!trajSVec.empty())
3201 this->
debugTrajectorySOSv(
"smoothed geom InnermostState", trajSVec[0].geometricalInnermostState());
3202 if (!trajSVec.empty())
3203 trackFittedTSOS = trajSVec[0].geometricalInnermostState();
3213 std::cout <<
" Hit " << nHit++ <<
" DetId " << (*i)->geographicalId().det();
3216 else if ((*i)->geographicalId().det() ==
DetId::Muon)
3220 if (!(*i)->isValid())
3221 std::cout <<
" not valid " << std::endl;
3231 for (
auto const&
hit : alongTr->recHits()) {
3232 std::cout <<
" Hit " << nHit++ <<
" DetId " <<
hit->geographicalId().det();
3239 if (!
hit->isValid())
3240 std::cout <<
" not valid " << std::endl;
3250 std::cout <<
" Not valid !!!! " << std::endl;
3254 << trajSOS.
charge() << std::endl;
3276 std::cout <<
" Not valid !!!! " << std::endl;
3280 << trajSOS.
charge() << std::endl;
3301 <<
" ...... " <<
title <<
" ...... " << std::endl;
3303 std::cout <<
" Not valid !!!!!!!! " << std::endl;
3308 std::cout <<
" alongMomentum >>>>" << std::endl;
3310 std::cout <<
" oppositeToMomentum <<<<" << std::endl;
3315 std::cout <<
" . . . . . . . . . . . . . . . . . . . . . . . . . . . . \n" << std::endl;
3331 std::cout <<
" paramVector " << paramVec.T() << std::endl;
3333 CLHEP::Hep3Vector colX, colY, colZ;
3335 #ifdef NOT_EXACT_ROTATION_MATRIX 3336 colX = CLHEP::Hep3Vector(1., -paramVec(6), paramVec(5));
3337 colY = CLHEP::Hep3Vector(paramVec(6), 1., -paramVec(4));
3338 colZ = CLHEP::Hep3Vector(-paramVec(5), paramVec(4), 1.);
3343 colX = CLHEP::Hep3Vector(c2 * c3, -c2 * s3, s2);
3344 colY = CLHEP::Hep3Vector(
c1 * s3 + s1 * s2 * c3,
c1 * c3 - s1 * s2 * s3, -s1 * c2);
3345 colZ = CLHEP::Hep3Vector(s1 * s3 -
c1 * s2 * c3, s1 * c3 +
c1 * s2 * s3,
c1 * c2);
3348 CLHEP::HepVector param0(6, 0);
3358 CLHEP::HepEulerAngles angMuGlRcd =
iteratorMuonRcd->rotation().eulerAngles();
3360 std::cout <<
" Old muon Rcd Euler angles " << angMuGlRcd.phi() <<
" " << angMuGlRcd.theta() <<
" " 3361 << angMuGlRcd.psi() << std::endl;
3363 if ((angMuGlRcd.phi() == 0.) && (angMuGlRcd.theta() == 0.) && (angMuGlRcd.psi() == 0.) && (posMuGlRcd.x() == 0.) &&
3364 (posMuGlRcd.y() == 0.) && (posMuGlRcd.z() == 0.)) {
3365 std::cout <<
" New muon parameters are stored in Rcd" << std::endl;
3371 }
else if ((paramVec(1) == 0.) && (paramVec(2) == 0.) && (paramVec(3) == 0.) && (paramVec(4) == 0.) &&
3372 (paramVec(5) == 0.) && (paramVec(6) == 0.)) {
3373 std::cout <<
" Old muon parameters are stored in Rcd" << std::endl;
3378 std::cout <<
" New + Old muon parameters are stored in Rcd" << std::endl;
3379 CLHEP::Hep3Vector posMuGlRcdThis = CLHEP::Hep3Vector(paramVec(1), paramVec(2), paramVec(3));
3380 CLHEP::HepRotation rotMuGlRcdThis = CLHEP::HepRotation(colX, colY, colZ);
3381 CLHEP::Hep3Vector posMuGlRcdNew = rotMuGlRcdThis * posMuGlRcd + posMuGlRcdThis;
3382 CLHEP::HepRotation rotMuGlRcdNew = rotMuGlRcdThis * rotMuGlRcd;
3398 <<
tracker.rotation().eulerAngles() << std::endl;
3401 std::cout <<
"Muon (" <<
muon.rawId() <<
") at " <<
muon.translation() <<
" " <<
muon.rotation().eulerAngles()
3403 std::cout <<
" rotations angles around x,y,z " 3404 <<
" ( " << -
muon.rotation().zy() <<
" " <<
muon.rotation().zx() <<
" " << -
muon.rotation().yx() <<
" )" 3408 std::cout <<
"Ecal (" <<
ecal.rawId() <<
") at " <<
ecal.translation() <<
" " <<
ecal.rotation().eulerAngles()
3412 std::cout <<
"Hcal (" <<
hcal.rawId() <<
") at " <<
hcal.translation() <<
" " <<
hcal.rotation().eulerAngles()
3416 std::cout <<
"Calo (" <<
calo.rawId() <<
") at " <<
calo.translation() <<
" " <<
calo.rotation().eulerAngles()
3420 globalPositions.m_align.push_back(
tracker);
3421 globalPositions.m_align.push_back(
muon);
3422 globalPositions.m_align.push_back(
ecal);
3423 globalPositions.m_align.push_back(
hcal);
3424 globalPositions.m_align.push_back(
calo);
3426 std::cout <<
"Uploading to the database..." << std::endl;
3431 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
float pzSign() const
Sign of the z-component of the momentum in the local frame.
const GlobalTrackingGeometry * trackingGeometry_
double CLHEP_dot(const CLHEP::HepVector &a, const CLHEP::HepVector &b)
edm::ESWatcher< GlobalPositionRcd > watchGlobalPositionRcd_
edm::ESHandle< GlobalTrackingGeometry > theTrackingGeometry
void debugTrajectorySOSv(const std::string, TrajectoryStateOnSurface)
KFTrajectorySmoother * theSmootherOp
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33
void gradientGlobalAlg(GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, AlgebraicSymMatrix66 &)
void gradientLocal(GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, CLHEP::HepSymMatrix &, CLHEP::HepMatrix &, CLHEP::HepVector &, AlgebraicVector4 &)
virtual TrajectoryContainer trajectories(const Trajectory &traj) const
const LocalTrajectoryError & localError() const
virtual ConstReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
trackingRecHit_iterator recHitsEnd() const
last iterator to RecHits
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
edm::ESGetToken< Alignments, GlobalPositionRcd > m_globalPosToken
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > m_TkGeometryToken
Sin< T >::type sin(const T &t)
KFTrajectoryFitter * theFitter
const GlobalTrajectoryParameters & globalParameters() const
CLHEP::HepVector MuGlAngle
void misalignMuon(GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &)
std::vector< AlignTransform >::const_iterator iteratorHcalRcd
AlgebraicVector6 vector() const
std::vector< ConstRecHitPointer > RecHitContainer
const LocalTrajectoryParameters & localParameters() const
trackingRecHit_iterator recHitsBegin() const
first iterator to RecHits
const SurfaceType & surface() const
void gradientGlobal(GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, AlgebraicSymMatrix66 &)
std::vector< AlignTransform > m_align
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
TrajectoryMeasurement const & lastMeasurement() const
const CartesianTrajectoryError cartesianError() const
RecordProviders::iterator Itr
RecHitPointer build(const TrackingRecHit *p, edm::ESHandle< GlobalTrackingGeometry > trackingGeometry) const
Call the MuonTransientTrackingRecHit::specificBuild.
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t V
GlobalPoint globalPosition() const
void debugTrackHit(const std::string, reco::TrackRef)
cond::Time_t currentTime() const
TrajectoryStateOnSurface outermostMeasurementState() const
edm::ESWatcher< GlobalTrackingGeometryRecord > watchTrackingGeometry_
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
PropagationDirection const & direction() const
AlgebraicVector5 vector() const
Cos< T >::type cos(const T &t)
KFTrajectoryFitter * theFitterOp
std::vector< AlignTransform >::const_iterator iteratorMuonRcd
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
void analyzeTrackTrajectory(const edm::Event &, const edm::EventSetup &)
#define DEFINE_FWK_MODULE(type)
TrajectoryStateOnSurface innermostMeasurementState() const
TrackCharge charge() const
const MagneticField * magneticField_
ROOT::Math::SVector< double, 4 > AlgebraicVector4
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > m_ttrhBuilderToken
void misalignMuonL(GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, AlgebraicVector4 &, TrajectoryStateOnSurface &, TrajectoryStateOnSurface &)
void analyze(const edm::Event &, const edm::EventSetup &) override
GlobalTrackerMuonAlignment(const edm::ParameterSet &)
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
void writeGlPosRcd(CLHEP::HepVector &d3)
std::vector< AlignTransform >::const_iterator iteratorEcalRcd
~GlobalTrackerMuonAlignment() override
void trackFitter(reco::TrackRef, reco::TransientTrack &, PropagationDirection, TrajectoryStateOnSurface &)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
auto const & tracks
cannot be loose
KFTrajectorySmoother * theSmoother
const PositionType & position() const
constexpr uint32_t rawId() const
get the raw id
const Alignments * globalPositionRcd_
GlobalTrackerMuonAlignment
const TransientTrackingRecHitBuilder * TTRHBuilder
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
edm::ESWatcher< IdealMagneticFieldRecord > watchMagneticFieldRecord_
GlobalVector globalMomentum() const
bool check(const edm::EventSetup &iSetup)
TrajectoryStateOnSurface const & updatedState() const
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_MagFieldToken
TrajectoryMeasurement const & firstMeasurement() const
void debugTrajectory(const std::string, Trajectory &)
const AlgebraicSymMatrix55 & matrix() const
ROOT::Math::SVector< double, 3 > AlgebraicVector3
const AlgebraicSymMatrix66 & matrix() const
FreeTrajectoryState const * freeState(bool withErrors=true) const
ROOT::Math::SVector< double, 6 > AlgebraicVector6
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
GlobalVector normalVector() const
std::vector< AlignTransform >::const_iterator iteratorTrackerRcd
const RotationType & rotation() const
edm::ESGetToken< Propagator, TrackingComponentsRecord > m_propToken
edm::ESWatcher< TrackingComponentsRecord > watchTrackingComponentsRecord_
void analyzeTrackTrack(const edm::Event &, const edm::EventSetup &)
void muonFitter(reco::TrackRef, reco::TransientTrack &, PropagationDirection, TrajectoryStateOnSurface &)
MuonTransientTrackingRecHitBuilder * MuRHBuilder
Global3DVector GlobalVector
CLHEP::HepVector MuGlShift
void debugTrajectorySOS(const std::string, TrajectoryStateOnSurface &)