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 eta_to_theta(double x) {
86  // give theta in rad
87  return (2. * atan(exp(-1. * x)));
88  }
89 
90  static double to_mpio2_pio2(double x) {
91  // put the angle in radians between -pi/2 and pi/2
92  while (x >= 0.5 * M_PI)
93  x -= M_PI;
94  while (x < -0.5 * M_PI)
95  x += M_PI;
96  return x;
97  }
98 
99 private:
100  int findBin(double val);
101 
103 
104  int nbins_; // counts the number of MuMatchWindow = bounds_.size() - 1
105  std::vector<double> bounds_; // counts the boundaries of the MuMatchWindow (in eta/theta)
106  std::vector<MuMatchWindow> wdws_theta_;
107  std::vector<MuMatchWindow> wdws_phi_;
108 
109  int min_nstubs = 4; // >= min_nstubs
110  double max_chi2 = 100; // < max_chi2
111 
112  float safety_factor_l_; // increase the lower theta/phi threshold by this fractions w.r.t. the center
113  float safety_factor_h_; // increase the upper theta/phi threshold by this fractions w.r.t. the center
114 
115  enum sortParType {
116  kMaxPt, // pick the highest pt track matched
117  kMinDeltaPt // pick the track with the smallest pt difference w.r.t the muon
118  };
119 
121 
122  int verbosity_ = 0;
123 };
124 
125 #endif // L1TKMUMANTRA_H
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
L1TkMuMantraDF::muon_df::theta
double theta
Definition: L1TkMuMantra.h:27
L1TkMuMantra::safety_factor_l_
float safety_factor_l_
Definition: L1TkMuMantra.h:112
MessageLogger.h
MuMatchWindow.h
L1TkMuMantra::max_chi2
double max_chi2
Definition: L1TkMuMantra.h:110
L1TkMuMantra::wdws_theta_
std::vector< MuMatchWindow > wdws_theta_
Definition: L1TkMuMantra.h:106
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:201
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:116
L1TkMuMantra::sort_type_
sortParType sort_type_
Definition: L1TkMuMantra.h:120
L1TkMuMantra::wdws_phi_
std::vector< MuMatchWindow > wdws_phi_
Definition: L1TkMuMantra.h:107
L1TkMuMantra::relax_windows
void relax_windows(double &low, double cent, double &high)
Definition: L1TkMuMantra.cc:180
L1TkMuMantra::kMinDeltaPt
Definition: L1TkMuMantra.h:117
PVValHelper::eta
Definition: PVValidationHelpers.h:70
L1TkMuMantra::L1TkMuMantra
L1TkMuMantra(const std::vector< double > &bounds, TFile *fIn_theta, TFile *fIn_phi, std::string name)
Definition: L1TkMuMantra.cc:10
L1TkMuMantra::test
void test(double eta, double pt)
Definition: L1TkMuMantra.cc:99
L1TkMuMantra::bounds_
std::vector< double > bounds_
Definition: L1TkMuMantra.h:105
L1TkMuMantra::safety_factor_h_
float safety_factor_h_
Definition: L1TkMuMantra.h:113
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
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
L1TkMuMantraDF::track_df::theta
double theta
Definition: L1TkMuMantra.h:17
L1TkMuMantra::findBin
int findBin(double val)
Definition: L1TkMuMantra.cc:82
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
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:117
L1TkMuMantraDF::muon_df
Definition: L1TkMuMantra.h:24
L1TkMuMantra::min_nstubs
int min_nstubs
Definition: L1TkMuMantra.h:109
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
L1TkMuMantra::to_mpio2_pio2
static double to_mpio2_pio2(double x)
Definition: L1TkMuMantra.h:90
L1TkMuMantra::nbins_
int nbins_
Definition: L1TkMuMantra.h:104
LaserClient_cfi.high
high
Definition: LaserClient_cfi.py:50
heppy_batch.val
val
Definition: heppy_batch.py:351
L1TkMuMantra::eta_to_theta
static double eta_to_theta(double x)
Definition: L1TkMuMantra.h:85
L1TkMuMantra::setArbitrationType
void setArbitrationType(std::string type)
Definition: L1TkMuMantra.cc:190
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:115
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
L1TkMuMantra::verbosity_
int verbosity_
Definition: L1TkMuMantra.h:122
L1TkMuMantra::~L1TkMuMantra
~L1TkMuMantra()
Definition: L1TkMuMantra.h:54
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
angle_units.h
L1TkMuMantra::name_
std::string name_
Definition: L1TkMuMantra.h:102
LaserClient_cfi.low
low
Definition: LaserClient_cfi.py:52
L1TkMuMantra
Definition: L1TkMuMantra.h:51
L1TkMuMantra::sign
int sign(double x)
Definition: L1TkMuMantra.h:73