saslib documentation
This package contains two libraries of SAS utilities: saslib
and sasdal. The latter contains utilities that make used of the
dal.
sasdal
C++ utility functions that make use of the DAL
The interface from sasdal.h
is as follows:
inline void setStringColumnRow(const ColumnData *c, const unsigned long row, const string &str);
inline string getStringColumnData(const ColumnData *c, const unsigned long row = 0);
Event attributes
The Fortran module eventattributes implements
GV/XMM/1999-01. The following functions
are available in this module.
- setEventAttribute(TableT tab, integer(kind=int32) eventAttribute)
Given eventAttribute, this subroutine will write a
table attribute to tab containing an expression that
can be used with evselect in order to select events that were
flagged with the given event attribute. Example:
call setEventAttribute(tab, EVATT_DIAGONAL)
will add:
XMMEA_0 = '(FLAG & 0x1) != 0' / XMM event attribute DIAGONAL
Events that have the DIAGONAL bit turned on can be selected with
the expression "#XMMEA_0". FLAG is the name of the event
attribute column (EVATT_COLUMN_NAME).
- function eventAttributeIsSet(TableT table, integer(kind=int32) eventAttribute)
This boolean function returns true if the table attribute
corresponding to eventAttribute was added to
table.
- setEmosRejectionMask(TableT table)
setEpnRejectionMask(TableT table)
setRgsRejectionMask(TableT table)
These routines set additiona table attributes corresponding
to the instrument rejection masks. The attributes are,
respectively, XMMEA_EM, XMMEA_EP, XMMEA_RG. Events
that do not have any of the rejection bits turned on (good
events) can be selected with the expression "#XMMEA_EM" (MOS),
"#XMMEA_EP" (PN), or "#XMMEA_RG" (RGS).
- copyEventAttributes(TableT from, TableT to)
This subroutine propagates the table attributes set with the
previous subroutines from one table to another.
There is also a C++ implementation event attributes in
EventAttributes.h. This is as follows:
namespace EventAttributes {
// Attributes can share the same number: it means that they apply to
// different instruments.
// Try to keep the info/rejection attributes in the first/last 16
// bits.
enum EvAtt {
DIAGONAL = 0,
CLOSE_TO_CCD_BORDER = 1,
CLOSE_TO_CCD_WINDOW = 2,
CLOSE_TO_NODE_BOUNDARY = 3, ON_NODE0 = 3, ON_OFFSET_COLUMN = 3,
ON_NODE1, NEXT_TO_OFFSET_COLUMN = 4,
CLOSE_TO_ONBOARD_BADPIX = 5,
CLOSE_TO_BRIGHTPIX = 6,
CLOSE_TO_FLICKERINGPIX = 7,
CLOSE_TO_DEADPIX = 8,
CLOSE_TO_BADCOL = 9,
CLOSE_TO_BADROW = 10,
IN_SPOILED_FRAME = 11,
UNKNOWN_RAWX_PATTERN = 12, ONBOARD_SER = 12,
OUT_OF_FOV = 16,
IN_BAD_FRAME = 17,
OUTSIDE_GTI = 18,
COSMIC_RAY= 19, BAD_SHAPE = 19,
MIP_ASSOCIATED = 20,
ON_BADPIX = 21,
REJECTED_BY_GATTI, SECONDARY = 22,
TRAILING, NEXT_TO_CCD_BORDER = 23,
NEXT_TO_BADPIX = 24,
OUT_OF_CCD_WINDOW = 25,
OUTSIDE_THRESHOLDS = 26,
BELOW_ACCEPTANCE = 27,
ON_BADROW = 28,
BAD_E3E4 = 29,
EVLIST_LOCAL = 31,
NUMBER_OF
};
// These are the rejection masks for the instruments.
const int RGS_REJECTION_MASK =
1 << (int) ON_BADPIX |
1 << (int) NEXT_TO_BADPIX |
1 << (int) BAD_SHAPE |
1 << (int) NEXT_TO_CCD_BORDER |
1 << (int) BELOW_ACCEPTANCE |
1 << (int) IN_BAD_FRAME |
1 << (int) OUTSIDE_GTI;
const int EMOS_REJECTION_MASK =
1 << (int) OUT_OF_FOV |
1 << (int) IN_BAD_FRAME |
1 << (int) COSMIC_RAY |
1 << (int) ON_BADPIX |
1 << (int) REJECTED_BY_GATTI |
1 << (int) OUT_OF_CCD_WINDOW |
1 << (int) OUTSIDE_THRESHOLDS;
const int EPN_REJECTION_MASK =
1 << (int) OUT_OF_FOV |
1 << (int) IN_BAD_FRAME |
1 << (int) COSMIC_RAY |
1 << (int) ON_BADPIX |
1 << (int) SECONDARY |
1 << (int) TRAILING |
1 << (int) MIP_ASSOCIATED ;
const int CLEAR_ALL_FLAGS = 0;
const string COLUMN_NAME = "FLAG";
const Dal::DataType COLUMN_TYPE = Dal::Int32;
// Set the bit corresponding to the event attribute
void setEventAttribute(int & v, const EvAtt n);
// Add a table attribute
void setEventAttribute(Table *table, const EvAtt n);
// Propagate table attributes from one table to another
void copyEventAttributes(const Table *fromtable, Table *totable);
// Specialized functions to set instrument specific rejection masks
// with a fixed name
void setEmosRejectionMask(Table *table);
void setEpnRejectionMask(Table *table);
void setRgsRejectionMask(Table *table);
const vector names();
EvAtt lookup(const string & name);
bool eventAttributeIsSet(const Table *table, const EvAtt n);
bool eventAttributeIsSet(int & v, const EvAtt n);
};
saslib
Directory
This is a C++ class to list the contents of a directory. File names
can be filtered with patterns. Multiple filter patterns are possible,
if they are separated with |
. For instance:
Directory d(".");
d.filter("*.cc|*.h");
By default a Directory object only lists entries it finds in the
directory indicated in the constructor. It is possible to alter this
behavior with the member function recurse(bool)
. For
instance:
Directory d(".");
d.filter("*.cc|*.h");
d.recurse(true);
The complete interface specification from Directory.h
is
as follows:
class Directory: public list {
public:
Directory(const string name = ".", const string pattern = "*", const bool recurse = false);
Directory(const DirEntry * d, const string pattern = "*", const bool recurse = false);
void filter(const string pattern);
string filter() const;
void recurse(const bool dorecurse);
bool recurse() const;
bool isOk() const;
string name() const;
void print(ostream & os) const;
private:
// disallowed
Directory(const Directory & rhs);
void operator=(Directory & rhs);
bool operator==(const Directory & rhs);
bool operator!=(const Directory & rhs);
void init();
void scan();
void reset();
bool _isOk;
string _name;
string _pattern;
string _separator;
bool _recurse;
};
ostream & operator<<(ostream &os, const Directory &d);
DirEntry
This is an abstract C++ class that contains one directory entry (a file). A
DirEntry object has methods to inquire about the most common file
properties (name, dirname, basename, size). It has also a method to
generate the MD5 signature of the file.
The complete interface specification from DirEntry.h
is
as follows:
class DirEntry : public virtual DigitallySignable {
public:
virtual ~DirEntry() {}
virtual string name() const = 0;
virtual string dirname() const = 0;
virtual string basename() const = 0;
virtual off_t size() const = 0;
virtual bool isDir() const = 0;
virtual void print(ostream & os) const = 0;
virtual bool operator==(const DirEntry & rhs) const = 0;
virtual bool operator!=(const DirEntry & rhs) const = 0;
};
inline ostream & operator<<(ostream & os, const DirEntry & d)
{
d.print(os);
return os;
}
DirEntry
objects are instantiated through the
DirEntryFactory
. For example:
#include "DirEntryFactory.h"
// ...
DirEntry * d = dirEntryFactory->dirEntry("file.cc");
d->sign();
Digital signatures
The MD5 code was taken from rfc1321. There
is an abstarct interface to a digitally signable object, with an
implementation in DirEntry.
The interface from DigitallySignable.h
is:
class DigitallySignable {
public:
virtual void sign() = 0;
virtual string signature() const = 0;
virtual bool isSigned() const = 0;
virtual ~DigitallySignable() {};
};
Giuseppe Vacanti
Updated on: September 13, 1999