29int main(
int argc,
char **argv)
44 JParser<> zap(
"Auxiliary program to zoom 1D histograms.");
46 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
54 catch(
const exception &error) {
55 FATAL(error.what() << endl);
60 for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
62 DEBUG(
"Input: " << *input << endl);
64 TDirectory* dir = getDirectory(*input);
67 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
71 const TRegexp regexp(input->getObjectName());
73 TIter iter(dir->GetListOfKeys());
75 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
77 const TString tag(key->GetName());
79 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
83 if (tag.Contains(regexp) && isTObject(key)) {
85 TH1D* ha =
dynamic_cast<TH1D*
>(key->ReadObj());
89 const Int_t ix1 = max(ha->GetXaxis()->FindBin(X.getLowerLimit()), 1);
90 const Int_t ix2 = min(ha->GetXaxis()->FindBin(X.getUpperLimit()), ha->GetXaxis()->GetNbins());
93 <<
"[" << ix1 <<
"," << ix2 <<
"]" << endl);
95 TH1D* hb =
new TH1D(
MAKE_CSTRING(ha->GetName() <<
".zoom"), NULL,
96 ix2 - ix1 + 1, ha->GetXaxis()->GetBinLowEdge(ix1), ha->GetXaxis()->GetBinUpEdge(ix2));
98 if (fabs(ha->GetXaxis()->GetBinWidth(1) - hb->GetXaxis()->GetBinWidth(1)) > precision) {
99 FATAL(
"Binwidth x " <<
FIXED(9,5) << ha->GetXaxis()->GetBinWidth(1) <<
" != " <<
FIXED(9,5) << hb->GetXaxis()->GetBinWidth(1) << endl);
102 for (Int_t ix = ix1; ix <= ix2; ++ix) {
104 hb->SetBinContent(ix - ix1 + 1, ha->GetBinContent(ix));
106 if (ha->GetSumw2N()) {
107 hb->SetBinError(ix - ix1 + 1, ha->GetBinError(ix));
111 listOfObjects.push_back(hb);
117 if (!listOfObjects.empty()) {
121 for (vector<TObject*>::const_iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {