Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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                         double x,
0020                         double y,
0021                         double z,
0022                         double bend,
0023                         double strip,
0024                         vector<int> tps) {
0025   L1TStub stub(DTClink, region, layerdisk, stubword, isPSmodule, isFlipped, x, y, z, bend, strip, tps);
0026 
0027   stubs_.push_back(stub);
0028   return true;
0029 }
0030 
0031 SLHCEvent::SLHCEvent(istream& in) {
0032   string tmp;
0033   in >> tmp;
0034   if (tmp != "Event:") {
0035     edm::LogVerbatim("Tracklet") << "Expected to read 'Event:' but found:" << tmp;
0036     if (tmp.empty()) {
0037       edm::LogVerbatim("Tracklet") << "WARNING: fewer events to process than specified!";
0038       return;
0039     } else {
0040       edm::LogVerbatim("Tracklet") << "ERROR, aborting reading file";
0041       abort();
0042     }
0043   }
0044   in >> eventnum_;
0045 
0046   // read the SimTracks
0047   in >> tmp;
0048   while (tmp != "SimTrackEnd") {
0049     if (!(tmp == "SimTrack:" || tmp == "SimTrackEnd")) {
0050       edm::LogVerbatim("Tracklet") << "Expected to read 'SimTrack:' or 'SimTrackEnd' but found:" << tmp;
0051       abort();
0052     }
0053     int eventid;
0054     int trackid;
0055     int type;
0056     double pt;
0057     double eta;
0058     double phi;
0059     double vx;
0060     double vy;
0061     double vz;
0062     in >> eventid >> trackid >> type >> pt >> eta >> phi >> vx >> vy >> vz;
0063     L1SimTrack simtrack(eventid, trackid, type, pt, eta, phi, vx, vy, vz);
0064     simtracks_.push_back(simtrack);
0065     in >> tmp;
0066   }
0067 
0068   //read stubs
0069   in >> tmp;
0070   while (tmp != "Stubend") {
0071     if (!in.good()) {
0072       edm::LogVerbatim("Tracklet") << "File not good (SLHCEvent)";
0073       abort();
0074     };
0075     if (!(tmp == "Stub:" || tmp == "Stubend")) {
0076       edm::LogVerbatim("Tracklet") << "Expected to read 'Stub:' or 'StubEnd' but found:" << tmp;
0077       abort();
0078     }
0079     string DTClink;
0080     int region;
0081     int layerdisk;
0082     string stubword;
0083     int isPSmodule;
0084     int isFlipped;
0085     double x;
0086     double y;
0087     double z;
0088     double bend;
0089     double strip;
0090     unsigned int ntps;
0091     vector<int> tps;
0092 
0093     in >> DTClink >> region >> layerdisk >> stubword >> isPSmodule >> isFlipped >> x >> y >> z >> bend >> strip >> ntps;
0094 
0095     for (unsigned int itps = 0; itps < ntps; itps++) {
0096       int tp;
0097       in >> tp;
0098       tps.push_back(tp);
0099     }
0100 
0101     L1TStub stub(DTClink, region, layerdisk, stubword, isPSmodule, isFlipped, x, y, z, bend, strip, tps);
0102 
0103     in >> tmp;
0104 
0105     double t = std::abs(stub.z()) / stub.r();
0106     double eta = asinh(t);
0107 
0108     if (std::abs(eta) < 2.6) {
0109       stubs_.push_back(stub);
0110     }
0111   }
0112 }
0113 
0114 void SLHCEvent::write(ofstream& out) {
0115   out << "Event: " << eventnum_ << endl;
0116 
0117   for (auto& simtrack : simtracks_) {
0118     simtrack.write(out);
0119   }
0120   out << "SimTrackEnd" << endl;
0121 
0122   for (auto& stub : stubs_) {
0123     stub.write(out);
0124   }
0125   out << "Stubend" << endl;
0126 }
0127 
0128 unsigned int SLHCEvent::layersHit(int tpid, int& nlayers, int& ndisks) {
0129   int l1 = 0;
0130   int l2 = 0;
0131   int l3 = 0;
0132   int l4 = 0;
0133   int l5 = 0;
0134   int l6 = 0;
0135 
0136   int d1 = 0;
0137   int d2 = 0;
0138   int d3 = 0;
0139   int d4 = 0;
0140   int d5 = 0;
0141 
0142   for (auto& stub : stubs_) {
0143     if (stub.tpmatch(tpid)) {
0144       if (stub.layer() == 0)
0145         l1 = 1;
0146       if (stub.layer() == 1)
0147         l2 = 1;
0148       if (stub.layer() == 2)
0149         l3 = 1;
0150       if (stub.layer() == 3)
0151         l4 = 1;
0152       if (stub.layer() == 4)
0153         l5 = 1;
0154       if (stub.layer() == 5)
0155         l6 = 1;
0156 
0157       if (abs(stub.disk()) == 1)
0158         d1 = 1;
0159       if (abs(stub.disk()) == 2)
0160         d2 = 1;
0161       if (abs(stub.disk()) == 3)
0162         d3 = 1;
0163       if (abs(stub.disk()) == 4)
0164         d4 = 1;
0165       if (abs(stub.disk()) == 5)
0166         d5 = 1;
0167     }
0168   }
0169 
0170   nlayers = l1 + l2 + l3 + l4 + l5 + l6;
0171   ndisks = d1 + d2 + d3 + d4 + d5;
0172 
0173   return l1 + 2 * l2 + 4 * l3 + 8 * l4 + 16 * l5 + 32 * l6 + 64 * d1 + 128 * d2 + 256 * d3 + 512 * d4 + 1024 * d5;
0174 }