30 return StatusCode::SUCCESS;
37 m_tree =
new TTree(
"FPGATrackSimHoughRootOutput",
"FPGATrackSimHoughRootOutput");
81 m_truthtree =
new TTree(
"FPGATrackSimTruthTree",
"FPGATrackSimTruthTree");
110 m_offlinetree =
new TTree(
"FPGATrackSimOfflineTree",
"FPGATrackSimOfflineTree");
132 return StatusCode::SUCCESS;
136 StatusCode FPGATrackSimHoughRootOutputTool::fillTree(
const std::vector<FPGATrackSimTrack> &track_cands,
const std::vector<FPGATrackSimTruthTrack> &truthTracks,
const std::vector<FPGATrackSimOfflineTrack> &offlineTracks,
const std::vector<std::shared_ptr<const FPGATrackSimHit>> &hits_2nd,
const bool writeOutNonSPStripHits,
const bool roadsAreSecondStage)
143 if (roadsAreSecondStage) {
148 std::vector<float> tmp_hits_x;
149 std::vector<float> tmp_hits_y;
150 std::vector<float> tmp_hits_z;
151 std::vector<float> tmp_hits_R;
152 std::vector<float> tmp_hits_phi;
153 std::vector<int> tmp_hits_layer_disk;
154 std::vector<bool> tmp_hits_mapped;
155 std::vector<bool> tmp_hits_isPixel;
156 std::vector<bool> tmp_hits_isStrip;
157 std::vector<bool> tmp_hits_isClustered;
158 std::vector<bool> tmp_hits_isSpacepoint;
159 std::vector<float> tmp_hits_barcodefrac;
160 std::vector<int> tmp_hits_barcode;
161 std::vector<float> tmp_hits_zIdeal;
162 std::vector<float> tmp_hits_gphiIdeal;
163 std::vector<long> tmp_hits_fineID;
164 std::vector<int> tmp_hits_volumeID;
166 std::vector<float> tmp_hits_x_sorted;
167 std::vector<float> tmp_hits_y_sorted;
168 std::vector<float> tmp_hits_z_sorted;
169 std::vector<float> tmp_hits_R_sorted;
170 std::vector<float> tmp_hits_phi_sorted;
171 std::vector<int> tmp_hits_layer_disk_sorted;
172 std::vector<bool> tmp_hits_isPixel_sorted;
173 std::vector<bool> tmp_hits_isStrip_sorted;
174 std::vector<bool> tmp_hits_isClustered_sorted;
175 std::vector<bool> tmp_hits_isSpacepoint_sorted;
176 std::vector<float> tmp_hits_barcodefrac_sorted;
177 std::vector<int> tmp_hits_barcode_sorted;
178 std::vector<float> tmp_hits_zIdeal_sorted;
179 std::vector<float> tmp_hits_gphiIdeal_sorted;
180 std::vector<long> tmp_hits_fineID_sorted;
181 std::vector<int> tmp_hits_volumeID_sorted;
183 std::vector<bool> tmp_hits_mapped_sorted;
184 bool has_strip_nonspacepoint;
189 for (
const auto &
track : truthTracks) {
191 if (
track.getStatus() != 1)
continue;
198 tmp_hits_phi.clear();
199 tmp_hits_layer_disk.clear();
200 tmp_hits_mapped.clear();
201 tmp_hits_isPixel.clear();
202 tmp_hits_isStrip.clear();
203 tmp_hits_isClustered.clear();
204 tmp_hits_isSpacepoint.clear();
205 tmp_hits_barcodefrac.clear();
206 tmp_hits_barcode.clear();
207 tmp_hits_zIdeal.clear();
208 tmp_hits_gphiIdeal.clear();
209 tmp_hits_fineID.clear();
211 tmp_hits_x_sorted.clear();
212 tmp_hits_y_sorted.clear();
213 tmp_hits_z_sorted.clear();
214 tmp_hits_R_sorted.clear();
215 tmp_hits_phi_sorted.clear();
216 tmp_hits_layer_disk_sorted.clear();
217 tmp_hits_mapped_sorted.clear();
218 tmp_hits_isPixel_sorted.clear();
219 tmp_hits_isStrip_sorted.clear();
220 tmp_hits_isClustered_sorted.clear();
221 tmp_hits_isSpacepoint_sorted.clear();
222 tmp_hits_barcodefrac_sorted.clear();
223 tmp_hits_barcode_sorted.clear();
224 tmp_hits_zIdeal_sorted.clear();
225 tmp_hits_gphiIdeal_sorted.clear();
226 tmp_hits_fineID_sorted.clear();
227 tmp_hits_volumeID.clear();
229 has_strip_nonspacepoint =
false;
232 std::vector<float> idealized_coords;
237 for (
auto hit : hits_2nd) {
239 if (hit->getBarcode() ==
track.getBarcode()) {
241 if (hit->isPixel() == 0 && hit->getHitType() !=
HitType::spacepoint) {has_strip_nonspacepoint =
true;}
246 const bool ok = truth.
best(tbarcode, tfrac);
247 if (tfrac < 1.0) {
continue; }
249 tmp_hits_barcode.push_back((
int)(tbarcode.second));
250 tmp_hits_barcodefrac.push_back(tfrac);
253 tmp_hits_barcode.push_back(-1);
254 tmp_hits_barcodefrac.push_back(-1);
257 tmp_hits_x.push_back(hit->getX());
258 tmp_hits_y.push_back(hit->getY());
259 tmp_hits_z.push_back(hit->getZ());
260 tmp_hits_R.push_back(hit->getR());
261 tmp_hits_phi.push_back(hit->getGPhi());
262 tmp_hits_layer_disk.push_back(hit->getLayerDisk());
264 tmp_hits_mapped.push_back(hit->isMapped());
265 tmp_hits_isPixel.push_back(hit->isPixel());
266 tmp_hits_isStrip.push_back(hit->isStrip());
267 tmp_hits_isClustered.push_back(hit->isClustered());
269 tmp_hits_fineID.push_back(
getFineID(*hit));
273 tmp_hits_zIdeal.push_back(idealized_coords[0]);
274 tmp_hits_gphiIdeal.push_back(idealized_coords[1]);
277 tmp_hits_isSpacepoint.push_back(
true);
280 tmp_hits_isSpacepoint.push_back(
false);
288 if ( (! writeOutNonSPStripHits & has_strip_nonspacepoint)) {
289 ATH_MSG_DEBUG(
"Truth Track is not written to HoughRootOutput file, because it contains a non-SP strip hit!");
293 std::vector<int> sorting_index(tmp_hits_R.size(), 0);
294 for (
unsigned int i = 0 ;
i != sorting_index.size() ;
i++) {
295 sorting_index[
i] =
i;
297 sort(sorting_index.begin(), sorting_index.end(),
298 [&](
const int&
a,
const int&
b) {
299 return (tmp_hits_R[a] < tmp_hits_R[b]);
303 for (
unsigned int i = 0 ;
i != sorting_index.size() ;
i++) {
304 tmp_hits_x_sorted.push_back(tmp_hits_x[sorting_index[
i]]);
305 tmp_hits_y_sorted.push_back(tmp_hits_y[sorting_index[
i]]);
306 tmp_hits_z_sorted.push_back(tmp_hits_z[sorting_index[
i]]);
307 tmp_hits_R_sorted.push_back(tmp_hits_R[sorting_index[
i]]);
308 tmp_hits_phi_sorted.push_back(tmp_hits_phi[sorting_index[
i]]);
309 tmp_hits_layer_disk_sorted.push_back(tmp_hits_layer_disk[sorting_index[
i]]);
310 tmp_hits_isPixel_sorted.push_back(tmp_hits_isPixel[sorting_index[
i]]);
311 tmp_hits_isStrip_sorted.push_back(tmp_hits_isStrip[sorting_index[
i]]);
312 tmp_hits_isClustered_sorted.push_back(tmp_hits_isClustered[sorting_index[
i]]);
313 tmp_hits_isSpacepoint_sorted.push_back(tmp_hits_isSpacepoint[sorting_index[
i]]);
314 tmp_hits_barcode_sorted.push_back(tmp_hits_barcode[sorting_index[
i]]);
315 tmp_hits_barcodefrac_sorted.push_back(tmp_hits_barcodefrac[sorting_index[
i]]);
316 tmp_hits_zIdeal_sorted.push_back(tmp_hits_zIdeal[sorting_index[
i]]);
317 tmp_hits_gphiIdeal_sorted.push_back(tmp_hits_gphiIdeal[sorting_index[
i]]);
318 tmp_hits_fineID_sorted.push_back(tmp_hits_fineID[sorting_index[
i]]);
319 tmp_hits_volumeID_sorted.push_back(tmp_hits_volumeID[sorting_index[
i]]);
320 tmp_hits_mapped_sorted.push_back(tmp_hits_mapped[sorting_index[
i]]);
360 for (
const auto &
track : offlineTracks) {
372 int nhole(0), nmeasurement(0), ninert(0), nbrem(0), nscatter(0), nperigee(0), noutlier(0), nother(0);
373 for (
const auto& hit :
track.getOfflineHits()) {
396 std::vector<FPGATrackSimMultiTruth> mtv;
400 for (
size_t iroad = 0; iroad < track_cands.size(); iroad++) {
404 if (roadsAreSecondStage) {
411 m_roadChi2.push_back(track_cands[iroad].getChi2ndof());
430 mtv.push_back( truth );
434 const bool ok = truth.
best(tbarcode,tfrac);
437 m_barcode.push_back((
int)(tbarcode.second));
447 std::shared_ptr<const FPGATrackSimHit> hit_ptr = std::make_shared<const FPGATrackSimHit>(hit);
450 m_x.push_back(hit.getX());
451 m_y.push_back(hit.getY());
452 m_z.push_back(hit.getZ());
456 m_etaID.push_back(hit.getEtaModule());
458 m_gphi.push_back(hit.getGPhi());
459 m_zIdeal.push_back(idealized_coords[0]);
461 m_isPixel.push_back(hit.isPixel() ? 1 : 0);
462 m_layer.push_back(hit.getLayer());
468 m_ID.push_back(hit.getIdentifierHash());
479 const bool ok = mt.
best(tbarcode,tfrac);
500 return StatusCode::SUCCESS;
505 StatusCode FPGATrackSimHoughRootOutputTool::fillTree(
const std::vector<std::shared_ptr<const FPGATrackSimRoad>> &roads,
const std::vector<FPGATrackSimTruthTrack> &truthTracks,
const std::vector<FPGATrackSimOfflineTrack> &offlineTracks,
const std::vector<std::shared_ptr<const FPGATrackSimHit>> &hits_2nd,
const bool writeOutNonSPStripHits,
const float minChi2,
const int maxOverlappingHits,
const bool roadsAreSecondStage)
511 std::vector<FPGATrackSimTrack> track_cands;
513 for (
size_t iroad = 0; iroad < roads.size(); iroad++) {
515 std::shared_ptr<const FPGATrackSimRoad> road = roads[iroad];
516 std::vector<FPGATrackSimTrack> track_cand;
517 if (road ==
nullptr)
continue;
521 if (roadsAreSecondStage) {
539 if (roadsAreSecondStage) {
559 for (
auto const &tr : track_cand) {
560 track_cands.push_back(tr);
566 for (
auto const &cand : track_cands) {
567 if (cand.passedOR()) {
574 return fillTree(track_cands, truthTracks, offlineTracks, hits_2nd, writeOutNonSPStripHits, roadsAreSecondStage);