12 #include "TMatrixDSym.h" 
   22   using namespace JMATH;
 
   27     const int N = A.
size() - 1;
 
   30     for (
int i = 0; i < N+1; i++) {
 
   35       for (
int j = 0; 
j < N+1; 
j++) {
 
   39         ret.
at(k,l) = A.
at(i,
j);
 
   49     if (A.
size() != x.size()) { 
 
   50       cout << 
"Can not evaluate dot product: dimensions dont match" << endl; 
 
   54     for (
unsigned int i = 0; i < A.
size(); ++i) {
 
   55       for (
unsigned int j = 0; 
j < A.
size(); ++
j) {
 
   56         ret.at(i) += A.
at(i,
j) * x.at(
j);
 
   71 int main(
int argc, 
char **argv)
 
   75   using namespace FITL1DT;
 
   80   bool   overwriteDetector;
 
   89     JParser<> zap(
"Program to calculate time offsets from FitL1dtSlices output");
 
   91     zap[
'f'] = 
make_field(inputFile,         
"input file")                   = 
"fitslices.root";
 
   93     zap[
'a'] = 
make_field(detectorFile,      
"detector file");
 
   94     zap[
'A'] = 
make_field(overwriteDetector, 
"overwrite the input detector file");
 
   95     zap[
'D'] = 
make_field(noInterDU,         
"do not use inter DU information in the calculation");
 
   96     zap[
'r'] = 
make_field(idom_ref,          
"reference DOM set to t=0")     = 9;
 
   97     zap[
'F'] = 
make_field(maxFloors,         
"number of floors used in fit") = 9999;
 
  100     if (zap.
read(argc, argv) != 0) {
 
  104   catch(
const exception &error) {
 
  105     FATAL(error.what() << endl);
 
  119   for (JDetector::iterator moduleA = 
detector.begin(); moduleA != 
detector.end(); ++moduleA) {
 
  120     DU_IDs.insert(moduleA->getString());
 
  126   TFile* 
in = TFile::Open(inputFile.c_str(), 
"exist");
 
  128   if (
in == NULL || !
in->IsOpen()) {
 
  129     FATAL(
"File: " << inputFile << 
" not opened." << endl);
 
  133   TH2D* h2A = (TH2D*)
in->Get(
"Aij");
 
  134   TH2D* h2B = (TH2D*)
in->Get(
"Bij");
 
  136   if (h2A == NULL || h2B == NULL) {
 
  137     FATAL(
"File does not contain histogram with matrix. Please use FitL1dtSlices script first." << endl);
 
  155     for (JDetector::iterator moduleA = 
detector.begin(); moduleA != 
detector.end(); ++moduleA) {
 
  157       const int ibin = h2A->GetXaxis()->FindBin(TString(Form(
"%i", moduleA->getID())));
 
  159       if (noInterDU && (moduleA->getString() != *DU_ID)) {
 
  163       for (JDetector::iterator moduleB = 
detector.begin(); moduleB != 
detector.end(); ++moduleB) {
 
  165         const int jbin = h2A->GetXaxis()->FindBin(TString(Form(
"%i", moduleB->getID())));
 
  171         if (noInterDU && (moduleB->getString() != *DU_ID)) {
 
  175         if (fabs(moduleA->getFloor() - moduleB->getFloor()) > maxFloors) {
 
  179         double Aij = h2A->GetBinContent(ibin, jbin);
 
  180         double Bij = h2B->GetBinContent(ibin, jbin);
 
  187         NOTICE(
"  " << idom << 
" " << jdom << 
"  " << moduleA->getID() << 
" " << moduleB->getID() << 
" Aij: " << Aij << 
" Bij: " << Bij << 
" bf: " << -0.5*Bij/Aij << endl);
 
  189         fitA.at(idom, jdom)  = -4.0*Aij;
 
  190         fitA.at(idom, idom) +=  4.0*Aij;
 
  191         fitB[idom]          +=  2.0*Bij; 
 
  192         diag[idom]          +=  4.0*Aij; 
 
  197     unsigned int icolumn = 0;
 
  200     while (icolumn < fitA.size()) {
 
  201       if (fitA.at(icolumn, icolumn) == 0) {
 
  203         fitB.erase(fitB.begin() + icolumn);
 
  205         changet0[idom] = 
false;
 
  213     if (fitA.size() <= 1) {
 
  220     TMatrixDSym fit_A(fitA.size());
 
  222     TVectorD fit_B(fitB.size());
 
  224     for (
unsigned int i = 0; i < fitA.size(); i++) {
 
  225       for (
unsigned int j = 0; 
j < fitA.size(); 
j++) {
 
  226         fit_A(i,
j) = fitA.at(i,
j);
 
  232     for (
int i = 0; i < fit_A.GetNrows(); ++i) {
 
  233       fit_A(idom_ref-1, i) = 0.0;
 
  234       fit_A(i, idom_ref-1) = 0.0;
 
  236     fit_A(idom_ref-1, idom_ref-1) = 1.0;
 
  237     fit_B(idom_ref-1) = 0.0;
 
  239     if (
debug >= 2) fit_A.Print();
 
  242     Double_t fit_A_det = -999; 
 
  243     fit_A.Invert(&fit_A_det);
 
  244     if (fit_A_det == 0) {
 
  245       NOTICE(
"Matrix not invertible." << endl);
 
  248     if (
debug >= 2) fit_A.Print();
 
  251     TVectorD dt_i = fit_A * fit_B;
 
  255     for (JDetector::iterator moduleA = 
detector.begin(); moduleA != 
detector.end(); ++moduleA) {
 
  257       if (changet0[idom]) {
 
  259         vart0[idom] = TMath::Sqrt(-1 / diag[idom]);
 
  271   for (JDetector::iterator moduleA = 
detector.begin(); moduleA != 
detector.end(); ++moduleA) {
 
  273     NOTICE(
"Changing t0 of DOM " << moduleA->getID() << 
" (S"<<setw(2) << moduleA->getString() << 
"F" << setw(2) << moduleA->getFloor() << 
") by " << setw(13) << dt0[idom] << 
" [ns] ");
 
  275     if (status[idom] == 0) {
 
  276       NOTICE(
" ** unable to fit **" << endl);
 
  278     else if (moduleA->getFloor() == idom_ref) {
 
  279       NOTICE(
" ** fixed **" << endl);
 
  285     if (overwriteDetector) {
 
  286       moduleA->add(dt0[idom]); 
 
  288     h_dt0.GetXaxis()->SetBinLabel(idom+1, Form(
"%i", moduleA->getID()));
 
  289     h_dt0.SetBinContent(idom+1, dt0[idom]);
 
  290     h_dt0.SetBinError(idom+1, vart0[idom]);
 
  297   if (overwriteDetector) {
 
  298     NOTICE(
"Store calibration data on file " << detectorFile << endl);
 
Utility class to parse command line options. 
 
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
 
int main(int argc, char *argv[])
 
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance. 
 
double at(size_t row, size_t col) const 
Get matrix element. 
 
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
 
Data structure for detector geometry and calibration. 
 
vector< double > dotprod(const JMatrixNS &A, const vector< double > &x)
 
static const double C
Physics constants. 
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file. 
 
size_t size() const 
Get dimension of matrix. 
 
int read(const int argc, const char *const argv[])
Parse the program's command line options. 
 
void load(const std::string &file_name, JDetector &detector)
Load detector from input file. 
 
Utility class to parse command line options. 
 
do set_variable DETECTOR_TXT $WORKDIR detector
 
KM3NeT DAQ constants, bit handling, etc. 
 
JMatrixNS removeRowColumn(const JMatrixNS &A, int C)
 
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
 
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A