File indexing completed on 2022-10-14 01:44:05
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 }
0056
0057 void L1TStub::write(ofstream& out) {
0058 out << "Stub: " << DTClink_ << "\t" << region_ << "\t" << layerdisk_ << "\t" << stubword_ << "\t" << isPSmodule_
0059 << "\t" << isFlipped_ << "\t" << x_ << "\t" << y_ << "\t" << z_ << "\t" << bend_ << "\t" << strip_ << "\t"
0060 << "\t" << tps_.size() << " \t";
0061 for (int itp : tps_) {
0062 out << itp << " \t";
0063 }
0064 out << endl;
0065 }
0066
0067 bool L1TStub::operator==(const L1TStub& other) const {
0068 return (other.iphi() == iphi_ && other.iz() == iz_ && other.layer() == layer_ && other.detId() == detId_);
0069 }
0070
0071 void L1TStub::lorentzcor(double shift) {
0072 double r = this->r();
0073 double phi = this->phi() - shift / r;
0074 this->x_ = r * cos(phi);
0075 this->y_ = r * sin(phi);
0076 }
0077
0078 double L1TStub::alpha(double pitch) const {
0079 if (isPSmodule())
0080 return 0.0;
0081 int flip = 1;
0082 if (isFlipped())
0083 flip = -1;
0084 if (z_ > 0.0) {
0085 return ((int)strip_ - 509.5) * pitch * flip / r2();
0086 }
0087 return -((int)strip_ - 509.5) * pitch * flip / r2();
0088 }
0089
0090 double L1TStub::alphanorm() const {
0091 if (isPSmodule())
0092 return 0.0;
0093 int flip = 1;
0094 if (isFlipped())
0095 flip = -1;
0096 if (z_ > 0.0) {
0097 return ((int)strip_ - 509.5) * flip / 510.0;
0098 }
0099 return -((int)strip_ - 509.5) * flip / 510.0;
0100 }
0101
0102 void L1TStub::setXY(double x, double y) {
0103 x_ = x;
0104 y_ = y;
0105 }
0106
0107 bool L1TStub::tpmatch(int tp) const {
0108 for (int itp : tps_) {
0109 if (tp == std::abs(itp))
0110 return true;
0111 }
0112
0113 return false;
0114 }
0115
0116 bool L1TStub::tpmatch2(int tp) const {
0117 bool match1 = false;
0118 bool match2 = false;
0119 for (int itp : tps_) {
0120 if (tp == itp) {
0121 match1 = true;
0122 }
0123 if (tp == -itp) {
0124 match2 = true;
0125 }
0126 }
0127
0128 return match1 && match2;
0129 }