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 4 of file L1TMuonBarrelKalmanAlgo.cc.

5  : verbose_(settings.getParameter<bool>("verbose")),
7  initK_(settings.getParameter<std::vector<double> >("initialK")),
8  initK2_(settings.getParameter<std::vector<double> >("initialK2")),
9  eLoss_(settings.getParameter<std::vector<double> >("eLoss")),
10  aPhi_(settings.getParameter<std::vector<double> >("aPhi")),
11  aPhiB_(settings.getParameter<std::vector<double> >("aPhiB")),
12  aPhiBNLO_(settings.getParameter<std::vector<double> >("aPhiBNLO")),
13  bPhi_(settings.getParameter<std::vector<double> >("bPhi")),
14  bPhiB_(settings.getParameter<std::vector<double> >("bPhiB")),
15  phiAt2_(settings.getParameter<double>("phiAt2")),
16 
17  chiSquare_(settings.getParameter<std::vector<double> >("chiSquare")),
18  chiSquareCutPattern_(settings.getParameter<std::vector<int> >("chiSquareCutPattern")),
19  chiSquareCutCurv_(settings.getParameter<std::vector<int> >("chiSquareCutCurvMax")),
20  chiSquareCut_(settings.getParameter<std::vector<int> >("chiSquareCut")),
21  trackComp_(settings.getParameter<std::vector<double> >("trackComp")),
22  trackCompErr1_(settings.getParameter<std::vector<double> >("trackCompErr1")),
23  trackCompErr2_(settings.getParameter<std::vector<double> >("trackCompErr2")),
24  trackCompPattern_(settings.getParameter<std::vector<int> >("trackCompCutPattern")),
25  trackCompCutCurv_(settings.getParameter<std::vector<int> >("trackCompCutCurvMax")),
26  trackCompCut_(settings.getParameter<std::vector<int> >("trackCompCut")),
27  chiSquareCutTight_(settings.getParameter<std::vector<int> >("chiSquareCutTight")),
28  combos4_(settings.getParameter<std::vector<int> >("combos4")),
29  combos3_(settings.getParameter<std::vector<int> >("combos3")),
30  combos2_(settings.getParameter<std::vector<int> >("combos2")),
31  combos1_(settings.getParameter<std::vector<int> >("combos1")),
32  useOfflineAlgo_(settings.getParameter<bool>("useOfflineAlgo")),
33  mScatteringPhi_(settings.getParameter<std::vector<double> >("mScatteringPhi")),
34  mScatteringPhiB_(settings.getParameter<std::vector<double> >("mScatteringPhiB")),
35  pointResolutionPhi_(settings.getParameter<double>("pointResolutionPhi")),
36  pointResolutionPhiB_(settings.getParameter<double>("pointResolutionPhiB")),
37  pointResolutionVertex_(settings.getParameter<double>("pointResolutionVertex"))
38 
39 {}
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< int > chiSquareCut_
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 128 of file L1TMuonBarrelKalmanAlgo.cc.

References convertToBMTF().

Referenced by L1TMuonBarrelKalmanTrackProducer::produce().

130  {
131  out->push_back(bx, convertToBMTF(track));
132 }
l1t::RegionalMuonCand convertToBMTF(const L1MuKBMTrack &track)
void L1TMuonBarrelKalmanAlgo::calculateEta ( L1MuKBMTrack track)
private

Definition at line 1215 of file L1TMuonBarrelKalmanAlgo.cc.

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

Referenced by chain().

1215  {
1216  uint pattern = track.hitPattern();
1217  int wheel = track.stubs()[0]->whNum();
1218  uint awheel = fabs(wheel);
1219  int sign = 1;
1220  if (wheel < 0)
1221  sign = -1;
1222  uint nstubs = track.stubs().size();
1223  uint mask = 0;
1224  for (unsigned int i = 0; i < track.stubs().size(); ++i) {
1225  if (fabs(track.stubs()[i]->whNum()) != awheel)
1226  mask = mask | (1 << i);
1227  }
1228  mask = (awheel << nstubs) | mask;
1229  track.setCoarseEta(sign * lutService_->coarseEta(pattern, mask));
1230 
1231  int sumweights = 0;
1232  int sums = 0;
1233 
1234  for (const auto& stub : track.stubs()) {
1235  uint rank = etaStubRank(stub);
1236  if (rank == 0)
1237  continue;
1238  // printf("Stub station=%d rank=%d values=%d %d\n",stub->stNum(),rank,stub->eta1(),stub->eta2());
1239  sumweights += rank;
1240  sums += rank * stub->eta1();
1241  }
1242 
1243  //0.5 0.332031 0.25 0.199219 0.164063
1244  float factor;
1245  if (sumweights == 1)
1246  factor = 1.0;
1247  else if (sumweights == 2)
1248  factor = 0.5;
1249  else if (sumweights == 3)
1250  factor = 0.332031;
1251  else if (sumweights == 4)
1252  factor = 0.25;
1253  else if (sumweights == 5)
1254  factor = 0.199219;
1255  else if (sumweights == 6)
1256  factor = 0.164063;
1257  else
1258  factor = 0.0;
1259 
1260  int eta = 0;
1261  if (sums > 0)
1262  eta = fp_product(factor, sums, 10);
1263  else
1264  eta = -fp_product(factor, fabs(sums), 10);
1265 
1266  //int eta=int(factor*sums);
1267  // printf("Eta debug %f *%d=%d\n",factor,sums,eta);
1268 
1269  if (sumweights > 0)
1270  track.setFineEta(eta);
1271 }
int rank(const L1MuKBMTrack &)
int fp_product(float, int, uint)
L1TMuonBarrelKalmanLUTs * lutService_
void setCoarseEta(int)
Definition: L1MuKBMTrack.cc:99
void setFineEta(int)
const L1MuKBMTCombinedStubRefVector & stubs() const
Definition: L1MuKBMTrack.cc:76
int hitPattern() const
Definition: L1MuKBMTrack.cc:58
uint etaStubRank(const L1MuKBMTCombinedStubRef &)
std::pair< bool, L1MuKBMTrack > L1TMuonBarrelKalmanAlgo::chain ( const L1MuKBMTCombinedStubRef seed,
const L1MuKBMTCombinedStubRefVector stubs 
)

Definition at line 738 of file L1TMuonBarrelKalmanAlgo.cc.

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

Referenced by L1TMuonBarrelKalmanRegionModule::process().

