Jpp  16.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UNESCO.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <string>
4 
5 #include "TROOT.h"
6 #include "TFile.h"
7 #include "TH2D.h"
8 
9 #include "Jeep/JParser.hh"
10 #include "Jeep/JMessage.hh"
11 
12 /**
13  * Get sound velocity.
14  *
15  * \param D Depth [m]
16  * \param S Salinity [ppk]
17  * \param T Temperature [C]
18  * \return sound velocity [m/s]
19  */
20 inline double getVelocity(const double D, const double S, const double T)
21 {
22  return (1448.96
23  + 4.591 * T
24  - 5.304e-2 * T*T
25  + 2.374e-4 * T*T*T
26  + 1.340 * (S - 35)
27  + 1.630e-2 * D
28  + 1.675e-7 * D*D
29  - 1.025e-2 * T * (S - 35)
30  - 7.139e-13 * T*D*D*D);
31 }
32 
33 /**
34  * \file
35  *
36  * Example program to plot UNESCO sound velocity.
37  * \author mdejong
38  */
39 int main(int argc, char **argv)
40 {
41  using namespace std;
42  using namespace JPP;
43 
44  string outputFile;
45  double D;
46  int debug;
47 
48  try {
49 
50  JParser<> zap("Example program to plot UNESCO sound velocity.");
51 
52  zap['o'] = make_field(outputFile);
53  zap['D'] = make_field(D, "Depth [m]");
54  zap['d'] = make_field(debug) = 2;
55 
56  zap(argc, argv);
57  }
58  catch(const exception &error) {
59  FATAL(error.what() << endl);
60  }
61 
62 
63  TFile out(outputFile.c_str(), "recreate");
64 
65  TH2D h2("h2", NULL, 1000, 10.0, 20.0, 1000, 25.0, 40.0);
66 
67  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
68  for (Int_t iy = 1; iy <= h2.GetXaxis()->GetNbins(); ++iy) {
69 
70  const Double_t T = h2.GetXaxis()->GetBinCenter(ix);
71  const Double_t S = h2.GetYaxis()->GetBinCenter(iy);
72 
73  const double V = getVelocity(D, S, T);
74  const double vs = getVelocity(D, S, T) - getVelocity(D + 1, S, T);
75 
76  h2.SetBinContent(ix, iy, V);
77  }
78  }
79 
80  out.Write();
81  out.Close();
82 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
do set_variable OUTPUT_DIRECTORY $WORKDIR T
double getVelocity(const double D, const double S, const double T)
Get sound velocity.
Definition: UNESCO.cc:20
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
do set_variable SIGMA_NS set_variable OUTLIERS set_variable OUTPUT_FILE matrix[${ALPHA_DEG}\deg\] root $JPP JMatrixNZ a $DETECTOR f $INPUT_FILE o $OUTPUT_FILE S
Definition: JMatrixNZ.sh:58
Utility class to parse command line options.
do echo Generating $dir eval D
Definition: JDrawLED.sh:53