ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimConstGenAlgo Class Reference

#include <FPGATrackSimConstGenAlgo.h>

Inheritance diagram for FPGATrackSimConstGenAlgo:

Public Member Functions

 FPGATrackSimConstGenAlgo (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~FPGATrackSimConstGenAlgo ()=default
StatusCode initialize () override
StatusCode finalize () override
StatusCode execute () override
StatusCode bookHistograms ()
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode copySliceTree (TFile *file)
StatusCode prepareOutputTree ()
void readSkipList (size_t nEntries)
void generate_constants ()
void fillConstTree (std::vector< module_t > &modules, FPGATrackSimMatrixAccumulator &acc, geo_constants &geo)
bool isNAN (double value, const char *name)
bool failedConstants (geo_constants const &geo, std::vector< bool > const &usable)
StatusCode DumpConstants (std::vector< geo_constants > &geo_consts, std::string &filename)
StatusCode writeSectors ()
bool GetConstants (FPGATrackSimMatrixAccumulator const &acc_norm, geo_constants &geo, int entryNumber)
bool GetConstants (FPGATrackSimMatrixAccumulator const &acc_norm, geo_constants &geo, int entryNumber, std::vector< bool > const &coordsToUse, unsigned int nusable)
void createMissingHitsConstants (FPGATrackSimMatrixAccumulator const &acc_norm, size_t entry)
FPGATrackSimMatrixAccumulator normalize (FPGATrackSimMatrixAccumulator const &acc_raw)
geo_constants makeConsts (FPGATrackSimMatrixAccumulator const &acc, std::vector< bool > const &usable, std::vector< double > const &inv_covariance, std::vector< double > const &eigvals, vector2D< double > const &eigvecs)
std::vector< double > matrix_multiply (std::vector< double > const &A, std::vector< double > const &b)
void eigen (size_t n_redu, size_t n_full, TMatrixD &mtx, std::vector< bool > const &usable, std::vector< double > &eigvals_v, vector2D< double > &eigvecs_v)
std::vector< double > invert (size_t n_full, TMatrixD mtx, std::vector< bool > const &usable)
 Inverts a reduced matrix, then pads with zeros to recover a full-sized matrix.
TMatrixD getReducedMatrix (size_t n, std::vector< double > const &mtx_v, std::vector< bool > const &usable, size_t nDimToUse)
 Removes the rows/columns specified by !usable.
bool isSingular (TMatrixD mtx)
double dot (const double *vec1, const double *vec2, size_t size)
geo_constants calculate_gcorth (geo_constants geo, int nCoords, std::vector< bool > const &usable)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ServiceHandle< IFPGATrackSimMappingSvcm_FPGATrackSimMapping {this, "FPGATrackSimMappingSvc","FPGATrackSimMappingSvc"}
ServiceHandle< IFPGATrackSimEventSelectionSvcm_EvtSel {this,"FPGATrackSimEventSelectionSvc","FPGATrackSimEventSelectionSvc"}
ServiceHandle< ITHistSvc > m_tHistSvc {this, "THistSvc","THistSvc"}
const FPGATrackSimPlaneMapm_pmap = nullptr
Gaudi::Property< std::string > m_cfpath {this, "merged_file_path", "", "merged file"}
Gaudi::Property< std::string > m_skipFile {this, "skip_sectors", "File with list of sectors to skip"}
Gaudi::Property< bool > m_Monitor {this,"Monitor",false,"flag to enable the monitor"}
Gaudi::Property< int > m_region {this, "region",0,"region to run"}
Gaudi::Property< bool > m_CheckGood2ndStage {this,"CheckGood2ndStage",true,"Check goodness of 2nd stage fit constants?"}
Gaudi::Property< bool > m_useHitScaleFactor {this,"UseHitScaleFactor",false,"Scale factor for hits"}
Gaudi::Property< bool > m_isSecondStage {this,"IsSecondStage",false,"If false, we're doing a 1st stage fit, otherwise 2nd stage"}
Gaudi::Property< bool > m_dumpMissingHitsConstants {this, "missHitsConsts", false, "if this is true we dump constants assuming a missing hit in each layer, too"}
TFile * m_mafile = nullptr
TTree * m_ctree = nullptr
TTree * m_matrix_tree = nullptr
TTree * m_good_tree = nullptr
FPGATrackSimTrackParsI m_sliceNBins
FPGATrackSimTrackPars m_sliceMin
FPGATrackSimTrackPars m_sliceMax
int m_nLayers = 0
int m_nKernel = 0
int m_nKAverages = 0
int m_nCoords = 0
int m_nCoords_2 = 0
std::vector< geo_constantsm_geo_consts
std::vector< std::vector< geo_constants > > m_geo_consts_with_missinghit
std::vector< bool > m_skipList
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 78 of file FPGATrackSimConstGenAlgo.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ FPGATrackSimConstGenAlgo()

FPGATrackSimConstGenAlgo::FPGATrackSimConstGenAlgo ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 57 of file FPGATrackSimConstGenAlgo.cxx.

57 :
58 AthAlgorithm(name, pSvcLocator)
59{
60}
AthAlgorithm()
Default constructor:

◆ ~FPGATrackSimConstGenAlgo()

virtual FPGATrackSimConstGenAlgo::~FPGATrackSimConstGenAlgo ( )
virtualdefault

Member Function Documentation

◆ bookHistograms()

StatusCode FPGATrackSimConstGenAlgo::bookHistograms ( )

Definition at line 118 of file FPGATrackSimConstGenAlgo.cxx.

119{
120 //usage guide:
121 //https://acode-browser.usatlas.bnl.gov/lxr/source/Gaudi/GaudiSvc/src/THistSvc/README.md
122 auto h_vc = std::make_unique<TH1F>("h_vc","h_vc",500,-1e-4,1e-4);
123 auto h_vd = std::make_unique<TH1F>("h_vd","h_vd",500,-1e-2,1e-2);
124 auto h_vf = std::make_unique<TH1F>("h_vf","h_vf",500,-1e-2,1e-2);
125 auto h_vz = std::make_unique<TH1F>("h_vz","h_vz",500,-1e-2,1e-2);
126 auto h_veta = std::make_unique<TH1F>("h_veta","h_veta",500,-1e-2,1e-2);
127 ATH_CHECK(m_tHistSvc->regHist("/TRIGFPGATrackSimTREEGOODOUT/h_vc",std::move(h_vc)));
128 ATH_CHECK(m_tHistSvc->regHist("/TRIGFPGATrackSimTREEGOODOUT/h_vd",std::move(h_vd)));
129 ATH_CHECK(m_tHistSvc->regHist("/TRIGFPGATrackSimTREEGOODOUT/h_vf",std::move(h_vf)));
130 ATH_CHECK(m_tHistSvc->regHist("/TRIGFPGATrackSimTREEGOODOUT/h_vz",std::move(h_vz)));
131 ATH_CHECK(m_tHistSvc->regHist("/TRIGFPGATrackSimTREEGOODOUT/h_veta",std::move(h_veta)));
132
133 return StatusCode::SUCCESS;
134}
#define ATH_CHECK
Evaluate an expression and check for errors.
ServiceHandle< ITHistSvc > m_tHistSvc

◆ calculate_gcorth()

geo_constants FPGATrackSimConstGenAlgo::calculate_gcorth ( geo_constants geo,
int nCoords,
std::vector< bool > const & usable )
private

Definition at line 712 of file FPGATrackSimConstGenAlgo.cxx.

713{
714 for (int i = 0; i < nCoords - FPGATrackSimTrackPars::NPARS;i++)
715 {
716 if (!usable[i]) continue;
717 double norm = dot(geo.kernel[i], geo.kernel[i], nCoords);
718
719 auto project = [&](std::vector<double> & hit_x_par, double & par)
720 {
721 double pr = dot(hit_x_par.data(), geo.kernel[i], nCoords) / norm;
722 for (int j = 0; j < nCoords; j++) hit_x_par[j] += -geo.kernel(i,j) * pr;
723 par += -geo.kaverages[i] * pr;
724 };
725
726 project(geo.Vd0, geo.pars.d0);
727 project(geo.Vcurvature, geo.pars.qOverPt);
728 project(geo.Vphi, geo.pars.phi);
729 project(geo.Vz0, geo.pars.z0);
730 project(geo.Veta, geo.pars.eta);
731 }
732
733 return geo;
734}
T_ResultType project(ParameterMapping::type< N > parameter_map, const T_Matrix &matrix)
double dot(const double *vec1, const double *vec2, size_t size)

◆ copySliceTree()

StatusCode FPGATrackSimConstGenAlgo::copySliceTree ( TFile * file)
private

Definition at line 137 of file FPGATrackSimConstGenAlgo.cxx.

138{
139 // Read old tree
140 TTree *old_tree = (TTree*)file->Get("slice");
141 old_tree->SetBranchAddress("c_max", &m_sliceMax.qOverPt);
142 old_tree->SetBranchAddress("c_min", &m_sliceMin.qOverPt);
143 old_tree->SetBranchAddress("c_slices", &m_sliceNBins.qOverPt);
144
145 old_tree->SetBranchAddress("phi_max", &m_sliceMax.phi);
146 old_tree->SetBranchAddress("phi_min", &m_sliceMin.phi);
147 old_tree->SetBranchAddress("phi_slices", &m_sliceNBins.phi);
148
149 old_tree->SetBranchAddress("d0_max", &m_sliceMax.d0);
150 old_tree->SetBranchAddress("d0_min", &m_sliceMin.d0);
151 old_tree->SetBranchAddress("d0_slices", &m_sliceNBins.d0);
152
153 old_tree->SetBranchAddress("z0_max", &m_sliceMax.z0);
154 old_tree->SetBranchAddress("z0_min", &m_sliceMin.z0);
155 old_tree->SetBranchAddress("z0_slices", &m_sliceNBins.z0);
156
157 old_tree->SetBranchAddress("eta_max", &m_sliceMax.eta);
158 old_tree->SetBranchAddress("eta_min", &m_sliceMin.eta);
159 old_tree->SetBranchAddress("eta_slices", &m_sliceNBins.eta);
160
161 old_tree->GetEntry(0);
162
163 // Write new tree
164 TTree *new_tree = new TTree("slice", "Slice boundaries");
165 ATH_CHECK(m_tHistSvc->regTree("/TRIGFPGATrackSimTREEGOODOUT/slice", new_tree));
166
167 new_tree->Branch("c_max", &m_sliceMax.qOverPt);
168 new_tree->Branch("c_min", &m_sliceMin.qOverPt);
169 new_tree->Branch("c_slices", &m_sliceNBins.qOverPt);
170
171 new_tree->Branch("phi_max", &m_sliceMax.phi);
172 new_tree->Branch("phi_min", &m_sliceMin.phi);
173 new_tree->Branch("phi_slices", &m_sliceNBins.phi);
174
175 new_tree->Branch("d0_max", &m_sliceMax.d0);
176 new_tree->Branch("d0_min", &m_sliceMin.d0);
177 new_tree->Branch("d0_slices", &m_sliceNBins.d0);
178
179 new_tree->Branch("z0_max", &m_sliceMax.z0);
180 new_tree->Branch("z0_min", &m_sliceMin.z0);
181 new_tree->Branch("z0_slices", &m_sliceNBins.z0);
182
183 new_tree->Branch("eta_max", &m_sliceMax.eta);
184 new_tree->Branch("eta_min", &m_sliceMin.eta);
185 new_tree->Branch("eta_slices", &m_sliceNBins.eta);
186
187 new_tree->Fill();
188
189 return StatusCode::SUCCESS;
190}
FPGATrackSimTrackParsI m_sliceNBins
TFile * file

◆ createMissingHitsConstants()

void FPGATrackSimConstGenAlgo::createMissingHitsConstants ( FPGATrackSimMatrixAccumulator const & acc_norm,
size_t entry )
private

Definition at line 297 of file FPGATrackSimConstGenAlgo.cxx.

298{
299 for (int ip = 0; ip < m_nLayers; ip++)
300 {
301 int missing = m_pmap->getCoordOffset(ip); // this is the coordinate we are missing
302 if (!acc_norm.coords_usable[missing]) // just skip ahead if we aren't using this coordinate already
303 {
304 geo_constants emptyGeo(m_nCoords);
305 m_geo_consts_with_missinghit[ip].push_back(std::move(emptyGeo));
306 continue;
307 }
308
309 unsigned int nusable = acc_norm.nusable() - 1;
310 std::vector<bool> coordsToUse = acc_norm.coords_usable;
311 coordsToUse[missing] = false;
312
313 if (m_pmap->getDim(ip) == 2)
314 {
315 coordsToUse[missing+1] = false;
316 nusable--;
317 }
318
319
320 geo_constants geo(m_nCoords);
321 bool success = GetConstants(acc_norm, geo, entry, coordsToUse, nusable);
322 if (!success)
323 {
324 // push this back to keep the order correct (ie same numbering as nominal constants)
325 geo_constants emptyGeo(m_nCoords);
326 m_geo_consts_with_missinghit[ip].push_back(std::move(emptyGeo));
327 }
328 else
329 {
330 m_geo_consts_with_missinghit[ip].push_back(std::move(geo));
331 }
332 }
333}
std::vector< std::vector< geo_constants > > m_geo_consts_with_missinghit
bool GetConstants(FPGATrackSimMatrixAccumulator const &acc_norm, geo_constants &geo, int entryNumber)
const FPGATrackSimPlaneMap * m_pmap

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ dot()

double FPGATrackSimConstGenAlgo::dot ( const double * vec1,
const double * vec2,
size_t size )
private

Definition at line 703 of file FPGATrackSimConstGenAlgo.cxx.

704{
705 double total = 0;
706 for (size_t i = 0; i < size; i++)
707 total += vec1[i] * vec2[i];
708 return total;
709}

◆ DumpConstants()

StatusCode FPGATrackSimConstGenAlgo::DumpConstants ( std::vector< geo_constants > & geo_consts,
std::string & filename )
private

Definition at line 833 of file FPGATrackSimConstGenAlgo.cxx.

834{
835 FILE *const_file = fopen(filename.c_str(),"w");
836 if (!const_file) {
837 ATH_MSG_ERROR("Cannot open output file " << filename);
838 return StatusCode::FAILURE;
839 }
840
841 fprintf(const_file,"! *** RECONSTRUCTION GEOMETRY CONSTANTS ***\n");
842 fprintf(const_file,"\n");
843 fprintf(const_file,"Version 2 ! File format version number\n");
844 fprintf(const_file,"\n");
845 fprintf(const_file,"! *** PHI is now in GLOBAL coordinate system ***\n");
846 fprintf(const_file," NPLANES\n");
847 fprintf(const_file," %d\n",m_nLayers);
848 fprintf(const_file," NSECTORS\n");
849 fprintf(const_file,"%zu\n",geo_consts.size());
850 fprintf(const_file," NDIM\n");
851 fprintf(const_file," 2\n");
852
853 std::string str_hex;
854
855 for (size_t sector = 0; sector < geo_consts.size(); sector++)
856 {
857 //gcon file
858 fprintf(const_file,"sector\n");
859 fprintf(const_file,"%zu\n", sector);
860
861 fprintf(const_file," Vc \n");
862 for(int i=0;i<m_nCoords;i++){
863 fprintf(const_file,"%e\n",geo_consts[sector].Vcurvature[i]);
864 }
865
866 fprintf(const_file," Vd \n");
867 for(int i=0;i<m_nCoords;i++){
868 fprintf(const_file,"%e\n",geo_consts[sector].Vd0[i]);
869 }
870
871 fprintf(const_file," Vf \n");
872 for(int i=0;i<m_nCoords;i++){
873 fprintf(const_file,"%e\n",geo_consts[sector].Vphi[i]);
874 }
875
876 fprintf(const_file," Vz0 \n");
877 for(int i=0;i<m_nCoords;i++){
878 fprintf(const_file,"%e\n",geo_consts[sector].Vz0[i]);
879 }
880
881 fprintf(const_file," Vo \n");
882 for(int i=0;i<m_nCoords;i++){
883 fprintf(const_file,"%e\n",geo_consts[sector].Veta[i]);
884 }
885
886 fprintf(const_file,"kaverages\n");
888 fprintf(const_file,"%e\n",m_geo_consts[sector].kaverages[i]);
889 }
890
891 fprintf(const_file,"kernel\n");
893 for(int j=0;j<m_nCoords;j++){
894 fprintf(const_file,"%e\n",geo_consts[sector].kernel(i, j));
895 }
896 }
897
898 fprintf(const_file,"Cc\n");
899 fprintf(const_file,"%e\n",geo_consts[sector].pars.qOverPt);
900
901 fprintf(const_file,"Cd\n");
902 fprintf(const_file,"%e\n",geo_consts[sector].pars.d0);
903
904 fprintf(const_file,"Cf\n");
905 fprintf(const_file,"%e\n",geo_consts[sector].pars.phi);
906
907 fprintf(const_file,"Cz0\n");
908 fprintf(const_file,"%e\n",geo_consts[sector].pars.z0);
909
910 fprintf(const_file,"Co\n");
911 fprintf(const_file,"%e\n",geo_consts[sector].pars.eta);
912 }
913
914 fclose(const_file);
915
916 return StatusCode::SUCCESS;
917}
#define ATH_MSG_ERROR(x)
std::vector< geo_constants > m_geo_consts

