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