11 #include "GaudiKernel/MsgStream.h"
12 #include "GaudiKernel/ITHistSvc.h"
87 ATH_MSG_INFO(
"Hough constants method needs idealized geometry > 0, aborting.");
88 return StatusCode::FAILURE;
114 ATH_MSG_ERROR(
"q/pt bin information not set in matrix element job options!");
115 return StatusCode::FAILURE;
124 return StatusCode::SUCCESS;
178 m_h_trackQoP_okHits =
new TH1I(
"h_trackQoP_okHits",
"half inverse pt of tracks passing hit check",
180 m_h_trackQoP_okRegion =
new TH1I(
"h_trackQoP_okRegion",
"half inverse pt of tracks passing region check",
182 m_h_nHit =
new TH1I(
"h_nHit",
"number of hits in sector", 100, 0, 100);
188 return StatusCode::SUCCESS;
216 if (tracks.empty()) {
218 return StatusCode::SUCCESS;
221 std::map<int, std::vector<FPGATrackSimHit>> barcode_hits =
makeBarcodeMap(
hits, tracks);
229 std::vector<FPGATrackSimHit> & sector_hits = barcode_hits[
track.getBarcode()];
235 for (
int iSlice = 0; iSlice<nSlices; iSlice++){
238 for (
auto & iHit : sector_hits) {
258 std::vector<std::shared_ptr<const FPGATrackSimRoad>> houghRoads;
261 std::vector<std::shared_ptr<const FPGATrackSimHit>> phits;
263 ATH_MSG_DEBUG(
"Starting from some number of sector hits = " << sector_hits.size());
264 for (
const FPGATrackSimHit& hit : sector_hits)
if (hit.isMapped() && hit.isReal()) phits.emplace_back(std::make_shared<const FPGATrackSimHit>(hit));
265 ATH_MSG_DEBUG(
"Passing nhits = " << phits.size() <<
" to road finder");
273 std::vector<FPGATrackSimTrack> tracks_1st;
279 ATH_MSG_DEBUG(
"We found " << tracks_1st.size() <<
" combinations");
281 for (
const auto& track_comb : tracks_1st) {
282 std::vector<FPGATrackSimHit> track_hits = track_comb.getFPGATrackSimHits();
289 std::vector<FPGATrackSimHit> hits_2nd;
290 std::vector<std::shared_ptr<const FPGATrackSimHit>> phits_2nd;
296 if (!success)
continue;
298 for (
const auto& hit : hits_2nd) {
299 phits_2nd.push_back(std::make_shared<const FPGATrackSimHit>(hit));
303 std::vector<std::shared_ptr<const FPGATrackSimRoad>> roads_2nd;
304 std::vector<std::shared_ptr<const FPGATrackSimTrack>> ptracks_1st;
305 ptracks_1st.reserve(tracks_1st.size());
306 for (
const auto&
track : tracks_1st) {
307 ptracks_1st.push_back(std::make_shared<const FPGATrackSimTrack>(
track));
310 for (
auto road_2nd : roads_2nd) {
313 acc.pars.qOverPt = road_2nd->getY();
314 acc.pars.phi = road_2nd->getX();
317 std::vector<std::shared_ptr<const FPGATrackSimHit>> phits;
331 double y = track_comb.getHoughY();
332 double x = track_comb.getHoughX();
336 acc.pars.qOverPt =
y;
369 return StatusCode::SUCCESS;
375 for (
const std::shared_ptr<const FPGATrackSimRoad>& road : houghRoads) {
390 std::vector<std::vector<int>> combs =
getComboIndices(road->getNHits_layer());
391 unsigned existing_size = track_cands.size();
392 track_cands.resize(existing_size + combs.size(), temp);
397 for (
size_t icomb = 0; icomb < combs.size(); icomb++)
399 track_cands[existing_size + icomb].setNLayers(
m_FPGATrackSimMapping->PlaneMap_1st(0)->getNLogiLayers());
400 std::vector<int>
const & hit_indices = combs[icomb];
403 if (hit_indices[
layer] < 0)
411 if (wcbits & (1 <<
layer ) ) {
416 track_cands[existing_size + icomb].setFPGATrackSimHit(
layer, newhit);
420 const std::shared_ptr<const FPGATrackSimHit> hit = road->getHits(
layer)[hit_indices[
layer]];
426 const FPGATrackSimHit inner_hit = track_cands[existing_size + icomb].getFPGATrackSimHits().at(
layer - 1);
428 track_cands[existing_size + icomb].setValidCand(
false);
431 track_cands[existing_size + icomb].setFPGATrackSimHit(
layer, *hit);
442 std::vector<FPGATrackSimHit>
hits;
455 std::vector<FPGATrackSimCluster> clustered_hits;
461 std::vector<FPGATrackSimCluster> spacepoints;
467 std::vector<FPGATrackSimTowerInputHeader>
towers = logicalHeader.
towers();
468 for (
auto &tower :
towers) {
469 std::vector<FPGATrackSimHit>
const & towerHits = tower.hits();
481 std::vector<FPGATrackSimTruthTrack> training_tracks;
491 double pt_GeV =
pt / 1000;
499 double eta = TMath::ASinH(
track.getPZ() /
pt);
505 <<
" pdgcode = " <<
track.getPDGCode());
510 return training_tracks;
517 std::map<int, std::vector<FPGATrackSimHit>> map;
521 map[
track.getBarcode()] = std::vector<FPGATrackSimHit>();
526 int barcode = hit.getTruth().best_barcode();
530 if (
it != map.end()) (*it).second.push_back(hit);
569 if (old_section == new_section) {
575 rmax = phi_max - phi_min;
581 rmax = phi_max - phi_min;
617 if (old_isEC != new_isEC) {
623 else if (old_disk == new_disk) {
625 ATH_MSG_DEBUG(
"Two modules hit in same physical disk " << old_disk);
630 ATH_MSG_DEBUG(
"Keeping the lower-z of the two disks (" << old_disk <<
", " << new_disk <<
") hit");
650 sector_hits.resize(nLayers, nohit);
651 std::vector<int> layer_count(nLayers);
654 if (!hit.isReal() || !hit.isMapped())
continue;
658 if (
rmap->getRegions(hit).size() == 0) {
661 int layer = hit.getLayer();
662 if (layer_count[
layer] == 0){
663 layer_count[
layer]++;
664 sector_hits[
layer] = hit;
666 else if (layer_count[
layer] == 1) {
667 layer_count[
layer]++;
678 ATH_MSG_DEBUG(
"Too many hits on a plane, exiting filterHitsSec");
689 for (
int i = 0;
i < nLayers; ++
i)
691 if (layer_count[
i] == 0)
701 if (sector_hits[
i].isPixel()) {
708 ATH_MSG_DEBUG(
"Found " << num_sp <<
" spacepoints after removing duplicates.");
720 if (num_sp < minSpacePlusPixel) {
721 ATH_MSG_DEBUG(
"Not enough pixel hits + spacepoints (" << num_sp <<
" < " << minSpacePlusPixel <<
")");
733 std::vector<bool> region_mask(
m_nRegions,
true);
737 for (
int region = 0; region <
m_nRegions; region++) {
740 region_mask[region] =
false;
744 region_mask[region] =
false;
751 for (
int region = 0; region <
m_nRegions; region++) {
752 if (region_mask[region])
767 for (
auto module : modules) {
783 sector_hits[
layer] = *wcHit;
787 unsigned other_layer = 0;
790 other_backup = sector_hits[other_layer];
800 if (
sc != StatusCode::SUCCESS){
802 ATH_MSG_ERROR(
"FPGATrackSimMatrixGenAlgo::fillAccumulatorByDropping; makeAccumulator failed");
803 return StatusCode::FAILURE;
805 accumulate(map, new_modules_acc.first, new_modules_acc.second);
808 sector_hits[
layer] = backup_hit;
813 sector_hits[other_layer] = other_backup;
817 return StatusCode::SUCCESS;
829 std::vector<module_t> modules(nLayers);
835 double qoverpt =
track.getQ() /
track.getPt();
847 std::string module_printout =
"";
848 for (
int i = 0;
i < nLayers;
i++)
850 if (sector_hits[
i].isReal()) {
851 if (
m_single) modules[
i] = sector_hits[
i].getIdentifierHash();
853 modules[
i] = sectorbin;
867 ATH_MSG_DEBUG(
"Generating track in sectorbin = " << sectorbin <<
" with modules: " << module_printout);
871 const int ToKeep[13] = {2200,2564,2861,3831,5368,14169,14173,20442,20446,29625,29629,42176,42180};
872 bool keepThis =
true;
873 for (
int i = 0;
i < 13;
i++) {
874 if (modules[
i] != ToKeep[
i] && modules[
i] != -1) {
880 for (
int i = 0;
i < 13;
i++) modules[
i] = -1;
883 for (
int i = 0;
i < 13;
i++) {
890 double y = accumulator.second.pars.qOverPt;
891 double x = accumulator.second.pars.phi;
894 std::vector<float> coords;
896 for (
int i = 0;
i < nLayers; ++
i) {
903 int other_layer = (sector_hits[
i].getSide() == 0) ?
i + 1 :
i - 1;
909 std::vector<float> coords_tmp;
921 coords.push_back(coords_tmp[1]);
926 if (sector_hits[
i].getDim() == 2 || (sector_hits[
i].getHitType() ==
HitType::spacepoint && (sector_hits[
i].getPhysLayer() % 2) == 1)) {
928 coords.push_back(coords_tmp[0]);
939 assert(coords.size() == (
size_t)nDim);
940 acc.hit_coords = coords;
941 acc.hit_coordsG = coords;
946 acc.pars.qOverPt = (
y / 1000.0) -
track.getQOverPt();
953 acc.track_bins.push_back(
bins);
957 while (
acc.pars.phi < 0)
acc.pars.phi += 2*
M_PI;
962 for (
int i = 0;
i < nDim;
i++)
964 acc.hit_x_QoP[
i] = coords[
i] *
acc.pars.qOverPt;
965 acc.hit_xG_HIP[
i] = coords[
i] *
acc.pars.qOverPt;
966 acc.hit_x_d0[
i] = coords[
i] *
acc.pars.d0;
967 acc.hit_x_z0[
i] = coords[
i] *
acc.pars.z0;
968 acc.hit_x_eta[
i] = coords[
i] *
acc.pars.eta;
969 acc.hit_xG_eta[
i] = coords[
i] *
acc.pars.eta;
970 acc.hit_x_phi[
i] = coords[
i] *
acc.pars.phi;
972 for (
int j =
i; j < nDim; j++)
973 acc.covariance[
i * nDim + j] = coords[
i] * coords[j];
975 for (
int j =
i; j < nDim; j++)
976 acc.covarianceG[
i * nDim + j] = coords[
i] * coords[j];
979 accumulator = {modules,
acc};
980 return StatusCode::SUCCESS;
997 for (
int region = 0; region <
m_nRegions; region++) {
999 std::stringstream
name;
1000 std::stringstream
title;
1001 name <<
"am" << region;
1002 title <<
"Ambank " << region <<
" parameters";
1003 TTree*
tree =
new TTree(
name.str().c_str(),
title.str().c_str());
1011 double coverage = sector_info.second.track_bins.size();
1020 return StatusCode::SUCCESS;
1026 TTree* sliceTree =
new TTree(
"slice",
"Region slice boundaries");
1041 sliceTree->Branch(
"d0_slices", &
m_nBins.
d0);
1042 sliceTree->Branch(
"phi_slices", &
m_nBins.
phi);
1043 sliceTree->Branch(
"z0_slices", &
m_nBins.
z0);
1044 sliceTree->Branch(
"eta_slices", &
m_nBins.
eta);