739  {
740  L1MuKBMTrackCollection pretracks;
741  std::vector<int> combinatorics;
742  switch (seed->stNum()) {
743  case 1:
744  combinatorics = combos1_;
745  break;
746  case 2:
747  combinatorics = combos2_;
748  break;
749 
750  case 3:
751  combinatorics = combos3_;
752  break;
753 
754  case 4:
755  combinatorics = combos4_;
756  break;
757 
758  default:
759  printf("Something really bad happend\n");
760  }
761 
762  L1MuKBMTrack nullTrack(seed, correctedPhi(seed, seed->scNum()), correctedPhiB(seed));
763 
764  for (const auto& mask : combinatorics) {
765  L1MuKBMTrack track(seed, correctedPhi(seed, seed->scNum()), correctedPhiB(seed));
766  int phiB = correctedPhiB(seed);
767  int charge;
768  if (phiB == 0)
769  charge = 0;
770  else
771  charge = phiB / fabs(phiB);
772 
773  int address = phiB;
774  if (track.step() == 4 && (fabs(seed->phiB()) > 15))
775  address = charge * 15 * 8;
776 
777  if (track.step() == 3 && (fabs(seed->phiB()) > 30))
778  address = charge * 30 * 8;
779  if (track.step() == 2 && (fabs(seed->phiB()) > 127))
780  address = charge * 127 * 8;
781  int initialK = int(initK_[seed->stNum() - 1] * address / (1 + initK2_[seed->stNum() - 1] * charge * address));
782  if (initialK > 8191)
783  initialK = 8191;
784  if (initialK < -8191)
785  initialK = -8191;
786 
787  track.setCoordinates(seed->stNum(), initialK, correctedPhi(seed, seed->scNum()), phiB);
788  if (seed->quality() < 4) {
789  track.setCoordinates(seed->stNum(), 0, correctedPhi(seed, seed->scNum()), 0);
790  }
791 
792  track.setHitPattern(hitPattern(track));
793  //set covariance
795 
796  float DK = 512 * 512.;
797  covariance(0, 0) = DK;
798  covariance(0, 1) = 0;
799  covariance(0, 2) = 0;
800  covariance(1, 0) = 0;
801  covariance(1, 1) = float(pointResolutionPhi_);
802  covariance(1, 2) = 0;
803  covariance(2, 0) = 0;
804  covariance(2, 1) = 0;
805  covariance(2, 2) = float(pointResolutionPhiB_);
806  track.setCovariance(covariance);
807  //
808  if (verbose_) {
809  printf("New Kalman fit staring at step=%d, phi=%d,phiB=%d with curvature=%d\n",
810  track.step(),
811  track.positionAngle(),
812  track.bendingAngle(),
813  track.curvature());
814  printf("BITMASK:");
815  for (unsigned int i = 0; i < 4; ++i)
816  printf("%d", getBit(mask, i));
817  printf("\n");
818  printf("------------------------------------------------------\n");
819  printf("------------------------------------------------------\n");
820  printf("------------------------------------------------------\n");
821  printf("stubs:\n");
822  for (const auto& stub : stubs)
823  printf("station=%d phi=%d phiB=%d qual=%d tag=%d sector=%d wheel=%d fineEta= %d %d\n",
824  stub->stNum(),
825  correctedPhi(stub, seed->scNum()),
826  correctedPhiB(stub),
827  stub->quality(),
828  stub->tag(),
829  stub->scNum(),
830  stub->whNum(),
831  stub->eta1(),
832  stub->eta2());
833  printf("------------------------------------------------------\n");
834  printf("------------------------------------------------------\n");
835  }
836 
837  int phiAtStation2 = 0;
838 
839  while (track.step() > 0) {
840  // muon station 1
841  if (track.step() == 1) {
842  track.setCoordinatesAtMuon(track.curvature(), track.positionAngle(), track.bendingAngle());
843  phiAtStation2 = phiAt2(track);
845  if (!passed)
846  break;
849  //calculate coarse eta
851 
852  if (verbose_)
853  printf("Unconstrained PT in Muon System: pt=%f\n", track.ptUnconstrained());
854  }
855 
856  propagate(track);
857  if (verbose_)
858  printf("propagated Coordinates step:%d,phi=%d,phiB=%d,K=%d\n",
859  track.step(),
860  track.positionAngle(),
861  track.bendingAngle(),
862  track.curvature());
863 
864  if (track.step() > 0)
865  if (getBit(mask, track.step() - 1)) {
866  std::pair<bool, uint> bestStub = match(seed, stubs, track.step());
867  if ((!bestStub.first) || (!update(track, stubs[bestStub.second], mask)))
868  break;
869  if (verbose_) {
870  printf("updated Coordinates step:%d,phi=%d,phiB=%d,K=%d\n",
871  track.step(),
872  track.positionAngle(),
873  track.bendingAngle(),
874  track.curvature());
875  }
876  }
877 
878  if (track.step() == 0) {
879  track.setCoordinatesAtVertex(track.curvature(), track.positionAngle(), track.bendingAngle());
880  if (verbose_)
881  printf(" Coordinates before vertex constraint step:%d,phi=%d,dxy=%d,K=%d\n",
882  track.step(),
883  track.phiAtVertex(),
884  track.dxy(),
885  track.curvatureAtVertex());
886  if (verbose_)
887  printf("Chi Square = %d\n", track.approxChi2());
888 
891  if (verbose_) {
892  printf(" Coordinates after vertex constraint step:%d,phi=%d,dxy=%d,K=%d maximum local chi2=%d\n",
893  track.step(),
894  track.phiAtVertex(),
895  track.dxy(),
896  track.curvatureAtVertex(),
897  track.approxChi2());
898  printf("------------------------------------------------------\n");
899  printf("------------------------------------------------------\n");
900  }
902  //rset the coordinates at muon to include phi at station 2
903  track.setCoordinatesAtMuon(track.curvatureAtMuon(), phiAtStation2, track.phiBAtMuon());
904  track.setRank(rank(track));
905  if (verbose_)
906  printf("Floating point coordinates at vertex: pt=%f, eta=%f phi=%f\n", track.pt(), track.eta(), track.phi());
907  pretracks.push_back(track);
908  }
909  }
910  }
911  //Now for all the pretracks we need only one
912  L1MuKBMTrackCollection cleaned = clean(pretracks, seed->stNum());
913 
914  if (!cleaned.empty()) {
915  return std::make_pair(true, cleaned[0]);
916  }
917  return std::make_pair(false, nullTrack);
918 }
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 1163 of file L1TMuonBarrelKalmanAlgo.cc.

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

Referenced by chain().

1163  {
1165 
1166  std::map<uint, int> infoRank;
1167  std::map<uint, L1MuKBMTrack> infoTrack;
1168  for (uint i = 3; i <= 15; ++i) {
1169  if (i == 4 || i == 8)
1170  continue;
1171  infoRank[i] = -1;
1172  }
1173 
1174  for (const auto& track : tracks) {
1175  infoRank[track.hitPattern()] = rank(track);
1176  infoTrack[track.hitPattern()] = track;
1177  }
1178 
1179  int selected = 15;
1180  if (seed == 4) //station 4 seeded
1181  {
1182  int sel6 = infoRank[10] >= infoRank[12] ? 10 : 12;
1183  int sel5 = infoRank[14] >= infoRank[9] ? 14 : 9;
1184  int sel4 = infoRank[11] >= infoRank[13] ? 11 : 13;
1185  int sel3 = infoRank[sel6] >= infoRank[sel5] ? sel6 : sel5;
1186  int sel2 = infoRank[sel4] >= infoRank[sel3] ? sel4 : sel3;
1187  selected = infoRank[15] >= infoRank[sel2] ? 15 : sel2;
1188  }
1189  if (seed == 3) //station 3 seeded
1190  {
1191  int sel2 = infoRank[5] >= infoRank[6] ? 5 : 6;
1192  selected = infoRank[7] >= infoRank[sel2] ? 7 : sel2;
1193  }
1194  if (seed == 2) //station 3 seeded
1195  selected = 3;
1196 
1197  auto search = infoTrack.find(selected);
1198  if (search != infoTrack.end())
1199  out.push_back(search->second);
1200 
1201  return out;
1202 }
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:315
int rank(const L1MuKBMTrack &)
std::vector< L1MuKBMTrack > L1MuKBMTrackCollection
Definition: L1MuKBMTrack.h:15
l1t::RegionalMuonCand L1TMuonBarrelKalmanAlgo::convertToBMTF ( const L1MuKBMTrack track)

Definition at line 50 of file L1TMuonBarrelKalmanAlgo.cc.

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

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

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

Definition at line 292 of file L1TMuonBarrelKalmanAlgo.cc.

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

292  {
293  if (stub->scNum() == sector) {
294  return stub->phi();
295  } else if ((stub->scNum() == sector - 1) || (stub->scNum() == 11 && sector == 0)) {
296  return stub->phi() - 2144;
297  } else if ((stub->scNum() == sector + 1) || (stub->scNum() == 0 && sector == 11)) {
298  return stub->phi() + 2144;
299  }
300  return stub->phi();
301 }
int L1TMuonBarrelKalmanAlgo::correctedPhiB ( const L1MuKBMTCombinedStubRef stub)
private

Definition at line 287 of file L1TMuonBarrelKalmanAlgo.cc.

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

287  {
288  //Promote phiB to 12 bits
289  return 8 * stub->phiB();
290 }
int L1TMuonBarrelKalmanAlgo::customBitmask ( unsigned int  bit1,
unsigned int  bit2,
unsigned int  bit3,
unsigned int  bit4 
)
private

Definition at line 311 of file L1TMuonBarrelKalmanAlgo.cc.

Referenced by rank().

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

Definition at line 1013 of file L1TMuonBarrelKalmanAlgo.cc.

Referenced by trackAddress().

