KaliVeda
Toolkit for HIC analysis
KVElasticScatter.cpp
1 /*
2 $Id: KVElasticScatter.cpp,v 1.9 2007/04/04 10:39:17 ebonnet Exp $
3 $Revision: 1.9 $
4 $Date: 2007/04/04 10:39:17 $
5 */
6 
7 //Created by KVClassFactory on Thu Oct 19 22:31:02 2006
8 //Author: John Frankland
9 
10 #include "KVElasticScatter.h"
11 #include "KVMultiDetArray.h"
12 #include "TH1F.h"
13 #include "KVDetector.h"
14 #include "KVGroup.h"
15 #include "KVTarget.h"
16 #include "KV2Body.h"
17 #include "TObjArray.h"
18 
19 using namespace std;
20 
22 
23 
24 
27 KVElasticScatter::KVElasticScatter(): fBeamDirection(0, 0, 1)
28 {
29  //Default constructor
30  fDepth = 0;
31  fTheta = 0;
32  fBinE = 500;
33  fEnergy = 0;
34  fKinematics = 0;
35  fTarget = 0;
36  fIntLayer = fNDets = 0;
37  fDetector = 0;
38  fMultiLayer = kFALSE;
39  fExx = 0.;
40  fHistos = 0;
41  has_outgoing = false;
42  if (gMultiDetArray) {
43  gMultiDetArray->SetSimMode(kTRUE);
44  }
45  else {
46  Warning("KVElasticScatter", "gMultiDetArray does not refer to a valid multidetector array");
47  printf("Define it before using this class, and put it in simulation mode : gMultiDetArray->SetSimMode(kTRUE)");
48  }
49 }
50 
51 
52 
53 
56 
57 KVElasticScatter::~KVElasticScatter()
58 {
59  //Destructor
60  if (fDepth)
61  delete fDepth;
62  if (fTheta)
63  delete fTheta;
64  if (fKinematics)
65  delete fKinematics;
66  if (fHistos)
67  delete fHistos;
68  gMultiDetArray->SetSimMode(kFALSE);
69 }
70 
71 
72 
73 
76 
78 {
79  //Set detector parameters, target, etc. for run
80  gMultiDetArray->SetParameters(run);
81  fTarget = gMultiDetArray->GetTarget();
82  fTarget->SetRandomized();
83  fIntLayer = 0;
84  fMultiLayer = (fTarget->NumberOfLayers() > 1);
85 }
86 
87 
88 
89 
92 
94 {
95  //Set projectile Z and A
96 
97  fProj.SetZandA(Z, A);
98 }
99 
100 
101 
102 
105 
107 {
108  //Set energy of projectile in MeV
109 
110  fProj.SetEnergy(e);
111  fEnergy = e;
112 }
113 
114 
115 
116 
123 
125 {
126  // Give name of detector towards which elastic scattering will occur.
127  //
128  // \note this does not necessarily mean that the particle will actually
129  // arrive in the given detector (it may stop before it), but the aim is to
130  // define the trajectory of the particle in the array.
131 
132  fDetector = gMultiDetArray->GetDetector(det);
133  if (!fDetector) {
134  Error("SetDetector", "Detector %s is unknown!", det);
135  return;
136  }
137  // get trajectory for detector
138  if (fDetector->GetNode()->GetNTraj()>1)
139  {
140  Warning("SetDetector", "Ambiguous trajectory choice: detector %s has %d trajectories", det, fDetector->GetNode()->GetNTraj());
141  }
142  auto traj = (KVGeoDNTrajectory*)fDetector->GetNode()->GetTrajectories()->First();
143  Info("SetDetector", "Using trajectory: %s", traj->GetName());
144 
145  //we store the association between detector type and index in list
146  fDetInd.Clear();
147  fAlignedDetectors.Clear();
148 
149  traj->IterateBackFrom();
150 
151  Int_t i = 0;
152  KVGeoDetectorNode* gdn = nullptr;
153  while ((gdn = traj->GetNextNode()))
154  {
155  KVDetector* d = gdn->GetDetector();
156  fAlignedDetectors.Add(d);
157  fDetInd.SetValue(d->GetLabel(), i);
158  ++i;
159  }
160  //store number of aligned detectors
161  fNDets = i;
162 }
163 
164 
165 
166 
172 
174 {
175  //For multilayer targets, use this method to choose in which
176  //layer the scattering will take place.
177  //If name="", reset any previous choice so that scattering
178  //can take place in any layer
179  if (!fTarget) {
180  cout <<
181  "<KVElasticScatter::SetTargetScatteringLayer> : No target set. Set run first."
182  << endl;
183  return;
184  }
185  fIntLayer = fTarget->GetLayerIndex(name);
186  if (fIntLayer)
187  fTarget->SetInteractionLayer(fIntLayer, fBeamDirection);
188 }
189 
190 
191 
192 
196 
198 {
199  //Set binning of the GetEnergy histogram
200  // Default value is 500
201  fBinE = nbins;
202 }
203 
204 
205 
209 
211 {
212  //Perform scattering 'N' times for current values
213  //of particle Z, A and energy, target excited state, and detector.
214 
215  if (!fProj.IsDefined()) {
216  cout <<
217  "<KVElasticScatter::CalculateScattering> : Set projectile properties first"
218  << endl;
219  return;
220  }
221  if (!fEnergy) {
222  cout <<
223  "<KVElasticScatter::CalculateScattering> : Set projectile energy first"
224  << endl;
225  return;
226  }
227  if (!fDetector) {
228  cout <<
229  "<KVElasticScatter::CalculateScattering> : Set detector first" <<
230  endl;
231  return;
232  }
233  if (!fTarget) {
234  cout <<
235  "<KVElasticScatter::CalculateScattering> : No target set. Set run first."
236  << endl;
237  return;
238  }
239 
240  /* -------------------------------------------------------------------------------------------------------------------------- */
241 
242  //set up histograms
243 
244  /* -------------------------------------------------------------------------------------------------------------------------- */
245 
246  // -- histograms for debugging: depth in target and angular distribution
247  if (fDepth)
248  delete fDepth;
249  if (fTheta)
250  delete fTheta;
251  fDepth =
252  new TH1F("hDepth", "Depth (mg/cm2)", 500, 0.,
253  fTarget->GetTotalEffectiveThickness());
254  fTheta = new TH1F("hTheta", "Theta (deg.)", 500, 0., 0.);
255 
256  /* -------------------------------------------------------------------------------------------------------------------------- */
257 
258  //set up histograms for all detectors particle passes through
259  if (!fHistos) {
260  fHistos = new TObjArray(fAlignedDetectors.GetSize());
261  fHistos->SetOwner(); //will delete histos it stores
262  }
263  else {
264  fHistos->Clear(); //delete any previous histograms
265  }
266  KVDetector* d;
267  TIter n(&fAlignedDetectors);
268  while ((d = (KVDetector*) n())) {
269  fHistos->
270  Add(new
271  TH1F(Form("hEloss_%s", d->GetName()), "Eloss (MeV)", fBinE, 0., 0.));
272  }
273 
274  /* -------------------------------------------------------------------------------------------------------------------------- */
275 
276  //set up kinematics
277  if (!fKinematics)
278  fKinematics = new KV2Body;
279  fProj.SetEnergy(fEnergy);
280  fProj.SetTheta(0);
281 
282  /* -------------------------------------------------------------------------------------------------------------------------- */
283 
284  //set random interaction point for scattering
285  if (fIntLayer) {
286  fTarget->SetInteractionLayer(fIntLayer, fBeamDirection);
287  }
288  else {
289  fTarget->GetInteractionPoint(&fProj);
290  }
291 
292  /* -------------------------------------------------------------------------------------------------------------------------- */
293 
294  //get target nucleus properties from scattering layer
295  TVector3 IP = fTarget->GetInteractionPoint();
296  KVMaterial* targ_mat = fTarget->GetLayer(IP);
297  KVNucleus t;
298  t.SetZ((Int_t) targ_mat->GetZ());
299  t.SetA((Int_t) targ_mat->GetMass());
300  fKinematics->SetTarget(t);
301 
302  /* -------------------------------------------------------------------------------------------------------------------------- */
303 
304  //set excited state of target nucleus - in other words, dissipated energy for
305  //reaction due to excitation of target
306  // check order !!!
307  fKinematics->SetEDiss(fExx);
308 
309  /* -------------------------------------------------------------------------------------------------------------------------- */
310 
311  Double_t xsec;
312  for (int i = 0; i < N; i++) {
313  //calculate slowing of incoming projectile
314  fTarget->SetIncoming();
315  fTarget->DetectParticle(&fProj);
316  fKinematics->SetProjectile(fProj);
317  if (!has_outgoing) fOutgoing = fProj;
318 
319  fKinematics->SetOutgoing(fOutgoing);
320 // else fKinematics->SetOutgoing(fProj);
321  fKinematics->CalculateKinematics();
322  //set random direction of outgoing projectile
323 
324  double th, ph;
325  th = ph = 0.;
326  fDetector->GetRandomAngles(th, ph);
327 
328  //set energy of scattered nucleus
329  //WARNING: for inverse kinematics reactions, their are two energies for
330  //each angle below the maximum scattering angle.
331  //We only use the highest energy corresponding to the most forward CM angle.
332  Double_t e1, e2;
333  fKinematics->GetELab(3, th, 3, e1, e2);
334  fOutgoing.SetEnergy(TMath::Max(e1, e2));
335  fOutgoing.SetTheta(th);
336  fOutgoing.SetPhi(ph);
337  xsec = TMath::Abs(fKinematics->GetXSecRuthLab(fOutgoing.GetTheta()));
338  fTheta->Fill(fOutgoing.GetTheta(), xsec);
339  //slowing of outgoing projectile in target
340  fTarget->SetOutgoing();
341 // fTarget->DetectParticle(&fProj);
342  fTarget->DetectParticle(&fOutgoing);
343  fDepth->Fill(IP.z());
344 
345  //now detect particle in detector(s)
346  int j = 0;
347  n.Reset();
348  while ((d = (KVDetector*) n())) {
349  auto cew = d->GetCentreOfEntranceWindow();
350  d->DetectParticle(&fOutgoing, &cew);
351  //fill histograms
352  ((TH1F*)(*fHistos)[j++])->Fill(d->GetEnergy(), xsec);
353  //prepare for next round: set energy loss to zero
354  d->Clear();
355  }
356  fProj.SetEnergy(fEnergy);
357  fProj.SetTheta(0);
358  fProj.GetParameters()->Clear();
359  fOutgoing.GetParameters()->Clear();
360  //set random interaction point for scattering
361  if (fIntLayer) {
362  fTarget->SetInteractionLayer(fIntLayer, fBeamDirection);
363  }
364  else {
365  fTarget->GetInteractionPoint(&fProj);
366  //if target is multilayer and the interaction layer is not fixed,
367  //the layer & hence the target nucleus may change
368  if (fMultiLayer) {
369  targ_mat = fTarget->GetLayer(fTarget->GetInteractionPoint());
370  KVNucleus t;
371  t.SetZandA((Int_t) targ_mat->GetZ(), (Int_t) targ_mat->GetMass());
372  fKinematics->SetTarget(t);
373  }
374  }
375  IP = fTarget->GetInteractionPoint();
376  }
377 }
378 
379 
380 
381 
382 
388 
390 {
391  //Energy loss in detector of given 'type' through which scattered particle passes.
392  //Warning: if there are several detectors of the same type in the list of detectors
393  //through which the particle passes, the first one (as seen by the impinging
394  //particle) will have type "type", the second "type_1", the third "type_2", etc.
395 
396  return (fDetInd.HasParameter(type) ? GetEnergy(fDetInd.GetIntValue(type)) : 0);
397 }
398 
399 
400 
401 
407 
409 {
410  //Energy loss in any detector through which scattered particle passes.
411  //The index corresponds to the order in which detectors are crossed by the
412  //particle, beginning with 0 for the first detector, and ending with
413  //(GetNDets()-1)
414  return (TH1F*)(*fHistos)[index];
415 }
416 
417 
418 //__________________________________________________________________//
419 
int Int_t
#define d(i)
#define e(i)
char Char_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
#define N
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
char * Form(const char *fmt,...)
Relativistic binary kinematics calculator.
Definition: KV2Body.h:166
Calculate elastic scattering spectra in multidetector arrays.
void SetDetector(const Char_t *det)
TH1F * GetEnergy()
Return pointer to energy loss histogram for chosen detector (in MeV)
void CalculateScattering(Int_t N)
void SetEbinning(Int_t nbins=500)
void SetProjectile(Int_t Z, Int_t A)
Set projectile Z and A.
void SetRun(Int_t run)
Set detector parameters, target, etc. for run.
void SetTargetScatteringLayer(const Char_t *name)
void SetEnergy(Double_t E)
Set energy of projectile in MeV.
Path taken by particles through multidetector geometry.
Information on relative positions of detectors & particle trajectories.
KVDetector * GetDetector() const
virtual KVDetector * GetDetector(const Char_t *name) const
Return detector in this structure with given name.
Description of physical materials used to construct detectors & targets; interface to range tables.
Definition: KVMaterial.h:89
Double_t GetZ() const
Definition: KVMaterial.cpp:390
Double_t GetMass() const
Definition: KVMaterial.cpp:302
KVTarget * GetTarget()
virtual void SetParameters(UInt_t n, Bool_t physics_parameters_only=kFALSE)
virtual void SetSimMode(Bool_t on=kTRUE)
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:123
void SetA(Int_t a)
Definition: KVNucleus.cpp:647
void SetZ(Int_t z, Char_t mt=-1)
Definition: KVNucleus.cpp:696
void SetZandA(Int_t z, Int_t a)
Set atomic number and mass number.
Definition: KVNucleus.cpp:713
void SetRandomized(Bool_t r=kTRUE)
Definition: KVTarget.h:253
Double_t z() const
const Int_t n
void Error(const char *location, const char *fmt,...)
void Info(const char *location, const char *fmt,...)
void Warning(const char *location, const char *fmt,...)
Add
Double_t Abs(Double_t d)
Double_t Max(Double_t a, Double_t b)
ClassImp(TPyArg)