30 #define FIRST_CHANNEL 84 31 #define LAST_CHANNEL 91 34 std::cout<<
"Usage: "<<
argv[0]<<
" <analysis tree file(s)>"<<std::endl;
39 <<
"WARNING: This script assumes that the TACs are in channels FIRST_CHANNEL-LAST_CHANNEL (which are the default). Should have they been assigned to other channel numbers, the script should be edited acordingly"<<std::endl
42 TFile* file =
new TFile(
argv[1]);
44 TTree* AnalysisTree =
static_cast<TTree*
>(file->Get(
"AnalysisTree"));
55 std::cout<<
"Current TAC offset in the calfile: "<<offset[n-
FIRST_CHANNEL]<<
" for channel #"<<n<<std::endl;
59 TLaBr* labr =
nullptr;
63 if(AnalysisTree->SetBranchAddress(
"TLaBr", &labr) == TTree::kMissingBranch) {
66 if(AnalysisTree->SetBranchAddress(
"TTAC", &tac) == TTree::kMissingBranch) {
69 if(AnalysisTree->SetBranchAddress(
"TGriffin", &grif) == TTree::kMissingBranch) {
73 Long64_t nEntries = AnalysisTree->GetEntries();
75 std::string outname =
argv[1];
76 outname.replace(outname.begin(), outname.end()-14,
"TAC_offset");
77 std::cout<<
"writing to '"<<outname<<
"'"<<std::endl;
79 TFile outfile(outname.c_str(),
"recreate");
83 UInt_t labr1,labr2,tac1;
86 Int_t multi_labr, multi_tac, multi_grif;
90 for(
int i = 0; i < 8; ++i) {
91 TAC_offset[i] =
new TH1D(Form(
"TAC_offset_%d",i), Form(
"TAC_offset_%d; time (ns); counts/ns",i), 10000,-5000.,5000.); list.Add(TAC_offset[i]);
94 TH1D* TAC_offset_corrected[8];
95 for(
int i = 0; i < 8; ++i) {
96 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.); list.Add(TAC_offset_corrected[i]);
100 for(
int i = 0; i < 8; ++i) {
101 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.); list.Add(time_diff[i]);
103 TH1D* time_diff_noTAC[8];
104 for(
int i = 0; i < 8; ++i) {
105 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.); list.Add(time_diff_noTAC[i]);
108 TH1D* timestamp_diff_noTACcoinc[8];
109 for(
int i = 0; i < 8; ++i) {
110 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.); list.Add(timestamp_diff_noTACcoinc[i]);
112 TH1D* timestamp_diff_TACcoinc[8];
113 for(
int i = 0; i < 8; ++i) {
114 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.); list.Add(timestamp_diff_TACcoinc[i]);
117 TH1D* timestamp_diff_hpge =
new TH1D(
"timestamp_diff_hpge",
"Timestamp difference for HPGe - LaBr, with TAC coincidence; time (ns); counts/ns", 10000,-5000.,5000.); list.Add(timestamp_diff_hpge);
118 TH1D* time_diff_hpge =
new TH1D(
"time_diff_hpge",
"Time difference for HPGe - LaBr, with TAC coincidence; time (ns); counts/ns", 10000,-5000.,5000.); list.Add(time_diff_hpge);
120 for(Long64_t n = 0; n < nEntries; ++n) {
121 AnalysisTree->GetEntry(n);
135 if(multi_labr==2 && multi_tac==1) {
146 for(
int i=0; i<multi_grif;i++) {
152 }
else if(labr1>labr2) {
159 for(
int i=0; i<multi_grif;i++) {
169 progress = ((double_t) n)/((double_t) nEntries);
170 std::cout<<std::setw(4)<<100*progress<<
"% done\r"<<std::flush;
174 std::cout<<
"100% done"<<std::endl;
TTACHit * GetTACHit(const int &i) const
static TChannel * GetChannelByNumber(int temp_num)
int main(int argc, char **argv)
static Int_t ReadCalFromTree(TTree *, Option_t *opt="overwrite")
virtual Double_t GetTime(const ETimeFlag &correct_flag=ETimeFlag::kAll, Option_t *opt="") const
Returns a time value to the nearest nanosecond!
Short_t GetMultiplicity() const override
TLaBrHit * GetLaBrHit(const int &i) const
Long64_t GetTimeOffset() const
virtual Int_t GetDetector() const
!
virtual Long64_t GetTimeStamp(Option_t *="") const
virtual Short_t GetMultiplicity() const
TGriffinHit * GetGriffinHit(const int &i)
!