6 verbose_(settings.getParameter<
bool>(
"verbose")),
8 initK_(settings.getParameter<
std::vector<double> >(
"initialK")),
9 initK2_(settings.getParameter<
std::vector<double> >(
"initialK2")),
10 eLoss_(settings.getParameter<
std::vector<double> >(
"eLoss")),
11 aPhi_(settings.getParameter<
std::vector<double> >(
"aPhi")),
12 aPhiB_(settings.getParameter<
std::vector<double> >(
"aPhiB")),
13 aPhiBNLO_(settings.getParameter<
std::vector<double> >(
"aPhiBNLO")),
14 bPhi_(settings.getParameter<
std::vector<double> >(
"bPhi")),
15 bPhiB_(settings.getParameter<
std::vector<double> >(
"bPhiB")),
16 globalChi2Cut_(settings.getParameter<unsigned
int>(
"globalChi2Cut")),
17 chiSquare_(settings.getParameter<
std::vector<double> >(
"chiSquare")),
18 chiSquareCutPattern_(settings.getParameter<
std::vector<
int> >(
"chiSquareCutPattern")),
19 chiSquareCutCurv_(settings.getParameter<
std::vector<
int> >(
"chiSquareCutCurvMax")),
20 chiSquareCut_(settings.getParameter<
std::vector<
int> >(
"chiSquareCut")),
21 combos4_(settings.getParameter<
std::vector<
int> >(
"combos4")),
22 combos3_(settings.getParameter<
std::vector<
int> >(
"combos3")),
23 combos2_(settings.getParameter<
std::vector<
int> >(
"combos2")),
24 combos1_(settings.getParameter<
std::vector<
int> >(
"combos1")),
25 useOfflineAlgo_(settings.getParameter<
bool>(
"useOfflineAlgo")),
26 mScatteringPhi_(settings.getParameter<
std::vector<double> >(
"mScatteringPhi")),
27 mScatteringPhiB_(settings.getParameter<
std::vector<double> >(
"mScatteringPhiB")),
28 pointResolutionPhi_(settings.getParameter<double>(
"pointResolutionPhi")),
29 pointResolutionPhiB_(settings.getParameter<double>(
"pointResolutionPhiB")),
30 pointResolutionVertex_(settings.getParameter<double>(
"pointResolutionVertex"))
41 for (
uint i=0;
i<tracks.size();++
i) {
42 printf(
"Code=%d, track=%d\n",tracks[
i].
hitPattern(),mask);
44 return std::make_pair(
true,
i);
46 return std::make_pair(
false,0);
73 float lsb=1.25/
float(1<<13);
74 int pt =
int(2*(1.0/(lsb*
float(K))));
84 int pt2 =
int(1.0/(lsb*
float(K2)));
92 int processor=track.
sector();
110 word1=word1 | quality<<9;
112 word1=word1 | HF<<22;
116 word2=word2 | signValid<<1;
117 word2=word2 | dxy<<2;
118 word2=word2 | trackAddr<<4;
120 word2=word2 | pt2<<23;
122 out->push_back(bx,muon);
134 for (
const auto& stub :stubs) {
136 if (stub->stNum()!=track.
step())
144 return std::make_pair(found,best);
151 return 8*stub->phiB();
156 if (stub->scNum()==sector) {
159 else if ((stub->scNum()==sector-1) || (stub->scNum()==11 && sector==0)) {
160 return stub->phi()-2144;
162 else if ((stub->scNum()==sector+1) || (stub->scNum()==0 && sector==11)) {
163 return stub->phi()+2144;
170 unsigned int mask = 0;
171 for (
const auto& stub : track.
stubs()) {
172 mask = mask+round(
pow(2,stub->stNum()-1));
180 return bit1*1+bit2*2+bit3*4+bit4*8;
184 return (bitmask & ( 1 << pos )) >> pos;
224 a[3] =
aPhi_[step-1];
227 a[5] = -
bPhi_[step-1];
234 ROOT::Math::SMatrix<double,3>
P(a,9);
236 const std::vector<double>& covLine = track.
covariance();
238 cov = ROOT::Math::Similarity(P,cov);
245 std::vector<double>
b(6);
258 printf(
"Covariance term for phiB = %f\n",cov(2,2));
259 printf(
"Multiple scattering term for phiB = %f\n",MS(2,2));
273 if (mask==3 || mask ==5 || mask==9 ||mask==6|| mask==10 ||mask==12)
299 residual[1] = phiB-trackPhiB;
322 const std::vector<double>& covLine = track.
covariance();
331 track.
setKalmanGain(track.
step(),
abs(trackK),
Gain(0,0),
Gain(0,1),
Gain(1,0),
Gain(1,1),
Gain(2,0),
Gain(2,1));
333 int KNew = (trackK+
int(
Gain(0,0)*residual(0)+
Gain(0,1)*residual(1)));
337 int phiNew =
wrapAround(trackPhi+residual(0),8192);
338 int phiBNew =
wrapAround(trackPhiB+
int(
Gain(2,0)*residual(0)+
Gain(2,1)*residual(1)),2048);
344 printf(
" K = %d + %f * %f + %f * %f\n",trackK,
Gain(0,0),residual(0),
Gain(0,1),residual(1));
345 printf(
" phiB = %d + %f * %f + %f * %f\n",trackPhiB,
Gain(2,0),residual(0),
Gain(2,1),residual(1));
350 Matrix33 covNew = cov - Gain*(H*cov);
363 printf(
"Post Fit Covariance Matrix %f %f %f \n",cov(0,0),cov(1,1),cov(2,2));
392 const std::vector<double>& covLine = track.
covariance();
401 track.
setKalmanGain(track.
step(),
abs(trackK),
Gain(0,0),0.0,
Gain(1,0),0.0,
Gain(2,0),0.0);
404 int phiNew =
wrapAround(trackPhi+residual,8192);
407 Matrix33 covNew = cov - Gain*(H*cov);
443 residual[1] = phiB-trackPhiB;
452 if (!(mask==3 || mask ==5 || mask==9 ||mask==6|| mask==10 ||mask==12)) {
460 int KNew =
wrapAround(trackK+
int(GAIN[0]*residual(0)+GAIN[1]*residual(1)),8192);
461 int phiNew =
wrapAround(trackPhi+residual(0),8192);
462 int phiBNew =
wrapAround(trackPhiB+
int(GAIN[2]*residual(0)+GAIN[3]*residual(1)),2048);
474 if (stub->qeta1()>=0) {
478 if (stub->qeta2()>=0)
485 if (stub->qeta2()>=0)
486 track.
setFineEta((stub->eta1()+stub->eta2())/2);
509 double residual = -track.
dxy();
515 const std::vector<double>& covLine = track.
covariance();
524 printf(
"sigma3=%f sigma6=%f\n",cov(0,3),cov(3,3));
525 printf(
" K = %d + %f * %f\n",track.
curvature(),
Gain(0,0),residual);
532 printf(
"Post fit impact parameter=%d\n",dxyNew);
534 Matrix33 covNew = cov - Gain*(H*cov);
552 double residual = -track.
dxy();
576 double lsb = 1.25/
float(1 << 13);
577 double lsbEta = 0.010875;
589 double eta = etaINT*lsbEta;
597 FK = fabs(0.912*FK+(2.557
e-5)*FK*FK-6);
602 double pt = 1.0/(lsb*(FK));
612 double pt = 1.0/(lsb*
abs(K));
621 std::vector<int> combinatorics;
622 switch(seed->stNum()) {
639 printf(
"Something really bad happend\n");
644 for(
const auto&
mask : combinatorics) {
647 if (seed->quality()<4)
653 charge=phiB/
abs(phiB);
654 int initialK =
int(
initK_[seed->stNum()-1]*phiB/(1+
initK2_[seed->stNum()-1]*charge*phiB));
662 track.setCoordinates(seed->stNum(),initialK,
correctedPhi(seed,seed->scNum()),phiB);
665 track.setCoarseEta(seed->coarseEta());
667 if (seed->qeta1()>=0) {
668 if (seed->qeta2()>=0) {
669 track.setFineEta((seed->eta1()+seed->eta2())/2);
672 track.setFineEta(seed->eta1());
690 track.setCovariance(covariance);
693 printf(
"New Kalman fit staring at step=%d, phi=%d,phiB=%d with curvature=%d\n",
track.step(),
track.positionAngle(),
track.bendingAngle(),
track.curvature());
695 for (
unsigned int i=0;
i<4;++
i)
698 printf(
"------------------------------------------------------\n");
699 printf(
"------------------------------------------------------\n");
700 printf(
"------------------------------------------------------\n");
702 for (
const auto& stub: stubs)
703 printf(
"station=%d phi=%d phiB=%d qual=%d \n",stub->stNum(),
correctedPhi(stub,seed->scNum()),
correctedPhiB(stub),stub->quality());
704 printf(
"------------------------------------------------------\n");
705 printf(
"------------------------------------------------------\n");
709 while(
track.step()>0) {
711 if (
track.step()==1) {
715 printf (
"Unconstrained PT in Muon System: pt=%f\n",
track.ptUnconstrained());
720 printf(
"propagated Coordinates step:%d,phi=%d,phiB=%d,K=%d\n",
track.step(),
track.positionAngle(),
track.bendingAngle(),
track.curvature());
724 std::pair<bool,uint> bestStub =
match(
track,stubs);
728 printf(
"updated Coordinates step:%d,phi=%d,phiB=%d,K=%d\n",
track.step(),
track.positionAngle(),
track.bendingAngle(),
track.curvature());
731 if (
track.step()==0) {
734 printf(
" Coordinates before vertex constraint step:%d,phi=%d,dxy=%d,K=%d\n",
track.step(),
track.phiAtVertex(),
track.dxy(),
track.curvatureAtVertex());
740 printf(
" Coordinates after vertex constraint step:%d,phi=%d,dxy=%d,K=%d maximum local chi2=%d\n",
track.step(),
track.phiAtVertex(),
track.dxy(),
track.curvatureAtVertex(),
track.approxChi2());
741 printf(
"------------------------------------------------------\n");
742 printf(
"------------------------------------------------------\n");
747 printf (
"Floating point coordinates at vertex: pt=%f, eta=%f phi=%f\n",
track.pt(),
track.eta(),
track.phi());
748 pretracks.push_back(
track);
758 if (!cleaned.empty())
759 return std::make_pair(
true,cleaned[0]);
760 return std::make_pair(
false,nullTrack);
775 for (
const auto& stub: track.
stubs()) {
799 return value-2*maximum;
801 return value+2*maximum;
809 for (
const auto&
track : tracks) {
810 if (
track.stubs().size()>bestSegments &&
track.hasFineEta()) {
811 bestFineEta =
track.fineEta();
812 bestSegments=
track.stubs().size();
816 for (
auto &
track :tracks) {
817 if (bestSegments!=0 && (!
track.hasFineEta())) {
818 track.setFineEta(bestFineEta);
833 printf(
" -----Preselected Kalman Tracks-----\n");
838 for(
const auto& track1 : tracks) {
840 printf(
"Preselected Kalman Track charge=%d pt=%f eta=%f phi=%f curvature=%d curvature STA =%d stubs=%d chi2=%d pts=%f %f\n",track1.charge(),track1.pt(),track1.eta(),track1.phi(),track1.curvatureAtVertex(),track1.curvatureAtMuon(),
int(track1.stubs().size()),track1.approxChi2(),track1.pt(),track1.ptUnconstrained());
851 pretracks.push_back(track1);
854 for(
const auto& track1 : pretracks) {
856 for(
const auto& track2 : pretracks) {
859 if (!track1.overlapTrack(track2))
861 if (track1.rank()<track2.rank())
865 out.push_back(track1);
869 printf(
" -----Algo Result Kalman Tracks-----\n");
870 for (
const auto& track1 :out)
871 printf(
"Final Kalman Track charge=%d pt=%f eta=%f phi=%f curvature=%d curvature STA =%d stubs=%d chi2=%d pts=%f %f\n",track1.charge(),track1.pt(),track1.eta(),track1.phi(),track1.curvatureAtVertex(),track1.curvatureAtMuon(),
int(track1.stubs().size()),track1.approxChi2(),track1.pt(),track1.ptUnconstrained());
878 std::sort(out.begin(),out.end(),
sorter);
882 for (
uint i=0;
i<out.size();++
i)
884 exported.push_back(out[
i]);
897 else if (sector==1) {
919 else if (sector==1) {
940 std::map<int,int>
out;
941 if (track.
wheel()>=0)
958 for (
const auto stub: track.
stubs()) {
959 bool ownwheel = stub->whNum() == track.
wheel();
961 if ((stub->scNum()==track.
sector()+1) || (stub->scNum()==0 && track.
sector()==11))
963 if ((stub->scNum()==track.
sector()-1) || (stub->scNum()==11 && track.
sector()==0))
965 int addr =
encode(ownwheel,sector,stub->tag());
967 if (stub->stNum()==4) {
971 if (stub->stNum()==3) {
974 if (stub->stNum()==2) {
977 if (stub->stNum()==1) {
std::vector< double > bPhiB_
int correctedPhiB(const L1MuKBMTCombinedStubRef &)
void setHwPt2(int bits)
Set compressed second displaced pT as transmitted by hardware LSB = 1.0 (8 bits)
std::vector< double > aPhi_
std::vector< int > combos1_
ROOT::Math::SMatrix< double, 3, 3 > Matrix33
void setCoordinatesAtVertex(int, int, int)
std::vector< double > aPhiB_
std::pair< bool, uint > match(const L1MuKBMTrack &, const L1MuKBMTCombinedStubRefVector &)
std::vector< double > aPhiBNLO_
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > CovarianceMatrix2
L1TMuonBarrelKalmanAlgo(const edm::ParameterSet &settings)
double pointResolutionPhiB_
std::vector< double > mScatteringPhiB_
bool update(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &, int)
void estimateChiSquare(L1MuKBMTrack &)
int rank(const L1MuKBMTrack &)
void setPtUnconstrained(float)
bool updateOffline1D(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &)
double pointResolutionVertex_
std::vector< edm::Ref< L1MuKBMTCombinedStubCollection > > L1MuKBMTCombinedStubRefVector
void setPtEtaPhi(double, double, double)
void vertexConstraintLUT(L1MuKBMTrack &)
void setCharge(Charge q) final
set electric charge
std::pair< bool, uint > getByCode(const L1MuKBMTrackCollection &tracks, int mask)
std::vector< double > chiSquare_
bool updateLUT(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &, int)
int curvatureAtMuon() const
std::vector< double > initK2_
void setCoordinates(int, int, int, int)
ROOT::Math::SVector< double, 2 > Vector2
void setCovariance(const CovarianceMatrix &)
std::vector< double > mScatteringPhi_
Abs< T >::type abs(const T &t)
void setDataword(uint32_t msbs, uint32_t lsbs)
void setHwHF(bool bit)
Set HF (halo / fine eta) bit (EMTF: halo -> 1; BMTF: fine eta -> 1)
void vertexConstraint(L1MuKBMTrack &)
int customBitmask(unsigned int, unsigned int, unsigned int, unsigned int)
std::vector< double > eLoss_
void vertexConstraintOffline(L1MuKBMTrack &)
const L1MuKBMTCombinedStubRefVector & stubs() const
std::vector< int > combos4_
std::vector< double > bPhi_
std::vector< double > initK_
void updateEta(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &)
ROOT::Math::SMatrix< double, 2, 3 > Matrix23
void setFloatingPointValues(L1MuKBMTrack &, bool)
void setHwDXY(int bits)
Set compressed impact parameter with respect to beamspot (4 bits)
ROOT::Math::SMatrix< double, 1, 3 > Matrix13
int encode(bool ownwheel, int sector, bool tag)
std::vector< int > chiSquareCutPattern_
const std::vector< double > & covariance() const
std::unique_ptr< L1TMuonBarrelKalmanLUTs > lutService_
std::pair< bool, L1MuKBMTrack > chain(const L1MuKBMTCombinedStubRef &, const L1MuKBMTCombinedStubRefVector &)
int curvatureAtVertex() const
std::pair< OmniClusterRef, TrackingParticleRef > P
std::vector< int > chiSquareCut_
double S(const TLorentzVector &, const TLorentzVector &)
void addBMTFMuon(int, const L1MuKBMTrack &, std::unique_ptr< l1t::RegionalMuonCandBxCollection > &)
L1MuKBMTrackCollection cleanAndSort(const L1MuKBMTrackCollection &, uint)
int hitPattern(const L1MuKBMTrack &)
void setKalmanGain(unsigned int step, unsigned int K, float a1, float a2, float a3, float a4=0, float a5=0, float a6=0)
std::vector< L1MuKBMTrack > L1MuKBMTrackCollection
int correctedPhi(const L1MuKBMTCombinedStubRef &, int)
void propagate(L1MuKBMTrack &)
std::vector< int > chiSquareCutCurv_
void addStub(const L1MuKBMTCombinedStubRef &)
void setResidual(uint, int)
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
double pointResolutionPhi_
ROOT::Math::SMatrix< double, 3, 1 > Matrix31
int positionAngle() const
bool updateOffline(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &)
ROOT::Math::SMatrix< double, 3, 2 > Matrix32
void resolveEtaUnit(L1MuKBMTrackCollection &)
Power< A, B >::type pow(const A &a, const B &b)
std::vector< int > combos3_
std::vector< int > combos2_
std::map< int, int > trackAddress(const L1MuKBMTrack &, int &)