102 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;
226 std::vector<AlignTransform>::const_iterator
296 trackTags_(iConfig.getParameter<
edm::
InputTag>(
"tracks")),
297 muonTags_(iConfig.getParameter<
edm::
InputTag>(
"muons")),
298 gmuonTags_(iConfig.getParameter<
edm::
InputTag>(
"gmuons")),
299 smuonTags_(iConfig.getParameter<
edm::
InputTag>(
"smuons")),
300 cosmicMuonMode_(iConfig.getParameter<
bool>(
"cosmics")),
301 isolatedMuonMode_(iConfig.getParameter<
bool>(
"isolated")),
302 refitMuon_(iConfig.getParameter<
bool>(
"refitmuon")),
303 refitTrack_(iConfig.getParameter<
bool>(
"refittrack")),
304 rootOutFile_(iConfig.getUntrackedParameter<
string>(
"rootOutFile")),
305 txtOutFile_(iConfig.getUntrackedParameter<
string>(
"txtOutFile")),
306 writeDB_(iConfig.getUntrackedParameter<
bool>(
"writeDB")),
307 debug_(iConfig.getUntrackedParameter<
bool>(
"debug")),
325 #ifdef NO_FALSE_FALSE_MODE 328 <<
"Use from GlobalTrackerMuonAlignment_test_cfg.py.";
332 throw cms::Exception(
"BadConfig") <<
"Muon collection can be either cosmic or isolated! " 333 <<
"Please set only one to true.";
344 desc.add<
bool>(
"isolated",
false);
345 desc.add<
bool>(
"cosmics",
false);
346 desc.add<
bool>(
"refitmuon",
false);
347 desc.add<
bool>(
"refittrack",
false);
350 desc.addUntracked<
bool>(
"writeDB",
false);
351 desc.addUntracked<
bool>(
"debug",
false);
352 descriptions.
add(
"globalTrackerMuonAlignment",
desc);
380 for (
int i = 0;
i <= 2;
i++) {
382 for (
int j = 0;
j <= 2;
j++) {
387 Grad = CLHEP::HepVector(6, 0);
388 Hess = CLHEP::HepSymMatrix(6, 0);
390 GradL = CLHEP::HepVector(6, 0);
391 HessL = CLHEP::HepSymMatrix(6, 0);
394 TDirectory* dirsave = gDirectory;
397 const bool oldAddDir = TH1::AddDirectoryStatus();
399 TH1::AddDirectory(
true);
403 TH1::AddDirectory(oldAddDir);
416 for (
int i = 0;
i <= 2;
i++)
417 for (
int j = 0;
j <= 2;
j++) {
422 bool ierr = !InfI.Invert();
425 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Error inverse Inf matrix !!!!!!!!!!!";
428 for (
int i = 0;
i <= 2;
i++)
429 for (
int k = 0;
k <= 2;
k++)
434 CLHEP::HepVector d3 = CLHEP::solve(
Hess, -
Grad);
436 CLHEP::HepMatrix Errd3 =
Hess.inverse(iEr3);
439 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" endJob Error inverse Hess matrix !!!!!!!!!!!";
444 CLHEP::HepVector dLI = CLHEP::solve(
HessL, -
GradL);
446 CLHEP::HepMatrix ErrdLI =
HessL.inverse(iErI);
449 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" endJob Error inverse HessL matrix !!!!!!!!!!!";
457 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ALCARECOMuAlCalIsolatedMu";
459 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ALCARECOMuAlGlobalCosmics";
470 <<
" dG " << d3(1) <<
" " << d3(2) <<
" " << d3(3) <<
" " << d3(4) <<
" " << d3(5) <<
" " << d3(6);
476 <<
" dL " << dLI(1) <<
" " << dLI(2) <<
" " << dLI(3) <<
" " << dLI(4) <<
" " << dLI(5) <<
" " << dLI(6);
483 CLHEP::HepVector vectorToDb(6, 0), vectorErrToDb(6, 0);
487 for (
unsigned int i = 1;
i <= 6;
i++)
497 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" outglobal.txt is not open !!!!!";
499 OutGlobalTxt << vectorToDb(1) <<
" " << vectorToDb(2) <<
" " << vectorToDb(3) <<
" " << vectorToDb(4) <<
" " 500 << vectorToDb(5) <<
" " << vectorToDb(6) <<
" muon Global.\n";
501 OutGlobalTxt << vectorErrToDb(1) <<
" " << vectorErrToDb(1) <<
" " << vectorErrToDb(1) <<
" " << vectorErrToDb(1)
502 <<
" " << vectorErrToDb(1) <<
" " << vectorErrToDb(1) <<
" errors.\n";
512 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Write to the file outglobal.txt done ";
524 double PI = 3.1415927;
525 histo =
new TH1F(
"Pt",
"pt", 1000, 0, 100);
526 histo2 =
new TH1F(
"P",
"P [GeV/c]", 400, 0., 400.);
527 histo2->GetXaxis()->SetTitle(
"momentum [GeV/c]");
528 histo3 =
new TH1F(
"outerLambda",
"#lambda outer", 100, -
PI / 2.,
PI / 2.);
529 histo3->GetXaxis()->SetTitle(
"#lambda outer");
530 histo4 =
new TH1F(
"phi",
"#phi [rad]", 100, -
PI,
PI);
531 histo4->GetXaxis()->SetTitle(
"#phi [rad]");
532 histo5 =
new TH1F(
"Rmuon",
"inner muon hit R [cm]", 100, 0., 800.);
533 histo5->GetXaxis()->SetTitle(
"R of muon [cm]");
534 histo6 =
new TH1F(
"Zmuon",
"inner muon hit Z[cm]", 100, -1000., 1000.);
535 histo6->GetXaxis()->SetTitle(
"Z of muon [cm]");
536 histo7 =
new TH1F(
"(Pm-Pt)/Pt",
" (Pmuon-Ptrack)/Ptrack", 100, -2., 2.);
537 histo7->GetXaxis()->SetTitle(
"(Pmuon-Ptrack)/Ptrack");
538 histo8 =
new TH1F(
"chi muon-track",
"#chi^{2}(muon-track)", 1000, 0., 1000.);
539 histo8->GetXaxis()->SetTitle(
"#chi^{2} of muon w.r.t. propagated track");
540 histo11 =
new TH1F(
"distance muon-track",
"distance muon w.r.t track [cm]", 100, 0., 30.);
541 histo11->GetXaxis()->SetTitle(
"distance of muon w.r.t. track [cm]");
542 histo12 =
new TH1F(
"Xmuon-Xtrack",
"Xmuon-Xtrack [cm]", 200, -20., 20.);
543 histo12->GetXaxis()->SetTitle(
"Xmuon - Xtrack [cm]");
544 histo13 =
new TH1F(
"Ymuon-Ytrack",
"Ymuon-Ytrack [cm]", 200, -20., 20.);
545 histo13->GetXaxis()->SetTitle(
"Ymuon - Ytrack [cm]");
546 histo14 =
new TH1F(
"Zmuon-Ztrack",
"Zmuon-Ztrack [cm]", 200, -20., 20.);
547 histo14->GetXaxis()->SetTitle(
"Zmuon-Ztrack [cm]");
548 histo15 =
new TH1F(
"NXmuon-NXtrack",
"NXmuon-NXtrack [rad]", 200, -.1, .1);
549 histo15->GetXaxis()->SetTitle(
"N_{X}(muon)-N_{X}(track) [rad]");
550 histo16 =
new TH1F(
"NYmuon-NYtrack",
"NYmuon-NYtrack [rad]", 200, -.1, .1);
551 histo16->GetXaxis()->SetTitle(
"N_{Y}(muon)-N_{Y}(track) [rad]");
552 histo17 =
new TH1F(
"NZmuon-NZtrack",
"NZmuon-NZtrack [rad]", 200, -.1, .1);
553 histo17->GetXaxis()->SetTitle(
"N_{Z}(muon)-N_{Z}(track) [rad]");
554 histo18 =
new TH1F(
"expected error of Xinner",
"outer hit of inner tracker", 100, 0, .01);
555 histo18->GetXaxis()->SetTitle(
"expected error of Xinner [cm]");
556 histo19 =
new TH1F(
"expected error of Xmuon",
"inner hit of muon", 100, 0, .1);
557 histo19->GetXaxis()->SetTitle(
"expected error of Xmuon [cm]");
558 histo20 =
new TH1F(
"expected error of Xmuon-Xtrack",
"muon w.r.t. propagated track", 100, 0., 10.);
559 histo20->GetXaxis()->SetTitle(
"expected error of Xmuon-Xtrack [cm]");
560 histo21 =
new TH1F(
"pull of Xmuon-Xtrack",
"pull of Xmuon-Xtrack", 100, -10., 10.);
561 histo21->GetXaxis()->SetTitle(
"(Xmuon-Xtrack)/expected error");
562 histo22 =
new TH1F(
"pull of Ymuon-Ytrack",
"pull of Ymuon-Ytrack", 100, -10., 10.);
563 histo22->GetXaxis()->SetTitle(
"(Ymuon-Ytrack)/expected error");
564 histo23 =
new TH1F(
"pull of Zmuon-Ztrack",
"pull of Zmuon-Ztrack", 100, -10., 10.);
565 histo23->GetXaxis()->SetTitle(
"(Zmuon-Ztrack)/expected error");
566 histo24 =
new TH1F(
"pull of PXmuon-PXtrack",
"pull of PXmuon-PXtrack", 100, -10., 10.);
567 histo24->GetXaxis()->SetTitle(
"(P_{X}(muon)-P_{X}(track))/expected error");
568 histo25 =
new TH1F(
"pull of PYmuon-PYtrack",
"pull of PYmuon-PYtrack", 100, -10., 10.);
569 histo25->GetXaxis()->SetTitle(
"(P_{Y}(muon)-P_{Y}(track))/expected error");
570 histo26 =
new TH1F(
"pull of PZmuon-PZtrack",
"pull of PZmuon-PZtrack", 100, -10., 10.);
571 histo26->GetXaxis()->SetTitle(
"(P_{Z}(muon)-P_{Z}(track))/expected error");
572 histo27 =
new TH1F(
"N_x",
"Nx of tangent plane", 120, -1.1, 1.1);
573 histo27->GetXaxis()->SetTitle(
"normal vector projection N_{X}");
574 histo28 =
new TH1F(
"N_y",
"Ny of tangent plane", 120, -1.1, 1.1);
575 histo28->GetXaxis()->SetTitle(
"normal vector projection N_{Y}");
576 histo29 =
new TH1F(
"lenght of track",
"lenght of track", 200, 0., 400);
577 histo29->GetXaxis()->SetTitle(
"lenght of track [cm]");
578 histo30 =
new TH1F(
"lenght of muon",
"lenght of muon", 200, 0., 800);
579 histo30->GetXaxis()->SetTitle(
"lenght of muon [cm]");
581 histo31 =
new TH1F(
"local chi muon-track",
"#local chi^{2}(muon-track)", 1000, 0., 1000.);
582 histo31->GetXaxis()->SetTitle(
"#local chi^{2} of muon w.r.t. propagated track");
583 histo32 =
new TH1F(
"pull of Px/Pz local",
"pull of Px/Pz local", 100, -10., 10.);
584 histo32->GetXaxis()->SetTitle(
"local (Px/Pz(muon) - Px/Pz(track))/expected error");
585 histo33 =
new TH1F(
"pull of Py/Pz local",
"pull of Py/Pz local", 100, -10., 10.);
586 histo33->GetXaxis()->SetTitle(
"local (Py/Pz(muon) - Py/Pz(track))/expected error");
587 histo34 =
new TH1F(
"pull of X local",
"pull of X local", 100, -10., 10.);
588 histo34->GetXaxis()->SetTitle(
"local (Xmuon - Xtrack)/expected error");
589 histo35 =
new TH1F(
"pull of Y local",
"pull of Y local", 100, -10., 10.);
590 histo35->GetXaxis()->SetTitle(
"local (Ymuon - Ytrack)/expected error");
592 histo101 =
new TH2F(
"Rtr/mu vs Ztr/mu",
"hit of track/muon", 100, -800., 800., 100, 0., 600.);
593 histo101->GetXaxis()->SetTitle(
"Z of track/muon [cm]");
594 histo101->GetYaxis()->SetTitle(
"R of track/muon [cm]");
595 histo102 =
new TH2F(
"Ytr/mu vs Xtr/mu",
"hit of track/muon", 100, -600., 600., 100, -600., 600.);
596 histo102->GetXaxis()->SetTitle(
"X of track/muon [cm]");
597 histo102->GetYaxis()->SetTitle(
"Y of track/muon [cm]");
627 using namespace reco;
632 double PI = 3.1415927;
646 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" treated as IsolatedMu ";
668 <<
" ievBunch " <<
iEvent.bunchCrossing() <<
" runN " << (
int)
iEvent.run();
670 <<
muons->size() <<
" " << gmuons->size() <<
" " << smuons->size();
671 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
673 <<
" is isolatValid Matches " << itMuon->isIsolationValid() <<
" " << itMuon->isMatchesValid();
680 if (
muons->size() != 1)
682 if (gmuons->size() != 1)
684 if (smuons->size() != 1)
689 if (smuons->size() > 2)
691 if (
tracks->size() != smuons->size())
693 if (
muons->size() != smuons->size())
695 if (gmuons->size() != smuons->size())
760 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
763 <<
" mu gM is GM Mu SaM tM " << itMuon->isGlobalMuon() <<
" " << itMuon->isMuon() <<
" " 764 << itMuon->isStandAloneMuon() <<
" " << itMuon->isTrackerMuon() <<
" ";
778 GlobalPoint pointTrackOut = outerTrackTSOS.globalPosition();
779 float lenghtTrack = (pointTrackOut - pointTrackIn).
mag();
780 GlobalPoint pointMuonIn = innerMuTSOS.globalPosition();
782 float lenghtMuon = (pointMuonOut - pointMuonIn).
mag();
783 GlobalVector momentumTrackOut = outerTrackTSOS.globalMomentum();
785 float distanceInIn = (pointTrackIn - pointMuonIn).
mag();
786 float distanceInOut = (pointTrackIn - pointMuonOut).
mag();
787 float distanceOutIn = (pointTrackOut - pointMuonIn).
mag();
788 float distanceOutOut = (pointTrackOut - pointMuonOut).
mag();
791 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" pointTrackIn " << pointTrackIn;
792 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Out " << pointTrackOut <<
" lenght " << lenghtTrack;
793 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" point MuonIn " << pointMuonIn;
794 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Out " << pointMuonOut <<
" lenght " << lenghtMuon;
796 <<
" momeTrackIn Out " << momentumTrackIn <<
" " << momentumTrackOut;
798 <<
" doi io ii oo " << distanceOutIn <<
" " << distanceInOut <<
" " << distanceInIn <<
" " << distanceOutOut;
801 if (lenghtTrack < 90.)
803 if (lenghtMuon < 300.)
805 if (momentumTrackIn.
mag() < 15. || momentumTrackOut.
mag() < 15.)
807 if (trackTT.charge() != muTT.charge())
811 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" passed lenght momentum cuts";
820 const Surface& refSurface = innerMuTSOS.surface();
822 Nl = tpMuLocal->normalVector();
826 const Plane* refPlane =
dynamic_cast<Plane*
>(surf);
830 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 831 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
832 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" global " << Ng.
x() <<
" " << Ng.
y() <<
" " << Ng.
z();
833 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" lp " << Nlp.
x() <<
" " << Nlp.
y() <<
" " << Nlp.
z();
835 <<
" Nlocal Nglobal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " << Ng.
x() <<
" " << Ng.
y() <<
" " 836 << Ng.
z() <<
" alfa " <<
static_cast<int>(asin(Nl.
x()) * 57.29578);
840 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
843 if (!extrapolationT.
isValid()) {
845 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 858 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
859 GPm = innerMuTSOS.globalMomentum();
861 (outerTrackTSOS.globalPosition()).
y(),
862 (outerTrackTSOS.globalPosition()).
z());
872 if ((distanceOutIn <= distanceInOut) & (distanceOutIn <= distanceInIn) &
873 (distanceOutIn <= distanceOutOut)) {
877 const Surface& refSurface = innerMuTSOS.surface();
879 Nl = tpMuGlobal->normalVector();
882 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
885 if (!extrapolationT.
isValid()) {
887 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 903 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
904 GPm = innerMuTSOS.globalMomentum();
906 (outerTrackTSOS.globalPosition()).
y(),
907 (outerTrackTSOS.globalPosition()).
z());
917 <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 918 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface));
920 <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 921 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
925 else if ((distanceInOut <= distanceInIn) & (distanceInOut <= distanceOutIn) &
926 (distanceInOut <= distanceOutOut)) {
932 Nl = tpMuGlobal->normalVector();
935 extrapolationT = oppositeSmPr.
propagate(innerTrackTSOS, refSurface);
937 if (!extrapolationT.
isValid()) {
939 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 940 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid();
968 <<
" propDirCh " << Chooser.operator()(*innerTrackTSOS.
freeState(), refSurface) <<
" Ch == oppisite " 971 <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 972 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
976 else if ((distanceOutOut <= distanceInOut) & (distanceOutOut <= distanceInIn) &
977 (distanceOutOut <= distanceOutIn)) {
986 Nl = tpMuGlobal->normalVector();
989 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
991 if (!extrapolationT.
isValid()) {
993 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-Out extrapolationT.isValid " 994 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid();
1011 (outerTrackTSOS.globalPosition()).
y(),
1012 (outerTrackTSOS.globalPosition()).
z());
1021 <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 1022 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface));
1024 <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1025 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1027 <<
" Nornal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1028 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1034 <<
" ------- !!!!!!!!!!!!!!! No proper Out - In \a\a\a\a\a\a\a";
1040 if (tsosMuonIf == 0) {
1047 if (tsosMuonIf == 1)
1048 tsosMuon = muTT.innermostMeasurementState();
1050 tsosMuon = muTT.outermostMeasurementState();
1059 float RelMomResidual = (Pm.
mag() - Pt.mag()) / (Pt.mag() + 1.e-6);
1069 float Rmuon = Rm.
perp();
1070 float Zmuon = Rm.
z();
1071 float alfa_x = atan2(Nl.
x(), Nl.
y()) * 57.29578;
1075 <<
" Nx Ny Nz alfa_x " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " << alfa_x;
1077 <<
" Rm " << Rm <<
"\n Rt " << Rt <<
"\n resR " << resR <<
"\n resP " << resP <<
" dp/p " << RelMomResidual;
1081 for (
int i = 0;
i <= 5;
i++)
1082 chi_d += Vm(
i) * Vm(
i) / Cm(
i,
i);
1087 bool ierrLoc = !
m.Invert();
1089 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ==== Error inverting Local covariance matrix ==== ";
1092 double chi_Loc = ROOT::Math::Similarity(Vml,
m);
1095 <<
" chi_Loc px/pz/err " << chi_Loc <<
" " << Vml(1) /
std::sqrt(Cml(1, 1));
1144 if (Rmuon < 120. || Rmuon > 450.)
1146 if (Zmuon < -720. || Zmuon > 720.)
1151 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" .............. passed all cuts";
1159 CLHEP::HepSymMatrix covLoc(4, 0);
1160 for (
int i = 1;
i <= 4;
i++)
1161 for (
int j = 1;
j <=
i;
j++) {
1167 CLHEP::HepMatrix rotLoc(3, 3, 0);
1180 CLHEP::HepVector posLoc(3);
1189 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" posLoc " << posLoc.T();
1194 histo->Fill(itMuon->track()->pt());
1198 histo3->Fill((
PI / 2. - itMuon->track()->outerTheta()));
1199 histo4->Fill(itMuon->track()->phi());
1202 histo7->Fill(RelMomResidual);
1212 if (fabs(Nl.
x()) < 0.98)
1214 if (fabs(Nl.
y()) < 0.98)
1216 if (fabs(Nl.
z()) < 0.98)
1222 if ((fabs(Nl.
x()) < 0.98) && (fabs(Nl.
y()) < 0.98) && (fabs(Nl.
z()) < 0.98)) {
1227 if (fabs(Nl.
x()) < 0.98)
1229 if (fabs(Nl.
y()) < 0.98)
1231 if (fabs(Nl.
z()) < 0.98)
1248 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag 0[ " << C0(0, 0) <<
" " << C0(1, 1) <<
" " << C0(2, 2)
1249 <<
" " << C0(3, 3) <<
" " << C0(4, 4) <<
" " << C0(5, 5) <<
" ]";
1250 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag e[ " << Ce(0, 0) <<
" " << Ce(1, 1) <<
" " << Ce(2, 2)
1251 <<
" " << Ce(3, 3) <<
" " << Ce(4, 4) <<
" " << Ce(5, 5) <<
" ]";
1252 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag 1[ " << C1(0, 0) <<
" " << C1(1, 1) <<
" " << C1(2, 2)
1253 <<
" " << C1(3, 3) <<
" " << C1(4, 4) <<
" " << C1(5, 5) <<
" ]";
1254 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Rm " << Rm.
x() <<
" " << Rm.
y() <<
" " << Rm.
z() <<
" Pm " 1255 << Pm.
x() <<
" " << Pm.
y() <<
" " << Pm.
z();
1256 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Rt " << Rt.x() <<
" " << Rt.y() <<
" " << Rt.z() <<
" Pt " 1257 << Pt.x() <<
" " << Pt.y() <<
" " << Pt.z();
1259 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" resR " << resR.
x() <<
" " << resR.
y() <<
" " << resR.
z()
1260 <<
" resP " << resP.
x() <<
" " << resP.
y() <<
" " << resP.
z();
1262 <<
" Rm-t " << (Rm - Rt).
x() <<
" " << (Rm - Rt).
y() <<
" " << (Rm - Rt).
z() <<
" Pm-t " << (Pm - Pt).
x()
1263 <<
" " << (Pm - Pt).
y() <<
" " << (Pm - Pt).
z();
1269 <<
" Pmuon Ptrack dP/Ptrack " << itMuon->outerTrack()->p() <<
" " << itMuon->track()->outerP() <<
" " 1270 << (itMuon->outerTrack()->p() - itMuon->track()->outerP()) / itMuon->track()->outerP();
1273 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag [ " << Cm(0, 0) <<
" " << Cm(1, 1) <<
" " << Cm(2, 2)
1274 <<
" " << Cm(3, 3) <<
" " << Cm(4, 4) <<
" " << Cm(5, 5) <<
" ]";
1278 for (
int i = 0;
i <= 5;
i++)
1280 for (
int i = 0;
i <= 5;
i++)
1281 for (
int j = 0;
j <= 5;
j++)
1282 Ro(
i,
j) = Cm(
i,
j) / Diag[
i] / Diag[
j];
1287 for (
int i = 0;
i <= 5;
i++)
1288 for (
int j = 0;
j <= 5;
j++)
1289 CmI(
i,
j) = Cm(
i,
j);
1291 bool ierr = !CmI.Invert();
1294 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Error inverse covariance matrix !!!!!!!!!!!";
1300 double chi = ROOT::Math::Similarity(Vm, CmI);
1301 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" chi chi_d " << chi <<
" " << chi_d;
1310 using namespace edm;
1311 using namespace reco;
1316 double PI = 3.1415927;
1330 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" treated as IsolatedMu ";
1352 <<
" ievBunch " <<
iEvent.bunchCrossing() <<
" runN " << (
int)
iEvent.run();
1354 <<
muons->size() <<
" " << gmuons->size() <<
" " << smuons->size();
1355 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
1357 <<
" is isolatValid Matches " << itMuon->isIsolationValid() <<
" " << itMuon->isMatchesValid();
1364 if (
muons->size() != 1)
1366 if (gmuons->size() != 1)
1368 if (smuons->size() != 1)
1373 if (smuons->size() > 2)
1375 if (
tracks->size() != smuons->size())
1377 if (
muons->size() != smuons->size())
1379 if (gmuons->size() != smuons->size())
1450 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ............... DEFINE FITTER ...................";
1454 theFitter =
new KFTrajectoryFitter(alongSmPr, *theUpdator, *theEstimator);
1456 theFitterOp =
new KFTrajectoryFitter(oppositeSmPr, *theUpdator, *theEstimator);
1465 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
"get also the MuonTransientTrackingRecHitBuilder" 1467 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
"get also the TransientTrackingRecHitBuilder" 1475 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
1478 <<
" mu gM is GM Mu SaM tM " << itMuon->isGlobalMuon() <<
" " << itMuon->isMuon() <<
" " 1479 << itMuon->isStandAloneMuon() <<
" " << itMuon->isTrackerMuon() <<
" ";
1493 GlobalPoint pointTrackOut = outerTrackTSOS.globalPosition();
1494 float lenghtTrack = (pointTrackOut - pointTrackIn).
mag();
1495 GlobalPoint pointMuonIn = innerMuTSOS.globalPosition();
1497 float lenghtMuon = (pointMuonOut - pointMuonIn).
mag();
1498 GlobalVector momentumTrackOut = outerTrackTSOS.globalMomentum();
1500 float distanceInIn = (pointTrackIn - pointMuonIn).
mag();
1501 float distanceInOut = (pointTrackIn - pointMuonOut).
mag();
1502 float distanceOutIn = (pointTrackOut - pointMuonIn).
mag();
1503 float distanceOutOut = (pointTrackOut - pointMuonOut).
mag();
1506 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" pointTrackIn " << pointTrackIn;
1507 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Out " << pointTrackOut <<
" lenght " << lenghtTrack;
1508 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" point MuonIn " << pointMuonIn;
1509 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Out " << pointMuonOut <<
" lenght " << lenghtMuon;
1511 <<
" momeTrackIn Out " << momentumTrackIn <<
" " << momentumTrackOut;
1513 <<
" doi io ii oo " << distanceOutIn <<
" " << distanceInOut <<
" " << distanceInIn <<
" " << distanceOutOut;
1516 if (lenghtTrack < 90.)
1518 if (lenghtMuon < 300.)
1520 if (innerMuTSOS.globalMomentum().mag() < 5. || outerMuTSOS.
globalMomentum().
mag() < 5.)
1522 if (momentumTrackIn.
mag() < 15. || momentumTrackOut.
mag() < 15.)
1524 if (trackTT.charge() != muTT.charge())
1528 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" passed lenght momentum cuts";
1542 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ------ Isolated (out-in) ----- ";
1543 const Surface& refSurface = innerMuTSOS.surface();
1545 Nl = tpMuLocal->normalVector();
1549 const Plane* refPlane =
dynamic_cast<Plane*
>(surf);
1553 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1554 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1555 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" global " << Ng.
x() <<
" " << Ng.
y() <<
" " << Ng.
z();
1556 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" lp " << Nlp.
x() <<
" " << Nlp.
y() <<
" " << Nlp.
z();
1558 <<
" Nlocal Nglobal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " << Ng.
x() <<
" " << Ng.
y() <<
" " 1559 << Ng.
z() <<
" alfa " <<
static_cast<int>(asin(Nl.
x()) * 57.29578);
1566 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
1569 if (trackFittedTSOS.
isValid())
1570 extrapolationT = alongSmPr.
propagate(trackFittedTSOS, refSurface);
1573 if (!extrapolationT.
isValid()) {
1575 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 1588 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
1589 GPm = innerMuTSOS.globalMomentum();
1592 (outerTrackTSOS.globalPosition()).
y(),
1593 (outerTrackTSOS.globalPosition()).
z());
1606 if ((distanceOutIn <= distanceInOut) & (distanceOutIn <= distanceInIn) &
1607 (distanceOutIn <= distanceOutOut)) {
1611 const Surface& refSurface = innerMuTSOS.surface();
1613 Nl = tpMuGlobal->normalVector();
1618 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
1621 if (trackFittedTSOS.
isValid())
1622 extrapolationT = alongSmPr.
propagate(trackFittedTSOS, refSurface);
1625 if (!extrapolationT.
isValid()) {
1627 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 1643 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
1644 GPm = innerMuTSOS.globalMomentum();
1646 (outerTrackTSOS.globalPosition()).
y(),
1647 (outerTrackTSOS.globalPosition()).
z());
1660 <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 1661 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface));
1663 <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1664 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1668 else if ((distanceInOut <= distanceInIn) & (distanceInOut <= distanceOutIn) &
1669 (distanceInOut <= distanceOutOut)) {
1675 Nl = tpMuGlobal->normalVector();
1680 extrapolationT = oppositeSmPr.
propagate(innerTrackTSOS, refSurface);
1683 if (trackFittedTSOS.
isValid())
1684 extrapolationT = oppositeSmPr.
propagate(trackFittedTSOS, refSurface);
1687 if (!extrapolationT.
isValid()) {
1689 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 1690 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid();
1721 <<
" propDirCh " << Chooser.operator()(*innerTrackTSOS.
freeState(), refSurface) <<
" Ch == oppisite " 1724 <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1725 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1729 else if ((distanceOutOut <= distanceInOut) & (distanceOutOut <= distanceInIn) &
1730 (distanceOutOut <= distanceOutIn)) {
1732 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ----- Out - Out -----";
1739 Nl = tpMuGlobal->normalVector();
1742 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
1744 if (!extrapolationT.
isValid()) {
1746 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-Out extrapolationT.isValid " 1747 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid();
1764 (outerTrackTSOS.globalPosition()).
y(),
1765 (outerTrackTSOS.globalPosition()).
z());
1774 <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 1775 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface));
1777 <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1778 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1780 <<
" Nornal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1781 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1787 <<
" ------- !!!!!!!!!!!!!!! No proper Out - In \a\a\a\a\a\a\a";
1793 if (tsosMuonIf == 0) {
1800 if (tsosMuonIf == 1)
1801 tsosMuon = muTT.innermostMeasurementState();
1803 tsosMuon = muTT.outermostMeasurementState();
1810 if (!trackFittedTSOS.
isValid()) {
1812 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ================= trackFittedTSOS notValid !!!!!!!! ";
1820 if (!muonFittedTSOS.
isValid()) {
1822 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ================= muonFittedTSOS notValid !!!!!!!! ";
1839 float RelMomResidual = (Pm.
mag() - Pt.mag()) / (Pt.mag() + 1.e-6);
1849 float Rmuon = Rm.
perp();
1850 float Zmuon = Rm.
z();
1851 float alfa_x = atan2(Nl.
x(), Nl.
y()) * 57.29578;
1855 <<
" Nx Ny Nz alfa_x " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " << alfa_x;
1857 <<
" Rm " << Rm <<
"\n Rt " << Rt <<
"\n resR " << resR <<
"\n resP " << resP <<
" dp/p " << RelMomResidual;
1861 for (
int i = 0;
i <= 5;
i++)
1862 chi_d += Vm(
i) * Vm(
i) / Cm(
i,
i);
1867 bool ierrLoc = !
m.Invert();
1869 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ==== Error inverting Local covariance matrix ==== ";
1872 double chi_Loc = ROOT::Math::Similarity(Vml,
m);
1875 <<
" chi_Loc px/pz/err " << chi_Loc <<
" " << Vml(1) /
std::sqrt(Cml(1, 1));
1895 if (fabs(resR.
x()) > 20.)
1897 if (fabs(resR.
y()) > 20.)
1899 if (fabs(resR.
z()) > 20.)
1901 if (fabs(resR.
mag()) > 30.)
1903 if (fabs(resP.
x()) > 0.06)
1905 if (fabs(resP.
y()) > 0.06)
1907 if (fabs(resP.
z()) > 0.06)
1930 if (Rmuon < 120. || Rmuon > 450.)
1932 if (Zmuon < -720. || Zmuon > 720.)
1937 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" .............. passed all cuts";
1945 CLHEP::HepSymMatrix covLoc(4, 0);
1946 for (
int i = 1;
i <= 4;
i++)
1947 for (
int j = 1;
j <=
i;
j++) {
1953 CLHEP::HepMatrix rotLoc(3, 3, 0);
1966 CLHEP::HepVector posLoc(3);
1975 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" posLoc " << posLoc.T();
1980 histo->Fill(itMuon->track()->pt());
1984 histo3->Fill((
PI / 2. - itMuon->track()->outerTheta()));
1985 histo4->Fill(itMuon->track()->phi());
1988 histo7->Fill(RelMomResidual);
1998 if (fabs(Nl.
x()) < 0.98)
2000 if (fabs(Nl.
y()) < 0.98)
2002 if (fabs(Nl.
z()) < 0.98)
2008 if ((fabs(Nl.
x()) < 0.98) && (fabs(Nl.
y()) < 0.98) && (fabs(Nl.
z()) < 0.98)) {
2013 if (fabs(Nl.
x()) < 0.98)
2015 if (fabs(Nl.
y()) < 0.98)
2017 if (fabs(Nl.
z()) < 0.98)
2034 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag 0[ " << C0(0, 0) <<
" " << C0(1, 1) <<
" " << C0(2, 2)
2035 <<
" " << C0(3, 3) <<
" " << C0(4, 4) <<
" " << C0(5, 5) <<
" ]";
2036 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag e[ " << Ce(0, 0) <<
" " << Ce(1, 1) <<
" " << Ce(2, 2)
2037 <<
" " << Ce(3, 3) <<
" " << Ce(4, 4) <<
" " << Ce(5, 5) <<
" ]";
2038 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag 1[ " << C1(0, 0) <<
" " << C1(1, 1) <<
" " << C1(2, 2)
2039 <<
" " << C1(3, 3) <<
" " << C1(4, 4) <<
" " << C1(5, 5) <<
" ]";
2040 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Rm " << Rm.
x() <<
" " << Rm.
y() <<
" " << Rm.
z() <<
" Pm " 2041 << Pm.
x() <<
" " << Pm.
y() <<
" " << Pm.
z();
2042 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Rt " << Rt.x() <<
" " << Rt.y() <<
" " << Rt.z() <<
" Pt " 2043 << Pt.x() <<
" " << Pt.y() <<
" " << Pt.z();
2045 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" resR " << resR.
x() <<
" " << resR.
y() <<
" " << resR.
z()
2046 <<
" resP " << resP.
x() <<
" " << resP.
y() <<
" " << resP.
z();
2048 <<
" Rm-t " << (Rm - Rt).
x() <<
" " << (Rm - Rt).
y() <<
" " << (Rm - Rt).
z() <<
" Pm-t " << (Pm - Pt).
x()
2049 <<
" " << (Pm - Pt).
y() <<
" " << (Pm - Pt).
z();
2055 <<
" Pmuon Ptrack dP/Ptrack " << itMuon->outerTrack()->p() <<
" " << itMuon->track()->outerP() <<
" " 2056 << (itMuon->outerTrack()->p() - itMuon->track()->outerP()) / itMuon->track()->outerP();
2059 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag [ " << Cm(0, 0) <<
" " << Cm(1, 1) <<
" " << Cm(2, 2)
2060 <<
" " << Cm(3, 3) <<
" " << Cm(4, 4) <<
" " << Cm(5, 5) <<
" ]";
2064 for (
int i = 0;
i <= 5;
i++)
2066 for (
int i = 0;
i <= 5;
i++)
2067 for (
int j = 0;
j <= 5;
j++)
2068 Ro(
i,
j) = Cm(
i,
j) / Diag[
i] / Diag[
j];
2073 for (
int i = 0;
i <= 5;
i++)
2074 for (
int j = 0;
j <= 5;
j++)
2075 CmI(
i,
j) = Cm(
i,
j);
2077 bool ierr = !CmI.Invert();
2080 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Error inverse covariance matrix !!!!!!!!!!!";
2086 double chi = ROOT::Math::Similarity(Vm, CmI);
2087 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" chi chi_d " << chi <<
" " << chi_d;
2116 for (
int i = 0;
i <= 2;
i++) {
2117 if (Cm(
i,
i) > 1.
e-20)
2118 Wi(
i) = 1. / Cm(
i,
i);
2121 dR(
i) = R_m(
i) - R_t(
i);
2124 float PtN = P_t(0) * Norm(0) + P_t(1) * Norm(1) + P_t(2) * Norm(2);
2126 Jac(0, 0) = 1. - P_t(0) * Norm(0) / PtN;
2127 Jac(0, 1) = -P_t(0) * Norm(1) / PtN;
2128 Jac(0, 2) = -P_t(0) * Norm(2) / PtN;
2130 Jac(1, 0) = -P_t(1) * Norm(0) / PtN;
2131 Jac(1, 1) = 1. - P_t(1) * Norm(1) / PtN;
2132 Jac(1, 2) = -P_t(1) * Norm(2) / PtN;
2134 Jac(2, 0) = -P_t(2) * Norm(0) / PtN;
2135 Jac(2, 1) = -P_t(2) * Norm(1) / PtN;
2136 Jac(2, 2) = 1. - P_t(2) * Norm(2) / PtN;
2140 for (
int i = 0;
i <= 2;
i++)
2141 for (
int j = 0;
j <= 2;
j++) {
2146 for (
int k = 0;
k <= 2;
k++) {
2151 for (
int i = 0;
i <= 2;
i++)
2152 for (
int j = 0;
j <= 2;
j++) {
2159 for (
int i = 0;
i <= 2;
i++)
2160 for (
int k = 0;
k <= 2;
k++)
2161 Gtr(
i) +=
dR(
k) * Wi(
k) * Jac(
k,
i);
2162 for (
int i = 0;
i <= 2;
i++)
2204 CLHEP::HepSymMatrix
w(Nd, 0);
2205 for (
int i = 1;
i <= Nd;
i++)
2206 for (
int j = 1;
j <= Nd;
j++) {
2208 w(
i,
j) = GCov(
i - 1,
j - 1);
2211 if ((
i ==
j) && (
i <= 3) && (GCov(
i - 1,
j - 1) < 1.
e-20))
2220 CLHEP::HepVector
V(Nd), Rt(3), Pt(3), Rm(3), Pm(3), Norm(3);
2233 Norm(1) = GNorm.
x();
2234 Norm(2) = GNorm.
y();
2235 Norm(3) = GNorm.
z();
2237 V = dsum(Rm - Rt, Pm - Pt);
2243 CLHEP::HepMatrix Jac(Nd, Nd, 0);
2244 for (
int i = 1;
i <= 3;
i++)
2245 for (
int j = 1;
j <= 3;
j++) {
2246 Jac(
i,
j) = Pm(
i) * Norm(
j) / PmN;
2262 CLHEP::HepVector dsda(3);
2263 dsda(1) = (Norm(2) * Rm(3) - Norm(3) * Rm(2)) / PmN;
2264 dsda(2) = (Norm(3) * Rm(1) - Norm(1) * Rm(3)) / PmN;
2265 dsda(3) = (Norm(1) * Rm(2) - Norm(2) * Rm(1)) / PmN;
2268 Jac(1, 4) = Pm(1) * dsda(1);
2269 Jac(2, 4) = -Rm(3) + Pm(2) * dsda(1);
2270 Jac(3, 4) = Rm(2) + Pm(3) * dsda(1);
2272 Jac(1, 5) = Rm(3) + Pm(1) * dsda(2);
2273 Jac(2, 5) = Pm(2) * dsda(2);
2274 Jac(3, 5) = -Rm(1) + Pm(3) * dsda(2);
2276 Jac(1, 6) = -Rm(2) + Pm(1) * dsda(3);
2277 Jac(2, 6) = Rm(1) + Pm(2) * dsda(3);
2278 Jac(3, 6) = Pm(3) * dsda(3);
2280 CLHEP::HepSymMatrix W(Nd, 0);
2282 W =
w.inverse(ierr);
2285 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" gradientGlobal: inversion of matrix w fail ";
2289 CLHEP::HepMatrix W_Jac(Nd, Nd, 0);
2290 W_Jac = Jac.T() * W;
2292 CLHEP::HepVector grad3(Nd);
2295 CLHEP::HepMatrix hess3(Nd, Nd);
2296 hess3 = Jac.T() * W * Jac;
2302 CLHEP::HepVector d3I = CLHEP::solve(
Hess, -
Grad);
2304 CLHEP::HepMatrix Errd3I =
Hess.inverse(iEr3I);
2307 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" gradientGlobal error inverse Hess matrix !!!!!!!!!!!";
2312 <<
" dG " << d3I(1) <<
" " << d3I(2) <<
" " << d3I(3) <<
" " << d3I(4) <<
" " << d3I(5) <<
" " << d3I(6);
2319 #ifdef CHECK_OF_DERIVATIVES 2322 CLHEP::HepVector
d(3, 0),
a(3, 0);
2323 CLHEP::HepMatrix
T(3, 3, 1);
2325 CLHEP::HepMatrix Ti =
T.T();
2329 double B =
CLHEP_dot((Rt - Ti * Rm + Ti *
d), Norm);
2332 CLHEP::HepVector r0(3, 0), p0(3, 0);
2333 r0 = Ti * Rm - Ti *
d + s0 * (Ti * Pm) - Rt;
2336 double delta = 0.0001;
2350 CLHEP::HepVector
r(3, 0),
p(3, 0);
2351 r = Ti * Rm - Ti *
d +
s * (Ti * Pm) - Rt;
2355 <<
" s0 s num dsda(" <<
ii <<
") " << s0 <<
" " <<
s <<
" " << (
s - s0) /
delta <<
" " << dsda(
ii);
2358 <<
" -- An d(r,p)/d(" <<
ii <<
") " << Jac(1,
ii) <<
" " << Jac(2,
ii) <<
" " << Jac(3,
ii) <<
" " << Jac(4,
ii)
2359 <<
" " << Jac(5,
ii) <<
" " << Jac(6,
ii);
2361 <<
" Nu d(r,p)/d(" <<
ii <<
") " << (
r(1) - r0(1)) /
delta <<
" " << (
r(2) - r0(2)) /
delta <<
" " 2362 << (
r(3) - r0(3)) /
delta <<
" " << (
p(1) - p0(1)) /
delta <<
" " << (
p(2) - p0(2)) /
delta <<
" " 2363 << (
p(3) - p0(3)) /
delta;
2366 <<
" -- An d(r,p)/a(" <<
ii <<
") " << Jac(1,
ii + 3) <<
" " << Jac(2,
ii + 3) <<
" " << Jac(3,
ii + 3) <<
" " 2367 << Jac(4,
ii + 3) <<
" " << Jac(5,
ii + 3) <<
" " << Jac(6,
ii + 3);
2369 <<
" Nu d(r,p)/a(" <<
ii <<
") " << (
r(1) - r0(1)) /
delta <<
" " << (
r(2) - r0(2)) /
delta <<
" " 2370 << (
r(3) - r0(3)) /
delta <<
" " << (
p(1) - p0(1)) /
delta <<
" " << (
p(2) - p0(2)) /
delta <<
" " 2371 << (
p(3) - p0(3)) /
delta;
2384 CLHEP::HepSymMatrix& covLoc,
2385 CLHEP::HepMatrix& rotLoc,
2386 CLHEP::HepVector&
R0,
2416 CLHEP::HepVector Rt(3), Pt(3), Rm(3), Pm(3), Norm(3);
2429 Norm(1) = GNorm.
x();
2430 Norm(2) = GNorm.
y();
2431 Norm(3) = GNorm.
z();
2433 CLHEP::HepVector
V(4), Rml(3), Pml(3), Rtl(3), Ptl(3);
2441 Rml = rotLoc * (Rm -
R0);
2442 Rtl = rotLoc * (Rt -
R0);
2446 V(1) = LPRm(0) - Ptl(1) / Ptl(3);
2447 V(2) = LPRm(1) - Ptl(2) / Ptl(3);
2448 V(3) = LPRm(2) - Rtl(1);
2449 V(4) = LPRm(3) - Rtl(2);
2464 CLHEP::HepSymMatrix W = covLoc;
2470 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" gradientLocal: inversion of matrix W fail ";
2482 CLHEP::HepMatrix JacToLoc(4, 6, 0);
2483 for (
int i = 1;
i <= 2;
i++)
2484 for (
int j = 1;
j <= 3;
j++) {
2485 JacToLoc(
i,
j + 3) = (rotLoc(
i,
j) - rotLoc(3,
j) * Pml(
i) / Pml(3)) / Pml(3);
2486 JacToLoc(
i + 2,
j) = rotLoc(
i,
j);
2493 CLHEP::HepMatrix Jac(6, 6, 0);
2494 for (
int i = 1;
i <= 3;
i++)
2495 for (
int j = 1;
j <= 3;
j++) {
2496 Jac(
i,
j) = Pm(
i) * Norm(
j) / PmN;
2512 CLHEP::HepVector dsda(3);
2513 dsda(1) = (Norm(2) * Rm(3) - Norm(3) * Rm(2)) / PmN;
2514 dsda(2) = (Norm(3) * Rm(1) - Norm(1) * Rm(3)) / PmN;
2515 dsda(3) = (Norm(1) * Rm(2) - Norm(2) * Rm(1)) / PmN;
2518 Jac(1, 4) = Pm(1) * dsda(1);
2519 Jac(2, 4) = -Rm(3) + Pm(2) * dsda(1);
2520 Jac(3, 4) = Rm(2) + Pm(3) * dsda(1);
2522 Jac(1, 5) = Rm(3) + Pm(1) * dsda(2);
2523 Jac(2, 5) = Pm(2) * dsda(2);
2524 Jac(3, 5) = -Rm(1) + Pm(3) * dsda(2);
2526 Jac(1, 6) = -Rm(2) + Pm(1) * dsda(3);
2527 Jac(2, 6) = Rm(1) + Pm(2) * dsda(3);
2528 Jac(3, 6) = Pm(3) * dsda(3);
2531 CLHEP::HepMatrix JacCorLoc(4, 6, 0);
2532 JacCorLoc = JacToLoc * Jac;
2535 CLHEP::HepMatrix W_Jac(6, 4, 0);
2536 W_Jac = JacCorLoc.T() * W;
2538 CLHEP::HepVector gradL(6);
2541 CLHEP::HepMatrix hessL(6, 6);
2542 hessL = JacCorLoc.T() * W * JacCorLoc;
2547 CLHEP::HepVector dLI = CLHEP::solve(
HessL, -
GradL);
2549 CLHEP::HepMatrix ErrdLI =
HessL.inverse(iErI);
2552 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" gradLocal Error inverse Hess matrix !!!!!!!!!!!";
2557 <<
" dL " << dLI(1) <<
" " << dLI(2) <<
" " << dLI(3) <<
" " << dLI(4) <<
" " << dLI(5) <<
" " << dLI(6);
2566 <<
" dV(da3) {" << -JacCorLoc(1, 6) * 0.002 <<
" " << -JacCorLoc(2, 6) * 0.002 <<
" " 2567 << -JacCorLoc(3, 6) * 0.002 <<
" " << -JacCorLoc(4, 6) * 0.002 <<
"}";
2568 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" JacCLo {" << JacCorLoc(1, 6) <<
" " << JacCorLoc(2, 6)
2569 <<
" " << JacCorLoc(3, 6) <<
" " << JacCorLoc(4, 6) <<
"}";
2571 <<
"Jpx/yx {" << Jac(4, 6) / Pm(3) <<
" " << Jac(5, 6) / Pm(3) <<
" " << Jac(1, 6) <<
" " << Jac(2, 6) <<
"}";
2573 <<
"Jac(,a3){" << Jac(1, 6) <<
" " << Jac(2, 6) <<
" " << Jac(3, 6) <<
" " << Jac(4, 6) <<
" " << Jac(5, 6)
2574 <<
" " << Jac(6, 6);
2576 if (GNorm.
z() > 0.95)
2578 else if (GNorm.
z() < -0.95)
2583 <<
" JacCLo(i," <<
i <<
") = {" << JacCorLoc(1,
i) <<
" " << JacCorLoc(2,
i) <<
" " << JacCorLoc(3,
i) <<
" " 2584 << JacCorLoc(4,
i) <<
"}";
2588 <<
" Pm,l " << Pm.T() <<
" " << Pml(1) / Pml(3) <<
" " << Pml(2) / Pml(3);
2590 <<
" Pt,l " << Pt.T() <<
" " << Ptl(1) / Ptl(3) <<
" " << Ptl(2) / Ptl(3);
2595 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" JacToLoc " << JacToLoc;
2598 #ifdef CHECK_OF_JACOBIAN_CARTESIAN_TO_LOCAL 2600 CLHEP::HepVector V0(4, 0);
2601 V0(1) = Pml(1) / Pml(3) - Ptl(1) / Ptl(3);
2602 V0(2) = Pml(2) / Pml(3) - Ptl(2) / Ptl(3);
2603 V0(3) = Rml(1) - Rtl(1);
2604 V0(4) = Rml(2) - Rtl(2);
2607 CLHEP::HepVector V1(4, 0);
2610 Rml = rotLoc * (Rm -
R0);
2617 V1(1) = Pml(1) / Pml(3) - Ptl(1) / Ptl(3);
2618 V1(2) = Pml(2) / Pml(3) - Ptl(2) / Ptl(3);
2619 V1(3) = Rml(1) - Rtl(1);
2620 V1(4) = Rml(2) - Rtl(2);
2622 if (GNorm.
z() > 0.95)
2624 else if (GNorm.
z() < -0.95)
2629 <<
" dldc Num (i," <<
ii <<
") " << (V1(1) - V0(1)) /
delta <<
" " << (V1(2) - V0(2)) /
delta <<
" " 2630 << (V1(3) - V0(3)) /
delta <<
" " << (V1(4) - V0(4)) /
delta;
2631 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" dldc Ana (i," <<
ii <<
") " << JacToLoc(1,
ii) <<
" " 2632 << JacToLoc(2,
ii) <<
" " << JacToLoc(3,
ii) <<
" " << JacToLoc(4,
ii);
2633 float dtxdpx = (rotLoc(1, 1) - rotLoc(3, 1) * Pml(1) / Pml(3)) / Pml(3);
2634 float dtydpx = (rotLoc(2, 1) - rotLoc(3, 2) * Pml(2) / Pml(3)) / Pml(3);
2635 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" dtx/dpx dty/ " << dtxdpx <<
" " << dtydpx;
2644 CLHEP::HepVector
d(3, 0),
a(3, 0), Norm(3), Rm0(3), Pm0(3), Rm1(3), Pm1(3), Rmi(3), Pmi(3);
2666 if ((
d(1) == 0.) && (
d(2) == 0.) && (
d(3) == 0.) && (
a(1) == 0.) && (
a(2) == 0.) && (
a(3) == 0.)) {
2670 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ...... without misalignment ";
2684 CLHEP::HepMatrix
T(3, 3, 1);
2694 T(1, 2) =
c1 * s3 + s1 * s2 * c3;
2695 T(1, 3) = s1 * s3 -
c1 * s2 * c3;
2697 T(2, 2) =
c1 * c3 - s1 * s2 * s3;
2698 T(2, 3) = s1 * c3 +
c1 * s2 * s3;
2705 CLHEP::HepMatrix Ti =
T.T();
2706 CLHEP::HepVector di = -Ti *
d;
2708 CLHEP::HepVector ex0(3, 0), ey0(3, 0), ez0(3, 0), ex(3, 0), ey(3, 0), ez(3, 0);
2716 CLHEP::HepVector TiN = Ti * Norm;
2722 Rm1(1) =
CLHEP_dot(ex, Rm0 + si * Pm0 - di);
2723 Rm1(2) =
CLHEP_dot(ey, Rm0 + si * Pm0 - di);
2724 Rm1(3) =
CLHEP_dot(ez, Rm0 + si * Pm0 - di);
2735 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" Ti*T*Pm0 " << (Ti * (
T * Pm0)).T();
2738 CLHEP::HepVector Rml = Rm1(1) * ex + Rm1(2) * ey + Rm1(3) * ez + di;
2740 CLHEP::HepVector Rt0(3);
2747 CLHEP::HepVector Rl = Rml + sl * (Ti * Pm1);
2755 CLHEP::HepVector Dr = Ti * Rm1 - Ti *
d +
s * (Ti * Pm1) - Rm0;
2756 CLHEP::HepVector Dp = Ti * Pm1 - Pm0;
2758 CLHEP::HepVector TiR = Ti * Rm0 + di;
2759 CLHEP::HepVector Ri =
T * TiR +
d;
2761 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" --TTi-0 " << (Ri - Rm0).
T();
2768 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" ---- Ti ---- " << Ti;
2769 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" ---- d ---- " <<
d.T();
2770 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" ---- di ---- " << di.T();
2771 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" -- si sl s " << si <<
" " << sl <<
" " <<
s;
2772 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- si sl " << si <<
" " << sl;
2773 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- si s " << si <<
" " <<
s;
2774 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" -- Rml-(Rm0+si*Pm0) " << (Rml - Rm0 - si * Pm0).
T();
2775 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- Rm0 " << Rm0.T();
2776 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- Rm1 " << Rm1.T();
2777 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- Rmi " << Rmi.T();
2778 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --siPm " << (si * Pm0).
T();
2779 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --s2Pm " << (s2 * (
T * Pm1)).T();
2780 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --R1-0 " << (Rm1 - Rm0).
T();
2781 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --Ri-0 " << (Rmi - Rm0).
T();
2783 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --Pi-0 " << (Pmi - Pm0).
T();
2800 CLHEP::HepVector
d(3, 0),
a(3, 0), Norm(3), Rm0(3), Pm0(3), Rm1(3), Pm1(3), Rmi(3), Pmi(3);
2824 if ((
d(1) == 0.) && (
d(2) == 0.) && (
d(3) == 0.) && (
a(1) == 0.) && (
a(2) == 0.) && (
a(3) == 0.)) {
2833 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ...... without misalignment ";
2847 CLHEP::HepMatrix
T(3, 3, 1);
2857 T(1, 2) =
c1 * s3 + s1 * s2 * c3;
2858 T(1, 3) = s1 * s3 -
c1 * s2 * c3;
2860 T(2, 2) =
c1 * c3 - s1 * s2 * s3;
2861 T(2, 3) = s1 * c3 +
c1 * s2 * s3;
2869 CLHEP::HepMatrix Ti =
T.T();
2870 CLHEP::HepVector di = -Ti *
d;
2872 CLHEP::HepVector ex0(3, 0), ey0(3, 0), ez0(3, 0), ex(3, 0), ey(3, 0), ez(3, 0);
2880 CLHEP::HepVector TiN = Ti * Norm;
2886 Rm1(1) =
CLHEP_dot(ex, Rm0 + si * Pm0 - di);
2887 Rm1(2) =
CLHEP_dot(ey, Rm0 + si * Pm0 - di);
2888 Rm1(3) =
CLHEP_dot(ez, Rm0 + si * Pm0 - di);
2898 CLHEP::HepMatrix Tl(3, 3, 0);
2912 CLHEP::HepVector
R0(3, 0), newR0(3, 0), newRl(3, 0), newPl(3, 0);
2917 newRl = Tl * (Rm1 -
R0);
2920 Vm(0) = newPl(1) / newPl(3);
2921 Vm(1) = newPl(2) / newPl(3);
2925 #ifdef CHECK_DERIVATIVES_LOCAL_VS_ANGLES 2933 CLHEP::HepVector Rm10 = Rm1, Pm10 = Pm1;
2935 CLHEP::HepMatrix newTl = Tl *
T;
2943 Rm1(1) =
CLHEP_dot(ex, Rm0 + si * Pm0 - di);
2944 Rm1(2) =
CLHEP_dot(ey, Rm0 + si * Pm0 - di);
2945 Rm1(3) =
CLHEP_dot(ez, Rm0 + si * Pm0 - di);
2948 newRl = Tl * (Rm1 -
R0);
2951 Vm(0) = newPl(1) / newPl(3);
2952 Vm(1) = newPl(2) / newPl(3);
2955 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ========= dVm/da" <<
ii <<
" " << (Vm - Vm0) * (1. / del);
2958 <<
" dRm/da3 " << ((Rm1 - Rm10) * (1. / del)).
T() <<
" " << ((Pm1 - Pm10) * (1. / del)).
T();
2962 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" Norm " << Norm.T();
2967 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" pxyz/p gl 0 " << (Pm0 / Pm0.norm()).
T();
2968 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" pxyz/p loc0 " << (Tl * Pm0 / (Tl * Pm0).norm()).
T();
2969 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" pxyz/p glob " << (Pm1 / Pm1.norm()).
T();
2970 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" pxyz/p loc " << (newPl / newPl.norm()).
T();
2975 <<
" ---- phi g0 g1 l0 l1 " << atan2(Pm0(2), Pm0(1)) <<
" " << atan2(Pm1(2), Pm1(1)) <<
" " 2976 << atan2((Tl * Pm0)(2), (Tl * Pm0)(1)) <<
" " << atan2(newPl(2), newPl(1));
2978 <<
" ---- angl Gl Loc " << atan2(Pm1(2), Pm1(1)) - atan2(Pm0(2), Pm0(1)) <<
" " 2979 << atan2(newPl(2), newPl(1)) - atan2((Tl * Pm0)(2), (Tl * Pm0)(1)) <<
" " 2980 << atan2(newPl(3), newPl(2)) - atan2((Tl * Pm0)(3), (Tl * Pm0)(2)) <<
" " 2981 << atan2(newPl(1), newPl(3)) - atan2((Tl * Pm0)(1), (Tl * Pm0)(3)) <<
" ";
2985 CLHEP::HepMatrix newTl(3, 3, 0);
2986 CLHEP::HepVector
R0(3, 0), newRl(3, 0), newPl(3, 0);
2987 newTl = Tl * Ti.T();
2988 newR0 = Ti *
R0 + di;
2998 CLHEP::HepVector Rvc(3, 0), Pvc(3, 0), Rvg(3, 0), Pvg(3, 0);
3002 Pvc(1) = Pvc(3) * Vm(0);
3003 Pvc(2) = Pvc(3) * Vm(1);
3005 Rvg = newTl.T() * Rvc + newR0;
3006 Pvg = newTl.T() * Pvc;
3020 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" Ti*T*Pm0 " << (Ti * (
T * Pm0)).T();
3023 CLHEP::HepVector Rml = Rm1(1) * ex + Rm1(2) * ey + Rm1(3) * ez + di;
3025 CLHEP::HepVector Rt0(3);
3032 CLHEP::HepVector Rl = Rml + sl * (Ti * Pm1);
3040 CLHEP::HepVector Dr = Ti * Rm1 - Ti *
d +
s * (Ti * Pm1) - Rm0;
3041 CLHEP::HepVector Dp = Ti * Pm1 - Pm0;
3043 CLHEP::HepVector TiR = Ti * Rm0 + di;
3044 CLHEP::HepVector Ri =
T * TiR +
d;
3046 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" --TTi-0 " << (Ri - Rm0).
T();
3053 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" ---- Ti ---- " << Ti;
3054 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" ---- d ---- " <<
d.T();
3055 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" ---- di ---- " << di.T();
3056 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" -- si sl s " << si <<
" " << sl <<
" " <<
s;
3057 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- si sl " << si <<
" " << sl;
3058 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- si s " << si <<
" " <<
s;
3059 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" -- Rml-(Rm0+si*Pm0) " << (Rml - Rm0 - si * Pm0).
T();
3060 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- Rm0 " << Rm0.T();
3061 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- Rm1 " << Rm1.T();
3062 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- Rmi " << Rmi.T();
3063 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --siPm " << (si * Pm0).
T();
3064 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --s2Pm " << (s2 * (
T * Pm1)).T();
3065 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --R1-0 " << (Rm1 - Rm0).
T();
3066 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --Ri-0 " << (Rmi - Rm0).
T();
3068 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --Pi-0 " << (Pmi - Pm0).
T();
3081 bool smooth =
false;
3084 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ......... start of trackFitter ......... ";
3085 if (
false &&
info) {
3087 this->
debugTrackHit(
" Tracker TransientTrack hits ", alongTTr);
3091 DetId trackDetId =
DetId(alongTr->innerDetId());
3092 for (
auto const&
hit : alongTr->recHits())
3097 for (
unsigned int ihit = recHitAlong.
size() - 1; ihit + 1 > 0; ihit--) {
3098 recHit.push_back(recHitAlong[ihit]);
3100 recHitAlong.
clear();
3104 <<
" ... Own recHit.size() " <<
recHit.size() <<
" " << trackDetId.
rawId();
3108 for (
auto const&
hit : alongTr->recHits())
3113 <<
" ... recHitTrack.size() " <<
recHit.size() <<
" " << trackDetId.
rawId() <<
" ======> recHitMu ";
3121 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ...along.... recHitMu.size() " << recHitMu.size();
3125 for (
unsigned int ihit = recHitMuAlong.size() - 1; ihit + 1 > 0; ihit--) {
3126 recHitMu.push_back(recHitMuAlong[ihit]);
3128 recHitMuAlong.clear();
3131 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ...opposite... recHitMu.size() " << recHitMu.size();
3152 std::vector<Trajectory> trajVec;
3154 trajVec =
theFitter->fit(seedT, recHitMu, initialTSOS);
3156 trajVec =
theFitterOp->fit(seedT, recHitMu, initialTSOS);
3162 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" . . . . . trajVec.size() " << trajVec.size();
3163 if (!trajVec.empty())
3168 if (!trajVec.empty())
3169 trackFittedTSOS = trajVec[0].lastMeasurement().updatedState();
3171 std::vector<Trajectory> trajSVec;
3172 if (!trajVec.empty()) {
3179 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" . . . . trajSVec.size() " << trajSVec.size();
3180 if (!trajSVec.empty())
3181 this->
debugTrajectorySOSv(
"smoothed geom InnermostState", trajSVec[0].geometricalInnermostState());
3182 if (!trajSVec.empty())
3183 trackFittedTSOS = trajSVec[0].geometricalInnermostState();
3197 bool smooth =
false;
3200 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ......... start of muonFitter ........";
3201 if (
false &&
info) {
3203 this->
debugTrackHit(
" Muon TransientTrack hits ", alongTTr);
3207 DetId trackDetId =
DetId(alongTr->innerDetId());
3208 for (
auto const&
hit : alongTr->recHits())
3213 for (
unsigned int ihit = recHitAlong.
size() - 1; ihit + 1 > 0; ihit--) {
3214 recHit.push_back(recHitAlong[ihit]);
3216 recHitAlong.
clear();
3220 <<
" ... Own recHit.size() DetId==Muon " <<
recHit.size() <<
" " << trackDetId.
rawId();
3225 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ...along.... recHitMu.size() " << recHitMu.size();
3229 for (
unsigned int ihit = recHitMuAlong.size() - 1; ihit + 1 > 0; ihit--) {
3230 recHitMu.push_back(recHitMuAlong[ihit]);
3232 recHitMuAlong.clear();
3235 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ...opposite... recHitMu.size() " << recHitMu.size();
3256 std::vector<Trajectory> trajVec;
3258 trajVec =
theFitter->fit(seedT, recHitMu, initialTSOS);
3260 trajVec =
theFitterOp->fit(seedT, recHitMu, initialTSOS);
3266 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" . . . . . trajVec.size() " << trajVec.size();
3267 if (!trajVec.empty())
3272 if (!trajVec.empty())
3273 trackFittedTSOS = trajVec[0].lastMeasurement().updatedState();
3275 std::vector<Trajectory> trajSVec;
3276 if (!trajVec.empty()) {
3283 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" . . . . trajSVec.size() " << trajSVec.size();
3284 if (!trajSVec.empty())
3285 this->
debugTrajectorySOSv(
"smoothed geom InnermostState", trajSVec[0].geometricalInnermostState());
3286 if (!trajSVec.empty())
3287 trackFittedTSOS = trajSVec[0].geometricalInnermostState();
3297 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Hit " << nHit++ <<
" DetId " << (*i)->geographicalId().det();
3300 else if ((*i)->geographicalId().det() ==
DetId::Muon)
3304 if (!(*i)->isValid())
3315 for (
auto const&
hit : alongTr->recHits()) {
3316 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Hit " << nHit++ <<
" DetId " <<
hit->geographicalId().det();
3323 if (!
hit->isValid())
3391 <<
" ...... " <<
title <<
" ...... ";
3400 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" oppositeToMomentum <<<<";
3405 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" . . . . . . . . . . . . . . . . . . . . . . . . . . . . \n";
3421 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" paramVector " << paramVec.T();
3423 CLHEP::Hep3Vector colX, colY, colZ;
3425 #ifdef NOT_EXACT_ROTATION_MATRIX 3426 colX = CLHEP::Hep3Vector(1., -paramVec(6), paramVec(5));
3427 colY = CLHEP::Hep3Vector(paramVec(6), 1., -paramVec(4));
3428 colZ = CLHEP::Hep3Vector(-paramVec(5), paramVec(4), 1.);
3433 colX = CLHEP::Hep3Vector(c2 * c3, -c2 * s3, s2);
3434 colY = CLHEP::Hep3Vector(
c1 * s3 + s1 * s2 * c3,
c1 * c3 - s1 * s2 * s3, -s1 * c2);
3435 colZ = CLHEP::Hep3Vector(s1 * s3 -
c1 * s2 * c3, s1 * c3 +
c1 * s2 * s3,
c1 * c2);
3438 CLHEP::HepVector param0(6, 0);
3448 CLHEP::HepEulerAngles angMuGlRcd =
iteratorMuonRcd->rotation().eulerAngles();
3451 <<
" Old muon Rcd Euler angles " << angMuGlRcd.phi() <<
" " << angMuGlRcd.theta() <<
" " << angMuGlRcd.psi();
3453 if ((angMuGlRcd.phi() == 0.) && (angMuGlRcd.theta() == 0.) && (angMuGlRcd.psi() == 0.) && (posMuGlRcd.x() == 0.) &&
3454 (posMuGlRcd.y() == 0.) && (posMuGlRcd.z() == 0.)) {
3455 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" New muon parameters are stored in Rcd";
3461 }
else if ((paramVec(1) == 0.) && (paramVec(2) == 0.) && (paramVec(3) == 0.) && (paramVec(4) == 0.) &&
3462 (paramVec(5) == 0.) && (paramVec(6) == 0.)) {
3463 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Old muon parameters are stored in Rcd";
3468 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" New + Old muon parameters are stored in Rcd";
3469 CLHEP::Hep3Vector posMuGlRcdThis = CLHEP::Hep3Vector(paramVec(1), paramVec(2), paramVec(3));
3470 CLHEP::HepRotation rotMuGlRcdThis = CLHEP::HepRotation(colX, colY, colZ);
3471 CLHEP::Hep3Vector posMuGlRcdNew = rotMuGlRcdThis * posMuGlRcd + posMuGlRcdThis;
3472 CLHEP::HepRotation rotMuGlRcdNew = rotMuGlRcdThis * rotMuGlRcd;
3488 <<
"Tracker (" <<
tracker.rawId() <<
") at " <<
tracker.translation() <<
" " <<
tracker.rotation().eulerAngles();
3492 <<
"Muon (" <<
muon.rawId() <<
") at " <<
muon.translation() <<
" " <<
muon.rotation().eulerAngles();
3494 <<
" rotations angles around x,y,z " 3495 <<
" ( " << -
muon.rotation().zy() <<
" " <<
muon.rotation().zx() <<
" " << -
muon.rotation().yx() <<
" )";
3499 <<
"Ecal (" <<
ecal.rawId() <<
") at " <<
ecal.translation() <<
" " <<
ecal.rotation().eulerAngles();
3503 <<
"Hcal (" <<
hcal.rawId() <<
") at " <<
hcal.translation() <<
" " <<
hcal.rotation().eulerAngles();
3507 <<
"Calo (" <<
calo.rawId() <<
") at " <<
calo.translation() <<
" " <<
calo.rotation().eulerAngles();
3510 globalPositions.m_align.push_back(
tracker);
3511 globalPositions.m_align.push_back(
muon);
3512 globalPositions.m_align.push_back(
ecal);
3513 globalPositions.m_align.push_back(
hcal);
3514 globalPositions.m_align.push_back(
calo);
3516 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
"Uploading to the database...";
3521 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_
Log< level::Info, true > LogVerbatim
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)
const edm::InputTag gmuonTags_
const edm::EDGetTokenT< reco::MuonCollection > smuonIsolateToken_
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 edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > m_ttrhBuilderToken
const LocalTrajectoryError & localError() const
virtual ConstReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
const edm::InputTag muonTags_
trackingRecHit_iterator recHitsEnd() const
last iterator to RecHits
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
const edm::EDGetTokenT< reco::MuonCollection > smuonToken_
Sin< T >::type sin(const T &t)
const edm::EDGetTokenT< reco::TrackCollection > gmuonCosmicToken_
KFTrajectoryFitter * theFitter
const GlobalTrajectoryParameters & globalParameters() const
std::vector< Track > TrackCollection
collection of Tracks
const edm::ESGetToken< Alignments, GlobalPositionRcd > m_globalPosToken
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 edm::EDGetTokenT< reco::TrackCollection > gmuonIsolateToken_
const LocalTrajectoryParameters & localParameters() const
const edm::EDGetTokenT< reco::TrackCollection > gmuonToken_
trackingRecHit_iterator recHitsBegin() const
first iterator to RecHits
const SurfaceType & surface() const
void gradientGlobal(GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, GlobalVector &, AlgebraicSymMatrix66 &)
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
std::vector< AlignTransform > m_align
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
TrajectoryMeasurement const & lastMeasurement() const
const edm::ESGetToken< Propagator, TrackingComponentsRecord > m_propToken
const CartesianTrajectoryError cartesianError() const
std::vector< Muon > MuonCollection
collection of Muon objects
const edm::InputTag smuonTags_
RecordProviders::iterator Itr
const edm::InputTag trackTags_
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
const edm::EDGetTokenT< reco::TrackCollection > muonToken_
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
const edm::EDGetTokenT< reco::TrackCollection > trackToken_
const edm::EDGetTokenT< reco::TrackCollection > trackCosmicToken_
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
const edm::EDGetTokenT< reco::TrackCollection > muonIsolateToken_
const std::string rootOutFile_
void trackFitter(reco::TrackRef, reco::TransientTrack &, PropagationDirection, TrajectoryStateOnSurface &)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
KFTrajectorySmoother * theSmoother
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const PositionType & position() const
constexpr uint32_t rawId() const
get the raw id
const Alignments * globalPositionRcd_
const TransientTrackingRecHitBuilder * TTRHBuilder
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ESWatcher< IdealMagneticFieldRecord > watchMagneticFieldRecord_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
GlobalVector globalMomentum() const
bool check(const edm::EventSetup &iSetup)
TrajectoryStateOnSurface const & updatedState() const
const std::string propagator_
const edm::EDGetTokenT< reco::MuonCollection > smuonCosmicToken_
TrajectoryMeasurement const & firstMeasurement() const
void debugTrajectory(const std::string, Trajectory &)
const AlgebraicSymMatrix55 & matrix() const
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_MagFieldToken
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 edm::EDGetTokenT< reco::TrackCollection > trackIsolateToken_
const std::string txtOutFile_
const RotationType & rotation() const
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > m_TkGeometryToken
edm::ESWatcher< TrackingComponentsRecord > watchTrackingComponentsRecord_
void analyzeTrackTrack(const edm::Event &, const edm::EventSetup &)
const edm::EDGetTokenT< reco::TrackCollection > muonCosmicToken_
void muonFitter(reco::TrackRef, reco::TransientTrack &, PropagationDirection, TrajectoryStateOnSurface &)
MuonTransientTrackingRecHitBuilder * MuRHBuilder
Global3DVector GlobalVector
CLHEP::HepVector MuGlShift
void debugTrajectorySOS(const std::string, TrajectoryStateOnSurface &)