103 using namespace reco;
133 CLHEP::HepSymMatrix&,
148 void writeGlPosRcd(CLHEP::HepVector& d3);
149 inline double CLHEP_dot(
const CLHEP::HepVector&
a,
const CLHEP::HepVector&
b) {
150 return a(1) *
b(1) +
a(2) *
b(2) +
a(3) *
b(3);
156 void endJob()
override;
227 std::vector<AlignTransform>::const_iterator
297 trackTags_(iConfig.getParameter<
edm::
InputTag>(
"tracks")),
298 muonTags_(iConfig.getParameter<
edm::
InputTag>(
"muons")),
299 gmuonTags_(iConfig.getParameter<
edm::
InputTag>(
"gmuons")),
300 smuonTags_(iConfig.getParameter<
edm::
InputTag>(
"smuons")),
301 cosmicMuonMode_(iConfig.getParameter<
bool>(
"cosmics")),
302 isolatedMuonMode_(iConfig.getParameter<
bool>(
"isolated")),
303 refitMuon_(iConfig.getParameter<
bool>(
"refitmuon")),
304 refitTrack_(iConfig.getParameter<
bool>(
"refittrack")),
305 rootOutFile_(iConfig.getUntrackedParameter<
string>(
"rootOutFile")),
306 txtOutFile_(iConfig.getUntrackedParameter<
string>(
"txtOutFile")),
307 writeDB_(iConfig.getUntrackedParameter<
bool>(
"writeDB")),
308 debug_(iConfig.getUntrackedParameter<
bool>(
"debug")),
326 #ifdef NO_FALSE_FALSE_MODE 329 <<
"Use from GlobalTrackerMuonAlignment_test_cfg.py.";
333 throw cms::Exception(
"BadConfig") <<
"Muon collection can be either cosmic or isolated! " 334 <<
"Please set only one to true.";
345 desc.add<
bool>(
"isolated",
false);
346 desc.add<
bool>(
"cosmics",
false);
347 desc.add<
bool>(
"refitmuon",
false);
348 desc.add<
bool>(
"refittrack",
false);
351 desc.addUntracked<
bool>(
"writeDB",
false);
352 desc.addUntracked<
bool>(
"debug",
false);
353 descriptions.
add(
"globalTrackerMuonAlignment",
desc);
381 for (
int i = 0;
i <= 2;
i++) {
383 for (
int j = 0;
j <= 2;
j++) {
388 Grad = CLHEP::HepVector(6, 0);
389 Hess = CLHEP::HepSymMatrix(6, 0);
391 GradL = CLHEP::HepVector(6, 0);
392 HessL = CLHEP::HepSymMatrix(6, 0);
395 TDirectory* dirsave = gDirectory;
398 const bool oldAddDir = TH1::AddDirectoryStatus();
400 TH1::AddDirectory(
true);
404 TH1::AddDirectory(oldAddDir);
417 for (
int i = 0;
i <= 2;
i++)
418 for (
int j = 0;
j <= 2;
j++) {
423 bool ierr = !InfI.Invert();
426 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Error inverse Inf matrix !!!!!!!!!!!";
429 for (
int i = 0;
i <= 2;
i++)
430 for (
int k = 0;
k <= 2;
k++)
435 CLHEP::HepVector d3 = CLHEP::solve(
Hess, -
Grad);
437 CLHEP::HepMatrix Errd3 =
Hess.inverse(iEr3);
440 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" endJob Error inverse Hess matrix !!!!!!!!!!!";
445 CLHEP::HepVector dLI = CLHEP::solve(
HessL, -
GradL);
447 CLHEP::HepMatrix ErrdLI =
HessL.inverse(iErI);
450 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" endJob Error inverse HessL matrix !!!!!!!!!!!";
458 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ALCARECOMuAlCalIsolatedMu";
460 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ALCARECOMuAlGlobalCosmics";
471 <<
" dG " << d3(1) <<
" " << d3(2) <<
" " << d3(3) <<
" " << d3(4) <<
" " << d3(5) <<
" " << d3(6);
477 <<
" dL " << dLI(1) <<
" " << dLI(2) <<
" " << dLI(3) <<
" " << dLI(4) <<
" " << dLI(5) <<
" " << dLI(6);
484 CLHEP::HepVector vectorToDb(6, 0), vectorErrToDb(6, 0);
488 for (
unsigned int i = 1;
i <= 6;
i++)
498 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" outglobal.txt is not open !!!!!";
500 OutGlobalTxt << vectorToDb(1) <<
" " << vectorToDb(2) <<
" " << vectorToDb(3) <<
" " << vectorToDb(4) <<
" " 501 << vectorToDb(5) <<
" " << vectorToDb(6) <<
" muon Global.\n";
502 OutGlobalTxt << vectorErrToDb(1) <<
" " << vectorErrToDb(1) <<
" " << vectorErrToDb(1) <<
" " << vectorErrToDb(1)
503 <<
" " << vectorErrToDb(1) <<
" " << vectorErrToDb(1) <<
" errors.\n";
513 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Write to the file outglobal.txt done ";
525 double PI = 3.1415927;
526 histo =
new TH1F(
"Pt",
"pt", 1000, 0, 100);
527 histo2 =
new TH1F(
"P",
"P [GeV/c]", 400, 0., 400.);
528 histo2->GetXaxis()->SetTitle(
"momentum [GeV/c]");
529 histo3 =
new TH1F(
"outerLambda",
"#lambda outer", 100, -
PI / 2.,
PI / 2.);
530 histo3->GetXaxis()->SetTitle(
"#lambda outer");
531 histo4 =
new TH1F(
"phi",
"#phi [rad]", 100, -
PI,
PI);
532 histo4->GetXaxis()->SetTitle(
"#phi [rad]");
533 histo5 =
new TH1F(
"Rmuon",
"inner muon hit R [cm]", 100, 0., 800.);
534 histo5->GetXaxis()->SetTitle(
"R of muon [cm]");
535 histo6 =
new TH1F(
"Zmuon",
"inner muon hit Z[cm]", 100, -1000., 1000.);
536 histo6->GetXaxis()->SetTitle(
"Z of muon [cm]");
537 histo7 =
new TH1F(
"(Pm-Pt)/Pt",
" (Pmuon-Ptrack)/Ptrack", 100, -2., 2.);
538 histo7->GetXaxis()->SetTitle(
"(Pmuon-Ptrack)/Ptrack");
539 histo8 =
new TH1F(
"chi muon-track",
"#chi^{2}(muon-track)", 1000, 0., 1000.);
540 histo8->GetXaxis()->SetTitle(
"#chi^{2} of muon w.r.t. propagated track");
541 histo11 =
new TH1F(
"distance muon-track",
"distance muon w.r.t track [cm]", 100, 0., 30.);
542 histo11->GetXaxis()->SetTitle(
"distance of muon w.r.t. track [cm]");
543 histo12 =
new TH1F(
"Xmuon-Xtrack",
"Xmuon-Xtrack [cm]", 200, -20., 20.);
544 histo12->GetXaxis()->SetTitle(
"Xmuon - Xtrack [cm]");
545 histo13 =
new TH1F(
"Ymuon-Ytrack",
"Ymuon-Ytrack [cm]", 200, -20., 20.);
546 histo13->GetXaxis()->SetTitle(
"Ymuon - Ytrack [cm]");
547 histo14 =
new TH1F(
"Zmuon-Ztrack",
"Zmuon-Ztrack [cm]", 200, -20., 20.);
548 histo14->GetXaxis()->SetTitle(
"Zmuon-Ztrack [cm]");
549 histo15 =
new TH1F(
"NXmuon-NXtrack",
"NXmuon-NXtrack [rad]", 200, -.1, .1);
550 histo15->GetXaxis()->SetTitle(
"N_{X}(muon)-N_{X}(track) [rad]");
551 histo16 =
new TH1F(
"NYmuon-NYtrack",
"NYmuon-NYtrack [rad]", 200, -.1, .1);
552 histo16->GetXaxis()->SetTitle(
"N_{Y}(muon)-N_{Y}(track) [rad]");
553 histo17 =
new TH1F(
"NZmuon-NZtrack",
"NZmuon-NZtrack [rad]", 200, -.1, .1);
554 histo17->GetXaxis()->SetTitle(
"N_{Z}(muon)-N_{Z}(track) [rad]");
555 histo18 =
new TH1F(
"expected error of Xinner",
"outer hit of inner tracker", 100, 0, .01);
556 histo18->GetXaxis()->SetTitle(
"expected error of Xinner [cm]");
557 histo19 =
new TH1F(
"expected error of Xmuon",
"inner hit of muon", 100, 0, .1);
558 histo19->GetXaxis()->SetTitle(
"expected error of Xmuon [cm]");
559 histo20 =
new TH1F(
"expected error of Xmuon-Xtrack",
"muon w.r.t. propagated track", 100, 0., 10.);
560 histo20->GetXaxis()->SetTitle(
"expected error of Xmuon-Xtrack [cm]");
561 histo21 =
new TH1F(
"pull of Xmuon-Xtrack",
"pull of Xmuon-Xtrack", 100, -10., 10.);
562 histo21->GetXaxis()->SetTitle(
"(Xmuon-Xtrack)/expected error");
563 histo22 =
new TH1F(
"pull of Ymuon-Ytrack",
"pull of Ymuon-Ytrack", 100, -10., 10.);
564 histo22->GetXaxis()->SetTitle(
"(Ymuon-Ytrack)/expected error");
565 histo23 =
new TH1F(
"pull of Zmuon-Ztrack",
"pull of Zmuon-Ztrack", 100, -10., 10.);
566 histo23->GetXaxis()->SetTitle(
"(Zmuon-Ztrack)/expected error");
567 histo24 =
new TH1F(
"pull of PXmuon-PXtrack",
"pull of PXmuon-PXtrack", 100, -10., 10.);
568 histo24->GetXaxis()->SetTitle(
"(P_{X}(muon)-P_{X}(track))/expected error");
569 histo25 =
new TH1F(
"pull of PYmuon-PYtrack",
"pull of PYmuon-PYtrack", 100, -10., 10.);
570 histo25->GetXaxis()->SetTitle(
"(P_{Y}(muon)-P_{Y}(track))/expected error");
571 histo26 =
new TH1F(
"pull of PZmuon-PZtrack",
"pull of PZmuon-PZtrack", 100, -10., 10.);
572 histo26->GetXaxis()->SetTitle(
"(P_{Z}(muon)-P_{Z}(track))/expected error");
573 histo27 =
new TH1F(
"N_x",
"Nx of tangent plane", 120, -1.1, 1.1);
574 histo27->GetXaxis()->SetTitle(
"normal vector projection N_{X}");
575 histo28 =
new TH1F(
"N_y",
"Ny of tangent plane", 120, -1.1, 1.1);
576 histo28->GetXaxis()->SetTitle(
"normal vector projection N_{Y}");
577 histo29 =
new TH1F(
"lenght of track",
"lenght of track", 200, 0., 400);
578 histo29->GetXaxis()->SetTitle(
"lenght of track [cm]");
579 histo30 =
new TH1F(
"lenght of muon",
"lenght of muon", 200, 0., 800);
580 histo30->GetXaxis()->SetTitle(
"lenght of muon [cm]");
582 histo31 =
new TH1F(
"local chi muon-track",
"#local chi^{2}(muon-track)", 1000, 0., 1000.);
583 histo31->GetXaxis()->SetTitle(
"#local chi^{2} of muon w.r.t. propagated track");
584 histo32 =
new TH1F(
"pull of Px/Pz local",
"pull of Px/Pz local", 100, -10., 10.);
585 histo32->GetXaxis()->SetTitle(
"local (Px/Pz(muon) - Px/Pz(track))/expected error");
586 histo33 =
new TH1F(
"pull of Py/Pz local",
"pull of Py/Pz local", 100, -10., 10.);
587 histo33->GetXaxis()->SetTitle(
"local (Py/Pz(muon) - Py/Pz(track))/expected error");
588 histo34 =
new TH1F(
"pull of X local",
"pull of X local", 100, -10., 10.);
589 histo34->GetXaxis()->SetTitle(
"local (Xmuon - Xtrack)/expected error");
590 histo35 =
new TH1F(
"pull of Y local",
"pull of Y local", 100, -10., 10.);
591 histo35->GetXaxis()->SetTitle(
"local (Ymuon - Ytrack)/expected error");
593 histo101 =
new TH2F(
"Rtr/mu vs Ztr/mu",
"hit of track/muon", 100, -800., 800., 100, 0., 600.);
594 histo101->GetXaxis()->SetTitle(
"Z of track/muon [cm]");
595 histo101->GetYaxis()->SetTitle(
"R of track/muon [cm]");
596 histo102 =
new TH2F(
"Ytr/mu vs Xtr/mu",
"hit of track/muon", 100, -600., 600., 100, -600., 600.);
597 histo102->GetXaxis()->SetTitle(
"X of track/muon [cm]");
598 histo102->GetYaxis()->SetTitle(
"Y of track/muon [cm]");
628 using namespace reco;
633 double PI = 3.1415927;
647 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" treated as IsolatedMu ";
669 <<
" ievBunch " <<
iEvent.bunchCrossing() <<
" runN " << (
int)
iEvent.run();
671 <<
muons->size() <<
" " << gmuons->size() <<
" " << smuons->size();
672 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
674 <<
" is isolatValid Matches " << itMuon->isIsolationValid() <<
" " << itMuon->isMatchesValid();
681 if (
muons->size() != 1)
683 if (gmuons->size() != 1)
685 if (smuons->size() != 1)
690 if (smuons->size() > 2)
692 if (
tracks->size() != smuons->size())
694 if (
muons->size() != smuons->size())
696 if (gmuons->size() != smuons->size())
761 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
764 <<
" mu gM is GM Mu SaM tM " << itMuon->isGlobalMuon() <<
" " << itMuon->isMuon() <<
" " 765 << itMuon->isStandAloneMuon() <<
" " << itMuon->isTrackerMuon() <<
" ";
779 GlobalPoint pointTrackOut = outerTrackTSOS.globalPosition();
780 float lenghtTrack = (pointTrackOut - pointTrackIn).
mag();
781 GlobalPoint pointMuonIn = innerMuTSOS.globalPosition();
783 float lenghtMuon = (pointMuonOut - pointMuonIn).
mag();
784 GlobalVector momentumTrackOut = outerTrackTSOS.globalMomentum();
786 float distanceInIn = (pointTrackIn - pointMuonIn).
mag();
787 float distanceInOut = (pointTrackIn - pointMuonOut).
mag();
788 float distanceOutIn = (pointTrackOut - pointMuonIn).
mag();
789 float distanceOutOut = (pointTrackOut - pointMuonOut).
mag();
792 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" pointTrackIn " << pointTrackIn;
793 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Out " << pointTrackOut <<
" lenght " << lenghtTrack;
794 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" point MuonIn " << pointMuonIn;
795 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Out " << pointMuonOut <<
" lenght " << lenghtMuon;
797 <<
" momeTrackIn Out " << momentumTrackIn <<
" " << momentumTrackOut;
799 <<
" doi io ii oo " << distanceOutIn <<
" " << distanceInOut <<
" " << distanceInIn <<
" " << distanceOutOut;
802 if (lenghtTrack < 90.)
804 if (lenghtMuon < 300.)
806 if (momentumTrackIn.
mag() < 15. || momentumTrackOut.
mag() < 15.)
808 if (trackTT.charge() != muTT.charge())
812 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" passed lenght momentum cuts";
821 const Surface& refSurface = innerMuTSOS.surface();
823 Nl = tpMuLocal->normalVector();
827 const Plane* refPlane =
dynamic_cast<Plane*
>(surf);
831 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 832 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
833 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" global " << Ng.
x() <<
" " << Ng.
y() <<
" " << Ng.
z();
834 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" lp " << Nlp.
x() <<
" " << Nlp.
y() <<
" " << Nlp.
z();
836 <<
" Nlocal Nglobal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " << Ng.
x() <<
" " << Ng.
y() <<
" " 837 << Ng.
z() <<
" alfa " <<
static_cast<int>(asin(Nl.
x()) * 57.29578);
841 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
844 if (!extrapolationT.
isValid()) {
846 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 859 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
860 GPm = innerMuTSOS.globalMomentum();
862 (outerTrackTSOS.globalPosition()).
y(),
863 (outerTrackTSOS.globalPosition()).
z());
873 if ((distanceOutIn <= distanceInOut) & (distanceOutIn <= distanceInIn) &
874 (distanceOutIn <= distanceOutOut)) {
878 const Surface& refSurface = innerMuTSOS.surface();
880 Nl = tpMuGlobal->normalVector();
883 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
886 if (!extrapolationT.
isValid()) {
888 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 904 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
905 GPm = innerMuTSOS.globalMomentum();
907 (outerTrackTSOS.globalPosition()).
y(),
908 (outerTrackTSOS.globalPosition()).
z());
918 <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 919 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface));
921 <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 922 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
926 else if ((distanceInOut <= distanceInIn) & (distanceInOut <= distanceOutIn) &
927 (distanceInOut <= distanceOutOut)) {
933 Nl = tpMuGlobal->normalVector();
936 extrapolationT = oppositeSmPr.
propagate(innerTrackTSOS, refSurface);
938 if (!extrapolationT.
isValid()) {
940 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 941 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid();
969 <<
" propDirCh " << Chooser.operator()(*innerTrackTSOS.
freeState(), refSurface) <<
" Ch == oppisite " 972 <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 973 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
977 else if ((distanceOutOut <= distanceInOut) & (distanceOutOut <= distanceInIn) &
978 (distanceOutOut <= distanceOutIn)) {
987 Nl = tpMuGlobal->normalVector();
990 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
992 if (!extrapolationT.
isValid()) {
994 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-Out extrapolationT.isValid " 995 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid();
1012 (outerTrackTSOS.globalPosition()).
y(),
1013 (outerTrackTSOS.globalPosition()).
z());
1022 <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 1023 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface));
1025 <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1026 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1028 <<
" Nornal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1029 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1035 <<
" ------- !!!!!!!!!!!!!!! No proper Out - In \a\a\a\a\a\a\a";
1041 if (tsosMuonIf == 0) {
1048 if (tsosMuonIf == 1)
1049 tsosMuon = muTT.innermostMeasurementState();
1051 tsosMuon = muTT.outermostMeasurementState();
1060 float RelMomResidual = (Pm.
mag() - Pt.mag()) / (Pt.mag() + 1.e-6);
1070 float Rmuon = Rm.
perp();
1071 float Zmuon = Rm.
z();
1072 float alfa_x = atan2(Nl.
x(), Nl.
y()) * 57.29578;
1076 <<
" Nx Ny Nz alfa_x " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " << alfa_x;
1078 <<
" Rm " << Rm <<
"\n Rt " << Rt <<
"\n resR " << resR <<
"\n resP " << resP <<
" dp/p " << RelMomResidual;
1082 for (
int i = 0;
i <= 5;
i++)
1083 chi_d += Vm(
i) * Vm(
i) / Cm(
i,
i);
1088 bool ierrLoc = !
m.Invert();
1090 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ==== Error inverting Local covariance matrix ==== ";
1093 double chi_Loc = ROOT::Math::Similarity(Vml,
m);
1096 <<
" chi_Loc px/pz/err " << chi_Loc <<
" " << Vml(1) /
std::sqrt(Cml(1, 1));
1145 if (Rmuon < 120. || Rmuon > 450.)
1147 if (Zmuon < -720. || Zmuon > 720.)
1152 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" .............. passed all cuts";
1160 CLHEP::HepSymMatrix covLoc(4, 0);
1161 for (
int i = 1;
i <= 4;
i++)
1162 for (
int j = 1;
j <=
i;
j++) {
1168 CLHEP::HepMatrix rotLoc(3, 3, 0);
1181 CLHEP::HepVector posLoc(3);
1190 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" posLoc " << posLoc.T();
1195 histo->Fill(itMuon->track()->pt());
1199 histo3->Fill((
PI / 2. - itMuon->track()->outerTheta()));
1200 histo4->Fill(itMuon->track()->phi());
1203 histo7->Fill(RelMomResidual);
1213 if (fabs(Nl.
x()) < 0.98)
1215 if (fabs(Nl.
y()) < 0.98)
1217 if (fabs(Nl.
z()) < 0.98)
1223 if ((fabs(Nl.
x()) < 0.98) && (fabs(Nl.
y()) < 0.98) && (fabs(Nl.
z()) < 0.98)) {
1228 if (fabs(Nl.
x()) < 0.98)
1230 if (fabs(Nl.
y()) < 0.98)
1232 if (fabs(Nl.
z()) < 0.98)
1249 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag 0[ " << C0(0, 0) <<
" " << C0(1, 1) <<
" " << C0(2, 2)
1250 <<
" " << C0(3, 3) <<
" " << C0(4, 4) <<
" " << C0(5, 5) <<
" ]";
1251 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag e[ " << Ce(0, 0) <<
" " << Ce(1, 1) <<
" " << Ce(2, 2)
1252 <<
" " << Ce(3, 3) <<
" " << Ce(4, 4) <<
" " << Ce(5, 5) <<
" ]";
1253 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag 1[ " << C1(0, 0) <<
" " << C1(1, 1) <<
" " << C1(2, 2)
1254 <<
" " << C1(3, 3) <<
" " << C1(4, 4) <<
" " << C1(5, 5) <<
" ]";
1255 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Rm " << Rm.
x() <<
" " << Rm.
y() <<
" " << Rm.
z() <<
" Pm " 1256 << Pm.
x() <<
" " << Pm.
y() <<
" " << Pm.
z();
1257 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Rt " << Rt.x() <<
" " << Rt.y() <<
" " << Rt.z() <<
" Pt " 1258 << Pt.x() <<
" " << Pt.y() <<
" " << Pt.z();
1260 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" resR " << resR.
x() <<
" " << resR.
y() <<
" " << resR.
z()
1261 <<
" resP " << resP.
x() <<
" " << resP.
y() <<
" " << resP.
z();
1263 <<
" Rm-t " << (Rm - Rt).
x() <<
" " << (Rm - Rt).
y() <<
" " << (Rm - Rt).
z() <<
" Pm-t " << (Pm - Pt).
x()
1264 <<
" " << (Pm - Pt).
y() <<
" " << (Pm - Pt).
z();
1270 <<
" Pmuon Ptrack dP/Ptrack " << itMuon->outerTrack()->p() <<
" " << itMuon->track()->outerP() <<
" " 1271 << (itMuon->outerTrack()->p() - itMuon->track()->outerP()) / itMuon->track()->outerP();
1274 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag [ " << Cm(0, 0) <<
" " << Cm(1, 1) <<
" " << Cm(2, 2)
1275 <<
" " << Cm(3, 3) <<
" " << Cm(4, 4) <<
" " << Cm(5, 5) <<
" ]";
1279 for (
int i = 0;
i <= 5;
i++)
1281 for (
int i = 0;
i <= 5;
i++)
1282 for (
int j = 0;
j <= 5;
j++)
1283 Ro(
i,
j) = Cm(
i,
j) / Diag[
i] / Diag[
j];
1288 for (
int i = 0;
i <= 5;
i++)
1289 for (
int j = 0;
j <= 5;
j++)
1290 CmI(
i,
j) = Cm(
i,
j);
1292 bool ierr = !CmI.Invert();
1295 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Error inverse covariance matrix !!!!!!!!!!!";
1301 double chi = ROOT::Math::Similarity(Vm, CmI);
1302 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" chi chi_d " << chi <<
" " << chi_d;
1311 using namespace edm;
1312 using namespace reco;
1317 double PI = 3.1415927;
1331 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" treated as IsolatedMu ";
1353 <<
" ievBunch " <<
iEvent.bunchCrossing() <<
" runN " << (
int)
iEvent.run();
1355 <<
muons->size() <<
" " << gmuons->size() <<
" " << smuons->size();
1356 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
1358 <<
" is isolatValid Matches " << itMuon->isIsolationValid() <<
" " << itMuon->isMatchesValid();
1365 if (
muons->size() != 1)
1367 if (gmuons->size() != 1)
1369 if (smuons->size() != 1)
1374 if (smuons->size() > 2)
1376 if (
tracks->size() != smuons->size())
1378 if (
muons->size() != smuons->size())
1380 if (gmuons->size() != smuons->size())
1451 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ............... DEFINE FITTER ...................";
1455 theFitter =
new KFTrajectoryFitter(alongSmPr, *theUpdator, *theEstimator);
1457 theFitterOp =
new KFTrajectoryFitter(oppositeSmPr, *theUpdator, *theEstimator);
1466 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
"get also the MuonTransientTrackingRecHitBuilder" 1468 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
"get also the TransientTrackingRecHitBuilder" 1476 for (MuonCollection::const_iterator itMuon = smuons->begin(); itMuon != smuons->end(); ++itMuon) {
1479 <<
" mu gM is GM Mu SaM tM " << itMuon->isGlobalMuon() <<
" " << itMuon->isMuon() <<
" " 1480 << itMuon->isStandAloneMuon() <<
" " << itMuon->isTrackerMuon() <<
" ";
1494 GlobalPoint pointTrackOut = outerTrackTSOS.globalPosition();
1495 float lenghtTrack = (pointTrackOut - pointTrackIn).
mag();
1496 GlobalPoint pointMuonIn = innerMuTSOS.globalPosition();
1498 float lenghtMuon = (pointMuonOut - pointMuonIn).
mag();
1499 GlobalVector momentumTrackOut = outerTrackTSOS.globalMomentum();
1501 float distanceInIn = (pointTrackIn - pointMuonIn).
mag();
1502 float distanceInOut = (pointTrackIn - pointMuonOut).
mag();
1503 float distanceOutIn = (pointTrackOut - pointMuonIn).
mag();
1504 float distanceOutOut = (pointTrackOut - pointMuonOut).
mag();
1507 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" pointTrackIn " << pointTrackIn;
1508 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Out " << pointTrackOut <<
" lenght " << lenghtTrack;
1509 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" point MuonIn " << pointMuonIn;
1510 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Out " << pointMuonOut <<
" lenght " << lenghtMuon;
1512 <<
" momeTrackIn Out " << momentumTrackIn <<
" " << momentumTrackOut;
1514 <<
" doi io ii oo " << distanceOutIn <<
" " << distanceInOut <<
" " << distanceInIn <<
" " << distanceOutOut;
1517 if (lenghtTrack < 90.)
1519 if (lenghtMuon < 300.)
1521 if (innerMuTSOS.globalMomentum().mag() < 5. || outerMuTSOS.
globalMomentum().
mag() < 5.)
1523 if (momentumTrackIn.
mag() < 15. || momentumTrackOut.
mag() < 15.)
1525 if (trackTT.charge() != muTT.charge())
1529 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" passed lenght momentum cuts";
1543 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ------ Isolated (out-in) ----- ";
1544 const Surface& refSurface = innerMuTSOS.surface();
1546 Nl = tpMuLocal->normalVector();
1550 const Plane* refPlane =
dynamic_cast<Plane*
>(surf);
1554 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1555 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1556 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" global " << Ng.
x() <<
" " << Ng.
y() <<
" " << Ng.
z();
1557 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" lp " << Nlp.
x() <<
" " << Nlp.
y() <<
" " << Nlp.
z();
1559 <<
" Nlocal Nglobal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " << Ng.
x() <<
" " << Ng.
y() <<
" " 1560 << Ng.
z() <<
" alfa " <<
static_cast<int>(asin(Nl.
x()) * 57.29578);
1567 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
1570 if (trackFittedTSOS.
isValid())
1571 extrapolationT = alongSmPr.
propagate(trackFittedTSOS, refSurface);
1574 if (!extrapolationT.
isValid()) {
1576 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 1589 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
1590 GPm = innerMuTSOS.globalMomentum();
1593 (outerTrackTSOS.globalPosition()).
y(),
1594 (outerTrackTSOS.globalPosition()).
z());
1607 if ((distanceOutIn <= distanceInOut) & (distanceOutIn <= distanceInIn) &
1608 (distanceOutIn <= distanceOutOut)) {
1612 const Surface& refSurface = innerMuTSOS.surface();
1614 Nl = tpMuGlobal->normalVector();
1619 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
1622 if (trackFittedTSOS.
isValid())
1623 extrapolationT = alongSmPr.
propagate(trackFittedTSOS, refSurface);
1626 if (!extrapolationT.
isValid()) {
1628 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 1644 (innerMuTSOS.globalPosition()).
x(), (innerMuTSOS.globalPosition()).
y(), (innerMuTSOS.globalPosition()).
z());
1645 GPm = innerMuTSOS.globalMomentum();
1647 (outerTrackTSOS.globalPosition()).
y(),
1648 (outerTrackTSOS.globalPosition()).
z());
1661 <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 1662 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface));
1664 <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1665 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1669 else if ((distanceInOut <= distanceInIn) & (distanceInOut <= distanceOutIn) &
1670 (distanceInOut <= distanceOutOut)) {
1676 Nl = tpMuGlobal->normalVector();
1681 extrapolationT = oppositeSmPr.
propagate(innerTrackTSOS, refSurface);
1684 if (trackFittedTSOS.
isValid())
1685 extrapolationT = oppositeSmPr.
propagate(trackFittedTSOS, refSurface);
1688 if (!extrapolationT.
isValid()) {
1690 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-In extrapolationT.isValid " 1691 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid();
1722 <<
" propDirCh " << Chooser.operator()(*innerTrackTSOS.
freeState(), refSurface) <<
" Ch == oppisite " 1725 <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1726 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1730 else if ((distanceOutOut <= distanceInOut) & (distanceOutOut <= distanceInIn) &
1731 (distanceOutOut <= distanceOutIn)) {
1733 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ----- Out - Out -----";
1740 Nl = tpMuGlobal->normalVector();
1743 extrapolationT = alongSmPr.
propagate(outerTrackTSOS, refSurface);
1745 if (!extrapolationT.
isValid()) {
1747 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" !!!!!!!!! Catastrophe Out-Out extrapolationT.isValid " 1748 <<
"\a\a\a\a\a\a\a\a" << extrapolationT.
isValid();
1765 (outerTrackTSOS.globalPosition()).
y(),
1766 (outerTrackTSOS.globalPosition()).
z());
1775 <<
" propDirCh " << Chooser.operator()(*outerTrackTSOS.freeState(), refSurface) <<
" Ch == along " 1776 << (
alongMomentum == Chooser.operator()(*outerTrackTSOS.freeState(), refSurface));
1778 <<
" --- Nlocal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1779 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1781 <<
" Nornal " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " 1782 <<
" alfa " <<
int(asin(Nl.
x()) * 57.29578);
1788 <<
" ------- !!!!!!!!!!!!!!! No proper Out - In \a\a\a\a\a\a\a";
1794 if (tsosMuonIf == 0) {
1801 if (tsosMuonIf == 1)
1802 tsosMuon = muTT.innermostMeasurementState();
1804 tsosMuon = muTT.outermostMeasurementState();
1811 if (!trackFittedTSOS.
isValid()) {
1813 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ================= trackFittedTSOS notValid !!!!!!!! ";
1821 if (!muonFittedTSOS.
isValid()) {
1823 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ================= muonFittedTSOS notValid !!!!!!!! ";
1840 float RelMomResidual = (Pm.
mag() - Pt.mag()) / (Pt.mag() + 1.e-6);
1850 float Rmuon = Rm.
perp();
1851 float Zmuon = Rm.
z();
1852 float alfa_x = atan2(Nl.
x(), Nl.
y()) * 57.29578;
1856 <<
" Nx Ny Nz alfa_x " << Nl.
x() <<
" " << Nl.
y() <<
" " << Nl.
z() <<
" " << alfa_x;
1858 <<
" Rm " << Rm <<
"\n Rt " << Rt <<
"\n resR " << resR <<
"\n resP " << resP <<
" dp/p " << RelMomResidual;
1862 for (
int i = 0;
i <= 5;
i++)
1863 chi_d += Vm(
i) * Vm(
i) / Cm(
i,
i);
1868 bool ierrLoc = !
m.Invert();
1870 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ==== Error inverting Local covariance matrix ==== ";
1873 double chi_Loc = ROOT::Math::Similarity(Vml,
m);
1876 <<
" chi_Loc px/pz/err " << chi_Loc <<
" " << Vml(1) /
std::sqrt(Cml(1, 1));
1896 if (fabs(resR.
x()) > 20.)
1898 if (fabs(resR.
y()) > 20.)
1900 if (fabs(resR.
z()) > 20.)
1902 if (fabs(resR.
mag()) > 30.)
1904 if (fabs(resP.
x()) > 0.06)
1906 if (fabs(resP.
y()) > 0.06)
1908 if (fabs(resP.
z()) > 0.06)
1931 if (Rmuon < 120. || Rmuon > 450.)
1933 if (Zmuon < -720. || Zmuon > 720.)
1938 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" .............. passed all cuts";
1946 CLHEP::HepSymMatrix covLoc(4, 0);
1947 for (
int i = 1;
i <= 4;
i++)
1948 for (
int j = 1;
j <=
i;
j++) {
1954 CLHEP::HepMatrix rotLoc(3, 3, 0);
1967 CLHEP::HepVector posLoc(3);
1976 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" posLoc " << posLoc.T();
1981 histo->Fill(itMuon->track()->pt());
1985 histo3->Fill((
PI / 2. - itMuon->track()->outerTheta()));
1986 histo4->Fill(itMuon->track()->phi());
1989 histo7->Fill(RelMomResidual);
1999 if (fabs(Nl.
x()) < 0.98)
2001 if (fabs(Nl.
y()) < 0.98)
2003 if (fabs(Nl.
z()) < 0.98)
2009 if ((fabs(Nl.
x()) < 0.98) && (fabs(Nl.
y()) < 0.98) && (fabs(Nl.
z()) < 0.98)) {
2014 if (fabs(Nl.
x()) < 0.98)
2016 if (fabs(Nl.
y()) < 0.98)
2018 if (fabs(Nl.
z()) < 0.98)
2035 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag 0[ " << C0(0, 0) <<
" " << C0(1, 1) <<
" " << C0(2, 2)
2036 <<
" " << C0(3, 3) <<
" " << C0(4, 4) <<
" " << C0(5, 5) <<
" ]";
2037 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag e[ " << Ce(0, 0) <<
" " << Ce(1, 1) <<
" " << Ce(2, 2)
2038 <<
" " << Ce(3, 3) <<
" " << Ce(4, 4) <<
" " << Ce(5, 5) <<
" ]";
2039 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag 1[ " << C1(0, 0) <<
" " << C1(1, 1) <<
" " << C1(2, 2)
2040 <<
" " << C1(3, 3) <<
" " << C1(4, 4) <<
" " << C1(5, 5) <<
" ]";
2041 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Rm " << Rm.
x() <<
" " << Rm.
y() <<
" " << Rm.
z() <<
" Pm " 2042 << Pm.
x() <<
" " << Pm.
y() <<
" " << Pm.
z();
2043 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Rt " << Rt.x() <<
" " << Rt.y() <<
" " << Rt.z() <<
" Pt " 2044 << Pt.x() <<
" " << Pt.y() <<
" " << Pt.z();
2046 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" resR " << resR.
x() <<
" " << resR.
y() <<
" " << resR.
z()
2047 <<
" resP " << resP.
x() <<
" " << resP.
y() <<
" " << resP.
z();
2049 <<
" Rm-t " << (Rm - Rt).
x() <<
" " << (Rm - Rt).
y() <<
" " << (Rm - Rt).
z() <<
" Pm-t " << (Pm - Pt).
x()
2050 <<
" " << (Pm - Pt).
y() <<
" " << (Pm - Pt).
z();
2056 <<
" Pmuon Ptrack dP/Ptrack " << itMuon->outerTrack()->p() <<
" " << itMuon->track()->outerP() <<
" " 2057 << (itMuon->outerTrack()->p() - itMuon->track()->outerP()) / itMuon->track()->outerP();
2060 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" diag [ " << Cm(0, 0) <<
" " << Cm(1, 1) <<
" " << Cm(2, 2)
2061 <<
" " << Cm(3, 3) <<
" " << Cm(4, 4) <<
" " << Cm(5, 5) <<
" ]";
2065 for (
int i = 0;
i <= 5;
i++)
2067 for (
int i = 0;
i <= 5;
i++)
2068 for (
int j = 0;
j <= 5;
j++)
2069 Ro(
i,
j) = Cm(
i,
j) / Diag[
i] / Diag[
j];
2074 for (
int i = 0;
i <= 5;
i++)
2075 for (
int j = 0;
j <= 5;
j++)
2076 CmI(
i,
j) = Cm(
i,
j);
2078 bool ierr = !CmI.Invert();
2081 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Error inverse covariance matrix !!!!!!!!!!!";
2087 double chi = ROOT::Math::Similarity(Vm, CmI);
2088 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" chi chi_d " << chi <<
" " << chi_d;
2117 for (
int i = 0;
i <= 2;
i++) {
2118 if (Cm(
i,
i) > 1.
e-20)
2119 Wi(
i) = 1. / Cm(
i,
i);
2122 dR(
i) = R_m(
i) - R_t(
i);
2125 float PtN = P_t(0) * Norm(0) + P_t(1) * Norm(1) + P_t(2) * Norm(2);
2127 Jac(0, 0) = 1. - P_t(0) * Norm(0) / PtN;
2128 Jac(0, 1) = -P_t(0) * Norm(1) / PtN;
2129 Jac(0, 2) = -P_t(0) * Norm(2) / PtN;
2131 Jac(1, 0) = -P_t(1) * Norm(0) / PtN;
2132 Jac(1, 1) = 1. - P_t(1) * Norm(1) / PtN;
2133 Jac(1, 2) = -P_t(1) * Norm(2) / PtN;
2135 Jac(2, 0) = -P_t(2) * Norm(0) / PtN;
2136 Jac(2, 1) = -P_t(2) * Norm(1) / PtN;
2137 Jac(2, 2) = 1. - P_t(2) * Norm(2) / PtN;
2141 for (
int i = 0;
i <= 2;
i++)
2142 for (
int j = 0;
j <= 2;
j++) {
2147 for (
int k = 0;
k <= 2;
k++) {
2152 for (
int i = 0;
i <= 2;
i++)
2153 for (
int j = 0;
j <= 2;
j++) {
2160 for (
int i = 0;
i <= 2;
i++)
2161 for (
int k = 0;
k <= 2;
k++)
2162 Gtr(
i) +=
dR(
k) * Wi(
k) * Jac(
k,
i);
2163 for (
int i = 0;
i <= 2;
i++)
2205 CLHEP::HepSymMatrix
w(Nd, 0);
2206 for (
int i = 1;
i <= Nd;
i++)
2207 for (
int j = 1;
j <= Nd;
j++) {
2209 w(
i,
j) = GCov(
i - 1,
j - 1);
2212 if ((
i ==
j) && (
i <= 3) && (GCov(
i - 1,
j - 1) < 1.
e-20))
2221 CLHEP::HepVector
V(Nd), Rt(3), Pt(3), Rm(3), Pm(3), Norm(3);
2234 Norm(1) = GNorm.
x();
2235 Norm(2) = GNorm.
y();
2236 Norm(3) = GNorm.
z();
2238 V = dsum(Rm - Rt, Pm - Pt);
2244 CLHEP::HepMatrix Jac(Nd, Nd, 0);
2245 for (
int i = 1;
i <= 3;
i++)
2246 for (
int j = 1;
j <= 3;
j++) {
2247 Jac(
i,
j) = Pm(
i) * Norm(
j) / PmN;
2263 CLHEP::HepVector dsda(3);
2264 dsda(1) = (Norm(2) * Rm(3) - Norm(3) * Rm(2)) / PmN;
2265 dsda(2) = (Norm(3) * Rm(1) - Norm(1) * Rm(3)) / PmN;
2266 dsda(3) = (Norm(1) * Rm(2) - Norm(2) * Rm(1)) / PmN;
2269 Jac(1, 4) = Pm(1) * dsda(1);
2270 Jac(2, 4) = -Rm(3) + Pm(2) * dsda(1);
2271 Jac(3, 4) = Rm(2) + Pm(3) * dsda(1);
2273 Jac(1, 5) = Rm(3) + Pm(1) * dsda(2);
2274 Jac(2, 5) = Pm(2) * dsda(2);
2275 Jac(3, 5) = -Rm(1) + Pm(3) * dsda(2);
2277 Jac(1, 6) = -Rm(2) + Pm(1) * dsda(3);
2278 Jac(2, 6) = Rm(1) + Pm(2) * dsda(3);
2279 Jac(3, 6) = Pm(3) * dsda(3);
2281 CLHEP::HepSymMatrix W(Nd, 0);
2283 W =
w.inverse(ierr);
2286 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" gradientGlobal: inversion of matrix w fail ";
2290 CLHEP::HepMatrix W_Jac(Nd, Nd, 0);
2291 W_Jac = Jac.T() * W;
2293 CLHEP::HepVector grad3(Nd);
2296 CLHEP::HepMatrix hess3(Nd, Nd);
2297 hess3 = Jac.T() * W * Jac;
2303 CLHEP::HepVector d3I = CLHEP::solve(
Hess, -
Grad);
2305 CLHEP::HepMatrix Errd3I =
Hess.inverse(iEr3I);
2308 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" gradientGlobal error inverse Hess matrix !!!!!!!!!!!";
2313 <<
" dG " << d3I(1) <<
" " << d3I(2) <<
" " << d3I(3) <<
" " << d3I(4) <<
" " << d3I(5) <<
" " << d3I(6);
2320 #ifdef CHECK_OF_DERIVATIVES 2323 CLHEP::HepVector
d(3, 0),
a(3, 0);
2324 CLHEP::HepMatrix
T(3, 3, 1);
2326 CLHEP::HepMatrix Ti =
T.T();
2330 double B =
CLHEP_dot((Rt - Ti * Rm + Ti *
d), Norm);
2333 CLHEP::HepVector r0(3, 0), p0(3, 0);
2334 r0 = Ti * Rm - Ti *
d + s0 * (Ti * Pm) - Rt;
2337 double delta = 0.0001;
2351 CLHEP::HepVector
r(3, 0),
p(3, 0);
2352 r = Ti * Rm - Ti *
d +
s * (Ti * Pm) - Rt;
2356 <<
" s0 s num dsda(" <<
ii <<
") " << s0 <<
" " <<
s <<
" " << (
s - s0) /
delta <<
" " << dsda(
ii);
2359 <<
" -- An d(r,p)/d(" <<
ii <<
") " << Jac(1,
ii) <<
" " << Jac(2,
ii) <<
" " << Jac(3,
ii) <<
" " << Jac(4,
ii)
2360 <<
" " << Jac(5,
ii) <<
" " << Jac(6,
ii);
2362 <<
" Nu d(r,p)/d(" <<
ii <<
") " << (
r(1) - r0(1)) /
delta <<
" " << (
r(2) - r0(2)) /
delta <<
" " 2363 << (
r(3) - r0(3)) /
delta <<
" " << (
p(1) - p0(1)) /
delta <<
" " << (
p(2) - p0(2)) /
delta <<
" " 2364 << (
p(3) - p0(3)) /
delta;
2367 <<
" -- An d(r,p)/a(" <<
ii <<
") " << Jac(1,
ii + 3) <<
" " << Jac(2,
ii + 3) <<
" " << Jac(3,
ii + 3) <<
" " 2368 << Jac(4,
ii + 3) <<
" " << Jac(5,
ii + 3) <<
" " << Jac(6,
ii + 3);
2370 <<
" Nu d(r,p)/a(" <<
ii <<
") " << (
r(1) - r0(1)) /
delta <<
" " << (
r(2) - r0(2)) /
delta <<
" " 2371 << (
r(3) - r0(3)) /
delta <<
" " << (
p(1) - p0(1)) /
delta <<
" " << (
p(2) - p0(2)) /
delta <<
" " 2372 << (
p(3) - p0(3)) /
delta;
2385 CLHEP::HepSymMatrix& covLoc,
2386 CLHEP::HepMatrix& rotLoc,
2387 CLHEP::HepVector&
R0,
2417 CLHEP::HepVector Rt(3), Pt(3), Rm(3), Pm(3), Norm(3);
2430 Norm(1) = GNorm.
x();
2431 Norm(2) = GNorm.
y();
2432 Norm(3) = GNorm.
z();
2434 CLHEP::HepVector
V(4), Rml(3), Pml(3), Rtl(3), Ptl(3);
2442 Rml = rotLoc * (Rm -
R0);
2443 Rtl = rotLoc * (Rt -
R0);
2447 V(1) = LPRm(0) - Ptl(1) / Ptl(3);
2448 V(2) = LPRm(1) - Ptl(2) / Ptl(3);
2449 V(3) = LPRm(2) - Rtl(1);
2450 V(4) = LPRm(3) - Rtl(2);
2465 CLHEP::HepSymMatrix W = covLoc;
2471 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" gradientLocal: inversion of matrix W fail ";
2483 CLHEP::HepMatrix JacToLoc(4, 6, 0);
2484 for (
int i = 1;
i <= 2;
i++)
2485 for (
int j = 1;
j <= 3;
j++) {
2486 JacToLoc(
i,
j + 3) = (rotLoc(
i,
j) - rotLoc(3,
j) * Pml(
i) / Pml(3)) / Pml(3);
2487 JacToLoc(
i + 2,
j) = rotLoc(
i,
j);
2494 CLHEP::HepMatrix Jac(6, 6, 0);
2495 for (
int i = 1;
i <= 3;
i++)
2496 for (
int j = 1;
j <= 3;
j++) {
2497 Jac(
i,
j) = Pm(
i) * Norm(
j) / PmN;
2513 CLHEP::HepVector dsda(3);
2514 dsda(1) = (Norm(2) * Rm(3) - Norm(3) * Rm(2)) / PmN;
2515 dsda(2) = (Norm(3) * Rm(1) - Norm(1) * Rm(3)) / PmN;
2516 dsda(3) = (Norm(1) * Rm(2) - Norm(2) * Rm(1)) / PmN;
2519 Jac(1, 4) = Pm(1) * dsda(1);
2520 Jac(2, 4) = -Rm(3) + Pm(2) * dsda(1);
2521 Jac(3, 4) = Rm(2) + Pm(3) * dsda(1);
2523 Jac(1, 5) = Rm(3) + Pm(1) * dsda(2);
2524 Jac(2, 5) = Pm(2) * dsda(2);
2525 Jac(3, 5) = -Rm(1) + Pm(3) * dsda(2);
2527 Jac(1, 6) = -Rm(2) + Pm(1) * dsda(3);
2528 Jac(2, 6) = Rm(1) + Pm(2) * dsda(3);
2529 Jac(3, 6) = Pm(3) * dsda(3);
2532 CLHEP::HepMatrix JacCorLoc(4, 6, 0);
2533 JacCorLoc = JacToLoc * Jac;
2536 CLHEP::HepMatrix W_Jac(6, 4, 0);
2537 W_Jac = JacCorLoc.T() * W;
2539 CLHEP::HepVector gradL(6);
2542 CLHEP::HepMatrix hessL(6, 6);
2543 hessL = JacCorLoc.T() * W * JacCorLoc;
2548 CLHEP::HepVector dLI = CLHEP::solve(
HessL, -
GradL);
2550 CLHEP::HepMatrix ErrdLI =
HessL.inverse(iErI);
2553 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" gradLocal Error inverse Hess matrix !!!!!!!!!!!";
2558 <<
" dL " << dLI(1) <<
" " << dLI(2) <<
" " << dLI(3) <<
" " << dLI(4) <<
" " << dLI(5) <<
" " << dLI(6);
2567 <<
" dV(da3) {" << -JacCorLoc(1, 6) * 0.002 <<
" " << -JacCorLoc(2, 6) * 0.002 <<
" " 2568 << -JacCorLoc(3, 6) * 0.002 <<
" " << -JacCorLoc(4, 6) * 0.002 <<
"}";
2569 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" JacCLo {" << JacCorLoc(1, 6) <<
" " << JacCorLoc(2, 6)
2570 <<
" " << JacCorLoc(3, 6) <<
" " << JacCorLoc(4, 6) <<
"}";
2572 <<
"Jpx/yx {" << Jac(4, 6) / Pm(3) <<
" " << Jac(5, 6) / Pm(3) <<
" " << Jac(1, 6) <<
" " << Jac(2, 6) <<
"}";
2574 <<
"Jac(,a3){" << Jac(1, 6) <<
" " << Jac(2, 6) <<
" " << Jac(3, 6) <<
" " << Jac(4, 6) <<
" " << Jac(5, 6)
2575 <<
" " << Jac(6, 6);
2577 if (GNorm.
z() > 0.95)
2579 else if (GNorm.
z() < -0.95)
2584 <<
" JacCLo(i," <<
i <<
") = {" << JacCorLoc(1,
i) <<
" " << JacCorLoc(2,
i) <<
" " << JacCorLoc(3,
i) <<
" " 2585 << JacCorLoc(4,
i) <<
"}";
2589 <<
" Pm,l " << Pm.T() <<
" " << Pml(1) / Pml(3) <<
" " << Pml(2) / Pml(3);
2591 <<
" Pt,l " << Pt.T() <<
" " << Ptl(1) / Ptl(3) <<
" " << Ptl(2) / Ptl(3);
2596 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" JacToLoc " << JacToLoc;
2599 #ifdef CHECK_OF_JACOBIAN_CARTESIAN_TO_LOCAL 2601 CLHEP::HepVector V0(4, 0);
2602 V0(1) = Pml(1) / Pml(3) - Ptl(1) / Ptl(3);
2603 V0(2) = Pml(2) / Pml(3) - Ptl(2) / Ptl(3);
2604 V0(3) = Rml(1) - Rtl(1);
2605 V0(4) = Rml(2) - Rtl(2);
2608 CLHEP::HepVector V1(4, 0);
2611 Rml = rotLoc * (Rm -
R0);
2618 V1(1) = Pml(1) / Pml(3) - Ptl(1) / Ptl(3);
2619 V1(2) = Pml(2) / Pml(3) - Ptl(2) / Ptl(3);
2620 V1(3) = Rml(1) - Rtl(1);
2621 V1(4) = Rml(2) - Rtl(2);
2623 if (GNorm.
z() > 0.95)
2625 else if (GNorm.
z() < -0.95)
2630 <<
" dldc Num (i," <<
ii <<
") " << (V1(1) - V0(1)) /
delta <<
" " << (V1(2) - V0(2)) /
delta <<
" " 2631 << (V1(3) - V0(3)) /
delta <<
" " << (V1(4) - V0(4)) /
delta;
2632 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" dldc Ana (i," <<
ii <<
") " << JacToLoc(1,
ii) <<
" " 2633 << JacToLoc(2,
ii) <<
" " << JacToLoc(3,
ii) <<
" " << JacToLoc(4,
ii);
2634 float dtxdpx = (rotLoc(1, 1) - rotLoc(3, 1) * Pml(1) / Pml(3)) / Pml(3);
2635 float dtydpx = (rotLoc(2, 1) - rotLoc(3, 2) * Pml(2) / Pml(3)) / Pml(3);
2636 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" dtx/dpx dty/ " << dtxdpx <<
" " << dtydpx;
2645 CLHEP::HepVector
d(3, 0),
a(3, 0), Norm(3), Rm0(3), Pm0(3), Rm1(3), Pm1(3), Rmi(3), Pmi(3);
2667 if ((
d(1) == 0.) && (
d(2) == 0.) && (
d(3) == 0.) && (
a(1) == 0.) && (
a(2) == 0.) && (
a(3) == 0.)) {
2671 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ...... without misalignment ";
2685 CLHEP::HepMatrix
T(3, 3, 1);
2695 T(1, 2) =
c1 * s3 + s1 * s2 * c3;
2696 T(1, 3) = s1 * s3 -
c1 * s2 * c3;
2698 T(2, 2) =
c1 * c3 - s1 * s2 * s3;
2699 T(2, 3) = s1 * c3 +
c1 * s2 * s3;
2706 CLHEP::HepMatrix Ti =
T.T();
2707 CLHEP::HepVector di = -Ti *
d;
2709 CLHEP::HepVector ex0(3, 0), ey0(3, 0), ez0(3, 0), ex(3, 0), ey(3, 0), ez(3, 0);
2717 CLHEP::HepVector TiN = Ti * Norm;
2723 Rm1(1) =
CLHEP_dot(ex, Rm0 + si * Pm0 - di);
2724 Rm1(2) =
CLHEP_dot(ey, Rm0 + si * Pm0 - di);
2725 Rm1(3) =
CLHEP_dot(ez, Rm0 + si * Pm0 - di);
2736 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" Ti*T*Pm0 " << (Ti * (
T * Pm0)).T();
2739 CLHEP::HepVector Rml = Rm1(1) * ex + Rm1(2) * ey + Rm1(3) * ez + di;
2741 CLHEP::HepVector Rt0(3);
2748 CLHEP::HepVector Rl = Rml + sl * (Ti * Pm1);
2756 CLHEP::HepVector Dr = Ti * Rm1 - Ti *
d +
s * (Ti * Pm1) - Rm0;
2757 CLHEP::HepVector Dp = Ti * Pm1 - Pm0;
2759 CLHEP::HepVector TiR = Ti * Rm0 + di;
2760 CLHEP::HepVector Ri =
T * TiR +
d;
2762 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" --TTi-0 " << (Ri - Rm0).
T();
2769 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" ---- Ti ---- " << Ti;
2770 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" ---- d ---- " <<
d.T();
2771 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" ---- di ---- " << di.T();
2772 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" -- si sl s " << si <<
" " << sl <<
" " <<
s;
2773 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- si sl " << si <<
" " << sl;
2774 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- si s " << si <<
" " <<
s;
2775 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" -- Rml-(Rm0+si*Pm0) " << (Rml - Rm0 - si * Pm0).
T();
2776 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- Rm0 " << Rm0.T();
2777 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- Rm1 " << Rm1.T();
2778 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- Rmi " << Rmi.T();
2779 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --siPm " << (si * Pm0).
T();
2780 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --s2Pm " << (s2 * (
T * Pm1)).T();
2781 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --R1-0 " << (Rm1 - Rm0).
T();
2782 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --Ri-0 " << (Rmi - Rm0).
T();
2784 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --Pi-0 " << (Pmi - Pm0).
T();
2801 CLHEP::HepVector
d(3, 0),
a(3, 0), Norm(3), Rm0(3), Pm0(3), Rm1(3), Pm1(3), Rmi(3), Pmi(3);
2825 if ((
d(1) == 0.) && (
d(2) == 0.) && (
d(3) == 0.) && (
a(1) == 0.) && (
a(2) == 0.) && (
a(3) == 0.)) {
2834 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ...... without misalignment ";
2848 CLHEP::HepMatrix
T(3, 3, 1);
2858 T(1, 2) =
c1 * s3 + s1 * s2 * c3;
2859 T(1, 3) = s1 * s3 -
c1 * s2 * c3;
2861 T(2, 2) =
c1 * c3 - s1 * s2 * s3;
2862 T(2, 3) = s1 * c3 +
c1 * s2 * s3;
2870 CLHEP::HepMatrix Ti =
T.T();
2871 CLHEP::HepVector di = -Ti *
d;
2873 CLHEP::HepVector ex0(3, 0), ey0(3, 0), ez0(3, 0), ex(3, 0), ey(3, 0), ez(3, 0);
2881 CLHEP::HepVector TiN = Ti * Norm;
2887 Rm1(1) =
CLHEP_dot(ex, Rm0 + si * Pm0 - di);
2888 Rm1(2) =
CLHEP_dot(ey, Rm0 + si * Pm0 - di);
2889 Rm1(3) =
CLHEP_dot(ez, Rm0 + si * Pm0 - di);
2899 CLHEP::HepMatrix Tl(3, 3, 0);
2913 CLHEP::HepVector
R0(3, 0), newR0(3, 0), newRl(3, 0), newPl(3, 0);
2918 newRl = Tl * (Rm1 -
R0);
2921 Vm(0) = newPl(1) / newPl(3);
2922 Vm(1) = newPl(2) / newPl(3);
2926 #ifdef CHECK_DERIVATIVES_LOCAL_VS_ANGLES 2934 CLHEP::HepVector Rm10 = Rm1, Pm10 = Pm1;
2936 CLHEP::HepMatrix newTl = Tl *
T;
2944 Rm1(1) =
CLHEP_dot(ex, Rm0 + si * Pm0 - di);
2945 Rm1(2) =
CLHEP_dot(ey, Rm0 + si * Pm0 - di);
2946 Rm1(3) =
CLHEP_dot(ez, Rm0 + si * Pm0 - di);
2949 newRl = Tl * (Rm1 -
R0);
2952 Vm(0) = newPl(1) / newPl(3);
2953 Vm(1) = newPl(2) / newPl(3);
2956 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ========= dVm/da" <<
ii <<
" " << (Vm - Vm0) * (1. / del);
2959 <<
" dRm/da3 " << ((Rm1 - Rm10) * (1. / del)).
T() <<
" " << ((Pm1 - Pm10) * (1. / del)).
T();
2963 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" Norm " << Norm.T();
2968 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" pxyz/p gl 0 " << (Pm0 / Pm0.norm()).
T();
2969 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" pxyz/p loc0 " << (Tl * Pm0 / (Tl * Pm0).norm()).
T();
2970 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" pxyz/p glob " << (Pm1 / Pm1.norm()).
T();
2971 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" pxyz/p loc " << (newPl / newPl.norm()).
T();
2976 <<
" ---- phi g0 g1 l0 l1 " << atan2(Pm0(2), Pm0(1)) <<
" " << atan2(Pm1(2), Pm1(1)) <<
" " 2977 << atan2((Tl * Pm0)(2), (Tl * Pm0)(1)) <<
" " << atan2(newPl(2), newPl(1));
2979 <<
" ---- angl Gl Loc " << atan2(Pm1(2), Pm1(1)) - atan2(Pm0(2), Pm0(1)) <<
" " 2980 << atan2(newPl(2), newPl(1)) - atan2((Tl * Pm0)(2), (Tl * Pm0)(1)) <<
" " 2981 << atan2(newPl(3), newPl(2)) - atan2((Tl * Pm0)(3), (Tl * Pm0)(2)) <<
" " 2982 << atan2(newPl(1), newPl(3)) - atan2((Tl * Pm0)(1), (Tl * Pm0)(3)) <<
" ";
2986 CLHEP::HepMatrix newTl(3, 3, 0);
2987 CLHEP::HepVector
R0(3, 0), newRl(3, 0), newPl(3, 0);
2988 newTl = Tl * Ti.T();
2989 newR0 = Ti *
R0 + di;
2999 CLHEP::HepVector Rvc(3, 0), Pvc(3, 0), Rvg(3, 0), Pvg(3, 0);
3003 Pvc(1) = Pvc(3) * Vm(0);
3004 Pvc(2) = Pvc(3) * Vm(1);
3006 Rvg = newTl.T() * Rvc + newR0;
3007 Pvg = newTl.T() * Pvc;
3021 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" Ti*T*Pm0 " << (Ti * (
T * Pm0)).T();
3024 CLHEP::HepVector Rml = Rm1(1) * ex + Rm1(2) * ey + Rm1(3) * ez + di;
3026 CLHEP::HepVector Rt0(3);
3033 CLHEP::HepVector Rl = Rml + sl * (Ti * Pm1);
3041 CLHEP::HepVector Dr = Ti * Rm1 - Ti *
d +
s * (Ti * Pm1) - Rm0;
3042 CLHEP::HepVector Dp = Ti * Pm1 - Pm0;
3044 CLHEP::HepVector TiR = Ti * Rm0 + di;
3045 CLHEP::HepVector Ri =
T * TiR +
d;
3047 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" --TTi-0 " << (Ri - Rm0).
T();
3054 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" ---- Ti ---- " << Ti;
3055 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" ---- d ---- " <<
d.T();
3056 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" ---- di ---- " << di.T();
3057 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" -- si sl s " << si <<
" " << sl <<
" " <<
s;
3058 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- si sl " << si <<
" " << sl;
3059 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- si s " << si <<
" " <<
s;
3060 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" -- Rml-(Rm0+si*Pm0) " << (Rml - Rm0 - si * Pm0).
T();
3061 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- Rm0 " << Rm0.T();
3062 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- Rm1 " << Rm1.T();
3063 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" -- Rmi " << Rmi.T();
3064 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --siPm " << (si * Pm0).
T();
3065 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --s2Pm " << (s2 * (
T * Pm1)).T();
3066 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --R1-0 " << (Rm1 - Rm0).
T();
3067 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --Ri-0 " << (Rmi - Rm0).
T();
3069 edm::LogVerbatim(
"GlobalTrackerMuonAlignmentDebug") <<
" --Pi-0 " << (Pmi - Pm0).
T();
3082 bool smooth =
false;
3085 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ......... start of trackFitter ......... ";
3086 if (
false &&
info) {
3088 this->
debugTrackHit(
" Tracker TransientTrack hits ", alongTTr);
3092 DetId trackDetId =
DetId(alongTr->innerDetId());
3093 for (
auto const&
hit : alongTr->recHits())
3098 for (
unsigned int ihit = recHitAlong.
size() - 1; ihit + 1 > 0; ihit--) {
3099 recHit.push_back(recHitAlong[ihit]);
3101 recHitAlong.
clear();
3105 <<
" ... Own recHit.size() " <<
recHit.size() <<
" " << trackDetId.
rawId();
3109 for (
auto const&
hit : alongTr->recHits())
3114 <<
" ... recHitTrack.size() " <<
recHit.size() <<
" " << trackDetId.
rawId() <<
" ======> recHitMu ";
3122 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ...along.... recHitMu.size() " << recHitMu.size();
3126 for (
unsigned int ihit = recHitMuAlong.size() - 1; ihit + 1 > 0; ihit--) {
3127 recHitMu.push_back(recHitMuAlong[ihit]);
3129 recHitMuAlong.clear();
3132 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ...opposite... recHitMu.size() " << recHitMu.size();
3153 std::vector<Trajectory> trajVec;
3155 trajVec =
theFitter->fit(seedT, recHitMu, initialTSOS);
3157 trajVec =
theFitterOp->fit(seedT, recHitMu, initialTSOS);
3163 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" . . . . . trajVec.size() " << trajVec.size();
3164 if (!trajVec.empty())
3169 if (!trajVec.empty())
3170 trackFittedTSOS = trajVec[0].lastMeasurement().updatedState();
3172 std::vector<Trajectory> trajSVec;
3173 if (!trajVec.empty()) {
3180 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" . . . . trajSVec.size() " << trajSVec.size();
3181 if (!trajSVec.empty())
3182 this->
debugTrajectorySOSv(
"smoothed geom InnermostState", trajSVec[0].geometricalInnermostState());
3183 if (!trajSVec.empty())
3184 trackFittedTSOS = trajSVec[0].geometricalInnermostState();
3198 bool smooth =
false;
3201 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ......... start of muonFitter ........";
3202 if (
false &&
info) {
3204 this->
debugTrackHit(
" Muon TransientTrack hits ", alongTTr);
3208 DetId trackDetId =
DetId(alongTr->innerDetId());
3209 for (
auto const&
hit : alongTr->recHits())
3214 for (
unsigned int ihit = recHitAlong.
size() - 1; ihit + 1 > 0; ihit--) {
3215 recHit.push_back(recHitAlong[ihit]);
3217 recHitAlong.
clear();
3221 <<
" ... Own recHit.size() DetId==Muon " <<
recHit.size() <<
" " << trackDetId.
rawId();
3226 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ...along.... recHitMu.size() " << recHitMu.size();
3230 for (
unsigned int ihit = recHitMuAlong.size() - 1; ihit + 1 > 0; ihit--) {
3231 recHitMu.push_back(recHitMuAlong[ihit]);
3233 recHitMuAlong.clear();
3236 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" ...opposite... recHitMu.size() " << recHitMu.size();
3257 std::vector<Trajectory> trajVec;
3259 trajVec =
theFitter->fit(seedT, recHitMu, initialTSOS);
3261 trajVec =
theFitterOp->fit(seedT, recHitMu, initialTSOS);
3267 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" . . . . . trajVec.size() " << trajVec.size();
3268 if (!trajVec.empty())
3273 if (!trajVec.empty())
3274 trackFittedTSOS = trajVec[0].lastMeasurement().updatedState();
3276 std::vector<Trajectory> trajSVec;
3277 if (!trajVec.empty()) {
3284 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" . . . . trajSVec.size() " << trajSVec.size();
3285 if (!trajSVec.empty())
3286 this->
debugTrajectorySOSv(
"smoothed geom InnermostState", trajSVec[0].geometricalInnermostState());
3287 if (!trajSVec.empty())
3288 trackFittedTSOS = trajSVec[0].geometricalInnermostState();
3298 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Hit " << nHit++ <<
" DetId " << (*i)->geographicalId().det();
3301 else if ((*i)->geographicalId().det() ==
DetId::Muon)
3305 if (!(*i)->isValid())
3316 for (
auto const&
hit : alongTr->recHits()) {
3317 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Hit " << nHit++ <<
" DetId " <<
hit->geographicalId().det();
3324 if (!
hit->isValid())
3392 <<
" ...... " <<
title <<
" ...... ";
3401 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" oppositeToMomentum <<<<";
3406 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" . . . . . . . . . . . . . . . . . . . . . . . . . . . . \n";
3422 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" paramVector " << paramVec.T();
3424 CLHEP::Hep3Vector colX, colY, colZ;
3426 #ifdef NOT_EXACT_ROTATION_MATRIX 3427 colX = CLHEP::Hep3Vector(1., -paramVec(6), paramVec(5));
3428 colY = CLHEP::Hep3Vector(paramVec(6), 1., -paramVec(4));
3429 colZ = CLHEP::Hep3Vector(-paramVec(5), paramVec(4), 1.);
3434 colX = CLHEP::Hep3Vector(c2 * c3, -c2 * s3, s2);
3435 colY = CLHEP::Hep3Vector(
c1 * s3 + s1 * s2 * c3,
c1 * c3 - s1 * s2 * s3, -s1 * c2);
3436 colZ = CLHEP::Hep3Vector(s1 * s3 -
c1 * s2 * c3, s1 * c3 +
c1 * s2 * s3,
c1 * c2);
3439 CLHEP::HepVector param0(6, 0);
3449 CLHEP::HepEulerAngles angMuGlRcd =
iteratorMuonRcd->rotation().eulerAngles();
3452 <<
" Old muon Rcd Euler angles " << angMuGlRcd.phi() <<
" " << angMuGlRcd.theta() <<
" " << angMuGlRcd.psi();
3454 if ((angMuGlRcd.phi() == 0.) && (angMuGlRcd.theta() == 0.) && (angMuGlRcd.psi() == 0.) && (posMuGlRcd.x() == 0.) &&
3455 (posMuGlRcd.y() == 0.) && (posMuGlRcd.z() == 0.)) {
3456 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" New muon parameters are stored in Rcd";
3462 }
else if ((paramVec(1) == 0.) && (paramVec(2) == 0.) && (paramVec(3) == 0.) && (paramVec(4) == 0.) &&
3463 (paramVec(5) == 0.) && (paramVec(6) == 0.)) {
3464 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" Old muon parameters are stored in Rcd";
3469 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
" New + Old muon parameters are stored in Rcd";
3470 CLHEP::Hep3Vector posMuGlRcdThis = CLHEP::Hep3Vector(paramVec(1), paramVec(2), paramVec(3));
3471 CLHEP::HepRotation rotMuGlRcdThis = CLHEP::HepRotation(colX, colY, colZ);
3472 CLHEP::Hep3Vector posMuGlRcdNew = rotMuGlRcdThis * posMuGlRcd + posMuGlRcdThis;
3473 CLHEP::HepRotation rotMuGlRcdNew = rotMuGlRcdThis * rotMuGlRcd;
3489 <<
"Tracker (" <<
tracker.rawId() <<
") at " <<
tracker.translation() <<
" " <<
tracker.rotation().eulerAngles();
3493 <<
"Muon (" <<
muon.rawId() <<
") at " <<
muon.translation() <<
" " <<
muon.rotation().eulerAngles();
3495 <<
" rotations angles around x,y,z " 3496 <<
" ( " << -
muon.rotation().zy() <<
" " <<
muon.rotation().zx() <<
" " << -
muon.rotation().yx() <<
" )";
3500 <<
"Ecal (" <<
ecal.rawId() <<
") at " <<
ecal.translation() <<
" " <<
ecal.rotation().eulerAngles();
3504 <<
"Hcal (" <<
hcal.rawId() <<
") at " <<
hcal.translation() <<
" " <<
hcal.rotation().eulerAngles();
3508 <<
"Calo (" <<
calo.rawId() <<
") at " <<
calo.translation() <<
" " <<
calo.rotation().eulerAngles();
3511 globalPositions.m_align.push_back(
tracker);
3512 globalPositions.m_align.push_back(
muon);
3513 globalPositions.m_align.push_back(
ecal);
3514 globalPositions.m_align.push_back(
hcal);
3515 globalPositions.m_align.push_back(
calo);
3517 edm::LogVerbatim(
"GlobalTrackerMuonAlignment") <<
"Uploading to the database...";
3522 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 &)