1013  {
1014  if (ownwheel) {
1015  if (sector == 0) {
1016  if (tag)
1017  return 9;
1018  else
1019  return 8;
1020  } else if (sector == 1) {
1021  if (tag)
1022  return 11;
1023  else
1024  return 10;
1025 
1026  } else {
1027  if (tag)
1028  return 13;
1029  else
1030  return 12;
1031  }
1032 
1033  } else {
1034  if (sector == 0) {
1035  if (tag)
1036  return 1;
1037  else
1038  return 0;
1039  } else if (sector == 1) {
1040  if (tag)
1041  return 3;
1042  else
1043  return 2;
1044 
1045  } else {
1046  if (tag)
1047  return 5;
1048  else
1049  return 4;
1050  }
1051  }
1052  return 15;
1053 }
bool L1TMuonBarrelKalmanAlgo::estimateChiSquare ( L1MuKBMTrack track)
private

Definition at line 920 of file L1TMuonBarrelKalmanAlgo.cc.

References funct::abs(), L1MuKBMTrack::approxChi2(), chiSquare_, chiSquareCut_, chiSquareCutCurv_, chiSquareCutPattern_, correctedPhi(), L1MuKBMTrack::curvatureAtMuon(), dumpMFGeometry_cfg::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().

920  {
921  //here we have a simplification of the algorithm for the sake of the emulator - rsult is identical
922  // we apply cuts on the firmware as |u -u'|^2 < a+b *K^2
923  int K = track.curvatureAtMuon();
924 
925  uint chi = 0;
926 
927  // const double PHI[4]={0.0,0.249,0.543,0.786};
928  // const double DROR[4]={0.0,0.182,0.430,0.677};
929 
930  int coords = wrapAround((track.phiAtMuon() + track.phiBAtMuon()) >> 4, 512);
931  for (const auto& stub : track.stubs()) {
932  int AK = wrapAround(fp_product(-chiSquare_[stub->stNum() - 1], K >> 4, 8), 256);
933  int stubCoords = wrapAround((correctedPhi(stub, track.sector()) >> 4) + (stub->phiB() >> 1), 512);
934  int diff1 = wrapAround(stubCoords - coords, 1024);
935  uint delta = wrapAround(abs(diff1 + AK), 2048);
936  chi = chi + delta;
937  if (verbose_)
938  printf("Chi Square stub for track with coords=%d -> AK=%d stubCoords=%d diff=%d delta=%d\n",
939  coords,
940  AK,
941  stubCoords,
942  diff1,
943  delta);
944  }
945 
946  if (chi > 127)
947  chi = 127;
948  // for (const auto& stub: track.stubs()) {
949  // int deltaPhi = (correctedPhi(stub,track.sector())-track.phiAtMuon())>>3;
950  // int AK = fp_product(PHI[stub->stNum()-1],K>>3,8);
951  // int BPB = fp_product(DROR[stub->stNum()-1],track.phiBAtMuon()>>3,8);
952  // chi=chi+abs(deltaPhi-AK-BPB);
953  // }
954  // // }
955 
956  track.setApproxChi2(chi);
957 
958  for (uint i = 0; i < chiSquareCutPattern_.size(); ++i) {
959  if (track.hitPattern() == chiSquareCutPattern_[i] && fabs(K) < chiSquareCutCurv_[i] &&
960  track.approxChi2() > chiSquareCut_[i])
961  return false;
962  }
963  return true;
964 }
int phiBAtMuon() const
Definition: L1MuKBMTrack.cc:39
int fp_product(float, int, uint)
std::vector< double > chiSquare_
int curvatureAtMuon() const
Definition: L1MuKBMTrack.cc:37
int approxChi2() const
Definition: L1MuKBMTrack.cc:55
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const L1MuKBMTCombinedStubRefVector & stubs() const
Definition: L1MuKBMTrack.cc:76
int phiAtMuon() const
Definition: L1MuKBMTrack.cc:38
std::vector< int > chiSquareCutPattern_
std::vector< int > chiSquareCut_
int correctedPhi(const L1MuKBMTCombinedStubRef &, int)
int sector() const
Definition: L1MuKBMTrack.cc:61
std::vector< int > chiSquareCutCurv_
int hitPattern() const
Definition: L1MuKBMTrack.cc:58
void setApproxChi2(int)
void L1TMuonBarrelKalmanAlgo::estimateCompatibility ( L1MuKBMTrack track)
private

Definition at line 966 of file L1TMuonBarrelKalmanAlgo.cc.

References L1MuKBMTrack::approxChi2(), chiSquareCutTight_, L1MuKBMTrack::curvatureAtVertex(), dumpMFGeometry_cfg::delta, change_name::diff, L1MuKBMTrack::dxy(), runTheMatrix::err, 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().

966  {
967  int K = track.curvatureAtVertex() >> 4;
968 
969  if (track.stubs().size() != 2) {
970  track.setTrackCompatibility(0);
971  return;
972  }
973 
974  uint stubSel = 1;
975  if (track.stubs()[0]->quality() > track.stubs()[1]->quality())
976  stubSel = 0;
977 
978  const L1MuKBMTCombinedStubRef& stub = track.stubs()[stubSel];
979  int absK = fabs(K);
980  int diff = wrapAround(stub->phiB() - fp_product(trackComp_[stub->stNum() - 1], K, 9), 2048);
981  int delta = fabs(diff);
982  uint err =
983  wrapAround(trackCompErr1_[stub->stNum() - 1] + fp_product(trackCompErr2_[stub->stNum() - 1], absK, 9), 256);
984  track.setTrackCompatibility(delta / err);
985 
986  for (uint i = 0; i < trackCompPattern_.size(); ++i) {
987  int deltaMax = err * trackCompCut_[i];
988  if ((track.hitPattern() == trackCompPattern_[i]) && (absK < trackCompCutCurv_[i]) &&
989  ((track.approxChi2() > chiSquareCutTight_[i]) || (delta > deltaMax))) {
990  track.setCoordinatesAtVertex(8191, track.phiAtVertex(), track.dxy());
991  break;
992  }
993  }
994 }
void setCoordinatesAtVertex(int, int, int)
Definition: L1MuKBMTrack.cc:87
void setTrackCompatibility(int)
int phiAtVertex() const
Definition: L1MuKBMTrack.cc:43
std::vector< int > trackCompPattern_
int fp_product(float, int, uint)
int approxChi2() const
Definition: L1MuKBMTrack.cc:55
std::vector< double > trackComp_
const L1MuKBMTCombinedStubRefVector & stubs() const
Definition: L1MuKBMTrack.cc:76
std::vector< int > chiSquareCutTight_
int dxy() const
Definition: L1MuKBMTrack.cc:45
int curvatureAtVertex() const
Definition: L1MuKBMTrack.cc:41
std::vector< double > trackCompErr1_
int hitPattern() const
Definition: L1MuKBMTrack.cc:58
std::vector< double > trackCompErr2_
std::vector< int > trackCompCutCurv_
uint L1TMuonBarrelKalmanAlgo::etaStubRank ( const L1MuKBMTCombinedStubRef stub)
private

Definition at line 1204 of file L1TMuonBarrelKalmanAlgo.cc.

Referenced by calculateEta().

1204  {
1205  if (stub->qeta1() != 0 && stub->qeta2() != 0) {
1206  return 0;
1207  }
1208  if (stub->qeta1() == 0) {
1209  return 0;
1210  }
1211  // return (stub->qeta1()*4+stub->stNum());
1212  return (stub->qeta1());
1213 }
int L1TMuonBarrelKalmanAlgo::fp_product ( float  a,
int  b,
uint  bits 
)
private

Definition at line 1124 of file L1TMuonBarrelKalmanAlgo.cc.

References bits.

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

1124  {
1125  // return long(a*(1<<bits)*b)>>bits;
1126  return (long((a * (1 << bits)) * b)) >> bits;
1127 }
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:118
double a
Definition: hdecay.h:119
bool L1TMuonBarrelKalmanAlgo::getBit ( int  bitmask,
int  pos 
)
private

Definition at line 315 of file L1TMuonBarrelKalmanAlgo.cc.

Referenced by chain().

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

Definition at line 41 of file L1TMuonBarrelKalmanAlgo.cc.

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

