Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4RootHitContainer.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4RootHitContainer.cc
1 #include "G4RootHitContainer.h"
2 
3 #include <g4main/PHG4Hit.h> // for PHG4Hit
4 #include <g4main/PHG4HitEval.h>
5 
6 #include <TClonesArray.h>
7 
8 #include <cmath> // for NAN
9 #include <ostream> // for basic_ostream::operator<<, operator<<
10 
11 using namespace std;
12 
13 static const int NMAX = 100000;
14 
16  : etotal(NAN)
17  , eion(NAN)
18  , leakage(NAN)
19  , event(0)
20 {
21  SnglHits = new TClonesArray("PHG4HitEval", NMAX);
22 }
23 
25 {
26  SnglHits->Clear();
27  delete SnglHits;
28 }
29 
31 {
32  etotal = NAN;
33  leakage = NAN;
34  event = 0;
35  SnglHits->Clear();
36  if (SnglHits->GetSize() > NMAX)
37  {
38  SnglHits->Expand(NMAX);
39  }
40  return;
41 }
42 
43 PHG4Hit *
45 {
46  TClonesArray &cl = *SnglHits;
47  int nextindex = SnglHits->GetLast() + 1;
48  if (nextindex == SnglHits->GetSize())
49  {
50  SnglHits->Expand(SnglHits->GetSize() + 10000);
51  }
52  new (cl[nextindex]) PHG4HitEval(g4hit);
53  return (static_cast<PHG4Hit *>(cl[nextindex]));
54 }
55 
56 void G4RootHitContainer::identify(ostream &os) const
57 {
58  os << "Number of Hits: " << SnglHits->GetLast() << endl;
59  return;
60 }