GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ToGeant.C
Go to the documentation of this file.
1 
3 using namespace Gw;
4 
19 void toGEANT1(const Char_t *nameAGS, Int_t nbcas = 100, const Char_t *nameOUT = "toGEANT101.event")
20 {
21 
22  // load AGS file
23  BaseGEM random;
24  if ( random.InitAGS(nameAGS) == 0 ) {
25  cout << " GLS level Scheme not correctly loaded " << endl; return;
26  }
27 
28  // open a file to store the simulated events.
29  FILE *fileOUT = fopen(nameOUT,"w");
30  if ( fileOUT == NULL ) {
31  printf(" Cannot open file %s \n",nameOUT); return;
32  }
33  fprintf(fileOUT,"FORMAT 4 4 \n");
34  fprintf(fileOUT,"# \n");
35  fprintf(fileOUT,"# GAMMAS GENERATED FROM THE %s LEVEL SCHEME \n",nameAGS);
36  fprintf(fileOUT,"# \n");
37  fprintf(fileOUT,"REACTION %d %d %d %d %.1f\n", 1, 1, 6, 12, 0.0);
38  fprintf(fileOUT,"# \n");
39  fprintf(fileOUT,"EMITTED 1 1 \n");
40  fprintf(fileOUT,"# \n");
41 
42  // Open the ROOT file and creat the spectrum to be filled
43  TFile *froot = (TFile*)gROOT->GetListOfFiles()->FindObject("toGEANT101.root");
44  if ( froot == NULL ) { froot = new TFile("toGEANT101.root","UPDATE"); }
45 
46  TH1F *K = new TH1F("K","Multiplicity Distribution",100,0,100);
47  TH1F *h = new TH1F(nameAGS,"Gamma-ray spectrum",8192,0,4096);
48 
49  // start the Monte-Carlo
50  Cascade cas; GammaLink *gam;
51 
52  for (Int_t i = 0; i < nbcas; i++ ) {
53 
54  random.DoCascade(&cas); // next cascade
55 
56  K->Fill(cas.GetSize()) ;
57 
58  fprintf(fileOUT,"$ \n -101 \n ");
59 
60  for (Int_t j = 0; j < cas.GetSize(); j++ ) {
61 
62  gam = (GammaLink *)cas.At(j); h->Fill(gam->GetEnergy().Get());
63 
64  fprintf(fileOUT,"1 %.1f 0. %.1f \n ",gam->GetEnergy().Get(),8);
65  }
66  }
67 
68  // close the ROOT file
69  K->Write(); h->Write(); froot->Close();
70 
71  // close the output file
72  fprintf(fileOUT,"# \n"); fclose(fileOUT);
73 }
printf("******************************************************************** \n")
A cascade is a list of links.
Definition: Cascade.h:51
Class to get randomly cascades of gammas on the basis of a level scheme.
Definition: BaseGEM.h:107
void toGEANT1(const Char_t *nameAGS, Int_t nbcas=100, const Char_t *nameOUT="toGEANT101.event")
To produce sequences of gamma-ray energies and format them to Enrico's program.
Definition: ToGeant.C:19
virtual Data_T Get() const
get the value, can be overloaded
Definition: Data.h:70
virtual Int_t DoCascade(TSeqCollection &cascade, Option_t *opt="")
cascade simulation
Definition: BaseGEM.cpp:523
ADF::LogMessage & endl(ADF::LogMessage &log)