Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/code integration #287

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 55 additions & 9 deletions Source/Core/LMCHFSSResponseFileHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,27 +292,73 @@ namespace locust
fIsFIRCreated=true;
return true;
}

bool HFSSResponseFileHandlerCore::WriteRootHisto( std::vector<double> aFilter, bool bIQ )
{
#ifdef ROOT_FOUND
char fbuffer[60];
if (!bIQ)
{
int a = sprintf(fbuffer, "FIR_I");
}
else
{
int a = sprintf(fbuffer, "FIR_Q");
}
fRootHistoWriter->OpenFile("UPDATE");
const char *hName = fbuffer;
TH1D* aHisto = new TH1D(hName, "FIR coefficients; index; coefficient", fFIRNBins, 0., (double)fFIRNBins);
aHisto->SetDirectory(0);

for (unsigned i=0; i<fFIRNBins; i++)
{
aHisto->SetBinContent(i+1, aFilter[i]);
}

fRootHistoWriter->Write1DHisto(aHisto);
fRootHistoWriter->CloseFile();
delete aHisto;
#endif
return true;
}


void HFSSResponseFileHandlerCore::PrintFIR( std::vector<double> aFilter )
{
LDEBUG( lmclog, "Printing FIR coefficients to file ... ");
FILE * fFIRout = fopen("output/FIR.txt", "w");
for (int i = 0; i < fFIRNBins; i++)
LDEBUG( lmclog, "Printing FIR coefficients to file ... ");
FILE * fFIRout = fopen("output/FIR.txt", "w");
for (int i = 0; i < fFIRNBins; i++)
{
fprintf(fFIRout,"%g\n", aFilter[i]);
}
fclose(fFIRout);
#ifdef ROOT_FOUND
WriteRootHisto( aFilter, 0 );
#endif

}

void HFSSResponseFileHandlerCore::PrintFIR( fftw_complex* aFilter )
{
LDEBUG( lmclog, "Printing FIR coefficients to file ... ");
FILE * fFIRout = fopen("output/FIR.txt", "w");
for (int i = 0; i < fFIRNBins; i++)
{
std::vector<double> vecFilter0;
std::vector<double> vecFilter1;
LDEBUG( lmclog, "Printing FIR coefficients to file ... ");
FILE * fFIRout = fopen("output/FIR.txt", "w");
for (int i = 0; i < fFIRNBins; i++)
{
fprintf(fFIRout,"%g %g\n", aFilter[i][0], aFilter[i][1]);
}
fclose(fFIRout);
vecFilter0.push_back(aFilter[i][0]);
vecFilter1.push_back(aFilter[i][1]);
}
fclose(fFIRout);
#ifdef ROOT_FOUND
fRootHistoWriter = RootHistoWriter::get_instance();
fRootHistoWriter->SetFilename("output/FIRhisto.root");
fRootHistoWriter->OpenFile("RECREATE");
fRootHistoWriter->CloseFile();
WriteRootHisto( vecFilter0, 0 );
WriteRootHisto( vecFilter1, 1 );
#endif
}

FIRFileHandlerCore::FIRFileHandlerCore():HFSSResponseFileHandlerCore()
Expand Down
9 changes: 9 additions & 0 deletions Source/Core/LMCHFSSResponseFileHandler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include "param.hh"
#include "LMCComplexFFT.hh"

#ifdef ROOT_FOUND
#include "LMCRootHistoWriter.hh"
#endif

namespace locust
{
/*!
Expand Down Expand Up @@ -33,6 +37,7 @@ namespace locust
double GetFilterResolution() const;//Get the resolution of the filter
void PrintFIR( std::vector<double> );
void PrintFIR( fftw_complex* aFilter );
bool WriteRootHisto( std::vector<double> aFilter, bool bIQ );


protected:
Expand All @@ -51,6 +56,10 @@ namespace locust
std::string fWindowName;
double fWindowParam;
bool fPrintFIR;
#ifdef ROOT_FOUND
FileWriter* fRootHistoWriter;
#endif



//Member functions
Expand Down
17 changes: 15 additions & 2 deletions Source/RxComponents/LMCAnalyticResponseFunction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,26 @@ namespace locust
{
return fTFarray;
}

void AnalyticResponseFunction::SetGFarray( std::vector<std::pair<double,std::pair<double,double> > > aGFarray )
{
for (unsigned index=0; index<aGFarray.size(); index++)
if (fGFarray.size() > 0)
{
for (unsigned index=0; index<aGFarray.size(); index++)
{
fGFarray[index].second.first = aGFarray[index].second.first;
fGFarray[index].second.second = aGFarray[index].second.second;
}
}
else
{
fGFarray.push_back(std::make_pair(aGFarray[index].first, aGFarray[index].second));
for (unsigned index=0; index<aGFarray.size(); index++)
{
fGFarray.push_back(std::make_pair(aGFarray[index].first, aGFarray[index].second));
}
}
}

std::vector<std::pair<double,std::pair<double,double> > > AnalyticResponseFunction::GetGFarray()
{
return fGFarray;
Expand Down