GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
firstdemo.C
Go to the documentation of this file.
1 
19 #ifndef __CINT__
20 #include <Link.h>
21 #include <XGammaLink.h>
22 
23 #include <TStopwatch.h>
24 #include <TH1.h>
25 #include <TTree.h>
26 
27 #include <iostream>
28 using namespace std;
29 #endif
30 
31 using namespace Gw;
32 
42 void CheckLS(const Char_t *name = "197Pb.ags")
43 {
44  LevelScheme *lev = new LevelScheme;
45  if ( lev->InitAGS(name) != 0 ) lev->Draw();
46 }
47 
57 void CheckX(const Char_t *name = "simu2.ags")
58 {
59  GammaLink *link;
60 
61  LevelScheme lev(name,"ags");
62  if ( lev.GetLinks().GetSize() == 0 ) { printf("No links in %s \n",name); }
63 
64  TIter iter(&lev.GetLinks()); // start an iterator on the list of links
65 
66  Int_t count = 0;
67  while ( link = (GammaLink *)iter() ) { // next link
68  if ( link->InheritsFrom("XGammaLink") ) count++;
69  }
70  printf("%d x-links found in %s \n",count,name);
71 }
72 
82 void CGate(TH1 *spgated, Cascade *cas, Int_t g1, Int_t g2)
83 {
84  Int_t i, iend, nb_in, flag[200];
85 
86  iend = cas->GetSize(); nb_in = 0;
87  for (i = 0; i < iend; i++ ) { // count how many gammas in the gate [g1,g2]
88 
89  flag[i] = 0;
90 
91  gam = (GammaLink *)cas->At(i);
92  if ( gam->GetEnergy().Get() > g1 && gam->GetEnergy().Get() < g2 ) { nb_in++; flag[i] = 1; }
93  } // i
94  if ( nb_in == 0 ) return; // no gammas in the gate
95  if ( nb_in == 1 ) { // keep only gammas outside the gate
96  for (i = 0; i < iend; i++ ) {
97  gam = (GammaLink *)cas->At(i);
98  if ( flag[i] == 0 ) spgated->Fill(gam->GetEnergy().Get());
99  } // i
100  } else { // keep all gammas
101  for (i = 0; i < iend; i++ ) {
102  gam = (GammaLink *)cas->At(i); spgated->Fill(gam->GetEnergy().Get());
103  } // i
104  }
105 }
106 
124 void simu1(Int_t nbcas = 100)
125 {
126  // name of the gls file and definition of the gate
127  const Char_t nameAGS[] = "simu2.ags";
128  Float_t gl1 = 572, gr1 = 574, gl2 = 656, gr2 = 657;
129 
130  // load AGS file
131  BaseGEM random;
132  if ( random.InitAGS(nameAGS) == 0 ) {
133  cout << " GLS level Scheme not correctly loaded " << endl; return;
134  }
135 
136  // some spectra to be filled
137  TH1F *K = new TH1F("K","K",100,0,100);
138  TH1F *h = new TH1F("ProjTot","ProjTot",8192,0,4096);
139  TH1F *hg1 = new TH1F("Gated1","Gated1",8192,0,4096); TH1F *hg2 = new TH1F("Gated2","Gated2",8192,0,4096);
140 
141  // start the Monte-Carlo
142  Cascade cas; GammaLink *gam;
143  for (Int_t i = 0; i < nbcas; i++ ) {
144 
145  random.DoCascade(cas,""); // to get the next cascade
146 
147  K->Fill(cas.GetSize()) ;
148  for (Int_t j = 0; j < cas.GetSize(); j++ ) { // to set the total projection
149  gam = (GammaLink *)cas.At(j); h->Fill(gam->GetEnergy().Get());
150  }
151  CGate(hg1,&cas,gl1,gr1); CGate(hg2,&cas,gl2,gr2);
152  }
153  hg1->Draw();
154 }
155 
174 void oneLS(const Char_t *nameAGS, Int_t nbcas = 100)
175 {
176  // load the AGS file
177  BaseGEM random;
178  if ( random.InitAGS(nameAGS) == 0 ) {
179  cout << " AGS level Scheme not correctly loaded " << endl; return;
180  }
181 
182  // some spectra to be filled
183  TH1F *K = new TH1F("K","K",100,0,100);
184  TH1F *h = new TH1F("ProjTot","ProjTot",8192,0,4096);
185 
186  // start the Monte-Carlo
187  Cascade cas; GammaLink *gam;
188  for (Int_t i = 0; i < nbcas; i++ ) {
189 
190  random.DoCascade(&cas,"");
191 
192  K->Fill(cas.GetSize()) ;
193  for (Int_t j = 0; j < cas.GetSize(); j++ ) {
194  gam = (GammaLink *)cas.At(j); h->Fill(gam->GetEnergy().Get());
195  } // j
196  } //i
197  h->Draw();
198 }
199 
226 void twoLS(Int_t nbcas = 100)
227 {
228  // load the two AGS file
229  BaseGEM pb197, pb198;
230  if ( pb197.InitAGS("197Pb.ags") == 0 ) {
231  cout << " 197Pb.ags level Scheme not correctly loaded " << endl; return;
232  }
233  if ( pb198.InitAGS("198Pb.ags") == 0 ) {
234  cout << " 198Pb.ags level Scheme not correctly loaded " << endl; return;
235  }
236  // create the RandObj to select between 197Pb 90 % & 198Pb 10 %
237  RandObj channel;
238  channel.Add(&pb197,0.9);channel.Add(&pb198,0.1);
239 
240  // some spectra to be filled
241  TH1F *hpb197 = new TH1F("Pb197","Pb197",8192,0,4096); hpb197->SetLineColor(2);
242  TH1F *hpb198 = new TH1F("Pb198","Pb198",8192,0,4096); hpb198->SetLineColor(4);
243 
244  // start the Monte-Carlo
245  Cascade cas; BaseGEM *gem; GammaLink *gam;
246  for (Int_t i = 0; i < nbcas; i++ ) {
247 
248  gem = (BaseGEM *)channel.Rand(); // select one nucleus
249  gem->DoCascade(&cas); // determine a cascade on this nucleus
250 
251  if ( gem == &pb197 ) {
252  for (Int_t j = 0; j < cas.GetSize(); j++ ) {
253  gam = (GammaLink *)cas.At(j); hpb197->Fill(gam->GetEnergy().Get());
254  } // j
255  } else {
256  for (Int_t j = 0; j < cas.GetSize(); j++ ) {
257  gam = (GammaLink *)cas.At(j); hpb198->Fill(gam->GetEnergy().Get());
258  } // j
259  } // gem
260  } //i
261  hpb197->Draw(); hpb198->Draw("same");
262 }
263 
270 void showIE(Int_t nbcas = 100)
271 {
272  // name of the gls file and definition of the gate
273  const Char_t nameAGS[] = "197Pb.ags";
274  Float_t spin_min = 0, spin_max = 50, e_min = 0, e_max = 10000;
275 
276  // load AGS file
277  BaseGEM random;
278  if ( random.InitAGS(nameAGS) == 0 ) {
279  cout << nameAGS << " level Scheme not correctly loaded " << endl; return;
280  }
281 
282  // to display the entry point
283  TH2F *bidim = new TH2F("I*E","I*E",50,spin_min,spin_max,100,e_min,e_max);
284 
285  // start the Monte-Carlo
286  Cascade li_gamma;
287  GammaLink *gam; NuclearLevel *levi;
288 
289  Float_t max_e, spin;
290  for (Int_t i = 0; i < nbcas; i++ ) {
291 
292  random.DoCascade(&li_gamma);
293 
294  max_e = 0;
295  for (Int_t j = 0; j < li_gamma.GetSize(); j++ ) { // loop on links to fin the highest level
296  gam = (GammaLink *)li_gamma.At(j);
297  levi = (NuclearLevel *)gam->GetIL();
298  if ( levi->GetEnergy().Get() > max_e && levi->GetSpin().Get() > 0 ) {
299  max_e = levi->GetEnergy().Get();
300  spin = levi->GetSpin().Get();
301  }
302  }
303  bidim->Fill(spin,max_e);
304  }
305  bidim->Draw();
306 }
307 
323 void simu1BG(Int_t nbcas = 100000)
324 {
325  // name of the gls file and definition of the gate
326  const Char_t nameAGS[] = "simu1.ags";
327 
328  // load AGS file
329  BaseGEM random;
330  if ( random.InitAGS(nameAGS) == 0 ) {
331  cout << " GLS level Scheme not correctly loaded " << endl; return;
332  }
333  // create the function for the background
334  TF1 bg("background","100-100*x/4096",0,4096);
335 
336  // create the RandObj to select between sim1.ags and bg
337  RandObj channel;
338  channel.Add(&random,0.001);channel.Add(&bg,0.999);
339 
340  // some spectra to be filled
341  TH1F *h = new TH1F("ProjTot","ProjTot",8192,0,4096);
342 
343  // start the Monte-Carlo
344  TObject *obj; BaseGEM *gem; GammaLink *gam;
345 
346  Cascade cas; Int_t which_channel;
347  for (Int_t i = 0; i < nbcas; i++ ) {
348 
349  obj = channel.Rand(which_channel); // channel selection
350 
351  if ( which_channel == 0 ) { // level scheme
352 
353  random.DoCascade(&cas); // to get the next cascade
354 
355  for (Int_t j = 0; j < cas.GetSize(); j++ ) { // to set the total projection
356  gam = (GammaLink *)cas.At(j); h->Fill(gam->GetEnergy().Get());
357  } // j
358  }
359  else { // background
360  h->Fill(bg.GetRandom(1,4096));
361  }
362  }
363  h->Draw();
364 }
365 
385 void simu1X(Int_t nbcas = 100000)
386 {
387  TObject *obj; XGammaLink *xlink;
388 
389  // name of the gls file and definition of the gate
390  const Char_t nameAGS[] = "simu2.ags";
391  const Int_t nbx = 2;
392  Float_t xe[nbx] = { 80, 82 }; Float_t xi[nbx] = { 80, 20 };
393 
394  // load the AGS file
395  BaseGEM random;
396  if ( random.InitAGS(nameAGS) == 0 ) {
397  cout << " GLS level Scheme not correctly loaded " << endl; return;
398  }
399 
400  // start an iterator on the list of links to find out a XGammaLink
401  TIter iter(&random.GetLS().GetLinks());
402  while ( obj = iter() ) {
403  if ( obj->InheritsFrom("XGammaLink") ) {
404  xlink = (XGammaLink *)obj; xlink->SetX(nbx,xe,xi);
405  }
406  }
407 
408  // some spectra to be filled
409  TH1F *h = new TH1F("ProjTot","ProjTot",8192,0,4096);
410 
411  // start the Monte-Carlo
412  Cascade cas; GammaLink *gam;
413  for (Int_t i = 0; i < nbcas; i++ ) {
414 
415  random.DoCascade(&cas); // to get the next cascade
416 
417  for (Int_t j = 0; j < cas.GetSize(); j++ ) { // to set the total projection
418  gam = (GammaLink *)cas.At(j); h->Fill(gam->GetEnergy().Get());
419  }
420  }
421  h->Draw();
422 }
423 
A level Scheme.
Definition: LevelScheme.h:82
virtual TObject * Rand()
it returns a pointer to a randomly selected object from the collection
Definition: RandObj.cpp:93
void simu1(Int_t nbcas=100)
Function to test BaseGEM.
Definition: firstdemo.C:124
printf("******************************************************************** \n")
A cascade is a list of links.
Definition: Cascade.h:51
virtual Int_t InitAGS(const Char_t *filename, Option_t *opt="152Dy")
BETTER TO USE Import - To init this level scheme with a Radford AGS file.
virtual void Draw(Option_t *opt="")
to draw this level scheme
Class to get randomly cascades of gammas on the basis of a level scheme.
Definition: BaseGEM.h:107
A nuclear level.
Definition: NuclearLevel.h:66
Float_t Get() const
To get the spin as a float.
Definition: Spin.h:166
A class to select randomly an object in a TObjArray of objects.
Definition: RandObj.h:55
void simu1X(Int_t nbcas=100000)
Same as simu1() but X-rays are added to the converted 417 keV.
Definition: firstdemo.C:385
const TList & GetLinks()
to get the list of links
Definition: LevelScheme.h:295
void CGate(TH1 *spgated, Cascade *cas, Int_t g1, Int_t g2)
Function to gate on a cascade.
Definition: firstdemo.C:82
void simu1BG(Int_t nbcas=100000)
Same as simu1() but with another source of gamma-ray that produces a continuous background.
Definition: firstdemo.C:323
void CheckX(const Char_t *name="simu2.ags")
function to check if a AGS file is correctly read by looking for XGammaLink
Definition: firstdemo.C:57
virtual Data_T Get() const
get the value, can be overloaded
Definition: Data.h:70
Measure< Float_t > & GetEnergy()
Definition: NuclearLevel.h:91
virtual void Add(TObject *, Float_t)
it adds an object with a weight to this collection.
Definition: RandObj.cpp:49
void CheckLS(const Char_t *name="197Pb.ags")
function to check if a AGS file is correctly read by drawing it
Definition: firstdemo.C:42
const LevelScheme * GetLS() const
To set the intensity of the lowest link of the level scheme.
Definition: BaseGEM.h:175
virtual void Draw(Option_t *opt="")
Definition: Cascade.cpp:116
virtual Int_t DoCascade(TSeqCollection &cascade, Option_t *opt="")
cascade simulation
Definition: BaseGEM.cpp:523
ADF::LogMessage & endl(ADF::LogMessage &log)
void twoLS(Int_t nbcas=100)
Function to make a Monte Carlo on two AGS files.
Definition: firstdemo.C:226
void showIE(Int_t nbcas=100)
Function to display the entry point distribution in a (spin,excitation energy) plan.
Definition: firstdemo.C:270
Spin & GetSpin()
to get the spin and modify it if it is needed
Definition: NuclearLevel.h:84
void oneLS(const Char_t *nameAGS, Int_t nbcas=100)
Function to make a monte carlo on any AGS file.
Definition: firstdemo.C:174