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 if (instname ==
"WISH")
174 center(0.0, 0.0, -mL1,
"undulator", ws, componentInfo);
176 center(0.0, 0.0, -mL1,
"moderator", ws, componentInfo);
180 API::Run &run = inputW->mutableRun();
187 alg1->setProperty(
"Offset", mT0 - T0IDF);
189 alg1->setProperty(
"Offset", mT0);
191 alg1->executeAsChildAlg();
192 inputW = alg1->getProperty(
"OutputWorkspace");
197 API::Run &run = inputP->mutableRun();
207 base_x >> base_y >> base_z >> up_x >> up_y >> up_z;
208 if (
id == 10 && filenames.size() == 2 && instname ==
"SNAP") {
210 input.open(filenames[1].c_str());
211 while (std::getline(input, line)) {
216 base_x >> base_y >> base_z >> up_x >> up_y >> up_z;
221 std::string bankName = getBankName(bankPart,
id);
222 auto matchingDetector = std::find_if(detList.begin(), detList.end(), [&bankName, &componentInfo](
size_t index) {
223 return componentInfo.name(index) == bankName;
226 V3D rX(base_x, base_y, base_z);
227 V3D rY(up_x, up_y, up_z);
229 if (matchingDetector != detList.end()) {
230 const size_t bankIndex = *matchingDetector;
231 detname = componentInfo.name(bankIndex);
232 center(
x,
y,
z, detname, ws, componentInfo);
235 const auto grid = componentInfo.pixelGridComponent(bankIndex);
236 detScaling.
scaleX =
CM_TO_M * width / (grid.nX * grid.xStep);
244 auto oldscalex =
pmap.getDouble(detname, std::string(
"scalex"));
245 auto oldscaley =
pmap.getDouble(detname, std::string(
"scaley"));
246 if (!oldscalex.empty())
247 detScaling.
scaleX *= oldscalex[0];
248 if (!oldscaley.empty())
249 detScaling.
scaleY *= oldscaley[0];
253 auto oldscalex =
pmap.getDouble(detname, std::string(
"scalex"));
254 auto oldscaley =
pmap.getDouble(detname, std::string(
"scaley"));
255 if (!oldscalex.empty())
256 detScaling.
scaleX *= oldscalex[0];
257 if (!oldscaley.empty())
258 detScaling.
scaleY *= oldscaley[0];
261 rectangularDetectorScalings.emplace_back(detScaling);
264 doRotation(rX, rY, componentInfo, bankComponent);
266 auto bank = uniqueBanks.find(
id);
267 if (bank == uniqueBanks.end())
271 bankName = getBankName(bankPart, idnum);
273 auto comp = inst->getComponentByName(bankName);
275 if (instname ==
"CORELLI") {
276 const size_t bankIndex = componentInfo.indexOfAny(bankName);
277 const auto children = componentInfo.children(bankIndex);
278 if (!children.empty()) {
284 detname = comp->getFullName();
285 center(
x,
y,
z, detname, ws, componentInfo);
287 bool doWishCorrection = (instname ==
"WISH");
288 doRotation(rX, rY, componentInfo, comp, doWishCorrection);