11 #include "GaudiKernel/MsgStream.h"
12 #include "GaudiKernel/ITHistSvc.h"
81 ATH_MSG_INFO(
"Hough constants method needs idealized geometry > 0, aborting.");
82 return StatusCode::FAILURE;
108 ATH_MSG_ERROR(
"q/pt bin information not set in matrix element job options!");
109 return StatusCode::FAILURE;
118 return StatusCode::SUCCESS;
176 m_h_nHit =
new TH1I(
"h_nHit",
"number of hits in sector", 100, 0, 100);
182 return StatusCode::SUCCESS;
212 if (tracks.empty()) {
214 return StatusCode::SUCCESS;
218 std::map<int, std::vector<FPGATrackSimHit>> barcode_hits =
makeBarcodeMap(
hits, tracks);
225 std::vector<FPGATrackSimHit> & track_hits = barcode_hits[
track.getBarcode()];
228 std::vector<FPGATrackSimHit> sector_hits;
230 if (!success)
continue;
235 if (region < 0 || region >=
m_nRegions)
continue;
239 std::vector<FPGATrackSimRoad*> houghRoads;
242 std::vector<const FPGATrackSimHit*> phits;
243 std::vector<FPGATrackSimRoad*> roads;
252 houghRoads.push_back(
hr);
256 if (!houghRoads.empty()){
266 std::vector<module_t> modules(
m_nLayers);
268 acc.pars.qOverPt =
y;
280 return StatusCode::SUCCESS;
285 std::vector<module_t> modules(
m_nLayers);
296 return StatusCode::SUCCESS;
304 std::vector<FPGATrackSimHit>
hits;
317 std::vector<FPGATrackSimCluster> clustered_hits;
323 std::vector<FPGATrackSimCluster> spacepoints;
329 std::vector<FPGATrackSimTowerInputHeader>
towers = logicalHeader.
towers();
330 for (
auto &tower :
towers) {
331 std::vector<FPGATrackSimHit>
const & towerHits = tower.hits();
343 std::vector<FPGATrackSimTruthTrack> training_tracks;
350 double pt_GeV =
pt / 1000;
358 double eta = TMath::ASinH(
track.getPZ() /
pt);
364 <<
" pdgcode = " <<
track.getPDGCode());
369 return training_tracks;
376 std::map<int, std::vector<FPGATrackSimHit>> map;
380 map[
track.getBarcode()] = std::vector<FPGATrackSimHit>();
385 int barcode = hit.getTruth().best_barcode();
389 if (
it != map.end()) (*it).second.push_back(hit);
427 if (old_section == new_section) {
437 rmax = phi_max - phi_min;
445 rmax = phi_max - phi_min;
483 if (old_isEC != new_isEC) {
489 else if (old_disk == new_disk) {
491 ATH_MSG_DEBUG(
"Two modules hit in same physical disk " << old_disk);
496 ATH_MSG_DEBUG(
"Keeping the lower-z of the two disks (" << old_disk <<
", " << new_disk <<
") hit");
518 int layer = hit.getLayer();
520 if (layer_count[
layer] == 0){
521 layer_count[
layer]++;
522 sector_hits[
layer] = hit;
524 else if (layer_count[
layer] == 1) {
525 layer_count[
layer]++;
537 ATH_MSG_DEBUG(
"Too many hits on a plane, exiting filterHitsSec");
552 if (layer_count[
i] == 0)
562 if (sector_hits[
i].isPixel()) {
570 ATH_MSG_DEBUG(
"Found " << num_sp <<
" spacepoints after removing duplicates.");
582 if (num_sp < minSpacePlusPixel) {
583 ATH_MSG_DEBUG(
"Not enough pixel hits + spacepoints (" << num_sp <<
" < " << minSpacePlusPixel <<
")");
595 std::vector<bool> region_mask(
m_nRegions,
true);
599 for (
int region = 0; region <
m_nRegions; region++) {
602 region_mask[region] =
false;
606 region_mask[region] =
false;
613 for (
int region = 0; region <
m_nRegions; region++)
614 if (region_mask[region])
625 std::vector<module_t> modules(
m_nLayers);
631 double qoverpt =
track.getQ() /
track.getPt();
639 std::string module_printout =
"";
643 if (
m_single) modules[
i] = sector_hits[
i].getIdentifierHash();
645 modules[
i] = sectorbin;
659 ATH_MSG_DEBUG(
"Generating track in sectorbin = " << sectorbin <<
" with modules: " << module_printout);
663 const int ToKeep[13] = {2200,2564,2861,3831,5368,14169,14173,20442,20446,29625,29629,42176,42180};
664 bool keepThis =
true;
665 for (
int i = 0;
i < 13;
i++) {
666 if (modules[
i] != ToKeep[
i] && modules[
i] != -1) {
672 for (
int i = 0;
i < 13;
i++) modules[
i] = -1;
675 for (
int i = 0;
i < 13;
i++) {
690 double const trackTwoRhoInv =
track.getQ() * 1.0 / ( 0.33 *
track.getPt() );
693 double y = accumulator.second.pars.qOverPt;
694 double x = accumulator.second.pars.phi;
695 double const houghRho = fpgatracksim::A *
y;
698 std::vector<double> coords;
699 std::vector<double> coordsG;
702 double hitGPhi = sector_hits[
i].getGPhi();
708 int other_layer = (sector_hits[
i].getSide() == 0) ?
i + 1 :
i - 1;
717 double expectedGPhi =
x;
719 hitGPhi += ( sector_hits[
i].getR() - target_r ) * houghRho;
720 expectedGPhi -= target_r * houghRho;
723 hitGPhi += (
pow( sector_hits[
i].
getR() * houghRho, 3.0 ) / 6.0 );
724 expectedGPhi -= (
pow( target_r * houghRho, 3.0 ) / 6.0 );
728 coords.push_back(hitGPhi - expectedGPhi);
729 coordsG.push_back(hitGPhi - expectedGPhi);
731 coords.push_back(hitGPhi);
732 coordsG.push_back(hitGPhi);
739 hitGPhi += ( sector_hits[
i].getR() - target_r ) * trackTwoRhoInv;
742 hitGPhi += (
pow( sector_hits[
i].
getR() * trackTwoRhoInv, 3.0 ) / 6.0 );
744 coords.push_back(hitGPhi);
745 coordsG.push_back(hitGPhi);
751 if (sector_hits[
i].getDim() == 2 || (sector_hits[
i].getHitType() ==
HitType::spacepoint && (sector_hits[
i].getPhysLayer() % 2) == 1)) {
752 double hitZ = sector_hits[
i].getZ();
755 hitZ -= sector_hits[
i].getGCotTheta() * (sector_hits[
i].getR() - target_r);
757 hitZ -= (sector_hits[
i].getGCotTheta() *
pow (sector_hits[
i].
getR(), 3.0) * houghRho * houghRho) / 6.0;
761 hitZ -= sector_hits[
i].getGCotTheta() * (sector_hits[
i].getR() - target_r);
764 hitZ -= sector_hits[
i].getGCotTheta() * (
pow (sector_hits[
i].
getR(), 3.0) * trackTwoRhoInv * trackTwoRhoInv) / 6.0;
768 coords.push_back(hitZ);
769 coordsG.push_back(hitZ);
776 coordsG.push_back(0);
781 assert(coords.size() == (
size_t)
m_nDim);
782 acc.hit_coords = coords;
783 acc.hit_coordsG = coordsG;
788 acc.pars.qOverPt = (
y / 1000.0) -
track.getQOverPt();
795 acc.track_bins.push_back(
bins);
799 while (
acc.pars.phi < 0)
acc.pars.phi += 2*
M_PI;
806 acc.hit_x_QoP[
i] = coords[
i] *
acc.pars.qOverPt;
807 acc.hit_xG_HIP[
i] = coordsG[
i] *
acc.pars.qOverPt;
808 acc.hit_x_d0[
i] = coords[
i] *
acc.pars.d0;
809 acc.hit_x_z0[
i] = coords[
i] *
acc.pars.z0;
810 acc.hit_x_eta[
i] = coords[
i] *
acc.pars.eta;
811 acc.hit_xG_eta[
i] = coordsG[
i] *
acc.pars.eta;
812 acc.hit_x_phi[
i] = coords[
i] *
acc.pars.phi;
814 for (
int j =
i; j <
m_nDim; j++)
815 acc.covariance[
i *
m_nDim + j] = coords[
i] * coords[j];
817 for (
int j =
i; j <
m_nDim; j++)
818 acc.covarianceG[
i *
m_nDim + j] = coordsG[
i] * coordsG[j];
821 accumulator = {modules,
acc};
822 return StatusCode::SUCCESS;
837 for (
int region = 0; region <
m_nRegions; region++) {
839 std::stringstream
name;
840 std::stringstream
title;
841 name <<
"am" << region;
842 title <<
"Ambank " << region <<
" parameters";
843 TTree*
tree =
new TTree(
name.str().c_str(),
title.str().c_str());
851 double coverage = sector_info.second.track_bins.size();
860 return StatusCode::SUCCESS;
866 TTree* sliceTree =
new TTree(
"slice",
"Region slice boundaries");
881 sliceTree->Branch(
"d0_slices", &
m_nBins.
d0);
882 sliceTree->Branch(
"phi_slices", &
m_nBins.
phi);
883 sliceTree->Branch(
"z0_slices", &
m_nBins.
z0);
884 sliceTree->Branch(
"eta_slices", &
m_nBins.
eta);