/** * @file PbarAtLead.cc */ //------------------------------------------------------------------ #include #include #include #include #include #include const std::string PbarAtLead::_tag = "PbarAtLead"; //------------------------------------------------------------------ PbarAtLead::PbarAtLead(void): _ok(false), _fixedValuesSet(false), _thresholdsSet(false) { } //------------------------------------------------------------------ PbarAtLead:: PbarAtLead(const TileInfo &tiling, const std::vector &thresh) : _ok(true), _fixedValuesSet(true), _thresholdsSet(true), _thresh(thresh) { for (size_t i=0; i vstring; if (TaXml::readStringArray(xml, "PbarThresh", vstring)) { LOG(ERROR) << "Reading tag PbarThresh"; _ok = false; return; } for (size_t i=0; i PbarAtLead::getTilePbar(int threshIndex) const { vector ret; if (!_thresholdsSet) { return ret; } return _pbarAtThresh[threshIndex].pbar(); } //------------------------------------------------------------------ std::vector PbarAtLead::getPbarsForOneTile(int tileIndex) const { vector ret; if (!_thresholdsSet) { return ret; } for (size_t i=0; i<_pbarAtThresh.size(); ++i) { ret.push_back(_pbarAtThresh[i].pbarForTile(tileIndex)); } return ret; } //------------------------------------------------------------------ void PbarAtLead::copyPbarForAllThresh(int fromTile, int toTile) { for (size_t i=0; i<_pbarAtThresh.size(); ++i) { _pbarAtThresh[i].setPbar(toTile, _pbarAtThresh[i].pbarForTile(fromTile)); } } //------------------------------------------------------------------ void PbarAtLead::setPbarForAllThresh(int tileIndex, const std::vector &pbar) { if (pbar.size() != _pbarAtThresh.size()) { LOG(ERROR) << "Mismatch in number of thresholds " << pbar.size() << " " << _pbarAtThresh.size(); return; } for (size_t i=0;i= (int)_thresh.size()) { LOG(ERROR) << "Setting tiled grids for bar obar index " << threshIndex; return; } _pbarAtThresh[threshIndex].setPbar(tileIndex, value); } //------------------------------------------------------------------ bool PbarAtLead::getTiledGrid(const std::string &inputName, double thresh, const TileInfo &tiling, double centerWeight, double edgeWeight, int nptSmooth, Grid2d &item) const { for (size_t i=0; i<_pbarAtThresh.size(); ++i) { if (_thresh[i] == thresh) { char buf[1000]; sprintf(buf, "_%05.2lf_pbar", thresh); std::string name = inputName + buf; return _pbarAtThresh[i].constructTiledGrid(name, tiling, centerWeight, edgeWeight, nptSmooth, item); } } LOG(ERROR) << "No thresh in db " << thresh; return false; } //------------------------------------------------------------------ void PbarAtLead::print(int lt, const TileInfo &info, bool verbose) const { printf("Pbar thresh:"); for (size_t i=0; i<_thresh.size(); ++i) { printf(" %5.2lf", _thresh[i]); } printf("\n"); for (size_t i=0; i<_pbarAtThresh.size(); ++i) { _pbarAtThresh[i].print(lt, _thresh[i], info, verbose); } } //------------------------------------------------------------------ void PbarAtLead::print(int lt, const std::vector &tiles, const TileInfo &info, bool verbose) const { printf("Pbar thresholds:"); for (size_t i=0; i<_thresh.size(); ++i) { printf(" %5.2lf", _thresh[i]); } printf("\n"); for (size_t i=0; i<_pbarAtThresh.size(); ++i) { _pbarAtThresh[i].print(lt, _thresh[i], tiles, info, verbose); } }