Jpp  18.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JCombinatoricsK40.cc File Reference

Auxiliary program to project single PMT data from 2D histogram. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH2D.h"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JPMTIdentifier.hh"
#include "JCalibrate/JCalibrateK40.hh"
#include "JROOT/JRootToolkit.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to project single PMT data from 2D histogram.

Author
mdejong

Definition in file JCombinatoricsK40.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 28 of file JCombinatoricsK40.cc.

29 {
30  using namespace std;
31  using namespace JPP;
32 
33  string detectorFile;
34  string inputFile;
35  string outputFile;
36  JPMTIdentifier pmt;
37  string extension;
38  int debug;
39 
40  try {
41 
42  JParser<> zap("Auxiliary program to project single PMT data from 2D histogram.");
43 
44  zap['a'] = make_field(detectorFile, "detector file.");
45  zap['f'] = make_field(inputFile, "input file.");
46  zap['o'] = make_field(outputFile, "output file.") = "k40.root";
47  zap['P'] = make_field(pmt, "PMT identifier");
48  zap['e'] = make_field(extension, "histogram name extension") = _2R, _2S, _2F;
49  zap['d'] = make_field(debug, "debug flag.") = 1;
50 
51  zap(argc, argv);
52  }
53  catch(const exception &error) {
54  FATAL(error.what() << endl);
55  }
56 
57 
58  gErrorIgnoreLevel = kError;
59 
60 
61  JDetector detector;
62 
63  try {
64  load(detectorFile, detector);
65  }
66  catch(const JException& error) {
67  FATAL(error);
68  }
69 
70  const JModuleRouter router(detector);
71 
72  const JModule& module = router.getModule(pmt.getModuleID());
73 
74  JCombinatorics combinatorics;
75 
76  combinatorics.configure(module.size());
77 
78  combinatorics.sort(JPairwiseComparator(module));
79 
80  TFile in(inputFile.c_str(), "read");
81 
82  TH2D* h2 = (TH2D*) in.Get(MAKE_CSTRING(pmt.getModuleID() << extension));
83 
84  if (h2 == NULL) {
85  FATAL("Missing histogram for module " << pmt.getModuleID() << endl);
86  }
87 
88  TH1D h1(MAKE_CSTRING(pmt.getModuleID() << '.' << FILL(2,'0') << pmt.getTDC()), NULL, h2->GetYaxis()->GetNbins(), h2->GetYaxis()->GetXmin(), h2->GetYaxis()->GetXmax());
89 
90  for (size_t i = 0; i != module.size(); ++i) {
91 
92  const Int_t ix = combinatorics.getIndex(pmt.getTDC(), i) + 1;
93 
94  for (Int_t iy = 1; iy <= h2->GetYaxis()->GetNbins(); ++iy) {
95  h1.SetBinContent(iy, h2->GetBinContent(ix,iy));
96  h1.SetBinError (iy, h2->GetBinError (ix,iy));
97  }
98  }
99 
100  TFile out(outputFile.c_str(), "recreate");
101 
102  out << h1;
103 
104  out.Write();
105  out.Close();
106 }
Utility class to parse command line options.
Definition: JParser.hh:1514
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:136
string outputFile
static const char *const _2F
Name extension for 2F rate fitted.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
static const char *const _2R
Name extension for 2D rate measured.
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
do set_variable DETECTOR_TXT $WORKDIR detector
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
static const char *const _2S
Name extension for 2D counts.