CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SLHCEvent.cc
Go to the documentation of this file.
3 
4 using namespace std;
5 using namespace trklet;
6 
7 void SLHCEvent::addL1SimTrack(
8  int eventid, int trackid, int type, double pt, double eta, double phi, double vx, double vy, double vz) {
9  L1SimTrack simtrack(eventid, trackid, type, pt, eta, phi, vx, vy, vz);
10  simtracks_.push_back(simtrack);
11 }
12 
13 bool SLHCEvent::addStub(string DTClink,
14  int region,
15  int layerdisk,
16  string stubword,
17  int isPSmodule,
18  int isFlipped,
19  double x,
20  double y,
21  double z,
22  double bend,
23  double strip,
24  vector<int> tps) {
25  L1TStub stub(DTClink, region, layerdisk, stubword, isPSmodule, isFlipped, x, y, z, bend, strip, tps);
26 
27  stubs_.push_back(stub);
28  return true;
29 }
30 
31 SLHCEvent::SLHCEvent(istream& in) {
32  string tmp;
33  in >> tmp;
34  if (tmp != "Event:") {
35  edm::LogVerbatim("Tracklet") << "Expected to read 'Event:' but found:" << tmp;
36  if (tmp.empty()) {
37  edm::LogVerbatim("Tracklet") << "WARNING: fewer events to process than specified!";
38  return;
39  } else {
40  edm::LogVerbatim("Tracklet") << "ERROR, aborting reading file";
41  abort();
42  }
43  }
44  in >> eventnum_;
45 
46  // read the SimTracks
47  in >> tmp;
48  while (tmp != "SimTrackEnd") {
49  if (!(tmp == "SimTrack:" || tmp == "SimTrackEnd")) {
50  edm::LogVerbatim("Tracklet") << "Expected to read 'SimTrack:' or 'SimTrackEnd' but found:" << tmp;
51  abort();
52  }
53  int eventid;
54  int trackid;
55  int type;
56  double pt;
57  double eta;
58  double phi;
59  double vx;
60  double vy;
61  double vz;
62  in >> eventid >> trackid >> type >> pt >> eta >> phi >> vx >> vy >> vz;
63  L1SimTrack simtrack(eventid, trackid, type, pt, eta, phi, vx, vy, vz);
64  simtracks_.push_back(simtrack);
65  in >> tmp;
66  }
67 
68  //read stubs
69  in >> tmp;
70  while (tmp != "Stubend") {
71  if (!in.good()) {
72  edm::LogVerbatim("Tracklet") << "File not good (SLHCEvent)";
73  abort();
74  };
75  if (!(tmp == "Stub:" || tmp == "Stubend")) {
76  edm::LogVerbatim("Tracklet") << "Expected to read 'Stub:' or 'StubEnd' but found:" << tmp;
77  abort();
78  }
79  string DTClink;
80  int region;
81  int layerdisk;
82  string stubword;
83  int isPSmodule;
84  int isFlipped;
85  double x;
86  double y;
87  double z;
88  double bend;
89  double strip;
90  unsigned int ntps;
91  vector<int> tps;
92 
93  in >> DTClink >> region >> layerdisk >> stubword >> isPSmodule >> isFlipped >> x >> y >> z >> bend >> strip >> ntps;
94 
95  for (unsigned int itps = 0; itps < ntps; itps++) {
96  int tp;
97  in >> tp;
98  tps.push_back(tp);
99  }
100 
101  L1TStub stub(DTClink, region, layerdisk, stubword, isPSmodule, isFlipped, x, y, z, bend, strip, tps);
102 
103  in >> tmp;
104 
105  double t = std::abs(stub.z()) / stub.r();
106  double eta = asinh(t);
107 
108  if (std::abs(eta) < 2.6) {
109  stubs_.push_back(stub);
110  }
111  }
112 }
113 
114 void SLHCEvent::write(ofstream& out) {
115  out << "Event: " << eventnum_ << endl;
116 
117  for (auto& simtrack : simtracks_) {
118  simtrack.write(out);
119  }
120  out << "SimTrackEnd" << endl;
121 
122  for (auto& stub : stubs_) {
123  stub.write(out);
124  }
125  out << "Stubend" << endl;
126 }
127 
128 unsigned int SLHCEvent::layersHit(int tpid, int& nlayers, int& ndisks) {
129  int l1 = 0;
130  int l2 = 0;
131  int l3 = 0;
132  int l4 = 0;
133  int l5 = 0;
134  int l6 = 0;
135 
136  int d1 = 0;
137  int d2 = 0;
138  int d3 = 0;
139  int d4 = 0;
140  int d5 = 0;
141 
142  for (auto& stub : stubs_) {
143  if (stub.tpmatch(tpid)) {
144  if (stub.layer() == 0)
145  l1 = 1;
146  if (stub.layer() == 1)
147  l2 = 1;
148  if (stub.layer() == 2)
149  l3 = 1;
150  if (stub.layer() == 3)
151  l4 = 1;
152  if (stub.layer() == 4)
153  l5 = 1;
154  if (stub.layer() == 5)
155  l6 = 1;
156 
157  if (abs(stub.disk()) == 1)
158  d1 = 1;
159  if (abs(stub.disk()) == 2)
160  d2 = 1;
161  if (abs(stub.disk()) == 3)
162  d3 = 1;
163  if (abs(stub.disk()) == 4)
164  d4 = 1;
165  if (abs(stub.disk()) == 5)
166  d5 = 1;
167  }
168  }
169 
170  nlayers = l1 + l2 + l3 + l4 + l5 + l6;
171  ndisks = d1 + d2 + d3 + d4 + d5;
172 
173  return l1 + 2 * l2 + 4 * l3 + 8 * l4 + 16 * l5 + 32 * l6 + 64 * d1 + 128 * d2 + 256 * d3 + 512 * d4 + 1024 * d5;
174 }
Log< level::Info, true > LogVerbatim
float float float z
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
uint16_t const *__restrict__ x
Definition: gpuClustering.h:39
static constexpr float d1
tmp
align.sh
Definition: createJobs.py:716