File indexing completed on 2025-08-05 08:13:28
0001
0002
0003 #include <bbc/MbdOut.h>
0004 #include <bbc/MbdPmtContainer.h>
0005 #include <bbc/MbdGeom.h>
0006 #include <bbc/MbdPmtHit.h>
0007 #include <phool/getClass.h>
0008
0009 #include <phool/PHCompositeNode.h>
0010
0011
0012 #include <fun4all/Fun4AllReturnCodes.h>
0013 #include <fun4all/Fun4AllServer.h>
0014 #include <fun4all/Fun4AllHistoManager.h>
0015 #include <phool/PHCompositeNode.h>
0016 #include <phool/getClass.h>
0017 #include <phool/phool.h>
0018 #include <ffaobjects/EventHeader.h>
0019
0020
0021 #include <TH1F.h>
0022 #include <TH2F.h>
0023 #include <TH3F.h>
0024 #include <TFile.h>
0025 #include <TLorentzVector.h>
0026 #include <TTree.h>
0027
0028 #include "mbdAnalysis.h"
0029
0030 #include <fun4all/Fun4AllReturnCodes.h>
0031
0032 #include <phool/PHCompositeNode.h>
0033
0034
0035 mbdAnalysis::mbdAnalysis(const std::string &name):
0036 SubsysReco(name)
0037 {
0038 std::cout << "mbdAnalysis::mbdAnalysis(const std::string &name) Calling ctor" << std::endl;
0039 }
0040
0041
0042 mbdAnalysis::~mbdAnalysis()
0043 {
0044 std::cout << "mbdAnalysis::~mbdAnalysis() Calling dtor" << std::endl;
0045 }
0046
0047
0048 int mbdAnalysis::Init(PHCompositeNode *topNode)
0049 {
0050
0051 out = new TFile("output.root","RECREATE");
0052
0053 T = new TTree("T","T");
0054
0055
0056
0057 T -> Branch("pmtcharge",&pmtcharge);
0058 T -> Branch("pmttime",&pmttime);
0059 T -> Branch("pmtx",&pmtx);
0060 T -> Branch("pmty",&pmty);
0061 T -> Branch("pmtz",&pmtz);
0062 T -> Branch("pmtr",&pmtr);
0063 T -> Branch("pmtphi",&pmtphi);
0064
0065
0066
0067 return Fun4AllReturnCodes::EVENT_OK;
0068 }
0069
0070
0071 int mbdAnalysis::InitRun(PHCompositeNode *topNode)
0072 {
0073 std::cout << "mbdAnalysis::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << std::endl;
0074 return Fun4AllReturnCodes::EVENT_OK;
0075 }
0076
0077
0078 int mbdAnalysis::process_event(PHCompositeNode *topNode)
0079 {
0080
0081
0082
0083
0084
0085
0086
0087
0088 MbdPmtContainer *mbdpmts = findNode::getClass<MbdPmtContainer>(topNode,"MbdPmtContainer");
0089 if(!mbdpmts)
0090 {
0091 std::cout << "makeMBDTrees::process_event: Could not find MbdPmtContainer, aborting" << std::endl;
0092 return Fun4AllReturnCodes::ABORTEVENT;
0093 }
0094
0095
0096 MbdGeom *mbdgeom = findNode::getClass<MbdGeom>(topNode, "MbdGeom");
0097
0098
0099
0100
0101 int nPMTs = mbdpmts -> get_npmt();
0102 for(int i = 0; i < nPMTs; i++)
0103 {
0104
0105 MbdPmtHit* mbdpmt = mbdpmts -> get_pmt(i);
0106
0107
0108
0109
0110
0111
0112
0113 float charge = mbdpmt->get_q();
0114 float time = mbdpmt->get_time();
0115
0116
0117 pmttime.push_back(charge);
0118 pmtcharge.push_back(time);
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129 pmtx.push_back(mbdgeom->get_x(i));
0130 pmty.push_back(mbdgeom->get_y(i));
0131 pmtz.push_back(mbdgeom->get_z(i));
0132 pmtr.push_back(mbdgeom->get_r(i));
0133 pmtphi.push_back(mbdgeom->get_phi(i));
0134
0135 std::cout << "phi angle of pmt is mbdgeom->get_phi(i)): " << mbdgeom->get_phi(i) << std::endl;
0136 }
0137
0138 T -> Fill();
0139
0140
0141 return Fun4AllReturnCodes::EVENT_OK;
0142 }
0143
0144
0145 int mbdAnalysis::ResetEvent(PHCompositeNode *topNode)
0146 {
0147 std::cout << "mbdAnalysis::ResetEvent(PHCompositeNode *topNode) Resetting internal structures, prepare for next event" << std::endl;
0148 return Fun4AllReturnCodes::EVENT_OK;
0149 }
0150
0151
0152 int mbdAnalysis::EndRun(const int runnumber)
0153 {
0154 std::cout << "mbdAnalysis::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
0155 return Fun4AllReturnCodes::EVENT_OK;
0156 }
0157
0158
0159 int mbdAnalysis::End(PHCompositeNode *topNode)
0160 {
0161 std::cout << "mbdAnalysis::End(PHCompositeNode *topNode) This is the End..." << std::endl;
0162 out -> cd();
0163 T -> Write();
0164 out -> Close();
0165 return Fun4AllReturnCodes::EVENT_OK;
0166 }
0167
0168
0169 int mbdAnalysis::Reset(PHCompositeNode *topNode)
0170 {
0171
0172
0173
0174 pmtcharge.clear();
0175 pmttime.clear();
0176 pmtx.clear();
0177 pmty.clear();
0178 pmtz.clear();
0179 pmtr.clear();
0180 pmtphi.clear();
0181
0182
0183 return Fun4AllReturnCodes::EVENT_OK;
0184 }
0185
0186
0187 void mbdAnalysis::Print(const std::string &what) const
0188 {
0189 std::cout << "mbdAnalysis::Print(const std::string &what) const Printing info for " << what << std::endl;
0190 }