-
Notifications
You must be signed in to change notification settings - Fork 1
/
VWPulseHeightCalibration.cpp
54 lines (42 loc) · 1.32 KB
/
VWPulseHeightCalibration.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
#include <VWPulseHeightCalibration.h>
//____________________________________________________
VWPulseHeightCalibration::VWPulseHeightCalibration(int num_bars) :
fNumBars(num_bars),
fGeoMeanScalingFactors(new double [fNumBars]),
fGainMatched(false)
{}
//____________________________________________________
VWPulseHeightCalibration::~VWPulseHeightCalibration()
{
delete [] fGeoMeanScalingFactors;
}
//____________________________________________________
int VWPulseHeightCalibration::LoadGainMatching(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;
if(LineRead.find('*')==0) continue;
if(LineRead.find_first_not_of(' ') == std::string::npos) continue;
std::istringstream LineStream(LineRead);
int numbar;
double fraction;
LineStream >> numbar >> fraction;
fGeoMeanScalingFactors[numbar]=fraction;
NRead++;
}
fGainMatched=true;
return NRead;
}
//____________________________________________________
double VWPulseHeightCalibration::GetGeoMeanMatched(double ch, int num_bar) const
{
return fGainMatched ? ch*fGeoMeanScalingFactors[num_bar] : -9999;
}