CMS 3D CMS Logo

L1TkMuMantra.h
Go to the documentation of this file.
1 #ifndef L1Trigger_L1TTrackMatch_L1TKMUMANTRA_H
2 #define L1Trigger_L1TTrackMatch_L1TKMUMANTRA_H
3 
4 /*
5 ** class : GenericDataFormat
6 ** author : L.Cadamuro (UF)
7 ** date : 4/11/2019
8 ** brief : very generic structs to be used as inputs to the correlator
9 ** : to make sure that Mantra can handle muons and tracks from all the detectors
10 */
11 
12 namespace L1TkMuMantraDF {
13 
14  struct track_df {
15  double pt; // GeV
16  double eta; // rad, -inf / +inf
17  double theta; // rad, 0 -> +90-90
18  double phi; // rad, -pi / + pi
19  int nstubs; //
20  double chi2; //
21  int charge; // -1. +1
22  };
23 
24  struct muon_df {
25  double pt; // GeV
26  double eta; // rad, -inf / +inf
27  double theta; // rad, 0 -> +90-90
28  double phi; // rad, -pi / + pi
29  int charge; // -1. +1
30  };
31 } // namespace L1TkMuMantraDF
32 
33 /*
34 ** class : L1TkMuMantra
35 ** author : L.Cadamuro (UF)
36 ** date : 4/11/2019
37 ** brief : correlates muons and tracks using pre-encoded windows
38 */
39 
40 #include <iostream>
41 #include <vector>
42 #include <string>
43 #include <utility>
45 #include <cmath>
46 
47 #include "TFile.h"
50 
51 class L1TkMuMantra {
52 public:
53  L1TkMuMantra(const std::vector<double>& bounds, TFile* fIn_theta, TFile* fIn_phi, std::string name);
55 
56  // returns a vector with the same size of muons, each with an index to the matched L1 track, or -1 if no match is found
57  std::vector<int> find_match(const std::vector<L1TkMuMantraDF::track_df>& tracks,
58  const std::vector<L1TkMuMantraDF::muon_df>& muons);
59 
60  void test(double eta, double pt);
61 
62  void relax_windows(double& low, double cent, double& high); // will modify low and high
63 
64  void set_safety_factor(float sf_l, float sf_h) {
65  safety_factor_l_ = sf_l;
66  safety_factor_h_ = sf_h;
67  if (verbosity_ > 0)
68  LogTrace("L1TkMuMantra") << name_ << " safety factor LOW is " << safety_factor_l_ << std::endl;
69  if (verbosity_ > 0)
70  LogTrace("L1TkMuMantra") << name_ << " safety factor HIGH is " << safety_factor_h_ << std::endl;
71  }
72 
73  int sign(double x) {
74  if (x == 0)
75  return 1;
76  return (0 < x) - (x < 0);
77  }
78 
79  void setArbitrationType(std::string type); // MaxPt, MinDeltaPt
80 
81  // static functions, meant to be used from outside to interface with MAnTra
82  static std::vector<double> prepare_corr_bounds(std::string fname, std::string hname);
83 
84  // converters
85  static double deg_to_rad(double x) { return (x * angle_units::degPerRad); }
86 
87  static double eta_to_theta(double x) {
88  // give theta in rad
89  return (2. * atan(exp(-1. * x)));
90  }
91 
92  static double to_mpio2_pio2(double x) {
93  // put the angle in radians between -pi/2 and pi/2
94  while (x >= 0.5 * M_PI)
95  x -= M_PI;
96  while (x < -0.5 * M_PI)
97  x += M_PI;
98  return x;
99  }
100 
101  static double to_mpi_pi(double x) {
102  while (x >= M_PI)
103  x -= 2. * M_PI;
104  while (x < -M_PI)
105  x += 2. * M_PI;
106  return x;
107  }
108 
109 private:
110  int findBin(double val);
111 
113 
114  int nbins_; // counts the number of MuMatchWindow = bounds_.size() - 1
115  std::vector<double> bounds_; // counts the boundaries of the MuMatchWindow (in eta/theta)
116  std::vector<MuMatchWindow> wdws_theta_;
117  std::vector<MuMatchWindow> wdws_phi_;
118 
119  int min_nstubs = 4; // >= min_nstubs
120  double max_chi2 = 100; // < max_chi2
121 
122  float safety_factor_l_; // increase the lower theta/phi threshold by this fractions w.r.t. the center
123  float safety_factor_h_; // increase the upper theta/phi threshold by this fractions w.r.t. the center
124 
125  enum sortParType {
126  kMaxPt, // pick the highest pt track matched
127  kMinDeltaPt // pick the track with the smallest pt difference w.r.t the muon
128  };
129 
131 
132  int verbosity_ = 0;
133 };
134 
135 #endif // L1TKMUMANTRA_H
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
L1TkMuMantraDF::muon_df::theta
double theta
Definition: L1TkMuMantra.h:27
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
L1TkMuMantra::safety_factor_l_
float safety_factor_l_
Definition: L1TkMuMantra.h:122
MessageLogger.h
MuMatchWindow.h
L1TkMuMantra::max_chi2
double max_chi2
Definition: L1TkMuMantra.h:120
L1TkMuMantra::wdws_theta_
std::vector< MuMatchWindow > wdws_theta_
Definition: L1TkMuMantra.h:116
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
L1TkMuMantra::set_safety_factor
void set_safety_factor(float sf_l, float sf_h)
Definition: L1TkMuMantra.h:64
L1TkMuMantraDF
Definition: L1TkMuMantra.h:12
L1TkMuMantra::prepare_corr_bounds
static std::vector< double > prepare_corr_bounds(std::string fname, std::string hname)
Definition: L1TkMuMantra.cc:199
L1TkMuMantraDF::track_df
Definition: L1TkMuMantra.h:14
DDAxes::x
L1TkMuMantraDF::track_df::charge
int charge
Definition: L1TkMuMantra.h:21
L1TkMuMantraDF::track_df::nstubs
int nstubs
Definition: L1TkMuMantra.h:19
L1TkMuMantra::kMaxPt
Definition: L1TkMuMantra.h:126
L1TkMuMantra::sort_type_
sortParType sort_type_
Definition: L1TkMuMantra.h:130
L1TkMuMantra::wdws_phi_
std::vector< MuMatchWindow > wdws_phi_
Definition: L1TkMuMantra.h:117
L1TkMuMantra::relax_windows
void relax_windows(double &low, double cent, double &high)
Definition: L1TkMuMantra.cc:178
angle_units::degPerRad
constexpr long double degPerRad
Definition: angle_units.h:9
L1TkMuMantra::kMinDeltaPt
Definition: L1TkMuMantra.h:127
PVValHelper::eta
Definition: PVValidationHelpers.h:69
L1TkMuMantra::L1TkMuMantra
L1TkMuMantra(const std::vector< double > &bounds, TFile *fIn_theta, TFile *fIn_phi, std::string name)
Definition: L1TkMuMantra.cc:8
L1TkMuMantra::test
void test(double eta, double pt)
Definition: L1TkMuMantra.cc:97
L1TkMuMantra::bounds_
std::vector< double > bounds_
Definition: L1TkMuMantra.h:115
L1TkMuMantra::safety_factor_h_
float safety_factor_h_
Definition: L1TkMuMantra.h:123
L1TkMuMantraDF::track_df::phi
double phi
Definition: L1TkMuMantra.h:18
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1TkMuMantraDF::track_df::pt
double pt
Definition: L1TkMuMantra.h:15
L1TkMuMantraDF::muon_df::phi
double phi
Definition: L1TkMuMantra.h:28
L1TkMuMantraDF::muon_df::eta
double eta
Definition: L1TkMuMantra.h:26
L1TkMuMantraDF::track_df::theta
double theta
Definition: L1TkMuMantra.h:17
L1TkMuMantra::findBin
int findBin(double val)
Definition: L1TkMuMantra.cc:80
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
L1TkMuMantraDF::track_df::chi2
double chi2
Definition: L1TkMuMantra.h:20
L1TkMuMantra::find_match
std::vector< int > find_match(const std::vector< L1TkMuMantraDF::track_df > &tracks, const std::vector< L1TkMuMantraDF::muon_df > &muons)
Definition: L1TkMuMantra.cc:115
L1TkMuMantraDF::muon_df
Definition: L1TkMuMantra.h:24
L1TkMuMantra::min_nstubs
int min_nstubs
Definition: L1TkMuMantra.h:119
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
L1TkMuMantra::to_mpio2_pio2
static double to_mpio2_pio2(double x)
Definition: L1TkMuMantra.h:92
L1TkMuMantra::nbins_
int nbins_
Definition: L1TkMuMantra.h:114
LaserClient_cfi.high
high
Definition: LaserClient_cfi.py:50
type
type
Definition: HCALResponse.h:21
heppy_batch.val
val
Definition: heppy_batch.py:351
L1TkMuMantra::eta_to_theta
static double eta_to_theta(double x)
Definition: L1TkMuMantra.h:87
L1TkMuMantra::setArbitrationType
void setArbitrationType(std::string type)
Definition: L1TkMuMantra.cc:188
L1TkMuMantraDF::muon_df::charge
int charge
Definition: L1TkMuMantra.h:29
L1TkMuMantraDF::track_df::eta
double eta
Definition: L1TkMuMantra.h:16
L1TkMuMantraDF::muon_df::pt
double pt
Definition: L1TkMuMantra.h:25
L1TkMuMantra::sortParType
sortParType
Definition: L1TkMuMantra.h:125
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
L1TkMuMantra::deg_to_rad
static double deg_to_rad(double x)
Definition: L1TkMuMantra.h:85
L1TkMuMantra::to_mpi_pi
static double to_mpi_pi(double x)
Definition: L1TkMuMantra.h:101
L1TkMuMantra::verbosity_
int verbosity_
Definition: L1TkMuMantra.h:132
L1TkMuMantra::~L1TkMuMantra
~L1TkMuMantra()
Definition: L1TkMuMantra.h:54
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
angle_units.h
L1TkMuMantra::name_
std::string name_
Definition: L1TkMuMantra.h:112
LaserClient_cfi.low
low
Definition: LaserClient_cfi.py:52
L1TkMuMantra
Definition: L1TkMuMantra.h:51
L1TkMuMantra::sign
int sign(double x)
Definition: L1TkMuMantra.h:73