41  {
42  for (uint i = 0; i < tracks.size(); ++i) {
43  printf("Code=%d, track=%d\n", tracks[i].hitPattern(), mask);
44  if (tracks[i].hitPattern() == mask)
45  return std::make_pair(true, i);
46  }
47  return std::make_pair(false, 0);
48 }
int hitPattern(const L1MuKBMTrack &)
int L1TMuonBarrelKalmanAlgo::hitPattern ( const L1MuKBMTrack track)
private

Definition at line 303 of file L1TMuonBarrelKalmanAlgo.cc.

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

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

303  {
304  unsigned int mask = 0;
305  for (const auto& stub : track.stubs()) {
306  mask = mask + round(pow(2, stub->stNum() - 1));
307  }
308  return mask;
309 }
const L1MuKBMTCombinedStubRefVector & stubs() const
Definition: L1MuKBMTrack.cc:76
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
std::pair< bool, uint > L1TMuonBarrelKalmanAlgo::match ( const L1MuKBMTCombinedStubRef seed,
const L1MuKBMTCombinedStubRefVector stubs,
int  step 
)
private

Definition at line 163 of file L1TMuonBarrelKalmanAlgo.cc.

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

Referenced by chain().

165  {
167 
168  std::map<uint, uint> diffInfo;
169  for (uint i = 0; i < 12; ++i) {
170  diffInfo[i] = 60000;
171  }
172 
173  std::map<uint, uint> stubInfo;
174 
175  int sector = seed->scNum();
176  int previousSector = sector - 1;
177  int nextSector = sector + 1;
178  if (sector == 0) {
179  previousSector = 11;
180  }
181  if (sector == 11) {
182  nextSector = 0;
183  }
184 
185  int wheel = seed->whNum();
186  int innerWheel = 0;
187  if (wheel == -2)
188  innerWheel = -1;
189  if (wheel == -1)
190  innerWheel = 0;
191  if (wheel == 0)
192  innerWheel = 1982;
193  if (wheel == 1)
194  innerWheel = 0;
195  if (wheel == 2)
196  innerWheel = 1;
197 
198  //First align the data
199  uint N = 0;
200  for (const auto& stub : stubs) {
201  N = N + 1;
202 
203  if (stub->stNum() != step)
204  continue;
205 
206  uint distance =
207  fabs(wrapAround(((correctedPhi(seed, seed->scNum()) - correctedPhi(stub, seed->scNum())) >> 3), 1024));
208 
209  if (stub->scNum() == previousSector) {
210  if (stub->whNum() == wheel) {
211  if (!stub->tag()) {
212  diffInfo[0] = distance;
213  stubInfo[0] = N - 1;
214  } else {
215  diffInfo[1] = distance;
216  stubInfo[1] = N - 1;
217  }
218  } else if (stub->whNum() == innerWheel) {
219  if (!stub->tag()) {
220  diffInfo[2] = distance;
221  stubInfo[2] = N - 1;
222  } else {
223  diffInfo[3] = distance;
224  stubInfo[3] = N - 1;
225  }
226  }
227  } else if (stub->scNum() == sector) {
228  if (stub->whNum() == wheel) {
229  if (!stub->tag()) {
230  diffInfo[4] = distance;
231  stubInfo[4] = N - 1;
232  } else {
233  diffInfo[5] = distance;
234  stubInfo[5] = N - 1;
235  }
236  } else if (stub->whNum() == innerWheel) {
237  if (!stub->tag()) {
238  diffInfo[6] = distance;
239  stubInfo[6] = N - 1;
240  } else {
241  diffInfo[7] = distance;
242  stubInfo[7] = N - 1;
243  }
244  }
245  } else if (stub->scNum() == nextSector) {
246  if (stub->whNum() == wheel) {
247  if (!stub->tag()) {
248  diffInfo[8] = distance;
249  stubInfo[8] = N - 1;
250  } else {
251  diffInfo[9] = distance;
252  stubInfo[9] = N - 1;
253  }
254  } else if (stub->whNum() == innerWheel) {
255  if (!stub->tag()) {
256  diffInfo[10] = distance;
257  stubInfo[10] = N - 1;
258  } else {
259  diffInfo[11] = distance;
260  stubInfo[11] = N - 1;
261  }
262  }
263  }
264  }
265 
266  uint s1_1 = matchAbs(diffInfo, 0, 1);
267  uint s1_2 = matchAbs(diffInfo, 2, 3);
268  uint s1_3 = matchAbs(diffInfo, 4, 5);
269  uint s1_4 = matchAbs(diffInfo, 6, 7);
270  uint s1_5 = matchAbs(diffInfo, 8, 9);
271  uint s1_6 = matchAbs(diffInfo, 10, 11);
272 
273  uint s2_1 = matchAbs(diffInfo, s1_1, s1_2);
274  uint s2_2 = matchAbs(diffInfo, s1_3, s1_4);
275  uint s2_3 = matchAbs(diffInfo, s1_5, s1_6);
276 
277  uint s3_1 = matchAbs(diffInfo, s2_1, s2_2);
278 
279  uint s4 = matchAbs(diffInfo, s3_1, s2_3);
280 
281  if (diffInfo[s4] != 60000)
282  return std::make_pair(true, stubInfo[s4]);
283  else
284  return std::make_pair(false, 0);
285 }
std::vector< edm::Ref< L1MuKBMTCombinedStubCollection > > L1MuKBMTCombinedStubRefVector
uint matchAbs(std::map< uint, uint > &, uint, uint)
#define N
Definition: blowfish.cc:9
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 156 of file L1TMuonBarrelKalmanAlgo.cc.

References mps_fire::i, and dqmiolumiharvest::j.

Referenced by match().

156  {
157  if (info[i] < info[j])
158  return i;
159  else
160  return j;
161 }
static const TGPicture * info(bool iBackgroundIsBlack)
int L1TMuonBarrelKalmanAlgo::phiAt2 ( const L1MuKBMTrack track)
private

Definition at line 1273 of file L1TMuonBarrelKalmanAlgo.cc.

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

Referenced by chain().

1273  {
1274  //If there is stub at station 2 use this else propagate from 1
1275  for (const auto& stub : track.stubs())
1276  if (stub->stNum() == 2)
1277  return correctedPhi(stub, track.sector());
1278 
1279  int phi = track.phiAtMuon();
1280  int phiB = track.phiBAtMuon();
1281 
1282  int phiNew = phi + fp_product(phiAt2_, phiB, 10);
1283  if (verbose_)
1284  printf("Phi at second station=%d\n", phiNew);
1285  if (phiNew > 4095)
1286  phiNew = 4095;
1287  if (phiNew < -4096)
1288  phiNew = -4096;
1289  return phiNew;
1290 }
int phiBAtMuon() const
Definition: L1MuKBMTrack.cc:39
int fp_product(float, int, uint)
const L1MuKBMTCombinedStubRefVector & stubs() const
Definition: L1MuKBMTrack.cc:76
int phiAtMuon() const
Definition: L1MuKBMTrack.cc:38
int correctedPhi(const L1MuKBMTCombinedStubRef &, int)
int sector() const
Definition: L1MuKBMTrack.cc:61
void L1TMuonBarrelKalmanAlgo::propagate ( L1MuKBMTrack track)
private

Definition at line 317 of file L1TMuonBarrelKalmanAlgo.cc.

References a, generateTowerEtThresholdLUT::addr, 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().

