25 int main(
int argc,
char *argv[])
30 cout <<
"Enter file name" << endl;
38 cerr<<
"USAGE: " << argv[0] <<
" [FILENAME]" << endl;
42 vector<vector<float> > data;
43 vector<string> headers;
44 cerr <<
"Loading :" << filename << endl;
45 if(
loadTextData(filename.c_str(),data,headers,
"\t",
true,
true,1))
47 cerr <<
" Failed to load text data" << endl;
52 vector<string> search = {
"det_x",
"det_y"};
53 vector<unsigned int> offset;
54 offset.resize(search.size(),(
unsigned int)-1);
55 for(
auto ui=0u; ui<headers.size();ui++)
57 auto s = std::find(search.begin(),search.end(),
61 offset[distance(search.begin(),s)] = ui;
65 cerr <<
"Header :" << h << endl;
67 if(find(offset.begin(),offset.end(),-1) != offset.end())
69 cerr <<
"Unable to locate det_x or det_y field" << endl;
74 vector<float> detX,detY;
75 detX.swap(data[offset[0]]);
76 detY.swap(data[offset[1]]);
79 cerr <<
"Loaded :" << detX.size() <<
" lines." << endl;
80 cerr <<
"Loaded :" << detY.size() <<
" lines." << endl;
81 float detBounds[2][2];
82 detBounds[0][0]=*std::min_element(detX.begin(),detX.end());
83 detBounds[1][0]=*std::min_element(detY.begin(),detY.end());
84 detBounds[0][1]=*std::max_element(detX.begin(),detX.end());
85 detBounds[1][1]=*std::max_element(detY.begin(),detY.end());
87 cerr <<
"Pre-cut" <<endl;
88 cerr << detBounds[0][0]<<
"<->" << detBounds[0][1] << endl;
89 cerr << detBounds[1][0]<<
"<->" << detBounds[1][1] << endl;
93 const float DET_RADIUS=0.04;
94 cerr <<
"Trimming to radius :" << DET_RADIUS << endl;
95 vector<float> trimX,trimY;
96 for(
auto ui=0u;ui<detX.size();ui++)
98 if(detX[ui]*detX[ui] + detY[ui]*detY[ui] < DET_RADIUS*DET_RADIUS)
100 trimX.push_back(detX[ui]);
101 trimY.push_back(detY[ui]);
111 std::vector<float> ionV,tof;
122 ionV.resize(detX.size());
123 tof.resize(detX.size());
128 std::vector<IonHit> pts;
135 cerr <<
"Reconstruction failed for reasons" << endl;
139 cerr <<
"Successfully reconstructed!" << endl;
142 cerr <<
"Error writing reconstruction to file" << endl;
void setFlightPath(float detEff)
Set flight path. Units must match detector units (eg mm)
void setReconFOV(float angle)
Set the angle (between 0 and pi radiaans). This is.
int main(int argc, char *argv[])
std::string stripWhite(const std::string &str)
Strip whitespace, (eg tab,space) from either side of a string.
unsigned int loadTextData(const char *cpFilename, std::vector< std::vector< float > > &dataVec, std::vector< std::string > &headerVec, const char *delim="\", bool allowNan=true, bool allowConvFails=false, unsigned int headerCount=-1)
Load a CSV, TSV or similar text file. Assumes "C" Locale for input (ie "." as decimal separator)...
unsigned int savePosFile(const std::vector< Point3D > &points, float mass, const char *name, bool append=false)
Save a vector of Point3Ds into a pos file, using a fixed mass, return nonzero on error.
bool reconstruct(const std::vector< float > &detectorX, const std::vector< float > &detectorY, const std::vector< float > &timeOfFlight, const std::vector< float > &ionVolume, std::vector< IonHit > &outputPts) const
Using the current reconstruction model, reconstruct a detector sequence.
This is a data holding class for POS file ions, from.
void setInitialRadius(float rInit)
Set the initial tip radius.
void setShankAngle(float angle)
Set initial angle, in radiians.
void setDetectorEfficiency(float detEff)
Set detector efficiency in range (0,1].
void setProjModel(AtomProbe::SphericPlaneProjection *model)
Set a given projection model.