Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:03

0001 #include "G4RootHitContainer.h"
0002 
0003 #include <g4main/PHG4Hit.h>  // for PHG4Hit
0004 #include <g4main/PHG4HitEval.h>
0005 
0006 #include <TClonesArray.h>
0007 
0008 #include <limits>
0009 #include <ostream>  // for basic_ostream::operator<<, operator<<
0010 
0011 static const int NMAX = 100000;
0012 
0013 G4RootHitContainer::G4RootHitContainer()
0014 {
0015   SnglHits = new TClonesArray("PHG4HitEval", NMAX);
0016 }
0017 
0018 G4RootHitContainer::~G4RootHitContainer()
0019 {
0020   SnglHits->Clear();
0021   delete SnglHits;
0022 }
0023 
0024 void G4RootHitContainer::Reset()
0025 {
0026   etotal = std::numeric_limits<float>::quiet_NaN();
0027   leakage = std::numeric_limits<float>::quiet_NaN();
0028   event = 0;
0029   SnglHits->Clear();
0030   if (SnglHits->GetSize() > NMAX)
0031   {
0032     SnglHits->Expand(NMAX);
0033   }
0034   return;
0035 }
0036 
0037 PHG4Hit *
0038 G4RootHitContainer::AddHit(const PHG4Hit *g4hit)
0039 {
0040   TClonesArray &cl = *SnglHits;
0041   int nextindex = SnglHits->GetLast() + 1;
0042   if (nextindex == SnglHits->GetSize())
0043   {
0044     SnglHits->Expand(SnglHits->GetSize() + 10000);
0045   }
0046   new (cl[nextindex]) PHG4HitEval(g4hit);
0047   return (static_cast<PHG4Hit *>(cl[nextindex]));
0048 }
0049 
0050 void G4RootHitContainer::identify(std::ostream &os) const
0051 {
0052   os << "Number of Hits: " << SnglHits->GetLast() << std::endl;
0053   return;
0054 }