Message: Can I fill histograms with energy deposit per event using EndOfEvent() method of G4VSensitiveDetector? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Can I fill histograms with energy deposit per event using EndOfEvent() method of G4VSensitiveDetector? 

Forum: Hits, Digitization and Pileup
Date: 07 Jun, 2007
From: Victor_Makarov <Victor_Makarov>

I have a sensitive detector. It calculates energy deposition per event and prints it out by means of the current block of EndofEvent method:

G4double totE = 0;
    G4int NbHits = trackerCollection->entries();
	for(int i=0;i<NbHits;i++)
    { totE += (*trackerCollection)[i]->GetEdep(); }
    G4cout << "     Total energy deposition in NaI : "
         << totE / MeV << " (MeV)" << G4endl;
....

It is printed out very well in my output. But I would also like to fill a histogram with that info. I think I should use something like

#ifdef G4ANALYSIS_USE
  Run->GetHisto(0)->fill(totE/MeV);
#endif

after the previous block.

I've already created a blank histogram in RunAction and an empty aida file is outputted. It's ok!

In an example (extended-Em4) I saw how things are connected in EventAction when energy deposition of every event with no SD is sent to histogram:

1) EventAction::EventAction(RunAction* run)

:Run(run),drawFlag("none"),printModulo(10000),eventMessenger(NULL)
2) Run->GetHisto(0)->fill(TotalEnergyDeposit/MeV);

In a similar way I think I should modify my sensitive detector constructor But I'm not very strong in C++ programming and don't know what to modify. My SD constructor is:

TrackerSD::TrackerSD(G4String name)
:G4VSensitiveDetector(name)
{
  G4String HCname;
  collectionName.insert(HCname="trackerCollection");
}

Any idea how to modify it? Thanks.

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

1 None: RE: Can I fill histograms with energy deposit per event using EndOfEvent() method of G4VSensitiveDetector?   (Makoto Asai - 07 Jun, 2007)
1 None: RE: Can I fill histograms with energy deposit per event using EndOfEvent() method of G4VSensitiveDetector?   (Victor - 08 Jun, 2007)
(_ None: RE: Can I fill histograms with energy deposit per event using EndOfEvent() method of G4VSensitiveDetector?   (Makoto Asai - 08 Jun, 2007)
(_ None: RE: Can I fill histograms with energy deposit per event using EndOfEvent() method of G4VSensitiveDetector?   (Victor - 09 Jun, 2007)
2 None: Re: Can I fill histograms with energy deposit per event using EndOfEvent() method of G4VSensitiveDetector?   (Vladimir IVANTCHENKO - 08 Jun, 2007)
 Add Message Add Message
to: "Can I fill histograms with energy deposit per event using EndOfEvent() method of G4VSensitiveDetector?"

 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 ]