◆ eigen()

void FPGATrackSimConstGenAlgo::eigen ( size_t n_redu,
size_t n_full,
TMatrixD & mtx,
std::vector< bool > const & usable,
std::vector< double > & eigvals_v,
vector2D< double > & eigvecs_v )
private

Definition at line 672 of file FPGATrackSimConstGenAlgo.cxx.

673{
674
675 // Reduced system (these are sorted by decreasing |eigenvalue|)
676 TVectorD eigvals_redu;
677 TMatrixD eigvecs_redu = mtx.EigenVectors(eigvals_redu);
678
679 // Full system (to be copied into)
680 eigvals_full.resize(n_full, 0);
681 eigvecs_full.resize(n_full, n_full, 0);
682
683 // Reverse order AND transpose. First row in eigvecs_full = last column in eigvecs_redu.
684 // Here, i = row index, j = column index.
685 size_t j_redu = n_redu - 1;
686 for (size_t i_full = 0; i_full < n_full; i_full++)
687 {
688 if (!usable[i_full]) continue;
689
690 size_t i_redu = 0;
691 for (size_t j_full = 0; j_full < n_full; j_full++)
692 {
693 if (!usable[j_full]) continue;
694 eigvecs_full(i_full, j_full) = eigvecs_redu[i_redu][j_redu];
695 i_redu++;
696 }
697 eigvals_full[i_full] = eigvals_redu[j_redu];
698 j_redu--;
699 }
700}

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode FPGATrackSimConstGenAlgo::execute ( )
override

Definition at line 737 of file FPGATrackSimConstGenAlgo.cxx.

738{
739 // Do nothing; this class does not process events. The main algorithm is
740 // called in initialize() and finalize().
741 return StatusCode::SUCCESS;
742}

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ failedConstants()

bool FPGATrackSimConstGenAlgo::failedConstants ( geo_constants const & geo,
std::vector< bool > const & usable )
private

Definition at line 435 of file FPGATrackSimConstGenAlgo.cxx.

436{
437 geo_constants gco = calculate_gcorth(geo, m_nCoords, usable);
438
439 //if (CHECK_NAN(gco.pars.qOverPt)) return true; commenting out all gco's to gret more sectors. we do not use this anyways... for the meanwhile
440 if (CHECK_NAN(geo.pars.qOverPt)) return true;
441 //if (CHECK_NAN(gco.pars.d0)) return true;
442 if (CHECK_NAN(geo.pars.d0)) return true;
443 //if (CHECK_NAN(gco.pars.phi)) return true;
444 if (CHECK_NAN(geo.pars.phi)) return true;
445 //if (CHECK_NAN(gco.pars.z0)) return true;
446 if (CHECK_NAN(geo.pars.z0)) return true;
447 //if (CHECK_NAN(gco.pars.eta)) return true;
448 if (CHECK_NAN(geo.pars.eta)) return true;
449
450 for (int i = 0; i < m_nCoords; i++)
451 {
452 //if (CHECK_NAN(gco.Vcurvature[i])) return true;
453 if (CHECK_NAN(geo.Vcurvature[i])) return true;
454 //if (CHECK_NAN(gco.Vd0[i])) return true;
455 if (CHECK_NAN(geo.Vd0[i])) return true;
456 //if (CHECK_NAN(gco.Vphi[i])) return true;
457 if (CHECK_NAN(geo.Vphi[i])) return true;
458 //if (CHECK_NAN(gco.Vz0[i])) return true;
459 if (CHECK_NAN(geo.Vz0[i])) return true;
460 //if (CHECK_NAN(gco.Veta[i])) return true;
461 if (CHECK_NAN(geo.Veta[i])) return true;
462 }
463
464 for (int i = 0; i < m_nCoords - FPGATrackSimTrackPars::NPARS; i++)
465 {
466 if (CHECK_NAN(geo.kaverages[i])) return true;
467 for (int j = 0; j < m_nCoords; j++)
468 if (CHECK_NAN(geo.kernel(i,j))) return true;
469 }
470
471 return false;
472}
#define CHECK_NAN(var)
geo_constants calculate_gcorth(geo_constants geo, int nCoords, std::vector< bool > const &usable)

