39 JParser<> zap(
"Auxiliary program to merge K40 data.");
41 zap[
'f'] =
make_field(inputFile,
"input file (output from JCalibrateK40).");
47 catch(
const exception &error) {
48 FATAL(error.what() << endl);
52 TH1* weights_hist = NULL;
61 DEBUG(
"Processing " << *i << endl) ;
63 TFile
in(i->c_str(),
"read");
68 FATAL(
"Histogram does not contain weights histogram." << endl);
73 if (weights_hist == NULL) {
75 weights_hist = (TH1*) weights_hist_i->Clone();
81 TAxis* x_axis = weights_hist->GetXaxis();
83 if (weights_hist_i->GetBinContent(x_axis->FindBin(
WS_t)) !=
84 weights_hist ->GetBinContent(x_axis->FindBin(
WS_t))) {
85 FATAL(
"Number of y-bins does not match for this file " << *i << endl);
88 if (weights_hist_i->GetBinContent(x_axis->FindBin(
WB_t)) !=
89 weights_hist ->GetBinContent(x_axis->FindBin(
WB_t))) {
90 FATAL(
"TMax_ns is not the same for this file " << *i << endl);
95 weights_hist->SetBinContent(x_axis->FindBin(
W1_overall_t),
96 weights_hist ->GetBinContent(x_axis->FindBin(
W1_overall_t)) +
97 weights_hist_i->GetBinContent(x_axis->FindBin(
W1_overall_t)));
101 TIter iter(
in.GetListOfKeys());
103 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
105 if (TString(key->GetName()) != TString(weights_hist->GetName())) {
107 TH1*
h1 =
dynamic_cast<TH1*
>(key->ReadObj());
111 map_type::iterator p = zmap.find(h1->GetName());
113 if (p == zmap.end()) {
115 DEBUG(
"Clone " << h1->GetName() << endl);
117 p = zmap.insert(make_pair(h1->GetName(), (TH1*) h1->Clone())).first;
121 DEBUG(
"Add " << h1->GetName() << endl);
129 weights_hist->SetDirectory(0);
131 for (map_type::iterator i = zmap.begin(); i != zmap.end(); ++i) {
132 i->second->SetDirectory(0);
139 if (weights_hist == NULL) {
148 const Double_t WS = weights_hist->GetBinContent(weights_hist->GetXaxis()->FindBin(
WS_t)) ;
149 const Double_t WB = weights_hist->GetBinContent(weights_hist->GetXaxis()->FindBin(
WB_t)) ;
151 for (map_type::iterator i = zmap.begin(); i != zmap.end(); ++i) {
153 if (i->first.EndsWith(
_2S)) {
155 TH2D* h2s = (TH2D*) i->second;
157 if (h2s->GetEntries() != 0) {
159 TH1D* h1b = (TH1D*) zmap.find(TString(i->first).ReplaceAll(
_2S,
_1B))->second;
160 TH1D* h1L = (TH1D*) zmap.find(TString(i->first).ReplaceAll(
_2S,
_1L))->second;
166 for (
int ix = 1; ix <= h2s->GetXaxis()->GetNbins(); ++ix) {
171 if (h1L->GetBinContent(ix) == 0.0) {
173 h1b->SetBinContent(ix, 0.0);
174 h1b->SetBinError (ix, 0.0);
176 for (
int iy = 1; iy <= h2s->GetYaxis()->GetNbins(); ++iy) {
177 h2s->SetBinContent(ix, iy, 0.0);
178 h2s->SetBinError (ix, iy, 999.999);
183 const double Y = h1b->GetBinContent(ix) / h1L->GetBinContent(ix) / WB;
184 const double W = h1b->GetBinError (ix) / h1L->GetBinContent(ix) / WB;
186 h1b->SetBinContent(ix, Y);
187 h1b->SetBinError (ix, W);
189 for (
int iy = 1; iy <= h2s->GetYaxis()->GetNbins(); ++iy) {
191 double y = h2s->GetBinContent(ix, iy) / h1L->GetBinContent(ix) / WS;
192 double w = h2s->GetBinError (ix, iy) / h1L->GetBinContent(ix) / WS;
198 w = 1.0 / h1L->GetBinContent(ix) / WS;
201 h2s->SetBinContent(ix, iy, y - Y);
202 h2s->SetBinError (ix, iy, TMath::Sqrt(w*w + W*W));
209 for (
int ix = 0; ix <= h2s->GetXaxis()->GetNbins() + 1; ++ix) {
210 h2s->SetBinContent(ix, 0, 0.0); h2s->SetBinContent(ix, h2s->GetYaxis()->GetNbins() + 1, 0.0);
211 h2s->SetBinError (ix, 0, 0.0); h2s->SetBinError (ix, h2s->GetYaxis()->GetNbins() + 1, 0.0);
214 for (
int iy = 0; iy <= h2s->GetYaxis()->GetNbins() + 1; ++iy) {
215 h2s->SetBinContent(0, iy, 0.0); h2s->SetBinContent(h2s->GetXaxis()->GetNbins() + 1, iy, 0.0);
216 h2s->SetBinError (0, iy, 0.0); h2s->SetBinError (h2s->GetXaxis()->GetNbins() + 1, iy, 0.0);
219 NOTICE(
"Biased coincidence rate [Hz] " << h2s->GetName() <<
' ' << h2s->GetSumOfWeights() * WS << endl);
221 h2s->SetName(TString(i->first).ReplaceAll(
_2S,
_2R));
Utility class to parse command line options.
static const char *const WB_t
Named bin for value of TMax_ns in JCalibrateK40.
then for HISTOGRAM in h0 h1
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
static const char *const WS_t
Named bin for time residual bin width.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
static const char *const _1B
Name extension for 1D background.
static const char *const _2R
Name extension for 2D rate measured.
do if[[!-f $ACOUSTICS_WORKDIR/${KEY}.txt &&-f $JPP_LIB/${KEY}_ ${(l:8::0::0:) ID}.txt]]
static const char *const weights_hist_t
Histogram naming.
static const char *const _1L
Name extension for 1D live time.
static const char *const W1_overall_t
Named bin for duration of the run.
void copy(const Head &from, JHead &to)
Copy header from from to to.
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 typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
static const char *const _2S
Name extension for 2D counts.
#define DEBUG(A)
Message macros.
bool putObject(TDirectory *dir, const T &object)
Write object to ROOT directory.