CMS 3D CMS Logo

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  bool tiltedBarrel,
20  unsigned int tiltedRingId,
21  unsigned int endcapRingId,
22  unsigned int detId,
23  double x,
24  double y,
25  double z,
26  double bend,
27  double strip,
28  vector<int> tps,
29  int stubindex) {
30  L1TStub stub(DTClink,
31  region,
32  layerdisk,
33  stubword,
34  isPSmodule,
35  isFlipped,
36  tiltedBarrel,
37  tiltedRingId,
38  endcapRingId,
39  detId,
40  x,
41  y,
42  z,
43  bend,
44  strip,
45  tps);
46 
47  stub.setUniqueIndex(stubindex);
48  stubs_.push_back(stub);
49  return true;
50 }
51 
52 SLHCEvent::SLHCEvent(istream& in) {
53  string tmp;
54  in >> tmp;
55  if (tmp != "Event:") {
56  edm::LogVerbatim("Tracklet") << "Expected to read 'Event:' but found:" << tmp;
57  if (tmp.empty()) {
58  edm::LogVerbatim("Tracklet") << "WARNING: fewer events to process than specified!";
59  return;
60  } else {
61  edm::LogVerbatim("Tracklet") << "ERROR, aborting reading file";
62  abort();
63  }
64  }
65  in >> eventnum_;
66 
67  // read the SimTracks
68  in >> tmp;
69  while (tmp != "SimTrackEnd") {
70  if (!(tmp == "SimTrack:" || tmp == "SimTrackEnd")) {
71  edm::LogVerbatim("Tracklet") << "Expected to read 'SimTrack:' or 'SimTrackEnd' but found:" << tmp;
72  abort();
73  }
74  int eventid;
75  int trackid;
76  int type;
77  double pt;
78  double eta;
79  double phi;
80  double vx;
81  double vy;
82  double vz;
83  in >> eventid >> trackid >> type >> pt >> eta >> phi >> vx >> vy >> vz;
84  L1SimTrack simtrack(eventid, trackid, type, pt, eta, phi, vx, vy, vz);
85  simtracks_.push_back(simtrack);
86  in >> tmp;
87  }
88 
89  //read stubs
90  in >> tmp;
91  while (tmp != "Stubend") {
92  if (!in.good()) {
93  edm::LogVerbatim("Tracklet") << "File not good (SLHCEvent)";
94  abort();
95  };
96  if (!(tmp == "Stub:" || tmp == "Stubend")) {
97  edm::LogVerbatim("Tracklet") << "Expected to read 'Stub:' or 'StubEnd' but found:" << tmp;
98  abort();
99  }
100  string DTClink;
101  int region;
102  int layerdisk;
103  string stubword;
104  int isPSmodule;
105  int isFlipped;
106  double x;
107  double y;
108  double z;
109  double bend;
110  double strip;
111  unsigned int ntps;
112  vector<int> tps;
113 
114  in >> DTClink >> region >> layerdisk >> stubword >> isPSmodule >> isFlipped >> x >> y >> z >> bend >> strip >> ntps;
115 
116  // TO FIX: READ THESE FROM INPUT FILE
117  bool tiltedBarrel = false;
118  unsigned int tiltedRingId = 999999;
119  unsigned int endcapRingId = 999999;
120  unsigned int detId = 999999; // Lower sensor in module
121 
122  for (unsigned int itps = 0; itps < ntps; itps++) {
123  int tp;
124  in >> tp;
125  tps.push_back(tp);
126  }
127 
128  L1TStub stub(DTClink,
129  region,
130  layerdisk,
131  stubword,
132  isPSmodule,
133  isFlipped,
134  tiltedBarrel,
135  tiltedRingId,
136  endcapRingId,
137  detId,
138  x,
139  y,
140  z,
141  bend,
142  strip,
143  tps);
144 
145  in >> tmp;
146 
147  double t = std::abs(stub.z()) / stub.r();
148  double eta = asinh(t);
149 
150  if (std::abs(eta) < 2.6) {
151  stubs_.push_back(stub);
152  }
153  }
154 }
155 
156 void SLHCEvent::write(ofstream& out) {
157  out << "Event: " << eventnum_ << endl;
158 
159  for (auto& simtrack : simtracks_) {
160  simtrack.write(out);
161  }
162  out << "SimTrackEnd" << endl;
163 
164  for (auto& stub : stubs_) {
165  stub.write(out);
166  }
167  out << "Stubend" << endl;
168 }
169 
170 unsigned int SLHCEvent::layersHit(int tpid, int& nlayers, int& ndisks) {
171  int l1 = 0;
172  int l2 = 0;
173  int l3 = 0;
174  int l4 = 0;
175  int l5 = 0;
176  int l6 = 0;
177 
178  int d1 = 0;
179  int d2 = 0;
180  int d3 = 0;
181  int d4 = 0;
182  int d5 = 0;
183 
184  for (auto& stub : stubs_) {
185  if (stub.tpmatch(tpid)) {
186  if (stub.layer() == 0)
187  l1 = 1;
188  if (stub.layer() == 1)
189  l2 = 1;
190  if (stub.layer() == 2)
191  l3 = 1;
192  if (stub.layer() == 3)
193  l4 = 1;
194  if (stub.layer() == 4)
195  l5 = 1;
196  if (stub.layer() == 5)
197  l6 = 1;
198 
199  if (abs(stub.disk()) == 1)
200  d1 = 1;
201  if (abs(stub.disk()) == 2)
202  d2 = 1;
203  if (abs(stub.disk()) == 3)
204  d3 = 1;
205  if (abs(stub.disk()) == 4)
206  d4 = 1;
207  if (abs(stub.disk()) == 5)
208  d5 = 1;
209  }
210  }
211 
212  nlayers = l1 + l2 + l3 + l4 + l5 + l6;
213  ndisks = d1 + d2 + d3 + d4 + d5;
214 
215  return l1 + 2 * l2 + 4 * l3 + 8 * l4 + 16 * l5 + 32 * l6 + 64 * d1 + 128 * d2 + 256 * d3 + 512 * d4 + 1024 * d5;
216 }
Log< level::Info, true > LogVerbatim
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setUniqueIndex(unsigned int index)
Definition: L1TStub.h:84
float x
static constexpr float d1
tmp
align.sh
Definition: createJobs.py:716