![]() |
|
|||
File indexing completed on 2025-02-23 09:22:10
0001 // ********************************************************************* 0002 // To execute this macro under ROOT after your simulation ended, 0003 // 1 - launch ROOT (usually type 'root' at your machine's prompt) 0004 // 2 - type '.X spectrum.C' at the ROOT session prompt 0005 // 3 - OR type directly 'root spectrum.C' 0006 // this will generate an output energy spectrum spectrum.txt, 0007 // according to selected statistics and distribution 0008 // (energy unit assumed by svalue example: eV) 0009 // ********************************************************************* 0010 0011 { 0012 gROOT->Reset(); 0013 0014 // 1) SELECT number of values to shoot 0015 int nbValues = 100; 0016 // 0017 0018 double value; 0019 TNtuple * ntuple = new TNtuple ("","","value"); 0020 0021 FILE * fp = fopen("spectrum.txt","w"); 0022 0023 TRandom r; 0024 0025 for (int i=0;i<nbValues;i++) 0026 { 0027 // 2) SELECT distribution 0028 // here Gaussian with mean, sigma 0029 // see https://root.cern.ch/doc/master/classTRandom.html 0030 value = r.Gaus(1.,0.1); 0031 // 0032 ntuple->Fill(value); 0033 fprintf(fp,"%f \n",value); 0034 } 0035 fclose(fp); 0036 0037 ntuple->Draw("value"); 0038 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |