50 int main(
int argc,
char **argv)
59 long long int Tmax_s = 600;
61 double sigma_deg = 1.0;
62 double stdev = numeric_limits<double>::max();
63 int numberOfOutliers = 0;
65 bool overwriteDetector;
78 JParser<> zap(
"Program to calibrate in situ AHRS.");
80 zap[
'f'] =
make_field(inputFile,
"output of JConvertDB -q ahrs");
81 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
84 zap[
'c'] =
make_field(ahrsFile,
"output of JAHRSCalibration");
91 catch(
const exception &error) {
92 FATAL(error.what() << endl);
129 JManager_t H0(
new TH1D(
"%.twist", NULL, 100, 0.0, 5.0));
130 JManager_t
H1(
new TH1D(
"%.swing", NULL, 250, 0.0, 2.5));
131 JManager_t HN(
new TH1D(
"%.count", NULL, 100, -0.5, 99.5));
135 range.getLength(),
range.getLowerLimit() - 0.5,
range.getUpperLimit() + 0.5);
137 for (Int_t i = 1; i <= h2.GetXaxis()->GetNbins(); ++i) {
138 h2.GetXaxis()->SetBinLabel(i,
MAKE_CSTRING(
string.at(i-1)));
140 for (Int_t i = 1; i <= h2.GetYaxis()->GetNbins(); ++i) {
144 TH2D*
h1 = (TH2D*) h2.Clone(
"h1");
153 for (JMultipleFileScanner_t::const_iterator file_name = inputFile.begin(); file_name != inputFile.end(); ++file_name) {
155 STATUS(
"processing file " << *file_name << endl);
170 sort(i->second.begin(), i->second.end(),
make_comparator(&JAHRS::UNIXTIME));
174 long long int t1 = p->UNIXTIME;
175 long long int t2 = t1;
179 for ( ; p != i->second.end() && p->UNIXTIME < t1 +
Tmax_s * 1000; t2 = (p++)->UNIXTIME) {
181 if (calibration.has(p->DOMID)) {
187 const JCompass compass(*p, calibration.get(p->DOMID));
191 buffer.push_back(
JHit(p->DOMID, module.
getZ(),
Q, sigma_deg));
196 if (buffer.size() > JModel::NUMBER_OF_PARAMETERS) {
209 for (
int ns = 0; ns != numberOfOutliers; ++ns) {
227 if (xmax >
stdev * sigma_deg) {
241 cout <<
"remove " << location <<
' '
247 swap(*out, *--__end);
259 simplex.step.resize(4);
266 const double chi2 = simplex(getChi2, buffer.begin(), __end);
267 const int ndf =
distance(buffer.begin(), __end) * 4 - simplex.step.size();
292 count[hit->getID()] += 1;
296 HN[i->first]->Fill(i->second);
308 for (JManager_t* p : { &H0, &
H1, &HN }) {
309 for (JManager_t::iterator i = p->begin(); i != p->end(); ++i) {
317 if (overwriteDetector) {
319 NOTICE(
"Store calibration data on file " << detectorFile << endl);
321 if (
detector.setToLatestVersion()) {
322 NOTICE(
"Set detector version to " <<
detector.getVersion() << endl);
static int debug
debug level (default is off).
Utility class to parse command line options.
double getAngle(const JQuaternion3D &first, const JQuaternion3D &second)
Get space angle between quanternions.
Q(UTCMax_s-UTCMin_s)-livetime_s
int main(int argc, char *argv[])
This class represents a rotation around the x-axis.
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
int getFloor() const
Get floor number.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
Data structure for a composite optical module.
JQuaternion3D getConjugate() const
Get conjugate of this quaternion.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define gmake_property(A)
macro to convert (template) parameter to JPropertiesElement object
const int getIndex(const JObjectID &id) const
Get index of module.
Recording of objects on file according a format that follows from the file name extension.
Router for direct addressing of module data in detector data structure.
Utility class to parse parameter values.
JEvt getEvt(const JHead &header, const JModel &model)
Get event.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
#define MAKE_CSTRING(A)
Make C-string.
then for HISTOGRAM in h0 h1
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Long64_t counter_type
Type definition for counter.
Dynamic ROOT object management.
Auxiliary data structure for floating point format specification.
floor_range getRangeOfFloors(const JDetector &detector)
Get range of floors.
Data structure for detector geometry and calibration.
Template spacialisation for averaging quaternions.
Utility class to parse parameter values.
ROOT TTree parameter settings.
const JQuaternion3D & getQuaternion() const
Get quaternion.
Model for fit to acoustics data.
Auxiliary data structure for chi2 evaluation.
JQuaternion3D swing
rotation around perpendicular axis
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
I/O formatting auxiliaries.
JQuaternion3D twist
rotation around parallel axis
void setQuaternion(const JQuaternion3D &quaternion)
Set quaternion.
Logical location of module.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
This class represents a rotation around the z-axis.
bool is_valid(const json &js)
Check validity of JSon data.
Data structure for compass in three dimensions.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
static const double PI
Mathematical constants.
int getIndex()
Get index for user I/O manipulation.
ROOT TTree parameter settings.
General purpose messaging.
static const JStringCounter getNumberOfStrings
Function object to count unique strings.
Direct access to string in detector data structure.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Data structure for unit quaternion in three dimensions.
Direct access to module in detector data structure.
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
int getString() const
Get string number.
Auxiliary base class for list of file names.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Router for mapping of string identifier to index.
General purpose class for object reading from a list of file names.
This class represents a rotation around the y-axis.
Utility class to parse command line options.
static const JVector3D JVector3Z_t(0, 0, 1)
unit z-vector
bool hasModule(const JObjectID &id) const
Has module.
Auxiliary class to map module identifier to AHRS calibration.
Compass event data types.
do set_variable DETECTOR_TXT $WORKDIR detector
Auxiliary data structure for decomposition of quaternion in twist and swing quaternions.
double getChi2(const double P)
Get chi2 corresponding to given probability.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
double getZ() const
Get z position.
Auxiliary data structure to check validity of AHRS data.
then usage $script< detector file >< tripodfile >< stage > input file nInput files correspond to the output of JAcousticsEventBuilder[.sh] nFirst stage eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY eval JPrintDetector a $DETECTOR O CAN source JAcoustics sh $DETECTOR_ID typeset A CONFIGURATION for key in Tmax_s