◆ fillConstTree()

void FPGATrackSimConstGenAlgo::fillConstTree ( std::vector< module_t > & modules,
FPGATrackSimMatrixAccumulator & acc,
geo_constants & geo )
private

Definition at line 369 of file FPGATrackSimConstGenAlgo.cxx.

370{
371 float coverage = static_cast<float>(acc.track_bins.size());
372 m_ctree->SetBranchAddress("sectorID", acc.FTK_modules.data());
373 m_ctree->SetBranchAddress("hashID", modules.data());
374 m_ctree->SetBranchAddress("nhit", &coverage);
375
376 m_ctree->SetBranchAddress("Cc", &geo.pars.qOverPt);
377 m_ctree->SetBranchAddress("Cd", &geo.pars.d0);
378 m_ctree->SetBranchAddress("Cf", &geo.pars.phi);
379 m_ctree->SetBranchAddress("Cz0", &geo.pars.z0);
380 m_ctree->SetBranchAddress("Co", &geo.pars.eta);
381
382 m_ctree->SetBranchAddress("Vc", geo.Vcurvature.data());
383 m_ctree->SetBranchAddress("Vd", geo.Vd0.data());
384 m_ctree->SetBranchAddress("Vf", geo.Vphi.data());
385 m_ctree->SetBranchAddress("Vz0", geo.Vz0.data());
386 m_ctree->SetBranchAddress("Vo", geo.Veta.data());
387
388 m_ctree->SetBranchAddress("kaverages", geo.kaverages.data());
389 m_ctree->SetBranchAddress("kernel", geo.kernel.data());
390
391 m_ctree->Fill();
392
393 if (m_Monitor)
394 {
395 const std::string prefix{"/TRIGFPGATrackSimTREEGOODOUT/"};
396 auto getHistogram = [&](const std::string & suffix)->TH1*{
397 TH1 * ptr{};
398 const auto sc = m_tHistSvc->getHist(prefix+suffix, ptr);
399 return (sc == StatusCode::SUCCESS) ? ptr: nullptr;
400 };
401 auto h_vc = getHistogram("h_vc");
402 auto h_vd = getHistogram("h_vd");
403 auto h_vf = getHistogram("h_vf");
404 auto h_vz = getHistogram("h_vz");
405 auto h_veta = getHistogram("h_veta");
406 if (anyNullPtr(h_vc, h_vd, h_vf, h_vz, h_veta)){
407 ATH_MSG_ERROR("FPGATrackSimConstGenAlgo::fillConstTree; nullptr");
408 return;
409 }
410 for (int i = 0; i < m_nCoords; i++)
411 {
412 h_vc->Fill(geo.Vcurvature[i]);
413 h_vd->Fill(geo.Vd0[i]);
414 h_vf->Fill(geo.Vphi[i]);
415 h_vz->Fill(geo.Vz0[i]);
416 h_veta->Fill(geo.Veta[i]);
417 }
418 }
419}
static Double_t sc
Gaudi::Property< bool > m_Monitor
void * ptr(T *p)
Definition SGImplSvc.cxx:74

◆ finalize()

StatusCode FPGATrackSimConstGenAlgo::finalize ( )
override

Definition at line 750 of file FPGATrackSimConstGenAlgo.cxx.

751{
752 ATH_MSG_DEBUG("finalize()");
753
754 std::string filename = "corrgen_raw_" + std::to_string(m_nLayers) + "L_reg" + std::to_string(m_region) + "_checkGood" + std::to_string(m_CheckGood2ndStage) + ".gcon";
755
757
759 for (int missing = 0; missing < m_nLayers; missing++) {
760 filename = "corrgen_raw_" + std::to_string(m_nLayers) + "L_reg" + std::to_string(m_region) + "_checkGood" + std::to_string(m_CheckGood2ndStage) + "_skipPlane" + std::to_string(missing) + ".gcon";
761 // pick up only the ones for this missing plane
763 }
764 }
765
767
768 ATH_CHECK(m_tHistSvc->finalize());
769 m_mafile->Close();
770
771 return StatusCode::SUCCESS;
772}
#define ATH_MSG_DEBUG(x)
Gaudi::Property< bool > m_dumpMissingHitsConstants
StatusCode DumpConstants(std::vector< geo_constants > &geo_consts, std::string &filename)
Gaudi::Property< bool > m_CheckGood2ndStage

◆ generate_constants()

void FPGATrackSimConstGenAlgo::generate_constants ( )
private

Definition at line 260 of file FPGATrackSimConstGenAlgo.cxx.

261{
262 FPGATrackSimMatrixReader reader(m_matrix_tree, m_nLayers, m_nCoords);
263 FPGATrackSimMatrixWriter writer(m_good_tree, m_nLayers, m_nCoords);
264 for (size_t entry = 0; entry < (size_t)m_matrix_tree->GetEntries(); entry++)
265 {
266 // Read the entry
267 if (!m_skipList.empty() && m_skipList[entry]) continue;
268 reader.readEntry(entry);
269 std::vector<module_t> & modules = reader.getModules();
270 FPGATrackSimMatrixAccumulator & acc = reader.getAccumulator();
271
272 // Check for sufficient statistics
273 if (acc.track_bins.size() < MIN_TRACK_SEC)
274 {
275 ATH_MSG_DEBUG("Insufficient tracks in sector " << reader.getEntry());
276 continue;
277 }
278
279 // Scale and normalize the accumulated variables
280 FPGATrackSimMatrixAccumulator acc_norm = normalize(acc);
281
282 // Create the constants
283 geo_constants geo(m_nCoords);
284 bool success = GetConstants(acc_norm, geo, entry);
285 if (!success) continue;
286
287 // Fill the constant tree and good matrix tree
288 fillConstTree(modules, acc, geo);
289 writer.fill(modules, acc);
290 m_geo_consts.push_back(std::move(geo));
291
292 // If needed, we generate the same as above but dropping/ignoring each potential hit
294 }
295}
#define MIN_TRACK_SEC
FPGATrackSimMatrixAccumulator normalize(FPGATrackSimMatrixAccumulator const &acc_raw)
void createMissingHitsConstants(FPGATrackSimMatrixAccumulator const &acc_norm, size_t entry)
void fillConstTree(std::vector< module_t > &modules, FPGATrackSimMatrixAccumulator &acc, geo_constants &geo)
reader
read the goodrunslist xml file(s)
Definition collisions.py:22
writer
show summary of content
Definition example.py:36

