CMS 3D CMS Logo

SLHCEvent.cc
Go to the documentation of this file.
2 
4 
5 using namespace std;
6 using namespace trklet;
7 
8 L1SimTrack::L1SimTrack() {
9  eventid_ = -1;
10  trackid_ = -1;
11 }
12 
13 L1SimTrack::L1SimTrack(
14  int eventid, int trackid, int type, double pt, double eta, double phi, double vx, double vy, double vz) {
15  eventid_ = eventid;
16  trackid_ = trackid;
17  type_ = type;
18  pt_ = pt;
19  eta_ = eta;
20  phi_ = phi;
21  vx_ = vx;
22  vy_ = vy;
23  vz_ = vz;
24 }
25 
26 void L1SimTrack::write(ofstream& out) {
27  if (pt_ > -2.0) {
28  out << "SimTrack: " << eventid_ << "\t" << trackid_ << "\t" << type_ << "\t" << pt_ << "\t" << eta_ << "\t" << phi_
29  << "\t" << vx_ << "\t" << vy_ << "\t" << vz_ << "\t" << endl;
30  }
31 }
32 
33 void L1SimTrack::write(ostream& out) {
34  if (pt_ > -2) {
35  out << "SimTrack: " << eventid_ << "\t" << trackid_ << "\t" << type_ << "\t" << pt_ << "\t" << eta_ << "\t" << phi_
36  << "\t" << vx_ << "\t" << vy_ << "\t" << vz_ << "\t" << endl;
37  }
38 }
39 
40 void SLHCEvent::addL1SimTrack(
41  int eventid, int trackid, int type, double pt, double eta, double phi, double vx, double vy, double vz) {
42  vx -= x_offset_;
43  vy -= y_offset_;
44  L1SimTrack simtrack(eventid, trackid, type, pt, eta, phi, vx, vy, vz);
45  simtracks_.push_back(simtrack);
46 }
47 
48 bool SLHCEvent::addStub(int layer,
49  int ladder,
50  int module,
51  int strip,
52  int eventid,
53  vector<int> tps,
54  double pt,
55  double bend,
56  double x,
57  double y,
58  double z,
59  int isPSmodule,
60  int isFlipped) {
61  if (layer > 999 && layer < 1999 && z < 0.0) {
62  layer += 1000;
63  }
64 
65  layer--;
66  x -= x_offset_;
67  y -= y_offset_;
68 
69  L1TStub stub(
70  eventid, tps, -1, -1, layer, ladder, module, strip, x, y, z, -1.0, -1.0, pt, bend, isPSmodule, isFlipped);
71 
72  stubs_.push_back(stub);
73  return true;
74 }
75 
76 SLHCEvent::SLHCEvent(istream& in) {
77  string tmp;
78  in >> tmp;
79  while (tmp == "Map:") {
80  in >> tmp >> tmp >> tmp >> tmp >> tmp >> tmp >> tmp >> tmp;
81  in >> tmp >> tmp >> tmp >> tmp >> tmp >> tmp >> tmp >> tmp;
82  }
83  if (tmp == "EndMap") {
84  in >> tmp;
85  }
86  if (tmp != "Event:") {
87  edm::LogVerbatim("Tracklet") << "Expected to read 'Event:' but found:" << tmp;
88  if (tmp.empty()) {
89  edm::LogVerbatim("Tracklet") << "WARNING: fewer events to process than specified!";
90  return;
91  } else {
92  edm::LogVerbatim("Tracklet") << "ERROR, aborting reading file";
93  abort();
94  }
95  }
96  in >> eventnum_;
97 
98  // read the SimTracks
99  in >> tmp;
100  while (tmp != "SimTrackEnd") {
101  if (!(tmp == "SimTrack:" || tmp == "SimTrackEnd")) {
102  edm::LogVerbatim("Tracklet") << "Expected to read 'SimTrack:' or 'SimTrackEnd' but found:" << tmp;
103  abort();
104  }
105  int eventid;
106  int trackid;
107  int type;
108  string pt_str;
109  string eta_str;
110  string phi_str;
111  string vx_str;
112  string vy_str;
113  string vz_str;
114  double pt;
115  double eta;
116  double phi;
117  double vx;
118  double vy;
119  double vz;
120  in >> eventid >> trackid >> type >> pt_str >> eta_str >> phi_str >> vx_str >> vy_str >> vz_str;
121  pt = strtod(pt_str.c_str(), nullptr);
122  eta = strtod(eta_str.c_str(), nullptr);
123  phi = strtod(phi_str.c_str(), nullptr);
124  vx = strtod(vx_str.c_str(), nullptr);
125  vy = strtod(vy_str.c_str(), nullptr);
126  vz = strtod(vz_str.c_str(), nullptr);
127  vx -= x_offset_;
128  vy -= y_offset_;
129  L1SimTrack simtrack(eventid, trackid, type, pt, eta, phi, vx, vy, vz);
130  simtracks_.push_back(simtrack);
131  in >> tmp;
132  }
133 
134  int oldlayer = 0;
135  int oldladder = 0;
136  int oldmodule = 0;
137  int oldcbc = -1;
138  int count = 1;
139  double oldz = -1000.0;
140 
141  //read stubs
142  in >> tmp;
143  while (tmp != "StubEnd") {
144  if (!in.good()) {
145  edm::LogVerbatim("Tracklet") << "File not good";
146  abort();
147  };
148  if (!(tmp == "Stub:" || tmp == "StubEnd")) {
149  edm::LogVerbatim("Tracklet") << "Expected to read 'Stub:' or 'StubEnd' but found:" << tmp;
150  abort();
151  }
152  int layer;
153  int ladder;
154  int module;
155  int eventid;
156  vector<int> tps;
157  int strip;
158  double pt;
159  double x;
160  double y;
161  double z;
162  double bend;
163  int isPSmodule;
164  int isFlipped;
165 
166  unsigned int ntps;
167 
168  in >> layer >> ladder >> module >> strip >> eventid >> pt >> x >> y >> z >> bend >> isPSmodule >> isFlipped >> ntps;
169 
170  for (unsigned int itps = 0; itps < ntps; itps++) {
171  int tp;
172  in >> tp;
173  tps.push_back(tp);
174  }
175 
176  if (layer > 999 && layer < 1999 && z < 0.0) { //negative disk
177  layer += 1000;
178  }
179 
180  int cbc = strip / 126;
181  if (layer > 3 && layer == oldlayer && ladder == oldladder && module == oldmodule && cbc == oldcbc &&
182  std::abs(oldz - z) < 1.0) {
183  count++;
184  } else {
185  oldlayer = layer;
186  oldladder = ladder;
187  oldmodule = module;
188  oldcbc = cbc;
189  oldz = z;
190  count = 1;
191  }
192 
193  layer--;
194  x -= x_offset_;
195  y -= y_offset_;
196 
197  L1TStub stub(
198  eventid, tps, -1, -1, layer, ladder, module, strip, x, y, z, -1.0, -1.0, pt, bend, isPSmodule, isFlipped);
199 
200  in >> tmp;
201 
202  double t = std::abs(stub.z()) / stub.r();
203  double eta = asinh(t);
204 
205  if (std::abs(eta) < 2.6 && count <= 100) {
206  stubs_.push_back(stub);
207  }
208  }
209 }
210 
211 void SLHCEvent::write(ofstream& out) {
212  out << "Event: " << eventnum_ << endl;
213 
214  for (auto& simtrack : simtracks_) {
215  simtrack.write(out);
216  }
217  out << "SimTrackEnd" << endl;
218 
219  for (auto& stub : stubs_) {
220  stub.write(out);
221  }
222  out << "StubEnd" << endl;
223 }
224 
225 void SLHCEvent::write(ostream& out) {
226  out << "Event: " << eventnum_ << endl;
227 
228  for (auto& simtrack : simtracks_) {
229  simtrack.write(out);
230  }
231  out << "SimTrackEnd" << endl;
232 
233  for (auto& stub : stubs_) {
234  stub.write(out);
235  }
236  out << "StubEnd" << endl;
237 }
238 
239 unsigned int SLHCEvent::layersHit(int tpid, int& nlayers, int& ndisks) {
240  int l1 = 0;
241  int l2 = 0;
242  int l3 = 0;
243  int l4 = 0;
244  int l5 = 0;
245  int l6 = 0;
246 
247  int d1 = 0;
248  int d2 = 0;
249  int d3 = 0;
250  int d4 = 0;
251  int d5 = 0;
252 
253  for (auto& stub : stubs_) {
254  if (stub.tpmatch(tpid)) {
255  if (stub.layer() == 0)
256  l1 = 1;
257  if (stub.layer() == 1)
258  l2 = 1;
259  if (stub.layer() == 2)
260  l3 = 1;
261  if (stub.layer() == 3)
262  l4 = 1;
263  if (stub.layer() == 4)
264  l5 = 1;
265  if (stub.layer() == 5)
266  l6 = 1;
267 
268  if (abs(stub.disk()) == 1)
269  d1 = 1;
270  if (abs(stub.disk()) == 2)
271  d2 = 1;
272  if (abs(stub.disk()) == 3)
273  d3 = 1;
274  if (abs(stub.disk()) == 4)
275  d4 = 1;
276  if (abs(stub.disk()) == 5)
277  d5 = 1;
278  }
279  }
280 
281  nlayers = l1 + l2 + l3 + l4 + l5 + l6;
282  ndisks = d1 + d2 + d3 + d4 + d5;
283 
284  return l1 + 2 * l2 + 4 * l3 + 8 * l4 + 16 * l5 + 32 * l6 + 64 * d1 + 128 * d2 + 256 * d3 + 512 * d4 + 1024 * d5;
285 }
286 
287 int SLHCEvent::getSimtrackFromSimtrackid(int simtrackid, int eventid) const {
288  for (unsigned int i = 0; i < simtracks_.size(); i++) {
289  if (simtracks_[i].trackid() == simtrackid && simtracks_[i].eventid() == eventid)
290  return i;
291  }
292  return -1;
293 }
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
trklet::L1TStub
Definition: L1TStub.h:12
trklet::L1SimTrack
Definition: SLHCEvent.h:16
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
PVValHelper::eta
Definition: PVValidationHelpers.h:69
vertices_cff.x
x
Definition: vertices_cff.py:29
SLHCEvent.h
OrderedSet.t
t
Definition: OrderedSet.py:90
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
PVValHelper::phi
Definition: PVValidationHelpers.h:68
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
recoMuon::in
Definition: RecoMuonEnumerators.h:6
edm::LogVerbatim
Definition: MessageLogger.h:297
module
Definition: vlib.h:198
trklet
Definition: AllProjectionsMemory.h:9
writeEcalDQMStatus.write
write
Definition: writeEcalDQMStatus.py:48
type
type
Definition: HCALResponse.h:21
std
Definition: JetResolutionObject.h:76
trklet::bend
double bend(double r, double rinv, double stripPitch)
Definition: Util.h:160
PVValHelper::ladder
Definition: PVValidationHelpers.h:72
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
d1
static constexpr float d1
Definition: L1EGammaCrystalsEmulatorProducer.cc:85
nlayers
Definition: HIMultiTrackSelector.h:48