Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
235c751f
Commit
235c751f
authored
11 years ago
by
Zhou, Wenduo
Browse files
Options
Downloads
Patches
Plain Diff
Finished cleaning codes. Refs #7362.
parent
26800470
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/Mantid/Framework/Algorithms/src/EditInstrumentGeometry.cpp
+43
-99
43 additions, 99 deletions
...antid/Framework/Algorithms/src/EditInstrumentGeometry.cpp
with
43 additions
and
99 deletions
Code/Mantid/Framework/Algorithms/src/EditInstrumentGeometry.cpp
+
43
−
99
View file @
235c751f
...
@@ -271,10 +271,7 @@ namespace Algorithms
...
@@ -271,10 +271,7 @@ namespace Algorithms
// ??? Condition: spectrum has 1 and only 1 detector
// ??? Condition: spectrum has 1 and only 1 detector
size_t
nspec
=
workspace
->
getNumberHistograms
();
size_t
nspec
=
workspace
->
getNumberHistograms
();
std
::
vector
<
bool
>
wsindexsetflag
(
nspec
,
false
);
// Initialize another set of L2/2-theta/Phi/DetectorIDs vector ordered by workspace index
// Initialize another set of L2/2-theta/Phi/DetectorIDs vector ordered by workspace index
std
::
vector
<
bool
>
storable
(
nspec
,
false
);
std
::
vector
<
double
>
storL2s
(
nspec
,
0.
);
std
::
vector
<
double
>
storL2s
(
nspec
,
0.
);
std
::
vector
<
double
>
stor2Thetas
(
nspec
,
0.
);
std
::
vector
<
double
>
stor2Thetas
(
nspec
,
0.
);
std
::
vector
<
double
>
storPhis
(
nspec
,
0.
);
std
::
vector
<
double
>
storPhis
(
nspec
,
0.
);
...
@@ -297,7 +294,6 @@ namespace Algorithms
...
@@ -297,7 +294,6 @@ namespace Algorithms
// Store and set value
// Store and set value
size_t
workspaceindex
=
it
->
second
;
size_t
workspaceindex
=
it
->
second
;
wsindexsetflag
[
workspaceindex
]
=
true
;
storL2s
[
workspaceindex
]
=
l2s
[
i
];
storL2s
[
workspaceindex
]
=
l2s
[
i
];
stor2Thetas
[
workspaceindex
]
=
tths
[
i
];
stor2Thetas
[
workspaceindex
]
=
tths
[
i
];
storPhis
[
workspaceindex
]
=
phis
[
i
];
storPhis
[
workspaceindex
]
=
phis
[
i
];
...
@@ -307,58 +303,6 @@ namespace Algorithms
...
@@ -307,58 +303,6 @@ namespace Algorithms
g_log
.
debug
()
<<
"workspace index = "
<<
workspaceindex
<<
" is for Spectrum "
<<
specids
[
i
]
<<
std
::
endl
;
g_log
.
debug
()
<<
"workspace index = "
<<
workspaceindex
<<
" is for Spectrum "
<<
specids
[
i
]
<<
std
::
endl
;
}
}
// Reset detector information of each spectrum
#if 0
NOT USED
for (size_t i = 0; i < workspace->getNumberHistograms(); i ++)
{
if (!wsindexsetflag[i])
{
throw std::runtime_error("Ever reached?");
// Won't be set
API::ISpectrum *spectrum = workspace->getSpectrum(i);
std::set<detid_t> detids = spectrum->getDetectorIDs();
if (detids.size() == 1)
{
// Case: 1 and only 1 detector
storable[i] = true;
// a) get DetectorID
detid_t detid = 0;
std::set<detid_t>::iterator it;
for (it=detids.begin(); it!=detids.end(); ++it)
{
detid = *it;
}
// b) get Detector
Geometry::IDetector_const_sptr stodet = originstrument->getDetector(detid);
double rt, thetat, phit;
stodet->getPos().getSpherical(rt, thetat, phit);
// c) Store
//storDetids[i] = detid;
storL2s[i] = rt;
stor2Thetas[i] = thetat;
storPhis[i] = phit;
}
else
{
// more than 1 detectors
storable[i] = false;
if (renameDetID)
{
// newinstrument = true;
g_log.notice() << "Spectrum at workspace index " << i << " has more than 1 (" << detids.size()
<< "detectors. A new instrument is required to create from sctrach regardless of "
<< "user's choice." << ".\n";
}
}
}
}
#endif
// Generate a new instrument
// Generate a new instrument
// Name of the new instrument
// Name of the new instrument
std
::
string
name
=
std
::
string
(
getProperty
(
"InstrumentName"
));
std
::
string
name
=
std
::
string
(
getProperty
(
"InstrumentName"
));
...
@@ -386,7 +330,7 @@ namespace Algorithms
...
@@ -386,7 +330,7 @@ namespace Algorithms
throw
std
::
runtime_error
(
errss
.
str
());
throw
std
::
runtime_error
(
errss
.
str
());
}
}
//
c) S
ource and sample information
//
Set up s
ource and sample information
Geometry
::
ObjComponent
*
samplepos
=
new
Geometry
::
ObjComponent
(
"Sample"
,
instrument
.
get
());
Geometry
::
ObjComponent
*
samplepos
=
new
Geometry
::
ObjComponent
(
"Sample"
,
instrument
.
get
());
instrument
->
add
(
samplepos
);
instrument
->
add
(
samplepos
);
instrument
->
markAsSamplePos
(
samplepos
);
instrument
->
markAsSamplePos
(
samplepos
);
...
@@ -397,54 +341,54 @@ namespace Algorithms
...
@@ -397,54 +341,54 @@ namespace Algorithms
instrument
->
markAsSource
(
source
);
instrument
->
markAsSource
(
source
);
source
->
setPos
(
0.0
,
0.0
,
-
1.0
*
l1
);
source
->
setPos
(
0.0
,
0.0
,
-
1.0
*
l1
);
//
d) Set
the new instrument
//
Add
the new instrument
workspace
->
setInstrument
(
instrument
);
workspace
->
setInstrument
(
instrument
);
//
6. Add or
copy detector information
//
Add/
copy detector information
for
(
size_t
i
=
0
;
i
<
workspace
->
getNumberHistograms
();
i
++
)
for
(
size_t
i
=
0
;
i
<
workspace
->
getNumberHistograms
();
i
++
)
{
{
if
(
wsindexsetflag
[
i
]
||
storable
[
i
]){
// Create a new detector.
// a) Create a new detector.
// (Instrument will take ownership of pointer so no need to delete.)
// (Instrument will take ownership of pointer so no need to delete.)
detid_t
newdetid
;
detid_t
newdetid
;
if
(
renameDetID
)
if
(
renameDetID
)
newdetid
=
storDetIDs
[
i
];
newdetid
=
storDetIDs
[
i
];
else
else
newdetid
=
detid_t
(
i
)
+
100
;
newdetid
=
detid_t
(
i
)
+
100
;
Geometry
::
Detector
*
detector
=
new
Geometry
::
Detector
(
"det"
,
newdetid
,
samplepos
);
Geometry
::
Detector
*
detector
=
new
Geometry
::
Detector
(
"det"
,
newdetid
,
samplepos
);
// Set up new detector parameters related to new instrument
// b) Set the new instrument
double
l2
=
storL2s
[
i
];
double
l2
=
storL2s
[
i
];
double
tth
=
stor2Thetas
[
i
];
double
tth
=
stor2Thetas
[
i
];
double
phi
=
storPhis
[
i
];
double
phi
=
storPhis
[
i
];
Kernel
::
V3D
pos
;
Kernel
::
V3D
pos
;
pos
.
spherical
(
l2
,
tth
,
phi
);
pos
.
spherical
(
l2
,
tth
,
phi
);
detector
->
setPos
(
pos
);
detector
->
setPos
(
pos
);
// Add new detector to spectrum and instrument
// c) add copy to instrument and mark it
API
::
ISpectrum
*
spectrum
=
workspace
->
getSpectrum
(
i
);
API
::
ISpectrum
*
spectrum
=
workspace
->
getSpectrum
(
i
);
if
(
!
spectrum
)
if
(
!
spectrum
)
{
{
// Error!
stringstream
errss
;
stringstream
errss
;
errss
<<
"Spectrum ID "
<<
specids
[
i
]
errss
<<
"Spectrum ID "
<<
specids
[
i
]
<<
" does not exist! Skip setting detector parameters to this spectrum"
<<
std
::
endl
;
<<
" does not exist! Skip setting detector parameters to this spectrum. "
;
g_log
.
error
(
errss
.
str
());
g_log
.
error
(
errss
.
str
());
throw
runtime_error
(
errss
.
str
());
throw
runtime_error
(
errss
.
str
());
}
else
{
g_log
.
debug
()
<<
"Raw: Spectrum "
<<
spectrum
->
getSpectrumNo
()
<<
": # Detectors = "
<<
spectrum
->
getDetectorIDs
().
size
()
<<
std
::
endl
;
}
spectrum
->
clearDetectorIDs
();
spectrum
->
addDetectorID
(
newdetid
);
instrument
->
add
(
detector
);
instrument
->
markAsDetector
(
detector
);
}
}
else
{
// Good and do some debug output
g_log
.
debug
()
<<
"Orignal spectrum "
<<
spectrum
->
getSpectrumNo
()
<<
"has "
<<
spectrum
->
getDetectorIDs
().
size
()
<<
" detectors.
\n
"
;
}
spectrum
->
clearDetectorIDs
();
spectrum
->
addDetectorID
(
newdetid
);
instrument
->
add
(
detector
);
instrument
->
markAsDetector
(
detector
);
}
//
for i
}
//
ENDFOR workspace index
delete
spec2indexmap
;
delete
spec2indexmap
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment