Jpp  18.0.0
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 "JAcoustics/JUNESCO.hh"
10 
11 #include "Jeep/JParser.hh"
12 #include "Jeep/JMessage.hh"
13 
14 
15 /**
16  * \file
17  *
18  * Example program to plot UNESCO sound velocity.
19  * \author mdejong
20  */
21 int main(int argc, char **argv)
22 {
23  using namespace std;
24  using namespace JPP;
25 
26  string outputFile;
27  double D;
28  double S;
29  double T;
30  int debug;
31 
32  try {
33 
34  JParser<> zap("Example program to plot UNESCO sound velocity.");
35 
36  zap['o'] = make_field(outputFile);
37  zap['D'] = make_field(D, "Depth [m]");
38  zap['S'] = make_field(S, "Salinity [ppk]") = 25.0;
39  zap['T'] = make_field(T, "Temperature [C]") = 14.3;
40  zap['d'] = make_field(debug) = 2;
41 
42  zap(argc, argv);
43  }
44  catch(const exception &error) {
45  FATAL(error.what() << endl);
46  }
47 
48 
49  TFile out(outputFile.c_str(), "recreate");
50 
51  TH1D h1("h1", NULL, 1000, 0.0, 3500);
52  TH2D h2("h2", NULL, 1000, 10.0, 20.0, 1000, 25.0, 40.0);
53 
54  for (Int_t ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
55 
56  const Double_t D = h1.GetXaxis()->GetBinCenter(ix);
57  const double V = getVelocity(D, S, T);
58 
59  h1.SetBinContent(ix, V);
60  }
61 
62  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
63  for (Int_t iy = 1; iy <= h2.GetXaxis()->GetNbins(); ++iy) {
64 
65  const Double_t T = h2.GetXaxis()->GetBinCenter(ix);
66  const Double_t S = h2.GetYaxis()->GetBinCenter(iy);
67 
68  const double V = getVelocity(D, S, T);
69  //const double vs = getVelocity(D, S, T) - getVelocity(D + 1, S, T);
70 
71  h2.SetBinContent(ix, iy, V);
72  }
73  }
74 
75  out.Write();
76  out.Close();
77 }
Utility class to parse command line options.
Definition: JParser.hh:1514
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:1989
do set_variable OUTPUT_DIRECTORY $WORKDIR T
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Sound velocity according UNESCO equation.
Utility class to parse command line options.
double getVelocity(const double D, const double S, const double T)
Get sound velocity according UNESCO equation.
Definition: JUNESCO.hh:23
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
int debug
debug level