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<double>(
"phiAt2")),
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 trackComp_(settings.getParameter<
std::vector<double> >(
"trackComp")),
23 trackCompErr1_(settings.getParameter<
std::vector<double> >(
"trackCompErr1")),
24 trackCompErr2_(settings.getParameter<
std::vector<double> >(
"trackCompErr2")),
25 trackCompPattern_(settings.getParameter<
std::vector<
int> >(
"trackCompCutPattern")),
26 trackCompCutCurv_(settings.getParameter<
std::vector<
int> >(
"trackCompCutCurvMax")),
27 trackCompCut_(settings.getParameter<
std::vector<
int> >(
"trackCompCut")),
28 chiSquareCutTight_(settings.getParameter<
std::vector<
int> >(
"chiSquareCutTight")),
29 combos4_(settings.getParameter<
std::vector<
int> >(
"combos4")),
30 combos3_(settings.getParameter<
std::vector<
int> >(
"combos3")),
31 combos2_(settings.getParameter<
std::vector<
int> >(
"combos2")),
32 combos1_(settings.getParameter<
std::vector<
int> >(
"combos1")),
33 useOfflineAlgo_(settings.getParameter<
bool>(
"useOfflineAlgo")),
34 mScatteringPhi_(settings.getParameter<
std::vector<double> >(
"mScatteringPhi")),
35 mScatteringPhiB_(settings.getParameter<
std::vector<double> >(
"mScatteringPhiB")),
36 pointResolutionPhi_(settings.getParameter<double>(
"pointResolutionPhi")),
37 pointResolutionPhiB_(settings.getParameter<double>(
"pointResolutionPhiB")),
38 pointResolutionVertex_(settings.getParameter<double>(
"pointResolutionVertex"))
49 for (
uint i=0;
i<tracks.size();++
i) {
50 printf(
"Code=%d, track=%d\n",tracks[
i].
hitPattern(),mask);
52 return std::make_pair(
true,
i);
54 return std::make_pair(
false,0);
111 int processor=track.
sector();
131 word1=word1 | quality<<9;
133 word1=word1 | HF<<22;
137 word2=word2 | signValid<<1;
138 word2=word2 | dxy<<2;
139 word2=word2 | trackAddr<<4;
141 word2=word2 | pt2<<23;
187 std::map<uint,uint> diffInfo;
192 std::map<uint,uint> stubInfo;
194 int sector = seed->scNum();
195 int previousSector=sector-1;
196 int nextSector=sector+1;
204 int wheel = seed->whNum();
220 for (
const auto& stub :stubs) {
223 if (stub->stNum()!=
step)
228 if (stub->scNum()==previousSector) {
229 if (stub->whNum()==
wheel) {
239 else if (stub->whNum()==innerWheel){
250 else if (stub->scNum()==sector) {
251 if (stub->whNum()==
wheel) {
261 else if (stub->whNum()==innerWheel){
272 else if (stub->scNum()==nextSector) {
273 if (stub->whNum()==
wheel) {
283 else if (stub->whNum()==innerWheel){
315 if (diffInfo[s4]!=60000)
316 return std::make_pair(
true,stubInfo[s4]);
318 return std::make_pair(
false,0);
328 return 8*stub->phiB();
333 if (stub->scNum()==sector) {
336 else if ((stub->scNum()==sector-1) || (stub->scNum()==11 && sector==0)) {
337 return stub->phi()-2144;
339 else if ((stub->scNum()==sector+1) || (stub->scNum()==0 && sector==11)) {
340 return stub->phi()+2144;
347 unsigned int mask = 0;
348 for (
const auto& stub : track.
stubs()) {
349 mask = mask+round(
pow(2,stub->stNum()-1));
357 return bit1*1+bit2*2+bit3*4+bit4*8;
361 return (bitmask & ( 1 << pos )) >> pos;
396 deltaK =2*addr-
int(2*addr/(1+
eLoss_[step-1]*addr));
399 printf(
"propagate to vertex K=%d deltaK=%d addr=%d\n",K,deltaK,addr);
412 printf(
"phi prop = %d* %f = %d, %d* %f =%d\n",K,
aPhi_[step-1],phi11,phiB,-
bPhi_[step-1],phi12);
420 printf(
"phiB prop = %d* %f = %d, %d* %f =%d\n",K,
aPhiB_[step-1],phiB11,phiB,
bPhiB_[step-1],phiB12);
438 a[3] =
aPhi_[step-1];
441 a[5] = -
bPhi_[step-1];
445 a[6] =
aPhiB_[step-1]/2.0;
451 ROOT::Math::SMatrix<double,3>
P(a,9);
453 const std::vector<double>& covLine = track.
covariance();
455 cov = ROOT::Math::Similarity(P,cov);
462 std::vector<double>
b(6);
475 printf(
"Covariance term for phiB = %f\n",cov(2,2));
476 printf(
"Multiple scattering term for phiB = %f\n",MS(2,2));
490 if (mask==3 || mask ==5 || mask==9 ||mask==6|| mask==10 ||mask==12)
514 residual[1] = phiB-trackPhiB;
535 const std::vector<double>& covLine = track.
covariance();
544 track.
setKalmanGain(track.
step(),fabs(trackK),
Gain(0,0),
Gain(0,1),
Gain(1,0),
Gain(1,1),
Gain(2,0),
Gain(2,1));
546 int KNew = (trackK+
int(
Gain(0,0)*residual(0)+
Gain(0,1)*residual(1)));
550 int phiNew =
wrapAround(trackPhi+residual(0),8192);
551 int phiBNew =
wrapAround(trackPhiB+
int(
Gain(2,0)*residual(0)+
Gain(2,1)*residual(1)),4096);
553 track.
setResidual(stub->stNum()-1,fabs(phi-phiNew)+fabs(phiB-phiBNew)/8);
557 printf(
" K = %d + %f * %f + %f * %f\n",trackK,
Gain(0,0),residual(0),
Gain(0,1),residual(1));
558 printf(
" phiB = %d + %f * %f + %f * %f\n",trackPhiB,
Gain(2,0),residual(0),
Gain(2,1),residual(1));
563 Matrix33 covNew = cov - Gain*(H*cov);
576 printf(
"Post Fit Covariance Matrix %f %f %f \n",cov(0,0),cov(1,1),cov(2,2));
605 const std::vector<double>& covLine = track.
covariance();
614 track.
setKalmanGain(track.
step(),fabs(trackK),
Gain(0,0),0.0,
Gain(1,0),0.0,
Gain(2,0),0.0);
617 int phiNew =
wrapAround(trackPhi+residual,8192);
620 Matrix33 covNew = cov - Gain*(H*cov);
650 if (stub->quality()<4)
654 int residualPhi =
wrapAround(phi-trackPhi,4096);
655 int residualPhiB =
wrapAround(phiB-trackPhiB,8192);
659 printf(
"residuals %d-%d=%d %d-%d=%d\n",phi,trackPhi,
int(residualPhi),phiB,trackPhiB,
int(residualPhiB));
662 uint absK = fabs(trackK);
666 std::vector<float> GAIN;
668 if (!(mask==3 || mask ==5 || mask==9 ||mask==6|| mask==10 ||mask==12)) {
680 printf(
"Gains:%d %f %f %f %f\n",absK/4,GAIN[0],GAIN[1],GAIN[2],GAIN[3]);
681 track.
setKalmanGain(track.
step(),fabs(trackK),GAIN[0],GAIN[1],1,0,GAIN[2],GAIN[3]);
686 int KNew = trackK+k_0+k_1;
687 if (fabs(KNew)>=8191)
693 int pbdouble_0 =
fp_product(fabs(GAIN[2]),residualPhi,9);
695 int pb_1 =
fp_product(GAIN[3],residualPhiB,9);
698 printf(
"phiupdate: %d %d\n",pb_0,pb_1);
701 if (!(mask==3 || mask ==5 || mask==9 ||mask==6|| mask==10 ||mask==12)) {
703 if (fabs(trackPhiB+pb_0)>=4095)
707 phiBNew =
wrapAround(trackPhiB+pb_1-pbdouble_0,4096);
708 if (fabs(trackPhiB+pb_1-pbdouble_0)>=4095)
743 double residual = -track.
dxy();
749 const std::vector<double>& covLine = track.
covariance();
758 printf(
"sigma3=%f sigma6=%f\n",cov(0,3),cov(3,3));
759 printf(
" K = %d + %f * %f\n",track.
curvature(),
Gain(0,0),residual);
766 printf(
"Post fit impact parameter=%d\n",dxyNew);
768 Matrix33 covNew = cov - Gain*(H*cov);
786 double residual = -track.
dxy();
794 int k_0 =
fp_product(GAIN.first,
int(residual),7);
798 printf(
"VERTEX GAIN(%d)= %f * %d = %d\n",absK/2,GAIN.first,
int(residual),k_0);
803 int p_0 =
fp_product(GAIN.second,
int(residual),7);
819 double lsb = 1.25/
float(1 << 13);
820 double lsbEta = 0.010875;
833 double eta = etaINT*lsbEta;
844 double pt = 1.0/(lsb*fabs(K));
855 std::vector<int> combinatorics;
856 switch(seed->stNum()) {
873 printf(
"Something really bad happend\n");
878 for(
const auto&
mask : combinatorics) {
885 charge=phiB/fabs(phiB);
888 if (
track.step()==4 && (fabs(seed->phiB())>15))
891 if (
track.step()==3 && (fabs(seed->phiB())>30))
893 if (
track.step()==2 && (fabs(seed->phiB())>127))
894 address=charge*127*8;
895 int initialK =
int(
initK_[seed->stNum()-1]*address/(1+
initK2_[seed->stNum()-1]*charge*address));
901 track.setCoordinates(seed->stNum(),initialK,
correctedPhi(seed,seed->scNum()),phiB);
902 if (seed->quality()<4) {
923 track.setCovariance(covariance);
926 printf(
"New Kalman fit staring at step=%d, phi=%d,phiB=%d with curvature=%d\n",
track.step(),
track.positionAngle(),
track.bendingAngle(),
track.curvature());
928 for (
unsigned int i=0;
i<4;++
i)
931 printf(
"------------------------------------------------------\n");
932 printf(
"------------------------------------------------------\n");
933 printf(
"------------------------------------------------------\n");
935 for (
const auto& stub: stubs)
936 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());
937 printf(
"------------------------------------------------------\n");
938 printf(
"------------------------------------------------------\n");
944 while(
track.step()>0) {
946 if (
track.step()==1) {
959 printf (
"Unconstrained PT in Muon System: pt=%f\n",
track.ptUnconstrained());
964 printf(
"propagated Coordinates step:%d,phi=%d,phiB=%d,K=%d\n",
track.step(),
track.positionAngle(),
track.bendingAngle(),
track.curvature());
968 std::pair<bool,uint> bestStub =
match(seed,stubs,
track.step());
972 printf(
"updated Coordinates step:%d,phi=%d,phiB=%d,K=%d\n",
track.step(),
track.positionAngle(),
track.bendingAngle(),
track.curvature());
977 if (
track.step()==0) {
980 printf(
" Coordinates before vertex constraint step:%d,phi=%d,dxy=%d,K=%d\n",
track.step(),
track.phiAtVertex(),
track.dxy(),
track.curvatureAtVertex());
982 printf(
"Chi Square = %d\n",
track.approxChi2());
987 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());
988 printf(
"------------------------------------------------------\n");
989 printf(
"------------------------------------------------------\n");
993 track.setCoordinatesAtMuon(
track.curvatureAtMuon(),phiAtStation2,
track.phiBAtMuon());
996 printf (
"Floating point coordinates at vertex: pt=%f, eta=%f phi=%f\n",
track.pt(),
track.eta(),
track.phi());
997 pretracks.push_back(
track);
1004 if (!cleaned.empty()) {
1005 return std::make_pair(
true,cleaned[0]);
1007 return std::make_pair(
false,nullTrack);
1028 for (
const auto& stub: track.
stubs()) {
1031 int diff1 =
wrapAround(stubCoords-coords,1024);
1035 printf(
"Chi Square stub for track with coords=%d -> AK=%d stubCoords=%d diff=%d delta=%d\n",coords,AK,stubCoords,diff1,delta);
1065 if (track.
stubs().size()!=2) {
1074 if (track.
stubs()[0]->quality()>track.
stubs()[1]->quality())
1080 int delta = fabs(diff);
1102 return 160+(track.
stubs().size())*20-chi;
1110 if (value>maximum-1)
1128 else if (sector==1) {
1150 else if (sector==1) {
1171 std::map<int,int>
out;
1174 if (track.
wheel()==-2)
1176 else if (track.
wheel()==-1)
1178 else if (track.
wheel()==0)
1180 else if (track.
wheel()==1)
1182 else if (track.
wheel()==2)
1197 for (
const auto stub: track.
stubs()) {
1198 bool ownwheel = stub->whNum() == track.
wheel();
1200 if ((stub->scNum()==track.
sector()+1) || (stub->scNum()==0 && track.
sector()==11))
1202 if ((stub->scNum()==track.
sector()-1) || (stub->scNum()==11 && track.
sector()==0))
1204 int addr =
encode(ownwheel,sector,stub->tag());
1206 if (stub->stNum()==4) {
1213 if (stub->stNum()==3) {
1216 if (stub->stNum()==2) {
1219 if (stub->stNum()==1) {
1250 return (
long((a*(1<<bits))*b))>>
bits;
1256 int charge = (K>=0) ? +1 : -1;
1257 float lsb=1.25/
float(1<<13);
1269 FK = 0.898*FK/(1.0-0.6*FK);
1271 FK=FK-26.382*FK*FK*FK*FK*FK;
1273 FK=FK-charge*1.408e-3;
1300 std::map<uint,int> infoRank;
1301 std::map<uint,L1MuKBMTrack> infoTrack;
1308 for (
const auto&
track :tracks) {
1317 int sel6 = infoRank[10]>= infoRank[12] ? 10 : 12;
1318 int sel5 = infoRank[14]>= infoRank[9] ? 14 : 9;
1319 int sel4 = infoRank[11]>= infoRank[13] ? 11 : 13;
1320 int sel3 = infoRank[sel6]>= infoRank[sel5] ? sel6 : sel5;
1321 int sel2 = infoRank[sel4]>= infoRank[sel3] ? sel4 : sel3;
1322 selected = infoRank[15]>= infoRank[sel2] ? 15 : sel2;
1326 int sel2 = infoRank[5]>= infoRank[6] ? 5 : 6;
1327 selected = infoRank[7]>= infoRank[sel2] ? 7 : sel2;
1332 auto search = infoTrack.find(selected);
1333 if (
search != infoTrack.end())
1334 out.push_back(
search->second);
1347 if (stub->qeta1()!=0 && stub->qeta2()!=0) {
1350 if (stub->qeta1()==0) {
1354 return (stub->qeta1());
1361 uint awheel=fabs(wheel);
1367 for (
unsigned int i=0;
i<track.
stubs().size();++
i) {
1368 if (fabs(track.
stubs()[
i]->whNum())!=awheel)
1371 mask=(awheel<<nstubs)|mask;
1378 for (
const auto& stub : track.
stubs()) {
1384 sums+=rank*stub->eta1();
1391 else if (sumweights==2)
1393 else if (sumweights==3)
1395 else if (sumweights==4)
1397 else if (sumweights==5)
1399 else if (sumweights==6)
1424 for (
const auto& stub:track.
stubs())
1425 if (stub->stNum()==2)
1434 printf(
"Phi at second station=%d\n",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
void setTrackCompatibility(int)
int phiAt2(const L1MuKBMTrack &track)
bool update(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &, int)
int rank(const L1MuKBMTrack &)
void setPtUnconstrained(float)
std::vector< int > trackCompPattern_
bool updateOffline1D(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &)
double pointResolutionVertex_
void estimateCompatibility(L1MuKBMTrack &)
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
std::vector< double > trackComp_
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_
bool estimateChiSquare(L1MuKBMTrack &)
void vertexConstraintOffline(L1MuKBMTrack &)
const L1MuKBMTCombinedStubRefVector & stubs() const
uint matchAbs(std::map< uint, uint > &, uint, uint)
std::vector< int > combos4_
std::vector< int > chiSquareCutTight_
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 > &)
int hitPattern(const L1MuKBMTrack &)
std::vector< std::vector< double > > tmp
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)
std::vector< double > trackCompErr1_
void propagate(L1MuKBMTrack &)
std::vector< int > chiSquareCutCurv_
void addStub(const L1MuKBMTCombinedStubRef &)
std::vector< double > trackCompErr2_
void setResidual(uint, int)
std::vector< float > trackGain(uint, uint, uint)
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
double pointResolutionPhi_
std::vector< int > trackCompCut_
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 > trackCompCutCurv_
std::vector< int > combos2_
std::map< int, int > trackAddress(const L1MuKBMTrack &, int &)