122 std::string instname = inst->getName();
128 double width,
height, depth, detd,
x,
y,
z, base_x, base_y, base_z, up_x, up_y, up_z;
129 std::ifstream input(filenames[0].c_str(), std::ios_base::in);
133 std::vector<std::shared_ptr<RectangularDetector>> detList;
134 for (
int i = 0; i < inst->nelements(); i++) {
135 std::shared_ptr<RectangularDetector> det;
136 std::shared_ptr<ICompAssembly> assem;
137 std::shared_ptr<ICompAssembly> assem2;
139 det = std::dynamic_pointer_cast<RectangularDetector>((*inst)[i]);
141 detList.emplace_back(det);
146 assem = std::dynamic_pointer_cast<ICompAssembly>((*inst)[i]);
148 for (
int j = 0; j < assem->nelements(); j++) {
149 det = std::dynamic_pointer_cast<RectangularDetector>((*assem)[j]);
151 detList.emplace_back(det);
158 assem2 = std::dynamic_pointer_cast<ICompAssembly>((*assem)[j]);
160 for (
int k = 0; k < assem2->nelements(); k++) {
161 det = std::dynamic_pointer_cast<RectangularDetector>((*assem2)[k]);
163 detList.emplace_back(det);
172 std::unordered_set<int> uniqueBanks;
173 std::string bankPart =
"bank";
174 if (instname ==
"WISH")
175 bankPart =
"WISHpanel";
176 if (detList.empty()) {
178 auto expInfoWS = std::dynamic_pointer_cast<ExperimentInfo>(ws);
179 const auto &componentInfo = expInfoWS->componentInfo();
182 size_t const rootIndex = componentInfo.root();
183 auto const topChildren = componentInfo.children(rootIndex);
184 for (
size_t const i : topChildren) {
186 size_t bankParent = componentInfo.findBankParent(i, bankPart);
187 auto const children = componentInfo.children(bankParent);
188 for (
size_t const child : children) {
189 std::string bankName = componentInfo.name(child);
190 boost::trim(bankName);
191 boost::erase_all(bankName, bankPart);
194 uniqueBanks.insert(bank);
200 auto expInfoWS = std::dynamic_pointer_cast<ExperimentInfo>(ws);
201 auto &componentInfo = expInfoWS->mutableComponentInfo();
202 std::vector<ComponentScaling> rectangularDetectorScalings;
204 while (std::getline(input, line)) {
205 if (line[0] ==
'7') {
207 std::stringstream(line) >>
count >> mL1 >> mT0;
210 if (instname ==
"WISH")
211 center(0.0, 0.0, -mL1,
"undulator", ws, componentInfo);
213 center(0.0, 0.0, -mL1,
"moderator", ws, componentInfo);
217 API::Run &run = inputW->mutableRun();
224 alg1->setProperty(
"Offset", mT0 - T0IDF);
226 alg1->setProperty(
"Offset", mT0);
228 alg1->executeAsChildAlg();
229 inputW = alg1->getProperty(
"OutputWorkspace");
234 API::Run &run = inputP->mutableRun();
244 base_x >> base_y >> base_z >> up_x >> up_y >> up_z;
245 if (
id == 10 && filenames.size() == 2 && instname ==
"SNAP") {
247 input.open(filenames[1].c_str());
248 while (std::getline(input, line)) {
253 base_x >> base_y >> base_z >> up_x >> up_y >> up_z;
258 std::shared_ptr<RectangularDetector> det;
259 std::string bankName = getBankName(bankPart,
id);
260 auto matchingDetector =
261 std::find_if(detList.begin(), detList.end(), [&bankName](
const std::shared_ptr<RectangularDetector> &detector) {
262 return detector->getName() == bankName;
264 if (matchingDetector != detList.end()) {
265 det = *matchingDetector;
268 V3D rX(base_x, base_y, base_z);
269 V3D rY(up_x, up_y, up_z);
272 detname = det->getName();
273 center(
x,
y,
z, detname, ws, componentInfo);
284 auto oldscalex =
pmap.getDouble(detname, std::string(
"scalex"));
285 auto oldscaley =
pmap.getDouble(detname, std::string(
"scaley"));
286 if (!oldscalex.empty())
287 detScaling.
scaleX *= oldscalex[0];
288 if (!oldscaley.empty())
289 detScaling.
scaleY *= oldscaley[0];
293 auto oldscalex =
pmap.getDouble(detname, std::string(
"scalex"));
294 auto oldscaley =
pmap.getDouble(detname, std::string(
"scaley"));
295 if (!oldscalex.empty())
296 detScaling.
scaleX *= oldscalex[0];
297 if (!oldscaley.empty())
298 detScaling.
scaleY *= oldscaley[0];
301 rectangularDetectorScalings.emplace_back(detScaling);
305 auto bank = uniqueBanks.find(
id);
306 if (bank == uniqueBanks.end())
310 bankName = getBankName(bankPart, idnum);
312 auto comp = inst->getComponentByName(bankName);
314 if (instname ==
"CORELLI") {
315 const size_t bankIndex = componentInfo.indexOfAny(bankName);
316 const auto children = componentInfo.children(bankIndex);
317 if (!children.empty()) {
323 detname = comp->getFullName();
324 center(
x,
y,
z, detname, ws, componentInfo);
326 bool doWishCorrection = (instname ==
"WISH");
327 doRotation(rX, rY, componentInfo, comp, doWishCorrection);