29int main(
int argc,
char **argv)
46 JParser<> zap(
"Auxiliary program to zoom 3D histograms.");
48 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
58 catch(
const exception &error) {
59 FATAL(error.what() << endl);
64 for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
66 DEBUG(
"Input: " << *input << endl);
68 TDirectory* dir = getDirectory(*input);
71 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
75 const TRegexp regexp(input->getObjectName());
77 TIter iter(dir->GetListOfKeys());
79 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
81 const TString tag(key->GetName());
83 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
87 if (tag.Contains(regexp) && isTObject(key)) {
89 TH3D* ha =
dynamic_cast<TH3D*
>(key->ReadObj());
93 const Int_t ix1 = max(ha->GetXaxis()->FindBin(X.getLowerLimit()), 1);
94 const Int_t ix2 = min(ha->GetXaxis()->FindBin(X.getUpperLimit()), ha->GetXaxis()->GetNbins());
95 const Int_t iy1 = max(ha->GetYaxis()->FindBin(Y.getLowerLimit()), 1);
96 const Int_t iy2 = min(ha->GetYaxis()->FindBin(Y.getUpperLimit()), ha->GetYaxis()->GetNbins());
97 const Int_t iz1 = max(ha->GetZaxis()->FindBin(Z.getLowerLimit()), 1);
98 const Int_t iz2 = min(ha->GetZaxis()->FindBin(Z.getUpperLimit()), ha->GetZaxis()->GetNbins());
101 <<
"[" << ix1 <<
"," << ix2 <<
"]" <<
" x "
102 <<
"[" << iy1 <<
"," << iy2 <<
"]" <<
" x "
103 <<
"[" << iz1 <<
"," << iz2 <<
"]" << endl);
105 TH3D* hb =
new TH3D(
MAKE_CSTRING(ha->GetName() <<
".zoom"), NULL,
106 ix2 - ix1 + 1, ha->GetXaxis()->GetBinLowEdge(ix1), ha->GetXaxis()->GetBinUpEdge(ix2),
107 iy2 - iy1 + 1, ha->GetYaxis()->GetBinLowEdge(iy1), ha->GetYaxis()->GetBinUpEdge(iy2),
108 iz2 - iz1 + 1, ha->GetZaxis()->GetBinLowEdge(iz1), ha->GetZaxis()->GetBinUpEdge(iz2));
110 if (fabs(ha->GetXaxis()->GetBinWidth(1) - hb->GetXaxis()->GetBinWidth(1)) > precision) {
111 FATAL(
"Binwidth x " <<
FIXED(9,5) << ha->GetXaxis()->GetBinWidth(1) <<
" != " <<
FIXED(9,5) << hb->GetXaxis()->GetBinWidth(1) << endl);
113 if (fabs(ha->GetYaxis()->GetBinWidth(1) - hb->GetYaxis()->GetBinWidth(1)) > precision) {
114 FATAL(
"Binwidth y " <<
FIXED(9,5) << ha->GetYaxis()->GetBinWidth(1) <<
" != " <<
FIXED(9,5) << hb->GetYaxis()->GetBinWidth(1) << endl);
116 if (fabs(ha->GetZaxis()->GetBinWidth(1) - hb->GetZaxis()->GetBinWidth(1)) > precision) {
117 FATAL(
"Binwidth z " <<
FIXED(9,5) << ha->GetZaxis()->GetBinWidth(1) <<
" != " <<
FIXED(9,5) << hb->GetZaxis()->GetBinWidth(1) << endl);
120 for (Int_t ix = ix1; ix <= ix2; ++ix) {
121 for (Int_t iy = iy1; iy <= iy2; ++iy) {
122 for (Int_t iz = iz1; iz <= iz2; ++iz) {
124 hb->SetBinContent(ix - ix1 + 1, iy - iy1 + 1, iz - iz1 + 1, ha->GetBinContent(ix, iy, iz));
126 if (ha->GetSumw2N()) {
127 hb->SetBinError(ix - ix1 + 1, iy - iy1 + 1, iz - iz1 + 1, ha->GetBinError(ix, iy, iz));
133 listOfObjects.push_back(hb);
139 if (!listOfObjects.empty()) {
143 for (vector<TObject*>::const_iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {