CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
L1TMuonBarrelKalmanAlgo Class Reference

#include <L1TMuonBarrelKalmanAlgo.h>

Classes

class  StubSorter
 

Public Types

typedef ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > CovarianceMatrix2
 
typedef ROOT::Math::SMatrix< double, 1, 3 > Matrix13
 
typedef ROOT::Math::SMatrix< double, 2, 3 > Matrix23
 
typedef ROOT::Math::SMatrix< double, 3, 1 > Matrix31
 
typedef ROOT::Math::SMatrix< double, 3, 2 > Matrix32
 
typedef ROOT::Math::SMatrix< double, 3, 3 > Matrix33
 
typedef ROOT::Math::SVector< double, 2 > Vector2
 

Public Member Functions

void addBMTFMuon (int, const L1MuKBMTrack &, std::unique_ptr< l1t::RegionalMuonCandBxCollection > &)
 
std::pair< bool, L1MuKBMTrackchain (const L1MuKBMTCombinedStubRef &, const L1MuKBMTCombinedStubRefVector &)
 
L1MuKBMTrackCollection clean (const L1MuKBMTrackCollection &, uint)
 
l1t::RegionalMuonCand convertToBMTF (const L1MuKBMTrack &track)
 
 L1TMuonBarrelKalmanAlgo (const edm::ParameterSet &settings)
 

Private Member Functions

void calculateEta (L1MuKBMTrack &track)
 
int correctedPhi (const L1MuKBMTCombinedStubRef &, int)
 
int correctedPhiB (const L1MuKBMTCombinedStubRef &)
 
int customBitmask (unsigned int, unsigned int, unsigned int, unsigned int)
 
int encode (bool ownwheel, int sector, bool tag)
 
bool estimateChiSquare (L1MuKBMTrack &)
 
void estimateCompatibility (L1MuKBMTrack &)
 
uint etaStubRank (const L1MuKBMTCombinedStubRef &)
 
int fp_product (float, int, uint)
 
bool getBit (int, int)
 
std::pair< bool, uint > getByCode (const L1MuKBMTrackCollection &tracks, int mask)
 
int hitPattern (const L1MuKBMTrack &)
 
std::pair< bool, uint > match (const L1MuKBMTCombinedStubRef &, const L1MuKBMTCombinedStubRefVector &, int)
 
uint matchAbs (std::map< uint, uint > &, uint, uint)
 
int phiAt2 (const L1MuKBMTrack &track)
 
void propagate (L1MuKBMTrack &)
 
int ptLUT (int K)
 
int rank (const L1MuKBMTrack &)
 
void setFloatingPointValues (L1MuKBMTrack &, bool)
 
std::map< int, int > trackAddress (const L1MuKBMTrack &, int &)
 
uint twosCompToBits (int)
 
bool update (L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &, int)
 
void updateEta (L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &)
 
bool updateLUT (L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &, int)
 
bool updateOffline (L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &)
 
bool updateOffline1D (L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &)
 
void vertexConstraint (L1MuKBMTrack &)
 
void vertexConstraintLUT (L1MuKBMTrack &)
 
void vertexConstraintOffline (L1MuKBMTrack &)
 
int wrapAround (int, int)
 

Private Attributes

std::vector< double > aPhi_
 
std::vector< double > aPhiB_
 
std::vector< double > aPhiBNLO_
 
std::vector< double > bPhi_
 
std::vector< double > bPhiB_
 
std::vector< double > chiSquare_
 
std::vector< int > chiSquareCut_
 
std::vector< int > chiSquareCutCurv_
 
std::vector< int > chiSquareCutPattern_
 
std::vector< int > chiSquareCutTight_
 
std::vector< int > combos1_
 
std::vector< int > combos2_
 
std::vector< int > combos3_
 
std::vector< int > combos4_
 
std::vector< double > eLoss_
 
std::vector< double > etaLUT0_
 
std::vector< double > etaLUT1_
 
uint globalChi2Cut_
 
uint globalChi2CutLimit_
 
std::vector< double > initK2_
 
std::vector< double > initK_
 
L1TMuonBarrelKalmanLUTslutService_
 
std::vector< double > mScatteringPhi_
 
std::vector< double > mScatteringPhiB_
 
double phiAt2_
 
double pointResolutionPhi_
 
double pointResolutionPhiB_
 
double pointResolutionVertex_
 
std::vector< double > trackComp_
 
std::vector< int > trackCompCut_
 
std::vector< int > trackCompCutCurv_
 
std::vector< double > trackCompErr1_
 
std::vector< double > trackCompErr2_
 
std::vector< int > trackCompPattern_
 
bool useOfflineAlgo_
 
bool verbose_
 

Detailed Description

Definition at line 16 of file L1TMuonBarrelKalmanAlgo.h.

Member Typedef Documentation

typedef ROOT::Math::SMatrix<double,2,2,ROOT::Math::MatRepSym<double,2> > L1TMuonBarrelKalmanAlgo::CovarianceMatrix2

Definition at line 19 of file L1TMuonBarrelKalmanAlgo.h.

typedef ROOT::Math::SMatrix<double,1,3> L1TMuonBarrelKalmanAlgo::Matrix13

Definition at line 22 of file L1TMuonBarrelKalmanAlgo.h.

typedef ROOT::Math::SMatrix<double,2,3> L1TMuonBarrelKalmanAlgo::Matrix23

Definition at line 21 of file L1TMuonBarrelKalmanAlgo.h.

typedef ROOT::Math::SMatrix<double,3,1> L1TMuonBarrelKalmanAlgo::Matrix31

Definition at line 23 of file L1TMuonBarrelKalmanAlgo.h.

typedef ROOT::Math::SMatrix<double,3,2> L1TMuonBarrelKalmanAlgo::Matrix32

Definition at line 20 of file L1TMuonBarrelKalmanAlgo.h.

typedef ROOT::Math::SMatrix<double,3,3> L1TMuonBarrelKalmanAlgo::Matrix33

Definition at line 24 of file L1TMuonBarrelKalmanAlgo.h.

typedef ROOT::Math::SVector<double,2> L1TMuonBarrelKalmanAlgo::Vector2

Definition at line 18 of file L1TMuonBarrelKalmanAlgo.h.

Constructor & Destructor Documentation

L1TMuonBarrelKalmanAlgo::L1TMuonBarrelKalmanAlgo ( const edm::ParameterSet settings)

Definition at line 5 of file L1TMuonBarrelKalmanAlgo.cc.

5  :
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")),
17 
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"))
39 
40 {
41 
42 
43 
44 }
std::vector< double > bPhiB_
T getParameter(std::string const &) const
std::vector< double > aPhi_
std::vector< double > aPhiB_
std::vector< double > aPhiBNLO_
std::vector< double > mScatteringPhiB_
std::vector< int > trackCompPattern_
std::vector< double > chiSquare_
std::vector< double > initK2_
std::vector< double > trackComp_
std::vector< double > mScatteringPhi_
L1TMuonBarrelKalmanLUTs * lutService_
std::vector< double > eLoss_
std::vector< int > chiSquareCutTight_
std::vector< double > bPhi_
std::vector< double > initK_
std::vector< int > chiSquareCutPattern_
std::vector< double > trackCompErr1_
std::vector< int > chiSquareCutCurv_
std::vector< double > trackCompErr2_
std::vector< int > trackCompCutCurv_

Member Function Documentation

void L1TMuonBarrelKalmanAlgo::addBMTFMuon ( int  bx,
const L1MuKBMTrack track,
std::unique_ptr< l1t::RegionalMuonCandBxCollection > &  out 
)

Definition at line 146 of file L1TMuonBarrelKalmanAlgo.cc.

References convertToBMTF().

Referenced by L1TMuonBarrelKalmanTrackProducer::produce().

146  {
147  out->push_back(bx,convertToBMTF(track));
148 }
l1t::RegionalMuonCand convertToBMTF(const L1MuKBMTrack &track)
void L1TMuonBarrelKalmanAlgo::calculateEta ( L1MuKBMTrack track)
private

Definition at line 1358 of file L1TMuonBarrelKalmanAlgo.cc.

References L1TMuonBarrelKalmanLUTs::coarseEta(), PVValHelper::eta, etaStubRank(), fp_product(), L1MuKBMTrack::hitPattern(), mps_fire::i, lutService_, RecoTauDiscriminantConfiguration::mask, listBenchmarks::pattern, rank(), L1MuKBMTrack::setCoarseEta(), L1MuKBMTrack::setFineEta(), Validation_hcalonly_cfi::sign, L1MuKBMTrack::stubs(), parallelization::uint(), and makeMuonMisalignmentScenario::wheel.

Referenced by chain().

1358  {
1359  uint pattern = track.hitPattern();
1360  int wheel = track.stubs()[0]->whNum();
1361  uint awheel=fabs(wheel);
1362  int sign=1;
1363  if (wheel<0)
1364  sign=-1;
1365  uint nstubs = track.stubs().size();
1366  uint mask=0;
1367  for (unsigned int i=0;i<track.stubs().size();++i) {
1368  if (fabs(track.stubs()[i]->whNum())!=awheel)
1369  mask=mask|(1<<i);
1370  }
1371  mask=(awheel<<nstubs)|mask;
1372  track.setCoarseEta(sign*lutService_->coarseEta(pattern,mask));
1373 
1374 
1375  int sumweights=0;
1376  int sums=0;
1377 
1378  for (const auto& stub : track.stubs()) {
1379  uint rank = etaStubRank(stub);
1380  if (rank==0)
1381  continue;
1382  // printf("Stub station=%d rank=%d values=%d %d\n",stub->stNum(),rank,stub->eta1(),stub->eta2());
1383  sumweights+=rank;
1384  sums+=rank*stub->eta1();
1385  }
1386 
1387  //0.5 0.332031 0.25 0.199219 0.164063
1388  float factor;
1389  if (sumweights==1)
1390  factor=1.0;
1391  else if (sumweights==2)
1392  factor = 0.5;
1393  else if (sumweights==3)
1394  factor=0.332031;
1395  else if (sumweights==4)
1396  factor=0.25;
1397  else if (sumweights==5)
1398  factor=0.199219;
1399  else if (sumweights==6)
1400  factor=0.164063;
1401  else
1402  factor=0.0;
1403 
1404 
1405 
1406 
1407  int eta=0;
1408  if (sums>0)
1409  eta=fp_product(factor,sums,10);
1410  else
1411  eta=-fp_product(factor,fabs(sums),10);
1412 
1413 
1414  //int eta=int(factor*sums);
1415  // printf("Eta debug %f *%d=%d\n",factor,sums,eta);
1416 
1417  if (sumweights>0)
1418  track.setFineEta(eta);
1419 }
int rank(const L1MuKBMTrack &)
int fp_product(float, int, uint)
L1TMuonBarrelKalmanLUTs * lutService_
void setCoarseEta(int)
void setFineEta(int)
const L1MuKBMTCombinedStubRefVector & stubs() const
def uint(string)
int hitPattern() const
Definition: L1MuKBMTrack.cc:90
uint etaStubRank(const L1MuKBMTCombinedStubRef &)
std::pair< bool, L1MuKBMTrack > L1TMuonBarrelKalmanAlgo::chain ( const L1MuKBMTCombinedStubRef seed,
const L1MuKBMTCombinedStubRefVector stubs 
)

