GRSISort
Created by P.C. Bender
Developement Team: P.C. Bender, R. Dunlop, V. Bildstein
An extension of the ROOT analysis Framework
testAnalysis.cxx
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <string>
4 
5 #include "TFile.h"
6 #include "TChain.h"
7 #include "TTree.h"
8 
9 #include "TGriffin.h"
10 #include "TChannel.h"
11 #include "TGRSIOptions.h"
12 #include "TGRSIMnemonic.h"
13 
14 int main(int argc, char** argv)
15 {
16  if(argc < 3) {
17  std::cerr<<"Usage: "<<argv[0]<<" <entries (-1 = all)> <file(s)>"<<std::endl;
18  return 1;
19  }
20 
21  TChain chain("AnalysisTree");
22 
23  for(int i = 2; i < argc; ++i) {
24  chain.Add(argv[i]);
25  }
26 
27  TGriffin* griffin = nullptr;
28 
29  if(chain.SetBranchAddress("TGriffin", &griffin) == TTree::kMissingBranch) {
30  griffin = new TGriffin;
31  }
32 
33  int64_t entries = chain.GetEntries();
34  int64_t maxEntries = std::stoi(std::string(argv[1]));
35 
36  if(maxEntries == -1 || maxEntries > entries) maxEntries = entries;
37 
38  static TFile* currentFile = nullptr;
39  TChannel::SetMnemonicClass(TGRSIMnemonic::Class());
40  for(int64_t e = 0; e < maxEntries; ++e) {
41  chain.GetEntry(e);
42  if(currentFile != chain.GetCurrentFile()) {
43  currentFile = chain.GetCurrentFile();
44  TChannel::ReadCalFromFile(currentFile);
46  std::cout<<"Mnemonic class "<<TChannel::GetMnemonicClass().GetClassName()<<std::endl;
47  }
48 
49  //TChannel::ReadCalFromCurrentFile();
50 
51  //if(griffin->GetMultiplicity() == 0) std::cout<<e<<": no GRIFFIN hits"<<std::endl;
52 
53  for(int g = 0; g < griffin->GetMultiplicity(); ++g) {
54  auto hit = griffin->GetGriffinHit(g);
55  std::cout<<"entry "<<e<<", hit "<<g<<std::endl;
56  hit->Print("all");
57  }
58  }
59 
60  return 0;
61 }
int main(int argc, char **argv)
static Int_t ReadCalFromFile(TFile *tempf, Option_t *opt="overwrite")
Definition: TChannel.cxx:880
static TClassRef GetMnemonicClass()
Definition: TChannel.h:77
static void SetMnemonicClass(TClassRef cl)
Definition: TChannel.h:76
Short_t GetMultiplicity() const override
Definition: TGriffin.h:49
static TAnalysisOptions * AnalysisOptions()
Definition: TGRSIOptions.h:68
void Print(Option_t *opt="") const override
!
Definition: TGriffinHit.cxx:69
void ReadFromFile(const std::string &file)
TGriffinHit * GetGriffinHit(const int &i)
!
Definition: TGriffin.h:44