Class Reference for E1039 Core & Analysis Software
AnaModule.cxx
Go to the documentation of this file.
1 #include <iomanip>
2 #include <TFile.h>
3 #include <TTree.h>
4 
7 #include <phool/getClass.h>
8 
9 #include "AnaModule.h"
10 
11 int AnaModule::Init(PHCompositeNode* topNode)
12 {
14 }
15 
17 {
18  int ret = GetNodes(topNode);
19  if(ret != Fun4AllReturnCodes::EVENT_OK) return ret;
20 
21  eventID = 0;
22  MakeTree();
24 }
25 
27 {
28  nHits = 0;
29  for(size_t i = 0; i < hitVector->size(); ++i)
30  {
31  SQHit* hit = hitVector->at(i);
32 
33  int elementID = hit->get_element_id();
34  edep[nHits] = hit->get_edep();
35  vID[nHits] = elementID % (3*6*2);
36  hID[nHits] = (elementID - hID[nHits])/(3*6*2);
37 
38  ++nHits;
39  }
40  saveTree->Fill();
41 
42  ++eventID;
44 }
45 
46 int AnaModule::End(PHCompositeNode* topNode)
47 {
48  saveFile->cd();
49  saveFile->Write();
50  saveFile->Close();
51 
53 }
54 
55 void AnaModule::set_output_filename(const TString& n)
56 {
57  saveName = n;
58 }
59 
60 int AnaModule::GetNodes(PHCompositeNode *topNode)
61 {
62  hitVector = findNode::getClass<SQHitVector>(topNode, "SQHitVector");
63  if(!hitVector)
64  {
66  }
68 }
69 
70 void AnaModule::MakeTree()
71 {
72  saveFile = new TFile(saveName, "RECREATE");
73  saveTree = new TTree("save", "Created by AnaModule");
74 
75  saveTree->Branch("eventID", &eventID, "eventID/I");
76  saveTree->Branch("nHits", &nHits, "nHits/I");
77  saveTree->Branch("edep", edep, "edep[nHits]/D");
78  saveTree->Branch("hID", hID, "hID[nHits]/I");
79  saveTree->Branch("vID", vID, "vID[nHits]/I");
80 }
void set_output_filename(const TString &n)
Definition: AnaModule.h:32
int End(PHCompositeNode *topNode)
Called at the end of all processing.
Definition: AnaModule.cxx:70
int Init(PHCompositeNode *topNode)
Definition: AnaModule.cxx:20
int InitRun(PHCompositeNode *topNode)
Definition: AnaModule.cxx:25
int process_event(PHCompositeNode *topNode)
Definition: AnaModule.cxx:35
virtual const SQHit * at(const size_t idkey) const =0
virtual size_t size() const =0
An SQ interface class to hold one detector hit.
Definition: SQHit.h:20
virtual float get_edep() const
Not valid in E1039. To be deleted.
Definition: SQHit.h:63
virtual short get_element_id() const
Return the element ID of this hit.
Definition: SQHit.h:45