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 std::vector<IComponent_const_sptr> comps;
179 inst->getChildren(comps,
true);
181 for (
auto &comp : comps) {
182 std::string bankName = comp->getName();
183 boost::trim(bankName);
184 boost::erase_all(bankName, bankPart);
190 uniqueBanks.insert(bank);
194 auto expInfoWS = std::dynamic_pointer_cast<ExperimentInfo>(ws);
195 auto &componentInfo = expInfoWS->mutableComponentInfo();
196 std::vector<ComponentScaling> rectangularDetectorScalings;
198 while (std::getline(input, line)) {
199 if (line[0] ==
'7') {
201 std::stringstream(line) >>
count >> mL1 >> mT0;
204 if (instname ==
"WISH")
205 center(0.0, 0.0, -mL1,
"undulator", ws, componentInfo);
207 center(0.0, 0.0, -mL1,
"moderator", ws, componentInfo);
211 API::Run &run = inputW->mutableRun();
218 alg1->setProperty(
"Offset", mT0 - T0IDF);
220 alg1->setProperty(
"Offset", mT0);
222 alg1->executeAsChildAlg();
223 inputW = alg1->getProperty(
"OutputWorkspace");
228 API::Run &run = inputP->mutableRun();
238 base_x >> base_y >> base_z >> up_x >> up_y >> up_z;
239 if (
id == 10 && filenames.size() == 2 && instname ==
"SNAP") {
241 input.open(filenames[1].c_str());
242 while (std::getline(input, line)) {
247 base_x >> base_y >> base_z >> up_x >> up_y >> up_z;
252 std::shared_ptr<RectangularDetector> det;
253 std::string bankName = getBankName(bankPart,
id);
254 auto matchingDetector =
255 std::find_if(detList.begin(), detList.end(), [&bankName](
const std::shared_ptr<RectangularDetector> &detector) {
256 return detector->getName() == bankName;
258 if (matchingDetector != detList.end()) {
259 det = *matchingDetector;
262 V3D rX(base_x, base_y, base_z);
263 V3D rY(up_x, up_y, up_z);
266 detname = det->getName();
267 center(
x,
y,
z, detname, ws, componentInfo);
278 auto oldscalex =
pmap.getDouble(detname, std::string(
"scalex"));
279 auto oldscaley =
pmap.getDouble(detname, std::string(
"scaley"));
280 if (!oldscalex.empty())
281 detScaling.
scaleX *= oldscalex[0];
282 if (!oldscaley.empty())
283 detScaling.
scaleY *= oldscaley[0];
287 auto oldscalex =
pmap.getDouble(detname, std::string(
"scalex"));
288 auto oldscaley =
pmap.getDouble(detname, std::string(
"scaley"));
289 if (!oldscalex.empty())
290 detScaling.
scaleX *= oldscalex[0];
291 if (!oldscaley.empty())
292 detScaling.
scaleY *= oldscaley[0];
295 rectangularDetectorScalings.emplace_back(detScaling);
299 auto bank = uniqueBanks.find(
id);
300 if (bank == uniqueBanks.end())
304 bankName = getBankName(bankPart, idnum);
306 auto comp = inst->getComponentByName(bankName);
308 if (instname ==
"CORELLI") {
309 std::vector<Geometry::IComponent_const_sptr> children;
310 std::shared_ptr<const Geometry::ICompAssembly> asmb =
311 std::dynamic_pointer_cast<const Geometry::ICompAssembly>(inst->getComponentByName(bankName));
312 asmb->getChildren(children,
false);
317 detname = comp->getFullName();
318 center(
x,
y,
z, detname, ws, componentInfo);
320 bool doWishCorrection = (instname ==
"WISH");
321 doRotation(rX, rY, componentInfo, comp, doWishCorrection);