317  {
318  int K = track.curvature();
319  int phi = track.positionAngle();
320  int phiB = track.bendingAngle();
321  unsigned int step = track.step();
322 
323  //energy loss term only for MU->VERTEX
324  //int offset=int(charge*eLoss_[step-1]*K*K);
325  // if (fabs(offset)>4096)
326  // offset=4096*offset/fabs(offset);
327 
328  int charge = 1;
329  if (K != 0)
330  charge = K / fabs(K);
331 
332  int KBound = K;
333  if (KBound > 4095)
334  KBound = 4095;
335  if (KBound < -4095)
336  KBound = -4095;
337 
338  int deltaK = 0;
339  int KNew = 0;
340  if (step == 1) {
341  int addr = KBound / 2;
342  if (addr < 0)
343  addr = (-KBound) / 2;
344  deltaK = 2 * addr - int(2 * addr / (1 + eLoss_[step - 1] * addr));
345 
346  if (verbose_)
347  printf("propagate to vertex K=%d deltaK=%d addr=%d\n", K, deltaK, addr);
348  }
349 
350  if (K >= 0)
351  KNew = K - deltaK;
352  else
353  KNew = K + deltaK;
354 
355  //phi propagation
356  int phi11 = fp_product(aPhi_[step - 1], K, 10);
357  int phi12 = fp_product(-bPhi_[step - 1], phiB, 10);
358  if (verbose_) {
359  printf("phi prop = %d* %f = %d, %d* %f =%d\n", K, aPhi_[step - 1], phi11, phiB, -bPhi_[step - 1], phi12);
360  }
361  int phiNew = wrapAround(phi + phi11 + phi12, 2048);
362  //phiB propagation
363  int phiB11 = fp_product(aPhiB_[step - 1], K, 10);
364  int phiB12 = fp_product(bPhiB_[step - 1], phiB, 11);
365  int phiBNew = wrapAround(phiB11 + phiB12, 4096);
366  if (verbose_) {
367  printf("phiB prop = %d* %f = %d, %d* %f =%d\n", K, aPhiB_[step - 1], phiB11, phiB, bPhiB_[step - 1], phiB12);
368  }
369 
370  //Only for the propagation to vertex we use the LUT for better precision and the full function
371  if (step == 1) {
372  int addr = KBound / 2;
373  phiBNew = wrapAround(
374  int(aPhiB_[step - 1] * addr / (1 + charge * aPhiBNLO_[step - 1] * addr)) + int(bPhiB_[step - 1] * phiB), 4096);
375  }
377  //Rest of the stuff is for the offline version only
378  //where we want to check what is happening in the covariaznce matrix
379 
380  //Create the transformation matrix
381  double a[9];
382  a[0] = 1.;
383  a[1] = 0.0;
384  a[2] = 0.0;
385  a[3] = aPhi_[step - 1];
386  // a[3] = 0.0;
387  a[4] = 1.0;
388  a[5] = -bPhi_[step - 1];
389  //a[6]=0.0;
390  a[6] = aPhiB_[step - 1];
391  if (step == 1)
392  a[6] = aPhiB_[step - 1] / 2.0;
393 
394  a[7] = 0.0;
395  a[8] = bPhiB_[step - 1];
396 
397  ROOT::Math::SMatrix<double, 3> P(a, 9);
398 
399  const std::vector<double>& covLine = track.covariance();
400  L1MuKBMTrack::CovarianceMatrix cov(covLine.begin(), covLine.end());
401  cov = ROOT::Math::Similarity(P, cov);
402 
403  //Add the multiple scattering
404  double phiRMS = mScatteringPhi_[step - 1] * K * K;
405  double phiBRMS = mScatteringPhiB_[step - 1] * K * K;
406 
407  std::vector<double> b(6);
408  b[0] = 0;
409  b[1] = 0;
410  b[2] = phiRMS;
411  b[3] = 0;
412  b[4] = 0;
413  b[5] = phiBRMS;
414 
415  reco::Candidate::CovarianceMatrix MS(b.begin(), b.end());
416 
417  cov = cov + MS;
418 
419  if (verbose_) {
420  printf("Covariance term for phiB = %f\n", cov(2, 2));
421  printf("Multiple scattering term for phiB = %f\n", MS(2, 2));
422  }
423 
424  track.setCovariance(cov);
425  track.setCoordinates(step - 1, KNew, phiNew, phiBNew);
426 }
std::vector< double > bPhiB_
std::vector< double > aPhi_
std::vector< double > aPhiB_
std::vector< double > aPhiBNLO_
int step() const
Definition: L1MuKBMTrack.cc:60
std::vector< double > mScatteringPhiB_
int bendingAngle() const
Definition: L1MuKBMTrack.cc:51
int fp_product(float, int, uint)
void setCoordinates(int, int, int, int)
Definition: L1MuKBMTrack.cc:80
void setCovariance(const CovarianceMatrix &)
std::vector< double > mScatteringPhi_
std::vector< double > eLoss_
int curvature() const
Definition: L1MuKBMTrack.cc:47
std::vector< double > bPhi_
const std::vector< double > & covariance() const
double b
Definition: hdecay.h:118
std::pair< OmniClusterRef, TrackingParticleRef > P
double a
Definition: hdecay.h:119
step
Definition: StallMonitor.cc:94
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Candidate.h:47
int positionAngle() const
Definition: L1MuKBMTrack.cc:49
int L1TMuonBarrelKalmanAlgo::ptLUT ( int  K)
private

Definition at line 1129 of file L1TMuonBarrelKalmanAlgo.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, dqmMemoryStats::float, createfilelist::int, and DiDispStaMuonMonitor_cfi::pt.

Referenced by convertToBMTF(), and setFloatingPointValues().

1129  {
1130  int charge = (K >= 0) ? +1 : -1;
1131  float lsb = 1.25 / float(1 << 13);
1132  float FK = fabs(K);
1133 
1134  if (FK > 2047)
1135  FK = 2047.;
1136  if (FK < 26)
1137  FK = 26.;
1138 
1139  FK = FK * lsb;
1140 
1141  //step 1 -material and B-field
1142  FK = 0.898 * FK / (1.0 - 0.6 * FK);
1143  //step 2 -low Pt
1144  FK = FK - 26.382 * FK * FK * FK * FK * FK;
1145  //step 3 - misalignment
1146  FK = FK - charge * 1.408e-3;
1147  //Get to BMTF
1148  FK = FK / 1.17;
1149 
1150  int pt = 0;
1151  if (FK != 0)
1152  pt = int(2.0 / FK);
1153 
1154  if (pt > 511)
1155  pt = 511;
1156 
1157  if (pt < 6)
1158  pt = 6;
1159 
1160  return pt;
1161 }
int L1TMuonBarrelKalmanAlgo::rank ( const L1MuKBMTrack track)
private

Definition at line 996 of file L1TMuonBarrelKalmanAlgo.cc.

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

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

996  {
997  // int offset=0;
998  uint chi = track.approxChi2() > 127 ? 127 : track.approxChi2();
999  if (hitPattern(track) == customBitmask(0, 0, 1, 1))
1000  return 60;
1001  // return offset+(track.stubs().size()*2+track.quality())*80-track.approxChi2();
1002  return 160 + (track.stubs().size()) * 20 - chi;
1003 }
int approxChi2() const
Definition: L1MuKBMTrack.cc:55
int customBitmask(unsigned int, unsigned int, unsigned int, unsigned int)
const L1MuKBMTCombinedStubRefVector & stubs() const
Definition: L1MuKBMTrack.cc:76
int hitPattern(const L1MuKBMTrack &)
void L1TMuonBarrelKalmanAlgo::setFloatingPointValues ( L1MuKBMTrack track,
bool  vertex 
)
private

Definition at line 702 of file L1TMuonBarrelKalmanAlgo.cc.

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

Referenced by chain().

702  {
703  int K, etaINT;
704 
705  if (track.hasFineEta())
706  etaINT = track.fineEta();
707  else
708  etaINT = track.coarseEta();
709 
710  double lsb = 1.25 / float(1 << 13);
711  double lsbEta = 0.010875;
712 
713  if (vertex) {
714  int charge = 1;
715  if (track.curvatureAtVertex() < 0)
716  charge = -1;
717  double pt = double(ptLUT(track.curvatureAtVertex())) / 2.0;
718 
719  double phi = track.sector() * M_PI / 6.0 + track.phiAtVertex() * M_PI / (6 * 2048.) - 2 * M_PI;
720 
721  double eta = etaINT * lsbEta;
722  track.setPtEtaPhi(pt, eta, phi);
723  track.setCharge(charge);
724  } else {
725  K = track.curvatureAtMuon();
726  if (K == 0)
727  K = 1;
728 
729  if (fabs(K) < 46)
730  K = 46 * K / fabs(K);
731  double pt = 1.0 / (lsb * fabs(K));
732  if (pt < 1.6)
733  pt = 1.6;
734  track.setPtUnconstrained(pt);
735  }
736 }
int fineEta() const
Definition: L1MuKBMTrack.cc:68
int coarseEta() const
Definition: L1MuKBMTrack.cc:53
int phiAtVertex() const
Definition: L1MuKBMTrack.cc:43
void setPtUnconstrained(float)
void setPtEtaPhi(double, double, double)
void setCharge(Charge q) final
set electric charge
int curvatureAtMuon() const
Definition: L1MuKBMTrack.cc:37
bool hasFineEta() const
Definition: L1MuKBMTrack.cc:70
#define M_PI
int curvatureAtVertex() const
Definition: L1MuKBMTrack.cc:41
int sector() const
Definition: L1MuKBMTrack.cc:61
std::map< int, int > L1TMuonBarrelKalmanAlgo::trackAddress ( const L1MuKBMTrack track,
int &  word 
)
private

