diff --git a/src/dump_header.cpp b/src/dump_header.cpp index 2fdfd9a2..58ccd792 100644 --- a/src/dump_header.cpp +++ b/src/dump_header.cpp @@ -145,6 +145,10 @@ int dump_header_root(const std::string fileName, const bool summary, const bool fileType = DH_LEM_ROOT; } + TMusrRunHeader *header{nullptr}; + bool ok; + Int_t ival; + if (fileType == DH_LEM_ROOT) { // ROOT (LEM) // read header and check if some missing run info need to be fed TLemRunHeader *runHeader = dynamic_cast(folder->FindObjectAny("TLemRunHeader")); @@ -197,7 +201,7 @@ int dump_header_root(const std::string fileName, const bool summary, const bool delete runHeader; } else { // MusrRoot // invoke the MusrRoot header object - TMusrRunHeader *header = new TMusrRunHeader(fileName.c_str(), true); // read quite + header = new TMusrRunHeader(fileName.c_str(), true); // read quite if (header == 0) { std::cerr << std::endl << "**ERROR** Couldn't invoke MusrRoot RunHeader in file:" << fileName; std::cerr << std::endl; @@ -216,8 +220,6 @@ int dump_header_root(const std::string fileName, const bool summary, const bool header->DumpHeader(); if (counts) { - bool ok; - Int_t ival; PIntVector ivec; header->Get("RunInfo/No of Histos", ival, ok); if (ok) @@ -226,8 +228,6 @@ int dump_header_root(const std::string fileName, const bool summary, const bool if (ok) redGreenOffset = ivec; } - - delete header; } // summary as well? @@ -256,27 +256,46 @@ int dump_header_root(const std::string fileName, const bool summary, const bool // detector counts as well? if (counts && (fileType == DH_MUSR_ROOT)) { // dump the detector counts - std::cout << "Detector counts" << std::endl; + std::cout << "Detector counts (all, between fgb and lgb)" << std::endl; f.GetObject("histos", folder); - if (folder != nullptr) { + if ((folder != nullptr) && (header != nullptr)) { char detectorLabel[64]; TH1F *histo{nullptr}; - UInt_t total{0}; + UInt_t total{0}, total_good{0}, ta, tg; + Int_t fgb, lgb; for (UInt_t i=0; iGet(detectorLabel, ival, ok); + if (ok) { + fgb = ival; + } + lgb = -1; + snprintf(detectorLabel, sizeof(detectorLabel), "DetectorInfo/Detector%03d/Last Good Bin", redGreenOffset[i]+j+1); + header->Get(detectorLabel, ival, ok); + if (ok) { + lgb = ival; + } + // get histo info snprintf(detectorLabel, sizeof(detectorLabel), "hDecay%03d", redGreenOffset[i]+j+1); histo = (TH1F*) folder->FindObjectAny(detectorLabel); if (histo != nullptr) { - std::cout << " " << histo->GetTitle() << ":\t " << histo->GetEntries() << std::endl; - total += histo->GetEntries(); + ta = histo->Integral(0, histo->GetNbinsX()+1); + tg = histo->Integral(fgb, lgb); + std::cout << " " << histo->GetTitle() << ":\t " << ta << ", " << tg << std::endl; + total += ta; + total_good += tg; } } if (i % 2 == 0) - std::cout << " total counts of group " << i+1 << ":\t\t\t " << total << std::endl; + std::cout << " total counts of group " << i+1 << ":\t\t\t " << total << ", " << total_good << std::endl; else - std::cout << " total counts of group " << i+1 << ":\t\t\t\t\t " << total << std::endl; + std::cout << " total counts of group " << i+1 << ":\t\t\t\t\t " << total << ", " << total_good << std::endl; } } else { std::cout << "Sorry, no histos folder found" << std::endl; @@ -287,6 +306,9 @@ int dump_header_root(const std::string fileName, const bool summary, const bool f.Close(); + if (header) + delete header; + return 0; }