libatomprobe
Library for Atom Probe Tomography (APT) computation
ionHit.h
Go to the documentation of this file.
1 /*
2  * ionhit.h - Ion event data class
3  * Copyright (C) 2014 D Haley
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef ATOMPROBE_IONHIT_H
20 #define ATOMPROBE_IONHIT_H
21 
22 #include <vector>
23 
25 
26 #include "point3D.h"
27 #include "boundcube.h"
28 
29 namespace AtomProbe {
30 
31 
33 /* Pos ions are typically obtained via reconstructed apt detector hits
34  * and are of form (x,y,z mass/charge)
35  */
36 class IonHit
37 {
38  private:
39  float massToCharge; // mass to charge ratio in Atomic Mass Units per (charge on electron)
40  Point3D pos; //position (xyz) in nm
41  public:
42  IonHit();
43  IonHit(float *);
44  //copy constructor
45  IonHit(const IonHit &);
46  IonHit(const Point3D &p, float massToCharge);
47  IonHit(float x, float y, float z, float mass);
48 
49  //Set the data from a 4 byte float array.
50  void setHit(float *arr) { pos.setValueArr(arr); massToCharge=arr[3];};
51  //Set only the mass/charge value
52  void setMassToCharge(float newMassToCharge);
53  //Set the position of the event
54  void setPos(const Point3D &pos);
55 
56  //Set the xth (0,1,2) coordinate of the data
57  void setPos(unsigned int idx, float pos);
58  //Set the XYZ coords of the data
59  void setPos(float fX, float fY, float fZ)
60  { pos.setValue(fX,fY,fZ);};
61 
62  //Retrieve the XYZ coordinate for this data
63  Point3D getPos() const;
64  //obtain the XYZ coordinates as a constant ref.
65  inline const Point3D &getPosRef() const {return pos;};
66  //returns true if any of the 4 data pts are NaN
67  bool hasNaN();
68 
69 #ifdef __LITTLE_ENDIAN__
70  void switchEndian();
71 #endif
72 
73  //obtain the mass-to-charge for the event
74  float getMassToCharge() const;
75 
76 
77  //Helper functions
78  //--
79  //get the points from a vector of of ionhits
80  static void getPoints(const std::vector<IonHit> &ions, std::vector<Point3D> &pts);
81 
82  //Get the bounding cube from a vector of ionhits
83  static void getBoundCube(const std::vector<IonHit> &p, BoundCube &b);
84 
85  //Get the centroid from a vector of ion hits
86  static void getCentroid(const std::vector<IonHit> &points, Point3D &centroid);
87 
88  //---
89 
90  //assignment operator
91  const IonHit &operator=(const IonHit &obj);
92  //equality operator
93  bool operator==(const IonHit &obj) const;
94  //array get operator (0,1,2,3 valid -> x/y/z/m)
95  float operator[](unsigned int ui) const ;
96 
97  //array get operator (0,1,2,3 valid -> x/y/z/m)
98  float &operator[](unsigned int ui) ;
99  IonHit operator+(const Point3D &obj);
100 
102  friend std::ostream &operator<<(std::ostream &stream, const IonHit &);
103 
104  static BoundCube getIonDataLimits(const std::vector<IonHit> &points);
105 
106 
107 };
108 
109 
110 //This is an entry in the epos "format".
111 // There is, to best knowledge, no official specification
112 // There are unofficial specifications
114 {
115  public:
118  float x,y,z,massToCharge;
120 
123  float timeOfFlight,voltDC,voltPulse;
125  float xDetector,yDetector;
126  // !Hit multiplicity is the number of hits, for the *FIRST MULTIPLE ONLY*
131  int32_t deltaPulse, hitMultiplicity;
132 
133  IonHit getIonHit() const ;
134  void getIonHit(IonHit &h) const ;
135 
137  int getDeltaPulse() { return deltaPulse;}
138  int getHitMultiplicity() { return hitMultiplicity;}
139 
140  //equality operator
141  bool operator==(const EPOS_ENTRY &obj) const;
142 };
143 
144 const size_t EPOS_RECORD_SIZE = 11*4;
145 
146 #ifdef DEBUG
147 bool testIonHit();
148 #endif
149 
150 };
151 
152 #endif
float z
Definition: ionHit.h:118
Point3D getPos() const
Definition: ionhit.cpp:117
int32_t hitMultiplicity
Definition: ionHit.h:131
const IonHit & operator=(const IonHit &obj)
Definition: ionhit.cpp:90
int getHitMultiplicity()
Definition: ionHit.h:138
void setHit(float *arr)
Definition: ionHit.h:50
friend std::ostream & operator<<(std::ostream &stream, const IonHit &)
Output streaming operator. Users (x,y,z,m) as format for output.
Definition: ionhit.cpp:181
float voltPulse
Definition: ionHit.h:123
const Point3D & getPosRef() const
Definition: ionHit.h:65
IonHit operator+(const Point3D &obj)
Definition: ionhit.cpp:103
void setPos(const Point3D &pos)
Definition: ionhit.cpp:76
A 3D point data class storage.
Definition: point3D.h:39
float operator[](unsigned int ui) const
Definition: ionhit.cpp:251
static void getPoints(const std::vector< IonHit > &ions, std::vector< Point3D > &pts)
Definition: ionhit.cpp:109
const size_t EPOS_RECORD_SIZE
Definition: ionHit.h:144
bool operator==(const IonHit &obj) const
Definition: ionhit.cpp:98
float yDetector
Definition: ionHit.h:125
static BoundCube getIonDataLimits(const std::vector< IonHit > &points)
Definition: ionhit.cpp:188
float getMassToCharge() const
Definition: ionhit.cpp:65
void setPos(float fX, float fY, float fZ)
Definition: ionHit.h:59
int getDeltaPulse()
Python convenience functions to avoid int32_t types.
Definition: ionHit.h:137
void setValueArr(const float *val)
Set value by pointer (X, Y, Z from array of len 3)
Definition: point3D.h:90
Definition: ionHit.h:113
static void getBoundCube(const std::vector< IonHit > &p, BoundCube &b)
Definition: ionhit.cpp:153
Helper class to define a bounding cube.
Definition: boundcube.h:29
void setMassToCharge(float newMassToCharge)
Definition: ionhit.cpp:60
This is a data holding class for POS file ions, from.
Definition: ionHit.h:36
static void getCentroid(const std::vector< IonHit > &points, Point3D &centroid)
Definition: ionhit.cpp:128