Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mbdAnalysis.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file mbdAnalysis.cc
1 //#include <bbc/BbcPmtContainerV1.h>
2 //#include <bbc/BbcGeom.h>
3 #include <mbd/MbdPmtContainer.h>
4 #include <mbd/MbdGeomV1.h>
5 #include <mbd/MbdPmtHit.h>
6 #include <phool/getClass.h>
8 
10 
11 //Fun4All
13 #include <fun4all/Fun4AllServer.h>
15 #include <phool/PHCompositeNode.h>
16 #include <phool/getClass.h>
17 #include <phool/phool.h>
18 #include <ffaobjects/EventHeader.h>
19 
20 //ROOT stuff
21 #include <TH1F.h>
22 #include <TH2F.h>
23 #include <TH3F.h>
24 #include <TFile.h>
25 #include <TLorentzVector.h>
26 #include <TTree.h>
27 
28 #include "mbdAnalysis.h"
29 
31 
32 #include <phool/PHCompositeNode.h>
33 
34 //____________________________________________________________________________..
36  SubsysReco(name)
37 {
38  std::cout << "mbdAnalysis::mbdAnalysis(const std::string &name) Calling ctor" << std::endl;
39 }
40 
41 //____________________________________________________________________________..
43 {
44  std::cout << "mbdAnalysis::~mbdAnalysis() Calling dtor" << std::endl;
45 }
46 
47 //____________________________________________________________________________..
49 {
50 
51  out = new TFile("output.root","RECREATE");
52 
53  T = new TTree("T","T");
54  T -> Branch("pmtcharge",&pmtcharge);
55  T -> Branch("pmttime",&pmttime);
56  T -> Branch("pmtx",&pmtx);
57  T -> Branch("pmty",&pmty);
58  T -> Branch("pmtz",&pmtz);
59  T -> Branch("pmtr",&pmtr);
60  T -> Branch("pmtphi",&pmtphi);
61 
62 
63 
65 }
66 
67 //____________________________________________________________________________..
69 {
70  std::cout << "mbdAnalysis::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << std::endl;
72 }
73 
74 //____________________________________________________________________________..
76 {
77 
78  //pmt information
79  MbdPmtContainer *bbcpmts = findNode::getClass<MbdPmtContainer>(topNode,"MbdPmtContainer"); // bbc info
80  if(!bbcpmts)
81  {
82  std::cout << "makeMBDTrees::process_event: Could not find MbdPmtContainer, aborting" << std::endl;
84  }
85 
86  //pmg geometry information
87  MbdGeom *mbdgeom = findNode::getClass<MbdGeom>(topNode, "MbdGeom");
88  if(!mbdgeom)
89  {
90  std::cout << "makeMBDTrees::process_event: Could not find MbdGeom, aborting" << std::endl;
92  }
93 
94  int nPMTs = bbcpmts -> get_npmt(); //size (should always be 128)
95  for(int i = 0; i < nPMTs; i++)
96  {
97  MbdPmtHit* mbdpmt = bbcpmts -> get_pmt(i); // grab ith pmt (changed from pmtID)
98 
99  //store quantities of interest
100  pmtcharge.push_back(mbdpmt -> get_q());
101  pmttime.push_back(mbdpmt -> get_time());
102  pmtx.push_back(mbdgeom->get_x(i));
103  pmty.push_back(mbdgeom->get_y(i));
104  pmtz.push_back(mbdgeom->get_z(i));
105  pmtr.push_back(mbdgeom->get_r(i));
106  pmtphi.push_back(mbdgeom->get_phi(i));
107 
108  }
109 
110  T -> Fill();
111 
112 
114 }
115 
116 //____________________________________________________________________________..
118 {
119  pmtcharge.clear();
120  pmttime.clear();
121  pmtx.clear();
122  pmty.clear();
123  pmtz.clear();
124  pmtr.clear();
125  pmtphi.clear();
127 }
128 
129 //____________________________________________________________________________..
131 {
132  std::cout << "mbdAnalysis::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
134 }
135 
136 //____________________________________________________________________________..
138 {
139  std::cout << "mbdAnalysis::End(PHCompositeNode *topNode) This is the End..." << std::endl;
140  out -> cd();
141  T -> Write();
142  out -> Close();
144 }
145 
146 //____________________________________________________________________________..
148 {
149 
150  pmtcharge.clear();
151  pmttime.clear();
152  pmtx.clear();
153  pmty.clear();
154  pmtz.clear();
155  pmtr.clear();
156  pmtphi.clear();
157 
158 
160 }
161 
162 //____________________________________________________________________________..
163 void mbdAnalysis::Print(const std::string &what) const
164 {
165  std::cout << "mbdAnalysis::Print(const std::string &what) const Printing info for " << what << std::endl;
166 }