Definition at line 853 of file L1TMuonBarrelKalmanAlgo.cc.

References calculateEta(), ALCARECOTkAlJpsiMuMu_cff::charge, clean(), combos1_, combos2_, combos3_, combos4_, correctedPhi(), correctedPhiB(), estimateChiSquare(), estimateCompatibility(), objects.autophobj::float, getBit(), hitPattern(), mps_fire::i, initK2_, initK_, createfilelist::int, RecoTauDiscriminantConfiguration::mask, match(), TriggerAnalyzer::passed, phiAt2(), pointResolutionPhi_, pointResolutionPhiB_, propagate(), rank(), setFloatingPointValues(), HiIsolationCommonParameters_cff::track, update(), verbose_, and vertexConstraint().

Referenced by L1TMuonBarrelKalmanRegionModule::process().

853  {
854  L1MuKBMTrackCollection pretracks;
855  std::vector<int> combinatorics;
856  switch(seed->stNum()) {
857  case 1:
858  combinatorics=combos1_;
859  break;
860  case 2:
861  combinatorics=combos2_;
862  break;
863 
864  case 3:
865  combinatorics=combos3_;
866  break;
867 
868  case 4:
869  combinatorics=combos4_;
870  break;
871 
872  default:
873  printf("Something really bad happend\n");
874  }
875 
876  L1MuKBMTrack nullTrack(seed,correctedPhi(seed,seed->scNum()),correctedPhiB(seed));
877 
878  for( const auto& mask : combinatorics) {
879  L1MuKBMTrack track(seed,correctedPhi(seed,seed->scNum()),correctedPhiB(seed));
880  int phiB = correctedPhiB(seed);
881  int charge;
882  if (phiB==0)
883  charge = 0;
884  else
885  charge=phiB/fabs(phiB);
886 
887  int address=phiB;
888  if (track.step()==4 && (fabs(seed->phiB())>15))
889  address=charge*15*8;
890 
891  if (track.step()==3 && (fabs(seed->phiB())>30))
892  address=charge*30*8;
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));
896  if (initialK>8191)
897  initialK=8191;
898  if (initialK<-8191)
899  initialK=-8191;
900 
901  track.setCoordinates(seed->stNum(),initialK,correctedPhi(seed,seed->scNum()),phiB);
902  if (seed->quality()<4) {
903  track.setCoordinates(seed->stNum(),0,correctedPhi(seed,seed->scNum()),0);
904  }
905 
906 
907 
908  track.setHitPattern(hitPattern(track));
909  //set covariance
910  L1MuKBMTrack::CovarianceMatrix covariance;
911 
912 
913  float DK=512*512.;
914  covariance(0,0)=DK;
915  covariance(0,1)=0;
916  covariance(0,2)=0;
917  covariance(1,0)=0;
918  covariance(1,1)=float(pointResolutionPhi_);
919  covariance(1,2)=0;
920  covariance(2,0)=0;
921  covariance(2,1)=0;
922  covariance(2,2)=float(pointResolutionPhiB_);
923  track.setCovariance(covariance);
924  //
925  if (verbose_) {
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());
927  printf("BITMASK:");
928  for (unsigned int i=0;i<4;++i)
929  printf("%d",getBit(mask,i));
930  printf("\n");
931  printf("------------------------------------------------------\n");
932  printf("------------------------------------------------------\n");
933  printf("------------------------------------------------------\n");
934  printf("stubs:\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");
939 
940  }
941 
942  int phiAtStation2=0;
943 
944  while(track.step()>0) {
945  // muon station 1
946  if (track.step()==1) {
947  track.setCoordinatesAtMuon(track.curvature(),track.positionAngle(),track.bendingAngle());
948  phiAtStation2=phiAt2(track);
950  if (!passed)
951  break;
954  //calculate coarse eta
956 
957 
958  if (verbose_)
959  printf ("Unconstrained PT in Muon System: pt=%f\n",track.ptUnconstrained());
960  }
961 
962  propagate(track);
963  if (verbose_)
964  printf("propagated Coordinates step:%d,phi=%d,phiB=%d,K=%d\n",track.step(),track.positionAngle(),track.bendingAngle(),track.curvature());
965 
966  if (track.step()>0)
967  if (getBit(mask,track.step()-1)) {
968  std::pair<bool,uint> bestStub = match(seed,stubs,track.step());
969  if ((!bestStub.first) || (!update(track,stubs[bestStub.second],mask)))
970  break;
971  if (verbose_) {
972  printf("updated Coordinates step:%d,phi=%d,phiB=%d,K=%d\n",track.step(),track.positionAngle(),track.bendingAngle(),track.curvature());
973  }
974  }
975 
976 
977  if (track.step()==0) {
978  track.setCoordinatesAtVertex(track.curvature(),track.positionAngle(),track.bendingAngle());
979  if (verbose_)
980  printf(" Coordinates before vertex constraint step:%d,phi=%d,dxy=%d,K=%d\n",track.step(),track.phiAtVertex(),track.dxy(),track.curvatureAtVertex());
981  if (verbose_)
982  printf("Chi Square = %d\n",track.approxChi2());
983 
986  if (verbose_) {
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");
990  }
992  //rset the coordinates at muon to include phi at station 2
993  track.setCoordinatesAtMuon(track.curvatureAtMuon(),phiAtStation2,track.phiBAtMuon());
994  track.setRank(rank(track));
995  if (verbose_)
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);
998  }
999  }
1000  }
1001  //Now for all the pretracks we need only one
1002  L1MuKBMTrackCollection cleaned = clean(pretracks,seed->stNum());
1003 
1004  if (!cleaned.empty()) {
1005  return std::make_pair(true,cleaned[0]);
1006  }
1007  return std::make_pair(false,nullTrack);
1008 }
int correctedPhiB(const L1MuKBMTCombinedStubRef &)
std::pair< bool, uint > match(const L1MuKBMTCombinedStubRef &, const L1MuKBMTCombinedStubRefVector &, int)
int phiAt2(const L1MuKBMTrack &track)
bool update(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &, int)
int rank(const L1MuKBMTrack &)
void estimateCompatibility(L1MuKBMTrack &)
std::vector< double > initK2_
void vertexConstraint(L1MuKBMTrack &)
bool estimateChiSquare(L1MuKBMTrack &)
std::vector< double > initK_
void setFloatingPointValues(L1MuKBMTrack &, bool)
L1MuKBMTrackCollection clean(const L1MuKBMTrackCollection &, uint)
void calculateEta(L1MuKBMTrack &track)
int hitPattern(const L1MuKBMTrack &)
std::vector< L1MuKBMTrack > L1MuKBMTrackCollection
Definition: L1MuKBMTrack.h:15
int correctedPhi(const L1MuKBMTCombinedStubRef &, int)
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Candidate.h:47
L1MuKBMTrackCollection L1TMuonBarrelKalmanAlgo::clean ( const L1MuKBMTrackCollection tracks,
uint  seed 
)

Definition at line 1297 of file L1TMuonBarrelKalmanAlgo.cc.

References mps_fire::i, MillePedeFileConverter_cfg::out, rank(), cond::persistency::search(), HiIsolationCommonParameters_cff::track, and parallelization::uint().

Referenced by chain().

1297  {
1299 
1300  std::map<uint,int> infoRank;
1301  std::map<uint,L1MuKBMTrack> infoTrack;
1302  for (uint i=3;i<=15;++i) {
1303  if (i==4 ||i==8)
1304  continue;
1305  infoRank[i]=-1;
1306  }
1307 
1308  for (const auto& track :tracks) {
1309  infoRank[track.hitPattern()] = rank(track);
1310  infoTrack[track.hitPattern()]=track;
1311  }
1312 
1313 
1314  int selected=15;
1315  if (seed==4) //station 4 seeded
1316  {
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;
1323  }
1324  if (seed==3) //station 3 seeded
1325  {
1326  int sel2 = infoRank[5]>= infoRank[6] ? 5 : 6;
1327  selected = infoRank[7]>= infoRank[sel2] ? 7 : sel2;
1328  }
1329  if (seed==2) //station 3 seeded
1330  selected = 3;
1331 
1332  auto search = infoTrack.find(selected);
1333  if (search != infoTrack.end())
1334  out.push_back(search->second);
1335 
1336  return out;
1337 
1338 
1339 }
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:314
int rank(const L1MuKBMTrack &)
def uint(string)
std::vector< L1MuKBMTrack > L1MuKBMTrackCollection
Definition: L1MuKBMTrack.h:15
l1t::RegionalMuonCand L1TMuonBarrelKalmanAlgo::convertToBMTF ( const L1MuKBMTrack track)

Definition at line 59 of file L1TMuonBarrelKalmanAlgo.cc.

References funct::abs(), l1t::bmtf, L1MuKBMTrack::coarseEta(), L1MuKBMTrack::curvatureAtMuon(), L1MuKBMTrack::curvatureAtVertex(), L1MuKBMTrack::dxy(), PVValHelper::dxy, PVValHelper::eta, L1MuKBMTrack::fineEta(), fp_product(), L1MuKBMTrack::hasFineEta(), CaloTPGTranscoder_cfi::HF, metsig::muon, phi, L1MuKBMTrack::phiAtMuon(), EnergyCorrector::pt, hiDetachedQuadStep_cff::pt2, ptLUT(), jets_cff::quality, rank(), L1MuKBMTrack::sector(), l1t::RegionalMuonCand::setDataword(), l1t::RegionalMuonCand::setHwDXY(), l1t::RegionalMuonCand::setHwHF(), l1t::RegionalMuonCand::setHwPt2(), Validation_hcalonly_cfi::sign, tmp, trackAddress(), twosCompToBits(), and L1MuKBMTrack::wheel().

Referenced by addBMTFMuon(), and L1TMuonBarrelKalmanSectorProcessor::makeWord().

59  {
60  // int K = fabs(track.curvatureAtVertex());
61 
62  //calibration
63  int sign,signValid;
64 
65  if (track.curvatureAtVertex()==0) {
66  sign=0;
67  signValid=0;
68  }
69  else if (track.curvatureAtVertex()>0) {
70  sign=0;
71  signValid=1;
72  }
73  else {
74  sign=1;
75  signValid=1;
76  }
77 
78  // if (K<22)
79  // K=22;
80 
81  // if (K>4095)
82  // K=4095;
83 
84  int pt = ptLUT(track.curvatureAtVertex());
85 
86 
87  // int K2 = fabs(track.curvatureAtMuon());
88  // if (K2<22)
89  // K2=22;
90 
91  // if (K2>4095)
92  // K2=4095;
93  int pt2 = ptLUT(track.curvatureAtMuon())/2;
94  int eta = track.hasFineEta() ? track.fineEta() : track.coarseEta();
95 
96 
97  // int phi2 = track.phiAtMuon()>>2;
98  // float phi_f = float(phi2);
99  //double kPhi = 57.2958/0.625/1024.;
100  //int phi = 24+int(floor(kPhi*phi_f));
101  // if (phi > 69) phi = 69;
102  // if (phi < -8) phi = -8;
103  int phi2 = track.phiAtMuon()>>2;
104  int tmp = fp_product(0.0895386,phi2,14);
105  int phi = 24+tmp;
106 
107 
108 
109 
110 
111  int processor=track.sector();
112  int HF = track.hasFineEta();
113 
114  int quality=12|(rank(track)>>6);
115 
116  int dxy=abs(track.dxy())>>9;
117  if (dxy>3)
118  dxy=3;
119 
120  int trackAddr;
121  std::map<int,int> addr = trackAddress(track,trackAddr);
122 
123  l1t::RegionalMuonCand muon(pt,phi,eta,sign,signValid,quality,processor,l1t::bmtf,addr);
124  muon.setHwHF(HF);
125  muon.setHwPt2(pt2);
126  muon.setHwDXY(dxy);
127 
128 
129  //nw the words!
130  uint32_t word1=pt;
131  word1=word1 | quality<<9;
132  word1=word1 | (twosCompToBits(eta))<<13;
133  word1=word1 | HF<<22;
134  word1=word1 | (twosCompToBits(phi))<<23;
135 
136  uint32_t word2=sign;
137  word2=word2 | signValid<<1;
138  word2=word2 | dxy<<2;
139  word2=word2 | trackAddr<<4;
140  word2=word2 | (twosCompToBits(track.wheel()))<<20;
141  word2=word2 | pt2<<23;
142  muon.setDataword(word2,word1);
143  return muon;
144 }
int fineEta() const
int coarseEta() const
Definition: L1MuKBMTrack.cc:79
int rank(const L1MuKBMTrack &)
int fp_product(float, int, uint)
int curvatureAtMuon() const
Definition: L1MuKBMTrack.cc:45
bool hasFineEta() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int phiAtMuon() const
Definition: L1MuKBMTrack.cc:48
int wheel() const
int dxy() const
Definition: L1MuKBMTrack.cc:63
int curvatureAtVertex() const
Definition: L1MuKBMTrack.cc:55
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
int sector() const
Definition: L1MuKBMTrack.cc:97
std::map< int, int > trackAddress(const L1MuKBMTrack &, int &)
int L1TMuonBarrelKalmanAlgo::correctedPhi ( const L1MuKBMTCombinedStubRef stub,
int  sector 
)
private

Definition at line 332 of file L1TMuonBarrelKalmanAlgo.cc.

Referenced by chain(), estimateChiSquare(), match(), phiAt2(), updateLUT(), updateOffline(), and updateOffline1D().

332  {
333  if (stub->scNum()==sector) {
334  return stub->phi();
335  }
336  else if ((stub->scNum()==sector-1) || (stub->scNum()==11 && sector==0)) {
337  return stub->phi()-2144;
338  }
339  else if ((stub->scNum()==sector+1) || (stub->scNum()==0 && sector==11)) {
340  return stub->phi()+2144;
341  }
342  return stub->phi();
343 }
int L1TMuonBarrelKalmanAlgo::correctedPhiB ( const L1MuKBMTCombinedStubRef stub)
private

Definition at line 326 of file L1TMuonBarrelKalmanAlgo.cc.

Referenced by chain(), updateLUT(), and updateOffline().

326  {
327  //Promote phiB to 12 bits
328  return 8*stub->phiB();
329 
330 }
int L1TMuonBarrelKalmanAlgo::customBitmask ( unsigned int  bit1,
unsigned int  bit2,
unsigned int  bit3,
unsigned int  bit4 
)
private

Definition at line 356 of file L1TMuonBarrelKalmanAlgo.cc.

Referenced by rank().

356  {
357  return bit1*1+bit2*2+bit3*4+bit4*8;
358 }
int L1TMuonBarrelKalmanAlgo::encode ( bool  ownwheel,
int  sector,
bool  tag 
)
private

Definition at line 1120 of file L1TMuonBarrelKalmanAlgo.cc.

Referenced by trackAddress().

1120  {
1121  if (ownwheel) {
1122  if (sector==0) {
1123  if (tag)
1124  return 9;
1125  else
1126  return 8;
1127  }
1128  else if (sector==1) {
1129  if (tag)
1130  return 11;
1131  else
1132  return 10;
1133 
1134  }
1135  else {
1136  if (tag)
1137  return 13;
1138  else
1139  return 12;
1140  }
1141 
1142  }
1143  else {
1144  if (sector==0) {
1145  if (tag)
1146  return 1;
1147  else
1148  return 0;
1149  }
1150  else if (sector==1) {
1151  if (tag)
1152  return 3;
1153  else
1154  return 2;
1155 
1156  }
1157  else {
1158  if (tag)
1159  return 5;
1160  else
1161  return 4;
1162  }
1163  }
1164  return 15;
1165 }
bool L1TMuonBarrelKalmanAlgo::estimateChiSquare ( L1MuKBMTrack track)
private

Definition at line 1015 of file L1TMuonBarrelKalmanAlgo.cc.

References funct::abs(), L1MuKBMTrack::approxChi2(), chiSquare_, chiSquareCut_, chiSquareCutCurv_, chiSquareCutPattern_, correctedPhi(), L1MuKBMTrack::curvatureAtMuon(), delta, fp_product(), L1MuKBMTrack::hitPattern(), mps_fire::i, L1MuKBMTrack::phiAtMuon(), L1MuKBMTrack::phiBAtMuon(), L1MuKBMTrack::sector(), L1MuKBMTrack::setApproxChi2(), L1MuKBMTrack::stubs(), parallelization::uint(), verbose_, and wrapAround().

Referenced by chain().

1015  {
1016  //here we have a simplification of the algorithm for the sake of the emulator - rsult is identical
1017  // we apply cuts on the firmware as |u -u'|^2 < a+b *K^2
1018  int K = track.curvatureAtMuon();
1019 
1020  uint chi=0;
1021 
1022  // const double PHI[4]={0.0,0.249,0.543,0.786};
1023  // const double DROR[4]={0.0,0.182,0.430,0.677};
1024 
1025 
1026 
1027  int coords = wrapAround((track.phiAtMuon()+track.phiBAtMuon())>>4,512);
1028  for (const auto& stub: track.stubs()) {
1029  int AK = wrapAround(fp_product(-chiSquare_[stub->stNum()-1],K>>4,8),256);
1030  int stubCoords = wrapAround((correctedPhi(stub,track.sector())>>4)+(stub->phiB()>>1),512);
1031  int diff1 = wrapAround(stubCoords-coords,1024);
1032  uint delta = wrapAround(abs(diff1+AK),2048);
1033  chi=chi+delta;
1034  if (verbose_)
1035  printf("Chi Square stub for track with coords=%d -> AK=%d stubCoords=%d diff=%d delta=%d\n",coords,AK,stubCoords,diff1,delta);
1036  }
1037 
1038  if (chi>127)
1039  chi=127;
1040  // for (const auto& stub: track.stubs()) {
1041  // int deltaPhi = (correctedPhi(stub,track.sector())-track.phiAtMuon())>>3;
1042  // int AK = fp_product(PHI[stub->stNum()-1],K>>3,8);
1043  // int BPB = fp_product(DROR[stub->stNum()-1],track.phiBAtMuon()>>3,8);
1044  // chi=chi+abs(deltaPhi-AK-BPB);
1045  // }
1046  // // }
1047 
1048 
1049 
1050  track.setApproxChi2(chi);
1051 
1052  for (uint i=0;i<chiSquareCutPattern_.size();++i) {
1053  if (track.hitPattern()==chiSquareCutPattern_[i] && fabs(K)<chiSquareCutCurv_[i] && track.approxChi2()>chiSquareCut_[i])
1054  return false;
1055  }
1056  return true;
1057 
1058 }
dbl * delta
Definition: mlp_gen.cc:36
int phiBAtMuon() const
Definition: L1MuKBMTrack.cc:51
int fp_product(float, int, uint)
std::vector< double > chiSquare_
int curvatureAtMuon() const
Definition: L1MuKBMTrack.cc:45
int approxChi2() const
Definition: L1MuKBMTrack.cc:83
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const L1MuKBMTCombinedStubRefVector & stubs() const
int phiAtMuon() const
Definition: L1MuKBMTrack.cc:48
std::vector< int > chiSquareCutPattern_
def uint(string)
int correctedPhi(const L1MuKBMTCombinedStubRef &, int)
int sector() const
Definition: L1MuKBMTrack.cc:97
std::vector< int > chiSquareCutCurv_
int hitPattern() const
Definition: L1MuKBMTrack.cc:90
void setApproxChi2(int)
void L1TMuonBarrelKalmanAlgo::estimateCompatibility ( L1MuKBMTrack track)
private

Definition at line 1062 of file L1TMuonBarrelKalmanAlgo.cc.

