15 #include "TTreeIndex.h" 16 #include "TVirtualIndex.h" 25 #include "TStopwatch.h" 27 #include "TGRSIRunInfo.h" 60 printf(
"No analysis tree found!\n");
66 TFile* outfile =
new TFile(
"output.root",
"recreate");
71 TList*
exAnalysis(TTree* tree,
long maxEntries = 0, TStopwatch* w =
nullptr)
78 Double_t nofBins = 4000;
82 Double_t ggThigh = 60.;
84 Double_t gbThigh = 100.;
90 auto* list =
new TList;
92 const size_t MEM_SIZE =
static_cast<size_t>(1024) * static_cast<size_t>(1024) *
static_cast<size_t>(1024) *
93 static_cast<size_t>(8);
96 auto* gammaSingles =
new TH1D(
"gammaSingles",
"#gamma singles;energy[keV]", nofBins, low, high);
97 list->Add(gammaSingles);
98 auto* gammaSinglesB =
new TH1D(
"gammaSinglesB",
"#beta #gamma;energy[keV]", nofBins, low, high);
99 list->Add(gammaSinglesB);
100 auto* ggmatrix =
new TH2D(
"ggmatrix",
"#gamma-#gamma matrix", nofBins, low, high, nofBins, low, high);
109 tree->SetBranchAddress(
"TGriffin", &grif);
112 if(tree->FindBranch(
"TSceptar") ==
nullptr) {
115 tree->SetBranchAddress(
"TSceptar", &scep);
121 long entries = tree->GetEntries();
127 std::cout<<std::fixed<<std::setprecision(1);
130 if(maxEntries == 0 || maxEntries > tree->GetEntries()) {
131 maxEntries = tree->GetEntries();
133 for(entry = 0; entry < maxEntries; entry++) {
134 tree->GetEntry(entry);
161 if((gbTlow <= grif->GetHit(one)->GetTime() - scep->
GetHit(b)->
GetTime()) &&
168 if((entry % 10000) == 1) {
169 printf(
"Completed %d of %d \r", entry, maxEntries);
174 std::cout<<
"creating histograms done after "<<w->RealTime()<<
" seconds"<<std::endl;
183 if(argc != 4 && argc != 3 && argc != 2) {
184 printf(
"try again (usage: %s <analysis tree file> <optional: output file> <max entries>).\n",
argv[0]);
193 auto* file =
new TFile(
argv[1]);
195 if(file ==
nullptr) {
196 printf(
"Failed to open file '%s'!\n",
argv[1]);
199 if(!file->IsOpen()) {
200 printf(
"Failed to open file '%s'!\n",
argv[1]);
206 TGRSIRunInfo* runinfo =
dynamic_cast<TGRSIRunInfo*
>(file->Get(
"TGRSIRunInfo"));
208 TTree* tree =
dynamic_cast<TTree*
>(file->Get(
"AnalysisTree"));
211 if(tree ==
nullptr) {
212 printf(
"Failed to find analysis tree in file '%s'!\n",
argv[1]);
221 if(runinfo ==
nullptr) {
222 printf(
"Could not find run info, please provide output file name\n");
225 int runnumber = runinfo->RunNumber();
226 int subrunnumber = runinfo->SubRunNumber();
227 outfile =
new TFile(Form(
"matrix%05d_%03d.root", runnumber, subrunnumber),
"recreate");
229 outfile =
new TFile(
argv[2],
"recreate");
232 std::cout<<
argv[0]<<
": starting Analysis after "<<w.RealTime()<<
" seconds"<<std::endl;
237 int entries = atoi(
argv[3]);
238 std::cout<<
"Limiting processing of analysis tree to "<<entries<<
" entries!"<<std::endl;
245 if(runinfo !=
nullptr) {
247 sortinfolist->AddSortInfo(info);
248 sortinfolist->Write(
"TGRSISortList", TObject::kSingleKey);
252 std::cout<<
argv[0]<<
" done after "<<w.RealTime()<<
" seconds"<<std::endl<<std::endl;
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
TDetectorHit * GetHit(const int &idx)
virtual TDetectorHit * GetHit(const int &) const
virtual double GetEnergy(Option_t *opt="") const
TList * exAnalysis(TTree *tree, long maxEntries=0, TStopwatch *w=nullptr)
virtual Short_t GetMultiplicity() const
TGriffinHit * GetGriffinHit(const int &i)
!