KaliVeda
Toolkit for HIC analysis
KVIDINDRACsI.cpp
1 /***************************************************************************
2  KVIDINDRACsI.cpp - description
3  -------------------
4  begin : Fri Feb 20 2004
5  copyright : (C) 2004 by J.D. Frankland
6  email : frankland@ganil.fr
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "KVIDINDRACsI.h"
19 #include "TMath.h"
20 #include "KVIdentificationResult.h"
21 #include "TRandom.h"
22 #include <KVIDGCsI.h>
23 #include <KVINDRADetector.h>
24 #include <KVReconstructedNucleus.h>
25 
27 
28 
29 
32 {
33  CsIGrid = 0;
34 
35  // thresholds used by filter for Rapide-Lente identifications
36  fThresMin[0][0] = 1;
37  fThresMax[0][0] = 2; // protons
38  fThresMin[0][1] = 2;
39  fThresMax[0][1] = 6; // deutons
40  fThresMin[0][2] = 5;
41  fThresMax[0][2] = 11; // tritons
42  fThresMin[0][3] = -1;
43  fThresMax[0][3] = -1; // 4H - NO!
44  fThresMin[1][0] = -1;
45  fThresMax[1][0] = -1; // 1He - NO!
46  fThresMin[1][1] = -1;
47  fThresMax[1][1] = -1; // 2He - NO!
48  fThresMin[1][2] = 20;
49  fThresMax[1][2] = 40; // 3He
50  fThresMin[1][3] = 1;
51  fThresMax[1][3] = 3; // alphas
52 
53  /* in principle all CsI telescopes can identify mass & charge */
54  SetHasMassID(kTRUE);
55 }
56 
57 
58 
59 
70 
72 {
73  // Particle identification and code setting using identification grid
74  //
75  // Note that gamma identification code is no longer attributed here: in case a gamma is identified,
76  // the IDR->IDcode will be the same general ID code as for all CsI particles,
77  // but IDR->IDquality == KVIDGCsI::kICODE10
78  //
79  // The KVIdentificationResult is first Clear()ed; then it is filled with IDtype = GetType()
80  // of this identification telescope, IDattempted = true, and the results of the identification
81  // procedure.
82 
83  IDR->Clear();
84  IDR->IDattempted = true;
85  IDR->SetIDType(GetType());
86 
87  //perform identification
88  Double_t X, Y;
89  GetIDGridCoords(X, Y, CsIGrid, x, y);
90  IDR->SetGridName(CsIGrid->GetName());
91  if (CsIGrid->IsIdentifiable(X, Y, &IDR->Rejecting_Cut)) {
92  CsIGrid->Identify(X, Y, IDR);
93  }
94  else if (IDR->Rejecting_Cut.Contains("gamma")) {
95  // gamma rejection
97  IDR->Z = 0;
98  IDR->A = 0;
99  IDR->IDOK = kTRUE;
100  IDR->SetComment("gamma");
101  }
102  else {
103  // rejected by some arbitrary cut line/contour
105  IDR->Z = 0;
106  IDR->A = 0;
107  IDR->IDOK = kFALSE;
108  IDR->SetComment(Form("rejected by cut:%s", IDR->Rejecting_Cut.Data()));
109  }
110 
111  // set general ID code
112  IDR->IDcode = GetIDCode();
113 
114  return kTRUE;
115 }
116 
117 
118 
128 
130 {
131  // For filtering simulations
132  //
133  // If energy loss in CsI is above threshold for mass identification, we set
134  // IDR->Aident=true (and IDR->Zident=true).
135  // Otherwise, we just set IDR->Zident=true and A will be given by mass formula for the particle
136  //
137  // individual thresholds defined for 1H, 2H, 3H, 3He, 4He
138  // for A>5 identification if CsI energy > 40 MeV
139 
141  if (!IDR->IDOK) return; // check for weird identifications of non-existent nuclei
142 
143  IDR->Zident = true;
144 
145  if (IDR->A > 5) {
146  if (GetDetector(1)->GetEnergy() > 40)
147  IDR->Aident = true;
148  return;
149  }
150  if (fThresMin[IDR->Z - 1][IDR->A - 1] > 0) {
151  Bool_t okmass = gRandom->Uniform() < smootherstep(fThresMin[IDR->Z - 1][IDR->A - 1],
152  fThresMax[IDR->Z - 1][IDR->A - 1], GetDetector(1)->GetEnergy());
153  if (okmass) {
154  IDR->Aident = true;
155  }
156  }
157 }
158 
159 
160 
161 
163 
164 float KVIDINDRACsI::clamp(float x, float lowerlimit, float upperlimit)
165 {
166  if (x < lowerlimit)
167  x = lowerlimit;
168  if (x > upperlimit)
169  x = upperlimit;
170  return x;
171 }
172 
173 
174 
177 
178 float KVIDINDRACsI::smootherstep(float edge0, float edge1, float x)
179 {
180  // Scale, and clamp x to 0..1 range
181  x = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
182  // Evaluate polynomial
183  return x * x * x * (x * (x * 6 - 15) + 10);
184 }
185 
186 
bool Bool_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
#define X(type, name)
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
virtual const Char_t * GetType() const
Definition: KVBase.h:176
virtual void Identify(Double_t, Double_t, KVIdentificationResult *) const =0
const Char_t * GetName() const override
Definition: KVIDGraph.cpp:1332
virtual Bool_t IsIdentifiable(Double_t, Double_t, TString *rejected_by=nullptr) const
Definition: KVIDGraph.cpp:1269
Bool_t Identify(KVIdentificationResult *, Double_t x=-1., Double_t y=-1.) override
float clamp(float x, float lowerlimit, float upperlimit)
Int_t fThresMin[2][4]
min ID thresholds (smooth step)
Definition: KVIDINDRACsI.h:34
Int_t fThresMax[2][4]
max ID thresholds (smooth step)
Definition: KVIDINDRACsI.h:35
void SetIdentificationStatus(KVIdentificationResult *IDR, const KVNucleus *) override
KVIDGraph * CsIGrid
telescope's grid
Definition: KVIDINDRACsI.h:32
float smootherstep(float edge0, float edge1, float x)
Scale, and clamp x to 0..1 range.
KVDetector * GetDetector(UInt_t n) const
virtual UShort_t GetIDCode()
void GetIDGridCoords(Double_t &X, Double_t &Y, KVIDGraph *grid, Double_t x=-1, Double_t y=-1)
virtual void SetIdentificationStatus(KVIdentificationResult *IDR, const KVNucleus *)
Full result of one attempted particle identification.
Bool_t IDattempted
=kTRUE if identification was attempted
Bool_t IDOK
general quality of identification, =kTRUE if acceptable identification made
void SetGridName(const Char_t *n)
void SetComment(const Char_t *c)
TString Rejecting_Cut
name of cut in grid which rejected particle for identification
Bool_t Aident
= kTRUE if A of particle established
Int_t A
A of particle found (if Aident==kTRUE)
Int_t Z
Z of particle found (if Zident==kTRUE)
Int_t IDquality
specific quality code returned by identification procedure
void Clear(Option_t *opt="") override
Reset to initial values.
Int_t IDcode
a general identification code for this type of identification
void SetIDType(const Char_t *t)
Bool_t Zident
=kTRUE if Z of particle established
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:123
virtual Double_t Uniform(Double_t x1, Double_t x2)
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Double_t y[n]
Double_t x[n]
ClassImp(TPyArg)