Definition at line 1055 of file L1TMuonBarrelKalmanAlgo.cc.

References generateTowerEtThresholdLUT::addr, 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().

1055  {
1056  std::map<int, int> out;
1057 
1058  out[l1t::RegionalMuonCand::kWheelSide] = track.wheel() < 0;
1059  if (track.wheel() == -2)
1061  else if (track.wheel() == -1)
1063  else if (track.wheel() == 0)
1065  else if (track.wheel() == 1)
1067  else if (track.wheel() == 2)
1069  else
1079  //out[l1t::RegionalMuonCand::kNumBmtfSubAddr]=0; // This is commented out for better data/MC agreement
1080 
1081  for (const auto stub : track.stubs()) {
1082  bool ownwheel = stub->whNum() == track.wheel();
1083  int sector = 0;
1084  if ((stub->scNum() == track.sector() + 1) || (stub->scNum() == 0 && track.sector() == 11))
1085  sector = +1;
1086  if ((stub->scNum() == track.sector() - 1) || (stub->scNum() == 11 && track.sector() == 0))
1087  sector = -1;
1088  int addr = encode(ownwheel, sector, stub->tag());
1089 
1090  if (stub->stNum() == 4) {
1091  if (stub->tag())
1092  addr = 1;
1093  else
1094  addr = 2;
1096  }
1097  if (stub->stNum() == 3) {
1099  }
1100  if (stub->stNum() == 2) {
1102  }
1103  if (stub->stNum() == 1) {
1105  }
1106  }
1107 
1108  word = 0;
1109  word = word | out[l1t::RegionalMuonCand::kStat1] << 12;
1110  word = word | out[l1t::RegionalMuonCand::kStat2] << 8;
1111  word = word | out[l1t::RegionalMuonCand::kStat3] << 4;
1113 
1114  return out;
1115 }
uint64_t word
const L1MuKBMTCombinedStubRefVector & stubs() const
Definition: L1MuKBMTrack.cc:76
int wheel() const
Definition: L1MuKBMTrack.cc:62
int encode(bool ownwheel, int sector, bool tag)
int sector() const
Definition: L1MuKBMTrack.cc:61
uint L1TMuonBarrelKalmanAlgo::twosCompToBits ( int  q)
private

Definition at line 1117 of file L1TMuonBarrelKalmanAlgo.cc.

References data-class-funcs::q.

Referenced by convertToBMTF().

1117  {
1118  if (q >= 0)
1119  return q;
1120  else
1121  return (~q) + 1;
1122 }
bool L1TMuonBarrelKalmanAlgo::update ( L1MuKBMTrack track,
const L1MuKBMTCombinedStubRef stub,
int  mask 
)
private

Definition at line 428 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().

428  {
429  updateEta(track, stub);
430  if (useOfflineAlgo_) {
431  if (mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12)
432  return updateOffline(track, stub);
433  else
434  return updateOffline1D(track, stub);
435 
436  } else
437  return updateLUT(track, stub, mask);
438 }
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 631 of file L1TMuonBarrelKalmanAlgo.cc.

Referenced by update().

631 {}
bool L1TMuonBarrelKalmanAlgo::updateLUT ( L1MuKBMTrack track,
const L1MuKBMTCombinedStubRef stub,
int  mask 
)
private

Definition at line 563 of file L1TMuonBarrelKalmanAlgo.cc.

References L1MuKBMTrack::addStub(), L1MuKBMTrack::bendingAngle(), correctedPhi(), correctedPhiB(), L1MuKBMTrack::curvature(), fp_product(), hitPattern(), L1MuKBMTrack::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().

563  {
564  int trackK = track.curvature();
565  int trackPhi = track.positionAngle();
566  int trackPhiB = track.bendingAngle();
567 
568  int phi = correctedPhi(stub, track.sector());
569  int phiB = correctedPhiB(stub);
570 
571  if (stub->quality() < 4)
572  phiB = trackPhiB;
573 
574  Vector2 residual;
575  int residualPhi = wrapAround(phi - trackPhi, 4096);
576  int residualPhiB = wrapAround(phiB - trackPhiB, 8192);
577 
578  if (verbose_)
579  printf("residuals %d-%d=%d %d-%d=%d\n", phi, trackPhi, int(residualPhi), phiB, trackPhiB, int(residualPhiB));
580 
581  uint absK = fabs(trackK);
582  if (absK > 4095)
583  absK = 4095;
584 
585  std::vector<float> GAIN;
586  //For the three stub stuff use only gains 0 and 4
587  if (!(mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12)) {
588  GAIN = lutService_->trackGain(track.step(), track.hitPattern(), absK / 4);
589  GAIN[1] = 0.0;
590  GAIN[3] = 0.0;
591 
592  } else {
593  GAIN = lutService_->trackGain2(track.step(), track.hitPattern(), absK / 8);
594  }
595  if (verbose_)
596  printf("Gains:%d %f %f %f %f\n", absK / 4, GAIN[0], GAIN[1], GAIN[2], GAIN[3]);
597  track.setKalmanGain(track.step(), fabs(trackK), GAIN[0], GAIN[1], 1, 0, GAIN[2], GAIN[3]);
598 
599  int k_0 = fp_product(GAIN[0], residualPhi, 3);
600  int k_1 = fp_product(GAIN[1], residualPhiB, 5);
601  int KNew = trackK + k_0 + k_1;
602  if (fabs(KNew) >= 8191)
603  return false;
604  KNew = wrapAround(KNew, 8192);
605  int phiNew = phi;
606 
607  //different products for different firmware logic
608  int pbdouble_0 = fp_product(fabs(GAIN[2]), residualPhi, 9);
609  int pb_0 = fp_product(GAIN[2], residualPhi, 9);
610  int pb_1 = fp_product(GAIN[3], residualPhiB, 9);
611 
612  if (verbose_)
613  printf("phiupdate: %d %d\n", pb_0, pb_1);
614 
615  int phiBNew;
616  if (!(mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12)) {
617  phiBNew = wrapAround(trackPhiB + pb_0, 4096);
618  if (fabs(trackPhiB + pb_0) >= 4095)
619  return false;
620  } else {
621  phiBNew = wrapAround(trackPhiB + pb_1 - pbdouble_0, 4096);
622  if (fabs(trackPhiB + pb_1 - pbdouble_0) >= 4095)
623  return false;
624  }
625  track.setCoordinates(track.step(), KNew, phiNew, phiBNew);
626  track.addStub(stub);
627  track.setHitPattern(hitPattern(track));
628  return true;
629 }
int correctedPhiB(const L1MuKBMTCombinedStubRef &)
int step() const
Definition: L1MuKBMTrack.cc:60
int bendingAngle() const
Definition: L1MuKBMTrack.cc:51
std::vector< float > trackGain2(uint, uint, uint)
void setHitPattern(int)
int fp_product(float, int, uint)
void setCoordinates(int, int, int, int)
Definition: L1MuKBMTrack.cc:80
L1TMuonBarrelKalmanLUTs * lutService_
int curvature() const
Definition: L1MuKBMTrack.cc:47
int hitPattern(const L1MuKBMTrack &)
ROOT::Math::SVector< double, 2 > Vector2
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:61
void addStub(const L1MuKBMTCombinedStubRef &)
int hitPattern() const
Definition: L1MuKBMTrack.cc:58
std::vector< float > trackGain(uint, uint, uint)
int positionAngle() const
Definition: L1MuKBMTrack.cc:49
bool L1TMuonBarrelKalmanAlgo::updateOffline ( L1MuKBMTrack track,
const L1MuKBMTCombinedStubRef stub 
)
private

