Message: Re: Geant4 simulation to obtain NaI spectrum (counts vs energy deposited) Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Geant4 simulation to obtain NaI spectrum (counts vs energy deposited)  

Forum: Biasing and Scoring
Re: Question Geant4 simulation to obtain NaI spectrum (counts vs energy deposited) (Sanchit Sharma)
Re: None Re: Geant4 simulation to obtain NaI spectrum (counts vs energy deposited) (Tsukasa Aso)
Re: None Re: Geant4 simulation to obtain NaI spectrum (counts vs energy deposited) (Sanchit Sharma)
Date: Mar 07, 02:10
From: Tsukasa Aso <Tsukasa Aso>

Hi,

   The command-line scorers were developed to accumulate physical quantities during a RUN.
And, it is specially developed for a segmented geometry.

  On the other hand, the energy spectrum needs deposited energy in one EVENT which corresponds to
a simulation of one primary particle (i.e. one decay).  
To do so, you are required to develop user's code, however, I hope that following example codes help your application development.

   I think you are using the command-line scorer. 
  For example, the commands will be like as follows.

  /score/create/boxMesh BM              <== Mesh name
  /score/mesh/boxSize 40. 40. 40. cm
  /score/mesh/nBin 1 1 1               <=== I assumed the mesh is a bulk w/o segmentation.
  /score/quantity/energyDeposit eDep  <== Primitive scorer's name
  /score/close

   Usually, above commands are for accumulating energy deposit "eDep"  in the boxMesh "BM" in the RUN,

   If you want to get energy spectrum, you need to access the result in every EVENT.

   As an example, I prepared following three files, which are attached in this messeage.
   These codes work with the command-line scorers.
       MyAnalysis.hh      for using analysis-manager
       MyRun.hh ,  MyRun.cc   for accessing the energy deposit in every event, and store it into 1D histogram.

I described about the codes for introducing these files to your application.
Here I assumed above commands for command-line scorer. 
i.e. the name of Mesh and Primitive scorer  are   "BM" and "eDep" .

0) Copy these files to your source directory.

1) The class MyRun have to be instantiated in your  RunAction.
      MyRun needs to be instantiated in GenerateRun() method with the Mesh name 
     that will be specified with a command-line scorer.

     (MyRunAction.cc)

      G4Run*  MyRunAction::GenerateRun(){
           return   new MyRun("BM");    <== "BM" should be same as the Mesh name in the command-line scorer.
      }

2) Modify the definition of histogram according to your needs. (OpenHistogram() method in MyRun.cc)
      
   void MyRun::OpenHistogram(){
         auto analysisManager = G4AnalysisManager::Instance();
        //                                                                            
        // Creating H1                                                                
         analysisManager->CreateH1("eDep","eDep", 100,0., 2.*MeV);   <== See below.
       //
       G4String fileName = "Output";       <== Output file name.
       analysisManager->OpenFile(fileName);
       //                                                                            
}

  Arguments in CreateH1
     1st:   Primitive scorer name
     2nd:  Title of output
     3rd:    Number of bin of histogram
     4th:   Lower edge of histogram
    5th:    Upper edge of histogram

  (Note)
    - The histogram is filled in MyRunAction::FillHistogram() method. 
    - The mesh is assumed to be a bulk (w/o segmentation).
    - Also, you can create more 1D histograms.

3) Cmake, make and Run
      The output file is "Output_h1_eDep.csv" in this case, 
      which includes the energy spectrum ( 0 MeV - 2 MeV  w/ 100 bins in the example. )
 
 ** I just developed it as an example code, so that the result should be checked by yours.

Best regards,


   Attachment:
      http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2019/03/07/02.02-25769-MyAnalysis.hh
      http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2019/03/07/02.02-36887-MyRun.hh
      http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2019/03/07/02.02-1266-MyRun.cc

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

1 None: Re: Geant4 simulation to obtain NaI spectrum (counts vs energy deposited)   (Sanchit Sharma - Mar 07, 14:11)
 Add Message Add Message
to: "Re: Geant4 simulation to obtain NaI spectrum (counts vs energy deposited) "

 Subscribe Subscribe

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