Jpp  17.3.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JGlow.cc File Reference

Auxiliary program to test simulation of L0 background. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TMath.h"
#include "TRandom3.h"
#include "JTools/JConstants.hh"
#include "JTools/JQuantile.hh"
#include "km3net-dataformat/online/JDAQ.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JROOT/JRootToolkit.hh"
#include "JTools/JRange.hh"
#include "JSupport/JMeta.hh"
#include "JCalibrate/JCalibrateK40.hh"
#include "JCalibrate/JFitK40.hh"
#include "JROOT/JManager.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JLightCurveBackgroundGenerator.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to test simulation of L0 background.

Author
mlincett

Definition in file JGlow.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 44 of file JGlow.cc.

44  {
45  using namespace std;
46  using namespace JPP;
47 
48  string inputFile;
49  string outputFile;
50  int debug;
51  int duration_ms;
52  int outNumberOfLines;
53 
54  try {
55 
56  JParser<> zap("Auxiliary program to test generation of L0 background.");
57 
58  zap['f'] = make_field(inputFile, "input file (output from JRipple).");
59  zap['o'] = make_field(outputFile, "output file.") = "glow.root";
60  zap['T'] = make_field(duration_ms, "duration in ms of the background sample.") = 500;
61  zap['N'] = make_field(outNumberOfLines, "number of lines of the simulated (output) detector") = 115;
62  zap['d'] = make_field(debug) = 1;
63  zap(argc, argv);
64  }
65  catch(const exception &error) {
66  FATAL(error.what() << endl);
67  }
68 
69  TFile* in = TFile::Open(inputFile.c_str(), "exist");
70 
71  if (in == NULL || !in->IsOpen()) {
72  FATAL("File: " << inputFile << " not opened." << endl);
73  }
74 
75  NOTICE("Initialising generator." << endl);
76 
77  JLightCurveBackgroundGenerator simbad(in, true);
78 
79  in->Close();
80 
81  NOTICE("File loaded." << endl);
82 
83  int T_ms = duration_ms;
84 
85  simbad.configureTimeWindow(T_ms);
86  simbad.setSeed();
87 
88  int inNumberOfLines = 1;
89 
90  simbad.configureRatio(inNumberOfLines, outNumberOfLines);
91 
92  JManager<int, TH1D> RT_SEQ(new TH1D("RT_SEQ_%", "Hit count" , T_ms, 0, T_ms));
93  JManager<int, TH1D> NC_SEQ(new TH1D("NC_SEQ_%", "Active channels" , T_ms, 0, T_ms));
94 
95  JManager<int, TH1D> RT_SHF(new TH1D("RT_SHF_%", "Hit count" , T_ms, 0, T_ms));
96  JManager<int, TH1D> NC_SHF(new TH1D("NC_SHF_%", "Active channels" , T_ms, 0, T_ms));
97 
98  JManager<string, TH1D> RT_FIT(new TH1D("RT_FIT_%", "Hit count" , T_ms, 0, T_ms));
99 
100  NOTICE("Generation SEQ" << endl);
101 
102  for (int i = 0; i < 10; i++) {
103  bg_type seq = simbad.generate();
104 
105  for (int j = 0; j < T_ms; j++) {
106  RT_SEQ[i]->Fill(j, seq[0][j]);
107  NC_SEQ[i]->Fill(j, seq[1][j]);
108 
109  }
110 
111  }
112 
113  NOTICE("Generation SHF" << endl);
114 
115  for (int i = 0; i < 10; i++) {
116  bg_type shf = simbad.generate_shuffled();
117 
118  for (int j = 0; j < T_ms; j++) {
119 
120  RT_SHF[i]->Fill(j, shf[0][j]);
121  NC_SHF[i]->Fill(j, shf[1][j]);
122 
123  }
124  }
125 
126  NOTICE("Generation H2D + FIT" << endl);
127 
128  h2d_t* test1 = simbad.generate_H2D();
129 
130  bg_type fit1 = simbad.generate_fitted();
131 
132  for (int j = 0; j < T_ms; j++) {
133  RT_FIT["SG_1"]->Fill(j, fit1[0][j]);
134  }
135 
136  NOTICE("Generation H2D + FIT - rebin = 5" << endl);
137 
138  h2d_t* test5 = simbad.generate_H2D(5);
139 
140 
141  bg_type fit5 = simbad.generate_fitted(5);
142 
143  for (size_t j = 0; j < fit5[0].size(); j++) {
144  cout << fit5[0][j] << endl;
145  RT_FIT["SG_5"]->Fill(j, fit5[0][j]);
146  }
147 
148 
149  /*
150  NOTICE("Generation FIT" << endl);
151 
152  for (int i = 0; i < 10; i++) {
153 
154  // RT_FIT["BG"]->Fill(j, fit[1][j]);
155  // RT_FIT["ER"]->Fill(j, fit[2][j]);
156  }
157 
158  }*/
159 
160 
161  TFile out(outputFile.c_str(), "recreate");
162 
163  TDirectory* dseq = out.mkdir("SEQ");
164  TDirectory* dshf = out.mkdir("SHF");
165  TDirectory* dfit = out.mkdir("FIT");
166 
167  RT_SEQ.Write(*dseq);
168  NC_SEQ.Write(*dseq);
169 
170  RT_SHF.Write(*dshf);
171  NC_SHF.Write(*dshf);
172 
173  RT_FIT.Write(*dfit);
174 
175  dfit->cd();
176  test1->Write();
177  test5->Write();
178 
179  out.Close();
180 
181 }
Utility class to parse command line options.
Definition: JParser.hh:1517
TH2F h2d_t
Definition: JRipple.hh:7
string outputFile
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
Class to emulate L0 background for an arbitrarily sized detector.
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int j
Definition: JPolint.hh:703
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
int debug
debug level