Message: Re: Save vectors into Ntuples Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Save vectors into Ntuples 

Forum: Analysis
Re: Question Save vectors into Ntuples
Re: None Re: Save vectors into Ntuples (Ivana Hrivnacova)
Date: Jan 11, 08:12
From: <fceraudo>

Hello,

your solution solved the compilation problem, but now I apparently save empty vectors... I know that the deposited energy is recorded, because I also save its sum, which is non-zero, but the vector is empty, as if push_back does not work or I inadvertently delete the vector content. I tried to print the vector at each step and it looks always empty.

I am actually a bit concerned about the following piece of code:

<DetectorSD.cc>

void DetectorSD::Initialize(G4HCofThisEvent* hce)
{
  fHitsCollection 
    = new DetectorHitsCollection(SensitiveDetectorName,
				 collectionName[0]);

  // Add this collection in hce
  G4int hcID 
    = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
  hce->AddHitsCollection(hcID, fHitsCollection); 

  DetectorHit* newHit = new DetectorHit();
  RunAction* myRun = (RunAction*) G4RunManager::GetRunManager()->GetUserRunAction();
  myRun->GetEdep().clear();
  newHit->SetEdepAddr(myRun->GetEdep());

  fHitsCollection->insert(newHit);
}

which I derived from a program found on line. I understand I have to clear the arrays to avoid mixing the information from all the particles, but I am worried I am actually deleting everything I stored each time a new hit is initialized, since all the arrays point to the same one defined in RunAction.hh. However, I am not that good at C++, so I am not sure.

Any thoughts and/or solutions?

Thank you again.

Francesco

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: Save vectors into Ntuples   (Ivana Hrivnacova - Jan 14, 02:59)
 Add Message Add Message
to: "Re: Save vectors into Ntuples"

 Subscribe Subscribe

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


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]