59int main(
int argc,
char **argv)
72 JParser<> zap(
"Auxiliary program for histogram operations.");
74 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
89 <<
"\n\t\"" << JOpera::SAME_AS_OPERATION() <<
"\" -> same as operation; or"
90 <<
"\n\t\"" << JOpera::SAME_AS_INPUT() <<
"\" -> same as input; else"
91 <<
"\n\t as specified") = JOpera::SAME_AS_OPERATION();
96 catch(
const exception &error) {
110 ERROR(
"File: " << input->getFullFilename() <<
" not opened." <<
endl);
120 const TString tag(key->GetName());
126 if (tag.Contains(
regexp) && isTObject(key)) {
130 if (
dynamic_cast<TH2*
>(p) ==
NULL) {
131 FATAL(
"Object " << p->GetName() <<
" not compatible with histogram operations." <<
endl);
147 opera == JOpera::Subtract() ||
148 opera == JOpera::Multiply() ||
149 opera == JOpera::Divide() ||
150 opera == JOpera::Replace())) {
155 TF2* f1 =
dynamic_cast<TF2*
>(h1->GetListOfFunctions()->First());
158 FATAL(h1->GetName() <<
" has no associated function." <<
endl);
163 if (name == JOpera::SAME_AS_OPERATION())
165 else if (name == JOpera::SAME_AS_INPUT())
166 h3 = (
TH2*) h1->Clone(h1->GetName());
168 h3 = (
TH2*) h1->Clone(name.c_str());
170 if (
opera == JOpera::Add()) {
174 }
else if (
opera == JOpera::Subtract()) {
178 }
else if (
opera == JOpera::Multiply()) {
182 }
else if (
opera == JOpera::Divide()) {
186 }
else if (
opera == JOpera::Replace()) {
189 h3->Fill(0.0, 0.0, 0.0);
200 if (name == JOpera::SAME_AS_OPERATION())
202 else if (name == JOpera::SAME_AS_INPUT())
203 h3 = (
TH2*) h1->Clone(h1->GetName());
205 h3 = (
TH2*) h1->Clone(name.c_str());
207 if (
opera == JOpera::Add()) {
209 h3->Add (h1, h2, +1.0, +1.0);
211 }
else if (
opera == JOpera::Subtract()) {
213 h3->Add (h1, h2, +1.0, -1.0);
215 }
else if (
opera == JOpera::Multiply()) {
217 h3->Multiply(h1, h2, +1.0, +1.0);
219 }
else if (
opera == JOpera::Divide()) {
221 h3->Divide (h1, h2, +1.0, +1.0);
223 }
else if (
opera == JOpera::add() ||
224 opera == JOpera::subtract() ||
225 opera == JOpera::multiply() ||
226 opera == JOpera::divide()) {
231 const Double_t x = h1->GetXaxis()->GetBinCenter(
i1);
232 const Double_t y = h1->GetYaxis()->GetBinCenter(
i2);
234 const Int_t j1 = h2->GetXaxis()->FindBin(x);
235 const Int_t j2 = h2->GetYaxis()->FindBin(y);
242 if (
opera == JOpera::add()) {
246 }
else if (
opera == JOpera::subtract()) {
250 }
else if (
opera == JOpera::multiply()) {
254 }
else if (
opera == JOpera::divide()) {
257 ERROR(
"Bin " << h2->GetName() <<
"[" <<
j1 <<
"," <<
j2 <<
"] empty." <<
endl);
268 }
else if (
opera == JOpera::efficiency() ||
269 opera == JOpera::stdev() ||
270 opera == JOpera::sqrt()) {
284 if (
opera == JOpera::efficiency()) {
287 ERROR(
"Bin " << h2->GetName() <<
"[" <<
i1 <<
"," <<
i2 <<
"] empty." <<
endl);
299 w3 =
y3 * fabs(
y3 - 1.0) * sqrt(w1*w1 + w2*w2);
302 }
else if (
opera == JOpera::stdev()) {
304 w3 = sqrt(w1*w1 + w2*w2);
311 }
else if (
opera == JOpera::sqrt()) {
313 y3 = (y1+y2) * (y1-y2);
329 }
else if (
opera == JOpera::Add() ||
330 opera == JOpera::Multiply()) {
334 TH2* h1 =
dynamic_cast<TH2*
>(*i);
340 if (name == JOpera::SAME_AS_OPERATION())
342 else if (name == JOpera::SAME_AS_INPUT())
343 h3 = (
TH2*) h1->Clone(h1->GetName());
345 h3 = (
TH2*) h1->Clone(name.c_str());
349 if (
opera == JOpera::Add()) {
351 h3->Add (
h3, h1, +1.0, +1.0);
353 }
else if (
opera == JOpera::Multiply()) {
355 h3->Multiply(
h3, h1, +1.0, +1.0);