11 #include "GaudiKernel/MsgStream.h"
12 #include "GaudiKernel/ITHistSvc.h"
88 ATH_MSG_INFO(
"Hough constants method needs idealized geometry > 0, aborting.");
89 return StatusCode::FAILURE;
115 ATH_MSG_ERROR(
"q/pt bin information not set in matrix element job options!");
116 return StatusCode::FAILURE;
125 return StatusCode::SUCCESS;
179 m_h_trackQoP_okHits =
new TH1I(
"h_trackQoP_okHits",
"half inverse pt of tracks passing hit check",
181 m_h_trackQoP_okRegion =
new TH1I(
"h_trackQoP_okRegion",
"half inverse pt of tracks passing region check",
183 m_h_nHit =
new TH1I(
"h_nHit",
"number of hits in sector", 100, 0, 100);
189 return StatusCode::SUCCESS;
217 if (tracks.empty()) {
219 return StatusCode::SUCCESS;
222 std::map<int, std::vector<FPGATrackSimHit>> barcode_hits =
makeBarcodeMap(
hits, tracks);
230 std::vector<FPGATrackSimHit> & sector_hits = barcode_hits[
track.getBarcode()];
236 for (
int iSlice = 0; iSlice<nSlices; iSlice++){
239 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<std::shared_ptr<const FPGATrackSimHit>> phits_2nd;
292 for (
const auto& hit : sector_hits) {
293 phits_2nd.push_back(std::make_shared<const FPGATrackSimHit>(hit));
297 std::vector<std::shared_ptr<const FPGATrackSimRoad>> roads_2nd;
298 std::vector<std::shared_ptr<const FPGATrackSimTrack>> ptracks_1st;
299 ptracks_1st.reserve(tracks_1st.size());
300 for (
const auto&
track : tracks_1st) {
301 ptracks_1st.push_back(std::make_shared<const FPGATrackSimTrack>(
track));
306 std::vector<FPGATrackSimTrack> tracks_2nd;
309 std::vector<FPGATrackSimHit> track_hits_2nd = track_2nd.getFPGATrackSimHits();
312 acc.pars.qOverPt = track_2nd.getHoughY();
313 acc.pars.phi = track_2nd.getHoughX();
316 std::vector<std::shared_ptr<const FPGATrackSimHit>> phits;
330 double y = track_comb.getHoughY();
331 double x = track_comb.getHoughX();
335 acc.pars.qOverPt =
y;
368 return StatusCode::SUCCESS;
376 std::vector<FPGATrackSimHit>
hits;
389 std::vector<FPGATrackSimCluster> clustered_hits;
395 std::vector<FPGATrackSimCluster> spacepoints;
401 std::vector<FPGATrackSimTowerInputHeader>
towers = logicalHeader.
towers();
402 for (
auto &tower :
towers) {
403 std::vector<FPGATrackSimHit>
const & towerHits = tower.hits();
415 std::vector<FPGATrackSimTruthTrack> training_tracks;
425 double pt_GeV =
pt / 1000;
433 double eta = TMath::ASinH(
track.getPZ() /
pt);
439 <<
" pdgcode = " <<
track.getPDGCode());
444 return training_tracks;
451 std::map<int, std::vector<FPGATrackSimHit>> map;
455 map[
track.getBarcode()] = std::vector<FPGATrackSimHit>();
460 int barcode = hit.getTruth().best_barcode();
464 if (
it != map.end()) (*it).second.push_back(hit);
503 if (old_section == new_section) {
509 rmax = phi_max - phi_min;
515 rmax = phi_max - phi_min;
551 if (old_isEC != new_isEC) {
557 else if (old_disk == new_disk) {
559 ATH_MSG_DEBUG(
"Two modules hit in same physical disk " << old_disk);
564 ATH_MSG_DEBUG(
"Keeping the lower-z of the two disks (" << old_disk <<
", " << new_disk <<
") hit");
584 sector_hits.resize(nLayers, nohit);
585 std::vector<int> layer_count(nLayers);
588 if (!hit.isReal() || !hit.isMapped())
continue;
592 if (
rmap->getRegions(hit).size() == 0) {
595 int layer = hit.getLayer();
596 if (layer_count[
layer] == 0){
597 layer_count[
layer]++;
598 sector_hits[
layer] = hit;
600 else if (layer_count[
layer] == 1) {
601 layer_count[
layer]++;
612 ATH_MSG_DEBUG(
"Too many hits on a plane, exiting filterHitsSec");
623 for (
int i = 0;
i < nLayers; ++
i)
625 if (layer_count[
i] == 0)
635 if (sector_hits[
i].isPixel()) {
642 ATH_MSG_DEBUG(
"Found " << num_sp <<
" spacepoints after removing duplicates.");
654 if (num_sp < minSpacePlusPixel) {
655 ATH_MSG_DEBUG(
"Not enough pixel hits + spacepoints (" << num_sp <<
" < " << minSpacePlusPixel <<
")");
667 std::vector<bool> region_mask(
m_nRegions,
true);
671 for (
int region = 0; region <
m_nRegions; region++) {
674 region_mask[region] =
false;
678 region_mask[region] =
false;
685 for (
int region = 0; region <
m_nRegions; region++) {
686 if (region_mask[region])
701 for (
auto module : modules) {
711 ATH_MSG_DEBUG(
"Attempting to make wildcard in layer " <<
layer <<
", is1ststage = " << is1ststage);
718 sector_hits[
layer] = *wcHit;
722 unsigned other_layer = 0;
725 other_backup = sector_hits[other_layer];
735 if (
sc != StatusCode::SUCCESS){
737 ATH_MSG_ERROR(
"FPGATrackSimMatrixGenAlgo::fillAccumulatorByDropping; makeAccumulator failed");
738 return StatusCode::FAILURE;
740 accumulate(map, new_modules_acc.first, new_modules_acc.second);
743 sector_hits[
layer] = backup_hit;
748 sector_hits[other_layer] = other_backup;
752 return StatusCode::SUCCESS;
764 std::vector<module_t> modules(nLayers);
770 double qoverpt =
track.getQ() /
track.getPt();
782 std::string module_printout =
"";
783 for (
int i = 0;
i < nLayers;
i++)
785 if (sector_hits[
i].isReal()) {
786 if (
m_single) modules[
i] = sector_hits[
i].getIdentifierHash();
788 modules[
i] = sectorbin;
802 ATH_MSG_DEBUG(
"Generating track in sectorbin = " << sectorbin <<
" with modules: " << module_printout);
806 const int ToKeep[13] = {2200,2564,2861,3831,5368,14169,14173,20442,20446,29625,29629,42176,42180};
807 bool keepThis =
true;
808 for (
int i = 0;
i < 13;
i++) {
809 if (modules[
i] != ToKeep[
i] && modules[
i] != -1) {
815 for (
int i = 0;
i < 13;
i++) modules[
i] = -1;
818 for (
int i = 0;
i < 13;
i++) {
825 double y = accumulator.second.pars.qOverPt;
826 double x = accumulator.second.pars.phi;
829 std::vector<float> coords;
831 for (
int i = 0;
i < nLayers; ++
i) {
833 if (sector_hits[
i].isReal()) {
838 int other_layer = (sector_hits[
i].getSide() == 0) ?
i + 1 :
i - 1;
844 std::vector<float> coords_tmp;
856 coords.push_back(coords_tmp[1]);
861 if (sector_hits[
i].getDim() == 2 || (sector_hits[
i].getHitType() ==
HitType::spacepoint && (sector_hits[
i].getPhysLayer() % 2) == 1)) {
863 coords.push_back(coords_tmp[0]);
874 assert(coords.size() == (
size_t)nDim);
875 acc.hit_coords = coords;
876 acc.hit_coordsG = coords;
881 acc.pars.qOverPt = (
y / 1000.0) -
track.getQOverPt();
888 acc.track_bins.push_back(
bins);
892 while (
acc.pars.phi < 0)
acc.pars.phi += 2*
M_PI;
897 for (
int i = 0;
i < nDim;
i++)
899 acc.hit_x_QoP[
i] = coords[
i] *
acc.pars.qOverPt;
900 acc.hit_xG_HIP[
i] = coords[
i] *
acc.pars.qOverPt;
901 acc.hit_x_d0[
i] = coords[
i] *
acc.pars.d0;
902 acc.hit_x_z0[
i] = coords[
i] *
acc.pars.z0;
903 acc.hit_x_eta[
i] = coords[
i] *
acc.pars.eta;
904 acc.hit_xG_eta[
i] = coords[
i] *
acc.pars.eta;
905 acc.hit_x_phi[
i] = coords[
i] *
acc.pars.phi;
907 for (
int j =
i; j < nDim; j++)
908 acc.covariance[
i * nDim + j] = coords[
i] * coords[j];
910 for (
int j =
i; j < nDim; j++)
911 acc.covarianceG[
i * nDim + j] = coords[
i] * coords[j];
914 accumulator = {modules,
acc};
915 return StatusCode::SUCCESS;
932 for (
int region = 0; region <
m_nRegions; region++) {
934 std::stringstream
name;
935 std::stringstream
title;
936 name <<
"am" << region;
937 title <<
"Ambank " << region <<
" parameters";
938 TTree*
tree =
new TTree(
name.str().c_str(),
title.str().c_str());
946 double coverage = sector_info.second.track_bins.size();
955 return StatusCode::SUCCESS;
961 TTree* sliceTree =
new TTree(
"slice",
"Region slice boundaries");
976 sliceTree->Branch(
"d0_slices", &
m_nBins.
d0);
977 sliceTree->Branch(
"phi_slices", &
m_nBins.
phi);
978 sliceTree->Branch(
"z0_slices", &
m_nBins.
z0);
979 sliceTree->Branch(
"eta_slices", &
m_nBins.
eta);