WCSim
read_number_of_PMTs.C
Go to the documentation of this file.
1 #include <iostream>
2 #include <stdio.h>
3 #include <stdlib.h>
4 
5 #include "TFile.h"
6 #include "TTree.h"
7 #include "TSystem.h"
8 
9 #include "WCSimRootGeom.hh"
10 
11 // Simple example of reading a generated Root file
12 int read_number_of_PMTs(const char *filename="../wcsim.root")
13 {
14 
15  // Open the file
16  TFile *f = new TFile(filename,"read");
17  if (!f->IsOpen()){
18  cout << "Error, could not open input file: " << filename << endl;
19  return -1;
20  }
21 
22  TTree *tree = (TTree*)f->Get("wcsimGeoT");
23  WCSimRootGeom* geom = new WCSimRootGeom();
24  TBranch *gb = tree->GetBranch("wcsimrootgeom");
25  gb->SetAddress(&geom);
26  tree->GetEntry(0);
27  Printf("Number of ID PMTs of the first type (e.g. 20\" PMTs in HK FD, 3\" PMTs in mPMTs in IWCD): %d", geom->GetWCNumPMT());
28  Printf("Number of OD PMTs: %d", geom->GetODWCNumPMT());
29  Printf("Number of ID PMTs of the second type (e.g. 3\" PMTs in mPMTs in HK FD): %d", geom->GetWCNumPMT(true));
30 
31  cout << "Tank radius & height: "
32  << geom->GetWCCylRadius() << "\t"
33  << geom->GetWCCylLength() << endl;
34 
35  //printout of the first few PMTs of the first type
36  // See WCSimRootGeom.hh for how to get more PMT information,
37  // and for how to get information about other PMT types
38  cout << "PMT radius " << geom->GetWCPMTRadius(false) << endl;
39  for(int i = 0; i < 10; i++)
40  cout << "PMT " << i << "\tX, Y, Z: "
41  << geom->GetPMT(i).GetPosition(0) << ",\t"
42  << geom->GetPMT(i).GetPosition(1) << ",\t"
43  << geom->GetPMT(i).GetPosition(2) << endl;
44 
45  return 0;
46 }
Int_t GetODWCNumPMT() const
Detector geometry information (also containing PMT information arrays)
Float_t GetWCPMTRadius(bool hybridsecondtype=false) const
Float_t GetWCCylLength() const
WCSimRootPMT GetPMT(Int_t i, bool hybridsecondtype=false)
Float_t GetWCCylRadius() const
Int_t GetWCNumPMT(bool hybridsecondtype=false) const
string filename
Definition: MakeKin.py:235
int read_number_of_PMTs(const char *filename="../wcsim.root")
Float_t GetPosition(Int_t i=0) const