File indexing completed on 2022-10-14 01:44:07
0001 #include "L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003
0004 using namespace std;
0005 using namespace trklet;
0006
0007 void SLHCEvent::addL1SimTrack(
0008 int eventid, int trackid, int type, double pt, double eta, double phi, double vx, double vy, double vz) {
0009 L1SimTrack simtrack(eventid, trackid, type, pt, eta, phi, vx, vy, vz);
0010 simtracks_.push_back(simtrack);
0011 }
0012
0013 bool SLHCEvent::addStub(string DTClink,
0014 int region,
0015 int layerdisk,
0016 string stubword,
0017 int isPSmodule,
0018 int isFlipped,
0019 bool tiltedBarrel,
0020 unsigned int tiltedRingId,
0021 unsigned int endcapRingId,
0022 unsigned int detId,
0023 double x,
0024 double y,
0025 double z,
0026 double bend,
0027 double strip,
0028 vector<int> tps) {
0029 L1TStub stub(DTClink,
0030 region,
0031 layerdisk,
0032 stubword,
0033 isPSmodule,
0034 isFlipped,
0035 tiltedBarrel,
0036 tiltedRingId,
0037 endcapRingId,
0038 detId,
0039 x,
0040 y,
0041 z,
0042 bend,
0043 strip,
0044 tps);
0045
0046 stubs_.push_back(stub);
0047 return true;
0048 }
0049
0050 SLHCEvent::SLHCEvent(istream& in) {
0051 string tmp;
0052 in >> tmp;
0053 if (tmp != "Event:") {
0054 edm::LogVerbatim("Tracklet") << "Expected to read 'Event:' but found:" << tmp;
0055 if (tmp.empty()) {
0056 edm::LogVerbatim("Tracklet") << "WARNING: fewer events to process than specified!";
0057 return;
0058 } else {
0059 edm::LogVerbatim("Tracklet") << "ERROR, aborting reading file";
0060 abort();
0061 }
0062 }
0063 in >> eventnum_;
0064
0065
0066 in >> tmp;
0067 while (tmp != "SimTrackEnd") {
0068 if (!(tmp == "SimTrack:" || tmp == "SimTrackEnd")) {
0069 edm::LogVerbatim("Tracklet") << "Expected to read 'SimTrack:' or 'SimTrackEnd' but found:" << tmp;
0070 abort();
0071 }
0072 int eventid;
0073 int trackid;
0074 int type;
0075 double pt;
0076 double eta;
0077 double phi;
0078 double vx;
0079 double vy;
0080 double vz;
0081 in >> eventid >> trackid >> type >> pt >> eta >> phi >> vx >> vy >> vz;
0082 L1SimTrack simtrack(eventid, trackid, type, pt, eta, phi, vx, vy, vz);
0083 simtracks_.push_back(simtrack);
0084 in >> tmp;
0085 }
0086
0087
0088 in >> tmp;
0089 while (tmp != "Stubend") {
0090 if (!in.good()) {
0091 edm::LogVerbatim("Tracklet") << "File not good (SLHCEvent)";
0092 abort();
0093 };
0094 if (!(tmp == "Stub:" || tmp == "Stubend")) {
0095 edm::LogVerbatim("Tracklet") << "Expected to read 'Stub:' or 'StubEnd' but found:" << tmp;
0096 abort();
0097 }
0098 string DTClink;
0099 int region;
0100 int layerdisk;
0101 string stubword;
0102 int isPSmodule;
0103 int isFlipped;
0104 double x;
0105 double y;
0106 double z;
0107 double bend;
0108 double strip;
0109 unsigned int ntps;
0110 vector<int> tps;
0111
0112 in >> DTClink >> region >> layerdisk >> stubword >> isPSmodule >> isFlipped >> x >> y >> z >> bend >> strip >> ntps;
0113
0114
0115 bool tiltedBarrel = false;
0116 unsigned int tiltedRingId = 999999;
0117 unsigned int endcapRingId = 999999;
0118 unsigned int detId = 999999;
0119
0120 for (unsigned int itps = 0; itps < ntps; itps++) {
0121 int tp;
0122 in >> tp;
0123 tps.push_back(tp);
0124 }
0125
0126 L1TStub stub(DTClink,
0127 region,
0128 layerdisk,
0129 stubword,
0130 isPSmodule,
0131 isFlipped,
0132 tiltedBarrel,
0133 tiltedRingId,
0134 endcapRingId,
0135 detId,
0136 x,
0137 y,
0138 z,
0139 bend,
0140 strip,
0141 tps);
0142
0143 in >> tmp;
0144
0145 double t = std::abs(stub.z()) / stub.r();
0146 double eta = asinh(t);
0147
0148 if (std::abs(eta) < 2.6) {
0149 stubs_.push_back(stub);
0150 }
0151 }
0152 }
0153
0154 void SLHCEvent::write(ofstream& out) {
0155 out << "Event: " << eventnum_ << endl;
0156
0157 for (auto& simtrack : simtracks_) {
0158 simtrack.write(out);
0159 }
0160 out << "SimTrackEnd" << endl;
0161
0162 for (auto& stub : stubs_) {
0163 stub.write(out);
0164 }
0165 out << "Stubend" << endl;
0166 }
0167
0168 unsigned int SLHCEvent::layersHit(int tpid, int& nlayers, int& ndisks) {
0169 int l1 = 0;
0170 int l2 = 0;
0171 int l3 = 0;
0172 int l4 = 0;
0173 int l5 = 0;
0174 int l6 = 0;
0175
0176 int d1 = 0;
0177 int d2 = 0;
0178 int d3 = 0;
0179 int d4 = 0;
0180 int d5 = 0;
0181
0182 for (auto& stub : stubs_) {
0183 if (stub.tpmatch(tpid)) {
0184 if (stub.layer() == 0)
0185 l1 = 1;
0186 if (stub.layer() == 1)
0187 l2 = 1;
0188 if (stub.layer() == 2)
0189 l3 = 1;
0190 if (stub.layer() == 3)
0191 l4 = 1;
0192 if (stub.layer() == 4)
0193 l5 = 1;
0194 if (stub.layer() == 5)
0195 l6 = 1;
0196
0197 if (abs(stub.disk()) == 1)
0198 d1 = 1;
0199 if (abs(stub.disk()) == 2)
0200 d2 = 1;
0201 if (abs(stub.disk()) == 3)
0202 d3 = 1;
0203 if (abs(stub.disk()) == 4)
0204 d4 = 1;
0205 if (abs(stub.disk()) == 5)
0206 d5 = 1;
0207 }
0208 }
0209
0210 nlayers = l1 + l2 + l3 + l4 + l5 + l6;
0211 ndisks = d1 + d2 + d3 + d4 + d5;
0212
0213 return l1 + 2 * l2 + 4 * l3 + 8 * l4 + 16 * l5 + 32 * l6 + 64 * d1 + 128 * d2 + 256 * d3 + 512 * d4 + 1024 * d5;
0214 }