Message: Re: Memory problem with optical photons Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Memory problem with optical photons 

Forum: Processes Involving Optical Photons
Re: None Memory problem with optical photons (Davinder Siwal)
Re: Feedback Re: Memory problem with optical photons (Gumplinger Peter)
Date: 29 May, 2011
From: Davinder Siwal <Davinder Siwal>

Hiii Peter

thanks for reply

now I am collecting the position hits on PMT which is similar to wls example. I made several attempts to solve this problem but I did not succeed in any case. Actually I am using ROOT interfacing for collecting the events and storing into the ROOT Tree But I don't understand why it is not releasing the memory when it exit from the simulation.Here is the code snippet which i am using in EventAction file

PlanarEventAction::PlanarEventAction():PlanarCollectionID(-1),
				       photoHitCollectionID(-1),
				       AbCounter(0),GCounter(0),
				       BoundaryCounter(0),GammaVertex_hit(0),
				       TEdep(0),En(0),n_hit(0),photo_hit(0)

{

  f = new TFile("Planar_2_10deg.root","RECREATE");
  T = new TTree("T","DOI Analysis Tree");
  T->Branch("ScintHit",&n_hit,"n_hit/I");
  T->Branch("Energy",&En,"En/D");
  T->Branch("GammaVertex_hit",&GammaVertex_hit,"GammaVertex_hit/I");
  T->Branch("Vertex_posx",VPos_x,"VPos_x[GammaVertex_hit]/D");
  T->Branch("Vertex_posy",VPos_y,"VPos_y[GammaVertex_hit]/D");
  T->Branch("Vertex_posz",VPos_z,"VPos_z[GammaVertex_hit]/D");
  T->Branch("photo_hit",&photo_hit,"photo_hit/I");
  T->Branch("Pos_x",Pos_x,"Pos_x[photo_hit]/D");
  T->Branch("Pos_y",Pos_y,"Pos_y[photo_hit]/D");

}

PlanarEventAction::~PlanarEventAction()
{
  f->Write();
  f->Close();
  delete f;
  G4cout<<"Events are written on ROOT tree "<<G4endl;
}

void PlanarEventAction::BeginOfEventAction(const G4Event* aEvent) {

  G4int eventNb = aEvent->GetEventID();
  G4cout<<"\n----------------> Begin of Event:"<<eventNb<<G4endl;
  G4SDManager *SDman = G4SDManager::GetSDMpointer();
  if(PlanarCollectionID<0)
    PlanarCollectionID = SDman->GetCollectionID("planar_Collection");
  if(photoHitCollectionID<0)
    photoHitCollectionID = SDman->GetCollectionID("PhotoHitCollection");

}

void PlanarEventAction::EndOfEventAction(const G4Event* aEvent) {

  G4HCofThisEvent *HCE = aEvent->GetHCofThisEvent();
   PlanarHitsCollection* PHC = 0;
   PlanarPhotoCathodeHitsCollection* PPC=0;

  if(PlanarCollectionID>=0)
   PHC =(PlanarHitsCollection*)(HCE->GetHC(PlanarCollectionID));

  n_hit = PHC->entries();

  for(int i=0;i<n_hit;i++)
    {
      PlanarHit *hit = (*PHC)[i];
      TEdep+= hit->GetEdep();
    }

  if(photoHitCollectionID>=0)
    PPC = (PlanarPhotoCathodeHitsCollection*)(HCE->GetHC(photoHitCollectionID));

  photo_hit = PPC->entries();

  En = 1000*TEdep;

  for(int j=0;j<photo_hit;j++)
    {
      PlanarPhotoCathodeHit *pHit = (*PPC)[j];
      Pos_x[j] = (pHit->GetPosition()).x();
      Pos_y[j] = (pHit->GetPosition()).y();
    }

  GammaVertex_hit = GCounter;
  for(int i=0;i<GCounter;i++)
    {
      VPos_x[i] = VPosition[i+1].x();
      VPos_y[i] = VPosition[i+1].y();
      VPos_z[i] = VPosition[i+1].z();
    }

  if(n_hit!=0)
    {

      G4cout<<"Total no. of hits in Scintillator = "<<n_hit<<G4endl; 
      G4cout<<"Total no. of Gamma Vertex in this Event = "<<GCounter<<G4endl;
      for(int i=1;i<=GCounter;i++)
	G4cout<<"Gamma vertex Position: "<<VPosition[i]<<G4endl;;
      G4cout<<"No. of photon Absorbed = "<<AbCounter<<G4endl;
      G4cout<<"No. of Photons Absorb at LYSO/glass Boundary = "<<BoundaryCounter<<G4endl;
      G4cout<<"Total PhotoCathode Hits = "<<photo_hit<<G4endl;
      G4cout<<"Total energy deposited by this event = "<<G4BestUnit(TEdep,"Energy")<<G4endl;
      G4cout<<"photons absorb in casing = "<<casingCounter<<G4endl;
      T->Fill();

    }
  photo_hit=0; 
  TEdep = 0;
  Time = 0;
  n_hit=0;
  AbCounter=0;
  BoundaryCounter = 0;
  GCounter = 0;
  casingCounter = 0;
  G4cout<<G4endl;
  //VPosition[] = {G4ThreeVctor(0.,0.,0.)};

 G4cout<<"\n----------------->End of event: "<<aEvent->GetEventID()<<G4endl;
}

Here Planar is the LYSO crystal. Can you shed some light in this direction.

With Regard

 Add Message Add Message
to: "Re: Memory problem with optical photons"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews