Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HijingCountNtuple.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HijingCountNtuple.cc
1 #include "HijingCountNtuple.h"
2 
4 #include <g4main/PHG4Hit.h>
5 
7 #include <g4main/PHG4Particle.h>
8 #include <g4main/PHG4VtxPoint.h>
9 
11 
12 #include <phool/getClass.h>
13 
14 #include <TFile.h>
15 #include <TH1.h>
16 #include <TH2.h>
17 #include <TNtuple.h>
18 
19 #include <boost/foreach.hpp>
20 
21 #include<sstream>
22 
23 using namespace std;
24 
26  SubsysReco( name ),
27  nblocks(0),
28  hm(NULL),
29  _filename(filename),
30  ntup(NULL),
31  outfile(NULL)
32 {}
33 
35 {
36  // delete ntup;
37  delete hm;
38 }
39 
40 
41 int
43 {
44  ostringstream hname, htit;
45  hm = new Fun4AllHistoManager(Name());
46  outfile = new TFile(_filename.c_str(), "RECREATE");
47  //ntup = new TNtuple("hitntup", "G4Hits", "detid:layer:x0:y0:z0:x1:y1:z1:edep");
48  ntupe = new TNtuple("hijingcnt", "NHits", "cemc:cemc_abs:ihcal:ihcal_abs:ohcal:ohcal_abs:prim");
49  // ntup->SetDirectory(0);
50  return 0;
51 }
52 
53 int
55 {
56  map<int, PHG4Particle*>::const_iterator particle_iter;
57  PHG4TruthInfoContainer *_truth_container = findNode::getClass<PHG4TruthInfoContainer>(topNode, "G4TruthInfo");
58 
60  _truth_container->GetPrimaryParticleRange();
61  float ntvars[7] = {0};
62  for (PHG4TruthInfoContainer::ConstIterator particle_iter = primary_range.first;
63  particle_iter != primary_range.second; ++particle_iter)
64  {
65  ntvars[6] += 1.;
66  }
67  PHG4HitContainer *hits = nullptr;
68  string nodename[6] = {"G4HIT_CEMC", "G4HIT_ABSORBER_CEMC",
69  "G4HIT_HCALIN", "G4HIT_ABSORBER_HCALIN",
70  "G4HIT_HCALOUT", "G4HIT_ABSORBER_HCALOUT"};
71 
72  for (int i=0; i<6; i++)
73  {
74  hits = findNode::getClass<PHG4HitContainer>(topNode,nodename[i]);
75 
76  if (hits)
77  {
78  // double numhits = hits->size();
79  // nhits[i]->Fill(numhits);
80  ntvars[i] = hits->size();
81  }
82  }
83 
84  ntupe->Fill(ntvars);
85  return 0;
86 }
87 
88 int
90 {
91  outfile->cd();
92  // ntup->Write();
93  ntupe->Write();
94  outfile->Write();
95  outfile->Close();
96  delete outfile;
97  hm->dumpHistos(_filename, "UPDATE");
98  return 0;
99 }
100 
101 void
103 {
104  _node_postfix.insert(name);
105  _detid[name] = detid;
106  return;
107 }