1717
1818SBND ::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."
0 commit comments