Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
draw_real_dst.cc
Go to the documentation of this file.
1 
17 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
18 R__LOAD_LIBRARY(libinterface_main)
19 #endif
20 
21 TTree* GetTree(const int run);
22 void PrintTreeElements(TTree* tree);
23 
25 void draw_real_dst(const int run=318)
26 {
27  gSystem->Load("libinterface_main.so");
28 
29  TTree* tree = GetTree(run);
30  //PrintTreeElements(tree); // Call this function if you want.
31  tree->SetAlias("event", "DST.SQEvent");
32  tree->SetAlias("hit" , "DST.SQHitVector._vector");
33 
34  TCanvas* c1 = new TCanvas("c1", "");
35  c1->SetGrid();
36 
38  //tree->Draw("DST.SQHitVector.@_vector.size()", "");
39  //c1->SaveAs("n_hits.png");
40 
42  tree->Draw("hit.get_tdc_time()",
43  "event._trigger == 0x4 && hit.get_detector_id() == 13");
44  c1->SaveAs("tdc_time.png");
45 
47  tree->Draw("hit.get_element_id()",
48  "event._trigger == 0x4 && hit.get_detector_id() == 13");
49  c1->SaveAs("ele_id.png");
50 
51  exit(0);
52 }
53 
55 TTree* GetTree(const int run)
56 {
57  ostringstream oss;
58  oss << "/data2/e1039/dst/run_" << setfill('0') << setw(6) << run << "_spin.root";
59  string fn_in = oss.str();
60  cout << "DST = " << fn_in << endl;
61  TFile* file = new TFile(fn_in.c_str());
62  if (! file->IsOpen()) {
63  cout << " Cannot open the DST file. Abort." << endl;
64  exit(1);
65  }
66  TTree* tree = (TTree*)file->Get("T");
67  if (! tree) {
68  cout << " Cannot get the tree object. Abort." << endl;
69  exit(1);
70  }
71  return tree;
72 }
73 
75 void PrintTreeElements(TTree* tree)
76 {
77  TObjArray* arr = tree->GetListOfLeaves();
78  int n_ent = arr->GetEntries();
79  for (int i_ent = 0; i_ent < n_ent; i_ent++) {
80  TObject* obj = arr->At(i_ent);
81  cout << setw(2) << i_ent << " " << obj->ClassName() << " " << obj->GetName() << "\n";
82  }
83  cout << endl;
84 
85  //TLeaf* leaf = tree->GetLeaf("DST.SQHitVector._vector");
86  //leaf->Print();
87  //TObject* cl = leaf->GetValuePointer();
88  //cout << leaf->GetTypeName() << " " << cl->GetName() << endl;
89  //leaf->PrintValue(10);
90  //exit(0);
91 }
void PrintTreeElements(TTree *tree)
Sub-function to just print out the list of tree variables.
int run(const int nEvents=1)
Definition: run.C:10
void draw_real_dst(const int run=318)
Main function.
TTree * GetTree(const int run)
ROOT macro to look into the E1039 DST file in a simple way.
TCanvas * c1
Definition: Fun4SimTree.C:5