19 #include <gsl/gsl_histogram2d.h> 42 bool convertToPos(
const vector<EPOS_ENTRY> &epos, vector<IonHit> &pos)
46 pos.resize(epos.size());
52 #pragma omp parallel for 53 for(
size_t ui=0;ui<epos.size();ui++)
55 pos[ui].setPos(epos[ui].xDetector,
58 pos[ui].setMassToCharge( epos[ui].hitMultiplicity);
66 std::ofstream of(outFile);
71 for(
unsigned int ui=0;ui<h->nx; ui++)
73 for(
unsigned int uj=0;uj<h->ny; uj++)
75 of<< gsl_histogram2d_get(h,ui,uj) <<
" ";
85 vector<EPOS_ENTRY> &output)
87 for(
unsigned int ui=0;ui<input.size(); ui++)
92 while(ui < input.size() &&
93 input[ui].deltaPulse <filterCount)
95 output.push_back(input[ui]);
102 int main(
int argc,
const char *argv[])
107 cerr <<
"USAGE: " << argv[0] <<
" EPOSFILE SAMPLES OUTPUTPOS" << endl;
109 cerr <<
" This filters an epos file by the number of pulses between evaporation events. Only events with less than SAMPLES pulses between them are kept" << endl;
111 cerr <<
"See Yao et al, MethodsX, 2016, 3:268-273" << endl;
116 unsigned int filterCount;
119 cerr <<
"Unable to interpret filter count value" << endl;
126 cerr <<
"filter count must be positive" << endl;
130 cerr <<
"Filtering EPOS file....";
131 unsigned int CHUNK_SIZE=4096;
137 unsigned int outputSize=0,chunkOffset=0,totalEntries=0,entriesLeft;
138 vector<EPOS_ENTRY> eposEntries,eposOutput;
142 vector<EPOS_ENTRY> thisEposOutput;
145 unsigned int errCode;
147 CHUNK_SIZE,chunkOffset,entriesLeft)))
158 eposEntries.insert(eposEntries.begin(),lastEntry);
165 lastEntry = eposEntries.back();
168 totalEntries+=eposEntries.size();
176 if(thisEposOutput.size() &&
177 (thisEposOutput.back() == lastEntry) && entriesLeft)
178 thisEposOutput.pop_back();
181 vector<IonHit> ionHits;
182 ionHits.resize(thisEposOutput.size());
184 for(
auto ui=0;ui<thisEposOutput.size();ui++)
185 thisEposOutput[ui].getIonHit(ionHits[ui]);
188 const bool APPEND=
true;
191 cerr <<
"Error writing pos file" << endl;
196 outputSize+=thisEposOutput.size();
197 thisEposOutput.clear();
201 pb.
update(100.0f*(
float)chunkOffset/(
float)(chunkOffset+entriesLeft/CHUNK_SIZE));
208 cerr <<
"\tFiltered " << totalEntries <<
" entries." << endl;
209 cerr << outputSize<<
" entries after filtering." << endl;
const char * RECORDREAD_ERR_STRINGS[]
bool convertToPos(const vector< EPOS_ENTRY > &epos, vector< IonHit > &pos)
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.
int main(int argc, const char *argv[])
void finish()
Finalise the progress bar. It is not necessary for the progress to be set to 100%, this is done for you.
void init()
Draw the initial progress bar.
void setLength(unsigned int l)
Set the number of markers in the progress bar.
bool dumpHistogram(gsl_histogram2d *h, const char *outFile)
bool stream_cast(T1 &result, const T2 &obj)
Template function to cast and object to another by the stringstream.
void update(unsigned int newProgress)
Draw the progress bar as needed, using the given progress value [0,100].
size_t chunkLoadEposFile(std::vector< EPOS_ENTRY > &outData, const char *filename, unsigned int chunkSize, unsigned int chunkOffset, unsigned int &nEntriesLeft)
Load an "EPOS" file, with a maximum chunk size.
void filterEposByPulse(const vector< EPOS_ENTRY > &input, unsigned int filterCount, vector< EPOS_ENTRY > &output)