Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-01 23:54:07

0001 // ===========================================================================
0002 //
0003 //       Filename:  Tauto3Mu.h
0004 //
0005 //    Description:
0006 //
0007 //        Version:  1.0
0008 //        Created:  03/15/2021 07:33:59 PM
0009 //       Revision:  none
0010 //       Compiler:  g++
0011 //
0012 //         Author:  Zhenbin Wu, zhenbin.wu@gmail.com
0013 //
0014 // ===========================================================================
0015 
0016 #ifndef PHASE2GMT_TAUTO3MU
0017 #define PHASE2GMT_TAUTO3MU
0018 
0019 #include "L1Trigger/Phase2L1GMT/interface/TopologicalAlgorithm.h"
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 
0022 namespace Phase2L1GMT {
0023   class Tauto3Mu : public TopoAlgo {
0024   public:
0025     Tauto3Mu(const edm::ParameterSet &iConfig);
0026     ~Tauto3Mu();
0027     Tauto3Mu(const Tauto3Mu &cpy);
0028     // Interface function
0029     bool GetTau3Mu(std::vector<l1t::TrackerMuon> &trkMus, std::vector<ConvertedTTTrack> &convertedTracks);
0030 
0031   private:
0032     bool Find3MuComb(std::vector<l1t::TrackerMuon> &trkMus);
0033 
0034     bool FindCloset3Mu(std::vector<std::pair<int, unsigned int> > &mu_phis,
0035                        std::vector<std::pair<unsigned, unsigned> > &nearby3mu);
0036 
0037     int Get3MuDphi(unsigned target, unsigned obj1, unsigned obj2);
0038 
0039     int Get3MuMass(unsigned target, unsigned obj1, unsigned obj2);
0040 
0041     int GetDiMass(const l1t::TrackerMuon &mu1, const l1t::TrackerMuon &mu2);
0042   };
0043 
0044   inline Tauto3Mu::Tauto3Mu(const edm::ParameterSet &iConfig) {}
0045 
0046   inline Tauto3Mu::~Tauto3Mu() {}
0047 
0048   inline Tauto3Mu::Tauto3Mu(const Tauto3Mu &cpy) : TopoAlgo(cpy) {}
0049 
0050   // ===  FUNCTION  ============================================================
0051   //         Name:  Tauto3Mu::GetTau3Mu
0052   //  Description:
0053   // ===========================================================================
0054   inline bool Tauto3Mu::GetTau3Mu(std::vector<l1t::TrackerMuon> &trkMus,
0055                                   std::vector<ConvertedTTTrack> &convertedTracks) {
0056     Find3MuComb(trkMus);
0057     return true;
0058   }  // -----  end of function Tauto3Mu::GetTau3Mu  -----
0059 
0060   // ===  FUNCTION  ============================================================
0061   //         Name:  Tauto3Mu::Find3MuComb
0062   //  Description:
0063   // ===========================================================================
0064   inline bool Tauto3Mu::Find3MuComb(std::vector<l1t::TrackerMuon> &trkMus) {
0065     // vector< phi, index of trackerMuon >
0066     std::vector<std::pair<int, unsigned int> > mu_phis;
0067     for (unsigned i = 0; i < trkMus.size(); ++i) {
0068       mu_phis.push_back(std::make_pair(trkMus.at(i).hwPhi(), i));
0069     }
0070 
0071     std::sort(mu_phis.begin(), mu_phis.end());
0072 
0073     std::vector<std::pair<unsigned, unsigned> > nearby3mu;
0074     std::vector<int> mu3mass;
0075     FindCloset3Mu(mu_phis, nearby3mu);
0076 
0077     for (unsigned i = 0; i < trkMus.size(); ++i) {
0078       int trimass = Get3MuMass(i, nearby3mu.at(i).first, nearby3mu.at(i).second);
0079       mu3mass.push_back(trimass);
0080     }
0081 
0082     return true;
0083   }  // -----  end of function Tauto3Mu::Find3MuComb  -----
0084 
0085   // ===  FUNCTION  ============================================================
0086   //         Name:  Tauto3Mu::Get3MuMass
0087   //  Description:
0088   // ===========================================================================
0089   inline int Tauto3Mu::Get3MuMass(unsigned target, unsigned obj1, unsigned obj2) {
0090     int mass12 = GetDiMass(trkMus->at(target), trkMus->at(obj1));
0091     int mass23 = GetDiMass(trkMus->at(obj1), trkMus->at(obj2));
0092     int mass31 = GetDiMass(trkMus->at(obj2), trkMus->at(target));
0093 
0094     return mass12 + mass23 + mass31;
0095   }  // -----  end of function Tauto3Mu::Get3MuMass  -----
0096 
0097   // ===  FUNCTION  ============================================================
0098   //         Name:  Tauto3Mu::GetDiMass
0099   //  Description:
0100   // ===========================================================================
0101   inline int Tauto3Mu::GetDiMass(const l1t::TrackerMuon &mu1, const l1t::TrackerMuon &mu2) {
0102     int deta = deltaEta(mu1.hwEta(), mu2.hwEta());
0103     int dphi = deltaPhi(mu1.hwPhi(), mu2.hwPhi());
0104     int mass = 2 * mu1.hwPt() * mu2.hwPt() * (cosh(deta) - cos(dphi));
0105     return mass;
0106   }  // -----  end of function Tauto3Mu::GetDiMass  -----
0107 
0108   // ===  FUNCTION  ============================================================
0109   //         Name:  Tauto3Mu::FindCloset3Mu
0110   //  Description:
0111   // ===========================================================================
0112   inline bool Tauto3Mu::FindCloset3Mu(std::vector<std::pair<int, unsigned int> > &mu_phis,
0113                                       std::vector<std::pair<unsigned, unsigned> > &nearby3mu) {
0114     nearby3mu.clear();
0115 
0116     std::vector<std::pair<int, unsigned int> > temp(mu_phis);
0117 
0118     // Round the last 2 to first element of vector
0119     temp.insert(temp.begin(), mu_phis.back());
0120     temp.insert(temp.begin(), *(mu_phis.rbegin() - 1));
0121     // Append the first two element to vector
0122     temp.push_back(mu_phis.front());
0123     temp.push_back(*(mu_phis.begin() + 1));
0124 
0125     for (unsigned i = 2; i < temp.size() - 2; ++i) {
0126       int combleft = Get3MuDphi(temp[i].second, temp[i - 1].second, temp[i - 2].second);
0127       std::pair<unsigned, unsigned> neighbors(temp[i - 1].second, temp[i - 2].second);
0128       int mincomb(combleft);
0129 
0130       int combcenter = Get3MuDphi(temp[i].second, temp[i - 1].second, temp[i + 1].second);
0131       if (combcenter < mincomb) {
0132         neighbors = std::make_pair(temp[i - 1].second, temp[i + 1].second);
0133         mincomb = combcenter;
0134       }
0135 
0136       int combright = Get3MuDphi(temp[i].second, temp[i + 1].second, temp[i + 2].second);
0137       if (combright < mincomb) {
0138         neighbors = std::make_pair(temp[i + 1].second, temp[i + 2].second);
0139       }
0140 
0141       nearby3mu.push_back(neighbors);
0142     }
0143 
0144     return true;
0145   }  // -----  end of function Tauto3Mu::FindCloset3Mu  -----
0146 
0147   inline int Tauto3Mu::Get3MuDphi(unsigned target, unsigned obj1, unsigned obj2) {
0148     int dPhi1 = deltaPhi(trkMus->at(target).hwPhi(), trkMus->at(obj1).hwPhi());
0149     int dPhi2 = deltaPhi(trkMus->at(target).hwPhi(), trkMus->at(obj2).hwPhi());
0150     return dPhi1 + dPhi2;
0151   }
0152 }  // namespace Phase2L1GMT
0153 
0154 #endif  // ----- #ifndef PHASE2GMT_TAUTO3MU -----