References L1MuKBMTrack::approxChi2(), chiSquareCutTight_, L1MuKBMTrack::curvatureAtVertex(), delta, diffTreeTool::diff, L1MuKBMTrack::dxy(), fp_product(), L1MuKBMTrack::hitPattern(), mps_fire::i, L1MuKBMTrack::phiAtVertex(), L1MuKBMTrack::setCoordinatesAtVertex(), L1MuKBMTrack::setTrackCompatibility(), L1MuKBMTrack::stubs(), trackComp_, trackCompCut_, trackCompCutCurv_, trackCompErr1_, trackCompErr2_, trackCompPattern_, parallelization::uint(), and wrapAround().

Referenced by chain().

1062  {
1063  int K = track.curvatureAtVertex()>>4;
1064 
1065  if (track.stubs().size()!=2) {
1066  track.setTrackCompatibility(0);
1067  return;
1068  }
1069 
1070 
1071 
1072 
1073  uint stubSel=1;
1074  if (track.stubs()[0]->quality()>track.stubs()[1]->quality())
1075  stubSel=0;
1076 
1077  const L1MuKBMTCombinedStubRef& stub = track.stubs()[stubSel];
1078  int absK = fabs(K);
1079  int diff = wrapAround(stub->phiB()-fp_product(trackComp_[stub->stNum()-1],K,9),2048);
1080  int delta = fabs(diff);
1081  uint err = wrapAround(trackCompErr1_[stub->stNum()-1]+fp_product(trackCompErr2_[stub->stNum()-1],absK,9),256);
1082  track.setTrackCompatibility(delta/err);
1083 
1084  for (uint i=0;i<trackCompPattern_.size();++i) {
1085  int deltaMax = err*trackCompCut_[i];
1086  if ( (track.hitPattern()==trackCompPattern_[i] ) && (absK<trackCompCutCurv_[i]) && ((track.approxChi2()>chiSquareCutTight_[i]) || (delta>deltaMax) )) {
1087  track.setCoordinatesAtVertex(8191,track.phiAtVertex(),track.dxy());
1088  break;
1089  }
1090  }
1091 
1092 }
dbl * delta
Definition: mlp_gen.cc:36
void setCoordinatesAtVertex(int, int, int)
void setTrackCompatibility(int)
int phiAtVertex() const
Definition: L1MuKBMTrack.cc:59
std::vector< int > trackCompPattern_
int fp_product(float, int, uint)
int approxChi2() const
Definition: L1MuKBMTrack.cc:83
std::vector< double > trackComp_
const L1MuKBMTCombinedStubRefVector & stubs() const
std::vector< int > chiSquareCutTight_
int dxy() const
Definition: L1MuKBMTrack.cc:63
def uint(string)
int curvatureAtVertex() const
Definition: L1MuKBMTrack.cc:55
std::vector< double > trackCompErr1_
int hitPattern() const
Definition: L1MuKBMTrack.cc:90
std::vector< double > trackCompErr2_
std::vector< int > trackCompCutCurv_
uint L1TMuonBarrelKalmanAlgo::etaStubRank ( const L1MuKBMTCombinedStubRef stub)
private

Definition at line 1345 of file L1TMuonBarrelKalmanAlgo.cc.

Referenced by calculateEta().

1345  {
1346 
1347  if (stub->qeta1()!=0 && stub->qeta2()!=0) {
1348  return 0;
1349  }
1350  if (stub->qeta1()==0) {
1351  return 0;
1352  }
1353  // return (stub->qeta1()*4+stub->stNum());
1354  return (stub->qeta1());
1355 
1356 }
int L1TMuonBarrelKalmanAlgo::fp_product ( float  a,
int  b,
uint  bits 
)
private

Definition at line 1248 of file L1TMuonBarrelKalmanAlgo.cc.

References bits.

Referenced by calculateEta(), convertToBMTF(), estimateChiSquare(), estimateCompatibility(), phiAt2(), propagate(), updateLUT(), and vertexConstraintLUT().

1248  {
1249  // return long(a*(1<<bits)*b)>>bits;
1250  return (long((a*(1<<bits))*b))>>bits;
1251 }
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
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
bool L1TMuonBarrelKalmanAlgo::getBit ( int  bitmask,
int  pos 
)
private

Definition at line 360 of file L1TMuonBarrelKalmanAlgo.cc.

Referenced by chain().

360  {
361  return (bitmask & ( 1 << pos )) >> pos;
362 }
std::pair< bool, uint > L1TMuonBarrelKalmanAlgo::getByCode ( const L1MuKBMTrackCollection tracks,
int  mask 
)
private

Definition at line 48 of file L1TMuonBarrelKalmanAlgo.cc.

References hitPattern(), mps_fire::i, and parallelization::uint().

48  {
49  for (uint i=0;i<tracks.size();++i) {
50  printf("Code=%d, track=%d\n",tracks[i].hitPattern(),mask);
51  if (tracks[i].hitPattern()==mask)
52  return std::make_pair(true,i);
53  }
54  return std::make_pair(false,0);
55 }
def uint(string)
int hitPattern(const L1MuKBMTrack &)
int L1TMuonBarrelKalmanAlgo::hitPattern ( const L1MuKBMTrack track)
private

Definition at line 346 of file L1TMuonBarrelKalmanAlgo.cc.

References RecoTauDiscriminantConfiguration::mask, funct::pow(), and L1MuKBMTrack::stubs().

Referenced by chain(), getByCode(), rank(), updateLUT(), updateOffline(), and updateOffline1D().

346  {
347  unsigned int mask = 0;
348  for (const auto& stub : track.stubs()) {
349  mask = mask+round(pow(2,stub->stNum()-1));
350  }
351  return mask;
352 }
const L1MuKBMTCombinedStubRefVector & stubs() const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
std::pair< bool, uint > L1TMuonBarrelKalmanAlgo::match ( const L1MuKBMTCombinedStubRef seed,
const L1MuKBMTCombinedStubRefVector stubs,
int  step 
)
private

Definition at line 184 of file L1TMuonBarrelKalmanAlgo.cc.

References correctedPhi(), SoftLeptonByDistance_cfi::distance, mps_fire::i, matchAbs(), N, parallelization::uint(), makeMuonMisalignmentScenario::wheel, and wrapAround().

Referenced by chain().

184  {
186 
187  std::map<uint,uint> diffInfo;
188  for (uint i=0;i<12;++i) {
189  diffInfo[i]=60000;
190  }
191 
192  std::map<uint,uint> stubInfo;
193 
194  int sector = seed->scNum();
195  int previousSector=sector-1;
196  int nextSector=sector+1;
197  if (sector==0) {
198  previousSector=11;
199  }
200  if (sector==11) {
201  nextSector=0;
202  }
203 
204  int wheel = seed->whNum();
205  int innerWheel=0;
206  if (wheel==-2)
207  innerWheel=-1;
208  if (wheel==-1)
209  innerWheel=0;
210  if (wheel==0)
211  innerWheel=1982;
212  if (wheel==1)
213  innerWheel=0;
214  if (wheel==2)
215  innerWheel=1;
216 
217 
218  //First align the data
219  uint N=0;
220  for (const auto& stub :stubs) {
221  N=N+1;
222 
223  if (stub->stNum()!=step)
224  continue;
225 
226  uint distance = fabs(wrapAround(((correctedPhi(seed,seed->scNum())-correctedPhi(stub,seed->scNum()))>>3),1024));
227 
228  if (stub->scNum()==previousSector) {
229  if (stub->whNum()==wheel) {
230  if (!stub->tag()) {
231  diffInfo[0]=distance;
232  stubInfo[0]=N-1;
233  }
234  else {
235  diffInfo[1]=distance;
236  stubInfo[1]=N-1;
237  }
238  }
239  else if (stub->whNum()==innerWheel){
240  if (!stub->tag()) {
241  diffInfo[2]=distance;
242  stubInfo[2]=N-1;
243  }
244  else {
245  diffInfo[3]=distance;
246  stubInfo[3]=N-1;
247  }
248  }
249  }
250  else if (stub->scNum()==sector) {
251  if (stub->whNum()==wheel) {
252  if (!stub->tag()) {
253  diffInfo[4]=distance;
254  stubInfo[4]=N-1;
255  }
256  else {
257  diffInfo[5]=distance;
258  stubInfo[5]=N-1;
259  }
260  }
261  else if (stub->whNum()==innerWheel){
262  if (!stub->tag()) {
263  diffInfo[6]=distance;
264  stubInfo[6]=N-1;
265  }
266  else {
267  diffInfo[7]=distance;
268  stubInfo[7]=N-1;
269  }
270  }
271  }
272  else if (stub->scNum()==nextSector) {
273  if (stub->whNum()==wheel) {
274  if (!stub->tag()) {
275  diffInfo[8]=distance;
276  stubInfo[8]=N-1;
277  }
278  else {
279  diffInfo[9]=distance;
280  stubInfo[9]=N-1;
281  }
282  }
283  else if (stub->whNum()==innerWheel){
284  if (!stub->tag()) {
285  diffInfo[10]=distance;
286  stubInfo[10]=N-1;
287  }
288  else {
289  diffInfo[11]=distance;
290  stubInfo[11]=N-1;
291  }
292  }
293  }
294 
295  }
296 
297 
298  uint s1_1 = matchAbs(diffInfo,0,1);
299  uint s1_2 = matchAbs(diffInfo,2,3);
300  uint s1_3 = matchAbs(diffInfo,4,5);
301  uint s1_4 = matchAbs(diffInfo,6,7);
302  uint s1_5 = matchAbs(diffInfo,8,9);
303  uint s1_6 = matchAbs(diffInfo,10,11);
304 
305  uint s2_1 = matchAbs(diffInfo,s1_1,s1_2);
306  uint s2_2 = matchAbs(diffInfo,s1_3,s1_4);
307  uint s2_3 = matchAbs(diffInfo,s1_5,s1_6);
308 
309  uint s3_1 = matchAbs(diffInfo,s2_1,s2_2);
310 
311  uint s4 = matchAbs(diffInfo,s3_1,s2_3);
312 
313 
314 
315  if (diffInfo[s4]!=60000)
316  return std::make_pair(true,stubInfo[s4]);
317  else
318  return std::make_pair(false,0);
319 }
std::vector< edm::Ref< L1MuKBMTCombinedStubCollection > > L1MuKBMTCombinedStubRefVector
uint matchAbs(std::map< uint, uint > &, uint, uint)
#define N
Definition: blowfish.cc:9
def uint(string)
int correctedPhi(const L1MuKBMTCombinedStubRef &, int)
step
Definition: StallMonitor.cc:94
uint L1TMuonBarrelKalmanAlgo::matchAbs ( std::map< uint, uint > &  info,
uint  i,
uint  j 
)
private

