Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:11:14

0001 #include "L1Trigger/DTTriggerPhase2/interface/MuonPath.h"
0002 
0003 #include <cmath>
0004 #include <iostream>
0005 #include <memory>
0006 
0007 using namespace cmsdt;
0008 
0009 MuonPath::MuonPath() {
0010   quality_ = NOPATH;
0011   baseChannelId_ = -1;
0012 
0013   for (int i = 0; i < NUM_LAYERS_2SL; i++) {
0014     prim_.push_back(std::make_shared<DTPrimitive>());
0015   }
0016 
0017   nprimitives_ = NUM_LAYERS;
0018   bxTimeValue_ = -1;
0019   bxNumId_ = -1;
0020   tanPhi_ = 0;
0021   horizPos_ = 0;
0022   chiSquare_ = 0;
0023   for (int i = 0; i < NUM_LAYERS; i++) {
0024     lateralComb_[i] = LEFT;
0025     setXCoorCell(0, i);
0026     setDriftDistance(0, i);
0027   }
0028 }
0029 
0030 MuonPath::MuonPath(DTPrimitivePtrs &ptrPrimitive, int nprimUp, int nprimDown) {
0031   if (nprimUp > 0 || nprimDown > 0)
0032     nprimitives_ = NUM_LAYERS_2SL;  //Instead of nprimUp + nprimDown;

0033   else {
0034     nprimitives_ = NUM_LAYERS;
0035   }
0036   nprimitivesUp_ = nprimUp;
0037   nprimitivesDown_ = nprimDown;
0038   rawId_ = 0;
0039   quality_ = NOPATH;
0040   baseChannelId_ = -1;
0041   bxTimeValue_ = -1;
0042   bxNumId_ = -1;
0043   tanPhi_ = 0;
0044   horizPos_ = 0;
0045   chiSquare_ = 0;
0046   phi_ = 0;
0047   phiB_ = 0;
0048   phicmssw_ = 0;
0049   phiBcmssw_ = 0;
0050 
0051   for (short i = 0; i < nprimitives_; i++) {
0052     lateralComb_[i] = LEFT;
0053     prim_.push_back(std::make_shared<DTPrimitive>(ptrPrimitive[i]));
0054 
0055     setXCoorCell(0, i);
0056     setDriftDistance(0, i);
0057     setXWirePos(0, i);
0058     setZWirePos(0, i);
0059     setTWireTDC(0, i);
0060   }
0061 }
0062 
0063 MuonPath::MuonPath(DTPrimitives &ptrPrimitive, int nprimUp, int nprimDown) {
0064   if (nprimUp > 0 || nprimDown > 0)
0065     nprimitives_ = NUM_LAYERS_2SL;  //Instead of nprimUp + nprimDown;

0066   else {
0067     nprimitives_ = NUM_LAYERS;
0068   }
0069   nprimitivesUp_ = nprimUp;
0070   nprimitivesDown_ = nprimDown;
0071   rawId_ = 0;
0072   quality_ = NOPATH;
0073   baseChannelId_ = -1;
0074   bxTimeValue_ = -1;
0075   bxNumId_ = -1;
0076   tanPhi_ = 0;
0077   horizPos_ = 0;
0078   chiSquare_ = 0;
0079   phi_ = 0;
0080   phiB_ = 0;
0081   phicmssw_ = 0;
0082   phiBcmssw_ = 0;
0083 
0084   for (short i = 0; i < nprimitives_; i++) {
0085     lateralComb_[i] = LEFT;
0086     prim_.push_back(std::make_shared<DTPrimitive>(ptrPrimitive[i]));
0087 
0088     setXCoorCell(0, i);
0089     setDriftDistance(0, i);
0090     setXWirePos(0, i);
0091     setZWirePos(0, i);
0092     setTWireTDC(0, i);
0093   }
0094 }
0095 
0096 MuonPath::MuonPath(MuonPathPtr &ptr) {
0097   setRawId(ptr->rawId());
0098   setPhi(ptr->phi());
0099   setPhiB(ptr->phiB());
0100   setPhiCMSSW(ptr->phi_cmssw());
0101   setPhiBCMSSW(ptr->phiB_cmssw());
0102   setQuality(ptr->quality());
0103   setBaseChannelId(ptr->baseChannelId());
0104   setCellHorizontalLayout(ptr->cellLayout());
0105   setNPrimitives(ptr->nprimitives());
0106 
0107   setLateralComb(ptr->lateralComb());
0108   setBxTimeValue(ptr->bxTimeValue());
0109   setTanPhi(ptr->tanPhi());
0110   setHorizPos(ptr->horizPos());
0111   setChiSquare(ptr->chiSquare());
0112 
0113   for (int i = 0; i < ptr->nprimitives(); i++) {
0114     prim_.push_back(ptr->primitive(i));
0115 
0116     setXCoorCell(ptr->xCoorCell(i), i);
0117     setDriftDistance(ptr->xDriftDistance(i), i);
0118     setXWirePos(ptr->xWirePos(i), i);
0119     setZWirePos(ptr->zWirePos(i), i);
0120     setTWireTDC(ptr->tWireTDC(i), i);
0121   }
0122 }
0123 
0124 //------------------------------------------------------------------

