libatomprobe
Library for Atom Probe Tomography (APT) computation
countepos.cpp
Go to the documentation of this file.
1 /* countEpos.cpp : Sample program to count entries in an epos file
2  * Copyright (C) 2015 Daniel Haley
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "atomprobe/atomprobe.h"
19 
20 using namespace std;
21 using namespace AtomProbe;
22 
23 int main( int argc, char *argv[])
24 {
25 
26  std::vector<EPOS_ENTRY> outData;
27 
28 
29 
30  std::string filename;
31  if(argc ==1)
32  {
33  cout << "Enter file name" << endl;
34 
35  cin >> filename;
36  }
37  else if(argc ==2)
38  filename=argv[1];
39  else
40  {
41  cerr<< "USAGE: " << argv[0] << " [FILENAME]" << endl;
42  return 1;
43  }
44 
45  if(loadEposFile(outData, filename.c_str()))
46  {
47  cerr << "Epos file load failed. File is :" << filename << endl;
48  return 1;
49  }
50 
51 
52  size_t numHits=0;
53  for(size_t ui=0;ui<outData.size();ui++)
54  {
55  if(outData[ui].hitMultiplicity > 1)
56  numHits++;
57  }
58  cerr << "There are:" << outData.size() << "Hits" << endl;
59 
60  cerr << "Number of multiples is :" << numHits << endl;
61 
62 
63  //Work out the duration of the experiment, in pulses
64  unsigned long long int ull=0;
65  for(auto v : outData)
66  ull+=v.deltaPulse;
67 
68  cerr << "Max pulse value :" << ull << endl;
69  unsigned long long nEmptyPulse=0;
70  unsigned long long nSinglePulse=0;
71  unsigned long long nMultiPulse=0;
72 
73  unsigned long long nMultiIons=0;
74  unsigned long long nSingleIons=0;
75  for(auto v : outData)
76  {
77  //Compute pulse statistics
78  //===
79 
80  if(v.deltaPulse)
81  nEmptyPulse+=v.deltaPulse -1;
82 
83  if(v.deltaPulse ==1)
84  {
85  nSinglePulse++;
86  }
87 
88  if(v.deltaPulse >1 && v.hitMultiplicity >1)
89  nMultiPulse++;
90  //===
91 
92  //Compute ion statistics
93 
94  //Hits with either a "0" or ">1" in hitMultiplicity field are mutliple hits.
95  // Don't need to add the zeros however.
96  if(v.hitMultiplicity > 1)
97  nMultiIons+=v.hitMultiplicity;
98 
99  //Single hits
100  if(v.hitMultiplicity ==1)
101  nSingleIons++;
102 
103  }
104 
105  unsigned long long hits=nSingleIons + nMultiIons;
106 
107 
108  cerr << "No-hit fraction (%,pulse basis):" << nEmptyPulse/(float)ull*100 << endl;
109  cerr << "Single-hit fraction (%, pulse basis):" << nSinglePulse/(float)ull*100<< endl;
110  cerr << "Multi-fraction (%,pulse basis):" << nMultiPulse/(float)ull*100 << endl;
111 
112  cerr << "Single hit fraction (%, ion basis) :" << nSingleIons/(float)hits*100 << endl;
113  cerr << "Mult-hit fraction (%, ion basis) :" << nMultiIons/(float)hits*100 << endl;
114 
115 
116 }
STL namespace.
size_t loadEposFile(std::vector< EPOS_ENTRY > &outData, const char *filename)
Load an entire "EPOS" File.
Definition: dataFiles.cpp:756
int main(int argc, char *argv[])
Definition: countepos.cpp:23