-
Notifications
You must be signed in to change notification settings - Fork 122
/
CreateCalFileByNames.h
101 lines (85 loc) · 4.21 KB
/
CreateCalFileByNames.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
#ifndef MANTID_ALGORITHMS_CREATECALFILEBYNAMES_H_
#define MANTID_ALGORITHMS_CREATECALFILEBYNAMES_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
// To be compatible with MSVC++ Express Edition that does not have TR1 headers
#include <map>
#include "MantidAPI/Algorithm.h"
namespace Mantid
{
namespace Algorithms
{
/** Create a calibration file for diffraction focussing (*.cal old Ariel format)
* based on list of names of the instrument tree.
* The offsets are all sets to zero and all detectors are selected. Detectors not assigned
* to any group will appear as group 0, i.e. not included when using AlignDetector or
* DiffractionFocussing algorithms.
* The group number is assigned based on a descent in the instrument tree assembly.
* If two assemblies are parented, say Bank1 and module1, and both assembly names
* are given in the GroupNames, they will get assigned different grouping numbers.
* This allows to isolate a particular sub-assembly of a particular leaf of the tree
Required Properties:
<UL>
<LI> InstrumentName - The name of the instrument. Needs to be present in the store</LI>
<LI> GroupingFilename - The name of the output file (*.cal extension) .</LI>
<LI> GroupNames - Name of assemblies to consider (names separated by "/" or "," or "*"</LI>
</UL>
@author Laurent Chapon, ISIS Facility, Rutherford Appleton Laboratory
@date 01/03/2009
Copyright © 2009 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport CreateCalFileByNames : public API::Algorithm
{
public:
/// (Empty) Constructor
CreateCalFileByNames();
/// Virtual destructor
virtual ~CreateCalFileByNames() {}
/// Algorithm's name
virtual const std::string name() const { return "CreateCalFileByNames"; }
///Summary of algorithms purpose
virtual const std::string summary() const {return "Create a calibration file (extension .cal) for diffraction focusing based on the names of the components in the instrument tree.";}
/// Algorithm's version
virtual int version() const { return (1); }
/// Algorithm's category for identification
virtual const std::string category() const { return "Diffraction"; }
private:
/// Calibration entries map
typedef std::map<int,std::pair<int,int> > instrcalmap;
/// Initialisation code
void init();
/// Execution code
void exec();
/// The name and path of the input file
std::string m_filename;
/// Determine whether the grouping file already exists.
/// @param filename :: GroupingFilename (extension .cal)
/// @return true if the grouping file exists
bool groupingFileDoesExist(const std::string& filename) const;
void saveGroupingFile(const std::string&,bool overwrite) const;
static void writeCalEntry(std::ostream& os, int number, int udet, double offset, int select, int group);
void writeHeaders(std::ostream& os,const std::string& filename,bool overwrite) const;
/// The names of the groups
std::string groups;
/// Calibration map used if the *.cal file exist. All entries in the *.cal file are registered with the udet number as the key and the <Number,Offset,Select,Group> as the tuple value.
instrcalmap instrcalib;
/// Number of groups
int group_no;
};
} // namespace Algorithms
} // namespace Mantid
#endif /*MANTID_ALGORITHMS_CREATECALFILEBYNAMES_H_*/