KaliVeda
Toolkit for HIC analysis
KVElasticCountRates.cpp
1 /*
2 $Id: KVElasticCountRates.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 Fri Nov 20 2015
8 //Author: John Frankland
9 
10 #include "KVElasticCountRates.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 "KVNucleus.h"
18 #include "TObjArray.h"
19 #include "KVDatime.h"
20 #include <TH2F.h>
21 #include <vector>
22 #include <algorithm>
23 
24 using namespace std;
25 
28 
29 
30 
31 
33 void KVElasticCountRates::SetAngularRange(Double_t theta_min, Double_t theta_max, Double_t phi_min, Double_t phi_max)
34 {
35  fAngularRange = {theta_min, theta_max, phi_min, phi_max};
36  fVolume = (theta_max - theta_min) * (phi_max - phi_min) * TMath::DegToRad() * TMath::DegToRad();
37 }
38 
39 
40 
42 
44 {
45  fArrayHistos.Delete();
46  fRates.clear();
47  fGlobalMap = new TH2F("hGlobalMap", "X-section in x(vert)-y(hori) plane",
48  500, -fAngularRange.GetThetaMax(), fAngularRange.GetThetaMax(),
49  500, -fAngularRange.GetThetaMax(), fAngularRange.GetThetaMax());
50  return true;
51 }
52 
53 
54 
56 
58 {
59  det_sim.ClearHitGroups();
60 }
61 
62 
63 
66 
68 {
69  //set random direction of outgoing projectile
70  double theta,phi;
71  fAngularRange.GetRandomAngles(theta, phi, "random");
72  return {theta,phi};
73 }
74 
75 
76 
79 
80 void KVElasticCountRates::detect_particle_fill_histograms(KVNucleus* ejectile, double theta, double phi, double xsec)
81 {
82  //now detect particle in array
83  auto detectors = det_sim.PropagateParticle(ejectile);
84  FillHistograms(&detectors, theta, phi, xsec);
85 }
86 
87 
88 
90 
92 {
93  PrintResults(fBeamIntensity);
94 }
95 
96 
97 
103 
104 void KVElasticCountRates::FillHistograms(const KVNameValueList* dets, double theta, double phi, double xsec)
105 {
106  // parse the list dets
107  // fill histograms with energy loss for all detectors
108  // clear the detector energy losses
109  // delete the list
110 
111  if (!dets) return;
112 
113  Int_t ndets = dets->GetNpar();
114  for (int i = 0; i < ndets; i++) {
115  TString detname = dets->GetNameAt(i);
116  KVDetector* det = gMultiDetArray->GetDetector(detname);
117  if (!det) continue;
118  TH1F* histo = (TH1F*)fArrayHistos.FindObject(detname);
119  if (!histo) {
120  histo = new TH1F(detname, Form("Eloss in %s", detname.Data()), GetEbinning(), 0, 0);
121  fArrayHistos.Add(histo);
122  }
123  double de = dets->GetDoubleValue(i);
124  histo->Fill(de, xsec * sin(theta * TMath::DegToRad()));
125  histo = (TH1F*)fArrayHistos.FindObject(detname + "_dW");
126  if (!histo) {
127  histo = new TH1F(detname + "_dW", Form("Solid angle of %s", detname.Data()), GetEbinning(), 0, 0);
128  fArrayHistos.Add(histo);
129  }
130  histo->Fill(de, sin(theta * TMath::DegToRad()));
131  TH2F* histo2 = (TH2F*)fArrayHistos.FindObject(detname + "_map");
132  if (!histo2) {
133  histo2 = new TH2F(detname + "_map", Form("Map of %s", detname.Data()), 100, 0, 0, 100, 0, 0);
134  fArrayHistos.Add(histo2);
135  }
136  histo2->Fill(theta, phi, xsec);
137  fGlobalMap->Fill(theta * sin(phi * TMath::DegToRad()), theta * cos(phi * TMath::DegToRad()), xsec);
138  det->Clear();
139  }
140 }
141 
142 
146 
151 struct count_rate {
153  double counts;
154  double energy;
155  double theta;
156  double phi;
157  double fluence;
158  double dissipation;
159  double intXsec;
160  count_rate(TString n, double c, double e, double t, double p, double f, double d, double i)
161  : detector(n), counts(c), energy(e), theta(t), phi(p), fluence(f), dissipation(d), intXsec(i) {}
162  void print()
163  {
164  printf("%s \t: N=%8.2f/sec. \t <E>=%7.1f MeV \t Tot.Xsec=%9.3E barn \t fluence=%9.3E/sec./cm**2 \t dissip.=%9.3E MeV/sec./cm**2\n",
165  detector.Data(), counts, energy, intXsec, fluence, dissipation);
166  }
168  {
169  if (nl.HasParameter("DetList")) {
170  KVString tmp = nl.GetStringValue("DetList");
171  tmp += ",";
172  tmp += detector;
173  nl.SetValue("DetList", tmp.Data());
174  }
175  else {
176  nl.SetValue("DetList", detector.Data());
177  }
178  nl.SetValue(Form("%s.Counts(/sec)", detector.Data()), Form("%8.2f", counts));
179 
180  nl.SetValue(Form("%s.Counts(/sec)", detector.Data()), Form("%8.2f", counts));
181  nl.SetValue(Form("%s.Emean(MeV)", detector.Data()), Form("%7.1f", energy));
182  nl.SetValue(Form("%s.TotXsec(barn)", detector.Data()), Form("%9.3E", intXsec));
183  nl.SetValue(Form("%s.Fluence(/sec./cm**2)", detector.Data()), Form("%9.3E", fluence));
184  nl.SetValue(Form("%s.dissip(MeV/sec./cm**2)", detector.Data()), Form("%9.3E", dissipation));
185  }
186 };
187 
188 
190 
191 bool compare_count_rates(count_rate a, count_rate b)
192 {
193  if (TMath::Abs(a.theta - b.theta) < 0.5) return a.phi < b.phi;
194  return a.theta < b.theta;
195 }
196 
197 
198 
201 
203 {
204  // Print mean energy deposit & counting rate for given beam intensity in particles per second
205 
206  TIter it(&fArrayHistos);
207  TH1F* h;
208  fRates.clear();
209 
210  std::vector<count_rate> count_rates;
211 
212  while ((h = (TH1F*)it())) {
213  TString name = h->GetName();
214  if (!name.EndsWith("_dW") && !name.EndsWith("_map")) {
215  TH2F* map = (TH2F*)fArrayHistos.FindObject(name + "_map");
216  // integrated cross-section
217  double intXsec = h->Integral() * fVolume / fNtirages;
218  // counting rate
219  double rate = fAtomicDensity * beam_intensity * intXsec;
220  // mean energy
221  double emean = h->GetMean();
222  KVDetector* det = gMultiDetArray->GetDetector(name);
223  double fluence = rate / det->GetEntranceWindowSurfaceArea();
224  double dissipation = emean * rate / det->GetEntranceWindowSurfaceArea();
225  count_rates.push_back(
226  count_rate(name, rate, emean, map->GetMean(), map->GetMean(2), fluence, dissipation, intXsec)
227  );
228  fRates[name.Data()] = KVElasticCountRate(rate, emean, intXsec, fluence, dissipation);
229  }
230  }
231  std::sort(count_rates.begin(), count_rates.end(), compare_count_rates);
232 
233  for (std::vector<count_rate>::iterator it = count_rates.begin(); it != count_rates.end(); ++it) {
234  it->print();
235  }
236 }
237 
238 
239 
242 
244 {
245  // Print mean energy deposit & counting rate for given beam intensity in particles per second
246  KVNameValueList nl;
247  nl.SetName("Generated by KVElasticCountRates::PutResultsInList method");
248  KVDatime dt;
249  nl.SetTitle(dt.AsSQLString());
250  TIter it(&fArrayHistos);
251  TH1F* h;
252  fRates.clear();
253  nl.SetValue("Intensity(pps)", beam_intensity);
254 
255  std::vector<count_rate> count_rates;
256 
257  while ((h = (TH1F*)it())) {
258  TString name = h->GetName();
259  if (!name.EndsWith("_dW") && !name.EndsWith("_map")) {
260  TH2F* map = (TH2F*)fArrayHistos.FindObject(name + "_map");
261  // integrated cross-section
262  double intXsec = h->Integral() * fVolume / fNtirages;
263  // counting rate
264  double rate = fAtomicDensity * beam_intensity * intXsec;
265  // mean energy
266  double emean = h->GetMean();
267  KVDetector* det = gMultiDetArray->GetDetector(name);
268  double fluence = rate / det->GetEntranceWindowSurfaceArea();
269  double dissipation = emean * rate / det->GetEntranceWindowSurfaceArea();
270  count_rates.push_back(
271  count_rate(name, rate, emean, map->GetMean(), map->GetMean(2), fluence, dissipation, intXsec)
272  );
273  fRates[name.Data()] = KVElasticCountRate(rate, emean, intXsec, fluence, dissipation);
274  }
275  }
276  std::sort(count_rates.begin(), count_rates.end(), compare_count_rates);
277 
278  for (std::vector<count_rate>::iterator it = count_rates.begin(); it != count_rates.end(); ++it) {
279  it->PutInList(nl);
280  }
281  return nl;
282 }
283 
284 
285 //__________________________________________________________________//
286 
int Int_t
#define d(i)
#define f(i)
#define c(i)
#define e(i)
double Double_t
winID h TVirtualViewer3D TVirtualGLPainter p
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 b
char name[80]
char * Form(const char *fmt,...)
Relativistic binary kinematics calculator.
Definition: KV2Body.h:178
Extension of TDatime to handle various useful date formats.
Definition: KVDatime.h:33
Base class for detector geometry description, interface to energy-loss calculations.
Definition: KVDetector.h:160
virtual Double_t GetEntranceWindowSurfaceArea()
Return surface area of first layer of detector in cm2.
void Clear(Option_t *opt="") override
Definition: KVDetector.cpp:565
Calculate elastic scattering count rates in the detectors of multidetector arrays ,...
void PrintResults(Double_t beam_intensity=1.e+07)
Print mean energy deposit & counting rate for given beam intensity in particles per second.
KVNameValueList PutResultsInList(Double_t beam_intensity=1.e+07)
Print mean energy deposit & counting rate for given beam intensity in particles per second.
bool initial_checks_and_reset() override
std::pair< double, double > get_random_angles_for_scattering(const KV2Body &) override
set random direction of outgoing projectile
void detect_particle_fill_histograms(KVNucleus *ejectile, double theta, double phi, double xsec) override
now detect particle in array
void end_of_run() override
void reset_before_new_scattering() override
void FillHistograms(const KVNameValueList *, double theta, double phi, double xsec)
virtual KVDetector * GetDetector(const Char_t *name) const
Return detector in this structure with given name.
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Double_t GetDoubleValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
const Char_t * GetNameAt(Int_t idx) const
Int_t GetNpar() const
return the number of stored parameters
const Char_t * GetStringValue(const Char_t *name) const
Bool_t HasParameter(const Char_t *name) const
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:123
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
const char * AsSQLString() const
virtual Double_t GetMean(Int_t axis=1) const
TObject * FindObject(const char *name) const override
virtual Int_t Fill(const char *name, Double_t w)
virtual Double_t Integral(Int_t binx1, Int_t binx2, Option_t *option="") const
virtual Int_t Fill(const char *namex, const char *namey, Double_t w)
virtual void SetTitle(const char *title="")
const char * GetName() const override
virtual void SetName(const char *name)
const char * Data() const
RVec< PromoteType< T > > cos(const RVec< T > &v)
RVec< PromoteType< T > > sin(const RVec< T > &v)
const Int_t n
TH1 * h
constexpr Double_t DegToRad()
Double_t Abs(Double_t d)
Utility class used by KVElasticCountRates to store results.
Utility class used by KVElasticCountRates.
count_rate(TString n, double c, double e, double t, double p, double f, double d, double i)
void PutInList(KVNameValueList &nl)
TArc a
ClassImp(TPyArg)