1 #include "KVDetector.h"
4 #include "KVCalibrator.h"
14 #include "KVCalibratedSignal.h"
15 #include "KVDetectorSignalExpression.h"
16 #include "KVZDependentCalibratedSignal.h"
17 #include "KVMaterialStack.h"
34 fCalibrators =
nullptr;
36 fActiveLayer =
nullptr;
37 fIdentP = fUnidentP = 0;
38 fELossF = fEResF = fRangeF =
nullptr;
43 fParentStrucList.SetCleanup();
45 fNode.SetDetector(
this);
47 fDetSignals.SetOwner();
50 fDetSignals.ReplaceObjects();
114 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
122 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
138 TIter next(&fAbsorbers);
144 Int_t in_actif = fAbsorbers.IndexOf(fActiveLayer);
153 KVDetector::~KVDetector()
208 if (kvp->
GetKE() <= 0.)
219 std::vector<Double_t> thickness;
229 thickness[i++] =
abs->GetThickness();
231 abs->SetThickness(
T);
242 abs->SetThickness(thickness[i++]);
279 std::vector<Double_t> thickness;
289 thickness[i++] =
abs->GetThickness();
291 abs->SetThickness(
T);
301 abs->SetThickness(thickness[i++]);
341 Einc =
abs->GetParticleEIncFromERes(&clone_part, norm);
344 clone_part.
SetKE(Einc);
361 if (!strcmp(opt,
"data")) {
380 cout <<
"(Belongs to an unidentified particle)";
383 else if (!strcmp(opt,
"all")) {
394 cout <<
" ### ACTIVE LAYER ### " << endl;
398 cout <<
" #################### " << endl;
401 cout <<
option <<
" --- Detected particles:" << endl;
470 Error(
"AddCalibrator",
"Detector:%s has no signal %s, required as input by calibrator %s to provide output %s",
482 Warning(
"AddCalibrator",
"%s : output signal not defined for calibrator %s. No output signal created.",
573 bool option_N = (strncmp(opt,
"N", 1) == 0);
574 bool sim_mode_option_N = option_N &&
IsSimMode();
589 if (!sim_mode_option_N) {
628 Error(
"GetAbsorber",
"No absorbers defined for detector");
632 Error(
"GetAbsorber",
"i=%d but valid values are 0-%d [number of absorbers in list]", i,
684 if (
K->GetOutputSignalType() !=
"") {
869 ELOSS = (ELOSS < 0. ?
GetEnergy() : ELOSS);
870 if (ELOSS <= 0)
return 0;
877 UInt_t last_positive_difference_z = 1;
879 if (mass_formula > -1)
884 while (zmax > zmin + 1) {
890 if (difference < 0.0) {
893 z += (
UInt_t)((zmax - z) / 2 + 0.5);
899 last_positive_difference_z = z;
900 z -= (
UInt_t)((z - zmin) / 2 + 0.5);
904 if (difference < 0) {
907 z = last_positive_difference_z;
991 Einc = mat->
GetERes(Z, A, Einc);
1084 if (!(ph =
LoadPlugin(
"KVDetector", det_type))) {
1126 0., 1.e+04, 2,
"KVDetector",
"EResDet");
1151 0., 1.e+04, 2,
"KVDetector",
"RangeDet");
1176 0., 1.e+04, 2,
"KVDetector",
"ELossActive");
1247 return Einc -
GetERes(Z, A, Einc);
1263 if (Einc <= 0.)
return 0.;
1267 if (eres < 0.) eres = 0.;
1320 if (Z < 1)
return 0.;
1375 if (Z < 1 || Eres <= 0.)
return 0.;
1377 if (Einc <= 0.)
return 0.;
1398 if (Z < 1 || Eres <= 0.)
return 0.;
1424 if (maxmin < 0.) maxmin =
abs->GetEmaxValid(Z, A);
1426 if (
abs->GetEmaxValid(Z, A) < maxmin) maxmin =
abs->GetEmaxValid(Z, A);
1471 TEnv fEnvFile(envrc);
1475 while (!layers.
End()) {
1482 thick = dens = press = 0.;
1484 if (pS !=
"" && tS !=
"") {
1491 else if (tS !=
"") {
1496 else if (dS !=
"") {
1572 punch->
SetTitle(
Form(
"Simple Punch-through %s (MeV) (mass formula %d)",
GetName(), massform));
1575 for (
int Z = 1; Z <= 92; Z++) {
1597 punch->
SetTitle(
Form(
"Simple Punch-through %s (AMeV) (mass formula %d)",
GetName(), massform));
1600 for (
int Z = 1; Z <= 92; Z++) {
1655 if (strcmp(
name,
"")) {
1750 newshape =
new TGeoArb8(0.5 * thick, vert);
1756 pn->
Align(
nullptr, newshape);
1781 for (
int iabs = 0; iabs < nabs; ++iabs) {
1818 return (ds !=
nullptr);
const Bool_t kIterBackward
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 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
R__EXTERN TGeoManager * gGeoManager
char * Form(const char *fmt,...)
virtual const Char_t * GetType() const
void Error(const char *method, const char *msgfmt,...) const override
virtual Bool_t IsType(const Char_t *typ) const
virtual void SetType(const Char_t *str)
Double_t ProtectedGetX(const TF1 *func, Double_t val, int &status, Double_t xmin=0.0, Double_t xmax=0.0) const
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
void Warning(const char *method, const char *msgfmt,...) const override
Output signal from detector obtained by calibration.
Bool_t IsAvailableFor(const KVNameValueList ¶ms) const override
Base class for all detector calibrations.
TString GetInputSignalType() const
void SetDetector(KVDetector *d)
TString GetOutputSignalType() const
Signal output from a mathematical combination of other signals.
Bool_t IsValid() const override
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 ¶ms="") const
Base class for detector geometry description, interface to energy-loss calculations.
static KVDetector * MakeDetector(const Char_t *name, Float_t thick)
void SetThickness(Double_t thick) override
virtual Bool_t IsSimMode() const
virtual Bool_t IsOK() const
KVPosition fEWPosition
position of entrance window i.e. first volume in detector geometry
KVMaterial * GetActiveLayer() const override
KVUniqueNameList fParentStrucList
list of geometry structures which directly contain this detector
Int_t GetNumberOfAbsorberLayers() const
void SetMaterial(const Char_t *type) override
Double_t ELossActive(Double_t *x, Double_t *par)
void SetTemperature(Double_t T) override
KVList * fCalibrators
list of associated calibrator objects
KVGeoStrucElement * GetParentStructure(const Char_t *type, const Char_t *name="") const
KVGroup * GetGroup() const
void AddDetectorSignal(KVDetectorSignal *ds)
Double_t GetRange(Int_t Z, Int_t A, Double_t Einc) override
Double_t GetIncidentEnergyFromERes(Int_t Z, Int_t A, Double_t Eres) override
Bool_t fDetecting
=kTRUE if detector is "detecting", =kFALSE if not
Bool_t ReplaceCalibrator(const Char_t *type, KVCalibrator *cal, const KVNameValueList &opts="")
virtual Double_t GetTotalDeltaE(Int_t Z, Int_t A, Double_t Einc)
virtual Double_t GetEnergy() const
virtual TF1 * GetEResFunction(Int_t Z, Int_t A)
virtual TGraph * DrawPunchThroughEsurAVsZ(Int_t massform=KVNucleus::kBetaMass)
void AddAbsorber(KVMaterial *)
virtual Double_t GetEResAfterDetector() const
Double_t GetIncidentEnergy(Int_t Z, Int_t A, Double_t delta_e=-1.0, enum SolType type=kEmax) override
Double_t GetPunchThroughEnergy(Int_t Z, Int_t A) override
void AddParentStructure(KVGeoStrucElement *elem)
Double_t GetDeltaE(Int_t Z, Int_t A, Double_t Einc, Double_t=0.) override
Double_t fEResforEinc
used by GetIncidentEnergy & GetCorrectedEnergy
void Print(Option_t *option="") const override
virtual Int_t FindZmin(Double_t ELOSS=-1., Char_t mass_formula=-1)
TF1 * fELossF
parametric function dE in active layer vs. incident energy
Double_t GetLinearRange(Int_t Z, Int_t A, Double_t Einc) override
const KVPosition & GetEntranceWindow() const
KVMaterial * GetAbsorber(Int_t i) const
Returns pointer to the i-th absorber in the detector (i=0 first absorber, i=1 second,...
void SetEnergyLoss(Double_t e) const override
void remove_signal_for_calibrator(KVCalibrator *K)
TF1 * fEResF
parametric function Eres residual energy after all layers of detector
Bool_t HasSameStructureAs(const KVDetector *) const
virtual KVDetectorSignal * GetDetectorSignal(const KVString &type) const
virtual void ReadDefinitionFromFile(const Char_t *)
Bool_t IsCalibrated() const
Double_t GetEnergyLoss() const override
void SetShape(TGeoBBox *s) override
void Copy(TObject &obj) const override
virtual TF1 * GetELossFunction(Int_t Z, Int_t A)
void SetActiveLayer(KVMaterial *actif)
Bool_t BelongsToUnidentifiedParticle() const
void DetectParticle(KVNucleus *, TVector3 *norm=0) override
Double_t RangeDet(Double_t *x, Double_t *par)
Double_t GetParticleEIncFromERes(KVNucleus *, TVector3 *norm=0) override
virtual void RemoveCalibrators()
virtual Double_t GetEntranceWindowSurfaceArea()
Return surface area of first layer of detector in cm2.
TGeoBBox * GetShape() const override
virtual TGraph * DrawPunchThroughEnergyVsZ(Int_t massform=KVNucleus::kBetaMass)
KVUniqueNameList fDetSignals
list of signals associated with detector
Double_t get_corrected_energy(AbsorberStack *stack, KVNucleus *nuc, Double_t e, Bool_t transmission)
Int_t fUnidentP
temporary counters, determine state of identified/unidentified particle flags
TF1 * fRangeF
parametric function range of particles in detector
Bool_t AddDetectorSignalExpression(const KVString &type, const KVString &_expr)
virtual void SetEResAfterDetector(Double_t e)
void SetActiveLayerMatrix(const TGeoHMatrix *)
Set ROOT geometry global matrix transformation to coordinate frame of active layer volume.
Double_t GetERes(Int_t Z, Int_t A, Double_t Einc, Double_t=0.) override
Double_t GetMaxDeltaE(Int_t Z, Int_t A) override
void RemoveParentStructure(KVGeoStrucElement *elem)
virtual Double_t GetSmallestEmaxValid(Int_t Z, Int_t A) const
const KVSeqCollection & GetListOfDetectorSignals() const
KVList * fParticles
list of particles hitting detector in an event
KVGeoDetectorNode * GetNode()
Bool_t fSimMode
=kTRUE when using to simulate detector response, =kFALSE when analysing data
Double_t GetDeltaEFromERes(Int_t Z, Int_t A, Double_t Eres) override
void SetMatrix(const TGeoHMatrix *m) override
void SetEntranceWindowMatrix(const TGeoHMatrix *)
Set ROOT geometry global matrix transformation to coordinate frame of entrance window.
Double_t EResDet(Double_t *x, Double_t *par)
KVMaterial * fActiveLayer
The active absorber in the detector.
void AddHit(KVNucleus *part)
void RemoveAllAbsorbers()
Double_t GetEIncOfMaxDeltaE(Int_t Z, Int_t A) override
Double_t GetTotalThicknessInCM() const
KVCalibrator * GetCalibrator(const Char_t *name, const Char_t *type) const
Int_t fIdentP
temporary counters, determine state of identified/unidentified particle flags
void SetPressure(Double_t P) override
Double_t GetELostByParticle(KVNucleus *, TVector3 *norm=0) override
void SetEntranceWindowShape(TGeoBBox *)
Set ROOT geometry shape of entrance window.
Bool_t fPresent
=kTRUE if detector is present, =kFALSE if it has been removed
void SetActiveLayerShape(TGeoBBox *)
Set ROOT geometry shape of active layer volume.
void SetAnalysed(Bool_t b=kTRUE)
Bool_t fSingleLayer
=kTRUE if detector has a single absorber layer
virtual TF1 * GetRangeFunction(Int_t Z, Int_t A)
virtual Double_t GetCorrectedEnergy(KVNucleus *, Double_t e=-1., Bool_t transmission=kTRUE)
void init()
default initialisations
void Clear(Option_t *opt="") override
KVList fAbsorbers
list of absorbers making up the detector
Bool_t AddCalibrator(KVCalibrator *cal, const KVNameValueList &opts="")
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.
Extended TList class which owns its objects by default.
A stack of materials in which successive energy losses of charged particles can be calculated ,...
Double_t GetMinimumIncidentAngleForDEMax(Int_t Z, Int_t A, Double_t Emax)
void SetIncidenceAngle(double psi)
Double_t GetMaxDeltaE(Int_t Z, Int_t A)
Description of physical materials used to construct detectors & targets; interface to range tables.
virtual void SetPressure(Double_t)
virtual void SetTemperature(Double_t)
virtual void SetThickness(Double_t thick)
virtual Double_t GetThickness() const
virtual TGeoMedium * GetGeoMedium(const Char_t *="")
void Clear(Option_t *opt="") override
Reset absorber - set stored energy lost by particles in absorber to zero.
virtual Double_t GetPunchThroughEnergy(Int_t Z, Int_t A)
virtual void SetMaterial(const Char_t *type)
virtual Double_t GetERes(Int_t Z, Int_t A, Double_t Einc, Double_t dx=0.)
virtual Double_t GetDeltaE(Int_t Z, Int_t A, Double_t Einc, Double_t dx=0.)
virtual Double_t GetLinearRange(Int_t Z, Int_t A, Double_t Einc)
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 * GetStringValue(const Char_t *name) const
Bool_t HasDoubleParameter(const Char_t *name) const
Bool_t HasParameter(const Char_t *name) const
Description of properties and kinematics of atomic nuclei.
void SetZ(Int_t z, Char_t mt=-1)
void SetMassFormula(UChar_t mt)
Int_t GetZ() const
Return the number of proton / atomic number.
TVector3 * GetPInitial() const
TVector3 GetMomentum() const
KVNameValueList * GetParameters() const
Double_t GetEnergy() const
void SetKE(Double_t ecin)
void SetMomentum(const TVector3 *v)
void SetE0(TVector3 *e=0)
void SetEnergy(Double_t e)
Base class used for handling geometry in a multidetector array.
virtual void SetShape(TGeoBBox *)
virtual Bool_t ROOTGeo() const
Returns kTRUE if ROOT geometry is used, kFALSE if not.
virtual Double_t GetSurfaceArea(int npoints=100000) const
virtual void SetMatrix(const TGeoHMatrix *)
virtual TGeoBBox * GetShape() const
KaliVeda extensions to ROOT collection classes.
TObject * Remove(TObject *obj) override
Remove object from list.
void Add(TObject *obj) override
TObject * FindObject(const char *name) const override
KVSeqCollection * GetSubListWithType(const Char_t *retvalue) const
Int_t GetSize() const override
void Clear(Option_t *option="") override
virtual TObject * FindObjectByType(const Char_t *) const
TObject * At(Int_t idx) const override
void Delete(Option_t *option="") override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
void RBegin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
KVString RNext(Bool_t strip_whitespace=kFALSE) const
void Add(TObject *obj) override
Handle several calibrations valid for different Z ranges.
virtual void Print(Option_t *option, const char *wildcard, Int_t recurse=1) const
virtual Int_t GetEntries() const
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void SetRange(Double_t xmin, Double_t xmax)
void SetTitle(const char *title="") override
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
TClass * IsA() const override
void RefreshPhysicalNodes(Bool_t lock=kTRUE)
TGeoPhysicalNode * MakePhysicalNode(const char *path=nullptr)
TObjArray * GetListOfPhysicalNodes()
Bool_t Align(TGeoMatrix *newmat=nullptr, TGeoShape *newshape=nullptr, Bool_t check=kFALSE, Double_t ovlp=0.001)
TGeoVolume * GetVolume(Int_t level=-1) const
TGeoShape * GetShape(Int_t level=-1) const
virtual Double_t GetRmin() const
virtual Double_t GetRmax() const
virtual void SetMedium(TGeoMedium *medium)
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
void SetName(const char *name="") override
void SetTitle(const char *title="") override
TObject * Clone(const char *newname="") const override
const char * GetName() const override
virtual void SetName(const char *name)
TObject * FindObject(const char *name) const override
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual const char * ClassName() const
virtual Bool_t InheritsFrom(const char *classname) const
Longptr_t ExecPlugin(int nargs)
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
RVec< PromoteType< T > > abs(const RVec< T > &v)