GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OneLStoSToGS.C
Go to the documentation of this file.
1 // Macro to produce from a level scheme, random gamma-ray cascades.
2 // The Monte- Carlo could be customize through parameters.
3 // In particular one can ask the random generator (ADTy[e == 1) to produce randomly directions of emissions
4 // based on the initial, final level and the gamma-ray linking them
5 
6 // In this case the root mathmore library is mandatory to have access to wigner_3j and 6j
7 // thus root should be build with this option and then gammaware built on top
8 // in case mathmore does not exists, all gamma-rays are emitted isotropically
9 //
10 // The output is a root tree containing the Pr [Primary] branch
11 // Such a file could be used as input in SToGS
12 //
13 // usage:
14 // root -l Load.C
15 // .L OneLStoSToGS.C++
16 // OneLSWithAngularDistributions("89Y.root","89Y")
17 
18 // O. Stézowski
19 
20 #include "Spin.h"
21 #include "GammaLink.h"
22 #include "NuclearLevel.h"
23 #include "BaseGEM.h"
24 #include "Random.h"
25 
26 #include "TStopwatch.h"
27 #include "TFile.h"
28 #include "TTree.h"
29 #include "TLorentzVector.h"
30 #include "TDatabasePDG.h"
31 #include "TH1F.h"
32 
33 #include <SToGS_BaseROOTEvents.h>
34 
35 void OneLSWithAngularDistributions(const char *lsname, const char *lstitle, Int_t nbcas = 100000, const char *treefilename = "PrimariesFromGW.root")
36 {
37  // Random engine is TRandom3 based on clock ... just remove clock to have identical random sequences
38  Gw::Random::Instance()->SetCurrent("large_clock");
39 
40  TStopwatch watch;
41  watch.Start();
42 
43  // build gem, customize it through paramters and then init with a level scheme
44  Gw::BaseGEM gem;
45  gem.SetParameter("ADType",1); // it means do angular distribution for all g-rays. 0 means isotropic for all
46  //gem.SetParameter("CutLifeTime",100.0); // below cut, do angular. Up isotropic
47  gem.Import(lsname,lstitle);
48 
49  // ROOT file for output tree
50  TFile rf(treefilename,"RECREATE"); TTree *tree_primary = new TTree("GWLS_to_SToGS","Primaries from GW");
51  SBRPEvent pr_event;
52  //
53  tree_primary->Branch("Pr.",&pr_event);
54 
55  Gw::Cascade cas; TObjArray directions; Gw::GammaLink *gam; Int_t gPDG = TDatabasePDG::Instance()->GetParticle("gamma")->PdgCode();
56 
57  for (Int_t i = 0; i < nbcas; i++ ) {
58 
59  // GAMMA-rays from LS with angular distributions
60  gem.DoCascade(cas,directions);
61 
62  Double_t ESUM = 0.0, MULTTOT = 0; pr_event.Clear("");
63 
64  MULTTOT = cas.GetSize();
65  for (Int_t j = 0; j < MULTTOT; j++ ) {
66  gam = (Gw::GammaLink *)cas.At(j);
67 
68  SBRPHit *stogshit = pr_event.AddHit();
69 
70  // now copy gam content into stogshit
71  stogshit->fE = gam->GetEnergy().Get();
72  stogshit->fX = 0.; // X position
73  stogshit->fY = 0.; // Y position
74  stogshit->fZ = 0.; // Z position
75 
76  TLorentzVector *lv = (TLorentzVector *)directions.At(j);
77  stogshit->fPX = lv->X();
78  stogshit->fPY = lv->Y();
79  stogshit->fPZ = lv->Z();
80  stogshit->fT = lv->T(); //
81 
82  stogshit->fPDG = gPDG;
83  stogshit->fFlag = j;
84  stogshit->fUID = 0;
85 
86  ESUM += stogshit->fE;
87 
88  } // j
89 
90  pr_event.SetEMult(ESUM,MULTTOT);
91  tree_primary->Fill();
92  }
93 
94  tree_primary->Print();
95  tree_primary->Write();
96 
97  watch.Stop();
98  cout << "Monte-Carlo time " << endl; watch.Print();
99 }
100 
101 /* Initial function used to test BaseGEM with angular distributions
102 void TestADBaseGEM(Int_t nbcas = 100, const char *rfilename = "PrimariesFromGW.root")
103 {
104  TH1F *testE2 = new TH1F("TestE2","Test",1000,0,180);
105  TH1F *testM1 = new TH1F("TestM1","Test",1000,0,180);
106  TH1F *testISO = new TH1F("TestISO","Test",1000,-1,1);
107  //TH1F *testISO = new TH1F("TestISO","Test",1000,-180,180);
108 
109  // Random engine is TRandom3 based on clock ... just remove clock to have identical random sequences
110  Gw::Random::Instance()->SetCurrent("large_clock");
111 
112  TStopwatch watch;
113  watch.Start();
114 
115  // build gem, set level scheme
116  Gw::BaseGEM gem;
117  gem.SetParameter("ADType",1); // it means do angular distribution for all g-rays. 0 means isotropic for all
118  //gem.SetParameter("CutLifeTime",100.0); // below cut, do angular. Up isotropic
119  gem.Import("89Y.root","89Y");
120 
121  // ROOT file for output tree
122  TFile rf(rfilename,"RECREATE"); TTree *tree_primary = new TTree("GWLS_to_SToGS","Primaries from GW");
123  SBRPEvent pr_event;
124  //
125  tree_primary->Branch("Pr.",&pr_event);
126 
127  Gw::Cascade cas; TObjArray directions; Gw::GammaLink *gam; Int_t gPDG = TDatabasePDG::Instance()->GetParticle("gamma")->PdgCode();
128 
129  for (Int_t i = 0; i < nbcas; i++ ) {
130 
131  // GAMMA-rays from LS with angular distributions
132  gem.DoCascade(cas,directions);
133 
134  Double_t ESUM = 0.0, MULTTOT = 0; pr_event.Clear("");
135 
136  MULTTOT = cas.GetSize();
137  for (Int_t j = 0; j < MULTTOT; j++ ) {
138  gam = (Gw::GammaLink *)cas.At(j);
139 
140  SBRPHit *stogshit = pr_event.AddHit();
141 
142  // now copy gam content into stogshit
143  stogshit->fE = gam->GetEnergy().Get();
144  stogshit->fX = 0.; // X position
145  stogshit->fY = 0.; // Y position
146  stogshit->fZ = 0.; // Z position
147 
148  TLorentzVector *lv = (TLorentzVector *)directions.At(j);
149  stogshit->fPX = lv->X();
150  stogshit->fPY = lv->Y();
151  stogshit->fPZ = lv->Z();
152  stogshit->fT = lv->T(); //
153 
154  stogshit->fPDG = gPDG;
155  stogshit->fFlag = j;
156  stogshit->fUID = 0;
157 
158  // hegamma->Fill(stogshit->fE);
159  ESUM += stogshit->fE;
160 
161  if (stogshit->fE >1743 && stogshit->fE < 1745 ) {
162  testE2->Fill(lv->Theta()*180./TMath::Pi());
163  }
164  if (stogshit->fE >1506 && stogshit->fE < 1508 ) {
165  testM1->Fill(lv->Theta()*180./TMath::Pi());
166  }
167  //if (stogshit->fE >4014 && stogshit->fE < 4016 ) {
168  if (stogshit->fE >908 && stogshit->fE < 910 ) {
169  //testISO->Fill(lv->Theta()*180./TMath::Pi());
170  testISO->Fill(TMath::Cos(lv->Theta()) );
171  //testISO->Fill(TMath::Cos(lv->Theta()) );
172 
173  //testISO->Fill(lv->Phi()*180./TMath::Pi());
174  }
175 
176  } // j
177 
178  pr_event.SetEMult(ESUM,MULTTOT);
179  tree_primary->Fill();
180  }
181 
182  tree_primary->Print();
183  tree_primary->Write();
184 
185  watch.Stop();
186  cout << "Monte-Carlo time " << endl; watch.Print();
187 
188 }
189 */
190 
191 
192 
193 
194 
195 
A cascade is a list of links.
Definition: Cascade.h:51
SToGS Base Root Polarized Hit.
Double32_t fZ
Double32_t fE
Double32_t fPZ
SBRPHit * AddHit()
add a hit to the current event
Class to get randomly cascades of gammas on the basis of a level scheme.
Definition: BaseGEM.h:107
Double32_t fX
header file for a NuclearLevel
Double32_t fPX
Double32_t fT
virtual Data_T Get() const
get the value, can be overloaded
Definition: Data.h:70
Double32_t fPY
header file for Random
virtual void Clear(Option_t *opt)
clear the collection of hits, set H, K to 0
virtual Int_t DoCascade(TSeqCollection &cascade, Option_t *opt="")
cascade simulation
Definition: BaseGEM.cpp:523
ADF::LogMessage & endl(ADF::LogMessage &log)
void OneLSWithAngularDistributions(const char *lsname, const char *lstitle, Int_t nbcas=100000, const char *treefilename="PrimariesFromGW.root")
Definition: OneLStoSToGS.C:35
static Random * Instance()
to access the unique instance
Definition: Random.cpp:69
virtual Int_t Import(const Char_t *, Option_t *opt="152DY")
Load the level scheme and init the Monte-Carlo.
Definition: BaseGEM.cpp:194
Bool_t SetParameter(const char *name, Int_t value)
to set some parameters that modify the way the simulation is performed. return false is the parameter...
Definition: BaseGEM.cpp:227
void SetEMult(Double_t h, Int_t k)
void SetCurrent(const char *name="basic")
to set the current TRandomom object
Definition: Random.cpp:75
header file for a BaseGEM (gamma-rays generator)
header file for a spin quantum number
Double32_t fY