KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVDetector.cpp
Go to the documentation of this file.
1 #include "KVDetector.h"
2 #include "Riostream.h"
3 #include "TROOT.h"
4 #include "TRandom3.h"
5 #include "TBuffer.h"
6 #include "KVUnits.h"
7 #include "KVTelescope.h"
8 #include "KVGroup.h"
9 #include "KVCalibrator.h"
10 #include "TPluginManager.h"
11 #include "TObjString.h"
12 #include "TClass.h"
13 /*** geometry ***/
14 #include "TGeoVolume.h"
15 #include "TGeoManager.h"
16 #include "TGeoMatrix.h"
17 #include "TGeoBBox.h"
18 #include "TGeoArb8.h"
19 #include "TGeoTube.h"
20 #include "KVCalibratedSignal.h"
23 
24 #include <TGeoPhysicalNode.h>
25 #include <TGraph.h>
26 
27 using namespace std;
28 
30 
31 
33 
34 
37 
39 {
40  //default initialisations
41  fCalibrators = 0;
42  fParticles = 0;
43  fCalWarning = 0;
44  fAbsorbers = new KVList;
45  fActiveLayer = nullptr;
46  fIDTelescopes = new KVList(kFALSE);
47  fIDTelescopes->SetCleanup(kTRUE);
48  fIDTelAlign = new KVList(kFALSE);
49  fIDTelAlign->SetCleanup(kTRUE);
50  fIDTele4Ident = 0;
51  fIdentP = fUnidentP = 0;
52  fTotThickness = 0.;
53  fDepthInTelescope = 0.;
54  fELossF = fEResF = fRangeF = 0;
55  fEResforEinc = -1.;
56  fAlignedDetectors[0] = 0;
57  fAlignedDetectors[1] = 0;
58  fSimMode = kFALSE;
59  fPresent = kTRUE;
60  fDetecting = kTRUE;
61  fParentStrucList.SetCleanup();
62  fSingleLayer = kTRUE;
63  fNode.SetDetector(this);
64  // detector owns any signals which are defined for it
65  fDetSignals.SetOwner();
66  // adding a new signal with the same name as an existing one
67  // will delete the existing signal and replace it
68  fDetSignals.ReplaceObjects();
69 }
70 
71 
72 
75 
77 {
78 //default ctor
79  init();
80  fDetCounter++;
81  SetName(Form("Det_%d", fDetCounter));
82 }
83 
84 
85 
88 
90  const Float_t thick): KVMaterial()
91 {
92  // Create a new detector of a given material and thickness in centimetres (default value = 0.0)
93 
94  init();
95  SetType("DET");
96  fDetCounter++;
97  SetName(Form("Det_%d", fDetCounter));
98  AddAbsorber(new KVMaterial(type, thick));
99 }
100 
101 
102 
105 
107 {
108 //copy ctor
109  init();
110  fDetCounter++;
111  SetName(Form("Det_%d", fDetCounter));
112 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
113  obj.Copy(*this);
114 #else
115  ((KVDetector&) obj).Copy(*this);
116 #endif
117 }
118 
119 
120 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
121 
126 
127 void KVDetector::Copy(TObject& obj) const
128 #else
129 void KVDetector::Copy(TObject& obj)
130 #endif
131 {
132  //copy 'this' to 'obj'
133  //The structure of the detector is copied, with new cloned objects for
134  //each absorber layer. The active layer is set in the new detector.
135 
136  TIter next(fAbsorbers);
137  KVMaterial* mat;
138  while ((mat = (KVMaterial*) next())) {
139  ((KVDetector&) obj).AddAbsorber((KVMaterial*) mat->Clone());
140  }
141  //set active layer
142  Int_t in_actif = fAbsorbers->IndexOf(fActiveLayer);
143  ((KVDetector&) obj).SetActiveLayer(((KVDetector&)obj).GetAbsorber(in_actif));
144 }
145 
146 
147 
148 
150 
151 KVDetector::~KVDetector()
152 {
153  fIDTelescopes->Clear();
157  delete fAbsorbers;
161  fIDTelAlign->Clear();
164  if (fAlignedDetectors[0]) fAlignedDetectors[0]->Clear("nodelete");
166  if (fAlignedDetectors[1]) fAlignedDetectors[1]->Clear("nodelete");
168 }
169 
170 
171 
176 
178 {
179  // Set material of active layer.
180  // If no absorbers have been added to the detector, create and add
181  // one (active layer by default)
182 
183  if (!GetActiveLayer())
185  else
187 }
188 
189 
190 
202 
204 {
205  //Calculate the energy loss of a charged particle traversing the detector,
206  //the particle is slowed down, it is added to the list of all particles hitting the
207  //detector. The apparent energy loss of the particle in the active layer of the
208  //detector is set.
209  //Do nothing if particle has zero (or -ve) energy.
210  //
211  //If the optional argument 'norm' is given, it is supposed to be a vector
212  //normal to the detector, oriented from the origin towards the detector.
213  //In this case the effective thicknesses of the detector's absorbers 'seen' by the particle
214  //depending on its direction of motion is used for the calculation.
215 
216  if (kvp->GetKE() <= 0.)
217  return;
218 
219  AddHit(kvp); //add nucleus to list of particles hitting detector in the event
220  //set flag to say that particle has been slowed down
221  kvp->SetIsDetected();
222  //If this is the first absorber that the particle crosses, we set a "reminder" of its
223  //initial energy
224  if (!kvp->GetPInitial())
225  kvp->SetE0();
226 
227  std::vector<Double_t> thickness;
228  if (norm) {
229  // modify thicknesses of all layers according to orientation,
230  // and store original thicknesses in array
231  TVector3 p = kvp->GetMomentum();
232  thickness.reserve(fAbsorbers->GetEntries());
233  KVMaterial* abs;
234  int i = 0;
235  TIter next(fAbsorbers);
236  while ((abs = (KVMaterial*) next())) {
237  thickness[i++] = abs->GetThickness();
238  Double_t T = abs->GetEffectiveThickness((*norm), p);
239  abs->SetThickness(T);
240  }
241  }
242  Double_t eloss = GetTotalDeltaE(kvp->GetZ(), kvp->GetA(), kvp->GetEnergy());
243  Double_t dE = GetDeltaE(kvp->GetZ(), kvp->GetA(), kvp->GetEnergy());
244  if (norm) {
245  // reset thicknesses of absorbers
246  KVMaterial* abs;
247  int i = 0;
248  TIter next(fAbsorbers);
249  while ((abs = (KVMaterial*) next())) {
250  abs->SetThickness(thickness[i++]);
251  }
252  }
253  Double_t epart = kvp->GetEnergy() - eloss;
254  if (epart < 1e-3) {
255  //printf("%s, pb d arrondi on met l energie de la particule a 0\n",GetName());
256  epart = 0.0;
257  }
258  kvp->SetEnergy(epart);
259  Double_t eloss_old = GetEnergyLoss();
260  SetEnergyLoss(eloss_old + dE);
261 }
262 
263 
264 
265 
275 
277 {
278  //Calculate the total energy loss of a charged particle traversing the detector.
279  //This does not affect the "stored" energy loss value of the detector,
280  //nor its ACQData, nor the energy of the particle.
281  //
282  //If the optional argument 'norm' is given, it is supposed to be a vector
283  //normal to the detector, oriented from the origin towards the detector.
284  //In this case the effective thicknesses of the detector's absorbers 'seen' by the particle
285  //depending on its direction of motion is used for the calculation.
286 
287  std::vector<Double_t> thickness;
288  if (norm) {
289  // modify thicknesses of all layers according to orientation,
290  // and store original thicknesses in array
291  TVector3 p = kvp->GetMomentum();
292  thickness.reserve(fAbsorbers->GetEntries());
293  KVMaterial* abs;
294  int i = 0;
295  TIter next(fAbsorbers);
296  while ((abs = (KVMaterial*) next())) {
297  thickness[i++] = abs->GetThickness();
298  Double_t T = abs->GetEffectiveThickness((*norm), p);
299  abs->SetThickness(T);
300  }
301  }
302  Double_t eloss = GetTotalDeltaE(kvp->GetZ(), kvp->GetA(), kvp->GetEnergy());
303  if (norm) {
304  // reset thicknesses of absorbers
305  KVMaterial* abs;
306  int i = 0;
307  TIter next(fAbsorbers);
308  while ((abs = (KVMaterial*) next())) {
309  abs->SetThickness(thickness[i++]);
310  }
311  }
312  return eloss;
313 }
314 
315 
316 
317 
327 
329 {
330  //Calculate the energy of particle 'kvn' before its passage through the detector,
331  //based on the current kinetic energy, Z & A of nucleus 'kvn', supposed to be
332  //after passing through the detector.
333  //
334  //If the optional argument 'norm' is given, it is supposed to be a vector
335  //normal to the detector, oriented from the origin towards the detector.
336  //In this case the effective thicknesses of the detector's absorbers 'seen' by the particle
337  //depending on its direction of motion is used for the calculation.
338 
339  Double_t Einc = 0.0;
340  //make 'clone' of particle
341  KVNucleus clone_part(kvp->GetZ(), kvp->GetA());
342  clone_part.SetMomentum(kvp->GetMomentum());
343  //composite detector - calculate losses in all layers
344  KVMaterial* abs;
345  TIter next(fAbsorbers, kIterBackward); //work through list backwards
346  while ((abs = (KVMaterial*) next())) {
347 
348  //calculate energy of particle before current absorber
349  Einc = abs->GetParticleEIncFromERes(&clone_part, norm);
350 
351  //set new energy of particle
352  clone_part.SetKE(Einc);
353  }
354  return Einc;
355 }
356 
357 
358 
359 
363 
364 void KVDetector::Print(Option_t* opt) const
365 {
366  //Print info on this detector
367  //if option="data" the energy loss and raw data are displayed
368 
369  if (!strcmp(opt, "data")) {
370  cout << GetName() << " -- ";
371  // print raw data signals
372  KVDetectorSignal* sig;
374  while ((sig = (KVDetectorSignal*)it())) {
375  if (sig->IsRaw()) {
376  std::cout << sig->GetName() << "=" << sig->GetValue() << " | ";
377  }
378  }
379  // print calibrated data
380  it.Reset();
381  while ((sig = (KVDetectorSignal*)it())) {
382  if (!sig->IsRaw() && !sig->GetValueNeedsExtraParameters()) {
383  std::cout << sig->GetName() << "=" << sig->GetValue() << " | ";
384  }
385  }
386  cout << " ";
388  cout << "(Belongs to an unidentified particle)";
389  cout << endl;
390  }
391  else if (!strcmp(opt, "all")) {
392  //Give full details of detector
393  //
394  TString option(" ");
395  cout << option << ClassName() << " : " << ((KVDetector*) this)->
396  GetName() << endl;
397  //composite detector - print all layers
398  KVMaterial* abs;
399  TIter next(fAbsorbers);
400  while ((abs = (KVMaterial*) next())) {
401  if (GetActiveLayer() == abs)
402  cout << " ### ACTIVE LAYER ### " << endl;
403  cout << option << option;
404  abs->Print();
405  if (GetActiveLayer() == abs)
406  cout << " #################### " << endl;
407  }
408  if (fParticles) {
409  cout << option << " --- Detected particles:" << endl;
410  fParticles->Print();
411  }
412  if (fIDTelescopes) {
413  cout << option << " --- Detector belongs to the following Identification Telescopes:" << endl;
414  fIDTelescopes->ls();
415  }
416  }
417  else {
418  //just print name
419  cout << ClassName() << ": " << ((KVDetector*) this)->
420  GetName() << endl;
421  }
422 }
423 
424 
425 
426 
427 
438 
440 {
441  // This method is called by KVASMultiDetArray::MakeListOfDetectors
442  // after the array geometry has been defined (i.e. all detectors have
443  // been placed in the array). The string returned by this method
444  // is used to set the name of the detector.
445  //
446  // Override this method in child classes in order to define a naming
447  // convention for specific detectors of the array.
448  //
449  // By default we return the same name as KVDetector::GetName
450 
451  fFName = GetName();
452  return fFName.Data();
453 }
454 
455 
456 
477 
479 {
480  // Associate a calibration with this detector.
481  //
482  // This will add a new signal to the list of the detector's signals.
483  //
484  // Also sets calibrator's name to `[detname]_[caltype]` where `caltype` is the type of the KVCalibration object.
485  //
486  // \param[in] cal pointer to KVCalibrator object (must be on heap, i.e. created with new: detector handles deletion)
487  // \param[in] opts
488  // \parblock
489  // can be used to pass any extra parameters/options needed by the calibrator.
490  //
491  // For example, if it contains a parameter `ZRange`, e.g. `ZRange=1-10`
492  // then the calibrator will be handled by a KVZDependentCalibratedSignal (handles several
493  // calibrators which provide the same output signal, each one is used for a specific range
494  // of atomic numbers)
495  // \endparblock
496  //
497  // \returns kFALSE in case of problems (non-existent input signal for calibrator, output signal not defined for calibrator),
498  // otherwise kTRUE
499 
500  if (!cal) return kFALSE;
501  // look for input signal
503  // input signal must exist
504  if (!in) {
505  Error("AddCalibrator", "No known detector signal: %s", cal->GetInputSignalType().Data());
506  return kFALSE;
507  }
508  if (!fCalibrators)
509  fCalibrators = new KVList();
510 
511  cal->SetDetector(this);
512  fCalibrators->Add(cal);
513  cal->SetName(Form("%s_%s", GetName(), cal->GetType()));
514 
515  if (cal->GetOutputSignalType() == "") {
516  Warning("AddCalibrator", "%s : output signal not defined for calibrator %s. No output signal created.",
517  GetName(), cal->GetType());
518  }
519  else {
520  KVDetectorSignal* new_cal_sig(nullptr);
521  if (opts.HasParameter("ZRange")) {
522  // If 'ZRange' parameter is given we need to find the KVZDependentCalibratedSignal
523  // and add a new signal to it.
525  if (!sig) {
526  new_cal_sig = sig = new KVZDependentCalibratedSignal(in, cal->GetOutputSignalType());
527  }
528  dynamic_cast<KVZDependentCalibratedSignal*>(sig)->AddSignal(new KVCalibratedSignal(in, cal), opts.GetStringValue("ZRange"));
529  }
530  else {
531  new_cal_sig = new KVCalibratedSignal(in, cal);
532  }
533  if (new_cal_sig) fDetSignals.Add(new_cal_sig);
534  }
535  return kTRUE;
536 }
537 
538 
539 
550 
552 {
553  // Replace calibrator of given type with the given calibrator object
554  // The calibrator object should not be shared with any other detectors: it now belongs
555  // to this detector, which will delete it when necessary.
556  // If an exising calibrator with the same type is already defined, it will be
557  // deleted and removed from the detector's calibrator list
558  //
559  // Returns kFALSE in case of problems.
560  //
561  // The (optional) KVNameValueList argument can be used to pass any extra parameters/options.
562 
563  KVCalibrator* old_cal = GetCalibrator(type);
564  if (old_cal) {
565  fCalibrators->Remove(old_cal);
567  delete old_cal;
568  }
569  return AddCalibrator(cal, opts);
570 }
571 
572 
573 
578 
580 {
581  // A detector is considered to be calibrated if it has
582  // a signal "Energy" available and if depending on the supplied parameters
583  // this signal can be calculated
584 
585  KVCalibratedSignal* e_sig = dynamic_cast<KVCalibratedSignal*>(GetDetectorSignal("Energy"));
586  return (e_sig && e_sig->IsAvailableFor(params) && IsOK());
587 }
588 
589 
590 
591 
595 
597 {
598  //Set energy loss(es) etc. to zero
599  //If opt="N" we do not reset acquisition parameters/raw detector signals
600 
602  fIdentP = fUnidentP = 0;
605  if (strncmp(opt, "N", 1)) {
607  KVDetectorSignal* ds;
608  while ((ds = (KVDetectorSignal*)it())) {
609  if (ds->IsRaw() && !ds->IsExpression()) ds->Reset();
610  }
611  }
612  ClearHits();
613  //reset all layers in detector
614  KVMaterial* mat;
615  TIter next(fAbsorbers);
616  while ((mat = (KVMaterial*) next())) {
617  mat->Clear();
618  }
619  fEResforEinc = -1.;
620 }
621 
622 
623 
628 
630 {
631  // Add a layer of absorber material to the detector
632  // By default, the first layer added is set as the "Active" layer.
633  // Call SetActiveLayer to change this.
634  fAbsorbers->Add(mat);
635  if (!TestBit(kActiveSet))
636  SetActiveLayer(mat);
637  if (fAbsorbers->GetSize() > 1) fSingleLayer = kFALSE;
638 }
639 
640 
641 
644 
646 {
647  //Returns pointer to the i-th absorber in the detector (i=0 first absorber, i=1 second, etc.)
648 
649  if (i < 0) {
650  //special case of reading old detectors
651  //no warning
652  return 0;
653  }
654  if (!fAbsorbers) {
655  Error("GetAbsorber", "No absorber list");
656  return 0;
657  }
658  if (fAbsorbers->GetSize() < 1) {
659  Error("GetAbsorber", "Nothing in absorber list");
660  return 0;
661  }
662  if (i >= fAbsorbers->GetSize()) {
663  Error("GetAbsorber", "i=%d but only %d absorbers in list", i,
664  fAbsorbers->GetSize());
665  return 0;
666  }
667 
668  return (KVMaterial*) fAbsorbers->At(i);
669 }
670 
671 
672 
676 
678 {
679  // Used when a calibrator object is removed or replaced
680  // We remove and delete the corresponding output signal from the list of detector signals
681 
682  if (K->GetOutputSignalType() != "") {
683  KVDetectorSignal* ds = GetDetectorSignal(K->GetOutputSignalType());
684  if (ds) {
685  fDetSignals.Remove(ds);
686  delete ds;
687  }
688  }
689 }
690 
691 
692 
698 
700 {
701  // Removes all calibrations associated to this detector: in other words, we delete all
702  // the KVCalibrator objects in list fCalibrators.
703  //
704  // We also destroy all signals provided by these calibrators
705 
706  if (fCalibrators) {
707  KVCalibrator* K;
708  TIter it(fCalibrators);
709  while ((K = (KVCalibrator*)it())) {
711  }
712  fCalibrators->Delete();
713  }
714 }
715 
716 
717 
718 
721 
723 {
724  //Add ID telescope to list of telescopes to which detector belongs
725  fIDTelescopes->Add(idt);
726 }
727 
728 
729 
735 
737 {
738  // Return list of all ID telescopes containing detectors placed in front of
739  // this one.
740 
741  // temporary kludge during transition to trajectory-based reconstruction
742  // ROOT-geometry-based detectors will not have fIDTelAlign filled
743  if (ROOTGeo() && !fIDTelAlign->GetEntries()) {
745  (KVGeoDNTrajectory*)GetNode()->GetTrajectories()->First(),
746  GetNode()
747  );
748  if (Rtr) fIDTelAlign->AddAll(Rtr->GetIDTelescopes());
749  }
750  return fIDTelAlign;
751 }
752 
753 
754 
755 
760 
762 {
763  //Returns list of identification telescopes to be used in order to try to identify
764  //particles stopping in this detector. This is the same as GetAlignedIDTelescopes
765  //but only including the telescopes of which this detector is a member.
766  if (fIDTele4Ident) return fIDTele4Ident;
767  if (!fIDTelescopes || !fIDTelAlign) return 0;
768  fIDTele4Ident = new TList;
770  TObject* idt;
771  while ((idt = next())) {
772  if (fIDTelescopes->FindObject(idt)) fIDTele4Ident->Add(idt);
773  }
774  return fIDTele4Ident;
775 }
776 
777 
778 
779 
780 
809 
811 {
812  // Returns the total energy loss in the detector for a given nucleus
813  // including inactive absorber layers.
814  // e = energy loss in active layer (if not given, we use current value)
815  // transmission = kTRUE (default): the particle is assumed to emerge with
816  // a non-zero residual energy Eres after the detector.
817  // = kFALSE: the particle is assumed to stop in the detector.
818  //
819  // WARNING: if transmission=kTRUE, and if the residual energy after the detector
820  // is known (i.e. measured in a detector placed after this one), you should
821  // first call
822  // SetEResAfterDetector(Eres);
823  // before calling this method. Otherwise, especially for heavy ions, the
824  // correction may be false for particles which are just above the punch-through energy.
825  //
826  // WARNING 2: if measured energy loss in detector active layer is greater than
827  // maximum possible theoretical value for given nucleus' Z & A, this may be because
828  // the A was not measured but calculated from Z and hence could be false, or perhaps
829  // there was an (undetected) pile-up of two or more particles in the detector.
830  // In this case we return the uncorrected energy measured in the active layer
831  // and we add the following parameters to the particle (in nuc->GetParameters()):
832  //
833  // GetCorrectedEnergy.Warning = 1
834  // GetCorrectedEnergy.Detector = [name]
835  // GetCorrectedEnergy.MeasuredDE = [value]
836  // GetCorrectedEnergy.MaxDE = [value]
837  // GetCorrectedEnergy.Transmission = 0 or 1
838  // GetCorrectedEnergy.ERES = [value]
839 
840  Int_t z = nuc->GetZ();
841  Int_t a = nuc->GetA();
842 
843  if (e < 0.) e = GetEnergy();
844  if (e <= 0) {
846  return 0;
847  }
848 
849  enum SolType solution = kEmax;
850  if (!transmission) solution = kEmin;
851 
852  // check that apparent energy loss in detector is compatible with a & z
853  Double_t maxDE = GetMaxDeltaE(z, a);
854  Double_t EINC, ERES = GetEResAfterDetector();
855  if (e > maxDE) {
856  nuc->GetParameters()->SetValue("GetCorrectedEnergy.Warning", 1);
857  nuc->GetParameters()->SetValue("GetCorrectedEnergy.Detector", GetName());
858  nuc->GetParameters()->SetValue("GetCorrectedEnergy.MeasuredDE", e);
859  nuc->GetParameters()->SetValue("GetCorrectedEnergy.MaxDE", maxDE);
860  nuc->GetParameters()->SetValue("GetCorrectedEnergy.Transmission", (Int_t)transmission);
861  nuc->GetParameters()->SetValue("GetCorrectedEnergy.ERES", ERES);
862  return e;
863 
864  }
865  if (transmission && ERES > 0.) {
866  // if residual energy is known we use it to calculate EINC.
867  // if EINC < max of dE curve, we change solution
868  EINC = GetIncidentEnergyFromERes(z, a, ERES);
869  if (EINC < GetEIncOfMaxDeltaE(z, a)) solution = kEmin;
870  // we could keep the EINC value calculated using ERES, but then
871  // the corrected dE of this detector would not depend on the
872  // measured dE !
873  }
874  EINC = GetIncidentEnergy(z, a, e, solution);
875  if (EINC < 0) {
877  return EINC;
878  }
879  ERES = GetERes(z, a, EINC);
880 
882  return (EINC - ERES);
883 }
884 
885 
886 
887 
905 
907 {
908  //For particles which stop in the first stage of an identification telescope,
909  //we can at least estimate a minimum Z value based on the energy lost in this
910  //detector.
911  //
912  //This is based on the KVMaterial::GetMaxDeltaE method, giving the maximum
913  //energy loss in the active layer of the detector for a given nucleus (A,Z).
914  //
915  //The "Zmin" is the Z of the particle which gives a maximum energy loss just greater
916  //than that measured in the detector. Particles with Z<Zmin could not lose as much
917  //energy and so are excluded.
918  //
919  //If ELOSS is not given, we use the current value of GetEnergy()
920  //Use 'mass_formula' to change the formula used to calculate the A of the nucleus
921  //from its Z. Default is valley of stability value. (see KVNucleus::GetAFromZ).
922  //
923  //If the value of ELOSS or GetEnergy() is <=0 we return Zmin=0
924 
925  ELOSS = (ELOSS < 0. ? GetEnergy() : ELOSS);
926  if (ELOSS <= 0) return 0;
927 
928  UInt_t z = 40;
929  UInt_t zmin, zmax;
930  zmin = 1;
931  zmax = 92;
932  Double_t difference;
933  UInt_t last_positive_difference_z = 1;
934  KVNucleus particle;
935  if (mass_formula > -1)
936  particle.SetMassFormula((UChar_t)mass_formula);
937 
938  difference = 0.;
939 
940  while (zmax > zmin + 1) {
941 
942  particle.SetZ(z);
943 
944  difference = GetMaxDeltaE(z, particle.GetA()) - ELOSS;
945  //if difference < 0 the z is too small
946  if (difference < 0.0) {
947 
948  zmin = z;
949  z += (UInt_t)((zmax - z) / 2 + 0.5);
950 
951  }
952  else {
953 
954  zmax = z;
955  last_positive_difference_z = z;
956  z -= (UInt_t)((z - zmin) / 2 + 0.5);
957 
958  }
959  }
960  if (difference < 0) {
961  //if the last z we tried actually made the difference become negative again
962  //(i.e. z too small) we return the last z which gave a +ve difference
963  z = last_positive_difference_z;
964  }
965  return z;
966 }
967 
968 
969 
970 
979 
981 {
982  // Calculates energy loss (in MeV) in active layer of detector, taking into account preceding layers
983  //
984  // Arguments are:
985  // x[0] is incident energy in MeV
986  // Parameters are:
987  // par[0] Z of ion
988  // par[1] A of ion
989 
990  Double_t e = x[0];
991  TIter next(fAbsorbers);
992  KVMaterial* mat;
993  mat = (KVMaterial*)next();
994  while (fActiveLayer != mat) {
995  // calculate energy losses in absorbers before active layer
996  e = mat->GetERes(par[0], par[1], e); //residual energy after layer
997  if (e <= 0.)
998  return 0.; // return 0 if particle stops in layers before active layer
999  mat = (KVMaterial*)next();
1000  }
1001  //calculate energy loss in active layer
1002  return mat->GetDeltaE(par[0], par[1], e);
1003 }
1004 
1005 
1006 
1007 
1017 
1019 {
1020  // Calculates range (in centimetres) of ions in detector as a function of incident energy (in MeV),
1021  // taking into account all layers of the detector.
1022  //
1023  // Arguments are:
1024  // x[0] = incident energy in MeV
1025  // Parameters are:
1026  // par[0] = Z of ion
1027  // par[1] = A of ion
1028 
1029  Double_t Einc = x[0];
1030  Int_t Z = (Int_t)par[0];
1031  Int_t A = (Int_t)par[1];
1032  Double_t range = 0.;
1033  TIter next(fAbsorbers);
1034  KVMaterial* mat = (KVMaterial*)next();
1035  if (!mat) return 0.;
1036  do {
1037  // range in this layer
1038  Double_t this_range = mat->GetLinearRange(Z, A, Einc);
1039  KVMaterial* next_mat = (KVMaterial*)next();
1040  if (this_range > mat->GetThickness()) {
1041  // particle traverses layer.
1042  if (next_mat)
1043  range += mat->GetThickness();
1044  else // if this is last layer, the range continues to increase beyond size of detector
1045  range += this_range;
1046  // calculate incident energy for next layer (i.e. residual energy after this layer)
1047  Einc = mat->GetERes(Z, A, Einc);
1048  }
1049  else {
1050  // particle stops in layer
1051  range += this_range;
1052  return range;
1053  }
1054  mat = next_mat;
1055  }
1056  while (mat);
1057  // particle traverses detector
1058  return range;
1059 }
1060 
1061 
1062 
1063 
1073 
1075 {
1076  // Calculates residual energy (in MeV) of particle after traversing all layers of detector.
1077  // Returned value is -1000 if particle stops in one of the layers of the detector.
1078  //
1079  // Arguments are:
1080  // x[0] is incident energy in MeV
1081  // Parameters are:
1082  // par[0] Z of ion
1083  // par[1] A of ion
1084 
1085  Double_t e = x[0];
1086  TIter next(fAbsorbers);
1087  KVMaterial* mat;
1088  while ((mat = (KVMaterial*)next())) {
1089  Double_t eres = mat->GetERes(par[0], par[1], e); //residual energy after layer
1090  if (eres <= 0.)
1091  return -1000.; // return -1000 if particle stops in layers before active layer
1092  e = eres;
1093  }
1094  return e;
1095 }
1096 
1097 
1098 
1099 
1114 
1116 {
1117  //Static function which will create an instance of the KVDetector-derived class
1118  //corresponding to 'name'
1119  //These are defined as 'Plugin' objects in the file $KVROOT/KVFiles/.kvrootrc :
1120  // [name_of_dataset].detector_type
1121  // detector_type
1122  // To use the dataset-dependent plugin, call this method with
1123  // name = "[name_of_dataset].detector_type"
1124  // If not, the default plugin will be used
1125  //first we check if there is a special plugin for the DataSet
1126  //if not we take the default one
1127  //
1128  //'thickness' is passed as argument to the constructor for the detector plugin
1129 
1130  //check and load plugin library
1131  TPluginHandler* ph = nullptr;
1132  KVString nom(name);
1133  if (!nom.Contains(".") && !(ph = LoadPlugin("KVDetector", name))) return nullptr;
1134  if (nom.Contains(".")) {
1135  // name format like [dataset].[det_type]
1136  // in case dataset name contains "." we parse string to find detector type: assumed after the last "."
1137  nom.RBegin(".");
1138  KVString det_type = nom.RNext();
1139  if (!(ph = LoadPlugin("KVDetector", name))) {
1140  if (!(ph = LoadPlugin("KVDetector", det_type))) {
1141  return nullptr;
1142  }
1143  }
1144  }
1145 
1146  //execute constructor/macro for detector
1147  return (KVDetector*) ph->ExecPlugin(1, thickness);
1148 }
1149 
1150 
1151 
1152 
1164 
1165 void KVDetector::GetVerticesInOwnFrame(TVector3* corners, Double_t depth, Double_t layer_thickness)
1166 {
1167  // This will fill the array corners[8] with the coordinates of the vertices of the
1168  // front (corners[0],...,corners[3]) & back (corners[4],...,corners[7]) sides of the volume
1169  // representing either a single absorber or the whole detector.
1170  //
1171  // depth = depth of detector/absorber inside the KVTelescope it belongs to (in centimetres)
1172  // layer_thickness = thickness of absorber/detector (in centimetres)
1173  //
1174  // Positioning information is taken from the KVTelescope to which this detector
1175  // belongs; if this is not the case, nothing will be done.
1176 
1177  // relative distance to back of detector
1178  Double_t dist_to_back = depth + layer_thickness;
1179 
1180  // get coordinates
1181  KVTelescope* fTelescope = (KVTelescope*)GetParentStructure("TELESCOPE");
1182  if (fTelescope) {
1183  fTelescope->GetCornerCoordinatesInOwnFrame(corners, depth);
1184  fTelescope->GetCornerCoordinatesInOwnFrame(&corners[4], dist_to_back);
1185  }
1186  else {
1187  GetCornerCoordinatesInOwnFrame(corners, depth);
1188  GetCornerCoordinatesInOwnFrame(&corners[4], dist_to_back);
1189  }
1190 }
1191 
1192 
1193 
1194 
1209 
1211 {
1212  // Construct a TGeoVolume shape to represent this detector in the current
1213  // geometry managed by gGeoManager.
1214  //
1215  // Making the volume requires:
1216  // - to construct a 'mother' volume (TGeoArb8) defined by the (theta-min/max, phi-min/max)
1217  // and the total thickness of the detector (all layers)
1218  // - to construct and position volumes (TGeoArb8) for each layer of the detector inside the
1219  // 'mother' volume. Each layer is represented by a TGeoArb8 whose two parallel faces correspond
1220  // to the front and back surfaces of the layer.
1221  //
1222  // If the detector is composed of a single absorber, we do not create a superfluous "mother" volume.
1223  //
1224  // gGeoManager must point to current instance of geometry manager.
1225 
1226  if (!gGeoManager) return NULL;
1227 
1228  if (fTotThickness == 0) GetTotalThicknessInCM(); // calculate sum of absorber thicknesses in centimetres
1229  // get from telescope info on relative depth of detector i.e. depth inside telescope
1230 
1231  KVTelescope* fTelescope = (KVTelescope*)GetParentStructure("TELESCOPE");
1232  if (fTelescope && fDepthInTelescope == 0)
1233  fDepthInTelescope = fTelescope->GetDepthInCM(fTelescope->GetDetectorRank(this));
1234 
1235  TVector3 coords[8];
1236  Double_t vertices[16];
1237  Double_t tot_thick_det = fTotThickness;
1238  TGeoMedium* med;
1239  TGeoVolume* mother_vol = 0;
1240 
1241  Bool_t multi_layer = fAbsorbers->GetSize() > 1;
1242 
1243  if (multi_layer) {
1244  mother_vol = gGeoManager->MakeVolumeAssembly(Form("%s_DET", GetName()));
1245  }
1246 
1247  /**** BUILD & ADD ABSORBER VOLUMES ****/
1248  TIter next(fAbsorbers);
1249  KVMaterial* abs;
1250  Double_t depth_in_det = 0.;
1251  Int_t no_abs = 1;
1252  while ((abs = (KVMaterial*)next())) {
1253  // get medium for absorber
1254  med = abs->GetGeoMedium();
1255  Double_t thick = abs->GetThickness();
1256  // do not include layers with zero thickness
1257  if (thick == 0.0) continue;
1258  GetVerticesInOwnFrame(coords, fDepthInTelescope + depth_in_det, thick);
1259  for (int i = 0; i < 8; i++) {
1260  vertices[2 * i] = coords[i].X();
1261  vertices[2 * i + 1] = coords[i].Y();
1262  }
1263  Double_t dz = thick / 2.;
1264  TString vol_name;
1265  if (abs == GetActiveLayer()) vol_name = GetName();
1266  else vol_name = Form("%s_%d_%s", GetName(), no_abs, abs->GetType());
1267  TGeoVolume* vol =
1268  gGeoManager->MakeArb8(vol_name.Data(), med, dz, vertices);
1269  vol->SetLineColor(med->GetMaterial()->GetDefaultColor());
1270  if (multi_layer) {
1271  /*** position absorber in mother ***/
1272  Double_t trans_z = -tot_thick_det / 2. + depth_in_det + dz; // (note: reference is CENTRE of absorber)
1273  TGeoTranslation* tr = new TGeoTranslation(0., 0., trans_z);
1274  mother_vol->AddNode(vol, 1, tr);
1275  }
1276  else {
1277  // single absorber: mother is absorber is detector is mother is ...
1278  mother_vol = vol;
1279  }
1280  depth_in_det += thick;
1281  no_abs++;
1282  }
1283 
1284  return mother_vol;
1285 }
1286 
1287 
1288 
1289 
1302 
1304 {
1305  // Construct and position a TGeoVolume shape to represent this detector in the current
1306  // geometry managed by gGeoManager.
1307  //
1308  // Adding the detector to the geometry requires:
1309  // - to construct a 'mother' volume (TGeoArb8) defined by the (theta-min/max, phi-min/max)
1310  // and the total thickness of the detector (all layers)
1311  // - to construct and position volumes (TGeoArb8) for each layer of the detector inside the
1312  // 'mother' volume
1313  // - to position 'mother' inside the top-level geometry
1314  //
1315  // gGeoManager must point to current instance of geometry manager.
1316 
1317  if (!gGeoManager) return;
1318 
1319  // get volume for detector
1320  TGeoVolume* vol = GetGeoVolume();
1321 
1322  // rotate detector to orientation corresponding to (theta,phi)
1323  Double_t theta = GetTheta();
1324  Double_t phi = GetPhi();
1325  TGeoRotation rot1, rot2;
1326  rot2.SetAngles(phi + 90., theta, 0.);
1327  rot1.SetAngles(-90., 0., 0.);
1328  // distance to detector centre = distance to telescope + depth of detector in telescope + half total thickness of detector
1329  KVTelescope* fTelescope = (KVTelescope*)GetParentStructure("TELESCOPE");
1330  Double_t dist_telescope = (fTelescope ? fTelescope->GetDistance() : 0.);
1331  Double_t dist = dist_telescope + fDepthInTelescope + fTotThickness / 2.;
1332  // translate detector to correct distance from target (note: reference is CENTRE of detector)
1333  Double_t trans_z = dist;
1334 
1335  TGeoTranslation tran(0, 0, trans_z);
1336  TGeoHMatrix h = rot2 * tran * rot1;
1337  TGeoHMatrix* ph = new TGeoHMatrix(h);
1338 
1339  // add detector volume to geometry
1340  gGeoManager->GetTopVolume()->AddNode(vol, 1, ph);
1341 }
1342 
1343 
1344 #ifndef WITH_CPP11
1345 
1347 
1348 void printvec(const TVector3& v)
1349 {
1350  cout << "(" << v.X() << "," << v.Y() << "," << v.Z() << ")";
1351 };
1352 
1353 #endif
1354 
1355 
1358 
1360 {
1361  // Return surface area of first layer of detector in cm2.
1362 
1363  if (ROOTGeo()) {
1364  if (!GetEntranceWindow().GetShape()->InheritsFrom("TGeoArb8")) {
1365  // simple shape area
1366  return GetEntranceWindow().GetShape()->GetFacetArea(1);
1367  }
1368  // Monte Carlo calculation for TGeoArb8 shapes
1369  return GetEntranceWindow().GetSurfaceArea();
1370  }
1371 
1372  KVTelescope* fTelescope = (KVTelescope*)GetParentStructure("TELESCOPE");
1373  if (fTelescope && fDepthInTelescope == 0)
1374  fDepthInTelescope = fTelescope->GetDepthInCM(fTelescope->GetDetectorRank(this));
1375 
1376  TVector3 coords[4];
1377 #ifdef WITH_CPP11
1378  auto printvec = [](const TVector3 & v) {
1379  cout << "(" << v.X() << "," << v.Y() << "," << v.Z() << ")";
1380  };
1381 #endif
1382 
1383  if (fTelescope) fTelescope->GetCornerCoordinates(coords, fDepthInTelescope);
1384  else GetCornerCoordinates(coords, 0);
1385  cout << "DETECTOR COORDINATES (in cm):" << endl;
1386  cout << "=================================" << endl;
1387  cout << " A : ";
1388  printvec(coords[0]);
1389  cout << endl;
1390  cout << " B : ";
1391  printvec(coords[1]);
1392  cout << endl;
1393  cout << " C : ";
1394  printvec(coords[2]);
1395  cout << endl;
1396  cout << " D : ";
1397  printvec(coords[3]);
1398  cout << endl;
1399 
1400  cout << "DETECTOR DIMENSIONS (in cm):" << endl;
1401  cout << "================================" << endl;
1402  Double_t c = (coords[0] - coords[1]).Mag();
1403  Double_t b = (coords[1] - coords[2]).Mag();
1404  Double_t d = (coords[2] - coords[3]).Mag();
1405  Double_t a = (coords[0] - coords[3]).Mag();
1406  cout << " AB = " << c << endl;
1407  cout << " BC = " << b << endl;
1408  cout << " CD = " << d << endl;
1409  cout << " AD = " << a << endl;
1410 
1411  cout << "DETECTOR SURFACE AREA = ";
1412  Double_t surf = pow((a + b), 2.0) * (a - b + 2.0 * c) * (b - a + 2.0 * c);
1413  surf = sqrt(surf) / 400.0;
1414  cout << surf << " cm2" << endl;
1415 
1416  return surf;
1417 }
1418 
1419 
1420 
1425 
1427 {
1428  // Return pointer toTF1 giving residual energy after detector as function of incident energy,
1429  // for a given nucleus (Z,A).
1430  // The TF1::fNpx parameter is taken from environment variable KVDetector.ResidualEnergy.Npx
1431 
1432  if (!fEResF) {
1433  fEResF = new TF1(Form("KVDetector:%s:ERes", GetName()), this, &KVDetector::EResDet,
1434  0., 1.e+04, 2, "KVDetector", "EResDet");
1435  fEResF->SetNpx(gEnv->GetValue("KVDetector.ResidualEnergy.Npx", 20));
1436  }
1438  fEResF->SetRange(0., GetSmallestEmaxValid(Z, A));
1439  fEResF->SetTitle(Form("Residual energy [MeV] after detector %s for Z=%d A=%d", GetName(), Z, A));
1440 
1441  return fEResF;
1442 }
1443 
1444 
1445 
1450 
1452 {
1453  // Return pointer toTF1 giving range (in centimetres) in detector as function of incident energy,
1454  // for a given nucleus (Z,A).
1455  // The TF1::fNpx parameter is taken from environment variable KVDetector.Range.Npx
1456 
1457  if (!fRangeF) {
1458  fRangeF = new TF1(Form("KVDetector:%s:Range", GetName()), this, &KVDetector::RangeDet,
1459  0., 1.e+04, 2, "KVDetector", "RangeDet");
1460  fRangeF->SetNpx(gEnv->GetValue("KVDetector.Range.Npx", 20));
1461  }
1464  fRangeF->SetTitle(Form("Range [cm] in detector %s for Z=%d A=%d", GetName(), Z, A));
1465 
1466  return fRangeF;
1467 }
1468 
1469 
1470 
1475 
1477 {
1478  // Return pointer to TF1 giving energy loss in active layer of detector as function of incident energy,
1479  // for a given nucleus (Z,A).
1480  // The TF1::fNpx parameter is taken from environment variable KVDetector.EnergyLoss.Npx
1481 
1482  if (!fELossF) {
1483  fELossF = new TF1(Form("KVDetector:%s:ELossActive", GetName()), this, &KVDetector::ELossActive,
1484  0., 1.e+04, 2, "KVDetector", "ELossActive");
1485  fELossF->SetNpx(gEnv->GetValue("KVDetector.EnergyLoss.Npx", 20));
1486  }
1489  fELossF->SetTitle(Form("Energy loss [MeV] in detector %s for Z=%d A=%d", GetName(), Z, A));
1490  return fELossF;
1491 }
1492 
1493 
1494 
1499 
1501 {
1502  // Overrides KVMaterial::GetEIncOfMaxDeltaE
1503  // Returns incident energy corresponding to maximum energy loss in the
1504  // active layer of the detector, for a given nucleus.
1505 
1506  return GetELossFunction(Z, A)->GetMaximumX();
1507 }
1508 
1509 
1510 
1515 
1517 {
1518  // Overrides KVMaterial::GetMaxDeltaE
1519  // Returns maximum energy loss in the
1520  // active layer of the detector, for a given nucleus.
1521 
1522  return GetELossFunction(Z, A)->GetMaximum();
1523 }
1524 
1525 
1526 
1531 
1533 {
1534  // Overrides KVMaterial::GetDeltaE
1535  // Returns energy loss of given nucleus in the active layer of the detector.
1536 
1537  // optimization for single-layer detectors
1538  if (fSingleLayer) {
1539  return fActiveLayer->GetDeltaE(Z, A, Einc);
1540  }
1541  return GetELossFunction(Z, A)->Eval(Einc);
1542 }
1543 
1544 
1545 
1549 
1551 {
1552  // Returns calculated total energy loss of ion in ALL layers of the detector.
1553  // This is just (Einc - GetERes(Z,A,Einc))
1554 
1555  return Einc - GetERes(Z, A, Einc);
1556 }
1557 
1558 
1559 
1564 
1566 {
1567  // Overrides KVMaterial::GetERes
1568  // Returns residual energy of given nucleus after the detector.
1569  // Returns 0 if Einc<=0
1570 
1571  if (Einc <= 0.) return 0.;
1572  Double_t eres = GetEResFunction(Z, A)->Eval(Einc);
1573  // Eres function returns -1000 when particle stops in detector,
1574  // in order for function inversion (GetEIncFromEres) to work
1575  if (eres < 0.) eres = 0.;
1576  return eres;
1577 }
1578 
1579 
1580 
1603 
1605 {
1606  // Overrides KVMaterial::GetIncidentEnergy
1607  // Returns incident energy corresponding to energy loss delta_e in active layer of detector for a given nucleus.
1608  // If delta_e is not given, the current energy loss in the active layer is used.
1609  //
1610  // By default the solution corresponding to the highest incident energy is returned
1611  // This is the solution found for Einc greater than the maximum of the dE(Einc) curve.
1612  // If you want the low energy solution set SolType = KVIonRangeTable::kEmin.
1613  //
1614  // WARNING: calculating the incident energy of a particle using only the dE in a detector
1615  // is ambiguous, as in general (and especially for very heavy ions) the maximum of the dE
1616  // curve occurs for Einc greater than the punch-through energy, therefore it is not always
1617  // true to assume that if the particle does not stop in the detector the required solution
1618  // is that for type=KVIonRangeTable::kEmax. For a range of energies between punch-through
1619  // and dE_max, the required solution is still that for type=KVIonRangeTable::kEmin.
1620  // If the residual energy of the particle is unknown, there is no way to know which is the
1621  // correct solution.
1622  //
1623  // WARNING 2
1624  // If the given energy loss in the active layer is greater than the maximum theoretical dE
1625  // for given Z & A, (dE > GetMaxDeltaE(Z,A)) then we return a NEGATIVE incident energy
1626  // corresponding to the maximum, GetEIncOfMaxDeltaE(Z,A)
1627 
1628  if (Z < 1) return 0.;
1629 
1630  Double_t DE = (delta_e > 0 ? delta_e : GetEnergyLoss());
1631 
1632  // If the given energy loss in the active layer is greater than the maximum theoretical dE
1633  // for given Z & A, (dE > GetMaxDeltaE(Z,A)) then we return a NEGATIVE incident energy
1634  // corresponding to the maximum, GetEIncOfMaxDeltaE(Z,A)
1635  if (DE > GetMaxDeltaE(Z, A)) return -GetEIncOfMaxDeltaE(Z, A);
1636 
1637  TF1* dE = GetELossFunction(Z, A);
1638  Double_t e1, e2;
1639  dE->GetRange(e1, e2);
1640  switch (type) {
1641  case kEmin:
1642  e2 = GetEIncOfMaxDeltaE(Z, A);
1643  break;
1644  case kEmax:
1645  e1 = GetEIncOfMaxDeltaE(Z, A);
1646  break;
1647  }
1648  int status;
1649  Double_t EINC = ProtectedGetX(dE, DE, status, e1, e2);
1650  if (status != 0) {
1651 // Warning("GetIncidentEnergy",
1652 // "In %s : Called for Z=%d A=%d with dE=%f sol_type %d",
1653 // GetName(), Z, A, DE, type);
1654 // Warning("GetIncidentEnergy",
1655 // "Max DeltaE in this case is %f MeV",
1656 // GetMaxDeltaE(Z, A));
1657 // Warning("GetIncidentEnergy",
1658 // "Between Einc limits [%f,%f] no solution found",
1659 // e1,e2);
1660 // Warning("GetIncidentEnergy",
1661 // "Returned value is -Einc for %s dE, %f",
1662 // (status>0 ? "maximum" : "minimum"), EINC);
1663  return -EINC;
1664  }
1665  return EINC;
1666 }
1667 
1668 
1669 
1675 
1677 {
1678  // Overrides KVMaterial::GetDeltaEFromERes
1679  //
1680  // Calculate energy loss in active layer of detGetAlignedDetector for nucleus (Z,A)
1681  // having a residual kinetic energy Eres (MeV)
1682 
1683  if (Z < 1 || Eres <= 0.) return 0.;
1684  Double_t Einc = GetIncidentEnergyFromERes(Z, A, Eres);
1685  if (Einc <= 0.) return 0.;
1686  return GetELossFunction(Z, A)->Eval(Einc);
1687 }
1688 
1689 
1690 
1697 
1699 {
1700  // Overrides KVMaterial::GetIncidentEnergyFromERes
1701  //
1702  // Calculate incident energy of nucleus from residual energy.
1703  //
1704  // Returns -1 if Eres is out of defined range of values
1705 
1706  if (Z < 1 || Eres <= 0.) return 0.;
1707  //return GetEResFunction(Z, A)->GetX(Eres);
1708  Int_t status;
1709  Double_t einc = KVBase::ProtectedGetX(GetEResFunction(Z, A), Eres, status);
1710  if (status != 0) {
1711  // problem with inversion - value out of defined range of function
1712  return -1;
1713  }
1714  return einc;
1715 }
1716 
1717 
1718 
1722 
1724 {
1725  // Returns the smallest maximum energy for which range tables are valid
1726  // for all absorbers in the detector, and given ion (Z,A)
1727 
1728  Double_t maxmin = -1.;
1729  TIter next(fAbsorbers);
1730  KVMaterial* abs;
1731  while ((abs = (KVMaterial*)next())) {
1732  if (maxmin < 0.) maxmin = abs->GetEmaxValid(Z, A);
1733  else {
1734  if (abs->GetEmaxValid(Z, A) < maxmin) maxmin = abs->GetEmaxValid(Z, A);
1735  }
1736  }
1737  return maxmin;
1738 }
1739 
1740 
1741 
1759 
1761 {
1762  // Create detector from text file in 'TEnv' format.
1763  //
1764  // Example:
1765  // ========
1766  //
1767  // Layer: Gold
1768  // Gold.Material: Au
1769  // Gold.AreaDensity: 200.*KVUnits::ug
1770  // +Layer: Gas1
1771  // Gas1.Material: C3F8
1772  // Gas1.Thickness: 5.*KVUnits::cm
1773  // Gas1.Pressure: 50.*KVUnits::mbar
1774  // Gas1.Active: yes
1775  // +Layer: Si1
1776  // Si1.Material: Si
1777  // Si1.Thickness: 300.*KVUnits::um
1778 
1779  TEnv fEnvFile(envrc);
1780 
1781  KVString layers(fEnvFile.GetValue("Layer", ""));
1782  layers.Begin(" ");
1783  while (!layers.End()) {
1784  KVString layer = layers.Next();
1785  KVString mat = fEnvFile.GetValue(Form("%s.Material", layer.Data()), "");
1786  KVString tS = fEnvFile.GetValue(Form("%s.Thickness", layer.Data()), "");
1787  KVString pS = fEnvFile.GetValue(Form("%s.Pressure", layer.Data()), "");
1788  KVString dS = fEnvFile.GetValue(Form("%s.AreaDensity", layer.Data()), "");
1789  Double_t thick, dens, press;
1790  thick = dens = press = 0.;
1791  KVMaterial* M = 0;
1792  if (pS != "" && tS != "") {
1793  press = (Double_t)gROOT->ProcessLineFast(Form("%s*1.e+12", pS.Data()));
1794  press /= 1.e+12;
1795  thick = (Double_t)gROOT->ProcessLineFast(Form("%s*1.e+12", tS.Data()));
1796  thick /= 1.e+12;
1797  M = new KVMaterial(mat.Data(), thick, press);
1798  }
1799  else if (tS != "") {
1800  thick = (Double_t)gROOT->ProcessLineFast(Form("%s*1.e+12", tS.Data()));
1801  thick /= 1.e+12;
1802  M = new KVMaterial(mat.Data(), thick);
1803  }
1804  else if (dS != "") {
1805  dens = (Double_t)gROOT->ProcessLineFast(Form("%s*1.e+12", dS.Data()));
1806  dens /= 1.e+12;
1807  M = new KVMaterial(dens, mat.Data());
1808  }
1809  if (M) {
1810  AddAbsorber(M);
1811  if (fEnvFile.GetValue(Form("%s.Active", layer.Data()), kFALSE)) SetActiveLayer(M);
1812  }
1813  }
1814 }
1815 
1816 
1817 
1818 
1836 
1838 {
1839  // Returns list of detectors (including this one) which are in geometrical aligment
1840  // with respect to the target position (assuming this detector is part of a multidetector
1841  // array described by KVMultiDetArray).
1842  //
1843  // By default the list is in the order starting from this detector and going towards the target
1844  // (direction=KVGroup::kBackwards).
1845  // Call with argument direction=KVGroup::kForwards to have the list of detectors in the order
1846  // "seen" by a particle flying out from the target and arriving in this detector.
1847  //
1848  // If this detector is not part of a KVMultiDetArray (i.e. we have no information on
1849  // its geometrical relation to other detectors), we return 0x0.
1850  //
1851  // The list pointers are stored in member variable fAlignedDetectors[] for rapid retrieval,
1852  // the lists will be deleted with this detector.
1853  //
1854  // See KVGroup::GetAlignedDetectors for more details.
1855 
1856  if (!GetGroup() || direction > 1) return 0x0;
1857  if (fAlignedDetectors[direction]) return fAlignedDetectors[direction];
1858  return (fAlignedDetectors[direction] = GetGroup()->GetAlignedDetectors(this, direction));
1859 }
1860 
1861 
1862 
1863 
1865 
1867 {
1868  if (!GetGroup() || direction > 1) return;
1869  if (fAlignedDetectors[direction]) fAlignedDetectors[direction] = 0;
1870 }
1871 
1872 
1873 
1877 
1879 {
1880  // WARNING: SAME AS KVDetector::GetLinearRange
1881  // Only linear range in centimetres is calculated for detectors!
1882  return GetLinearRange(Z, A, Einc);
1883 }
1884 
1885 
1886 
1892 
1894 {
1895  // Returns range of ion in centimetres in this detector,
1896  // taking into account all layers.
1897  // Note that for Einc > punch through energy, this range is no longer correct
1898  // (but still > total thickness of detector).
1899  return GetRangeFunction(Z, A)->Eval(Einc);
1900 }
1901 
1902 
1903 
1907 
1909 {
1910  // Returns energy (in MeV) necessary for ion (Z,A) to punch through all
1911  // layers of this detector
1912 
1913  if (fSingleLayer) {
1914  // Optimize calculation time for single-layer detector
1915  return fActiveLayer->GetPunchThroughEnergy(Z, A);
1916  }
1917  return GetRangeFunction(Z, A)->GetX(GetTotalThicknessInCM());
1918 }
1919 
1920 
1921 
1922 
1927 
1929 {
1930  // Creates and fills a TGraph with the punch through energy in MeV vs. Z for the given detector,
1931  // for Z=1-92. The mass of each nucleus is calculated according to the given mass formula
1932  // (see KVNucleus).
1933 
1934  TGraph* punch = new TGraph(92);
1935  punch->SetName(Form("KVDetpunchthrough_%s_mass%d", GetName(), massform));
1936  punch->SetTitle(Form("Simple Punch-through %s (MeV) (mass formula %d)", GetName(), massform));
1937  KVNucleus nuc;
1938  nuc.SetMassFormula(massform);
1939  for (int Z = 1; Z <= 92; Z++) {
1940  nuc.SetZ(Z);
1941  punch->SetPoint(Z - 1, Z, GetPunchThroughEnergy(nuc.GetZ(), nuc.GetA()));
1942  }
1943  return punch;
1944 }
1945 
1946 
1947 
1952 
1954 {
1955  // Creates and fills a TGraph with the punch through energy in MeV/nucleon vs. Z for the given detector,
1956  // for Z=1-92. The mass of each nucleus is calculated according to the given mass formula
1957  // (see KVNucleus).
1958 
1959  TGraph* punch = new TGraph(92);
1960  punch->SetName(Form("KVDetpunchthroughEsurA_%s_mass%d", GetName(), massform));
1961  punch->SetTitle(Form("Simple Punch-through %s (AMeV) (mass formula %d)", GetName(), massform));
1962  KVNucleus nuc;
1963  nuc.SetMassFormula(massform);
1964  for (int Z = 1; Z <= 92; Z++) {
1965  nuc.SetZ(Z);
1966  punch->SetPoint(Z - 1, Z, GetPunchThroughEnergy(nuc.GetZ(), nuc.GetA()) / nuc.GetA());
1967  }
1968  return punch;
1969 }
1970 
1971 
1972 
1973 
1975 
1977 {
1978  return (KVGroup*)GetParentStructure("GROUP");
1979 }
1980 
1981 
1982 
1984 
1986 {
1987  return (GetGroup() ? GetGroup()->GetNumber() : 0);
1988 }
1989 
1990 
1991 
1993 
1995 {
1996  fParentStrucList.Add(elem);
1997 }
1998 
1999 
2000 
2002 
2004 {
2005  fParentStrucList.Remove(elem);
2006 }
2007 
2008 
2009 
2013 
2015 {
2016  // Get parent geometry structure element of given type.
2017  // Give unique name of structure if more than one element of same type is possible.
2018  KVGeoStrucElement* el = 0;
2019  if (strcmp(name, "")) {
2021  el = (KVGeoStrucElement*)strucs->FindObject(name);
2022  delete strucs;
2023  }
2024  else
2026  return el;
2027 }
2028 
2029 
2030 
2033 
2035 {
2036  // Set ROOT geometry global matrix transformation to coordinate frame of active layer volume
2037  SetMatrix(m);
2038 }
2039 
2040 
2041 
2044 
2046 {
2047  // Set ROOT geometry shape of active layer volume
2048  SetShape(s);
2049 }
2050 
2051 
2052 
2055 
2057 {
2058  // Set ROOT geometry global matrix transformation to coordinate frame of entrance window
2060 }
2061 
2062 
2063 
2066 
2068 {
2069  // Set ROOT geometry shape of entrance window
2071 }
2072 
2073 
2074 
2082 
2084 {
2085  // Overrides KVMaterial::SetThickness
2086  //
2087  // If ROOT geometry is defined, we modify the DZ thickness of the volume representing
2088  // this detector in accordance with the new thickness.
2089  //
2090  // This is only implemented for single-layer detectors with a simple shape.
2091 
2092  if (ROOTGeo() && fSingleLayer) {
2095  TGeoBBox* shape = (TGeoBBox*)pn->GetShape();
2096  TGeoShape* newshape = nullptr;
2097  // bad kludge - is there no better way to clone a shape and change its dZ?
2098  if (shape->IsA() == TGeoBBox::Class()) {
2099  newshape = new TGeoBBox(shape->GetDX(), shape->GetDY(), 0.5 * thick);
2100  }
2101  else if (shape->IsA() == TGeoTube::Class()) {
2102  TGeoTube* oldtube = static_cast<TGeoTube*>(shape);
2103  newshape = new TGeoTube(oldtube->GetRmin(), oldtube->GetRmax(), 0.5 * thick);
2104  }
2105  else {
2106  Error("SetThickness", "No implementation for %s (%s)", shape->IsA()->GetName(), GetName());
2107  }
2108  if (newshape) {
2109  pn->Align(nullptr, newshape);
2110  //Info("SetThickness", "Modified ROOT geometry for %s: new thickness=%g cm", GetName(), thick);
2112  }
2113  }
2114  KVMaterial::SetThickness(thick);
2115 }
2116 
2117 
2118 
2124 
2126 {
2127  // Return kTRUE if the two detectors have the same internal structure, i.e.
2128  // - the same number of absorber layers
2129  // - in the same order
2130  // - with the same material & thickness
2131 
2132  int nabs = GetNumberOfAbsorberLayers();
2133  if (other->GetNumberOfAbsorberLayers() != nabs) return kFALSE;
2134  bool same = true;
2135  for (int iabs = 0; iabs < nabs; ++iabs) {
2136  KVMaterial* this_abs = GetAbsorber(iabs);
2137  KVMaterial* other_abs = other->GetAbsorber(iabs);
2138  if (!this_abs->IsType(other_abs->GetType())
2139  || this_abs->GetMass() != other_abs->GetMass()
2140  || this_abs->GetThickness() != other_abs->GetThickness())
2141  same = false;
2142  }
2143  return same;
2144 }
2145 
2146 
2147 
2155 
2157 {
2158  // Add a new KVDetectorSignalExpression to this detector
2159  //
2160  // \param[in] type the name/type of the new signal
2161  // \param[in] _expr mathematical expression using any of the known signals of the detector
2162  //
2163  // \note If the expression is not valid, no signal will be created and method returns kFALSE.
2164 
2166  if (!ds->IsValid()) {
2167  delete ds;
2168  ds = nullptr;
2169  }
2170  else
2171  AddDetectorSignal(ds);
2172  return (ds != nullptr);
2173 }
2174 
2175 
int Int_t
unsigned int UInt_t
KVIonRangeTableMaterial * M
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
#define SafeDelete(p)
#define d(i)
#define b(i)
#define c(i)
#define e(i)
unsigned char UChar_t
char Char_t
const Bool_t kFALSE
bool Bool_t
double Double_t
float Float_t
const Bool_t kTRUE
const char Option_t
const Bool_t kIterBackward
R__EXTERN TEnv * gEnv
int type
R__EXTERN TGeoManager * gGeoManager
double pow(double, double)
#define gROOT
char * Form(const char *fmt,...)
virtual const Char_t * GetType() const
Definition: KVBase.h:176
virtual Bool_t IsType(const Char_t *typ) const
Definition: KVBase.h:184
virtual void SetType(const Char_t *str)
Definition: KVBase.h:172
Double_t ProtectedGetX(const TF1 *func, Double_t val, int &status, Double_t xmin=0.0, Double_t xmax=0.0) const
Definition: KVBase.cpp:1691
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition: KVBase.cpp:793
UInt_t GetNumber() const
Definition: KVBase.h:219
Output signal from detector obtained by calibration.
virtual Bool_t IsAvailableFor(const KVNameValueList &params) const
Base class for all detector calibrations.
Definition: KVCalibrator.h:98
TString GetInputSignalType() const
Definition: KVCalibrator.h:223
void SetDetector(KVDetector *d)
Definition: KVCalibrator.h:231
TString GetOutputSignalType() const
Definition: KVCalibrator.h:227
Signal output from a mathematical combination of other signals.
Base class for output signal data produced by a detector.
virtual Bool_t IsExpression() const
virtual Bool_t IsRaw() const
virtual Bool_t GetValueNeedsExtraParameters() const
virtual Double_t GetValue(const KVNameValueList &params="") const
virtual void Reset()
Base class for detector geometry description.
Definition: KVDetector.h:159
static KVDetector * MakeDetector(const Char_t *name, Float_t thick)
virtual const Char_t * GetArrayName()
Definition: KVDetector.cpp:439
virtual Bool_t IsOK() const
Definition: KVDetector.h:681
void SetMatrix(const TGeoHMatrix *m)
Definition: KVDetector.h:185
KVPosition fEWPosition
position of entrance window i.e. first volume in detector geometry
Definition: KVDetector.h:162
virtual Double_t GetMaxDeltaE(Int_t Z, Int_t A)
@ kIdentifiedParticle
Definition: KVDetector.h:176
@ kUnidentifiedParticle
Definition: KVDetector.h:175
KVUniqueNameList fParentStrucList
list of geometry structures which directly contain this detector
Definition: KVDetector.h:163
Int_t GetNumberOfAbsorberLayers() const
Definition: KVDetector.h:304
virtual void GetVerticesInOwnFrame(TVector3 *, Double_t, Double_t)
virtual Double_t GetERes(Int_t Z, Int_t A, Double_t Einc)
virtual Double_t GetELostByParticle(KVNucleus *, TVector3 *norm=0)
Definition: KVDetector.cpp:276
Double_t ELossActive(Double_t *x, Double_t *par)
Definition: KVDetector.cpp:980
TList * GetTelescopesForIdentification()
Definition: KVDetector.cpp:761
virtual void AddIDTelescope(TObject *idt)
Add ID telescope to list of telescopes to which detector belongs.
Definition: KVDetector.cpp:722
KVList * GetAlignedIDTelescopes()
Definition: KVDetector.cpp:736
KVList * fCalibrators
list of associated calibrator objects
Definition: KVDetector.h:233
KVGeoStrucElement * GetParentStructure(const Char_t *type, const Char_t *name="") const
KVGroup * GetGroup() const
void AddDetectorSignal(KVDetectorSignal *ds)
Definition: KVDetector.h:260
virtual Double_t GetRange(Int_t Z, Int_t A, Double_t Einc)
virtual void SetEnergyLoss(Double_t e) const
Definition: KVDetector.h:372
Bool_t ReplaceCalibrator(const Char_t *type, KVCalibrator *cal, const KVNameValueList &opts="")
Definition: KVDetector.cpp:551
virtual Double_t GetTotalDeltaE(Int_t Z, Int_t A, Double_t Einc)
virtual TGeoVolume * GetGeoVolume()
virtual Double_t GetEnergy() const
Definition: KVDetector.h:348
virtual TF1 * GetEResFunction(Int_t Z, Int_t A)
virtual Double_t GetEIncOfMaxDeltaE(Int_t Z, Int_t A)
virtual TGraph * DrawPunchThroughEsurAVsZ(Int_t massform=KVNucleus::kBetaMass)
static Int_t fDetCounter
Definition: KVDetector.h:165
void AddAbsorber(KVMaterial *)
Definition: KVDetector.cpp:629
virtual Double_t GetEnergyLoss() const
Definition: KVDetector.h:368
virtual Double_t GetEResAfterDetector() const
Definition: KVDetector.h:633
KVList * fIDTelescopes
list of ID telescopes to which detector belongs
Definition: KVDetector.h:167
void SetShape(TGeoBBox *s)
Definition: KVDetector.h:189
void AddParentStructure(KVGeoStrucElement *elem)
Double_t GetTheta() const
Definition: KVDetector.h:743
Double_t fEResforEinc
used by GetIncidentEnergy & GetCorrectedEnergy
Definition: KVDetector.h:251
KVList * fIDTelAlign
list of ID telescopes made of this detector and all aligned detectors placed in front of it
Definition: KVDetector.h:168
virtual Int_t FindZmin(Double_t ELOSS=-1., Char_t mass_formula=-1)
Definition: KVDetector.cpp:906
TF1 * fELossF
parametric function dE in active layer vs. incident energy
Definition: KVDetector.h:247
TList * fAlignedDetectors[2]
stores lists of aligned detectors in both directions
Definition: KVDetector.h:252
virtual void Clear(Option_t *opt="")
Definition: KVDetector.cpp:596
const KVPosition & GetEntranceWindow() const
Definition: KVDetector.h:700
KVMaterial * GetAbsorber(Int_t i) const
Returns pointer to the i-th absorber in the detector (i=0 first absorber, i=1 second,...
Definition: KVDetector.cpp:645
void ClearHits()
Definition: KVDetector.h:429
void remove_signal_for_calibrator(KVCalibrator *K)
Definition: KVDetector.cpp:677
KVList * fAbsorbers
list of absorbers making up the detector
Definition: KVDetector.h:235
TList * fIDTele4Ident
list of ID telescopes used for particle ID
Definition: KVDetector.h:169
TF1 * fEResF
parametric function Eres residual energy after all layers of detector
Definition: KVDetector.h:248
virtual Double_t GetSmallestEmaxValid(Int_t Z, Int_t A)
Bool_t HasSameStructureAs(const KVDetector *) const
void SetThickness(Double_t thick)
virtual void AddToGeometry()
UInt_t GetGroupNumber()
virtual Double_t GetIncidentEnergy(Int_t Z, Int_t A, Double_t delta_e=-1.0, enum SolType type=kEmax)
virtual KVDetectorSignal * GetDetectorSignal(const KVString &type) const
Definition: KVDetector.h:532
virtual void ReadDefinitionFromFile(const Char_t *)
Double_t GetTotalThicknessInCM()
Definition: KVDetector.h:314
Bool_t IsCalibrated() const
Definition: KVDetector.h:389
virtual TF1 * GetELossFunction(Int_t Z, Int_t A)
void SetActiveLayer(KVMaterial *actif)
Definition: KVDetector.h:284
KVDetector()
default ctor
Definition: KVDetector.cpp:76
Bool_t BelongsToUnidentifiedParticle() const
Definition: KVDetector.h:570
Double_t RangeDet(Double_t *x, Double_t *par)
KVMaterial * GetActiveLayer() const
Definition: KVDetector.h:289
virtual void RemoveCalibrators()
Definition: KVDetector.cpp:699
virtual Double_t GetEntranceWindowSurfaceArea()
Return surface area of first layer of detector in cm2.
virtual TGraph * DrawPunchThroughEnergyVsZ(Int_t massform=KVNucleus::kBetaMass)
KVUniqueNameList fDetSignals
list of signals associated with detector
Definition: KVDetector.h:226
Double_t GetPhi() const
Definition: KVDetector.h:761
virtual Double_t GetPunchThroughEnergy(Int_t Z, Int_t A)
Int_t fUnidentP
temporary counters, determine state of identified/unidentified particle flags
Definition: KVDetector.h:180
TF1 * fRangeF
parametric function range of particles in detector
Definition: KVDetector.h:249
Bool_t AddDetectorSignalExpression(const KVString &type, const KVString &_expr)
virtual Double_t GetParticleEIncFromERes(KVNucleus *, TVector3 *norm=0)
Definition: KVDetector.cpp:328
virtual void SetEResAfterDetector(Double_t e)
Definition: KVDetector.h:629
void SetActiveLayerMatrix(const TGeoHMatrix *)
Set ROOT geometry global matrix transformation to coordinate frame of active layer volume.
virtual void Copy(TObject &obj) const
Definition: KVDetector.cpp:127
void RemoveParentStructure(KVGeoStrucElement *elem)
const KVSeqCollection & GetListOfDetectorSignals() const
Definition: KVDetector.h:785
KVList * fParticles
list of particles hitting detector in an event
Definition: KVDetector.h:234
virtual TList * GetAlignedDetectors(UInt_t direction=1)
KVGeoDetectorNode * GetNode()
Definition: KVDetector.h:325
void SetEntranceWindowMatrix(const TGeoHMatrix *)
Set ROOT geometry global matrix transformation to coordinate frame of entrance window.
virtual Double_t GetDeltaE(Int_t Z, Int_t A, Double_t Einc)
Double_t EResDet(Double_t *x, Double_t *par)
Double_t fDepthInTelescope
used to store depth of detector in parent telescope
Definition: KVDetector.h:241
KVMaterial * fActiveLayer
The active absorber in the detector.
Definition: KVDetector.h:166
void AddHit(KVNucleus *part)
Definition: KVDetector.h:404
KVCalibrator * GetCalibrator(const Char_t *name, const Char_t *type) const
Definition: KVDetector.h:814
virtual Double_t GetIncidentEnergyFromERes(Int_t Z, Int_t A, Double_t Eres)
Int_t fIdentP
temporary counters, determine state of identified/unidentified particle flags
Definition: KVDetector.h:179
virtual Double_t GetDeltaEFromERes(Int_t Z, Int_t A, Double_t Eres)
void SetEntranceWindowShape(TGeoBBox *)
Set ROOT geometry shape of entrance window.
void ResetAlignedDetectors(UInt_t direction=1)
virtual void DetectParticle(KVNucleus *, TVector3 *norm=0)
Definition: KVDetector.cpp:203
void SetActiveLayerShape(TGeoBBox *)
Set ROOT geometry shape of active layer volume.
void SetAnalysed(Bool_t b=kTRUE)
Definition: KVDetector.h:446
TString fFName
dynamically generated full name of detector
Definition: KVDetector.h:232
virtual void Print(Option_t *option="") const
Definition: KVDetector.cpp:364
Bool_t fSingleLayer
=kTRUE if detector has a single absorber layer
Definition: KVDetector.h:258
virtual Double_t GetLinearRange(Int_t Z, Int_t A, Double_t Einc)
virtual TF1 * GetRangeFunction(Int_t Z, Int_t A)
virtual Double_t GetCorrectedEnergy(KVNucleus *, Double_t e=-1., Bool_t transmission=kTRUE)
Definition: KVDetector.cpp:810
void init()
default initialisations
Definition: KVDetector.cpp:38
Bool_t AddCalibrator(KVCalibrator *cal, const KVNameValueList &opts="")
Definition: KVDetector.cpp:478
Double_t fTotThickness
used to store value calculated by GetTotalThicknessInCM
Definition: KVDetector.h:240
TGeoBBox * GetShape() const
Definition: KVDetector.h:197
virtual void SetMaterial(const Char_t *type)
Definition: KVDetector.cpp:177
Path taken by particles through multidetector geometry.
const KVSeqCollection * GetIDTelescopes() const
const Char_t * GetFullPathToNode() const
Base class describing elements of array geometry.
Group of detectors which can be treated independently of all others in array.
Definition: KVGroup.h:19
const KVGeoDNTrajectory * GetTrajectoryForReconstruction(const KVGeoDNTrajectory *t, const KVGeoDetectorNode *n) const
Definition: KVGroup.h:103
Extended TList class which owns its objects by default.
Definition: KVList.h:27
Description of physical materials used to construct detectors & targets; interface to range tables.
Definition: KVMaterial.h:93
virtual void SetThickness(Double_t thick)
Definition: KVMaterial.cpp:454
virtual Double_t GetThickness() const
Definition: KVMaterial.cpp:487
virtual TGeoMedium * GetGeoMedium(const Char_t *="")
virtual void Print(Option_t *option="") const
Show information on this material.
Definition: KVMaterial.cpp:742
Double_t GetEmaxValid(Int_t Z, Int_t A)
virtual Double_t GetPunchThroughEnergy(Int_t Z, Int_t A)
virtual Double_t GetParticleEIncFromERes(KVNucleus *, TVector3 *norm=nullptr)
Definition: KVMaterial.cpp:804
virtual void SetMaterial(const Char_t *type)
Definition: KVMaterial.cpp:225
virtual Double_t GetERes(Int_t Z, Int_t A, Double_t Einc)
virtual Double_t GetDeltaE(Int_t Z, Int_t A, Double_t Einc)
Definition: KVMaterial.cpp:835
virtual void Clear(Option_t *opt="")
Reset absorber - set stored energy lost by particles in absorber to zero.
KVMaterial()
default ctor
Definition: KVMaterial.cpp:77
Double_t GetEffectiveThickness(TVector3 &norm, TVector3 &direction)
Definition: KVMaterial.cpp:700
virtual Double_t GetLinearRange(Int_t Z, Int_t A, Double_t Einc)
Definition: KVMaterial.cpp:902
Double_t GetMass() const
Definition: KVMaterial.cpp:305
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
void SetValue(const Char_t *name, value_type value)
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:125
Int_t GetA() const
Definition: KVNucleus.cpp:799
void SetZ(Int_t z, Char_t mt=-1)
Definition: KVNucleus.cpp:704
void SetMassFormula(UChar_t mt)
Definition: KVNucleus.h:344
Int_t GetZ() const
Return the number of proton / atomic number.
Definition: KVNucleus.cpp:770
TVector3 * GetPInitial() const
Definition: KVParticle.h:728
TVector3 GetMomentum() const
Definition: KVParticle.h:606
KVNameValueList * GetParameters() const
Definition: KVParticle.h:816
void SetMomentum(const TVector3 &v)
Definition: KVParticle.h:576
Double_t GetEnergy() const
Definition: KVParticle.h:623
void SetKE(Double_t ecin)
Definition: KVParticle.cpp:230
void SetE0(TVector3 *e=0)
Definition: KVParticle.h:717
void SetIsDetected()
Definition: KVParticle.h:732
Double_t GetKE() const
Definition: KVParticle.h:616
void SetEnergy(Double_t e)
Definition: KVParticle.h:601
Base class used for handling geometry in a multidetector array.
Definition: KVPosition.h:90
virtual void SetShape(TGeoBBox *)
Definition: KVPosition.cpp:743
Bool_t ROOTGeo() const
Returns kTRUE if ROOT geometry is used, kFALSE if not.
Definition: KVPosition.cpp:598
void GetCornerCoordinates(TVector3 *, Double_t=0)
Definition: KVPosition.cpp:496
virtual Double_t GetDistance(void) const
Definition: KVPosition.h:189
virtual Double_t GetSurfaceArea(int npoints=100000) const
Definition: KVPosition.cpp:974
virtual void SetMatrix(const TGeoHMatrix *)
Definition: KVPosition.cpp:702
virtual TGeoBBox * GetShape() const
Definition: KVPosition.cpp:790
void GetCornerCoordinatesInOwnFrame(TVector3 *, Double_t=0)
Definition: KVPosition.cpp:544
KaliVeda extensions to ROOT collection classes.
virtual void Clear(Option_t *option="")
virtual Int_t GetSize() const
virtual TObject * At(Int_t idx) const
KVSeqCollection * GetSubListWithType(const Char_t *retvalue) const
virtual TObject * FindObjectByType(const Char_t *) const
virtual void Add(TObject *obj)
virtual TObject * Remove(TObject *obj)
Remove object from list.
virtual void Delete(Option_t *option="")
virtual TObject * FindObject(const char *name) const
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
void Begin(TString delim) const
Definition: KVString.cpp:565
void RBegin(TString delim) const
Definition: KVString.cpp:768
Bool_t End() const
Definition: KVString.cpp:634
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:695
KVString RNext(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:841
Associates two detectors placed one behind the other.
Definition: KVTelescope.h:35
Int_t GetDetectorRank(KVDetector *kvd)
returns position (1=front, 2=next, etc.) detector in the telescope structure
Double_t GetDepthInCM(Int_t ndet) const
Definition: KVTelescope.h:73
virtual void Add(TObject *obj)
Handle several calibrations valid for different Z ranges.
virtual void ls(Option_t *option="") const
virtual void Print(Option_t *option, const char *wildcard, Int_t recurse=1) const
virtual void AddAll(const TCollection *col)
virtual Int_t GetEntries() const
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void SetTitle(const char *title="")
virtual void SetRange(Double_t xmin, Double_t xmax)
virtual void SetNpx(Int_t npx=100)
virtual Double_t GetX(Double_t y, Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual void GetRange(Double_t &xmin, Double_t &xmax) const
virtual void SetParameters(const Double_t *params)
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
virtual Double_t GetMaximum(Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual Double_t GetMaximumX(Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual Double_t GetDX() const
virtual Double_t GetFacetArea(Int_t index=0) const
virtual Double_t GetDY() const
TGeoVolume * MakeArb8(const char *name, TGeoMedium *medium, Double_t dz, Double_t *vertices=0)
void RefreshPhysicalNodes(Bool_t lock=kTRUE)
TObjArray * GetListOfPhysicalNodes()
TGeoVolumeAssembly * MakeVolumeAssembly(const char *name)
TGeoVolume * GetTopVolume() const
TGeoPhysicalNode * MakePhysicalNode(const char *path=0)
virtual Int_t GetDefaultColor() const
TGeoMaterial * GetMaterial() const
Bool_t Align(TGeoMatrix *newmat=0, TGeoShape *newshape=0, Bool_t check=kFALSE, Double_t ovlp=0.001)
TGeoShape * GetShape(Int_t level=-1) const
void SetAngles(Double_t phi, Double_t theta, Double_t psi)
virtual const char * GetName() const
virtual Double_t GetRmin() const
virtual Double_t GetRmax() const
virtual void SetLineColor(Color_t lcolor)
virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
virtual void SetName(const char *name="")
virtual void SetTitle(const char *title="")
void Reset()
virtual void Add(TObject *obj)
virtual void Clear(Option_t *option="")
virtual const char * GetName() const
virtual void SetName(const char *name)
virtual TObject * Clone(const char *newname="") const
virtual TObject * FindObject(const char *name) const
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Error(const char *method, const char *msgfmt,...) const
void ResetBit(UInt_t f)
Longptr_t ExecPlugin(int nargs, const T &... params)
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Double_t Y() const
Double_t X() const
VecExpr< UnaryOp< Sqrt< T >, SVector< T, D >, T >, T, D > sqrt(const SVector< T, D > &rhs)
T Mag(const SVector< T, D > &rhs)
Double_t x[n]
gr SetName("gr")
TH1 * h
const long double s
Definition: KVUnits.h:94
const long double m
Definition: KVUnits.h:70
double T(double x)
double dist(AxisAngle const &r1, AxisAngle const &r2)
constexpr Double_t K()
v
auto * a