-
Notifications
You must be signed in to change notification settings - Fork 121
/
ExperimentInfo.h
177 lines (148 loc) · 6.8 KB
/
ExperimentInfo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#ifndef MANTID_API_EXPERIMENTINFO_H_
#define MANTID_API_EXPERIMENTINFO_H_
#include "MantidAPI/DllConfig.h"
#include "MantidAPI/Run.h"
#include "MantidAPI/Sample.h"
#include "MantidGeometry/Instrument.h"
#include "MantidAPI/SpectraDetectorTypes.h"
#include "MantidKernel/DeltaEMode.h"
#include <list>
namespace Mantid
{
//---------------------------------------------------------------------------
// Forward declaration
//---------------------------------------------------------------------------
namespace Geometry
{
class ParameterMap;
}
namespace API
{
//---------------------------------------------------------------------------
// Forward declaration
//---------------------------------------------------------------------------
class ChopperModel;
class ModeratorModel;
/** This class is shared by a few Workspace types
* and holds information related to a particular experiment/run:
*
* - Instrument (with parameter map)
* - Run object (sample logs)
* - Sample object (sample info)
*
* @author Janik Zikovsky
* @date 2011-06-20
*/
class MANTID_API_DLL ExperimentInfo
{
public:
/// Default constructor
ExperimentInfo();
/// Virtual destructor
virtual ~ExperimentInfo();
/// Copy constructor
ExperimentInfo(const ExperimentInfo &);
/// Copy everything from the given experiment object
void copyExperimentInfoFrom(const ExperimentInfo * other);
/// Clone us
ExperimentInfo * cloneExperimentInfo()const;
/// Returns a string description of the object
const std::string toString() const;
/// Instrument accessors
void setInstrument(const Geometry::Instrument_const_sptr& instr);
/// Returns the parameterized instrument
Geometry::Instrument_const_sptr getInstrument() const;
/// Returns the set of parameters modifying the base instrument (const-version)
const Geometry::ParameterMap& instrumentParameters() const;
/// Returns a modifiable set of instrument parameters
Geometry::ParameterMap& instrumentParameters();
/// Const version
const Geometry::ParameterMap& constInstrumentParameters() const;
// Add parameters to the instrument parameter map
virtual void populateInstrumentParameters();
/// Replaces current parameter map with copy of given map
void replaceInstrumentParameters(const Geometry::ParameterMap & pmap);
/// exchange contents of current parameter map with contents of other map)
void swapInstrumentParameters(Geometry::ParameterMap & pmap);
/// Cache a lookup of grouped detIDs to member IDs
void cacheDetectorGroupings(const det2group_map & mapping);
/// Returns the detector IDs that make up the group that this ID is part of
const std::vector<detid_t> & getGroupMembers(const detid_t detID) const;
/// Get a detector or detector group from an ID
Geometry::IDetector_const_sptr getDetectorByID(const detid_t detID) const;
/// Set an object describing the source properties and take ownership
void setModeratorModel(ModeratorModel *source);
/// Returns a reference to the source properties object
ModeratorModel & moderatorModel() const;
/// Set a chopper description specified by index where 0 is closest to the source
void setChopperModel(ChopperModel *chopper, const size_t index = 0);
/// Returns a reference to a chopper description
ChopperModel & chopperModel(const size_t index = 0) const;
/// Sample accessors
const Sample& sample() const;
/// Writable version of the sample object
Sample& mutableSample();
/// Run details object access
const Run & run() const;
/// Writable version of the run object
Run& mutableRun();
/// Access a log for this experiment.
Kernel::Property * getLog(const std::string & log) const;
/// Access a single value from a log for this experiment.
double getLogAsSingleValue(const std::string & log) const;
/// Utility method to get the run number
int getRunNumber() const;
/// Returns the emode for this run
Kernel::DeltaEMode::Type getEMode() const;
/// Easy access to the efixed value for this run & detector ID
double getEFixed(const detid_t detID) const;
/// Easy access to the efixed value for this run & optional detector
double getEFixed(const Geometry::IDetector_const_sptr detector = Geometry::IDetector_const_sptr()) const;
/// Set the efixed value for a given detector ID
void setEFixed(const detid_t detID, const double value);
/// Saves this experiment description to the open NeXus file
void saveExperimentInfoNexus(::NeXus::File * file) const;
/// Loads an experiment description from the open NeXus file
void loadExperimentInfoNexus(::NeXus::File * file, std::string & parameterStr);
/// Load the instrument from an open NeXus file.
void loadInstrumentInfoNexus(::NeXus::File * file, std::string & parameterStr);
/// Load the sample and log info from an open NeXus file.
void loadSampleAndLogInfoNexus(::NeXus::File * file);
/// Populate the parameter map given a string
void readParameterMap(const std::string & parameterStr);
/// Returns the start date for this experiment
std::string getWorkspaceStartDate();
/// Utility to retrieve the validity dates for the given IDF
static void getValidFromTo(const std::string& IDFfilename, std::string& outValidFrom, std::string& outValidTo);
/// Get the IDF using the instrument name and date
static std::string getInstrumentFilename(const std::string& instrumentName, const std::string& date="");
protected:
/// Description of the source object
boost::shared_ptr<ModeratorModel> m_moderatorModel;
/// Description of the choppers for this experiment.
std::list<boost::shared_ptr<ChopperModel> > m_choppers;
/// The information on the sample environment
boost::shared_ptr<Sample> m_sample;
/// The run information
boost::shared_ptr<Run> m_run;
/// Parameters modifying the base instrument
boost::shared_ptr<Geometry::ParameterMap> m_parmap;
/// The base (unparametrized) instrument
Geometry::Instrument_const_sptr sptr_instrument;
private:
/// Fill with given instrument parameter
void populateWithParameter(Geometry::ParameterMap & paramMap,
const std::string & name, const Geometry::XMLInstrumentParameter & paramInfo,
const Run & runData);
/// Detector grouping information
det2group_map m_detgroups;
/// Mutex to protect against cow_ptr copying
mutable Poco::Mutex m_mutex;
};
/// Shared pointer to ExperimentInfo
typedef boost::shared_ptr<ExperimentInfo> ExperimentInfo_sptr;
/// Shared pointer to const ExperimentInfo
typedef boost::shared_ptr<const ExperimentInfo> ExperimentInfo_const_sptr;
} // namespace Mantid
} // namespace API
#endif /* MANTID_API_EXPERIMENTINFO_H_ */