Definition at line 176 of file L1TMuonBarrelKalmanAlgo.cc.

References mps_fire::i.

Referenced by match().

176  {
177  if (info[i]<info[j])
178  return i;
179  else
180  return j;
181 }
static const TGPicture * info(bool iBackgroundIsBlack)
int L1TMuonBarrelKalmanAlgo::phiAt2 ( const L1MuKBMTrack track)
private

Definition at line 1422 of file L1TMuonBarrelKalmanAlgo.cc.

References correctedPhi(), fp_product(), phi, phiAt2_, L1MuKBMTrack::phiAtMuon(), L1MuKBMTrack::phiBAtMuon(), L1MuKBMTrack::sector(), L1MuKBMTrack::stubs(), and verbose_.

Referenced by chain().

1422  {
1423  //If there is stub at station 2 use this else propagate from 1
1424  for (const auto& stub:track.stubs())
1425  if (stub->stNum()==2)
1426  return correctedPhi(stub,track.sector());
1427 
1428  int phi = track.phiAtMuon();
1429  int phiB = track.phiBAtMuon();
1430 
1431 
1432  int phiNew=phi+fp_product(phiAt2_,phiB,10);
1433  if (verbose_)
1434  printf("Phi at second station=%d\n",phiNew);
1435  if (phiNew>4095)
1436  phiNew=4095;
1437  if (phiNew<-4096)
1438  phiNew=-4096;
1439  return phiNew;
1440 
1441 }
int phiBAtMuon() const
Definition: L1MuKBMTrack.cc:51
int fp_product(float, int, uint)
const L1MuKBMTCombinedStubRefVector & stubs() const
int phiAtMuon() const
Definition: L1MuKBMTrack.cc:48
int correctedPhi(const L1MuKBMTCombinedStubRef &, int)
int sector() const
Definition: L1MuKBMTrack.cc:97
void L1TMuonBarrelKalmanAlgo::propagate ( L1MuKBMTrack track)
private

Definition at line 366 of file L1TMuonBarrelKalmanAlgo.cc.

References a, aPhi_, aPhiB_, aPhiBNLO_, b, L1MuKBMTrack::bendingAngle(), bPhi_, bPhiB_, ALCARECOTkAlJpsiMuMu_cff::charge, L1MuKBMTrack::covariance(), L1MuKBMTrack::curvature(), eLoss_, fp_product(), createfilelist::int, mScatteringPhi_, mScatteringPhiB_, phi, L1MuKBMTrack::positionAngle(), L1MuKBMTrack::setCoordinates(), L1MuKBMTrack::setCovariance(), L1MuKBMTrack::step(), verbose_, and wrapAround().

Referenced by chain().

366  {
367  int K = track.curvature();
368  int phi = track.positionAngle();
369  int phiB = track.bendingAngle();
370  unsigned int step = track.step();
371 
372  //energy loss term only for MU->VERTEX
373  //int offset=int(charge*eLoss_[step-1]*K*K);
374  // if (fabs(offset)>4096)
375  // offset=4096*offset/fabs(offset);
376 
377  int charge=1;
378  if (K!=0)
379  charge = K/fabs(K);
380 
381 
382 
383 
384  int KBound=K;
385  if (KBound>4095)
386  KBound=4095;
387  if (KBound<-4095)
388  KBound=-4095;
389 
390  int deltaK=0;
391  int KNew=0;
392  if (step==1) {
393  int addr = KBound/2;
394  if (addr<0)
395  addr=(-KBound)/2;
396  deltaK =2*addr-int(2*addr/(1+eLoss_[step-1]*addr));
397 
398  if (verbose_)
399  printf("propagate to vertex K=%d deltaK=%d addr=%d\n",K,deltaK,addr);
400  }
401 
402  if (K>=0)
403  KNew=K-deltaK;
404  else
405  KNew=K+deltaK;
406 
407 
408  //phi propagation
409  int phi11 = fp_product(aPhi_[step-1],K,10);
410  int phi12 = fp_product(-bPhi_[step-1],phiB,10);
411  if (verbose_) {
412  printf("phi prop = %d* %f = %d, %d* %f =%d\n",K,aPhi_[step-1],phi11,phiB,-bPhi_[step-1],phi12);
413  }
414  int phiNew =wrapAround(phi+phi11+phi12,2048);
415  //phiB propagation
416  int phiB11 = fp_product(aPhiB_[step-1],K,10);
417  int phiB12 = fp_product(bPhiB_[step-1],phiB,11);
418  int phiBNew = wrapAround(phiB11+phiB12,4096);
419  if (verbose_) {
420  printf("phiB prop = %d* %f = %d, %d* %f =%d\n",K,aPhiB_[step-1],phiB11,phiB,bPhiB_[step-1],phiB12);
421  }
422 
423 
424  //Only for the propagation to vertex we use the LUT for better precision and the full function
425  if (step==1) {
426  int addr = KBound/2;
427  phiBNew = wrapAround(int(aPhiB_[step-1]*addr/(1+charge*aPhiBNLO_[step-1]*addr))+int(bPhiB_[step-1]*phiB),4096);
428  }
430  //Rest of the stuff is for the offline version only
431  //where we want to check what is happening in the covariaznce matrix
432 
433  //Create the transformation matrix
434  double a[9];
435  a[0] = 1.;
436  a[1] = 0.0;
437  a[2] = 0.0;
438  a[3] = aPhi_[step-1];
439  // a[3] = 0.0;
440  a[4] = 1.0;
441  a[5] = -bPhi_[step-1];
442  //a[6]=0.0;
443  a[6] = aPhiB_[step-1];
444  if (step==1)
445  a[6] = aPhiB_[step-1]/2.0;
446 
447  a[7] = 0.0;
448  a[8] = bPhiB_[step-1];
449 
450 
451  ROOT::Math::SMatrix<double,3> P(a,9);
452 
453  const std::vector<double>& covLine = track.covariance();
454  L1MuKBMTrack::CovarianceMatrix cov(covLine.begin(),covLine.end());
455  cov = ROOT::Math::Similarity(P,cov);
456 
457 
458  //Add the multiple scattering
459  double phiRMS = mScatteringPhi_[step-1]*K*K;
460  double phiBRMS = mScatteringPhiB_[step-1]*K*K;
461 
462  std::vector<double> b(6);
463  b[0] = 0;
464  b[1] = 0;
465  b[2] =phiRMS;
466  b[3] =0;
467  b[4] = 0;
468  b[5] = phiBRMS;
469 
470  reco::Candidate::CovarianceMatrix MS(b.begin(),b.end());
471 
472  cov = cov+MS;
473 
474  if (verbose_) {
475  printf("Covariance term for phiB = %f\n",cov(2,2));
476  printf("Multiple scattering term for phiB = %f\n",MS(2,2));
477  }
478 
479 
480 
481  track.setCovariance(cov);
482  track.setCoordinates(step-1,KNew,phiNew,phiBNew);
483 
484 }
std::vector< double > bPhiB_
std::vector< double > aPhi_
std::vector< double > aPhiB_
std::vector< double > aPhiBNLO_
int step() const
Definition: L1MuKBMTrack.cc:94
std::vector< double > mScatteringPhiB_
int bendingAngle() const
Definition: L1MuKBMTrack.cc:75
int fp_product(float, int, uint)
void setCoordinates(int, int, int, int)
void setCovariance(const CovarianceMatrix &)
std::vector< double > mScatteringPhi_
std::vector< double > eLoss_
int curvature() const
Definition: L1MuKBMTrack.cc:67
std::vector< double > bPhi_
const std::vector< double > & covariance() const
double b
Definition: hdecay.h:120
std::pair< OmniClusterRef, TrackingParticleRef > P
double a
Definition: hdecay.h:121
step
Definition: StallMonitor.cc:94
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Candidate.h:47
int positionAngle() const
Definition: L1MuKBMTrack.cc:71
int L1TMuonBarrelKalmanAlgo::ptLUT ( int  K)
private

Definition at line 1255 of file L1TMuonBarrelKalmanAlgo.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, objects.autophobj::float, createfilelist::int, and EnergyCorrector::pt.

Referenced by convertToBMTF(), and setFloatingPointValues().

1255  {
1256  int charge = (K>=0) ? +1 : -1;
1257  float lsb=1.25/float(1<<13);
1258  float FK = fabs(K);
1259 
1260 
1261  if (FK>2047)
1262  FK=2047.;
1263  if (FK<26)
1264  FK=26.;
1265 
1266  FK=FK*lsb;
1267 
1268  //step 1 -material and B-field
1269  FK = 0.898*FK/(1.0-0.6*FK);
1270  //step 2 -low Pt
1271  FK=FK-26.382*FK*FK*FK*FK*FK;
1272  //step 3 - misalignment
1273  FK=FK-charge*1.408e-3;
1274  //Get to BMTF
1275  FK=FK/1.17;
1276 
1277 
1278  int pt=0;
1279  if (FK!=0)
1280  pt=int(2.0/FK);
1281 
1282  if (pt>511)
1283  pt=511;
1284 
1285  if (pt<6)
1286  pt=6;
1287 
1288  return pt;
1289 }
int L1TMuonBarrelKalmanAlgo::rank ( const L1MuKBMTrack track)
private

Definition at line 1096 of file L1TMuonBarrelKalmanAlgo.cc.

References L1MuKBMTrack::approxChi2(), customBitmask(), hitPattern(), L1MuKBMTrack::stubs(), and parallelization::uint().

Referenced by calculateEta(), chain(), clean(), and convertToBMTF().

1096  {
1097  // int offset=0;
1098  uint chi = track.approxChi2()>127 ? 127 :track.approxChi2();
1099  if (hitPattern(track)==customBitmask(0,0,1,1))
1100  return 60;
1101  // return offset+(track.stubs().size()*2+track.quality())*80-track.approxChi2();
1102  return 160+(track.stubs().size())*20-chi;
1103 
1104 }
int approxChi2() const
Definition: L1MuKBMTrack.cc:83
int customBitmask(unsigned int, unsigned int, unsigned int, unsigned int)
const L1MuKBMTCombinedStubRefVector & stubs() const
def uint(string)
int hitPattern(const L1MuKBMTrack &)
void L1TMuonBarrelKalmanAlgo::setFloatingPointValues ( L1MuKBMTrack track,
bool  vertex 
)
private

Definition at line 810 of file L1TMuonBarrelKalmanAlgo.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, L1MuKBMTrack::coarseEta(), L1MuKBMTrack::curvatureAtMuon(), L1MuKBMTrack::curvatureAtVertex(), PVValHelper::eta, L1MuKBMTrack::fineEta(), objects.autophobj::float, L1MuKBMTrack::hasFineEta(), M_PI, phi, L1MuKBMTrack::phiAtVertex(), EnergyCorrector::pt, ptLUT(), L1MuKBMTrack::sector(), reco::LeafCandidate::setCharge(), L1MuKBMTrack::setPtEtaPhi(), and L1MuKBMTrack::setPtUnconstrained().

Referenced by chain().

810  {
811  int K,etaINT;
812 
813  if (track.hasFineEta())
814  etaINT=track.fineEta();
815  else
816  etaINT=track.coarseEta();
817 
818 
819  double lsb = 1.25/float(1 << 13);
820  double lsbEta = 0.010875;
821 
822 
823 
824  if (vertex) {
825  int charge=1;
826  if (track.curvatureAtVertex()<0)
827  charge=-1;
828  double pt = double(ptLUT(track.curvatureAtVertex()))/2.0;
829 
830 
831  double phi= track.sector()*M_PI/6.0+track.phiAtVertex()*M_PI/(6*2048.)-2*M_PI;
832 
833  double eta = etaINT*lsbEta;
834  track.setPtEtaPhi(pt,eta,phi);
835  track.setCharge(charge);
836  }
837  else {
838  K=track.curvatureAtMuon();
839  if (K==0)
840  K=1;
841 
842  if (fabs(K)<46)
843  K=46*K/fabs(K);
844  double pt = 1.0/(lsb*fabs(K));
845  if (pt<1.6)
846  pt=1.6;
847  track.setPtUnconstrained(pt);
848  }
849 }
int fineEta() const
int coarseEta() const
Definition: L1MuKBMTrack.cc:79
int phiAtVertex() const
Definition: L1MuKBMTrack.cc:59
void setPtUnconstrained(float)
void setPtEtaPhi(double, double, double)
void setCharge(Charge q) final
set electric charge
Definition: LeafCandidate.h:93
int curvatureAtMuon() const
Definition: L1MuKBMTrack.cc:45
bool hasFineEta() const
#define M_PI
int curvatureAtVertex() const
Definition: L1MuKBMTrack.cc:55
int sector() const
Definition: L1MuKBMTrack.cc:97
std::map< int, int > L1TMuonBarrelKalmanAlgo::trackAddress ( const L1MuKBMTrack track,
int &  word 
)
private

Definition at line 1170 of file L1TMuonBarrelKalmanAlgo.cc.

References encode(), l1t::RegionalMuonCand::kSegSelStat1, l1t::RegionalMuonCand::kSegSelStat2, l1t::RegionalMuonCand::kSegSelStat3, l1t::RegionalMuonCand::kSegSelStat4, l1t::RegionalMuonCand::kStat1, l1t::RegionalMuonCand::kStat2, l1t::RegionalMuonCand::kStat3, l1t::RegionalMuonCand::kStat4, l1t::RegionalMuonCand::kWheelNum, l1t::RegionalMuonCand::kWheelSide, MillePedeFileConverter_cfg::out, L1MuKBMTrack::sector(), L1MuKBMTrack::stubs(), and L1MuKBMTrack::wheel().

Referenced by convertToBMTF().

1170  {
1171  std::map<int,int> out;
1172 
1173  out[l1t::RegionalMuonCand::kWheelSide] = track.wheel()<0;
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)
1184  else
1194  //out[l1t::RegionalMuonCand::kNumBmtfSubAddr]=0; // This is commented out for better data/MC agreement
1195 
1196 
1197  for (const auto stub: track.stubs()) {
1198  bool ownwheel = stub->whNum() == track.wheel();
1199  int sector=0;
1200  if ((stub->scNum()==track.sector()+1) || (stub->scNum()==0 && track.sector()==11))
1201  sector=+1;
1202  if ((stub->scNum()==track.sector()-1) || (stub->scNum()==11 && track.sector()==0))
1203  sector=-1;
1204  int addr = encode(ownwheel,sector,stub->tag());
1205 
1206  if (stub->stNum()==4) {
1207  if (stub->tag())
1208  addr=1;
1209  else
1210  addr=2;
1212  }
1213  if (stub->stNum()==3) {
1214  out[l1t::RegionalMuonCand::kStat2]=addr;
1215  }
1216  if (stub->stNum()==2) {
1218  }
1219  if (stub->stNum()==1) {
1221  }
1222  }
1223 
1224  word=0;
1225  word = word | out[l1t::RegionalMuonCand::kStat1]<<12;
1226  word = word | out[l1t::RegionalMuonCand::kStat2]<<8;
1227  word = word | out[l1t::RegionalMuonCand::kStat3]<<4;
1228  word = word | out[l1t::RegionalMuonCand::kStat4];
1229 
1230 
1231 
1232  return out;
1233 }
const L1MuKBMTCombinedStubRefVector & stubs() const
int wheel() const
int encode(bool ownwheel, int sector, bool tag)
int sector() const
Definition: L1MuKBMTrack.cc:97
uint L1TMuonBarrelKalmanAlgo::twosCompToBits ( int  q)
private

Definition at line 1237 of file L1TMuonBarrelKalmanAlgo.cc.

References lumiQueryAPI::q.

Referenced by convertToBMTF().

1237  {
1238  if (q>=0)
1239  return q;
1240  else
1241  return (~q)+1;
1242 
1243 
1244 }
bool L1TMuonBarrelKalmanAlgo::update ( L1MuKBMTrack track,
const L1MuKBMTCombinedStubRef stub,
int  mask 
)
private

Definition at line 487 of file L1TMuonBarrelKalmanAlgo.cc.

References updateEta(), updateLUT(), updateOffline(), updateOffline1D(), and useOfflineAlgo_.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), chain(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

487  {
488  updateEta(track,stub);
489  if (useOfflineAlgo_) {
490  if (mask==3 || mask ==5 || mask==9 ||mask==6|| mask==10 ||mask==12)
491  return updateOffline(track,stub);
492  else
493  return updateOffline1D(track,stub);
494 
495  }
496  else
497  return updateLUT(track,stub,mask);
498 
499 }
bool updateOffline1D(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &)
bool updateLUT(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &, int)
void updateEta(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &)
bool updateOffline(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &)
void L1TMuonBarrelKalmanAlgo::updateEta ( L1MuKBMTrack track,
const L1MuKBMTCombinedStubRef stub 
)
private

Definition at line 721 of file L1TMuonBarrelKalmanAlgo.cc.

Referenced by update().

721  {
722 
723 
724 
725 
726 }
bool L1TMuonBarrelKalmanAlgo::updateLUT ( L1MuKBMTrack track,
const L1MuKBMTCombinedStubRef stub,
int  mask 
)
private

Definition at line 641 of file L1TMuonBarrelKalmanAlgo.cc.

References L1MuKBMTrack::addStub(), L1MuKBMTrack::bendingAngle(), correctedPhi(), correctedPhiB(), L1MuKBMTrack::curvature(), fp_product(), L1MuKBMTrack::hitPattern(), hitPattern(), lutService_, phi, L1MuKBMTrack::positionAngle(), L1MuKBMTrack::sector(), L1MuKBMTrack::setCoordinates(), L1MuKBMTrack::setHitPattern(), L1MuKBMTrack::setKalmanGain(), L1MuKBMTrack::step(), L1TMuonBarrelKalmanLUTs::trackGain(), L1TMuonBarrelKalmanLUTs::trackGain2(), reco::btau::trackPhi, parallelization::uint(), verbose_, and wrapAround().

Referenced by update().

641  {
642  int trackK = track.curvature();
643  int trackPhi = track.positionAngle();
644  int trackPhiB = track.bendingAngle();
645 
646 
647  int phi = correctedPhi(stub,track.sector());
648  int phiB = correctedPhiB(stub);
649 
650  if (stub->quality()<4)
651  phiB=trackPhiB;
652 
653  Vector2 residual;
654  int residualPhi = wrapAround(phi-trackPhi,4096);
655  int residualPhiB = wrapAround(phiB-trackPhiB,8192);
656 
657 
658  if (verbose_)
659  printf("residuals %d-%d=%d %d-%d=%d\n",phi,trackPhi,int(residualPhi),phiB,trackPhiB,int(residualPhiB));
660 
661 
662  uint absK = fabs(trackK);
663  if (absK>4095)
664  absK = 4095;
665 
666  std::vector<float> GAIN;
667  //For the three stub stuff use only gains 0 and 4
668  if (!(mask==3 || mask ==5 || mask==9 ||mask==6|| mask==10 ||mask==12)) {
669  GAIN = lutService_->trackGain(track.step(),track.hitPattern(),absK/4);
670  GAIN[1]=0.0;
671  GAIN[3]=0.0;
672 
673  }
674  else {
675  GAIN = lutService_->trackGain2(track.step(),track.hitPattern(),absK/8);
676 
677 
678  }
679  if (verbose_)
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]);
682 
683 
684  int k_0 = fp_product(GAIN[0],residualPhi,3);
685  int k_1 = fp_product(GAIN[1],residualPhiB,5);
686  int KNew = trackK+k_0+k_1;
687  if (fabs(KNew)>=8191)
688  return false;
689  KNew = wrapAround(KNew,8192);
690  int phiNew = phi;
691 
692  //different products for different firmware logic
693  int pbdouble_0 = fp_product(fabs(GAIN[2]),residualPhi,9);
694  int pb_0 = fp_product(GAIN[2],residualPhi,9);
695  int pb_1 = fp_product(GAIN[3],residualPhiB,9);
696 
697  if (verbose_)
698  printf("phiupdate: %d %d\n",pb_0,pb_1);
699 
700  int phiBNew;
701  if (!(mask==3 || mask ==5 || mask==9 ||mask==6|| mask==10 ||mask==12)) {
702  phiBNew = wrapAround(trackPhiB+pb_0,4096);
703  if (fabs(trackPhiB+pb_0)>=4095)
704  return false;
705  }
706  else {
707  phiBNew = wrapAround(trackPhiB+pb_1-pbdouble_0,4096);
708  if (fabs(trackPhiB+pb_1-pbdouble_0)>=4095)
709  return false;
710 
711  }
712  track.setCoordinates(track.step(),KNew,phiNew,phiBNew);
713  track.addStub(stub);
714  track.setHitPattern(hitPattern(track));
715  return true;
716 }
int correctedPhiB(const L1MuKBMTCombinedStubRef &)
int step() const
Definition: L1MuKBMTrack.cc:94
int bendingAngle() const
Definition: L1MuKBMTrack.cc:75
std::vector< float > trackGain2(uint, uint, uint)
void setHitPattern(int)
int fp_product(float, int, uint)
void setCoordinates(int, int, int, int)
ROOT::Math::SVector< double, 2 > Vector2
L1TMuonBarrelKalmanLUTs * lutService_
int curvature() const
Definition: L1MuKBMTrack.cc:67
def uint(string)
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)
int correctedPhi(const L1MuKBMTCombinedStubRef &, int)
int sector() const
Definition: L1MuKBMTrack.cc:97
void addStub(const L1MuKBMTCombinedStubRef &)
int hitPattern() const
Definition: L1MuKBMTrack.cc:90
std::vector< float > trackGain(uint, uint, uint)
int positionAngle() const
Definition: L1MuKBMTrack.cc:71
bool L1TMuonBarrelKalmanAlgo::updateOffline ( L1MuKBMTrack track,
const L1MuKBMTCombinedStubRef stub 
)
private