◆ GetConstants() [1/2]

bool FPGATrackSimConstGenAlgo::GetConstants ( FPGATrackSimMatrixAccumulator const & acc_norm,
geo_constants & geo,
int entryNumber )
private

Definition at line 335 of file FPGATrackSimConstGenAlgo.cxx.

336{
337 return GetConstants(acc_norm, geo, entryNumber, acc_norm.coords_usable, acc_norm.nusable());
338}

◆ GetConstants() [2/2]

bool FPGATrackSimConstGenAlgo::GetConstants ( FPGATrackSimMatrixAccumulator const & acc_norm,
geo_constants & geo,
int entryNumber,
std::vector< bool > const & coordsToUse,
unsigned int nusable )
private

Definition at line 340 of file FPGATrackSimConstGenAlgo.cxx.

341{
342 // Get the reduced matrix and invert it
343 TMatrixD mtx_reduced = getReducedMatrix(m_nCoords, acc_norm.covariance, coordsToUse, nusable);
344 if (isSingular(mtx_reduced))
345 {
346 ATH_MSG_DEBUG("Singular matrix in sector " << entryNumber);
347 return false;
348 }
349 std::vector<double> inv_covariance = invert(m_nCoords, mtx_reduced, coordsToUse);
350
351 // Calculate the eigen system
352 std::vector<double> eigvals;
353 vector2D<double> eigvecs;
354
355 eigen(nusable, m_nCoords, mtx_reduced, coordsToUse, eigvals, eigvecs);
356
357 // Calculate the constants
358 geo = makeConsts(acc_norm, coordsToUse, inv_covariance, eigvals, eigvecs);
359
360 if (failedConstants(geo, coordsToUse))
361 {
362 ATH_MSG_DEBUG("Failed constants in sector " << entryNumber);
363 return false;
364 }
365
366 return true;
367}
TMatrixD getReducedMatrix(size_t n, std::vector< double > const &mtx_v, std::vector< bool > const &usable, size_t nDimToUse)
Removes the rows/columns specified by !usable.
void eigen(size_t n_redu, size_t n_full, TMatrixD &mtx, std::vector< bool > const &usable, std::vector< double > &eigvals_v, vector2D< double > &eigvecs_v)
geo_constants makeConsts(FPGATrackSimMatrixAccumulator const &acc, std::vector< bool > const &usable, std::vector< double > const &inv_covariance, std::vector< double > const &eigvals, vector2D< double > const &eigvecs)
std::vector< double > invert(size_t n_full, TMatrixD mtx, std::vector< bool > const &usable)
Inverts a reduced matrix, then pads with zeros to recover a full-sized matrix.
bool failedConstants(geo_constants const &geo, std::vector< bool > const &usable)

◆ getReducedMatrix()

TMatrixD FPGATrackSimConstGenAlgo::getReducedMatrix ( size_t n,
std::vector< double > const & mtx_v,
std::vector< bool > const & usable,
size_t nDimToUse )
private

Removes the rows/columns specified by !usable.

Parameters
n- Initial size of matrix
mtx_v- Matrix to be reduced (size n*n)
usable- Which rows/columns are to be kept (size n)
nDimToUse- Must be count(usable), size of output matrix

Definition at line 600 of file FPGATrackSimConstGenAlgo.cxx.

601{
602 TMatrixD mtx(n, n, mtx_v.data());
603 TMatrixD newmtx(nDimToUse, nDimToUse);
604
605 size_t counteri = 0;
606 for (size_t i = 0; i < n; i++)
607 {
608 if (!usable[i]) continue;
609
610 size_t counterj = 0;
611 for (size_t j = 0; j < n; j++)
612 {
613 if (!usable[j]) continue;
614 newmtx[counteri][counterj] = mtx[i][j]; // if we use this coordinate, copy it over
615 counterj++; // iterate counter
616 }
617 assert(counterj == nDimToUse);
618 counteri++;
619 }
620 assert(counteri == nDimToUse);
621
622 return newmtx;
623}

◆ initialize()

StatusCode FPGATrackSimConstGenAlgo::initialize ( )
override

Definition at line 63 of file FPGATrackSimConstGenAlgo.cxx.

64{
65 ATH_MSG_DEBUG("initialize()");
66 ATH_MSG_DEBUG("Are we going to dump missing hist constants? " << m_dumpMissingHitsConstants);
68 ATH_CHECK(m_EvtSel.retrieve());
69 m_pmap = (m_isSecondStage ? m_FPGATrackSimMapping->PlaneMap_2nd(0) : m_FPGATrackSimMapping->PlaneMap_1st(0) );
70
71 ATH_CHECK(m_tHistSvc.retrieve());
73
74 // Input file
75 ATH_MSG_DEBUG("reading " << m_cfpath.value());
76 m_mafile = TFile::Open(m_cfpath.value().c_str());
77 gROOT->cd();
78 // Copy the slice tree
80
81 // Read sizing
82 m_matrix_tree = (TTree*)m_mafile->Get(("am" + std::to_string(0)).c_str());
83 m_matrix_tree->SetBranchAddress("ndim", &m_nCoords);
84 m_matrix_tree->SetBranchAddress("nplanes", &m_nLayers);
85 m_matrix_tree->GetEntry(0);
89
90 if (static_cast<size_t>(m_nLayers) == m_FPGATrackSimMapping->PlaneMap_2nd(0)->getNLogiLayers())
91 m_pmap = m_FPGATrackSimMapping->PlaneMap_2nd(0);
92 else if (static_cast<size_t>(m_nLayers) == m_FPGATrackSimMapping->PlaneMap_1st(0)->getNLogiLayers())
93 m_pmap = m_FPGATrackSimMapping->PlaneMap_1st(0);
94 else
95 ATH_MSG_ERROR("nLayers " << m_nLayers << " doesn't match any pmap");
96
98
99 // Read skip list
100 if (!m_skipFile.empty()) readSkipList(m_matrix_tree->GetEntries());
101
102 // Prepare output contstants tree
104
105 // Create the good tree
106 std::string tree_name = "am" + std::to_string(0);
107 std::string tree_title = "Ambank " + std::to_string(0) + " matrices";
108 m_good_tree = new TTree(tree_name.c_str(), tree_title.c_str());
109 ATH_CHECK(m_tHistSvc->regTree(("/TRIGFPGATrackSimTREEGOODOUT/"+tree_name).c_str(), m_good_tree));
110
111 // Run the constant generation
113
114 return StatusCode::SUCCESS;
115}
ServiceHandle< IFPGATrackSimEventSelectionSvc > m_EvtSel
Gaudi::Property< std::string > m_skipFile
StatusCode copySliceTree(TFile *file)
Gaudi::Property< bool > m_isSecondStage
Gaudi::Property< std::string > m_cfpath
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ invert()

