32int main(
int argc,
char **argv)
45 JParser<> zap(
"Auxiliary program to extract quantiles from 2D histogram.");
55 catch(
const exception &error) {
56 FATAL(error.what() << endl);
61 FATAL(
"No quantiles." << endl);
67 for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
69 DEBUG(
"Input: " << *input << endl);
71 TDirectory* dir = getDirectory(*input);
74 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
78 const TRegexp regexp(input->getObjectName());
80 TIter iter(dir->GetListOfKeys());
82 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
84 const TString tag(key->GetName());
86 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
90 if (tag.Contains(regexp) && isTObject(key)) {
92 TObject*
object = key->ReadObj();
96 TH2& h2 =
dynamic_cast<TH2&
>(*object);
100 for (
size_t i = 0; i != Q.size(); ++i) {
105 os << i <<
"[" << setw(3) << (int) (100.0 * Q[i]) <<
"%]";
107 DEBUG(
"Creating 1D histogram: " << os.str() << endl);
109 TAxis* axis = h2.GetXaxis();
111 if (axis->IsVariableBinSize())
112 h1[i] =
new TH1D(os.str().c_str(), NULL, axis->GetNbins(), axis->GetXbins()->GetArray());
114 h1[i] =
new TH1D(os.str().c_str(), NULL, axis->GetNbins(), axis->GetXmin(), axis->GetXmax());
118 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
122 for (Int_t iy = 0; iy <= h2.GetYaxis()->GetNbins() + 1; ++iy) {
123 W += h2.GetBinContent(ix,iy);
132 for (
int iy = 0, k = 0; iy <= h2.GetYaxis()->GetNbins() + 1; ++iy) {
134 w += h2.GetBinContent(ix,iy);
136 for ( ; k != (int) h1.size() && w >= Q[k]*W; ++k) {
137 h1[k]->SetBinContent(ix, h2.GetYaxis()->GetBinCenter(iy));
143 for (
int iy = h2.GetYaxis()->GetNbins() + 1, k = 0; iy >= 0; --iy) {
145 w += h2.GetBinContent(ix,iy);
147 for ( ; k != (int) h1.size() && w >= Q[k]*W; ++k) {
148 h1[k]->SetBinContent(ix, h2.GetYaxis()->GetBinCenter(iy));
162 ERROR(
"Not available for other objects than 2D histograms." << endl);