Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-07 22:33:32

0001 #include "L1Trigger/TrackFindingTracklet/interface/L1TStub.h"
0002 
0003 using namespace std;
0004 using namespace trklet;
0005 
0006 L1TStub::L1TStub() {}
0007 
0008 L1TStub::L1TStub(std::string DTClink,
0009                  int region,
0010                  int layerdisk,
0011                  std::string stubword,
0012                  int isPSmodule,
0013                  int isFlipped,
0014                  double x,
0015                  double y,
0016                  double z,
0017                  double bend,
0018                  double strip,
0019                  std::vector<int> tps) {
0020   DTClink_ = DTClink;
0021   layerdisk_ = layerdisk;
0022   region_ = region;
0023   stubword_ = stubword;
0024   eventid_ = -1;
0025   tps_ = tps;
0026   iphi_ = -1;
0027   iz_ = -1;
0028   layer_ = layerdisk;
0029   if (layerdisk >= N_LAYER) {
0030     layer_ = 1000 + layerdisk - N_LAYER + 1;
0031     if (z < 0.0)
0032       layer_ += 1000;
0033   }
0034 
0035   ladder_ = -1;
0036   module_ = -1;
0037   strip_ = strip;
0038   x_ = x;
0039   y_ = y;
0040   z_ = z;
0041   sigmax_ = -1.0;
0042   sigmaz_ = -1.0;
0043   pt_ = -1.0;
0044   bend_ = bend;
0045   isPSmodule_ = isPSmodule;
0046   isFlipped_ = isFlipped;
0047 
0048   allstubindex_ = 999;
0049 }
0050 
0051 void L1TStub::write(ofstream& out) {
0052   out << "Stub: " << DTClink_ << "\t" << region_ << "\t" << layerdisk_ << "\t" << stubword_ << "\t" << isPSmodule_
0053       << "\t" << isFlipped_ << "\t" << x_ << "\t" << y_ << "\t" << z_ << "\t" << bend_ << "\t" << strip_ << "\t"
0054       << "\t" << tps_.size() << " \t";
0055   for (int itp : tps_) {
0056     out << itp << " \t";
0057   }
0058   out << endl;
0059 }
0060 
0061 bool L1TStub::operator==(const L1TStub& other) const {
0062   return (other.iphi() == iphi_ && other.iz() == iz_ && other.layer() == layer_ && other.ladder() == ladder_ &&
0063           other.module() == module_);
0064 }
0065 
0066 void L1TStub::lorentzcor(double shift) {
0067   double r = this->r();
0068   double phi = this->phi() - shift / r;
0069   this->x_ = r * cos(phi);
0070   this->y_ = r * sin(phi);
0071 }
0072 
0073 double L1TStub::alpha(double pitch) const {
0074   if (isPSmodule())
0075     return 0.0;
0076   int flip = 1;
0077   if (isFlipped())
0078     flip = -1;
0079   if (z_ > 0.0) {
0080     return ((int)strip_ - 509.5) * pitch * flip / r2();
0081   }
0082   return -((int)strip_ - 509.5) * pitch * flip / r2();
0083 }
0084 
0085 double L1TStub::alphanorm() const {
0086   if (isPSmodule())
0087     return 0.0;
0088   int flip = 1;
0089   if (isFlipped())
0090     flip = -1;
0091   if (z_ > 0.0) {
0092     return ((int)strip_ - 509.5) * flip / 510.0;
0093   }
0094   return -((int)strip_ - 509.5) * flip / 510.0;
0095 }
0096 
0097 void L1TStub::setXY(double x, double y) {
0098   x_ = x;
0099   y_ = y;
0100 }
0101 
0102 bool L1TStub::tpmatch(int tp) const {
0103   for (int itp : tps_) {
0104     if (tp == std::abs(itp))
0105       return true;
0106   }
0107 
0108   return false;
0109 }
0110 
0111 bool L1TStub::tpmatch2(int tp) const {
0112   bool match1 = false;
0113   bool match2 = false;
0114   for (int itp : tps_) {
0115     if (tp == itp) {
0116       match1 = true;
0117     }
0118     if (tp == -itp) {
0119       match2 = true;
0120     }
0121   }
0122 
0123   return match1 && match2;
0124 }
0125 
0126 bool L1TStub::isTilted() const {
0127   //here layer_ runs 0-5 for barrel, >1000 for disk
0128   //disk modules and outer barrel modules are not tilted by construction
0129   if (layer_ >= N_PSLAYER)
0130     return false;
0131 
0132   assert(layer_ < N_PSLAYER);  // safety for acccessing # modules/plank
0133   if ((module_ <= N_TILTED_RINGS) || (module_ >= N_TILTED_RINGS + N_MOD_PLANK.at(layer_)))
0134     return true;
0135   return false;
0136 }