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 phiAt2_(settings.getParameter<
std::vector<double> >(
"phiAt2")),
17 globalChi2Cut_(settings.getParameter<unsigned
int>(
"globalChi2Cut")),
18 chiSquare_(settings.getParameter<
std::vector<double> >(
"chiSquare")),
19 chiSquareCutPattern_(settings.getParameter<
std::vector<
int> >(
"chiSquareCutPattern")),
20 chiSquareCutCurv_(settings.getParameter<
std::vector<
int> >(
"chiSquareCutCurvMax")),
21 chiSquareCut_(settings.getParameter<
std::vector<
int> >(
"chiSquareCut")),
22 combos4_(settings.getParameter<
std::vector<
int> >(
"combos4")),
23 combos3_(settings.getParameter<
std::vector<
int> >(
"combos3")),
24 combos2_(settings.getParameter<
std::vector<
int> >(
"combos2")),
25 combos1_(settings.getParameter<
std::vector<
int> >(
"combos1")),
26 useOfflineAlgo_(settings.getParameter<
bool>(
"useOfflineAlgo")),
27 mScatteringPhi_(settings.getParameter<
std::vector<double> >(
"mScatteringPhi")),
28 mScatteringPhiB_(settings.getParameter<
std::vector<double> >(
"mScatteringPhiB")),
29 pointResolutionPhi_(settings.getParameter<double>(
"pointResolutionPhi")),
30 pointResolutionPhiB_(settings.getParameter<double>(
"pointResolutionPhiB")),
31 pointResolutionVertex_(settings.getParameter<double>(
"pointResolutionVertex"))
42 for (
uint i=0;
i<tracks.size();++
i) {
43 printf(
"Code=%d, track=%d\n",tracks[
i].
hitPattern(),mask);
45 return std::make_pair(
true,
i);
47 return std::make_pair(
false,0);
98 phi =signPhi*
int((phi*2*
M_PI/(6.0*2048.0))/(0.625*
M_PI/180.0));
100 int processor=track.
sector();
118 word1=word1 | quality<<9;
120 word1=word1 | HF<<22;
124 word2=word2 | signValid<<1;
125 word2=word2 | dxy<<2;
126 word2=word2 | trackAddr<<4;
128 word2=word2 | pt2<<23;
146 for (
const auto& stub :stubs) {
148 if (stub->stNum()!=
step)
158 return std::make_pair(found,best);
165 return 8*stub->phiB();
170 if (stub->scNum()==sector) {
173 else if ((stub->scNum()==sector-1) || (stub->scNum()==11 && sector==0)) {
174 return stub->phi()-2144;
176 else if ((stub->scNum()==sector+1) || (stub->scNum()==0 && sector==11)) {
177 return stub->phi()+2144;
184 unsigned int mask = 0;
185 for (
const auto& stub : track.
stubs()) {
186 mask = mask+round(
pow(2,stub->stNum()-1));
194 return bit1*1+bit2*2+bit3*4+bit4*8;
198 return (bitmask & ( 1 << pos )) >> pos;
233 deltaK =2*addr-
int(2*addr/(1+
eLoss_[step-1]*addr));
236 printf(
"propagate to vertex K=%d deltaK=%d addr=%d\n",K,deltaK,addr);
249 printf(
"phi prop = %d* %f = %d, %d* %f =%d\n",K,
aPhi_[step-1],phi11,phiB,-
bPhi_[step-1],phi12);
257 printf(
"phiB prop = %d* %f = %d, %d* %f =%d\n",K,
aPhiB_[step-1],phiB11,phiB,
bPhiB_[step-1],phiB12);
275 a[3] =
aPhi_[step-1];
278 a[5] = -
bPhi_[step-1];
285 ROOT::Math::SMatrix<double,3>
P(a,9);
287 const std::vector<double>& covLine = track.
covariance();
289 cov = ROOT::Math::Similarity(P,cov);
296 std::vector<double>
b(6);
309 printf(
"Covariance term for phiB = %f\n",cov(2,2));
310 printf(
"Multiple scattering term for phiB = %f\n",MS(2,2));
324 if (mask==3 || mask ==5 || mask==9 ||mask==6|| mask==10 ||mask==12)
348 residual[1] = phiB-trackPhiB;
371 const std::vector<double>& covLine = track.
covariance();
380 track.
setKalmanGain(track.
step(),fabs(trackK),
Gain(0,0),
Gain(0,1),
Gain(1,0),
Gain(1,1),
Gain(2,0),
Gain(2,1));
382 int KNew = (trackK+
int(
Gain(0,0)*residual(0)+
Gain(0,1)*residual(1)));
386 int phiNew =
wrapAround(trackPhi+residual(0),8192);
387 int phiBNew =
wrapAround(trackPhiB+
int(
Gain(2,0)*residual(0)+
Gain(2,1)*residual(1)),2048);
389 track.
setResidual(stub->stNum()-1,fabs(phi-phiNew)+fabs(phiB-phiBNew)/8);
393 printf(
" K = %d + %f * %f + %f * %f\n",trackK,
Gain(0,0),residual(0),
Gain(0,1),residual(1));
394 printf(
" phiB = %d + %f * %f + %f * %f\n",trackPhiB,
Gain(2,0),residual(0),
Gain(2,1),residual(1));
399 Matrix33 covNew = cov - Gain*(H*cov);
412 printf(
"Post Fit Covariance Matrix %f %f %f \n",cov(0,0),cov(1,1),cov(2,2));
441 const std::vector<double>& covLine = track.
covariance();
450 track.
setKalmanGain(track.
step(),fabs(trackK),
Gain(0,0),0.0,
Gain(1,0),0.0,
Gain(2,0),0.0);
453 int phiNew =
wrapAround(trackPhi+residual,8192);
456 Matrix33 covNew = cov - Gain*(H*cov);
489 int residualPhi =
wrapAround(phi-trackPhi,8192);
490 int residualPhiB =
wrapAround(phiB-trackPhiB,2048);
494 printf(
"residuals %d %d\n",
int(residualPhi),
int(residualPhiB));
497 uint absK = fabs(trackK);
501 std::vector<float> GAIN;
503 if (!(mask==3 || mask ==5 || mask==9 ||mask==6|| mask==10 ||mask==12)) {
515 printf(
"Gains:%d %f %f %f %f\n",absK/4,GAIN[0],GAIN[1],GAIN[2],GAIN[3]);
516 track.
setKalmanGain(track.
step(),fabs(trackK),GAIN[0],GAIN[1],1,0,GAIN[2],GAIN[3]);
523 printf(
"Kupdate: %d %d\n",k_0,k_1);
528 int pbdouble_0 =
fp_product(fabs(GAIN[2]),residualPhi,9);
530 int pb_1 =
fp_product(GAIN[3],residualPhiB,9);
533 printf(
"phiupdate: %d %d\n",pb_0,pb_1);
536 if (!(mask==3 || mask ==5 || mask==9 ||mask==6|| mask==10 ||mask==12))
539 phiBNew =
wrapAround(trackPhiB+pb_1-pbdouble_0,2048);
572 double residual = -track.
dxy();
578 const std::vector<double>& covLine = track.
covariance();
587 printf(
"sigma3=%f sigma6=%f\n",cov(0,3),cov(3,3));
588 printf(
" K = %d + %f * %f\n",track.
curvature(),
Gain(0,0),residual);
595 printf(
"Post fit impact parameter=%d\n",dxyNew);
597 Matrix33 covNew = cov - Gain*(H*cov);
615 double residual = -track.
dxy();
623 int k_0 =
fp_product(GAIN.first,
int(residual),7);
627 printf(
"VERTEX GAIN(%d)= %f * %d = %d\n",absK/2,GAIN.first,
int(residual),k_0);
632 int p_0 =
fp_product(GAIN.second,
int(residual),7);
648 double lsb = 1.25/
float(1 << 13);
649 double lsbEta = 0.010875;
661 double eta = etaINT*lsbEta;
671 double pt = 1.0/(lsb*(FK));
681 double pt = 1.0/(lsb*fabs(K));
690 std::vector<int> combinatorics;
691 switch(seed->stNum()) {
708 printf(
"Something really bad happend\n");
713 for(
const auto&
mask : combinatorics) {
720 charge=phiB/fabs(phiB);
723 if (
track.step()>=3 && (fabs(seed->phiB())>63))
725 if (
track.step()==2 && (fabs(seed->phiB())>127))
726 address=charge*127*8;
727 int initialK =
int(
initK_[seed->stNum()-1]*address/(1+
initK2_[seed->stNum()-1]*charge*address));
732 track.setCoordinates(seed->stNum(),initialK,
correctedPhi(seed,seed->scNum()),phiB);
733 if (seed->quality()<4) {
754 track.setCovariance(covariance);
757 printf(
"New Kalman fit staring at step=%d, phi=%d,phiB=%d with curvature=%d\n",
track.step(),
track.positionAngle(),
track.bendingAngle(),
track.curvature());
759 for (
unsigned int i=0;
i<4;++
i)
762 printf(
"------------------------------------------------------\n");
763 printf(
"------------------------------------------------------\n");
764 printf(
"------------------------------------------------------\n");
766 for (
const auto& stub: stubs)
767 printf(
"station=%d phi=%d phiB=%d qual=%d tag=%d sector=%d wheel=%d fineEta= %d %d\n",stub->stNum(),
correctedPhi(stub,seed->scNum()),
correctedPhiB(stub),stub->quality(),stub->tag(),stub->scNum(),stub->whNum(),stub->eta1(),stub->eta2());
768 printf(
"------------------------------------------------------\n");
769 printf(
"------------------------------------------------------\n");
775 while(
track.step()>0) {
777 if (
track.step()==1) {
788 printf (
"Unconstrained PT in Muon System: pt=%f\n",
track.ptUnconstrained());
793 printf(
"propagated Coordinates step:%d,phi=%d,phiB=%d,K=%d\n",
track.step(),
track.positionAngle(),
track.bendingAngle(),
track.curvature());
797 std::pair<bool,uint> bestStub =
match(seed,stubs,
track.step());
801 printf(
"updated Coordinates step:%d,phi=%d,phiB=%d,K=%d\n",
track.step(),
track.positionAngle(),
track.bendingAngle(),
track.curvature());
806 if (
track.step()==0) {
809 printf(
" Coordinates before vertex constraint step:%d,phi=%d,dxy=%d,K=%d\n",
track.step(),
track.phiAtVertex(),
track.dxy(),
track.curvatureAtVertex());
811 printf(
"Chi Square = %d\n",
track.approxChi2());
817 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());
818 printf(
"------------------------------------------------------\n");
819 printf(
"------------------------------------------------------\n");
823 track.setCoordinatesAtMuon(
track.curvatureAtMuon(),phiAtStation2,
track.phiBAtMuon());
826 printf (
"Floating point coordinates at vertex: pt=%f, eta=%f phi=%f\n",
track.pt(),
track.eta(),
track.phi());
827 pretracks.push_back(
track);
834 if (!cleaned.empty()) {
837 printf(
"Punch through veto=%d\n",veto);
839 return std::make_pair(
true,cleaned[0]);
841 return std::make_pair(
false,nullTrack);
857 for (
const auto& stub: track.
stubs()) {
885 return value-2*maximum;
887 return value+2*maximum;
906 printf(
" -----Preselected Kalman Tracks-----\n");
909 for(
const auto& track1 : pretracks) {
911 printf(
"Pre Track charge=%d pt=%f eta=%f phi=%f curvature=%d curvature STA =%d stubs=%d bitmask=%d rank=%d chi=%d pts=%f %f\n",track1.charge(),track1.pt(),track1.eta(),track1.phi(),track1.curvatureAtVertex(),track1.curvatureAtMuon(),
int(track1.stubs().size()),track1.hitPattern(),
rank(track1),track1.approxChi2(),track1.pt(),track1.ptUnconstrained());
914 for(
const auto& track2 : pretracks) {
917 if (!track1.overlapTrack(track2))
919 if (track1.rank()<track2.rank())
923 out.push_back(track1);
927 printf(
" -----Algo Result Kalman Tracks-----\n");
928 for (
const auto& track1 :out)
929 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());
936 std::sort(out.begin(),out.end(),
sorter);
940 for (
uint i=0;
i<out.size();++
i)
942 exported.push_back(out[
i]);
955 else if (sector==1) {
977 else if (sector==1) {
998 std::map<int,int>
out;
999 if (track.
wheel()>=0)
1016 for (
const auto stub: track.
stubs()) {
1017 bool ownwheel = stub->whNum() == track.
wheel();
1019 if ((stub->scNum()==track.
sector()+1) || (stub->scNum()==0 && track.
sector()==11))
1021 if ((stub->scNum()==track.
sector()-1) || (stub->scNum()==11 && track.
sector()==0))
1023 int addr =
encode(ownwheel,sector,stub->tag());
1025 if (stub->stNum()==4) {
1029 if (stub->stNum()==3) {
1032 if (stub->stNum()==2) {
1035 if (stub->stNum()==1) {
1065 return long(a*(1<<bits)*b)>>
bits;
1071 float lsb=1.25/
float(1<<13);
1072 float ptF = (2*(1.0/(lsb*
float(K))));
1075 KF = 0.797*KF+0.454*KF*KF-5.679e-4;
1095 std::map<uint,int> infoRank;
1096 std::map<uint,L1MuKBMTrack> infoTrack;
1103 for (
const auto&
track :tracks) {
1112 int sel6 = infoRank[12]>= infoRank[10] ? 12 : 10;
1113 int sel5 = infoRank[14]>= infoRank[9] ? 14 : 9;
1114 int sel4 = infoRank[11]>= infoRank[13] ? 11 : 13;
1115 int sel3 = infoRank[sel6]>= infoRank[sel5] ? sel6 : sel5;
1116 int sel2 = infoRank[sel4]>= infoRank[sel3] ? sel4 : sel3;
1117 selected = infoRank[15]>= infoRank[sel2] ? 15 : sel2;
1121 int sel2 = infoRank[5]>= infoRank[6] ? 5 : 6;
1122 selected = infoRank[7]>= infoRank[sel2] ? 7 : sel2;
1127 auto search = infoTrack.find(selected);
1128 if (
search != infoTrack.end())
1129 out.push_back(
search->second);
1138 if (stub->qeta1()!=0 && stub->qeta2()!=0) {
1141 if (stub->qeta1()==0) {
1145 return (stub->qeta1());
1152 uint awheel=fabs(wheel);
1158 for (
unsigned int i=0;
i<track.
stubs().size();++
i) {
1159 if (fabs(track.
stubs()[
i]->whNum())!=awheel)
1162 mask=(awheel<<nstubs)|mask;
1169 for (
const auto& stub : track.
stubs()) {
1175 sums+=rank*stub->eta1();
1182 else if (sumweights==2)
1184 else if (sumweights==3)
1186 else if (sumweights==4)
1188 else if (sumweights==5)
1190 else if (sumweights==6)
1216 for (
const auto& stub:track.
stubs())
1217 if (stub->stNum()==2)
1229 int phiNew =phi+phi11+phi12;
1237 printf(
"phi at station 2 = %d* %f = %d, %d* %f =%d , final=%d\n",K,
phiAt2_[0],phi11,phiB,
phiAt2_[1],phi12,phiNew);
std::vector< double > bPhiB_
int correctedPhiB(const L1MuKBMTCombinedStubRef &)
l1t::RegionalMuonCand convertToBMTF(const L1MuKBMTrack &track)
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::vector< double > aPhiBNLO_
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > CovarianceMatrix2
L1TMuonBarrelKalmanAlgo(const edm::ParameterSet &settings)
uint coarseEta(uint, uint)
std::pair< bool, uint > match(const L1MuKBMTCombinedStubRef &, const L1MuKBMTCombinedStubRefVector &, int)
double pointResolutionPhiB_
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
std::vector< double > mScatteringPhiB_
std::vector< float > trackGain2(uint, uint, uint)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
int phiAt2(const L1MuKBMTrack &track)
bool punchThroughVeto(const L1MuKBMTrack &track)
bool update(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &, int)
void estimateChiSquare(L1MuKBMTrack &)
int rank(const L1MuKBMTrack &)
void setPtUnconstrained(float)
std::vector< double > phiAt2_
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)
int fp_product(float, int, uint)
std::vector< double > chiSquare_
bool updateLUT(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &, int)
int curvatureAtMuon() const
std::vector< double > initK2_
std::pair< float, float > vertexGain(uint, uint)
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)
L1TMuonBarrelKalmanLUTs * lutService_
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
L1MuKBMTrackCollection clean(const L1MuKBMTrackCollection &, uint)
int encode(bool ownwheel, int sector, bool tag)
std::vector< int > chiSquareCutPattern_
const std::vector< double > & covariance() const
std::pair< bool, L1MuKBMTrack > chain(const L1MuKBMTCombinedStubRef &, const L1MuKBMTCombinedStubRefVector &)
void calculateEta(L1MuKBMTrack &track)
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)
std::vector< float > trackGain(uint, uint, uint)
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
Power< A, B >::type pow(const A &a, const B &b)
uint etaStubRank(const L1MuKBMTCombinedStubRef &)
std::vector< int > combos3_
std::vector< int > combos2_
std::map< int, int > trackAddress(const L1MuKBMTrack &, int &)