hpstr
The Heavy Photon Search Toolkit for Reconstruction (hpstr) provides an interface to physics data from the HPS experiment saved in the LCIO format and converts it into an ROOT based format.
Loading...
Searching...
No Matches
utilities.cxx
Go to the documentation of this file.
1#include "utilities.h"
2
3#include <algorithm>
4#include <memory>
5/*
6 void utils::buildTrackCollection(std::vector<Track*>& tracks,
7 Event* event,
8 const char* LCTrackCollection)
9 {
10
11 EVENT::LCCollection* lc_tracks event->getLCCollection(LCTrackCollection);
12
13
14 }
15
16*/
17
18bool utils::hasCollection(EVENT::LCEvent* lc_event, const std::string& collection) {
19 if (!lc_event || collection.empty()) return false;
20
21 auto evColls = lc_event->getCollectionNames();
22 auto it = std::find(evColls->begin(), evColls->end(), collection);
23 if (it != evColls->end()) return true;
24 return false;
25}
26
27Vertex* utils::buildVertex(EVENT::Vertex* lc_vertex) {
28 if (!lc_vertex) return nullptr;
29
30 // TODO move the static cast outside?
31
32 Vertex* vertex = new Vertex();
33 vertex->setChi2(lc_vertex->getChi2());
34 vertex->setProbability(lc_vertex->getProbability());
35 vertex->setID(lc_vertex->id());
36 vertex->setType(lc_vertex->getAlgorithmType());
37 vertex->setVtxParameters((std::vector<float>)lc_vertex->getParameters());
38
39 // TODO Rotate the covariance matrix!
40 vertex->setCovariance((std::vector<float>)lc_vertex->getCovMatrix());
41 vertex->setType(lc_vertex->getAlgorithmType());
42 vertex->setPos(lc_vertex->getPosition(), false);
43
44 return vertex;
45}
46
47Particle* utils::buildParticle(EVENT::ReconstructedParticle* lc_particle, std::string trackstate_location,
48 EVENT::LCCollection* gbl_kink_data, EVENT::LCCollection* track_data)
49
50{
51 if (!lc_particle) return nullptr;
52
53 Particle* part = new Particle();
54 // Set the charge of the HpsParticle
55 part->setCharge(lc_particle->getCharge());
56
57 // Set the HpsParticle type
58 part->setType(lc_particle->getType());
59
60 // Set the energy of the HpsParticle
61 part->setEnergy(lc_particle->getEnergy());
62
63 // Set the momentum of the HpsParticle
64 part->setMomentum(lc_particle->getMomentum());
65
66 // Set the mass of the HpsParticle
67 part->setMass(lc_particle->getMass());
68
69 // Set the goodness of PID for the HpsParticle
70 part->setGoodnessOfPID(lc_particle->getGoodnessOfPID());
71
72 // Set the PDG ID for the HpsParticle
73 part->setPDG(lc_particle->getParticleIDUsed()->getPDG());
74
75 // Set the Track for the HpsParticle
76 if (lc_particle->getTracks().size() > 0) {
77 Track* trkPtr = utils::buildTrack(lc_particle->getTracks()[0], trackstate_location, gbl_kink_data, track_data);
78 // buildTrack returns nullptr when the requested track state is missing
79 if (trkPtr) {
80 part->setTrack(trkPtr);
81 delete trkPtr;
82 }
83 }
84
85 // Set the Track for the HpsParticle
86 if (lc_particle->getClusters().size() > 0) {
87 CalCluster* clusBuf = utils::buildCalCluster(lc_particle->getClusters()[0]);
88 part->setCluster(clusBuf);
89 delete clusBuf;
90 }
91
92 return part;
93}
94
95CalCluster* utils::buildCalCluster(EVENT::Cluster* lc_cluster) {
96 if (!lc_cluster) return nullptr;
97
98 CalCluster* cluster = new CalCluster();
99 // Set the cluster position
100 cluster->setPosition(lc_cluster->getPosition());
101
102 // Set the cluster energy
103 cluster->setEnergy(lc_cluster->getEnergy());
104
105 // Get the ecal hits used to create the cluster
106 EVENT::CalorimeterHitVec lc_hits = lc_cluster->getCalorimeterHits();
107
108 // Loop over all of the Ecal hits and add them to the Ecal cluster. The
109 // seed hit is set to be the hit with the highest energy. The cluster time
110 // is set to be the hit time of the seed hit.
111 double senergy = 0;
112 double stime = 0;
113 for (int ihit = 0; ihit < (int)lc_hits.size(); ++ihit) {
114 // Get an Ecal hit
115 EVENT::CalorimeterHit* lc_hit = lc_hits[ihit];
116 if (senergy < lc_hit->getEnergy()) {
117 senergy = lc_hit->getEnergy();
118 stime = lc_hit->getTime();
119 }
120 }
121
122 // Set the time of the cluster
123 cluster->setTime(stime);
124
125 return cluster;
126}
127
128bool utils::IsSameTrack(Track* trk1, Track* trk2) {
129 double tol = 1e-6;
130 if (fabs(trk1->getD0() - trk2->getD0()) > tol || fabs(trk1->getPhi() - trk2->getPhi()) > tol ||
131 fabs(trk1->getOmega() - trk2->getOmega()) > tol || fabs(trk1->getTanLambda() - trk2->getTanLambda()) > tol ||
132 fabs(trk1->getZ0() - trk2->getZ0()) > tol || fabs(trk1->getChi2Ndf() - trk2->getChi2Ndf()) > tol)
133 return false;
134
135 return true;
136}
137
138Track* utils::buildTrack(EVENT::Track* lc_track, std::string trackstate_location, EVENT::LCCollection* gbl_kink_data,
139 EVENT::LCCollection* track_data) {
140 if (!lc_track) return nullptr;
141
142 // public final static int AtOther = 0; // Any location other than the ones defined below.
143 // public final static int AtPerigee = 1; //track state at perigee, which is what the track finder returns
144 // public final static int AtIP = 2; // this is at the target
145 // public final static int AtTarget = 2; // this is at the target
146 // public final static int AtFirstHit = 3;
147 // public final static int AtLastHit = 4;
148 // public final static int AtCalorimeter = 5;
149 // public final static int AtVertex = 6;
150 // public final static int LastLocation = AtVertex;
151
152 // TrackState Location maps
153 // V30 is the current version, so just get numbers from LCIO
154 std::map<std::string, int> trackstateLocationMapV30_ = {{"", EVENT::TrackState::AtPerigee},
155 {"AtPerigee", EVENT::TrackState::AtPerigee},
156 {"AtIP", EVENT::TrackState::AtIP},
157 {"AtTarget", EVENT::TrackState::AtTarget},
158 {"AtFirstHit", EVENT::TrackState::AtFirstHit},
159 {"AtLastHit", EVENT::TrackState::AtLastHit},
160 {"AtCalorimeter", EVENT::TrackState::AtCalorimeter},
161 {"AtVertex", EVENT::TrackState::AtVertex},
162 {"LastLocation", EVENT::TrackState::LastLocation}};
163 // V23 is the old map, so put numbers in by hand
164 std::map<std::string, int> trackstateLocationMapV23_ = {
165 {"", EVENT::TrackState::AtIP}, {"AtIP", 1}, {"AtFirstHit", 2}, {"AtLastHit", 3},
166 {"AtCalorimeter", 4}, {"AtVertex", 5}, {"LastLocation", 5}};
167
168 Track* track = new Track();
169
170 // If using track AtPerigee or unset, get params from lc_track
171 // if (loc == trackstateLocationMap_[""]){
172 // Set the track parameters
173 // track->setTrackParameters(lc_track->getD0(),
174 // lc_track->getPhi(),
175 // lc_track->getOmega(),
176 // lc_track->getTanLambda(),
177 // lc_track->getZ0());
178
179 // Set the track covariance matrix
180 // track->setCov(static_cast<std::vector<float> > (lc_track->getCovMatrix()));
181 //}
182 // use getBLocal to check if it's V23 or V30
183 // V30 will have sensible BField
184
185 // Defensive check: try to access track states safely
186 const EVENT::TrackStateVec* trackStatesPtr = nullptr;
187 try {
188 trackStatesPtr = &(lc_track->getTrackStates());
189 } catch (...) {
190 delete track;
191 return nullptr;
192 }
193
194 if (!trackStatesPtr || trackStatesPtr->size() < 2) {
195 delete track;
196 return nullptr;
197 }
198
199 const EVENT::TrackState* ts1 = trackStatesPtr->at(1);
200 if (!ts1) {
201 delete track;
202 return nullptr;
203 }
204 double bTmp = ts1->getBLocal();
205 std::map<std::string, int> trackstateLocationMap_;
206 if (abs(bTmp) < 10.0)
207 trackstateLocationMap_ = trackstateLocationMapV30_;
208 else
209 trackstateLocationMap_ = trackstateLocationMapV23_;
210
211 int loc;
212 auto it = trackstateLocationMap_.find(trackstate_location);
213 if (it != trackstateLocationMap_.end()) {
214 loc = it->second;
215 } else {
216 std::cout << "[utilities]::ERROR Track State Location " << trackstate_location << " Doesn't Exist!"
217 << std::endl;
218 std::cout << "Check map in utilities::buildTrack for defined locations" << std::endl;
219 delete track;
220 return nullptr;
221 }
222 // If other TrackState specified, get track params from track state
223 // else {
224 // If track state doesn't exist, no track returned
225 const EVENT::TrackState* ts = lc_track->getTrackState(loc);
226 if (ts == nullptr) {
227 delete track;
228 return nullptr;
229 }
230
231 // If the track state is AtTarget, replace the d0 & z0
232 // with their reference positions in global x & y.
233 // We do this because the reference for ts@target
234 // is defined as where the track intersects with the target
235 // plane; so d0 & z0 == 0. This is a bit of a kludge to make
236 // it simpler for analysts.
237 // NOTE that these will not be strictly correct perigee parameters
238 double tsD0 = ts->getD0();
239 double tsZ0 = ts->getZ0();
240 if (loc == EVENT::TrackState::AtTarget) {
241 tsD0 = ts->getReferencePoint()[1];
242 tsZ0 = ts->getReferencePoint()[2];
243 }
244
245 // Set the track parameters using trackstate
246 track->setTrackParameters(tsD0, ts->getPhi(), ts->getOmega(), ts->getTanLambda(), tsZ0);
247
248 double position[3] = {ts->getReferencePoint()[1], ts->getReferencePoint()[2], ts->getReferencePoint()[0]};
249
250 track->setCov(static_cast<std::vector<float>>(ts->getCovMatrix()));
251 track->setPosition(position);
252
253 double bLocal = lc_track->getTrackState(loc)->getBLocal();
254 if (abs(bLocal) <
255 10.0) // check if it has non-default value (which should be 666)...this fails for pre-v3 lcio. see below
256 track->setMomentum(bLocal);
257
258 // Set the track id
259 track->setID(lc_track->id());
260
261 // Set the track type
262 track->setType(lc_track->getType());
263
264 // Set the track fit chi^2
265 track->setChi2(lc_track->getChi2());
266
267 // Set the track ndf
268 track->setNdf(lc_track->getNdf());
269
270 // Set the position of the extrapolated track at the ECal face. The
271 // extrapolation uses the full 3D field map.
272 const EVENT::TrackState* track_state = lc_track->getTrackState(trackstateLocationMap_["AtCalorimeter"]);
273
274 if (track_state) {
275 double position_at_ecal[3] = {track_state->getReferencePoint()[1], track_state->getReferencePoint()[2],
276 track_state->getReferencePoint()[0]};
277 track->setPositionAtEcal(position_at_ecal);
278 }
279
280 if (gbl_kink_data) {
281 // Instantiate an LCRelation navigator which will allow faster access
282 // to GBLKinkData object
283 std::shared_ptr<UTIL::LCRelationNavigator> gbl_kink_data_nav =
284 std::make_shared<UTIL::LCRelationNavigator>(gbl_kink_data);
285
286 // Get the list of GBLKinkData associated with the LCIO Track
287 EVENT::LCObjectVec gbl_kink_data_list = gbl_kink_data_nav->getRelatedFromObjects(lc_track);
288
289 // The container of GBLKinkData objects should only contain a
290 // single object. If not, throw an exception
291 if (gbl_kink_data_list.size() == 1) {
292 /*
293 std::cout<<"[ Utilities ]: The collection "
294 + std::string(Collections::KINK_DATA)
295 + " has the wrong data structure for this track"<<std::endl;
296 */
297
298 // Get the list GBLKinkData GenericObject associated with the LCIO Track
299 IMPL::LCGenericObjectImpl* gbl_kink_datum =
300 static_cast<IMPL::LCGenericObjectImpl*>(gbl_kink_data_list.at(0));
301
302 // Set the lambda and phi kink values
303 for (int ikink = 0; ikink < gbl_kink_datum->getNDouble(); ++ikink) {
304 track->setLambdaKink(ikink, gbl_kink_datum->getFloatVal(ikink));
305 track->setPhiKink(ikink, gbl_kink_datum->getDoubleVal(ikink));
306 }
307
308 } // gbl_kink_data has right structure
309
310 } // add gbl kink data
311
312 if (track_data) {
313 // Instantiate an LCRelation navigator which will allow faster access
314 // to TrackData objects
315 std::shared_ptr<UTIL::LCRelationNavigator> track_data_nav =
316 std::make_shared<UTIL::LCRelationNavigator>(track_data);
317
318 // Get the list of TrackData associated with the LCIO Track
319 EVENT::LCObjectVec track_data_list = track_data_nav->getRelatedFromObjects(lc_track);
320
321 // The container of TrackData objects should only contain a single
322 // object. If not, throw an exception.
323 if (track_data_list.size() == 1) {
324 // Get the TrackData GenericObject associated with the LCIO Track
325 IMPL::LCGenericObjectImpl* track_datum = static_cast<IMPL::LCGenericObjectImpl*>(track_data_list.at(0));
326
327 // Check that the TrackData data structure is correct. If it's
328 // not, throw a runtime exception.
329 if (track_datum->getNDouble() > 14 || track_datum->getNFloat() > 8 || track_datum->getNInt() != 1) {
330 throw std::runtime_error("[ TrackingProcessor ]: The collection " +
331 std::string(Collections::TRACK_DATA) + " has the wrong structure.");
332 }
333
334 // Set the SvtTrack isolation values
335 for (int iso_index = 0; iso_index < track_datum->getNDouble(); ++iso_index) {
336 track->setIsolation(iso_index, track_datum->getDoubleVal(iso_index));
337 }
338
339 // Set the SvtTrack time
340 track->setTrackTime(track_datum->getFloatVal(0));
341
342 // Set the Track momentum
343 // mg comment this out
344 // if(abs(bLocal)<10.0) // check if it has non-default value (which should be 666)
345
346 if (track_datum->getNFloat() > 3 &&
347 abs(bLocal) > 10.0) // bfield is not set in track state so get from track data...
348 track->setMomentum(track_datum->getFloatVal(1), track_datum->getFloatVal(2),
349 track_datum->getFloatVal(3));
350
351 // Set the volume (top/bottom) in which the SvtTrack resides
352 track->setTrackVolume(track_datum->getIntVal(0));
353
354 // Set the BfieldY for track state
355 // mg comment this out
356 if (abs(bLocal) > 10.0) { // bfield is not set in track state so get from track data...pre-v3 lcio
357 double bfieldY = -999.9;
358 if (track_datum->getNFloat() > 4) {
359 if (loc == trackstateLocationMap_[""]) bfieldY = track_datum->getFloatVal(4);
360 if (loc == trackstateLocationMap_["AtTarget"]) {
361 bfieldY = track_datum->getFloatVal(5);
362 }
363 if (loc == trackstateLocationMap_["AtCalorimeter"]) bfieldY = track_datum->getFloatVal(6);
364 track->setMomentum(-bfieldY);
365 }
366 }
367 }
368
369 } // add track data
370
371 return track;
372}
373
374RawSvtHit* utils::buildRawHit(EVENT::TrackerRawData* rawTracker_hit, EVENT::LCCollection* raw_svt_hit_fits) {
375 EVENT::long64 value =
376 EVENT::long64(rawTracker_hit->getCellID0() & 0xffffffff) | (EVENT::long64(rawTracker_hit->getCellID1()) << 32);
377 decoder.setValue(value);
378
379 RawSvtHit* rawHit = new RawSvtHit();
380 rawHit->setSystem(decoder["system"]);
381 rawHit->setBarrel(decoder["barrel"]);
382 rawHit->setLayer(decoder["layer"]);
383 rawHit->setModule(decoder["module"]);
384 rawHit->setSensor(decoder["sensor"]);
385 rawHit->setSide(decoder["side"]);
386 rawHit->setStrip(decoder["strip"]);
387
388 // Extract ADC values for this hit
389 int hit_adcs[6] = {(int)rawTracker_hit->getADCValues().at(0), (int)rawTracker_hit->getADCValues().at(1),
390 (int)rawTracker_hit->getADCValues().at(2), (int)rawTracker_hit->getADCValues().at(3),
391 (int)rawTracker_hit->getADCValues().at(4), (int)rawTracker_hit->getADCValues().at(5)};
392
393 rawHit->setADCs(hit_adcs);
394 if (raw_svt_hit_fits) {
395 std::shared_ptr<UTIL::LCRelationNavigator> rawTracker_hit_fits_nav =
396 std::make_shared<UTIL::LCRelationNavigator>(raw_svt_hit_fits);
397
398 // Get the list of fit params associated with the raw tracker hit
399 EVENT::LCObjectVec rawTracker_hit_fits_list = rawTracker_hit_fits_nav->getRelatedToObjects(rawTracker_hit);
400
401 // Get the list SVTFittedRawTrackerHit GenericObject associated with the SVTRawTrackerHit
402 IMPL::LCGenericObjectImpl* hit_fit_param =
403 static_cast<IMPL::LCGenericObjectImpl*>(rawTracker_hit_fits_list.at(0));
404
405 double fit_params[5] = {(double)hit_fit_param->getDoubleVal(0), (double)hit_fit_param->getDoubleVal(1),
406 (double)hit_fit_param->getDoubleVal(2), (double)hit_fit_param->getDoubleVal(3),
407 (double)hit_fit_param->getDoubleVal(4)};
408 rawHit->setFit(fit_params, 0);
409 if (rawTracker_hit_fits_list.size() > 1) {
410 hit_fit_param = static_cast<IMPL::LCGenericObjectImpl*>(rawTracker_hit_fits_list.at(1));
411 fit_params[0] = (double)hit_fit_param->getDoubleVal(0);
412 fit_params[1] = (double)hit_fit_param->getDoubleVal(1);
413 fit_params[2] = (double)hit_fit_param->getDoubleVal(2);
414 fit_params[3] = (double)hit_fit_param->getDoubleVal(3);
415 fit_params[4] = (double)hit_fit_param->getDoubleVal(4);
416
417 rawHit->setFit(fit_params, 1);
418 }
419 rawHit->setFitN(rawTracker_hit_fits_list.size());
420 } // raw svt hit fits
421
422 return rawHit;
423
424} // build raw hit
425
426// type = 0 RotatedHelicalTrackHit type = 1 SiCluster
427TrackerHit* utils::buildTrackerHit(IMPL::TrackerHitImpl* lc_tracker_hit, bool rotate, int type) {
428 if (!lc_tracker_hit) return nullptr;
429
430 TrackerHit* tracker_hit = new TrackerHit();
431
432 // Get the position of the LCIO TrackerHit and set the position of
433 // the TrackerHit
434 double hit_position[3] = {
435 lc_tracker_hit->getPosition()[0], // lcio x
436 lc_tracker_hit->getPosition()[1], // lcio y
437 lc_tracker_hit->getPosition()[2] // lcio z
438 };
439 tracker_hit->setPosition(hit_position, rotate, type);
440
441 // Set the covariance matrix of the SvtHit
442 tracker_hit->setCovarianceMatrix(lc_tracker_hit->getCovMatrix());
443
444 // Set the time of the SvtHit
445 tracker_hit->setTime(lc_tracker_hit->getTime());
446
447 // Set the charge of the SvtHit
448 tracker_hit->setCharge(lc_tracker_hit->getEDep());
449
450 // Set the LCIO id
451 tracker_hit->setID(lc_tracker_hit->id());
452
453 return tracker_hit;
454}
455
456// type 0 rotatedHelicalHit type 1 SiClusterHit
457bool utils::addRawInfoTo3dHit(TrackerHit* tracker_hit, IMPL::TrackerHitImpl* lc_tracker_hit,
458 EVENT::LCCollection* raw_svt_fits, std::vector<RawSvtHit*>* rawHits, int type,
459 bool storeRawHit) {
460 if (!tracker_hit || !lc_tracker_hit) return false;
461
462 float rawcharge = 0;
463 // 0 top 1 bottom
464 int volume = -1;
465 // 1-6(7) for rotated 0-13 for SiCluster
466 int layer = -1;
467
468 // Get decoders to read cellids
469 UTIL::BitField64 decoder("system:6,barrel:3,layer:4,module:12,sensor:1,side:32:-2,strip:12");
470
471 // Get the Raw content of the tracker hits
472 EVENT::LCObjectVec lc_rawHits = lc_tracker_hit->getRawHits();
473
474 std::vector<int> rawhit_strips;
475 for (unsigned int irh = 0; irh < lc_rawHits.size(); ++irh) {
476 // Get a raw hit from the list of hits
477 EVENT::TrackerRawData* rawTracker_hit = static_cast<EVENT::TrackerRawData*>(lc_rawHits.at(irh));
478
479 // Decode the cellid
480 EVENT::long64 value = EVENT::long64(rawTracker_hit->getCellID0() & 0xffffffff) |
481 (EVENT::long64(rawTracker_hit->getCellID1()) << 32);
482 decoder.setValue(value);
483
484 // Get rawhit strip number
485 int stripnumber = decoder["strip"];
486 rawhit_strips.push_back(stripnumber);
487
488 // TODO useless to build all of it?
489 RawSvtHit* rawHit = buildRawHit(rawTracker_hit, raw_svt_fits);
490 rawcharge += rawHit->getAmp(0);
491 int currentHitVolume = rawHit->getModule() % 2 ? 1 : 0;
492 int currentHitLayer = (rawHit->getLayer() - 1) / 2;
493 if (type == 1) currentHitLayer = rawHit->getLayer() - 1;
494 if (volume == -1)
495 volume = currentHitVolume;
496 else {
497 if (currentHitVolume != volume)
498 std::cout << "[ ERROR ] : utils::addRawInfoTo3dHit raw hits with inconsistent volume found"
499 << std::endl;
500 }
501
502 if (layer == -1)
503 layer = currentHitLayer;
504 else {
505 if (currentHitLayer != layer)
506 std::cout << "[ ERROR ] : utils::addRawInfoTo3dHit raw hits with inconsistent layer found" << std::endl;
507 }
508
509 if (storeRawHit) {
510 tracker_hit->addRawHit(rawHit);
511 if (rawHits) rawHits->push_back(rawHit);
512 } else
513 delete rawHit;
514 }
515
516 tracker_hit->setRawCharge(rawcharge);
517 tracker_hit->setVolume(volume);
518 tracker_hit->setLayer(layer);
519 tracker_hit->setRawHitStripNumbers(rawhit_strips);
520
521 return true;
522}
523
524// TODO-improve shared finding algorithm
525
526bool utils::isUsedByTrack(IMPL::TrackerHitImpl* lc_tracker_hit, EVENT::Track* lc_track) {
527 EVENT::TrackerHitVec trk_lc_tracker_hits = lc_track->getTrackerHits();
528
529 for (auto trk_lc_tracker_hit : trk_lc_tracker_hits) {
530 // std::cout<<lc_tracker_hit->id()<<" " <<trk_lc_tracker_hit->id()<<std::endl;
531 if (lc_tracker_hit->id() == trk_lc_tracker_hit->id()) return true;
532 }
533 return false;
534}
535
536bool utils::isUsedByTrack(TrackerHit* tracker_hit, EVENT::Track* lc_track) {
537 EVENT::TrackerHitVec trk_lc_tracker_hits = lc_track->getTrackerHits();
538
539 for (auto trk_lc_tracker_hit : trk_lc_tracker_hits) {
540 if (tracker_hit->getID() == trk_lc_tracker_hit->id()) return true;
541 }
542 return false;
543}
544
546 for (int ipart = 0; ipart < vtx->getParticles().GetEntries(); ++ipart) {
547 int pdg_id = ((Particle*)vtx->getParticles().At(ipart))->getPDG();
548 if (pdg_id == 11) {
549 ele = (Particle*)vtx->getParticles().At(ipart);
550 } else if (pdg_id == -11) {
551 pos = (Particle*)vtx->getParticles().At(ipart);
552 }
553
554 else {
555 std::cout << "Utilities::Wrong particle ID " << pdg_id << "associated to vertex. Skip." << std::endl;
556 return false;
557 }
558 }
559
560 if (!ele || !pos) {
561 std::cout << "Utilities::Vertex formed without ele/pos. Skip." << std::endl;
562 return false;
563 }
564
565 return true;
566}
567
568double utils::getKalmanTrackL1Isolations(Track* track, std::vector<TrackerHit*>* siClusters) {
569 double L1_axial_iso = 999999.9;
570 double L1_stereo_iso = 999999.9;
571 // Loop over hits on track
572 for (int i = 0; i < track->getSvtHits().GetEntries(); i++) {
573 TrackerHit* track_hit = (TrackerHit*)track->getSvtHits().At(i);
574 // Track hit info
575 int trackhit_id = track_hit->getID();
576 int trackhit_layer = track_hit->getLayer();
577 int trackhit_volume = track_hit->getVolume();
578 double trackhit_y = track_hit->getGlobalY();
579 double trackhit_charge = track_hit->getRawCharge();
580 double trackhit_time = track_hit->getTime();
581
582 // Only look at L1
583 if (trackhit_layer > 1) continue;
584
585 // Get rawhit strip information
586 std::vector<int> trackhit_rawhits = track_hit->getRawHitStripNumbers();
587 if (trackhit_rawhits.size() < 1) continue;
588 int trackhit_maxstrip = *max_element(trackhit_rawhits.begin(), trackhit_rawhits.end());
589 int trackhit_minstrip = *min_element(trackhit_rawhits.begin(), trackhit_rawhits.end());
590
591 // Isolation only calculated for axial sensors (sensitive to global y)
592 bool isAxial = false;
593 // Axial/Stereo Top/Bot mapping
594 if (trackhit_volume == 1) {
595 if (trackhit_layer % 2 == 1) isAxial = true;
596 }
597 if (trackhit_volume == 0) {
598 if (trackhit_layer % 2 == 0) isAxial = true;
599 }
600
601 // Loop over all SiClusters in event
602 // Find closest/best alternative SiCluster to track hit
603 TrackerHit* closest_althit = nullptr;
604 double isohit_dy = 999999.9;
605 double closest_dcharge = 99999.9;
606 double closest_dt = 999999.9;
607 double isohit_y = 999999.9;
608
609 if (siClusters == nullptr) return isohit_dy;
610 for (int j = 0; j < siClusters->size(); j++) {
611 TrackerHit* althit = siClusters->at(j);
612 int althit_id = althit->getID();
613 int althit_volume = althit->getVolume();
614 int althit_layer = althit->getLayer();
615 double althit_y = althit->getGlobalY();
616 double althit_charge = althit->getRawCharge();
617 double althit_time = althit->getTime();
618
619 // Skip if SiCluster not on same layer as track hit
620 if (althit_layer != trackhit_layer) continue;
621
622 // Skip if volume doesn't match
623 if (althit_volume != trackhit_volume) continue;
624
625 // Skip same hit
626 if (althit_id == trackhit_id) continue;
627
628 // Only look at hits that are further from beam-axis in Global Y
629 if ((trackhit_volume == 0 && althit_y < trackhit_y) || (trackhit_volume == 1 && althit_y > trackhit_y))
630 continue;
631
632 // Require alternative hits to be within +-30ns (based on SiClustersOnTrack t distr)
633 if (std::abs(althit_time) > 30.0) continue;
634
635 // Skip adjacent rawhits
636 std::vector<int> althit_rawhits = althit->getRawHitStripNumbers();
637 int althit_maxstrip = *max_element(althit_rawhits.begin(), althit_rawhits.end());
638 int althit_minstrip = *min_element(althit_rawhits.begin(), althit_rawhits.end());
639 if (trackhit_minstrip - althit_maxstrip <= 1 && althit_minstrip - trackhit_maxstrip <= 1) continue;
640
641 // Pick closest alternative hit
642 if (std::abs(trackhit_y - althit_y) < isohit_dy) {
643 isohit_dy = std::abs(trackhit_y - althit_y);
644 closest_althit = althit;
645 closest_dcharge = trackhit_charge - althit_charge;
646 closest_dt = trackhit_time - althit_time;
647 isohit_y = althit_y;
648 }
649 }
650
651 if (isAxial)
652 L1_axial_iso = isohit_dy;
653 else
654 L1_stereo_iso = isohit_dy;
655 }
656
657 if (L1_axial_iso < L1_stereo_iso) {
658 return L1_axial_iso;
659 } else
660 return L1_stereo_iso;
661}
662
663void utils::get2016KFMCTruthHitCodes(Track* ele_trk, Track* pos_trk, int& L1L2hitCode, int& L1hitCode, int& L2hitCode) {
664 // Count the number of hits per part on the ele track
665 std::map<int, int> nHits4part_ele;
666 for (int i = 0; i < ele_trk->getMcpHits().size(); i++) {
667 int partID = ele_trk->getMcpHits().at(i).second;
668 if (nHits4part_ele.find(partID) == nHits4part_ele.end()) {
669 // not found
670 nHits4part_ele[partID] = 1;
671 } else {
672 // found
673 nHits4part_ele[partID]++;
674 }
675 }
676
677 // Determine the MC part with the most hits on the track
678 int maxNHits_ele = 0;
679 int maxID_ele = 0;
680 for (std::map<int, int>::iterator it = nHits4part_ele.begin(); it != nHits4part_ele.end(); ++it) {
681 if (it->second > maxNHits_ele) {
682 maxNHits_ele = it->second;
683 maxID_ele = it->first;
684 }
685 }
686
687 // Count the number of hits per part on the pos track
688 std::map<int, int> nHits4part_pos;
689 for (int i = 0; i < pos_trk->getMcpHits().size(); i++) {
690 int partID = pos_trk->getMcpHits().at(i).second;
691 if (nHits4part_pos.find(partID) == nHits4part_pos.end()) {
692 // not found
693 nHits4part_pos[partID] = 1;
694 } else {
695 // found
696 nHits4part_pos[partID]++;
697 }
698 }
699
700 // Determine the MC part with the most hits on the track
701 int maxNHits_pos = 0;
702 int maxID_pos = 0;
703 for (std::map<int, int>::iterator it = nHits4part_pos.begin(); it != nHits4part_pos.end(); ++it) {
704 if (it->second > maxNHits_pos) {
705 maxNHits_pos = it->second;
706 maxID_pos = it->first;
707 }
708 }
709
710 // Determine Ele L1 and L2 truth information
711 bool ele_trueAxialL1 = false;
712 bool ele_trueStereoL1 = false;
713 bool ele_trueAxialL2 = false;
714 bool ele_trueStereoL2 = false;
715 bool pos_trueAxialL1 = false;
716 bool pos_trueStereoL1 = false;
717 bool pos_trueAxialL2 = false;
718 bool pos_trueStereoL2 = false;
719
720 if (ele_trk->isKalmanTrack()) {
721 for (int i = 0; i < ele_trk->getMcpHits().size(); i++) {
722 int mcpid = ele_trk->getMcpHits().at(i).second;
723 int layer = ele_trk->getMcpHits().at(i).first;
724 int volume = -1;
725 if (ele_trk->isTopTrack() == 1)
726 volume = 0;
727 else
728 volume = 1;
729
730 bool isAxial = false;
731 bool isStereo = false;
732 bool isL1 = false;
733 bool isL2 = false;
734 bool isGood = false;
735
736 // L1 and L2 only
737 if (layer < 2)
738 isL1 = true;
739 else if (layer > 1 && layer < 4)
740 isL2 = true;
741 else
742 continue;
743
744 if (volume == 1) {
745 if (layer % 2 == 1)
746 isAxial = true;
747 else
748 isStereo = true;
749 }
750 if (volume == 0) {
751 if (layer % 2 == 0)
752 isAxial = true;
753 else
754 isStereo = true;
755 }
756
757 if (mcpid == maxID_ele) isGood = true;
758
759 if (isGood) {
760 if (isAxial) {
761 if (isL1) ele_trueAxialL1 = true;
762 if (isL2) ele_trueAxialL2 = true;
763 }
764 if (isStereo) {
765 if (isL1) ele_trueStereoL1 = true;
766 if (isL2) ele_trueStereoL2 = true;
767 }
768 }
769 }
770 }
771
772 if (pos_trk->isKalmanTrack()) {
773 for (int i = 0; i < pos_trk->getMcpHits().size(); i++) {
774 int mcpid = pos_trk->getMcpHits().at(i).second;
775 int layer = pos_trk->getMcpHits().at(i).first;
776 int volume = -1;
777 if (pos_trk->isTopTrack() == 1)
778 volume = 0;
779 else
780 volume = 1;
781
782 bool isAxial = false;
783 bool isStereo = false;
784 bool isL1 = false;
785 bool isL2 = false;
786 bool isGood = false;
787
788 // L1 and L2 only
789 if (layer < 2)
790 isL1 = true;
791 else if (layer > 1 && layer < 4)
792 isL2 = true;
793 else
794 continue;
795
796 if (volume == 1) {
797 if (layer % 2 == 1)
798 isAxial = true;
799 else
800 isStereo = true;
801 }
802 if (volume == 0) {
803 if (layer % 2 == 0)
804 isAxial = true;
805 else
806 isStereo = true;
807 }
808
809 if (mcpid == maxID_pos) isGood = true;
810
811 if (isGood) {
812 if (isAxial) {
813 if (isL1) pos_trueAxialL1 = true;
814 if (isL2) pos_trueAxialL2 = true;
815 }
816 if (isStereo) {
817 if (isL1) pos_trueStereoL1 = true;
818 if (isL2) pos_trueStereoL2 = true;
819 }
820 }
821 }
822 }
823
824 // Require both Axial and Stereo truth hits to be 'Good' hit
825 if (ele_trueAxialL1 && ele_trueStereoL1) L1L2hitCode = L1L2hitCode | (0x1 << 3);
826 if (pos_trueAxialL1 && pos_trueStereoL1) L1L2hitCode = L1L2hitCode | (0x1 << 2);
827 if (ele_trueAxialL2 && ele_trueStereoL2) L1L2hitCode = L1L2hitCode | (0x1 << 1);
828 if (pos_trueAxialL2 && pos_trueStereoL2) L1L2hitCode = L1L2hitCode | (0x1 << 0);
829
830 // Set L1 axial/stereo hit code for ele and positron
831 if (ele_trueAxialL1) L1hitCode = L1hitCode | (0x1 << 3);
832 if (ele_trueStereoL1) L1hitCode = L1hitCode | (0x1 << 2);
833 if (pos_trueAxialL1) L1hitCode = L1hitCode | (0x1 << 1);
834 if (pos_trueStereoL1) L1hitCode = L1hitCode | (0x1 << 0);
835
836 // Set L2 axial/stereo hit code for ele and positron
837 if (ele_trueAxialL2) L2hitCode = L2hitCode | (0x1 << 3);
838 if (ele_trueStereoL2) L2hitCode = L2hitCode | (0x1 << 2);
839 if (pos_trueAxialL2) L2hitCode = L2hitCode | (0x1 << 1);
840 if (pos_trueStereoL2) L2hitCode = L2hitCode | (0x1 << 0);
841}
842
843double utils::v0_projection_to_target_significance(json v0proj_fits, int run, double& vtx_proj_x, double& vtx_proj_y,
844 double& vtx_proj_x_signif, double& vtx_proj_y_signif,
845 double& vtx_proj_x_centered, double& vtx_proj_y_centered,
846 double vtx_x, double vtx_y, double vtx_z, double vtx_px,
847 double vtx_py, double vtx_pz, bool debug) {
848 // V0 Projection fit parameters are calculated externally by projecting vertices to the target z position,
849 // and then fitting the 2D distribution vtx_x vs vtx_y with a rotated 2D Gaussian.
850 // The fit parameters are defined along the rotated coordinate system.
851 // Therefore, the vertex position must be rotated into this coordinate system before calculating significance.
852 // The rotation angle corresponding to the fit is provided in the json file containing the rotated fit values.
853
854 // Read v0 projection fits from json file
855 int closest_run = -1;
856 for (auto entry : v0proj_fits.items()) {
857 int check_run = std::stoi(entry.key());
858 if (check_run > run) {
859 // run predates every entry in the JSON; fall back to the earliest one available
860 if (closest_run < 0) closest_run = check_run;
861 break;
862 } else {
863 closest_run = check_run;
864 }
865 }
866 if (closest_run < 0)
867 throw std::runtime_error("v0_projection_to_target_significance: no run entries found in v0proj_fits JSON");
868 double target_pos = v0proj_fits[std::to_string(closest_run)]["target_position"];
869 double rot_mean_x = v0proj_fits[std::to_string(closest_run)]["rotated_mean_x"];
870 double rot_mean_y = v0proj_fits[std::to_string(closest_run)]["rotated_mean_y"];
871 double rot_sigma_x = v0proj_fits[std::to_string(closest_run)]["rotated_sigma_x"];
872 double rot_sigma_y = v0proj_fits[std::to_string(closest_run)]["rotated_sigma_y"];
873 double rotation_angle = (double)v0proj_fits[std::to_string(closest_run)]["rotation_angle_mrad"] / 1000.0;
874
875 if (debug) {
876 std::cout << "[v0proj debug] run=" << run << " -> closest_run=" << closest_run << std::endl;
877 std::cout << "[v0proj debug] calibration constants:"
878 << " target_pos=" << target_pos
879 << " rot_mean_x=" << rot_mean_x
880 << " rot_mean_y=" << rot_mean_y
881 << " rot_sigma_x=" << rot_sigma_x
882 << " rot_sigma_y=" << rot_sigma_y
883 << " rotation_angle_mrad=" << rotation_angle * 1000.0
884 << " rotation_angle_rad=" << rotation_angle << std::endl;
885 std::cout << "[v0proj debug] input vertex:"
886 << " vtx_x=" << vtx_x
887 << " vtx_y=" << vtx_y
888 << " vtx_z=" << vtx_z
889 << " vtx_px=" << vtx_px
890 << " vtx_py=" << vtx_py
891 << " vtx_pz=" << vtx_pz << std::endl;
892 }
893
894 // project vertex to target position
895 vtx_proj_x = vtx_x - ((vtx_z - target_pos) * (vtx_px / vtx_pz));
896 vtx_proj_y = vtx_y - ((vtx_z - target_pos) * (vtx_py / vtx_pz));
897
898 if (debug) {
899 std::cout << "[v0proj debug] projection:"
900 << " dz=(vtx_z - target_pos)=" << (vtx_z - target_pos)
901 << " dx_correction=" << ((vtx_z - target_pos) * (vtx_px / vtx_pz))
902 << " dy_correction=" << ((vtx_z - target_pos) * (vtx_py / vtx_pz))
903 << " vtx_proj_x=" << vtx_proj_x
904 << " vtx_proj_y=" << vtx_proj_y << std::endl;
905 }
906
907 // Rotate projected vertex by angle corresponding to run number
908 double rot_vtx_proj_x = vtx_proj_x * std::cos(rotation_angle) - vtx_proj_y * std::sin(rotation_angle);
909 double rot_vtx_proj_y = vtx_proj_x * std::sin(rotation_angle) + vtx_proj_y * std::cos(rotation_angle);
910
911 if (debug) {
912 std::cout << "[v0proj debug] after rotation:"
913 << " rot_vtx_proj_x=" << rot_vtx_proj_x
914 << " rot_vtx_proj_y=" << rot_vtx_proj_y << std::endl;
915 }
916
917 // Calculate mean-subtracted rotated components and significance
918 vtx_proj_x_centered = rot_vtx_proj_x - rot_mean_x;
919 vtx_proj_y_centered = rot_vtx_proj_y - rot_mean_y;
920 vtx_proj_x_signif = vtx_proj_x_centered / rot_sigma_x;
921 vtx_proj_y_signif = vtx_proj_y_centered / rot_sigma_y;
922
923 double significance = std::sqrt(vtx_proj_x_signif * vtx_proj_x_signif + vtx_proj_y_signif * vtx_proj_y_signif);
924
925 if (debug) {
926 std::cout << "[v0proj debug] significance:"
927 << " vtx_proj_x_centered=" << vtx_proj_x_centered
928 << " vtx_proj_y_centered=" << vtx_proj_y_centered
929 << " vtx_proj_x_signif=" << vtx_proj_x_signif
930 << " vtx_proj_y_signif=" << vtx_proj_y_signif
931 << " significance=" << significance << std::endl;
932 }
933
934 return significance;
935}
936
937double utils::v0_projection_to_target_significance(json v0proj_fits, int run, double& vtx_proj_x, double& vtx_proj_y,
938 double& vtx_proj_x_signif, double& vtx_proj_y_signif, Vertex* vtx,
939 double& vtx_proj_x_err, double& vtx_proj_y_err,
940 double& vtx_proj_x_centered, double& vtx_proj_y_centered,
941 bool debug) {
942 // Read v0 projection fits from json file
943 int closest_run = -1;
944 for (auto entry : v0proj_fits.items()) {
945 int check_run = std::stoi(entry.key());
946 if (check_run > run) {
947 // run predates every entry in the JSON; fall back to the earliest one available
948 if (closest_run < 0) closest_run = check_run;
949 break;
950 } else {
951 closest_run = check_run;
952 }
953 }
954 if (closest_run < 0)
955 throw std::runtime_error("v0_projection_to_target_significance: no run entries found in v0proj_fits JSON");
956 double target_pos = v0proj_fits[std::to_string(closest_run)]["target_position"];
957 double rot_mean_x = v0proj_fits[std::to_string(closest_run)]["rotated_mean_x"];
958 double rot_mean_y = v0proj_fits[std::to_string(closest_run)]["rotated_mean_y"];
959 double rot_sigma_x = v0proj_fits[std::to_string(closest_run)]["rotated_sigma_x"];
960 double rot_sigma_y = v0proj_fits[std::to_string(closest_run)]["rotated_sigma_y"];
961 double rotation_angle =
962 (double)v0proj_fits[std::to_string(closest_run)]["rotation_angle_mrad"] / 1000.0; // convert mrad to rad
963
964 // get target projected vertex position
965 double vtx_tgt_x = vtx->getTgtProjX();
966 double vtx_tgt_x_err = vtx->getTgtProjSigmaX();
967 double vtx_tgt_y = vtx->getTgtProjY();
968 double vtx_tgt_y_err = vtx->getTgtProjSigmaY();
969
970 vtx_proj_x = vtx_tgt_x;
971 vtx_proj_y = vtx_tgt_y;
972 vtx_proj_x_err = vtx_tgt_x_err;
973 vtx_proj_y_err = vtx_tgt_y_err;
974
975 if (debug) {
976 std::cout << "[v0proj debug] run=" << run << " -> closest_run=" << closest_run << std::endl;
977 std::cout << "[v0proj debug] calibration constants:"
978 << " target_pos=" << target_pos
979 << " rot_mean_x=" << rot_mean_x
980 << " rot_mean_y=" << rot_mean_y
981 << " rot_sigma_x=" << rot_sigma_x
982 << " rot_sigma_y=" << rot_sigma_y
983 << " rotation_angle_mrad=" << rotation_angle * 1000.0
984 << " rotation_angle_rad=" << rotation_angle << std::endl;
985 std::cout << "[v0proj debug] vertex tgt projection (from Vertex object):"
986 << " vtx_tgt_x=" << vtx_tgt_x
987 << " vtx_tgt_x_err=" << vtx_tgt_x_err
988 << " vtx_tgt_y=" << vtx_tgt_y
989 << " vtx_tgt_y_err=" << vtx_tgt_y_err << std::endl;
990 }
991
992 // Rotate projected vertex by angle corresponding to run number
993 double rot_vtx_proj_x = vtx_proj_x * std::cos(rotation_angle) - vtx_proj_y * std::sin(rotation_angle);
994 double rot_vtx_proj_y = vtx_proj_x * std::sin(rotation_angle) + vtx_proj_y * std::cos(rotation_angle);
995
996 if (debug) {
997 std::cout << "[v0proj debug] after rotation:"
998 << " rot_vtx_proj_x=" << rot_vtx_proj_x
999 << " rot_vtx_proj_y=" << rot_vtx_proj_y << std::endl;
1000 }
1001
1002 // Calculate mean-subtracted rotated components and significance
1003 // (sigma includes vertex position error added in quadrature)
1004 double sigma_x = std::sqrt(rot_sigma_x * rot_sigma_x + vtx_tgt_x_err * vtx_tgt_x_err);
1005 double sigma_y = std::sqrt(rot_sigma_y * rot_sigma_y + vtx_tgt_y_err * vtx_tgt_y_err);
1006 vtx_proj_x_centered = rot_vtx_proj_x - rot_mean_x;
1007 vtx_proj_y_centered = rot_vtx_proj_y - rot_mean_y;
1008 vtx_proj_x_signif = vtx_proj_x_centered / sigma_x;
1009 vtx_proj_y_signif = vtx_proj_y_centered / sigma_y;
1010
1011 double significance = std::sqrt(vtx_proj_x_signif * vtx_proj_x_signif + vtx_proj_y_signif * vtx_proj_y_signif);
1012
1013 if (debug) {
1014 std::cout << "[v0proj debug] significance:"
1015 << " sigma_x(combined)=" << sigma_x
1016 << " sigma_y(combined)=" << sigma_y
1017 << " vtx_proj_x_centered=" << vtx_proj_x_centered
1018 << " vtx_proj_y_centered=" << vtx_proj_y_centered
1019 << " vtx_proj_x_signif=" << vtx_proj_x_signif
1020 << " vtx_proj_y_signif=" << vtx_proj_y_signif
1021 << " significance=" << significance << std::endl;
1022 }
1023
1024 return significance;
1025}
1026
1027void utils::debug_target_projection(double target_pos, Vertex* vtx) {
1028 // LCIO-stored values
1029 double lcio_x = vtx->getTgtProjX();
1030 double lcio_x_err = vtx->getTgtProjSigmaX();
1031 double lcio_y = vtx->getTgtProjY();
1032 double lcio_y_err = vtx->getTgtProjSigmaY();
1033
1034 // Manually project: walk from vtx position along momentum to target_pos in z
1035 TVector3 p = vtx->getP();
1036 double vtx_x = vtx->getX();
1037 double vtx_y = vtx->getY();
1038 double vtx_z = vtx->getZ();
1039 double dz = vtx_z - target_pos;
1040 double manual_x = vtx_x - dz * (p.X() / p.Z());
1041 double manual_y = vtx_y - dz * (p.Y() / p.Z());
1042
1043 std::cout << "[tgt_proj_debug]"
1044 << " target_pos=" << target_pos
1045 << " vtx_z=" << vtx_z
1046 << " dz=" << dz << std::endl;
1047 std::cout << "[tgt_proj_debug] LCIO : x=" << lcio_x
1048 << " x_err=" << lcio_x_err
1049 << " y=" << lcio_y
1050 << " y_err=" << lcio_y_err << std::endl;
1051 std::cout << "[tgt_proj_debug] manual : x=" << manual_x
1052 << " y=" << manual_y
1053 << " (px/pz=" << p.X()/p.Z()
1054 << " py/pz=" << p.Y()/p.Z() << ")" << std::endl;
1055 std::cout << "[tgt_proj_debug] delta : dx=" << (manual_x - lcio_x)
1056 << " dy=" << (manual_y - lcio_y) << std::endl;
1057}
nlohmann::json json
void setPosition(const float *position)
void setEnergy(const double energy)
Definition CalCluster.h:70
void setTime(const double time)
Definition CalCluster.h:80
void setGoodnessOfPID(const double goodness_pid)
Definition Particle.h:84
void setPDG(const int pdg)
Definition Particle.h:98
void setMass(const double mass)
Definition Particle.h:112
void setCharge(const int charge)
Definition Particle.h:77
void setType(const int type)
Definition Particle.h:91
void setMomentum(const double *momentum)
Definition Particle.cxx:23
void setTrack(Track *track)
Definition Particle.h:42
void setEnergy(const double energy)
Definition Particle.h:105
void setCluster(CalCluster *cluster)
Definition Particle.h:56
void setBarrel(int barrel)
Definition RawSvtHit.cxx:48
void setSystem(int system)
Definition RawSvtHit.cxx:44
void setFit(double fit[5], int fitI)
Definition RawSvtHit.cxx:27
int getLayer()
Definition RawSvtHit.cxx:88
void setStrip(int strip)
Definition RawSvtHit.cxx:68
void setSensor(int sensor)
Definition RawSvtHit.cxx:60
void setSide(int side)
Definition RawSvtHit.cxx:64
double getAmp(int fitI)
Definition RawSvtHit.h:101
void setADCs(int adcs[6])
Definition RawSvtHit.cxx:35
int getModule()
Definition RawSvtHit.cxx:92
void setFitN(int fitN)
Definition RawSvtHit.cxx:23
void setLayer(int layer)
Definition RawSvtHit.cxx:52
void setModule(int module)
Definition RawSvtHit.cxx:56
Definition Track.h:32
bool isKalmanTrack() const
Definition Track.h:233
bool isTopTrack() const
Definition Track.h:332
double getPhi() const
Definition Track.h:88
double getChi2Ndf() const
Definition Track.h:128
double getOmega() const
Definition Track.h:90
double getD0() const
Definition Track.h:87
double getTanLambda() const
Definition Track.h:92
std::vector< std::pair< int, int > > getMcpHits()
Definition Track.h:105
double getZ0() const
Definition Track.h:93
double getGlobalY() const
Definition TrackerHit.h:53
void setLayer(const int layer)
Definition TrackerHit.h:106
int getLayer() const
Definition TrackerHit.h:109
void setVolume(const int volume)
Definition TrackerHit.h:100
void addRawHit(TObject *rawhit)
Definition TrackerHit.h:115
void setCovarianceMatrix(std::vector< float > cov)
void setID(const int id)
Definition TrackerHit.h:122
std::vector< int > getRawHitStripNumbers()
Definition TrackerHit.h:130
void setRawHitStripNumbers(std::vector< int > rawhit_strips)
Definition TrackerHit.h:133
void setRawCharge(const double rawcharge)
Definition TrackerHit.h:95
int getID() const
Definition TrackerHit.h:124
void setCharge(const double charge)
Definition TrackerHit.h:90
int getVolume()
Definition TrackerHit.h:103
double getRawCharge() const
Definition TrackerHit.h:98
void setTime(const double time)
Definition TrackerHit.h:73
void setPosition(const double *position, bool rotate=false, int type=0)
double getTime() const
Definition TrackerHit.h:83
void setPos(const float *pos, bool rotate=false)
Definition Vertex.cxx:39
void setVtxParameters(const std::vector< float > &parameters)
Definition Vertex.cxx:81
void setID(const int id)
Definition Vertex.h:83
void setType(const std::string &type)
Definition Vertex.h:80
void setProbability(const float probability)
Definition Vertex.h:92
void setCovariance(const std::vector< float > &vec)
Definition Vertex.cxx:35
void setChi2(const double chi2)
Definition Vertex.h:45
constexpr const char * TRACK_DATA
Definition Collections.h:41
bool addRawInfoTo3dHit(TrackerHit *tracker_hit, IMPL::TrackerHitImpl *lc_tracker_hit, EVENT::LCCollection *raw_svt_fits, std::vector< RawSvtHit * > *rawHits=nullptr, int type=0, bool storeRawHit=true)
description
CalCluster * buildCalCluster(EVENT::Cluster *lc_cluster)
description
Definition utilities.cxx:95
Track * buildTrack(EVENT::Track *lc_track, std::string trackstate_location, EVENT::LCCollection *gbl_kink_data, EVENT::LCCollection *track_data)
description
Vertex * buildVertex(EVENT::Vertex *lc_vertex)
description
Definition utilities.cxx:27
bool hasCollection(EVENT::LCEvent *lc_event, const std::string &collection)
description
Definition utilities.cxx:18
void debug_target_projection(double target_pos, Vertex *vtx)
bool isUsedByTrack(IMPL::TrackerHitImpl *lc_tracker_hit, EVENT::Track *lc_track)
description
TrackerHit * buildTrackerHit(IMPL::TrackerHitImpl *lc_trackerHit, bool rotate=true, int type=0)
description
double getKalmanTrackL1Isolations(Track *track, std::vector< TrackerHit * > *siClusters)
description
static UTIL::BitField64 decoder("system:6,barrel:3,layer:4,module:12,sensor:1,side:32:-2,strip:12")
description
bool getParticlesFromVertex(Vertex *vtx, Particle *ele, Particle *pos)
description
Particle * buildParticle(EVENT::ReconstructedParticle *lc_particle, std::string trackstate_location, EVENT::LCCollection *gbl_kink_data, EVENT::LCCollection *track_data)
description
Definition utilities.cxx:47
void get2016KFMCTruthHitCodes(Track *ele_trk, Track *pos_trk, int &L1L2hitCode, int &L1hitCode, int &L2hitCode)
description
bool IsSameTrack(Track *trk1, Track *trk2)
description
double v0_projection_to_target_significance(json v0proj_fits, int run, double &vtx_proj_x, double &vtx_proj_y, double &vtx_proj_x_signif, double &vtx_proj_y_signif, double &vtx_proj_x_centered, double &vtx_proj_y_centered, double vtx_x, double vtx_y, double vtx_z, double vtx_px, double vtx_py, double vtx_pz, bool debug=false)
description
RawSvtHit * buildRawHit(EVENT::TrackerRawData *rawTracker_hit, EVENT::LCCollection *raw_svt_hit_fits)