33int main(
int argc,
char** argv)
36 std::cout <<
"Usage: " << argv[0] <<
" <analysis tree file(s)>" << std::endl;
40 std::cout << std::endl
41 <<
"WARNING: This script assumes that the TACs are in channels " <<
FirstChannel <<
" - " <<
LastChannel <<
" (which are the default). Should have they been assigned to other channel numbers, the script should be edited acordingly" << std::endl
44 auto* file =
new TFile(argv[1]);
46 auto* AnalysisTree =
static_cast<TTree*
>(file->Get(
"AnalysisTree"));
52 std::array<double, 8> offset;
57 std::cout <<
"Current TAC offset in the calfile: " << offset[n -
FirstChannel] <<
" for channel #" << n << std::endl;
60 TLaBr* labr =
nullptr;
64 if(AnalysisTree->SetBranchAddress(
"TLaBr", &labr) == TTree::kMissingBranch) {
67 if(AnalysisTree->SetBranchAddress(
"TTAC", &tac) == TTree::kMissingBranch) {
70 if(AnalysisTree->SetBranchAddress(
"TGriffin", &grif) == TTree::kMissingBranch) {
74 Long64_t nEntries = AnalysisTree->GetEntries();
76 std::string outname = argv[1];
77 outname.replace(outname.begin(), outname.end() - 14,
"TAC_offset");
78 std::cout <<
"writing to '" << outname <<
"'" << std::endl;
80 TFile outfile(outname.c_str(),
"recreate");
88 Double_t progress = 0.;
94 std::array<TH1D*, 8> TAC_offset;
95 for(
int i = 0; i < 8; ++i) {
96 TAC_offset[i] =
new TH1D(Form(
"TAC_offset_%d", i), Form(
"TAC_offset_%d; time (ns); counts/ns", i), 10000, -5000., 5000.);
97 list.Add(TAC_offset[i]);
100 std::array<TH1D*, 8> TAC_offset_corrected;
101 for(
int i = 0; i < 8; ++i) {
102 TAC_offset_corrected[i] =
new TH1D(Form(
"TAC_offset_corrected_%d", i), Form(
"TAC_offset_corrected_%d; time (ns); counts/ns", i), 10000, -5000., 5000.);
103 list.Add(TAC_offset_corrected[i]);
106 std::array<TH1D*, 8> time_diff;
107 for(
int i = 0; i < 8; ++i) {
108 time_diff[i] =
new TH1D(Form(
"time_diff%d", i), Form(
"Time difference for LaBr_%d - LaBr with TAC coincidence; time (ns); counts/ns", i), 10000, -5000., 5000.);
109 list.Add(time_diff[i]);
112 std::array<TH1D*, 8> time_diff_noTAC;
113 for(
int i = 0; i < 8; ++i) {
114 time_diff_noTAC[i] =
new TH1D(Form(
"time_diff_noTAC%d", i), Form(
"Time difference for LaBr_%d - LaBr with no TAC coincidence; time (ns); counts/ns", i), 10000, -5000., 5000.);
115 list.Add(time_diff_noTAC[i]);
118 std::array<TH1D*, 8> timestamp_diff_noTACcoinc;
119 for(
int i = 0; i < 8; ++i) {
120 timestamp_diff_noTACcoinc[i] =
new TH1D(Form(
"timestamp_diff_noTACcoinc%d", i), Form(
"Timestamp difference for LaBr_%d - LaBr, no TAC coincidence; time (ns); counts/ns", i), 10000, -5000., 5000.);
121 list.Add(timestamp_diff_noTACcoinc[i]);
124 std::array<TH1D*, 8> timestamp_diff_TACcoinc;
125 for(
int i = 0; i < 8; ++i) {
126 timestamp_diff_TACcoinc[i] =
new TH1D(Form(
"timestamp_diff_TACcoinc%d", i), Form(
"Timestamp difference for LaBr_%d - LaBr, with TAC coincidence; time (ns); counts/ns", i), 10000, -5000., 5000.);
127 list.Add(timestamp_diff_TACcoinc[i]);
130 TH1D* timestamp_diff_hpge =
new TH1D(
"timestamp_diff_hpge",
"Timestamp difference for HPGe - LaBr, with TAC coincidence; time (ns); counts/ns", 10000, -5000., 5000.);
131 list.Add(timestamp_diff_hpge);
132 TH1D* time_diff_hpge =
new TH1D(
"time_diff_hpge",
"Time difference for HPGe - LaBr, with TAC coincidence; time (ns); counts/ns", 10000, -5000., 5000.);
133 list.Add(time_diff_hpge);
135 for(Long64_t n = 0; n < nEntries; ++n) {
136 AnalysisTree->GetEntry(n);
143 if(multi_labr == 2) {
150 if(multi_labr == 2 && multi_tac == 1) {
161 for(
int i = 0; i < multi_grif; i++) {
167 }
else if(labr1 > labr2) {
174 for(
int i = 0; i < multi_grif; i++) {
184 progress = (
static_cast<double>(n)) / (
static_cast<double>(nEntries));
185 std::cout << std::setw(4) << 100 * progress <<
"% done\r" << std::flush;
189 std::cout <<
"100% done" << std::endl;