-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMedianTextReader.cpp
More file actions
76 lines (54 loc) · 1.83 KB
/
MedianTextReader.cpp
File metadata and controls
76 lines (54 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "MedianTextReader.hpp"
MedianTextRecord::MedianTextRecord( unsigned num, unsigned pmt, unsigned bolt, unsigned x, unsigned y, std::string id ) : fNum( num ), fPMT( pmt ), fBolt( bolt ), fX( x) , fY( y ), fID( id ) { }
MedianTextRecord::MedianTextRecord() : fNum( 0 ), fPMT( 0 ), fBolt( 0 ), fX( 0) , fY( 0 ), fID("" ) { }
bool MedianTextRecord::is_bolt(){
/*
## Numbering Convention
20001: UK B1
00: Center of diffuser ball
30001: Korean B1
00-07: Bolts clockwise from top-left
<19999: PMTs
00: Center of dynode (or light reflection for labels PD1/2)
01-24: Bolts clockwise from top center (+z)
25: Centroid of light reflection nearest dynode center
26+: First dark ring around dynode center
*/
if ( fPMT<19999 && fBolt > 0 && fBolt < 25) { return true; } //finds if the data is really a bolt.
return false;
}
std::istream& operator>>( std::istream& in, MedianTextRecord & rec ){
unsigned num, pmt, bolt, x, y;
std::string id;
char dash;
in >> num >> pmt >> dash >> bolt >> x >> y >> id;
rec = MedianTextRecord( num, pmt, bolt, x, y, id );
return in;
}
MedianTextReader * MedianTextReader::instance = nullptr;
MedianTextReader::MedianTextReader() {}
MedianTextReader* MedianTextReader::Get(){
if ( instance == nullptr ) instance = new MedianTextReader();
return instance;
}
void MedianTextReader::set_input_file( const std::string& fname ){
if ( fData.size() > 0 ){
fData.clear();
}
std::ifstream infile( fname );
MedianTextRecord r;
while ( infile >> r ){
if(r.is_bolt()){
fData.push_back( r );
}
}
}
std::ostream& operator<<( std::ostream& out, const MedianTextRecord& r ){
out << r.photo_num() <<" "
<< r.pmt_num() <<"-"
<< r.bolt_num() <<" "
<< r.x() <<" "
<< r.y() <<" "
<< r.id() <<std::endl;
return out;
}