Fill Histogram with particles that have weights less than 1

Dear Geant4 users,
For example in the following code, I fill the histogram using the kinetic energy of particles, but these particles have small weights (<1).

    G4double E = aStep->GetPreStepPoint()->GetKineticEnergy() / keV;
    G4double w = aStep->GetPreStepPoint()->GetWeight();
    // G4cout << E << "--------------->" << w << "\n";
    G4AnalysisManager *man = G4AnalysisManager::Instance();

    // man->FillNtupleDColumn(0, 0, E);
    // man->AddNtupleRow(0);
    man->FillH1(0, E);

I want to ask if this is the right way.
many regards.

You didn’t include the weight in the filling:

   man->FillH1(0, E, w);

Also, if you ever uncomment this, don’t use the newline character at the end; use G4endl; instead, as it takes care of multithreaded buffering properly.

Thank you @mkelsey, It’s working very well

Hi mkelsey
I’m sorry to bother you here, but I really need your help right now. I’ve recently been testing a radioactive seed I designed and implanted this seed into a DICOM built model using parallel geometry. I want to use the command /gps/pos/confine to restrict my gps in this radioactive seed. Since my radioactive seed is a spiral structure, I can’t just define the gps as a cylinder and place it into source geometry.

According to my previous experience, if I define a source geometry in mass world I can use /gps/pos/confine to confine the generated gps in this source geometry, but when this source geometry is defined in parallel geometry, G4 tells me that I can’t find the source geometry I defined.

So I wanted to ask if G4 doesn’t support using /gps/pos/confine in parallel geometry or if it is possible to do so but there is something wrong with my approach. Thanks for your answer and really looking forward to your reply.
Cheers!