std::vector< double > FPGATrackSimConstGenAlgo::invert ( size_t n_full,
TMatrixD mtx,
std::vector< bool > const & usable )
private

Inverts a reduced matrix, then pads with zeros to recover a full-sized matrix.

Parameters
n_full- Size of full (output) system
mtx- A reduced matrix to be inverted (size n_redu * n_redu)
usable- Which rows/columns were kept (size n_full, count(usable == n_redu))

Definition at line 633 of file FPGATrackSimConstGenAlgo.cxx.

634{
635 // Output
636 std::vector<double> inv(n_full * n_full); // filled with 0s
637
638 mtx.Invert();
639
640 size_t counteri = 0;
641 for (size_t i = 0; i < n_full; i++)
642 {
643 if (!usable[i]) continue;
644
645 size_t counterj = 0;
646 for (size_t j = 0; j < n_full; j++)
647 {
648 if (!usable[j]) continue;
649 inv[i*n_full + j] = mtx[counteri][counterj];
650 counterj++;
651 }
652 counteri++;
653 }
654
655 return inv;
656}

◆ isNAN()

bool FPGATrackSimConstGenAlgo::isNAN ( double value,
const char * name )
private

Definition at line 422 of file FPGATrackSimConstGenAlgo.cxx.

423{
424 if (TMath::IsNaN(value))
425 {
426 ATH_MSG_WARNING("NaN found in " << name);
427 return true;
428 }
429 return false;
430}
#define ATH_MSG_WARNING(x)

◆ isSingular()

bool FPGATrackSimConstGenAlgo::isSingular ( TMatrixD mtx)
private

Definition at line 584 of file FPGATrackSimConstGenAlgo.cxx.

585{
586 TDecompLU dc(mtx); // note mtx is a copy
587 bool ok = dc.InvertLU(mtx, MTX_TOLERANCE);
588 return !ok;
589}
#define MTX_TOLERANCE

◆ makeConsts()

geo_constants FPGATrackSimConstGenAlgo::makeConsts ( FPGATrackSimMatrixAccumulator const & acc,
std::vector< bool > const & usable,
std::vector< double > const & inv_covariance,
std::vector< double > const & eigvals,
vector2D< double > const & eigvecs )
private

Definition at line 523 of file FPGATrackSimConstGenAlgo.cxx.

526{
527 size_t nCoords = acc.hit_coords.size();
528 geo_constants geo(nCoords);
529
530 geo.Vcurvature = matrix_multiply(inv_covariance, acc.hit_x_QoP);
531 geo.Vd0 = matrix_multiply(inv_covariance, acc.hit_x_d0);
532 geo.Vphi = matrix_multiply(inv_covariance, acc.hit_x_phi);
533 geo.Vz0 = matrix_multiply(inv_covariance, acc.hit_x_z0);
534 geo.Veta = matrix_multiply(inv_covariance, acc.hit_x_eta);
535
536 for (size_t i = 0; i < nCoords - FPGATrackSimTrackPars::NPARS; i++)
537 {
538 if (!usable[i]) continue; // vectors are filled with 0's by default
539 for (size_t j = 0; j < nCoords; j++)
540 {
541 if (!usable[j]) continue;
542 if (eigvals[i] > 0)
543 geo.kernel(i, j) = eigvecs(i, j) / sqrt(eigvals[i]);
544
545 geo.kaverages[i] += -geo.kernel(i, j) * acc.hit_coords[j];
546 }
547 }
548
549 geo.pars = acc.pars;
550 for (size_t i = 0; i < nCoords; i++)
551 {
552 geo.pars.d0 += -geo.Vd0[i] * acc.hit_coords[i];
553 geo.pars.qOverPt += -geo.Vcurvature[i] * acc.hit_coords[i];
554 geo.pars.phi += -geo.Vphi[i] * acc.hit_coords[i];
555 geo.pars.z0 += -geo.Vz0[i] * acc.hit_coords[i];
556 geo.pars.eta += -geo.Veta[i] * acc.hit_coords[i];
557 }
558
559 geo.real = static_cast<int>(acc.track_bins.size());
560 return geo;
561}
std::vector< double > matrix_multiply(std::vector< double > const &A, std::vector< double > const &b)

◆ matrix_multiply()

std::vector< double > FPGATrackSimConstGenAlgo::matrix_multiply ( std::vector< double > const & A,
std::vector< double > const & b )
private

Definition at line 571 of file FPGATrackSimConstGenAlgo.cxx.

572{
573 size_t n = b.size();
574 std::vector<double> x(n);
575
576 for (size_t i = 0; i < n; i++)
577 for (size_t j = 0; j < n; j++)
578 x[i] += A[i * n + j] * b[j];
579
580 return x;
581}
#define x

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ normalize()

FPGATrackSimMatrixAccumulator FPGATrackSimConstGenAlgo::normalize ( FPGATrackSimMatrixAccumulator const & acc_raw)
private

Definition at line 486 of file FPGATrackSimConstGenAlgo.cxx.

487{
488 FPGATrackSimMatrixAccumulator acc(acc_raw);
489 double coverage = static_cast<double>(acc.track_bins.size());
490 size_t nCoords = acc.hit_coords.size();
491
492 for (unsigned i = 0; i < FPGATrackSimTrackPars::NPARS; i++)
493 acc.pars[i] /= coverage;
494
495 for (unsigned i = 0; i < nCoords; i++)
496 {
497 acc.hit_coords[i] /= coverage;
498 if (std::abs(acc.hit_coords[i]) < MTX_TOLERANCE) acc.coords_usable[i] = false;
499 else acc.coords_usable[i] = true;
500 }
501
502 // Divide by n-1 for the sample variance (Bessel's correction)
503 for (unsigned i = 0; i < nCoords; i++)
504 {
505 acc.hit_x_QoP[i] = (acc.hit_x_QoP[i] - acc.hit_coords[i] * acc.pars.qOverPt * coverage) / (coverage-1);
506 acc.hit_x_d0[i] = (acc.hit_x_d0[i] - acc.hit_coords[i] * acc.pars.d0 * coverage) / (coverage-1);
507 acc.hit_x_z0[i] = (acc.hit_x_z0[i] - acc.hit_coords[i] * acc.pars.z0 * coverage) / (coverage-1);
508 acc.hit_x_phi[i] = (acc.hit_x_phi[i] - acc.hit_coords[i] * acc.pars.phi * coverage) / (coverage-1);
509 acc.hit_x_eta[i] = (acc.hit_x_eta[i] - acc.hit_coords[i] * acc.pars.eta * coverage) / (coverage-1);
510
511 // Covariance (and symmetrize)
512 for (unsigned j = i ; j < nCoords; ++j)
513 {
514 acc.covariance[j * nCoords + i] = acc.covariance[i * nCoords + j] =
515 (acc.covariance[i * nCoords + j] - acc.hit_coords[i] * acc.hit_coords[j] * coverage) / (coverage-1);
516 }
517 }
518
519 return acc;
520}

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ prepareOutputTree()

