File indexing completed on 2024-04-06 12:22:00
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 bool tiltedBarrel,
0015 unsigned int tiltedRingId,
0016 unsigned int endcapRingId,
0017 unsigned int detId,
0018 double x,
0019 double y,
0020 double z,
0021 double bend,
0022 double strip,
0023 std::vector<int> tps) {
0024 DTClink_ = DTClink;
0025 layerdisk_ = layerdisk;
0026 region_ = region;
0027 stubword_ = stubword;
0028 eventid_ = -1;
0029 tps_ = tps;
0030 iphi_ = -1;
0031 iz_ = -1;
0032 layer_ = layerdisk;
0033 if (layerdisk >= N_LAYER) {
0034 layer_ = 1000 + layerdisk - N_LAYER + 1;
0035 if (z < 0.0)
0036 layer_ += 1000;
0037 }
0038
0039 strip_ = strip;
0040 x_ = x;
0041 y_ = y;
0042 z_ = z;
0043 sigmax_ = -1.0;
0044 sigmaz_ = -1.0;
0045 pt_ = -1.0;
0046 bend_ = bend;
0047 isPSmodule_ = isPSmodule;
0048 isFlipped_ = isFlipped;
0049 tiltedBarrel_ = tiltedBarrel;
0050 tiltedRingId_ = tiltedRingId;
0051 endcapRingId_ = endcapRingId;
0052 detId_ = detId;
0053
0054 allstubindex_ = 999;
0055 uniqueindex_ = 99999;
0056 }
0057
0058 void L1TStub::write(ofstream& out) {
0059 out << "Stub: " << DTClink_ << "\t" << region_ << "\t" << layerdisk_ << "\t" << stubword_ << "\t" << isPSmodule_
0060 << "\t" << isFlipped_ << "\t" << x_ << "\t" << y_ << "\t" << z_ << "\t" << bend_ << "\t" << strip_ << "\t"
0061 << "\t" << tps_.size() << " \t";
0062 for (int itp : tps_) {
0063 out << itp << " \t";
0064 }
0065 out << endl;
0066 }
0067
0068 bool L1TStub::operator==(const L1TStub& other) const {
0069 return (other.iphi() == iphi_ && other.iz() == iz_ && other.layer() == layer_ && other.detId() == detId_);
0070 }
0071
0072 void L1TStub::lorentzcor(double shift) {
0073 double r = this->r();
0074 double phi = this->phi() - shift / r;
0075 this->x_ = r * cos(phi);
0076 this->y_ = r * sin(phi);
0077 }
0078
0079 double L1TStub::alpha(double pitch) const {
0080 if (isPSmodule())
0081 return 0.0;
0082 int flip = 1;
0083 if (isFlipped())
0084 flip = -1;
0085 if (z_ > 0.0) {
0086 return ((int)strip_ - 509.5) * pitch * flip / r2();
0087 }
0088 return -((int)strip_ - 509.5) * pitch * flip / r2();
0089 }
0090
0091 double L1TStub::alphanorm() const {
0092 if (isPSmodule())
0093 return 0.0;
0094 int flip = 1;
0095 if (isFlipped())
0096 flip = -1;
0097 if (z_ > 0.0) {
0098 return ((int)strip_ - 509.5) * flip / 510.0;
0099 }
0100 return -((int)strip_ - 509.5) * flip / 510.0;
0101 }
0102
0103 void L1TStub::setXY(double x, double y) {
0104 x_ = x;
0105 y_ = y;
0106 }
0107
0108 bool L1TStub::tpmatch(int tp) const {
0109 for (int itp : tps_) {
0110 if (tp == std::abs(itp))
0111 return true;
0112 }
0113
0114 return false;
0115 }
0116
0117 bool L1TStub::tpmatch2(int tp) const {
0118 bool match1 = false;
0119 bool match2 = false;
0120 for (int itp : tps_) {
0121 if (tp == itp) {
0122 match1 = true;
0123 }
0124 if (tp == -itp) {
0125 match2 = true;
0126 }
0127 }
0128
0129 return match1 && match2;
0130 }