13 #include "TFitResult.h"
60 JSetup(
const string& file_name) :
63 fp = TFile::Open(file_name.c_str(),
"read");
77 ResultSet& rs =
getResultSet(getTable <JPMTHVRunSettings>(),
85 location =
JLocation_t(parameters.DUID, parameters.FLOORID, parameters.PMTINTID);
87 location =
JLocation_t(parameters.DUID, parameters.FLOORID, parameters.CABLEPOS);
89 HV[location] = parameters.HV_VALUE;
101 TH2D*
get(
const string& key)
const
103 return (TH2D*) fp->Get(key.c_str());
122 int main(
int argc,
char **argv)
126 using namespace KM3NETDAQ;
149 JParser<> zap(
"Auxiliary program to check t0's.");
156 zap[
'f'] =
make_field(inputFile,
"pair of input files (output of JCalibrateK40)");
158 zap[
'e'] =
make_field(precision,
"precision for HV comparison") = 0.5;
160 zap[
'x'] =
make_field(
X,
"ROOT fit range (PMT pairs).") =
JRange_t(300, numeric_limits<size_t>::max());
161 zap[
'O'] =
make_field(option,
"ROOT fit option, see TH1::Fit.") =
"";
167 catch(
const exception &error) {
168 FATAL(error.what() << endl);
175 catch(
const exception& error) {
176 FATAL(error.what() << endl);
184 for (
int i = 0;
i != 2; ++
i) {
185 DEBUG(setw(32) << setups[
i].file_name <<
' ' << setups[
i].header.getDetectorID() <<
' ' << setups[
i].header.getRunNumber() << endl);
197 if (option.find(
'S') == string::npos) { option +=
'S'; }
204 TF1
f1(
"f1",
"[0]*TMath::Gaus(x,[1],[2]) + [3]");
206 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
213 DEBUG(
"Module " << setw(10) << module->getID() <<
' ' << (h2[0] != NULL) << (h2[0] != NULL) << endl);
228 for (
size_t ip = max(
X.getLowerLimit(), size_t(0)); ip != min(
X.getUpperLimit(), combinatorics.
getNumberOfPairs()); ++ip) {
232 const JLocation_t location_1(module->getString(), module->getFloor(), pair.first);
233 const JLocation_t location_2(module->getString(), module->getFloor(), pair.second);
235 const bool hv_1 = (fabs(setups[0].HV[location_1] - setups[1].HV[location_1]) < precision);
236 const bool hv_2 = (fabs(setups[0].HV[location_2] - setups[1].HV[location_2]) < precision);
239 numeric_limits<double>::max(),
240 numeric_limits<double>::max()
243 const Int_t ix = ip + 1;
245 for (
int i = 0;
i != 2; ++
i) {
247 TH1D h1(
"__py", NULL, h2[
i]->GetYaxis()->GetNbins(), h2[
i]->GetYaxis()->GetXmin(), h2[
i]->GetYaxis()->GetXmax());
251 Double_t ymin = numeric_limits<double>::max();
252 Double_t ymax = numeric_limits<double>::lowest();
254 Double_t
sigma = 4.5;
257 for (
int iy = 1; iy <= h1.GetNbinsX(); ++iy) {
259 const Double_t
x = h1.GetBinCenter(iy);
260 const Double_t
y = h2[
i]->GetBinContent(ix,iy);
262 h1.SetBinContent(iy, y);
263 h1.SetBinError (iy, sqrt(y));
279 f1.SetParameter(0, ymax);
280 f1.SetParameter(1, mean);
281 f1.SetParameter(2, sigma);
282 f1.SetParameter(3, ymin);
284 for (Int_t
i = 0;
i != f1.GetNpar(); ++
i) {
285 f1.SetParError(
i, 0.0);
288 TFitResultPtr
result = h1.Fit(&f1, option.c_str(),
"same");
290 if (result.Get() == NULL) {
291 FATAL(
"Invalid TFitResultPtr " << h1.GetName() << endl);
295 cout <<
"Histogram slice: "
296 << setw(3) << ix <<
' '
297 <<
FIXED(7,3) << f1.GetParameter(1) <<
" +/- "
298 <<
FIXED(7,3) << f1.GetParError(1) <<
' '
299 <<
FIXED(7,3) << result->Chi2() <<
'/'
300 << result->Ndf() <<
' '
301 << (result->IsValid() ?
"" :
"failed") << endl;
304 t1[
i] = f1.GetParameter(1);
308 if (t1[0] != numeric_limits<double>::max() &&
309 t1[1] != numeric_limits<double>::max()) {
324 cout << setw(10) << module->getID() <<
"." <<
FILL(2,
'0') << p2.first <<
FILL() <<
' ';
325 cout <<
"(" <<
FILL(2,
'0') << p2.second <<
FILL() <<
")" <<
' ';
326 cout <<
FIXED(6,2) << (combinatorics.
getSign(p2) * (t1[1] - t1[0])) << endl;
329 Q[p2.first].put(combinatorics.
getSign(p2) * (t1[1] - t1[0]));
336 H1[module->getID()]->SetBinContent(
i+1,
Q[
i].
getMean());
337 H1[module->getID()]->SetBinError (
i+1,
Q[
i].getSTDev());
Utility class to parse command line options.
JCombinatorics::pair_type pair_type
Q(UTCMax_s-UTCMin_s)-livetime_s
int main(int argc, char *argv[])
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Utility class to parse parameter values.
Auxiliary data structure for setup of complete system.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
#define MAKE_CSTRING(A)
Make C-string.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Dynamic ROOT object management.
Auxiliary data structure for floating point format specification.
Data structure for detector geometry and calibration.
double getMean(vector< double > &v)
get mean of vector content
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
Utility class to parse parameter values.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
Type definition of range.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
I/O formatting auxiliaries.
Auxiliary class to sort pairs of PMT addresses within optical module.
Auxiliary data structure for location of product in detector.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
void Write(TDirectory &out, const bool wm=false)
Write objects to file.
ROOT TTree parameter settings.
General purpose messaging.
Auxiliary data structure for sequence of same character.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Auxiliary class to define a range between two values.
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Utility class to parse command line options.
ResultSet & getResultSet(const std::string &query)
Get result set.
std::vector< JServer > getServernames()
Get list of names of available database servers.
int getCount(const T &hit)
Get hit count.
Wrapper class for server name.
no fit printf nominal n $STRING awk v X
do set_variable DETECTOR_TXT $WORKDIR detector
KM3NeT DAQ constants, bit handling, etc.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Template definition for getting table specific selector.
static const char *const _2S
Name extension for 2D counts.
#define DEBUG(A)
Message macros.