Definition at line 440 of file L1TMuonBarrelKalmanAlgo.cc.

References L1MuKBMTrack::addStub(), L1MuKBMTrack::bendingAngle(), HltBtagPostValidation_cff::c, correctedPhi(), correctedPhiB(), L1MuKBMTrack::covariance(), L1MuKBMTrack::curvature(), IntegrityClient_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().

440  {
441  int trackK = track.curvature();
442  int trackPhi = track.positionAngle();
443  int trackPhiB = track.bendingAngle();
444 
445  int phi = correctedPhi(stub, track.sector());
446  int phiB = correctedPhiB(stub);
447 
448  Vector2 residual;
449  residual[0] = phi - trackPhi;
450  residual[1] = phiB - trackPhiB;
451 
452  Matrix23 H;
453  H(0, 0) = 0.0;
454  H(0, 1) = 1.0;
455  H(0, 2) = 0.0;
456  H(1, 0) = 0.0;
457  H(1, 1) = 0.0;
458  H(1, 2) = 1.0;
459 
461  R(0, 0) = pointResolutionPhi_;
462  R(0, 1) = 0.0;
463  R(1, 0) = 0.0;
464  R(1, 1) = pointResolutionPhiB_;
465 
466  const std::vector<double>& covLine = track.covariance();
467  L1MuKBMTrack::CovarianceMatrix cov(covLine.begin(), covLine.end());
468 
469  CovarianceMatrix2 S = ROOT::Math::Similarity(H, cov) + R;
470  if (!S.Invert())
471  return false;
472  Matrix32 Gain = cov * ROOT::Math::Transpose(H) * S;
473 
474  track.setKalmanGain(
475  track.step(), fabs(trackK), Gain(0, 0), Gain(0, 1), Gain(1, 0), Gain(1, 1), Gain(2, 0), Gain(2, 1));
476 
477  int KNew = (trackK + int(Gain(0, 0) * residual(0) + Gain(0, 1) * residual(1)));
478  if (fabs(KNew) > 8192)
479  return false;
480 
481  int phiNew = wrapAround(trackPhi + residual(0), 8192);
482  int phiBNew = wrapAround(trackPhiB + int(Gain(2, 0) * residual(0) + Gain(2, 1) * residual(1)), 4096);
483 
484  track.setResidual(stub->stNum() - 1, fabs(phi - phiNew) + fabs(phiB - phiBNew) / 8);
485 
486  if (verbose_) {
487  printf(" K = %d + %f * %f + %f * %f\n", trackK, Gain(0, 0), residual(0), Gain(0, 1), residual(1));
488  printf(" phiB = %d + %f * %f + %f * %f\n", trackPhiB, Gain(2, 0), residual(0), Gain(2, 1), residual(1));
489  }
490 
491  track.setCoordinates(track.step(), KNew, phiNew, phiBNew);
492  Matrix33 covNew = cov - Gain * (H * cov);
494 
495  c(0, 0) = covNew(0, 0);
496  c(0, 1) = covNew(0, 1);
497  c(0, 2) = covNew(0, 2);
498  c(1, 0) = covNew(1, 0);
499  c(1, 1) = covNew(1, 1);
500  c(1, 2) = covNew(1, 2);
501  c(2, 0) = covNew(2, 0);
502  c(2, 1) = covNew(2, 1);
503  c(2, 2) = covNew(2, 2);
504  if (verbose_) {
505  printf("Post Fit Covariance Matrix %f %f %f \n", cov(0, 0), cov(1, 1), cov(2, 2));
506  }
507 
508  track.setCovariance(c);
509  track.addStub(stub);
510  track.setHitPattern(hitPattern(track));
511 
512  return true;
513 }
int correctedPhiB(const L1MuKBMTCombinedStubRef &)
int step() const
Definition: L1MuKBMTrack.cc:60
int bendingAngle() const
Definition: L1MuKBMTrack.cc:51
void setHitPattern(int)
void setCoordinates(int, int, int, int)
Definition: L1MuKBMTrack.cc:80
void setCovariance(const CovarianceMatrix &)
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > CovarianceMatrix2
int curvature() const
Definition: L1MuKBMTrack.cc:47
const std::vector< double > & covariance() const
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:97
int hitPattern(const L1MuKBMTrack &)
ROOT::Math::SVector< double, 2 > Vector2
void setKalmanGain(unsigned int step, unsigned int K, float a1, float a2, float a3, float a4=0, float a5=0, float a6=0)
ROOT::Math::SMatrix< double, 2, 3 > Matrix23
int correctedPhi(const L1MuKBMTCombinedStubRef &, int)
int sector() const
Definition: L1MuKBMTrack.cc:61
ROOT::Math::SMatrix< double, 3, 2 > Matrix32
ROOT::Math::SMatrix< double, 3, 3 > Matrix33
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:49
bool L1TMuonBarrelKalmanAlgo::updateOffline1D ( L1MuKBMTrack track,
const L1MuKBMTCombinedStubRef stub 
)
private

Definition at line 515 of file L1TMuonBarrelKalmanAlgo.cc.

References L1MuKBMTrack::addStub(), L1MuKBMTrack::bendingAngle(), HltBtagPostValidation_cff::c, correctedPhi(), L1MuKBMTrack::covariance(), L1MuKBMTrack::curvature(), IntegrityClient_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().

515  {
516  int trackK = track.curvature();
517  int trackPhi = track.positionAngle();
518  int trackPhiB = track.bendingAngle();
519 
520  int phi = correctedPhi(stub, track.sector());
521 
522  double residual = phi - trackPhi;
523 
524  Matrix13 H;
525  H(0, 0) = 0.0;
526  H(0, 1) = 1.0;
527  H(0, 2) = 0.0;
528 
529  const std::vector<double>& covLine = track.covariance();
530  L1MuKBMTrack::CovarianceMatrix cov(covLine.begin(), covLine.end());
531 
532  double S = ROOT::Math::Similarity(H, cov)(0, 0) + pointResolutionPhi_;
533 
534  if (S == 0.0)
535  return false;
536  Matrix31 Gain = cov * ROOT::Math::Transpose(H) / S;
537 
538  track.setKalmanGain(track.step(), fabs(trackK), Gain(0, 0), 0.0, Gain(1, 0), 0.0, Gain(2, 0), 0.0);
539 
540  int KNew = wrapAround(trackK + int(Gain(0, 0) * residual), 8192);
541  int phiNew = wrapAround(trackPhi + residual, 8192);
542  int phiBNew = wrapAround(trackPhiB + int(Gain(2, 0) * residual), 4096);
543  track.setCoordinates(track.step(), KNew, phiNew, phiBNew);
544  Matrix33 covNew = cov - Gain * (H * cov);
546 
547  c(0, 0) = covNew(0, 0);
548  c(0, 1) = covNew(0, 1);
549  c(0, 2) = covNew(0, 2);
550  c(1, 0) = covNew(1, 0);
551  c(1, 1) = covNew(1, 1);
552  c(1, 2) = covNew(1, 2);
553  c(2, 0) = covNew(2, 0);
554  c(2, 1) = covNew(2, 1);
555  c(2, 2) = covNew(2, 2);
556  track.setCovariance(c);
557  track.addStub(stub);
558  track.setHitPattern(hitPattern(track));
559 
560  return true;
561 }
int step() const
Definition: L1MuKBMTrack.cc:60
int bendingAngle() const
Definition: L1MuKBMTrack.cc:51
void setHitPattern(int)
ROOT::Math::SMatrix< double, 1, 3 > Matrix13
void setCoordinates(int, int, int, int)
Definition: L1MuKBMTrack.cc:80
void setCovariance(const CovarianceMatrix &)
ROOT::Math::SMatrix< double, 3, 1 > Matrix31
int curvature() const
Definition: L1MuKBMTrack.cc:47
const std::vector< double > & covariance() const
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:97
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:61
ROOT::Math::SMatrix< double, 3, 3 > Matrix33
void addStub(const L1MuKBMTCombinedStubRef &)
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Candidate.h:47
int positionAngle() const
Definition: L1MuKBMTrack.cc:49
void L1TMuonBarrelKalmanAlgo::vertexConstraint ( L1MuKBMTrack track)
private