Definition at line 501 of file L1TMuonBarrelKalmanAlgo.cc.

References L1MuKBMTrack::addStub(), L1MuKBMTrack::bendingAngle(), EnergyCorrector::c, correctedPhi(), correctedPhiB(), L1MuKBMTrack::covariance(), L1MuKBMTrack::curvature(), g4SimHits_cfi::Gain, class-composition::H, hitPattern(), createfilelist::int, phi, pointResolutionPhi_, pointResolutionPhiB_, L1MuKBMTrack::positionAngle(), dttmaxenums::R, S(), L1MuKBMTrack::sector(), L1MuKBMTrack::setCoordinates(), L1MuKBMTrack::setCovariance(), L1MuKBMTrack::setHitPattern(), L1MuKBMTrack::setKalmanGain(), L1MuKBMTrack::setResidual(), L1MuKBMTrack::step(), reco::btau::trackPhi, verbose_, and wrapAround().

Referenced by update().

501  {
502  int trackK = track.curvature();
503  int trackPhi = track.positionAngle();
504  int trackPhiB = track.bendingAngle();
505 
506  int phi = correctedPhi(stub,track.sector());
507  int phiB = correctedPhiB(stub);
508 
509 
510 
511 
512  Vector2 residual;
513  residual[0] = phi-trackPhi;
514  residual[1] = phiB-trackPhiB;
515 
516 
517 
518 
519 
520  Matrix23 H;
521  H(0,0)=0.0;
522  H(0,1)=1.0;
523  H(0,2)=0.0;
524  H(1,0)=0.0;
525  H(1,1)=0.0;
526  H(1,2)=1.0;
527 
528 
530  R(0,0) = pointResolutionPhi_;
531  R(0,1) = 0.0;
532  R(1,0) = 0.0;
533  R(1,1) = pointResolutionPhiB_;
534 
535  const std::vector<double>& covLine = track.covariance();
536  L1MuKBMTrack::CovarianceMatrix cov(covLine.begin(),covLine.end());
537 
538 
539  CovarianceMatrix2 S = ROOT::Math::Similarity(H,cov)+R;
540  if (!S.Invert())
541  return false;
542  Matrix32 Gain = cov*ROOT::Math::Transpose(H)*S;
543 
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));
545 
546  int KNew = (trackK+int(Gain(0,0)*residual(0)+Gain(0,1)*residual(1)));
547  if (fabs(KNew)>8192)
548  return false;
549 
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);
552 
553  track.setResidual(stub->stNum()-1,fabs(phi-phiNew)+fabs(phiB-phiBNew)/8);
554 
555 
556  if (verbose_) {
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));
559  }
560 
561 
562  track.setCoordinates(track.step(),KNew,phiNew,phiBNew);
563  Matrix33 covNew = cov - Gain*(H*cov);
565 
566  c(0,0)=covNew(0,0);
567  c(0,1)=covNew(0,1);
568  c(0,2)=covNew(0,2);
569  c(1,0)=covNew(1,0);
570  c(1,1)=covNew(1,1);
571  c(1,2)=covNew(1,2);
572  c(2,0)=covNew(2,0);
573  c(2,1)=covNew(2,1);
574  c(2,2)=covNew(2,2);
575  if (verbose_) {
576  printf("Post Fit Covariance Matrix %f %f %f \n",cov(0,0),cov(1,1),cov(2,2));
577 
578  }
579 
580  track.setCovariance(c);
581  track.addStub(stub);
582  track.setHitPattern(hitPattern(track));
583 
584  return true;
585 }
int correctedPhiB(const L1MuKBMTCombinedStubRef &)
ROOT::Math::SMatrix< double, 3, 3 > Matrix33
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > CovarianceMatrix2
int step() const
Definition: L1MuKBMTrack.cc:94
int bendingAngle() const
Definition: L1MuKBMTrack.cc:75
void setHitPattern(int)
void setCoordinates(int, int, int, int)
ROOT::Math::SVector< double, 2 > Vector2
void setCovariance(const CovarianceMatrix &)
int curvature() const
Definition: L1MuKBMTrack.cc:67
ROOT::Math::SMatrix< double, 2, 3 > Matrix23
const std::vector< double > & covariance() const
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
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)
int correctedPhi(const L1MuKBMTCombinedStubRef &, int)
int sector() const
Definition: L1MuKBMTrack.cc:97
void addStub(const L1MuKBMTCombinedStubRef &)
void setResidual(uint, int)
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Candidate.h:47
int positionAngle() const
Definition: L1MuKBMTrack.cc:71
ROOT::Math::SMatrix< double, 3, 2 > Matrix32
bool L1TMuonBarrelKalmanAlgo::updateOffline1D ( L1MuKBMTrack track,
const L1MuKBMTCombinedStubRef stub 
)
private

Definition at line 588 of file L1TMuonBarrelKalmanAlgo.cc.

References L1MuKBMTrack::addStub(), L1MuKBMTrack::bendingAngle(), EnergyCorrector::c, correctedPhi(), L1MuKBMTrack::covariance(), L1MuKBMTrack::curvature(), g4SimHits_cfi::Gain, class-composition::H, hitPattern(), phi, pointResolutionPhi_, L1MuKBMTrack::positionAngle(), S(), L1MuKBMTrack::sector(), L1MuKBMTrack::setCoordinates(), L1MuKBMTrack::setCovariance(), L1MuKBMTrack::setHitPattern(), L1MuKBMTrack::setKalmanGain(), L1MuKBMTrack::step(), reco::btau::trackPhi, and wrapAround().

Referenced by update().

588  {
589  int trackK = track.curvature();
590  int trackPhi = track.positionAngle();
591  int trackPhiB = track.bendingAngle();
592 
593 
594  int phi = correctedPhi(stub,track.sector());
595 
596 
597  double residual= phi-trackPhi;
598 
599  Matrix13 H;
600  H(0,0)=0.0;
601  H(0,1)=1.0;
602  H(0,2)=0.0;
603 
604 
605  const std::vector<double>& covLine = track.covariance();
606  L1MuKBMTrack::CovarianceMatrix cov(covLine.begin(),covLine.end());
607 
608  double S = ROOT::Math::Similarity(H,cov)(0,0)+pointResolutionPhi_;
609 
610  if (S==0.0)
611  return false;
612  Matrix31 Gain = cov*ROOT::Math::Transpose(H)/S;
613 
614  track.setKalmanGain(track.step(),fabs(trackK),Gain(0,0),0.0,Gain(1,0),0.0,Gain(2,0),0.0);
615 
616  int KNew = wrapAround(trackK+int(Gain(0,0)*residual),8192);
617  int phiNew = wrapAround(trackPhi+residual,8192);
618  int phiBNew = wrapAround(trackPhiB+int(Gain(2,0)*residual),4096);
619  track.setCoordinates(track.step(),KNew,phiNew,phiBNew);
620  Matrix33 covNew = cov - Gain*(H*cov);
622 
623  c(0,0)=covNew(0,0);
624  c(0,1)=covNew(0,1);
625  c(0,2)=covNew(0,2);
626  c(1,0)=covNew(1,0);
627  c(1,1)=covNew(1,1);
628  c(1,2)=covNew(1,2);
629  c(2,0)=covNew(2,0);
630  c(2,1)=covNew(2,1);
631  c(2,2)=covNew(2,2);
632  track.setCovariance(c);
633  track.addStub(stub);
634  track.setHitPattern(hitPattern(track));
635 
636  return true;
637 }
ROOT::Math::SMatrix< double, 3, 3 > Matrix33
int step() const
Definition: L1MuKBMTrack.cc:94
int bendingAngle() const
Definition: L1MuKBMTrack.cc:75
void setHitPattern(int)
void setCoordinates(int, int, int, int)
void setCovariance(const CovarianceMatrix &)
int curvature() const
Definition: L1MuKBMTrack.cc:67
ROOT::Math::SMatrix< double, 1, 3 > Matrix13
const std::vector< double > & covariance() const
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
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)
int correctedPhi(const L1MuKBMTCombinedStubRef &, int)
int sector() const
Definition: L1MuKBMTrack.cc:97
void addStub(const L1MuKBMTCombinedStubRef &)
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Candidate.h:47
ROOT::Math::SMatrix< double, 3, 1 > Matrix31
int positionAngle() const
Definition: L1MuKBMTrack.cc:71
void L1TMuonBarrelKalmanAlgo::vertexConstraint ( L1MuKBMTrack track)
private

Definition at line 733 of file L1TMuonBarrelKalmanAlgo.cc.

References useOfflineAlgo_, vertexConstraintLUT(), and vertexConstraintOffline().

Referenced by chain().

733  {
734  if (useOfflineAlgo_)
736  else
737  vertexConstraintLUT(track);
738 
739 }
void vertexConstraintLUT(L1MuKBMTrack &)
void vertexConstraintOffline(L1MuKBMTrack &)
void L1TMuonBarrelKalmanAlgo::vertexConstraintLUT ( L1MuKBMTrack track)
private

Definition at line 785 of file L1TMuonBarrelKalmanAlgo.cc.

References L1MuKBMTrack::curvature(), L1MuKBMTrack::dxy(), fp_product(), L1MuKBMTrack::hitPattern(), lutService_, L1MuKBMTrack::positionAngle(), L1MuKBMTrack::setCoordinatesAtVertex(), L1MuKBMTrack::setKalmanGain(), L1MuKBMTrack::step(), parallelization::uint(), verbose_, L1TMuonBarrelKalmanLUTs::vertexGain(), and wrapAround().