StatusCode FPGATrackSimConstGenAlgo::prepareOutputTree ( )
private

Definition at line 193 of file FPGATrackSimConstGenAlgo.cxx.

194{
195 // Dummy variables for typing
196 int anInt;
197 float aFloat;
198 double aDouble;
199
200 std::string tree_name = "am" + std::to_string(0);
201 std::string tree_title = "Ambank " + std::to_string(0) + " constants";
202 m_ctree = new TTree(tree_name.c_str(), tree_title.c_str());
203
204 m_ctree->Branch("ndim", &m_nCoords, "ndim/I");
205 m_ctree->Branch("ndim2", &m_nCoords_2, "ndim2/I");
206 m_ctree->Branch("nkernel", &m_nKernel, "nkernel/I");
207 m_ctree->Branch("nkaverages", &m_nKAverages, "nkaverages/I");
208 m_ctree->Branch("nplane", &m_nLayers, "nplane/I");
209
210 m_ctree->Branch("sectorID", &anInt, "sectorID[nplane]/I");
211 m_ctree->Branch("hashID", &anInt, "hashID[nplane]/I");
212 m_ctree->Branch("nhit", &aFloat, "nhit/F");
213
214 m_ctree->Branch("Cd", &aDouble, "Cd/D");
215 m_ctree->Branch("Cc", &aDouble, "Cc/D");
216 m_ctree->Branch("Cf", &aDouble, "Cf/D");
217 m_ctree->Branch("Cz0", &aDouble, "Cz0/D");
218 m_ctree->Branch("Co", &aDouble, "Co/D");
219
220 m_ctree->Branch("Vc", &aDouble, "Vc[ndim]/D");
221 m_ctree->Branch("Vd", &aDouble, "Vd[ndim]/D");
222 m_ctree->Branch("Vf", &aDouble, "Vf[ndim]/D");
223 m_ctree->Branch("Vz0", &aDouble, "Vz0[ndim]/D");
224 m_ctree->Branch("Vo", &aDouble, "Vo[ndim]/D");
225
226 m_ctree->Branch("kernel", &aDouble, "kernel[nkernel]/D");
227 m_ctree->Branch("kaverages", &aDouble, "kaverages[nkaverages]/D");
228
229 ATH_CHECK(m_tHistSvc->regTree(("/TRIGFPGATrackSimCTREEOUT/"+tree_name).c_str(), m_ctree));
230 return StatusCode::SUCCESS;
231}

◆ readSkipList()

void FPGATrackSimConstGenAlgo::readSkipList ( size_t nEntries)
private

Definition at line 234 of file FPGATrackSimConstGenAlgo.cxx.

235{
236 m_skipList.resize(nSectors);
237
238 std::ifstream file(m_skipFile);
239 if (!file.is_open()) return;
240
241 size_t count = 0;
242 size_t sector;
243 while (file >> sector)
244 {
245 if (sector >= nSectors)
246 {
247 ATH_MSG_ERROR("Bad sector " << sector << "/" << nSectors);
248 return;
249 }
250 m_skipList[sector] = true;
251 count++;
252 }
253 ATH_MSG_INFO("Skipping " << count << " sectors out of " << nSectors);
254 file.close();
255}
#define ATH_MSG_INFO(x)
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

◆ writeSectors()

StatusCode FPGATrackSimConstGenAlgo::writeSectors ( )
private

Definition at line 775 of file FPGATrackSimConstGenAlgo.cxx.

776{
777 // Create FPGATrackSimSectorSlice
778 FPGATrackSimTrackPars copymin = m_sliceMin;
779 FPGATrackSimTrackPars copymax = m_sliceMax;
780 FPGATrackSimSectorSlice slice(m_geo_consts.size(), m_sliceNBins, copymin, copymax);
781
782 // Open files
783 std::string sector_filename = "sectors_raw_" + std::to_string(m_nLayers) + "L_reg" + std::to_string(m_region) + "_checkGood" + std::to_string(m_CheckGood2ndStage) + ".patt";
784 std::string sectorHW_filename = "sectorsHW_raw_" + std::to_string(m_nLayers) + "L_reg" + std::to_string(m_region) + "_checkGood" + std::to_string(m_CheckGood2ndStage) + ".patt";
785 FILE *sector_file = fopen(sector_filename.c_str(),"w");
786 if (!sector_file) {
787 ATH_MSG_ERROR("Cannot open output file " << sector_filename);
788 return StatusCode::FAILURE;
789 }
790 FILE *sectorHW_file = fopen(sectorHW_filename.c_str(),"w");
791 if (!sectorHW_file) {
792 ATH_MSG_ERROR("Cannot open output file " << sectorHW_filename);
793 fclose (sector_file);
794 return StatusCode::FAILURE;
795 }
796
797 fprintf(sector_file,"%zu %d\n",m_geo_consts.size(),m_nLayers);
798 fprintf(sectorHW_file,"%zu %d\n",m_geo_consts.size(),m_nLayers);
799
800 // Write sectors
801 FPGATrackSimMatrixReader reader(m_good_tree, m_nLayers, m_nCoords);
802 while (reader.nextEntry())
803 {
804 FPGATrackSimMatrixAccumulator const & acc = reader.getAccumulator();
805 size_t sector = reader.getEntry();
806
807 fprintf(sector_file,"%zu ", sector);
808 fprintf(sectorHW_file,"%zu ", sector);
809 for(int i=0;i<m_nLayers;i++)
810 {
811 fprintf(sector_file,"%d ", acc.FTK_modules[i]);
812 fprintf(sectorHW_file,"%d ", reader.getModules()[i]);
813 }
814 fprintf(sector_file,"0 %zu", acc.track_bins.size());
815 fprintf(sector_file,"\n");
816 fprintf(sectorHW_file,"0 %zu", acc.track_bins.size());
817 fprintf(sectorHW_file,"\n");
818
819 for (FPGATrackSimTrackParsI const & pars : acc.track_bins)
820 slice.addSectorToSlice(sector, pars);
821 }
822
823 fclose(sector_file);
824 fclose(sectorHW_file);
825 std::string slice_filename = "slices_" + std::to_string(m_nLayers) + "L_reg" + std::to_string(m_region) + ".root";
826 slice.saveSlices(slice_filename);
827
828 return StatusCode::SUCCESS;
829}

Member Data Documentation

◆ m_cfpath

Gaudi::Property<std::string> FPGATrackSimConstGenAlgo::m_cfpath {this, "merged_file_path", "", "merged file"}
private