Definition at line 633 of file L1TMuonBarrelKalmanAlgo.cc.

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

Referenced by chain().

633  {
634  if (useOfflineAlgo_)
636  else
637  vertexConstraintLUT(track);
638 }
void vertexConstraintLUT(L1MuKBMTrack &)
void vertexConstraintOffline(L1MuKBMTrack &)
void L1TMuonBarrelKalmanAlgo::vertexConstraintLUT ( L1MuKBMTrack track)
private

Definition at line 681 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().

681  {
682  double residual = -track.dxy();
683  uint absK = fabs(track.curvature());
684  if (absK > 2047)
685  absK = 2047;
686 
687  std::pair<float, float> GAIN = lutService_->vertexGain(track.hitPattern(), absK / 2);
688  track.setKalmanGain(track.step(), fabs(track.curvature()), GAIN.first, GAIN.second, -1);
689 
690  int k_0 = fp_product(GAIN.first, int(residual), 7);
691  int KNew = wrapAround(track.curvature() + k_0, 8192);
692 
693  if (verbose_) {
694  printf("VERTEX GAIN(%d)= %f * %d = %d\n", absK / 2, GAIN.first, int(residual), k_0);
695  }
696 
697  int p_0 = fp_product(GAIN.second, int(residual), 7);
698  int phiNew = wrapAround(track.positionAngle() + p_0, 8192);
699  track.setCoordinatesAtVertex(KNew, phiNew, -residual);
700 }
void setCoordinatesAtVertex(int, int, int)
Definition: L1MuKBMTrack.cc:87
int step() const
Definition: L1MuKBMTrack.cc:60
int fp_product(float, int, uint)
std::pair< float, float > vertexGain(uint, uint)
L1TMuonBarrelKalmanLUTs * lutService_
int curvature() const
Definition: L1MuKBMTrack.cc:47
int dxy() const
Definition: L1MuKBMTrack.cc:45
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:58
int positionAngle() const
Definition: L1MuKBMTrack.cc:49
void L1TMuonBarrelKalmanAlgo::vertexConstraintOffline ( L1MuKBMTrack track)
private

Definition at line 640 of file L1TMuonBarrelKalmanAlgo.cc.

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

Referenced by vertexConstraint().

640  {
641  double residual = -track.dxy();
642  Matrix13 H;
643  H(0, 0) = 0;
644  H(0, 1) = 0;
645  H(0, 2) = 1;
646 
647  const std::vector<double>& covLine = track.covariance();
648  L1MuKBMTrack::CovarianceMatrix cov(covLine.begin(), covLine.end());
649 
650  double S = (ROOT::Math::Similarity(H, cov))(0, 0) + pointResolutionVertex_;
651  S = 1.0 / S;
652  Matrix31 Gain = cov * (ROOT::Math::Transpose(H)) * S;
653  track.setKalmanGain(track.step(), fabs(track.curvature()), Gain(0, 0), Gain(1, 0), Gain(2, 0));
654 
655  if (verbose_) {
656  printf("sigma3=%f sigma6=%f\n", cov(0, 3), cov(3, 3));
657  printf(" K = %d + %f * %f\n", track.curvature(), Gain(0, 0), residual);
658  }
659 
660  int KNew = wrapAround(int(track.curvature() + Gain(0, 0) * residual), 8192);
661  int phiNew = wrapAround(int(track.positionAngle() + Gain(1, 0) * residual), 8192);
662  int dxyNew = wrapAround(int(track.dxy() + Gain(2, 0) * residual), 8192);
663  if (verbose_)
664  printf("Post fit impact parameter=%d\n", dxyNew);
665  track.setCoordinatesAtVertex(KNew, phiNew, -residual);
666  Matrix33 covNew = cov - Gain * (H * cov);
668  c(0, 0) = covNew(0, 0);
669  c(0, 1) = covNew(0, 1);
670  c(0, 2) = covNew(0, 2);
671  c(1, 0) = covNew(1, 0);
672  c(1, 1) = covNew(1, 1);
673  c(1, 2) = covNew(1, 2);
674  c(2, 0) = covNew(2, 0);
675  c(2, 1) = covNew(2, 1);
676  c(2, 2) = covNew(2, 2);
677  track.setCovariance(c);
678  // track.covariance = track.covariance - Gain*H*track.covariance;
679 }
void setCoordinatesAtVertex(int, int, int)
Definition: L1MuKBMTrack.cc:87
int step() const
Definition: L1MuKBMTrack.cc:60
ROOT::Math::SMatrix< double, 1, 3 > Matrix13
void setCovariance(const CovarianceMatrix &)
ROOT::Math::SMatrix< double, 3, 1 > Matrix31
int curvature() const
Definition: L1MuKBMTrack.cc:47
const std::vector< double > & covariance() const
int dxy() const
Definition: L1MuKBMTrack.cc:45
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:97
void setKalmanGain(unsigned int step, unsigned int K, float a1, float a2, float a3, float a4=0, float a5=0, float a6=0)
ROOT::Math::SMatrix< double, 3, 3 > Matrix33
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Candidate.h:47
int positionAngle() const
Definition: L1MuKBMTrack.cc:49
int L1TMuonBarrelKalmanAlgo::wrapAround ( int  value,
int  maximum 
)
private

Definition at line 1005 of file L1TMuonBarrelKalmanAlgo.cc.

References relativeConstraints::value.

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

1005  {
1006  if (value > maximum - 1)
1007  return wrapAround(value - 2 * maximum, maximum);
1008  if (value < -maximum)
1009  return wrapAround(value + 2 * maximum, maximum);
1010  return value;
1011 }
Definition: value.py:1

Member Data Documentation

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

Definition at line 78 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

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

Definition at line 79 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

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

Definition at line 80 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

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

Definition at line 81 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

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

Definition at line 82 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

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

Definition at line 90 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateChiSquare().

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

Definition at line 93 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateChiSquare().

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

Definition at line 92 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateChiSquare().

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

Definition at line 91 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateChiSquare().

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

Definition at line 101 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

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

Definition at line 107 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain().

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

Definition at line 106 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain().

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

Definition at line 105 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain().

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

Definition at line 104 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain().

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

Definition at line 77 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

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

Definition at line 84 of file L1TMuonBarrelKalmanAlgo.h.

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

Definition at line 85 of file L1TMuonBarrelKalmanAlgo.h.

uint L1TMuonBarrelKalmanAlgo::globalChi2Cut_
private

Definition at line 88 of file L1TMuonBarrelKalmanAlgo.h.

uint L1TMuonBarrelKalmanAlgo::globalChi2CutLimit_
private

Definition at line 89 of file L1TMuonBarrelKalmanAlgo.h.

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

Definition at line 74 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain().

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

Definition at line 73 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain().

L1TMuonBarrelKalmanLUTs* L1TMuonBarrelKalmanAlgo::lutService_
private

Definition at line 69 of file L1TMuonBarrelKalmanAlgo.h.

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

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

Definition at line 113 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

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

Definition at line 114 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by propagate().

double L1TMuonBarrelKalmanAlgo::phiAt2_
private

Definition at line 83 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by phiAt2().

double L1TMuonBarrelKalmanAlgo::pointResolutionPhi_
private

Definition at line 116 of file L1TMuonBarrelKalmanAlgo.h.

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

double L1TMuonBarrelKalmanAlgo::pointResolutionPhiB_
private

Definition at line 118 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by chain(), and updateOffline().

double L1TMuonBarrelKalmanAlgo::pointResolutionVertex_
private

Definition at line 120 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by vertexConstraintOffline().

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

Definition at line 95 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

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

Definition at line 100 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

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

Definition at line 99 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

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

Definition at line 96 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

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

Definition at line 97 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

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

Definition at line 98 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by estimateCompatibility().

bool L1TMuonBarrelKalmanAlgo::useOfflineAlgo_
private

Definition at line 112 of file L1TMuonBarrelKalmanAlgo.h.

Referenced by update(), and vertexConstraint().

bool L1TMuonBarrelKalmanAlgo::verbose_
private