Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-02 03:45:48

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuDTTrack
0004 //
0005 //   Description: Muon Track Candidate
0006 //
0007 //
0008 //
0009 //   Author :
0010 //   N. Neumeister            CERN EP
0011 //   J. Troconiz              UAM Madrid
0012 //
0013 //--------------------------------------------------
0014 
0015 //-----------------------
0016 // This Class's Header --
0017 //-----------------------
0018 
0019 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrack.h"
0020 
0021 //---------------
0022 // C++ Headers --
0023 //---------------
0024 
0025 #include <iostream>
0026 #include <iomanip>
0027 
0028 //-------------------------------
0029 // Collaborating Class Headers --
0030 //-------------------------------
0031 
0032 #include "L1Trigger/DTTrackFinder/interface/L1MuDTSecProcId.h"
0033 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrackSegPhi.h"
0034 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrackSegEta.h"
0035 #include "CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h"
0036 #include "CondFormats/DataRecord/interface/L1MuTriggerPtScaleRcd.h"
0037 #include "CondFormats/L1TObjects/interface/L1MuPacking.h"
0038 
0039 using namespace std;
0040 
0041 // --------------------------------
0042 //       class L1MuDTTrack
0043 //---------------------------------
0044 
0045 //----------------
0046 // Constructors --
0047 //----------------
0048 L1MuDTTrack::L1MuDTTrack()
0049     : L1MuRegionalCand(0, 0),
0050       m_spid(L1MuDTSecProcId()),
0051       m_name("L1MuDTTrack"),
0052       m_empty(true),
0053       m_tc(UNDEF),
0054       m_addArray(),
0055       m_tsphiList(),
0056       m_tsetaList() {
0057   m_tsphiList.reserve(4);
0058   m_tsetaList.reserve(3);
0059 
0060   setType(0);
0061   setChargeValid(true);
0062 }
0063 
0064 L1MuDTTrack::L1MuDTTrack(const L1MuDTSecProcId& spid)
0065     : L1MuRegionalCand(0, 0),
0066       m_spid(spid),
0067       m_name("L1MuDTTrack"),
0068       m_empty(true),
0069       m_tc(UNDEF),
0070       m_addArray(),
0071       m_tsphiList(),
0072       m_tsetaList() {
0073   m_tsphiList.reserve(4);
0074   m_tsetaList.reserve(3);
0075 
0076   setType(0);
0077   setChargeValid(true);
0078 }
0079 
0080 L1MuDTTrack::L1MuDTTrack(const L1MuDTTrack& id)
0081     : L1MuRegionalCand(id),
0082       m_spid(id.m_spid),
0083       m_name(id.m_name),
0084       m_empty(id.m_empty),
0085       m_tc(id.m_tc),
0086       m_addArray(id.m_addArray),
0087       m_tsphiList(id.m_tsphiList),
0088       m_tsetaList(id.m_tsetaList) {}
0089 
0090 //--------------
0091 // Destructor --
0092 //--------------
0093 L1MuDTTrack::~L1MuDTTrack() {}
0094 
0095 //--------------
0096 // Operations --
0097 //--------------
0098 
0099 //
0100 // reset Muon Track Candidate
0101 //
0102 void L1MuDTTrack::reset() {
0103   L1MuRegionalCand::reset();
0104   m_empty = true;
0105   m_tc = UNDEF;
0106   m_addArray.reset();
0107   m_tsphiList.clear();
0108   m_tsetaList.clear();
0109 }
0110 
0111 //
0112 // set (packed) eta-code of muon candidate
0113 //
0114 void L1MuDTTrack::setEta(int eta) {
0115   // eta is a signed integer [-32,31],
0116   // representing 64 bins in an interval [-1.2,+1.2]
0117   // first convert eta into an unsigned integer
0118   L1MuSignedPacking<6> pEta;
0119   setEtaPacked(pEta.packedFromIdx(eta));
0120 }
0121 
0122 //
0123 // return start phi track segment
0124 //
0125 const L1MuDTTrackSegPhi& L1MuDTTrack::getStartTSphi() const { return m_tsphiList.front(); }
0126 
0127 //
0128 // return end phi track segment
0129 //
0130 const L1MuDTTrackSegPhi& L1MuDTTrack::getEndTSphi() const { return m_tsphiList.back(); }
0131 
0132 //
0133 // return start eta track segment
0134 //
0135 const L1MuDTTrackSegEta& L1MuDTTrack::getStartTSeta() const { return m_tsetaList.front(); }
0136 
0137 //
0138 // return end eta track segment
0139 //
0140 const L1MuDTTrackSegEta& L1MuDTTrack::getEndTSeta() const { return m_tsetaList.back(); }
0141 
0142 //
0143 // set phi track segments used to form the muon candidate
0144 //
0145 void L1MuDTTrack::setTSphi(const vector<const L1MuDTTrackSegPhi*>& tsList) {
0146   if (!tsList.empty()) {
0147     vector<const L1MuDTTrackSegPhi*>::const_iterator iter;
0148     for (iter = tsList.begin(); iter != tsList.end(); iter++) {
0149       if (*iter)
0150         m_tsphiList.push_back(**iter);
0151     }
0152   }
0153 }
0154 
0155 //
0156 // set eta track segments used to form the muon candidate
0157 //
0158 void L1MuDTTrack::setTSeta(const vector<const L1MuDTTrackSegEta*>& tsList) {
0159   if (!tsList.empty()) {
0160     vector<const L1MuDTTrackSegEta*>::const_iterator iter;
0161     for (iter = tsList.begin(); iter != tsList.end(); iter++) {
0162       if (*iter)
0163         m_tsetaList.push_back(**iter);
0164     }
0165   }
0166 }
0167 
0168 //
0169 // convert pt value in GeV to pt code
0170 //
0171 unsigned int L1MuDTTrack::triggerScale(float value, const edm::EventSetup& c) const {
0172   const float eps = 1.e-5;  // add an epsilon so that setting works with low edge value
0173 
0174   edm::ESHandle<L1MuTriggerPtScale> theTriggerScales;
0175   c.get<L1MuTriggerPtScaleRcd>().get(theTriggerScales);
0176   unsigned int t_Scale = theTriggerScales->getPtScale()->getPacked(value + eps);
0177 
0178   return t_Scale;
0179 }
0180 
0181 //
0182 // Assignment operator
0183 //
0184 L1MuDTTrack& L1MuDTTrack::operator=(const L1MuDTTrack& track) {
0185   if (this != &track) {
0186     this->setBx(track.bx());
0187     this->setDataWord(track.getDataWord());
0188     m_spid = track.m_spid;
0189     m_empty = track.m_empty;
0190     m_name = track.m_name;
0191     m_tc = track.m_tc;
0192     m_addArray = track.m_addArray;
0193     m_tsphiList = track.m_tsphiList;
0194     m_tsetaList = track.m_tsetaList;
0195   }
0196   return *this;
0197 }
0198 
0199 //
0200 // Equal operator
0201 //
0202 bool L1MuDTTrack::operator==(const L1MuDTTrack& track) const {
0203   if (m_spid != track.m_spid)
0204     return false;
0205   if (m_empty != track.m_empty)
0206     return false;
0207   if (m_tc != track.m_tc)
0208     return false;
0209   if (bx() != track.bx())
0210     return false;
0211   if (phi() != track.phi())
0212     return false;
0213   if (eta() != track.eta())
0214     return false;
0215   if (fineEtaBit() != track.fineEtaBit())
0216     return false;
0217   if (pt() != track.pt())
0218     return false;
0219   if (charge() != track.charge())
0220     return false;
0221   if (quality() != track.quality())
0222     return false;
0223   if (m_addArray != track.m_addArray)
0224     return false;
0225   return true;
0226 }
0227 
0228 //
0229 // Unequal operator
0230 //
0231 bool L1MuDTTrack::operator!=(const L1MuDTTrack& track) const {
0232   if (m_spid != track.m_spid)
0233     return true;
0234   if (m_empty != track.m_empty)
0235     return true;
0236   if (m_tc != track.m_tc)
0237     return true;
0238   if (bx() != track.bx())
0239     return true;
0240   if (phi() != track.phi())
0241     return true;
0242   if (eta() != track.eta())
0243     return true;
0244   if (fineEtaBit() != track.fineEtaBit())
0245     return true;
0246   if (pt() != track.pt())
0247     return true;
0248   if (charge() != track.charge())
0249     return true;
0250   if (quality() != track.quality())
0251     return true;
0252   if (m_addArray != track.m_addArray)
0253     return true;
0254   return false;
0255 }
0256 
0257 //
0258 // print parameters of track candidate
0259 //
0260 void L1MuDTTrack::print() const {
0261   if (!empty()) {
0262     cout.setf(ios::showpoint);
0263     cout.setf(ios::right, ios::adjustfield);
0264     cout << setiosflags(ios::showpoint | ios::fixed);
0265     cout << "MUON : "
0266          << "pt = " << setw(2) << pt_packed() << "  "
0267          << "charge = " << setw(2) << charge_packed() << "  "
0268          << "eta = " << setw(2) << eta_packed() << " (" << setw(1) << finehalo_packed() << ")  "
0269          << "phi = " << setw(3) << phi_packed() << "  "
0270          << "quality = " << setw(1) << quality_packed() << '\t' << "class = " << tc() << "  "
0271          << "bx = " << setw(2) << bx() << endl;
0272     cout << "       found in " << m_spid << " with phi track segments :" << endl;
0273     vector<L1MuDTTrackSegPhi>::const_iterator iter;
0274     for (iter = m_tsphiList.begin(); iter != m_tsphiList.end(); iter++) {
0275       cout << "       " << (*iter) << endl;
0276     }
0277   }
0278 }
0279 
0280 //
0281 // output stream operator for track candidate
0282 //
0283 ostream& operator<<(ostream& s, const L1MuDTTrack& id) {
0284   if (!id.empty()) {
0285     s << setiosflags(ios::showpoint | ios::fixed) << "pt = " << setw(2) << id.pt_packed() << "  "
0286       << "charge = " << setw(2) << id.charge_packed() << "  "
0287       << "eta = " << setw(2) << id.eta_packed() << " (" << setw(1) << id.finehalo_packed() << ")  "
0288       << "phi = " << setw(3) << id.phi_packed() << "  "
0289       << "quality = " << setw(1) << id.quality_packed() << '\t' << "bx = " << setw(2) << id.bx();
0290   }
0291   return s;
0292 }