Definition at line 107 of file FPGATrackSimConstGenAlgo.h.

107{this, "merged_file_path", "", "merged file"};

◆ m_CheckGood2ndStage

Gaudi::Property<bool> FPGATrackSimConstGenAlgo::m_CheckGood2ndStage {this,"CheckGood2ndStage",true,"Check goodness of 2nd stage fit constants?"}
private

Definition at line 111 of file FPGATrackSimConstGenAlgo.h.

111{this,"CheckGood2ndStage",true,"Check goodness of 2nd stage fit constants?"};

◆ m_ctree

TTree* FPGATrackSimConstGenAlgo::m_ctree = nullptr
private

Definition at line 120 of file FPGATrackSimConstGenAlgo.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_dumpMissingHitsConstants

Gaudi::Property<bool> FPGATrackSimConstGenAlgo::m_dumpMissingHitsConstants {this, "missHitsConsts", false, "if this is true we dump constants assuming a missing hit in each layer, too"}
private

Definition at line 114 of file FPGATrackSimConstGenAlgo.h.

114{this, "missHitsConsts", false, "if this is true we dump constants assuming a missing hit in each layer, too"};

◆ m_EvtSel

ServiceHandle<IFPGATrackSimEventSelectionSvc> FPGATrackSimConstGenAlgo::m_EvtSel {this,"FPGATrackSimEventSelectionSvc","FPGATrackSimEventSelectionSvc"}
private

Definition at line 98 of file FPGATrackSimConstGenAlgo.h.

98{this,"FPGATrackSimEventSelectionSvc","FPGATrackSimEventSelectionSvc"};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_FPGATrackSimMapping

ServiceHandle<IFPGATrackSimMappingSvc> FPGATrackSimConstGenAlgo::m_FPGATrackSimMapping {this, "FPGATrackSimMappingSvc","FPGATrackSimMappingSvc"}
private

Definition at line 97 of file FPGATrackSimConstGenAlgo.h.

97{this, "FPGATrackSimMappingSvc","FPGATrackSimMappingSvc"};

◆ m_geo_consts

std::vector<geo_constants> FPGATrackSimConstGenAlgo::m_geo_consts
private

Definition at line 146 of file FPGATrackSimConstGenAlgo.h.

◆ m_geo_consts_with_missinghit

std::vector<std::vector<geo_constants> > FPGATrackSimConstGenAlgo::m_geo_consts_with_missinghit
private

Definition at line 150 of file FPGATrackSimConstGenAlgo.h.

◆ m_good_tree

TTree* FPGATrackSimConstGenAlgo::m_good_tree = nullptr
private

Definition at line 122 of file FPGATrackSimConstGenAlgo.h.

◆ m_isSecondStage

Gaudi::Property<bool> FPGATrackSimConstGenAlgo::m_isSecondStage {this,"IsSecondStage",false,"If false, we're doing a 1st stage fit, otherwise 2nd stage"}
private

Definition at line 113 of file FPGATrackSimConstGenAlgo.h.

113{this,"IsSecondStage",false,"If false, we're doing a 1st stage fit, otherwise 2nd stage"};

◆ m_mafile

TFile* FPGATrackSimConstGenAlgo::m_mafile = nullptr
private

Definition at line 119 of file FPGATrackSimConstGenAlgo.h.

◆ m_matrix_tree

TTree* FPGATrackSimConstGenAlgo::m_matrix_tree = nullptr
private

Definition at line 121 of file FPGATrackSimConstGenAlgo.h.

◆ m_Monitor

Gaudi::Property<bool> FPGATrackSimConstGenAlgo::m_Monitor {this,"Monitor",false,"flag to enable the monitor"}
private

Definition at line 109 of file FPGATrackSimConstGenAlgo.h.

109{this,"Monitor",false,"flag to enable the monitor"};

◆ m_nCoords

int FPGATrackSimConstGenAlgo::m_nCoords = 0
private

Definition at line 138 of file FPGATrackSimConstGenAlgo.h.

◆ m_nCoords_2

int FPGATrackSimConstGenAlgo::m_nCoords_2 = 0
private

Definition at line 139 of file FPGATrackSimConstGenAlgo.h.

◆ m_nKAverages

int FPGATrackSimConstGenAlgo::m_nKAverages = 0
private

Definition at line 137 of file FPGATrackSimConstGenAlgo.h.

◆ m_nKernel

int FPGATrackSimConstGenAlgo::m_nKernel = 0
private

Definition at line 136 of file FPGATrackSimConstGenAlgo.h.

◆ m_nLayers

int FPGATrackSimConstGenAlgo::m_nLayers = 0
private

Definition at line 135 of file FPGATrackSimConstGenAlgo.h.

◆ m_pmap

const FPGATrackSimPlaneMap* FPGATrackSimConstGenAlgo::m_pmap = nullptr
private

Definition at line 101 of file FPGATrackSimConstGenAlgo.h.

◆ m_region

Gaudi::Property<int> FPGATrackSimConstGenAlgo::m_region {this, "region",0,"region to run"}
private

Definition at line 110 of file FPGATrackSimConstGenAlgo.h.

110{this, "region",0,"region to run"};

◆ m_skipFile

Gaudi::Property<std::string> FPGATrackSimConstGenAlgo::m_skipFile {this, "skip_sectors", "File with list of sectors to skip"}
private

Definition at line 108 of file FPGATrackSimConstGenAlgo.h.

108{this, "skip_sectors", "File with list of sectors to skip"};

◆ m_skipList

std::vector<bool> FPGATrackSimConstGenAlgo::m_skipList
private

Definition at line 153 of file FPGATrackSimConstGenAlgo.h.

◆ m_sliceMax

FPGATrackSimTrackPars FPGATrackSimConstGenAlgo::m_sliceMax
private

Definition at line 130 of file FPGATrackSimConstGenAlgo.h.

◆ m_sliceMin

FPGATrackSimTrackPars FPGATrackSimConstGenAlgo::m_sliceMin
private

Definition at line 129 of file FPGATrackSimConstGenAlgo.h.

◆ m_sliceNBins

FPGATrackSimTrackParsI FPGATrackSimConstGenAlgo::m_sliceNBins
private

Definition at line 128 of file FPGATrackSimConstGenAlgo.h.

◆ m_tHistSvc

ServiceHandle<ITHistSvc> FPGATrackSimConstGenAlgo::m_tHistSvc {this, "THistSvc","THistSvc"}
private

Definition at line 99 of file FPGATrackSimConstGenAlgo.h.

99{this, "THistSvc","THistSvc"};

◆ m_useHitScaleFactor

Gaudi::Property<bool> FPGATrackSimConstGenAlgo::m_useHitScaleFactor {this,"UseHitScaleFactor",false,"Scale factor for hits"}
private

Definition at line 112 of file FPGATrackSimConstGenAlgo.h.

112{this,"UseHitScaleFactor",false,"Scale factor for hits"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: