Skip to content
Snippets Groups Projects
Commit 659b4773 authored by Stephen A. Wood's avatar Stephen A. Wood
Browse files

Convert Reconstruction coefs/exps to vector of structures

parent b99f35d0
No related branches found
No related tags found
No related merge requests found
...@@ -147,14 +147,7 @@ Bool_t THcHallCSpectrometer::GetTrSorting() const ...@@ -147,14 +147,7 @@ Bool_t THcHallCSpectrometer::GetTrSorting() const
void THcHallCSpectrometer::InitializeReconstruction() void THcHallCSpectrometer::InitializeReconstruction()
{ {
fNReconTerms = 0; fNReconTerms = 0;
for(Int_t i=0;i<fMaxReconElements;i++) { fReconTerms.clear();
for(Int_t j=0;j<4;j++) {
fReconCoeff[i][j] = 0.0;
}
for(Int_t j=0;j<5;j++) {
fReconExponents[i][j] = 0;
}
}
fAngSlope_x = 0.0; fAngSlope_x = 0.0;
fAngSlope_y = 0.0; fAngSlope_y = 0.0;
fAngOffset_x = 0.0; fAngOffset_x = 0.0;
...@@ -301,22 +294,19 @@ Int_t THcHallCSpectrometer::ReadDatabase( const TDatime& date ) ...@@ -301,22 +294,19 @@ Int_t THcHallCSpectrometer::ReadDatabase( const TDatime& date )
good = getline(ifile,line).good(); good = getline(ifile,line).good();
// cout << line << endl; // cout << line << endl;
fNReconTerms = 0; fNReconTerms = 0;
fReconTerms.clear();
fReconTerms.reserve(500);
//cout << "Reading matrix elements" << endl; //cout << "Reading matrix elements" << endl;
while(good && line.compare(0,4," ---")!=0) { while(good && line.compare(0,4," ---")!=0) {
if(fNReconTerms >= fMaxReconElements) { fReconTerms.push_back(reconTerm());
Error(here, "too much data in reconstruction coefficient file %s",reconCoeffFilename.c_str());
return kInitError; // Is this the right return code?
}
sscanf(line.c_str()," %le %le %le %le %1d%1d%1d%1d%1d" sscanf(line.c_str()," %le %le %le %le %1d%1d%1d%1d%1d"
,&fReconCoeff[fNReconTerms][0],&fReconCoeff[fNReconTerms][1] ,&fReconTerms[fNReconTerms].Coeff[0],&fReconTerms[fNReconTerms].Coeff[1]
,&fReconCoeff[fNReconTerms][2],&fReconCoeff[fNReconTerms][3] ,&fReconTerms[fNReconTerms].Coeff[2],&fReconTerms[fNReconTerms].Coeff[3]
,&fReconExponents[fNReconTerms][0] ,&fReconTerms[fNReconTerms].Exp[0]
,&fReconExponents[fNReconTerms][1] ,&fReconTerms[fNReconTerms].Exp[1]
,&fReconExponents[fNReconTerms][2] ,&fReconTerms[fNReconTerms].Exp[2]
,&fReconExponents[fNReconTerms][3] ,&fReconTerms[fNReconTerms].Exp[3]
,&fReconExponents[fNReconTerms][4]); ,&fReconTerms[fNReconTerms].Exp[4]);
// Parse line into fReconCoeff[fNReconTerms][0 - 3] and
// fReconExponents[fNReconTerms][0 - 5]
fNReconTerms++; fNReconTerms++;
good = getline(ifile,line).good(); good = getline(ifile,line).good();
} }
...@@ -372,12 +362,12 @@ Int_t THcHallCSpectrometer::FindVertices( TClonesArray& tracks ) ...@@ -372,12 +362,12 @@ Int_t THcHallCSpectrometer::FindVertices( TClonesArray& tracks )
for(Int_t iterm=0;iterm<fNReconTerms;iterm++) { for(Int_t iterm=0;iterm<fNReconTerms;iterm++) {
Double_t term=1.0; Double_t term=1.0;
for(Int_t j=0;j<5;j++) { for(Int_t j=0;j<5;j++) {
if(fReconExponents[iterm][j]!=0) { if(fReconTerms[iterm].Exp[j]!=0) {
term *= pow(hut_rot[j],fReconExponents[iterm][j]); term *= pow(hut_rot[j],fReconTerms[iterm].Exp[j]);
} }
} }
for(Int_t k=0;k<4;k++) { for(Int_t k=0;k<4;k++) {
sum[k] += term*fReconCoeff[iterm][k]; sum[k] += term*fReconTerms[iterm].Coeff[k];
} }
} }
// Transfer results to track // Transfer results to track
......
...@@ -94,12 +94,22 @@ protected: ...@@ -94,12 +94,22 @@ protected:
THcShower* fShower; THcShower* fShower;
THcHodoscope* fHodo; THcHodoscope* fHodo;
// Should look at the ThaMatrixElement class in THaVDC.h for better way
// to store matrix element data
#define fMaxReconElements 1000
Int_t fNReconTerms; Int_t fNReconTerms;
Double_t fReconCoeff[fMaxReconElements][4]; struct reconTerm {
Int_t fReconExponents[fMaxReconElements][5]; Double_t Coeff[4];
Int_t Exp[5];
reconTerm() {
for(Int_t i=0;i<4;i++) {
Coeff[i] = 0.0;
}
for(Int_t i=0;i<5;i++) {
Exp[i] = 0;
}
}
};
std::vector<reconTerm> fReconTerms;
// Double_t fReconCoeff[fMaxReconElements][4];
// Int_t fReconExponents[fMaxReconElements][5];
Double_t fAngSlope_x; Double_t fAngSlope_x;
Double_t fAngSlope_y; Double_t fAngSlope_y;
Double_t fAngOffset_x; Double_t fAngOffset_x;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment