WCSim
testgeo.C
Go to the documentation of this file.
1 #include <iostream>
2 #include <stdio.h>
3 #include <stdlib.h>
4 
5 #include "TH1F.h"
6 #include "TFile.h"
7 #include "TTree.h"
8 #include "TSystem.h"
9 #include "TROOT.h"
10 
11 #include "WCSimRootGeom.hh"
12 
13 // Simple example of reading a generated Root file
14 int testgeo(const char *filename="../wcsim.root")
15 {
16 
17  // Clear global scope
18  gROOT->Reset();
19 
20  // Open the file
21  TFile *file = new TFile(filename,"read");
22  if (!file->IsOpen()){
23  cout << "Error, could not open input file: " << filename << endl;
24  return -1;
25  }
26 
27  // Get the a pointer to the tree from the file
28  TTree *gtree = (TTree*)file->Get("wcsimGeoT");
29 
30  // Get the number of events
31  int nevent = gtree->GetEntries();
32  printf("geo nevent %d\n",nevent);
33 
34  // Create a WCSimRootGeom to put stuff from the tree in
35 
36  WCSimRootGeom* wcsimrootgeom = new WCSimRootGeom();
37 
38  // Set the branch address for reading from the tree
39  TBranch *branch = gtree->GetBranch("wcsimrootgeom");
40  branch->SetAddress(&wcsimrootgeom);
41 
42  // Now loop over "events" (should be only one for geo tree)
43  int ev;
44  for (ev=0;ev<nevent; ev++) {
45  // Read the event from the tree into the WCSimRootGeom instance
46  gtree->GetEntry(ev);
47  printf("Cyl radius %f\n", wcsimrootgeom->GetWCCylRadius());
48  printf("Cyl length %f\n", wcsimrootgeom->GetWCCylLength());
49  printf("PMT radius %f\n", wcsimrootgeom->GetWCPMTRadius());
50  printf("Offset x y z %f %f %f\n", wcsimrootgeom->GetWCOffset(0),
51  wcsimrootgeom->GetWCOffset(1),wcsimrootgeom->GetWCOffset(2));
52  int numpmt = wcsimrootgeom->GetWCNumPMT();
53  printf("Num PMTs %d\n", numpmt);
54 
55  int i;
56  for (i=0;i<((numpmt<20)?numpmt:20);i++){
57  WCSimRootPMT pmt;
58  pmt = wcsimrootgeom->GetPMT(i);
59  printf ("pmt %d %d %d\n",i,pmt.GetTubeNo(), pmt.GetCylLoc());
60  printf ("position: %f %f %f\n", pmt.GetPosition(0),
61  pmt.GetPosition(1),pmt.GetPosition(2));
62  printf ("orientation: %f %f %f\n", pmt.GetOrientation(0),
63  pmt.GetOrientation(1),pmt.GetOrientation(2));
64  }
65 
66  } // End of loop over events
67 
68  return 0;
69 }
Int_t GetCylLoc() const
Detector geometry information (also containing PMT information arrays)
Float_t GetWCPMTRadius(bool hybridsecondtype=false) const
Float_t GetWCCylLength() const
int testgeo(const char *filename="../wcsim.root")
Definition: testgeo.C:14
WCSimRootPMT GetPMT(Int_t i, bool hybridsecondtype=false)
Float_t GetWCCylRadius() const
PMT geometry information.
Int_t GetWCNumPMT(bool hybridsecondtype=false) const
string filename
Definition: MakeKin.py:235
Int_t GetTubeNo() const
Float_t GetWCOffset(Int_t i) const
Float_t GetOrientation(Int_t i=0) const
Float_t GetPosition(Int_t i=0) const