29 int main(
int argc,
char **argv)
40 JParser<> zap(
"Auxiliary program to determine standard deviation of a set of 1D histograms.");
42 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
48 catch(
const exception &error) {
49 FATAL(error.what() << endl);
59 DEBUG(
"Input: " << *input << endl);
64 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
68 const TRegexp regexp(input->getObjectName());
70 TIter iter(dir->GetListOfKeys());
72 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
74 const TString tag(key->GetName());
76 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
80 if (tag.Contains(regexp) &&
isTObject(key)) {
84 if (!p->InheritsFrom(
"TH1")) {
85 FATAL(
"Object " << p->GetName() <<
" not compatible with histogram operations." << endl);
90 h3 = (TH1*) p->Clone(
"stdev");
96 if (h3->GetXaxis()->GetNbins() != h1->GetXaxis()->GetNbins() ||
97 h3->GetXaxis()->GetXmin () != h1->GetXaxis()->GetXmin () ||
98 h3->GetXaxis()->GetXmax () != h1->GetXaxis()->GetXmax ()) {
99 FATAL(
"Objects " << h3->GetName() <<
" and " << p->GetName() <<
" have different binning." << endl);
103 listOfHistograms.push_back((TH1*) p);
108 if (listOfHistograms.size() <= 1) {
109 FATAL(
"Not enough histograms " << listOfHistograms.size() << endl);
112 for (Int_t i = 1; i <= h3->GetNbinsX(); ++i) {
118 Y += (*p)->GetBinContent(i);
119 Z += (*p)->GetBinError(i) * (*p)->GetBinError(i);
123 Y /= listOfHistograms.size();
124 Z /= listOfHistograms.size();
129 y += ((*p)->GetBinContent(i) - Y)*((*p)->GetBinContent(i) - Y) / ((*p)->GetBinError(i)*(*p)->GetBinError(i) + Z*Z);
132 y = sqrt(
y / listOfHistograms.size());
134 h3->SetBinContent(i,
y);
135 h3->SetBinError (i, 0.0);
General purpose messaging.
#define DEBUG(A)
Message macros.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
int main(int argc, char **argv)
Utility class to parse command line options.
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).