CMS 3D CMS Logo

Tauto3Mu.h
Go to the documentation of this file.
1 // ===========================================================================
2 //
3 // Filename: Tauto3Mu.h
4 //
5 // Description:
6 //
7 // Version: 1.0
8 // Created: 03/15/2021 07:33:59 PM
9 // Revision: none
10 // Compiler: g++
11 //
12 // Author: Zhenbin Wu, zhenbin.wu@gmail.com
13 //
14 // ===========================================================================
15 
16 #ifndef PHASE2GMT_TAUTO3MU
17 #define PHASE2GMT_TAUTO3MU
18 
19 #include "TopologicalAlgorithm.h"
21 
22 namespace Phase2L1GMT {
23  class Tauto3Mu : public TopoAlgo {
24  public:
25  Tauto3Mu(const edm::ParameterSet &iConfig);
26  ~Tauto3Mu();
27  Tauto3Mu(const Tauto3Mu &cpy);
28  // Interface function
29  bool GetTau3Mu(std::vector<l1t::TrackerMuon> &trkMus, std::vector<ConvertedTTTrack> &convertedTracks);
30 
31  private:
32  bool Find3MuComb(std::vector<l1t::TrackerMuon> &trkMus);
33 
34  bool FindCloset3Mu(std::vector<std::pair<int, unsigned int> > &mu_phis,
35  std::vector<std::pair<unsigned, unsigned> > &nearby3mu);
36 
37  int Get3MuDphi(unsigned target, unsigned obj1, unsigned obj2);
38 
39  int Get3MuMass(unsigned target, unsigned obj1, unsigned obj2);
40 
41  int GetDiMass(const l1t::TrackerMuon &mu1, const l1t::TrackerMuon &mu2);
42  };
43 
44  inline Tauto3Mu::Tauto3Mu(const edm::ParameterSet &iConfig) {}
45 
46  inline Tauto3Mu::~Tauto3Mu() {}
47 
48  inline Tauto3Mu::Tauto3Mu(const Tauto3Mu &cpy) : TopoAlgo(cpy) {}
49 
50  // === FUNCTION ============================================================
51  // Name: Tauto3Mu::GetTau3Mu
52  // Description:
53  // ===========================================================================
54  inline bool Tauto3Mu::GetTau3Mu(std::vector<l1t::TrackerMuon> &trkMus,
55  std::vector<ConvertedTTTrack> &convertedTracks) {
57  return true;
58  } // ----- end of function Tauto3Mu::GetTau3Mu -----
59 
60  // === FUNCTION ============================================================
61  // Name: Tauto3Mu::Find3MuComb
62  // Description:
63  // ===========================================================================
64  inline bool Tauto3Mu::Find3MuComb(std::vector<l1t::TrackerMuon> &trkMus) {
65  // vector< phi, index of trackerMuon >
66  std::vector<std::pair<int, unsigned int> > mu_phis;
67  for (unsigned i = 0; i < trkMus.size(); ++i) {
68  mu_phis.push_back(std::make_pair(trkMus.at(i).hwPhi(), i));
69  }
70 
71  std::sort(mu_phis.begin(), mu_phis.end());
72 
73  std::vector<std::pair<unsigned, unsigned> > nearby3mu;
74  std::vector<int> mu3mass;
75  FindCloset3Mu(mu_phis, nearby3mu);
76 
77  for (unsigned i = 0; i < trkMus.size(); ++i) {
78  int trimass = Get3MuMass(i, nearby3mu.at(i).first, nearby3mu.at(i).second);
79  mu3mass.push_back(trimass);
80  }
81 
82  return true;
83  } // ----- end of function Tauto3Mu::Find3MuComb -----
84 
85  // === FUNCTION ============================================================
86  // Name: Tauto3Mu::Get3MuMass
87  // Description:
88  // ===========================================================================
89  inline int Tauto3Mu::Get3MuMass(unsigned target, unsigned obj1, unsigned obj2) {
90  int mass12 = GetDiMass(trkMus->at(target), trkMus->at(obj1));
91  int mass23 = GetDiMass(trkMus->at(obj1), trkMus->at(obj2));
92  int mass31 = GetDiMass(trkMus->at(obj2), trkMus->at(target));
93 
94  return mass12 + mass23 + mass31;
95  } // ----- end of function Tauto3Mu::Get3MuMass -----
96 
97  // === FUNCTION ============================================================
98  // Name: Tauto3Mu::GetDiMass
99  // Description:
100  // ===========================================================================
101  inline int Tauto3Mu::GetDiMass(const l1t::TrackerMuon &mu1, const l1t::TrackerMuon &mu2) {
102  int deta = deltaEta(mu1.hwEta(), mu2.hwEta());
103  int dphi = deltaPhi(mu1.hwPhi(), mu2.hwPhi());
104  int mass = 2 * mu1.hwPt() * mu2.hwPt() * (cosh(deta) - cos(dphi));
105  return mass;
106  } // ----- end of function Tauto3Mu::GetDiMass -----
107 
108  // === FUNCTION ============================================================
109  // Name: Tauto3Mu::FindCloset3Mu
110  // Description:
111  // ===========================================================================
112  inline bool Tauto3Mu::FindCloset3Mu(std::vector<std::pair<int, unsigned int> > &mu_phis,
113  std::vector<std::pair<unsigned, unsigned> > &nearby3mu) {
114  nearby3mu.clear();
115 
116  std::vector<std::pair<int, unsigned int> > temp(mu_phis);
117 
118  // Round the last 2 to first element of vector
119  temp.insert(temp.begin(), mu_phis.back());
120  temp.insert(temp.begin(), *(mu_phis.rbegin() - 1));
121  // Append the first two element to vector
122  temp.push_back(mu_phis.front());
123  temp.push_back(*(mu_phis.begin() + 1));
124 
125  for (unsigned i = 2; i < temp.size() - 2; ++i) {
126  int combleft = Get3MuDphi(temp[i].second, temp[i - 1].second, temp[i - 2].second);
127  std::pair<unsigned, unsigned> neighbors(temp[i - 1].second, temp[i - 2].second);
128  int mincomb(combleft);
129 
130  int combcenter = Get3MuDphi(temp[i].second, temp[i - 1].second, temp[i + 1].second);
131  if (combcenter < mincomb) {
132  neighbors = std::make_pair(temp[i - 1].second, temp[i + 1].second);
133  mincomb = combcenter;
134  }
135 
136  int combright = Get3MuDphi(temp[i].second, temp[i + 1].second, temp[i + 2].second);
137  if (combright < mincomb) {
138  neighbors = std::make_pair(temp[i + 1].second, temp[i + 2].second);
139  }
140 
141  nearby3mu.push_back(neighbors);
142  }
143 
144  return true;
145  } // ----- end of function Tauto3Mu::FindCloset3Mu -----
146 
147  inline int Tauto3Mu::Get3MuDphi(unsigned target, unsigned obj1, unsigned obj2) {
148  int dPhi1 = deltaPhi(trkMus->at(target).hwPhi(), trkMus->at(obj1).hwPhi());
149  int dPhi2 = deltaPhi(trkMus->at(target).hwPhi(), trkMus->at(obj2).hwPhi());
150  return dPhi1 + dPhi2;
151  }
152 } // namespace Phase2L1GMT
153 
154 #endif // ----- #ifndef PHASE2GMT_TAUTO3MU -----
int hwPhi() const
Definition: L1Candidate.h:37
int GetDiMass(const l1t::TrackerMuon &mu1, const l1t::TrackerMuon &mu2)
Definition: Tauto3Mu.h:101
U second(std::pair< T, U > const &p)
int deltaEta(const int eta1, const int eta2)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tauto3Mu(const edm::ParameterSet &iConfig)
Definition: Tauto3Mu.h:44
int hwEta() const
Definition: L1Candidate.h:36
std::vector< ConvertedTTTrack > * convertedTracks
bool Find3MuComb(std::vector< l1t::TrackerMuon > &trkMus)
Definition: Tauto3Mu.h:64
int Get3MuMass(unsigned target, unsigned obj1, unsigned obj2)
Definition: Tauto3Mu.h:89
int hwPt() const
Definition: L1Candidate.h:35
int Get3MuDphi(unsigned target, unsigned obj1, unsigned obj2)
Definition: Tauto3Mu.h:147
bool GetTau3Mu(std::vector< l1t::TrackerMuon > &trkMus, std::vector< ConvertedTTTrack > &convertedTracks)
Definition: Tauto3Mu.h:54
std::vector< l1t::TrackerMuon > * trkMus
bool FindCloset3Mu(std::vector< std::pair< int, unsigned int > > &mu_phis, std::vector< std::pair< unsigned, unsigned > > &nearby3mu)
Definition: Tauto3Mu.h:112
int deltaPhi(int phi1, int phi2)