0125 //--- Public

0126 //------------------------------------------------------------------

0127 void MuonPath::setPrimitive(DTPrimitivePtr &ptr, int layer) { prim_[layer] = std::move(ptr); }
0128 
0129 void MuonPath::setCellHorizontalLayout(int layout[4]) {
0130   for (int i = 0; i < NUM_LAYERS; i++)
0131     cellLayout_[i] = layout[i];
0132 }
0133 
0134 void MuonPath::setCellHorizontalLayout(const int *layout) {
0135   for (int i = 0; i < NUM_LAYERS; i++)
0136     cellLayout_[i] = layout[i];
0137 }
0138 
0139 bool MuonPath::isEqualTo(MuonPath *ptr) {
0140   for (int i = 0; i < ptr->nprimitives(); i++) {
0141     if (this->primitive(i)->isValidTime() && ptr->primitive(i)->isValidTime()) {
0142       if (ptr->primitive(i)->superLayerId() != this->primitive(i)->superLayerId() ||
0143 
0144           ptr->primitive(i)->channelId() != this->primitive(i)->channelId() ||
0145 
0146           ptr->primitive(i)->tdcTimeStamp() != this->primitive(i)->tdcTimeStamp() ||
0147 
0148           ptr->primitive(i)->orbit() != this->primitive(i)->orbit() ||
0149           (ptr->lateralComb())[i] != (this->lateralComb())[i])
0150         return false;
0151     } else {
0152       if (!this->primitive(i)->isValidTime() && !ptr->primitive(i)->isValidTime())
0153         continue;
0154 
0155       else
0156         return false;
0157     }
0158   }
0159 
0160   return true;
0161 }
0162 
0163 bool MuonPath::isAnalyzable() {
0164   short countValidHits = 0;
0165   for (int i = 0; i < this->nprimitives(); i++) {
0166     //    if (!this->primitive(i))

0167     //      continue;

0168     if (this->primitive(i)->isValidTime())
0169       countValidHits++;
0170   }
0171 
0172   if (countValidHits >= 3)
0173     return true;
0174   return false;
0175 }
0176 
0177 bool MuonPath::completeMP() {
0178   return (prim_[0]->isValidTime() && prim_[1]->isValidTime() && prim_[2]->isValidTime() && prim_[3]->isValidTime());
0179 }
0180 
0181 void MuonPath::setBxTimeValue(int time) {
0182   bxTimeValue_ = time;
0183 
0184   float auxBxId = float(time) / LHC_CLK_FREQ;
0185   bxNumId_ = int(auxBxId);
0186   if ((auxBxId - int(auxBxId)) >= 0.5)
0187     bxNumId_ = int(bxNumId_ + 1);
0188 }
0189 
0190 void MuonPath::setLateralCombFromPrimitives() {
0191   for (int i = 0; i < nprimitives_; i++) {
0192     if (!this->primitive(i)->isValidTime())
0193       continue;
0194     lateralComb_[i] = this->primitive(i)->laterality();
0195   }
0196 }
0197 
0198 void MuonPath::setLateralComb(LATERAL_CASES latComb[4]) {
0199   for (int i = 0; i < NUM_LAYERS; i++)
0200     lateralComb_[i] = latComb[i];
0201 }
0202 
0203 void MuonPath::setLateralComb(const LATERAL_CASES *latComb) {
0204   for (int i = 0; i < NUM_LAYERS; i++)
0205     lateralComb_[i] = latComb[i];
0206 }