Skip to content

Commit ce63868

Browse files
committed
Factorise timing corrections out into four categories
1 parent 6e3f515 commit ce63868

7 files changed

Lines changed: 582 additions & 24 deletions

sbndcode/Calibration/CRT/CalibService/CRTCalibService.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ class SBND::CRTCalibService {
3131
CRTCalibService(fhicl::ParameterSet const& pset);
3232
CRTCalibService(fhicl::ParameterSet const& pset, art::ActivityRegistry&);
3333

34-
double GetTimingOffsetFromFEBMAC5(unsigned int feb_mac5) const;
34+
double GetT0CableOffsetFromFEBMAC5(unsigned int feb_mac5) const;
35+
36+
double GetT1CableOffsetFromFEBMAC5(unsigned int feb_mac5) const;
37+
38+
double GetT0CalibOffsetFromFEBMAC5(unsigned int feb_mac5) const;
39+
40+
double GetT1CalibOffsetFromFEBMAC5(unsigned int feb_mac5) const;
3541

3642
double GetPedestalFromFEBMAC5AndChannel(unsigned int feb_mac5, unsigned int ch) const;
3743

@@ -40,7 +46,8 @@ class SBND::CRTCalibService {
4046

4147
private:
4248

43-
std::unordered_map<unsigned int, double> fTimingOffsetFromFEBMAC5;
49+
std::unordered_map<unsigned int, double> fT0CableOffsetFromFEBMAC5, fT1CableOffsetFromFEBMAC5,
50+
fT0CalibOffsetFromFEBMAC5, fT1CalibOffsetFromFEBMAC5;
4451

4552
std::unordered_map<unsigned int, std::unordered_map<unsigned int, double>> fPedestalFromFEBMAC5AndChannel;
4653

sbndcode/Calibration/CRT/CalibService/CRTCalibService_service.cc

Lines changed: 143 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,44 @@
1717

1818
SBND::CRTCalibService::CRTCalibService(fhicl::ParameterSet const& pset)
1919
{
20-
const std::string timingOffsetFile = pset.get<std::string>("TimingOffsetFileName");
21-
const std::string pedestalFile = pset.get<std::string>("PedestalFileName");
22-
const std::string badChannelsFile = pset.get<std::string>("BadChannelsFileName");
23-
24-
std::string timingOffsetPath, pedestalPath, badChannelsPath;
20+
const std::string t0CableOffsetFile = pset.get<std::string>("T0CableOffsetFileName");
21+
const std::string t1CableOffsetFile = pset.get<std::string>("T1CableOffsetFileName");
22+
const std::string t0CalibOffsetFile = pset.get<std::string>("T0CalibOffsetFileName");
23+
const std::string t1CalibOffsetFile = pset.get<std::string>("T1CalibOffsetFileName");
24+
const std::string pedestalFile = pset.get<std::string>("PedestalFileName");
25+
const std::string badChannelsFile = pset.get<std::string>("BadChannelsFileName");
26+
27+
std::string t0CableOffsetPath, t1CableOffsetPath, t0CalibOffsetPath, t1CalibOffsetPath,
28+
pedestalPath, badChannelsPath;
2529
cet::search_path sp("FW_SEARCH_PATH");
26-
sp.find_file(timingOffsetFile, timingOffsetPath);
30+
sp.find_file(t0CableOffsetFile, t0CableOffsetPath);
31+
sp.find_file(t1CableOffsetFile, t1CableOffsetPath);
32+
sp.find_file(t0CalibOffsetFile, t0CalibOffsetPath);
33+
sp.find_file(t1CalibOffsetFile, t1CalibOffsetPath);
2734
sp.find_file(pedestalFile, pedestalPath);
2835
sp.find_file(badChannelsFile, badChannelsPath);
2936

30-
if(timingOffsetPath.empty())
37+
if(t0CableOffsetPath.empty())
38+
{
39+
std::cout << "SBND::CRTCalibService Input file " << t0CableOffsetFile << " not found" << std::endl;
40+
throw cet::exception("File not found");
41+
}
42+
43+
if(t1CableOffsetPath.empty())
44+
{
45+
std::cout << "SBND::CRTCalibService Input file " << t1CableOffsetFile << " not found" << std::endl;
46+
throw cet::exception("File not found");
47+
}
48+
49+
if(t0CalibOffsetPath.empty())
50+
{
51+
std::cout << "SBND::CRTCalibService Input file " << t0CalibOffsetFile << " not found" << std::endl;
52+
throw cet::exception("File not found");
53+
}
54+
55+
if(t1CalibOffsetPath.empty())
3156
{
32-
std::cout << "SBND::CRTCalibService Input file " << timingOffsetFile << " not found" << std::endl;
57+
std::cout << "SBND::CRTCalibService Input file " << t1CalibOffsetFile << " not found" << std::endl;
3358
throw cet::exception("File not found");
3459
}
3560

@@ -46,26 +71,77 @@ SBND::CRTCalibService::CRTCalibService(fhicl::ParameterSet const& pset)
4671
}
4772

4873
std::cout << "SBND CRT Channel Map: Building map from files...\n"
49-
<< "\t Timing Offsets: " << timingOffsetFile << '\n'
74+
<< "\t T0 Offsets Cable: " << t0CableOffsetFile << '\n'
75+
<< "\t T1 Offsets Cable: " << t1CableOffsetFile << '\n'
76+
<< "\t T0 Offsets Calib: " << t0CalibOffsetFile << '\n'
77+
<< "\t T1 Offsets Calib: " << t1CalibOffsetFile << '\n'
5078
<< "\t Pedestals: " << pedestalFile << '\n'
5179
<< "\t Bad Channels: " << badChannelsFile << std::endl;
5280

53-
std::ifstream timingOffsetStream(timingOffsetPath, std::ios::in);
81+
std::ifstream t0CableOffsetStream(t0CableOffsetPath, std::ios::in);
5482
std::string line;
5583

56-
while(std::getline(timingOffsetStream, line))
84+
while(std::getline(t0CableOffsetStream, line))
5785
{
5886
std::stringstream linestream(line);
59-
87+
6088
unsigned int mac5, offset;
61-
linestream
89+
linestream
6290
>> mac5
6391
>> offset;
6492

65-
fTimingOffsetFromFEBMAC5[mac5] = offset;
93+
fT0CableOffsetFromFEBMAC5[mac5] = offset;
6694
}
67-
68-
timingOffsetStream.close();
95+
96+
t0CableOffsetStream.close();
97+
98+
std::ifstream t1CableOffsetStream(t1CableOffsetPath, std::ios::in);
99+
100+
while(std::getline(t1CableOffsetStream, line))
101+
{
102+
std::stringstream linestream(line);
103+
104+
unsigned int mac5, offset;
105+
linestream
106+
>> mac5
107+
>> offset;
108+
109+
fT1CableOffsetFromFEBMAC5[mac5] = offset;
110+
}
111+
112+
t1CableOffsetStream.close();
113+
114+
std::ifstream t0CalibOffsetStream(t0CalibOffsetPath, std::ios::in);
115+
116+
while(std::getline(t0CalibOffsetStream, line))
117+
{
118+
std::stringstream linestream(line);
119+
120+
unsigned int mac5, offset;
121+
linestream
122+
>> mac5
123+
>> offset;
124+
125+
fT0CalibOffsetFromFEBMAC5[mac5] = offset;
126+
}
127+
128+
t0CalibOffsetStream.close();
129+
130+
std::ifstream t1CalibOffsetStream(t1CalibOffsetPath, std::ios::in);
131+
132+
while(std::getline(t1CalibOffsetStream, line))
133+
{
134+
std::stringstream linestream(line);
135+
136+
unsigned int mac5, offset;
137+
linestream
138+
>> mac5
139+
>> offset;
140+
141+
fT1CalibOffsetFromFEBMAC5[mac5] = offset;
142+
}
143+
144+
t1CalibOffsetStream.close();
69145

70146
std::ifstream pedestalStream(pedestalPath, std::ios::in);
71147

@@ -131,11 +207,59 @@ SBND::CRTCalibService::CRTCalibService(fhicl::ParameterSet const& pset, art::Act
131207
{
132208
}
133209

134-
double SBND::CRTCalibService::GetTimingOffsetFromFEBMAC5(unsigned int feb_mac5) const
210+
double SBND::CRTCalibService::GetT0CableOffsetFromFEBMAC5(unsigned int feb_mac5) const
211+
{
212+
auto iter = fT0CableOffsetFromFEBMAC5.find(feb_mac5);
213+
214+
if(iter == fT0CableOffsetFromFEBMAC5.end())
215+
{
216+
mf::LogInfo("SBND CRT Calibration Service") << "Asked for FEB with MAC5: " << feb_mac5 << '\n'
217+
<< "This FEB does not appear in the channel map."
218+
<< std::endl;
219+
220+
return 0.;
221+
}
222+
223+
return iter->second;
224+
}
225+
226+
double SBND::CRTCalibService::GetT1CableOffsetFromFEBMAC5(unsigned int feb_mac5) const
227+
{
228+
auto iter = fT1CableOffsetFromFEBMAC5.find(feb_mac5);
229+
230+
if(iter == fT1CableOffsetFromFEBMAC5.end())
231+
{
232+
mf::LogInfo("SBND CRT Calibration Service") << "Asked for FEB with MAC5: " << feb_mac5 << '\n'
233+
<< "This FEB does not appear in the channel map."
234+
<< std::endl;
235+
236+
return 0.;
237+
}
238+
239+
return iter->second;
240+
}
241+
242+
double SBND::CRTCalibService::GetT0CalibOffsetFromFEBMAC5(unsigned int feb_mac5) const
243+
{
244+
auto iter = fT0CalibOffsetFromFEBMAC5.find(feb_mac5);
245+
246+
if(iter == fT0CalibOffsetFromFEBMAC5.end())
247+
{
248+
mf::LogInfo("SBND CRT Calibration Service") << "Asked for FEB with MAC5: " << feb_mac5 << '\n'
249+
<< "This FEB does not appear in the channel map."
250+
<< std::endl;
251+
252+
return 0.;
253+
}
254+
255+
return iter->second;
256+
}
257+
258+
double SBND::CRTCalibService::GetT1CalibOffsetFromFEBMAC5(unsigned int feb_mac5) const
135259
{
136-
auto iter = fTimingOffsetFromFEBMAC5.find(feb_mac5);
260+
auto iter = fT1CalibOffsetFromFEBMAC5.find(feb_mac5);
137261

138-
if(iter == fTimingOffsetFromFEBMAC5.end())
262+
if(iter == fT1CalibOffsetFromFEBMAC5.end())
139263
{
140264
mf::LogInfo("SBND CRT Calibration Service") << "Asked for FEB with MAC5: " << feb_mac5 << '\n'
141265
<< "This FEB does not appear in the channel map."

sbndcode/Calibration/CRT/CalibService/SBNDCRTTimingOffsets_v1.txt renamed to sbndcode/Calibration/CRT/CalibService/SBNDCRTT0CableOffsets_v1.txt

File renamed without changes.
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
16 1.53
2+
18 -4.15
3+
19 -2.54
4+
24 0.43
5+
33 -0.47
6+
34 0.27
7+
35 -1.68
8+
36 -13.56
9+
39 -3.17
10+
40 -3.53
11+
42 -2.16
12+
44 0
13+
45 -3.21
14+
47 -1.91
15+
48 0.57
16+
49 -1.82
17+
50 -0.22
18+
51 -14.73
19+
55 -0.38
20+
56 -4.59
21+
57 0
22+
58 -0.08
23+
59 -0.77
24+
60 -4.22
25+
61 -26.48
26+
71 -15.07
27+
72 -2.77
28+
73 -0.08
29+
75 1.37
30+
77 -0.51
31+
78 -4.06
32+
79 -1.99
33+
81 -3.52
34+
82 0
35+
83 -1.85
36+
84 2.1
37+
85 -3.8
38+
86 -0.77
39+
87 -0.81
40+
88 2.72
41+
90 -0.77
42+
91 1.93
43+
93 2.7
44+
94 -0.81
45+
95 -0.81
46+
97 -0.81
47+
98 0.76
48+
99 1.16
49+
100 -1.36
50+
101 0
51+
102 0
52+
103 0
53+
104 2.31
54+
105 1.75
55+
106 -0.74
56+
107 -16.27
57+
109 3.53
58+
111 -15.98
59+
114 2.58
60+
115 -0.16
61+
116 0
62+
117 0.94
63+
118 0
64+
119 2.81
65+
120 0
66+
121 -2.03
67+
123 0.88
68+
125 -0.08
69+
126 -0.64
70+
127 -0.61
71+
128 -0.92
72+
129 -0.55
73+
130 -1.82
74+
131 -1.38
75+
132 -7.83
76+
133 -7.41
77+
134 -5.55
78+
135 -4.96
79+
136 -3.97
80+
138 -2.9
81+
141 -2.43
82+
143 -4.41
83+
144 -1.82
84+
145 1.44
85+
146 -2.44
86+
147 -1.73
87+
148 -4.91
88+
149 -0.03
89+
150 -3.67
90+
151 -4.35
91+
152 -2.43
92+
153 -1.63
93+
155 0.57
94+
156 -1.51
95+
157 -2.79
96+
158 -1.85
97+
159 -1.68
98+
160 -0.04
99+
162 -4.87
100+
163 -4.7
101+
164 -5.22
102+
165 -2.71
103+
166 -25.77
104+
168 -2.11
105+
169 -29.5
106+
170 -3.06
107+
171 -2.65
108+
172 0.82
109+
173 0.44
110+
174 -1.07
111+
176 -0.55
112+
178 -0.33
113+
179 -1.39
114+
180 -2.85
115+
182 0
116+
183 -0.07
117+
184 1.44
118+
185 1.28
119+
187 -13.43
120+
197 -4.74
121+
198 -2.25
122+
199 -4.72
123+
200 -5.23
124+
202 -2.71
125+
203 -1.89
126+
204 -5.12
127+
205 0.42
128+
206 -3.58
129+
207 -1.53
130+
209 -3.15
131+
210 -3.54
132+
211 -0.78
133+
212 -0.33
134+
213 0.34
135+
216 -2.87
136+
220 -2.35
137+
222 -1.04
138+
223 1.6
139+
228 -0.73
140+
238 2.72

0 commit comments

Comments
 (0)