/** * Update the detector information from a raw file * @param filename :: The input filename */ void UpdateInstrumentFromFile::updateFromRaw(const std::string & filename) { ISISRAW2 iraw; if (iraw.readFromFile(filename.c_str(),false) != 0) { g_log.error("Unable to open file " + filename); throw Exception::FileError("Unable to open File:" , filename); } const int32_t numDetector = iraw.i_det; std::vector<int32_t> detID(iraw.udet, iraw.udet + numDetector); std::vector<float> l2(iraw.len2, iraw.len2 + numDetector); std::vector<float> theta(iraw.tthe, iraw.tthe + numDetector); // Is ut01 (=phi) present? Sometimes an array is present but has wrong values e.g.all 1.0 or all 2.0 bool phiPresent = iraw.i_use>0 && iraw.ut[0]!= 1.0 && iraw.ut[0] !=2.0; std::vector<float> phi(0); if( phiPresent ) { phi = std::vector<float>(iraw.ut, iraw.ut + numDetector); } else { phi = std::vector<float>(numDetector, 0.0); } g_log.information() << "Setting detector postions from RAW file.\n"; setDetectorPositions(detID, l2, theta, phi); }
/** * Full format is defined in doc text * @param filename A full path to the input DAT file */ void LoadDetectorInfo::loadFromDAT(const std::string & filename) { std::ifstream datFile(filename.c_str()); if(!datFile) { throw Exception::FileError("Unable to access dat file", filename); } std::string line; // skip 3 lines of header info for(int i = 0; i < 3; ++i) getline(datFile, line); // start loop over file auto & pmap = m_workspace->instrumentParameters(); while(getline(datFile, line)) { if(line.empty() || line[0] == '#') continue; std::istringstream is(line); detid_t detID(0); int code(0); float droppedFloat(0.0f); float delta(0.0f), l2(0.0f), theta(0.0f), phi(0.0f); is >> detID >> delta >> l2 >> code >> theta >> phi; // offset value is be subtracted so store negative delta *= -1.0f; IDetector_const_sptr det; try { det = m_baseInstrument->getDetector(detID); } catch(Exception::NotFoundError&) { continue; } if(det->isMonitor() || code == 1) continue; // drop 10 float columns for(int i = 0; i < 10; ++i) is >> droppedFloat; // pressure, wall thickness float pressure(0.0), thickness(0.0); is >> pressure >> thickness; updateParameterMap(pmap, det, l2, theta, phi, delta, pressure, thickness); } }