more robust handling of positron detector entries.
This commit is contained in:
parent
bcbe945d84
commit
29d09fc272
@ -145,6 +145,10 @@ int dump_header_root(const std::string fileName, const bool summary, const bool
|
|||||||
fileType = DH_LEM_ROOT;
|
fileType = DH_LEM_ROOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TMusrRunHeader *header{nullptr};
|
||||||
|
bool ok;
|
||||||
|
Int_t ival;
|
||||||
|
|
||||||
if (fileType == DH_LEM_ROOT) { // ROOT (LEM)
|
if (fileType == DH_LEM_ROOT) { // ROOT (LEM)
|
||||||
// read header and check if some missing run info need to be fed
|
// read header and check if some missing run info need to be fed
|
||||||
TLemRunHeader *runHeader = dynamic_cast<TLemRunHeader*>(folder->FindObjectAny("TLemRunHeader"));
|
TLemRunHeader *runHeader = dynamic_cast<TLemRunHeader*>(folder->FindObjectAny("TLemRunHeader"));
|
||||||
@ -197,7 +201,7 @@ int dump_header_root(const std::string fileName, const bool summary, const bool
|
|||||||
delete runHeader;
|
delete runHeader;
|
||||||
} else { // MusrRoot
|
} else { // MusrRoot
|
||||||
// invoke the MusrRoot header object
|
// 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) {
|
if (header == 0) {
|
||||||
std::cerr << std::endl << "**ERROR** Couldn't invoke MusrRoot RunHeader in file:" << fileName;
|
std::cerr << std::endl << "**ERROR** Couldn't invoke MusrRoot RunHeader in file:" << fileName;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -216,8 +220,6 @@ int dump_header_root(const std::string fileName, const bool summary, const bool
|
|||||||
header->DumpHeader();
|
header->DumpHeader();
|
||||||
|
|
||||||
if (counts) {
|
if (counts) {
|
||||||
bool ok;
|
|
||||||
Int_t ival;
|
|
||||||
PIntVector ivec;
|
PIntVector ivec;
|
||||||
header->Get("RunInfo/No of Histos", ival, ok);
|
header->Get("RunInfo/No of Histos", ival, ok);
|
||||||
if (ok)
|
if (ok)
|
||||||
@ -226,8 +228,6 @@ int dump_header_root(const std::string fileName, const bool summary, const bool
|
|||||||
if (ok)
|
if (ok)
|
||||||
redGreenOffset = ivec;
|
redGreenOffset = ivec;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete header;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// summary as well?
|
// summary as well?
|
||||||
@ -256,27 +256,46 @@ int dump_header_root(const std::string fileName, const bool summary, const bool
|
|||||||
// detector counts as well?
|
// detector counts as well?
|
||||||
if (counts && (fileType == DH_MUSR_ROOT)) {
|
if (counts && (fileType == DH_MUSR_ROOT)) {
|
||||||
// dump the detector counts
|
// 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);
|
f.GetObject("histos", folder);
|
||||||
if (folder != nullptr) {
|
if ((folder != nullptr) && (header != nullptr)) {
|
||||||
char detectorLabel[64];
|
char detectorLabel[64];
|
||||||
TH1F *histo{nullptr};
|
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; i<redGreenOffset.size(); i++) {
|
for (UInt_t i=0; i<redGreenOffset.size(); i++) {
|
||||||
std::cout << " Group " << i+1 << " (Offset=" << redGreenOffset[i] << ") : " << std::endl;
|
std::cout << " Group " << i+1 << " (Offset=" << redGreenOffset[i] << ") : " << std::endl;
|
||||||
total = 0;
|
total = 0;
|
||||||
|
total_good = 0;
|
||||||
for (UInt_t j=0; j<noOfHistos; j++) {
|
for (UInt_t j=0; j<noOfHistos; j++) {
|
||||||
|
// get fgb, lgb
|
||||||
|
fgb = -1;
|
||||||
|
snprintf(detectorLabel, sizeof(detectorLabel), "DetectorInfo/Detector%03d/First Good Bin", redGreenOffset[i]+j+1);
|
||||||
|
header->Get(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);
|
snprintf(detectorLabel, sizeof(detectorLabel), "hDecay%03d", redGreenOffset[i]+j+1);
|
||||||
histo = (TH1F*) folder->FindObjectAny(detectorLabel);
|
histo = (TH1F*) folder->FindObjectAny(detectorLabel);
|
||||||
if (histo != nullptr) {
|
if (histo != nullptr) {
|
||||||
std::cout << " " << histo->GetTitle() << ":\t " << histo->GetEntries() << std::endl;
|
ta = histo->Integral(0, histo->GetNbinsX()+1);
|
||||||
total += histo->GetEntries();
|
tg = histo->Integral(fgb, lgb);
|
||||||
|
std::cout << " " << histo->GetTitle() << ":\t " << ta << ", " << tg << std::endl;
|
||||||
|
total += ta;
|
||||||
|
total_good += tg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i % 2 == 0)
|
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
|
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 {
|
} else {
|
||||||
std::cout << "Sorry, no histos folder found" << std::endl;
|
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();
|
f.Close();
|
||||||
|
|
||||||
|
if (header)
|
||||||
|
delete header;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user