121 std::string instname = inst->getName();
123 auto expInfoWS = std::dynamic_pointer_cast<ExperimentInfo>(ws);
124 auto &componentInfo = expInfoWS->mutableComponentInfo();
130 double width,
height, depth, detd,
x,
y,
z, base_x, base_y, base_z, up_x, up_y, up_z;
131 std::ifstream input(filenames[0].c_str(), std::ios_base::in);
135 std::vector<size_t> detList;
136 for (
size_t i = 0; i < componentInfo.size(); ++i) {
137 if (componentInfo.isGridDetector(i)) {
138 detList.emplace_back(i);
141 std::unordered_set<int> uniqueBanks;
142 std::string bankPart =
"bank";
143 if (instname ==
"WISH")
144 bankPart =
"WISHpanel";
145 if (detList.empty()) {
147 size_t const rootIndex = componentInfo.root();
148 auto const topChildren = componentInfo.children(rootIndex);
149 for (
size_t const i : topChildren) {
151 size_t bankParent = componentInfo.findBankParent(i, bankPart);
152 auto const children = componentInfo.children(bankParent);
153 for (
size_t const child : children) {
154 std::string bankName = componentInfo.name(child);
155 boost::trim(bankName);
156 boost::erase_all(bankName, bankPart);
159 uniqueBanks.insert(bank);
165 std::vector<ComponentScaling> rectangularDetectorScalings;
167 while (std::getline(input, line)) {
168 if (line[0] ==
'7') {
170 std::stringstream(line) >>
count >> mL1 >> mT0;
173 const std::string sourceName = instname ==
"WISH" ?
"undulator" :
"moderator";
176 sourceIndex = componentInfo.indexOfAny(sourceName);
177 }
catch (
const std::invalid_argument &) {
178 throw std::runtime_error(
"Component with name " + sourceName +
" was not found.");
180 center(0.0, 0.0, -mL1, sourceIndex, componentInfo);
184 API::Run &run = inputW->mutableRun();
191 alg1->setProperty(
"Offset", mT0 - T0IDF);
193 alg1->setProperty(
"Offset", mT0);
195 alg1->executeAsChildAlg();
196 inputW = alg1->getProperty(
"OutputWorkspace");
201 API::Run &run = inputP->mutableRun();
211 base_x >> base_y >> base_z >> up_x >> up_y >> up_z;
212 if (
id == 10 && filenames.size() == 2 && instname ==
"SNAP") {
214 input.open(filenames[1].c_str());
215 while (std::getline(input, line)) {
220 base_x >> base_y >> base_z >> up_x >> up_y >> up_z;
225 std::string bankName = getBankName(bankPart,
id);
226 auto matchingDetector = std::find_if(detList.begin(), detList.end(), [&bankName, &componentInfo](
size_t index) {
227 return componentInfo.name(index) == bankName;
230 V3D rX(base_x, base_y, base_z);
231 V3D rY(up_x, up_y, up_z);
233 if (matchingDetector != detList.end()) {
234 const size_t bankIndex = *matchingDetector;
235 detname = componentInfo.name(bankIndex);
236 center(
x,
y,
z, bankIndex, componentInfo);
239 const auto grid = componentInfo.pixelGridComponent(bankIndex);
240 detScaling.
scaleX =
CM_TO_M * width / (grid.nX * grid.xStep);
248 auto oldscalex =
pmap.getDouble(detname, std::string(
"scalex"));
249 auto oldscaley =
pmap.getDouble(detname, std::string(
"scaley"));
250 if (!oldscalex.empty())
251 detScaling.
scaleX *= oldscalex[0];
252 if (!oldscaley.empty())
253 detScaling.
scaleY *= oldscaley[0];
257 auto oldscalex =
pmap.getDouble(detname, std::string(
"scalex"));
258 auto oldscaley =
pmap.getDouble(detname, std::string(
"scaley"));
259 if (!oldscalex.empty())
260 detScaling.
scaleX *= oldscalex[0];
261 if (!oldscaley.empty())
262 detScaling.
scaleY *= oldscaley[0];
265 rectangularDetectorScalings.emplace_back(detScaling);
269 auto bank = uniqueBanks.find(
id);
270 if (bank == uniqueBanks.end())
274 bankName = getBankName(bankPart, idnum);
276 size_t componentIndex;
278 componentIndex = componentInfo.indexOfAny(bankName);
279 }
catch (
const std::invalid_argument &) {
283 if (instname ==
"CORELLI") {
284 const auto children = componentInfo.children(componentIndex);
285 if (!children.empty()) {
286 componentIndex = children[0];
290 center(
x,
y,
z, componentIndex, componentInfo);
292 bool doWishCorrection = (instname ==
"WISH");
293 doRotation(rX, rY, componentInfo, componentIndex, doWishCorrection);