Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:19:16

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