-
Notifications
You must be signed in to change notification settings - Fork 1
/
NWCosmicRayManager.cpp
68 lines (55 loc) · 1.7 KB
/
NWCosmicRayManager.cpp
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
#include "include/NWCosmicRayManager.h"
//____________________________________________________
NWCosmicRayManager::NWCosmicRayManager(int num_bars) :
fNumBars(num_bars),
fCenter(0),
fSigma(0),
fPositionLoaded(false)
{
fCenter=new double[fNumBars];
fSigma=new double[fNumBars];
}
//____________________________________________________
NWCosmicRayManager::~NWCosmicRayManager()
{
if(fCenter) delete [] fCenter;
if(fSigma) delete [] fSigma;
}
//____________________________________________________
int NWCosmicRayManager::LoadPeakPositions(const char * file_name)
{
std::ifstream FileIn(file_name);
if(!FileIn.is_open()) {
return -1;
}
int NRead=0;
while (!FileIn.eof())
{
std::string LineRead;
std::getline(FileIn, LineRead);
if(LineRead.empty()) continue;
LineRead.assign(LineRead.substr(0,LineRead.find('*')));
if(LineRead.find_first_not_of(' ') == std::string::npos) continue;
std::istringstream LineStream(LineRead);
std::string DetName;
double center;
double sigma;
LineStream>>DetName>>center>>sigma;
int NumBar=std::stoi(DetName.substr(DetName.find("bar")+3));
fCenter[NumBar]=center;
fSigma[NumBar]=sigma;
NRead++;
}
NRead>0 ? fPositionLoaded=true : fPositionLoaded=false;
return NRead;
}
//____________________________________________________
double NWCosmicRayManager::GetCosmicRayCenter(int num_bar) const
{
return fPositionLoaded ? fCenter[num_bar] : -9999;
}
//____________________________________________________
double NWCosmicRayManager::GetCosmicRayStartingPoint(int num_bar) const
{
return fPositionLoaded ? fCenter[num_bar]-2*fSigma[num_bar] : -9999;
}