Referenced by vertexConstraint().

785  {
786  double residual = -track.dxy();
787  uint absK = fabs(track.curvature());
788  if (absK>2047)
789  absK = 2047;
790 
791 std::pair<float,float> GAIN = lutService_->vertexGain(track.hitPattern(),absK/2);
792  track.setKalmanGain(track.step(),fabs(track.curvature()),GAIN.first,GAIN.second,-1);
793 
794  int k_0 = fp_product(GAIN.first,int(residual),7);
795  int KNew = wrapAround(track.curvature()+k_0,8192);
796 
797  if (verbose_) {
798  printf("VERTEX GAIN(%d)= %f * %d = %d\n",absK/2,GAIN.first,int(residual),k_0);
799 
800  }
801 
802 
803  int p_0 = fp_product(GAIN.second,int(residual),7);
804  int phiNew = wrapAround(track.positionAngle()+p_0,8192);
805  track.setCoordinatesAtVertex(KNew,phiNew,-residual);
806 }
void setCoordinatesAtVertex(int, int, int)
int step() const
Definition: L1MuKBMTrack.cc:94
int fp_product(float, int, uint)
std::pair< float, float > vertexGain(uint, uint)
L1TMuonBarrelKalmanLUTs * lutService_
int curvature() const
Definition: L1MuKBMTrack.cc:67
int dxy() const
Definition: L1MuKBMTrack.cc:63
def uint(string)
void setKalmanGain(unsigned int step, unsigned int K, float a1, float a2, float a3, float a4=0, float a5=0, float a6=0)
int hitPattern() const
Definition: L1MuKBMTrack.cc:90
int positionAngle() const
Definition: L1MuKBMTrack.cc:71
void L1TMuonBarrelKalmanAlgo::vertexConstraintOffline ( L1MuKBMTrack track)
private

Definition at line 742 of file L1TMuonBarrelKalmanAlgo.cc.

References EnergyCorrector::c, L1MuKBMTrack::covariance(), L1MuKBMTrack::curvature(), L1MuKBMTrack::dxy(), g4SimHits_cfi::Gain, class-composition::H, pointResolutionVertex_, L1MuKBMTrack::positionAngle(), S(), L1MuKBMTrack::setCoordinatesAtVertex(), L1MuKBMTrack::setCovariance(), L1MuKBMTrack::setKalmanGain(), L1MuKBMTrack::step(), verbose_, and wrapAround().

Referenced by vertexConstraint().

742  {
743  double residual = -track.dxy();
744  Matrix13 H;
745  H(0,0)=0;
746  H(0,1)=0;
747  H(0,2)=1;
748 
749  const std::vector<double>& covLine = track.covariance();
750  L1MuKBMTrack::CovarianceMatrix cov(covLine.begin(),covLine.end());
751 
752  double S = (ROOT::Math::Similarity(H,cov))(0,0)+pointResolutionVertex_;
753  S=1.0/S;
754  Matrix31 Gain = cov*(ROOT::Math::Transpose(H))*S;
755  track.setKalmanGain(track.step(),fabs(track.curvature()),Gain(0,0),Gain(1,0),Gain(2,0));
756 
757  if (verbose_) {
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);
760  }
761 
762  int KNew = wrapAround(int(track.curvature()+Gain(0,0)*residual),8192);
763  int phiNew = wrapAround(int(track.positionAngle()+Gain(1,0)*residual),8192);
764  int dxyNew = wrapAround(int(track.dxy()+Gain(2,0)*residual),8192);
765  if (verbose_)
766  printf("Post fit impact parameter=%d\n",dxyNew);
767  track.setCoordinatesAtVertex(KNew,phiNew,-residual);
768  Matrix33 covNew = cov - Gain*(H*cov);
770  c(0,0)=covNew(0,0);
771  c(0,1)=covNew(0,1);
772  c(0,2)=covNew(0,2);
773  c(1,0)=covNew(1,0);
774  c(1,1)=covNew(1,1);
775  c(1,2)=covNew(1,2);
776  c(2,0)=covNew(2,0);
777  c(2,1)=covNew(2,1);
778  c(2,2)=covNew(2,2);
779  track.setCovariance(c);
780  // track.covariance = track.covariance - Gain*H*track.covariance;
781 }
ROOT::Math::SMatrix< double, 3, 3 > Matrix33
void setCoordinatesAtVertex(int, int, int)
int step() const
Definition: L1MuKBMTrack.cc:94
void setCovariance(const CovarianceMatrix &)
int curvature() const
Definition: L1MuKBMTrack.cc:67
ROOT::Math::SMatrix< double, 1, 3 > Matrix13
const std::vector< double > & covariance() const
int dxy() const
Definition: L1MuKBMTrack.cc:63
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
void setKalmanGain(unsigned int step, unsigned int K, float a1, float a2, float a3, float a4=0, float a5=0, float a6=0)
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Candidate.h:47
ROOT::Math::SMatrix< double, 3, 1 > Matrix31
int positionAngle() const
Definition: L1MuKBMTrack.cc:71
int L1TMuonBarrelKalmanAlgo::wrapAround ( int  value,
int  maximum 
)
private

Definition at line 1108 of file L1TMuonBarrelKalmanAlgo.cc.

References relativeConstraints::value.

Referenced by estimateChiSquare(), estimateCompatibility(), match(), propagate(), updateLUT(), updateOffline(), updateOffline1D(), vertexConstraintLUT(), and vertexConstraintOffline().

1108  {
1109 
1110  if (value>maximum-1)
1111  return wrapAround(value-2*maximum,maximum);
1112  if (value<-maximum)
1113  return wrapAround(value+2*maximum,maximum);
1114  return value;
1115 
1116 }
Definition: value.py:1

Member Data Documentation

std::vector<double> L1TMuonBarrelKalmanAlgo::aPhi_
private

Definition at line 86 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

std::vector<double> L1TMuonBarrelKalmanAlgo::aPhiB_
private

Definition at line 87 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

std::vector<double> L1TMuonBarrelKalmanAlgo::aPhiBNLO_
private

Definition at line 88 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

std::vector<double> L1TMuonBarrelKalmanAlgo::bPhi_
private

Definition at line 89 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

std::vector<double> L1TMuonBarrelKalmanAlgo::bPhiB_
private

Definition at line 90 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

std::vector<double> L1TMuonBarrelKalmanAlgo::chiSquare_
private

Definition at line 98 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateChiSquare().

std::vector<int> L1TMuonBarrelKalmanAlgo::chiSquareCut_
private

Definition at line 101 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateChiSquare().

std::vector<int> L1TMuonBarrelKalmanAlgo::chiSquareCutCurv_
private

Definition at line 100 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateChiSquare().

std::vector<int> L1TMuonBarrelKalmanAlgo::chiSquareCutPattern_
private

Definition at line 99 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateChiSquare().

std::vector<int> L1TMuonBarrelKalmanAlgo::chiSquareCutTight_
private

Definition at line 109 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

std::vector<int> L1TMuonBarrelKalmanAlgo::combos1_
private

Definition at line 116 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain().

std::vector<int> L1TMuonBarrelKalmanAlgo::combos2_
private

Definition at line 115 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain().

std::vector<int> L1TMuonBarrelKalmanAlgo::combos3_
private

Definition at line 114 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain().

std::vector<int> L1TMuonBarrelKalmanAlgo::combos4_
private

Definition at line 113 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain().

std::vector<double> L1TMuonBarrelKalmanAlgo::eLoss_
private

Definition at line 85 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

std::vector<double> L1TMuonBarrelKalmanAlgo::etaLUT0_
private

Definition at line 92 of file L1TMuonBarrelKalmanAlgo.h.

std::vector<double> L1TMuonBarrelKalmanAlgo::etaLUT1_
private

Definition at line 93 of file L1TMuonBarrelKalmanAlgo.h.

uint L1TMuonBarrelKalmanAlgo::globalChi2Cut_
private

Definition at line 96 of file L1TMuonBarrelKalmanAlgo.h.

uint L1TMuonBarrelKalmanAlgo::globalChi2CutLimit_
private

Definition at line 97 of file L1TMuonBarrelKalmanAlgo.h.

std::vector<double> L1TMuonBarrelKalmanAlgo::initK2_
private

Definition at line 82 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain().

std::vector<double> L1TMuonBarrelKalmanAlgo::initK_
private

Definition at line 81 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain().

L1TMuonBarrelKalmanLUTs* L1TMuonBarrelKalmanAlgo::lutService_
private

Definition at line 76 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by calculateEta(), updateLUT(), and vertexConstraintLUT().

std::vector<double> L1TMuonBarrelKalmanAlgo::mScatteringPhi_
private

Definition at line 123 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

std::vector<double> L1TMuonBarrelKalmanAlgo::mScatteringPhiB_
private

Definition at line 124 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

double L1TMuonBarrelKalmanAlgo::phiAt2_
private

Definition at line 91 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by phiAt2().

double L1TMuonBarrelKalmanAlgo::pointResolutionPhi_
private

Definition at line 126 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain(), updateOffline(), and updateOffline1D().

double L1TMuonBarrelKalmanAlgo::pointResolutionPhiB_
private

Definition at line 128 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain(), and updateOffline().

double L1TMuonBarrelKalmanAlgo::pointResolutionVertex_
private

Definition at line 130 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by vertexConstraintOffline().

std::vector<double> L1TMuonBarrelKalmanAlgo::trackComp_
private

Definition at line 103 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

std::vector<int> L1TMuonBarrelKalmanAlgo::trackCompCut_
private

Definition at line 108 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

std::vector<int> L1TMuonBarrelKalmanAlgo::trackCompCutCurv_
private

Definition at line 107 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

std::vector<double> L1TMuonBarrelKalmanAlgo::trackCompErr1_
private

Definition at line 104 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

std::vector<double> L1TMuonBarrelKalmanAlgo::trackCompErr2_
private

Definition at line 105 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

std::vector<int> L1TMuonBarrelKalmanAlgo::trackCompPattern_
private

Definition at line 106 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

bool L1TMuonBarrelKalmanAlgo::useOfflineAlgo_
private

Definition at line 122 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by update(), and vertexConstraint().

bool L1TMuonBarrelKalmanAlgo::verbose_
private