6 #include <calobase/RawTower.h>
7 #include <calobase/RawTowerContainer.h>
8 #include <calobase/RawTowerDefs.h>
10 #include <phparameter/PHParameters.h>
22 #include <boost/format.hpp>
40 , _calib_towers(nullptr)
41 , _raw_towers(nullptr)
43 , _calib_tower_node_prefix(
"CALIB")
44 , _raw_tower_node_prefix(
"RAW")
46 , _fit_type(kPowerLawDoubleExpWithGlobalFitConstraint)
58 std::cout <<
Name() <<
"::" <<
detector <<
"::" << __PRETTY_FUNCTION__
59 <<
" - print calibration parameters: " << endl;
71 std::cout <<
Name() <<
"::" <<
detector <<
"::" << __PRETTY_FUNCTION__
72 <<
"Process event entered" << std::endl;
75 map<int, double> parameters_constraints;
82 <<
Name() <<
"::" <<
detector <<
"::" << __PRETTY_FUNCTION__
83 <<
"Extract global fit parameter for constraining individual fits"
95 for (rtiter = begin_end.first; rtiter != begin_end.second; ++rtiter)
120 vec_signal_samples[
i] =
121 numeric_limits<double>::quiet_NaN();
132 vec_signal_samples[
i] /=
count;
136 double peak_sample = NAN;
137 double pedstal = NAN;
138 map<int, double> parameters_io;
141 peak_sample, pedstal,
149 parameters_constraints[1] = parameters_io[1];
150 parameters_constraints[2] = parameters_io[2];
151 parameters_constraints[3] = parameters_io[3];
152 parameters_constraints[5] = parameters_io[5];
153 parameters_constraints[6] = parameters_io[6];
178 std::cout <<
Name() <<
"::" <<
detector <<
"::" << __PRETTY_FUNCTION__
179 <<
": Failed to build signal template! Fit each channel "
180 "individually instead"
185 const double calib_const_scale =
187 const bool use_chan_calibration =
192 for (rtiter = begin_end.first; rtiter != begin_end.second; ++rtiter)
199 double calibration_const = calib_const_scale;
201 if (use_chan_calibration)
205 const int row = raw_tower->
get_row();
210 string calib_const_name(
216 vector<double> vec_signal_samples;
223 double peak_sample = NAN;
224 double pedstal = NAN;
240 map<int, double> parameters_io;
243 peak_sample, pedstal,
250 map<int, double> parameters_io(parameters_constraints);
253 peak_sample, pedstal,
258 cout << __PRETTY_FUNCTION__ <<
" - FATAL error - unkown fit type "
280 calib_tower->
set_energy(peak * calibration_const);
295 std::cout <<
Name() <<
"::" <<
detector <<
"::" << __PRETTY_FUNCTION__
297 <<
", output sum digitalized value = "
310 dynamic_cast<PHCompositeNode *
>(iter.findFirst(
"PHCompositeNode",
"DST"));
313 std::cerr <<
Name() <<
"::" <<
detector <<
"::" << __PRETTY_FUNCTION__
314 <<
"DST Node missing, doing nothing." << std::endl;
315 throw std::runtime_error(
316 "Failed to find DST node in RawTowerCalibration::CreateNodes");
324 std::cerr <<
Name() <<
"::" << detector <<
"::" << __PRETTY_FUNCTION__
328 " node in RawTowerCalibration::CreateNodes");
334 dstiter.findFirst(
"PHCompositeNode", detector));
338 dstNode->addNode(DetNode);
351 DetNode->addNode(towerNode);
356 dynamic_cast<PHCompositeNode *
>(iter.findFirst(
"PHCompositeNode",
"RUN"));