KaliVeda
Toolkit for HIC analysis
KVIDTelescope.h
1 /***************************************************************************
2 $Id: KVIDTelescope.h,v 1.33 2009/04/01 15:58:10 ebonnet Exp $
3  KVIDTelescope.h - description
4  -------------------
5  begin : Wed Jun 18 2003
6  copyright : (C) 2003 by J.D Frankland
7  email : frankland@ganil.fr
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef KVIDTELESCOPE_H
20 #define KVIDTELESCOPE_H
21 
22 #include "KVBase.h"
23 #include "KVDetector.h"
24 #include "TGraph.h"
25 #include "KVParticleCondition.h"
26 #include <optional>
28 class KVGroup;
29 class KVIDGraph;
30 class KVIDGrid;
31 class KVMultiDetArray;
33 class TH2;
34 
35 #include <KVUnownedList.h>
36 #include <unordered_map>
37 
85 class KVIDTelescope: public KVBase {
86 
87 
90 
91 protected:
95  enum {
96  kMassID = BIT(15), //set if telescope is capable of mass identification i.e. isotopic resolution
97  kReadyForID = BIT(16) //set if telescope is ready and able for identification. set in Initialize()
98  };
100 
101  void SetLabelFromURI(const Char_t* uri);
102  std::unique_ptr<KVParticleCondition> fMassIDValidity;
103  KVDetectorSignal* GetSignalFromGridVar(const KVString& var, const KVString& axe, KVString& det_labels);
104  struct GraphCoords {
109  };
110  mutable std::unordered_map<KVIDGraph*, GraphCoords> fGraphCoords;
112 
113  KVIDGrid* newGrid(bool onlyZ);
114  void addLineToGrid(KVIDGrid* gg, int zz, int aa, int npoints, std::optional<Double_t> einc_max = std::nullopt);
115 
116 public:
117 
119 
121  enum {
122  kCalibStatus_OK, // fine, OK, all detectors calculated and functioning properly
123  kCalibStatus_Calculated, // one or more detectors not calibrated/functioning, energy loss calculated
124  kCalibStatus_NoCalibrations, // no calibrations available for any detectors
125  kCalibStatus_Multihit, // one or more detectors hit by more than one particle, energy loss calculated for this detector
126  kCalibStatus_Coherency // comparison of calculated and measured energy loss in one or more detectors reveals presence of other particles
127  };
128 
129  KVIDTelescope();
130  void init();
131  virtual void AddDetector(KVDetector* d);
132  const KVList* GetDetectors() const
133  {
134  return &fDetectors;
135  }
136  KVDetector* GetDetector(UInt_t n) const
137  {
139  if (n > GetSize() || n < 1) {
140  Error("GetDetector(UInt_t n)", "n must be between 1 and %u",
141  GetSize());
142  return 0;
143  }
144  KVDetector* d = (KVDetector*) GetDetectors()->At((n - 1));
145  return d;
146  };
147  KVDetector* GetDetector(const Char_t* name) const;
148  Bool_t HasDetector(const KVDetector* d) const
149  {
151  return GetDetectorRank(d) > 0;
152  }
153  UInt_t GetDetectorRank(const KVDetector* kvd) const
154  {
157 
158  return GetDetectors()->IndexOf(kvd) + 1;
159  }
160  UInt_t GetSize() const
161  {
163  return GetDetectors()->GetSize();
164  }
165 
166  KVGroup* GetGroup() const;
167  void SetGroup(KVGroup* kvg);
169 
170  virtual void Initialize(void);
171 
172  virtual Bool_t Identify(KVIdentificationResult*, Double_t x = -1., Double_t y = -1.);
173 
175  virtual Int_t GetCalibStatus() const
176  {
182  return fCalibStatus;
183  }
184 
185  void Print(Option_t* opt = "") const override;
186 
187  void SetIDGrid(KVIDGraph*);
188  KVIDGraph* GetIDGrid();
190  KVIDGraph* GetIDGrid(const Char_t*);
191  const KVList* GetListOfIDGrids() const
192  {
193  return &fIDGrids;
194  }
195 
196  virtual void RemoveGrids();
197 
198  virtual Double_t GetIDMapX(Option_t* opt = "");
199  virtual Double_t GetIDMapY(Option_t* opt = "");
200  virtual Double_t GetPedestalX(Option_t* opt = "");
201  virtual Double_t GetPedestalY(Option_t* opt = "");
202 
205  void GetIDGridCoords(Double_t& X, Double_t& Y, KVIDGraph* grid, Double_t x = -1, Double_t y = -1)
206  {
211 
212  Y = (y < 0. ? GetIDGridYCoord(grid) : y);
213  X = (x < 0. ? GetIDGridXCoord(grid) : x);
214  }
215  void SetHasMassID(Bool_t yes = kTRUE)
216  {
217  SetBit(kMassID, yes);
218  }
219 
223  {
224  return TestBit(kMassID);
225  }
226 
227  static KVIDTelescope* MakeIDTelescope(const Char_t* name);
228 
230  virtual void RemoveIdentificationParameters();
231 
232  Bool_t LoadIdentificationParameters(const KVMultiDetArray* multidet, const TString& _filename = "");
234 
238  {
239  return TestBit(kReadyForID);
240  };
241 
242  const Char_t* GetDefaultIDGridClass();
243  KVIDGrid* CalculateDeltaE_EGrid(const KVNameValueList& AperZ, Int_t npoints = 30, Double_t xfactor = 1.);
244  KVIDGrid* CalculateDeltaE_EGrid(const KVNumberList& Zrange, Int_t deltaMasse, Int_t npoints, Double_t lifetime = -10/*s*/, UChar_t massformula = 0, Double_t xfactor = 1.);
245  KVIDGrid* CalculateDeltaE_EGrid(const KVNumberList& Zrange, Int_t npoints, Double_t Einc_max, UChar_t massformula = 0);
246  KVIDGrid* CalculateDeltaE_EGrid(TH2* haa_zz, Bool_t Zonly, Int_t npoints);
248  enum {
249  kMeanDE_OK, // all OK
250  kMeanDE_XtooSmall, // X-coordinate is smaller than smallest X-coordinate of ID line
251  kMeanDE_XtooLarge, // X-coordinate is larger than largest X-coordinate of ID line
252  kMeanDE_NoIdentifier // No identifier found for Z or (Z,A)
253  };
254  virtual Double_t GetMeanDEFromID(Int_t& status, Int_t Z, Int_t A = -1, Double_t Eres = -1.0);
255  virtual UShort_t GetIDCode()
256  {
259  return fIDCode;
260  }
261 
262  virtual void SetIDCode(UShort_t c)
263  {
265  fIDCode = c;
266  }
267 
268  virtual Bool_t CheckTheoreticalIdentificationThreshold(KVNucleus* /*ION*/, Double_t /*EINC*/ = 0.0);
269  virtual Bool_t CanIdentify(Int_t Z, Int_t /*A*/)
270  {
276  return (Z > 0);
277  }
278  virtual void SetIdentificationStatus(KVIdentificationResult* IDR, const KVNucleus*);
280  {
286 
287  return (GetSize() == 1 || (GetSize() == 2 && GetDetector(1)->GetNode()->GetNTraj() == 1
288  && GetDetector(2)->GetNode()->GetNTraj() == 1));
289  }
290 
291  static void OpenIdentificationBilan(const TString& path);
292  void CheckIdentificationBilan(const TString& system);
293 
294  ClassDefOverride(KVIDTelescope, 5) //A delta-E - E identification telescope
295 };
296 
297 #endif
int Int_t
unsigned int UInt_t
#define d(i)
#define c(i)
bool Bool_t
unsigned short UShort_t
unsigned char UChar_t
char Char_t
double Double_t
const char Option_t
#define BIT(n)
#define ClassDefOverride(name, id)
#define X(type, name)
Base class for KaliVeda framework.
Definition: KVBase.h:139
void Error(const char *method, const char *msgfmt,...) const override
Definition: KVBase.cpp:1650
Base class for output signal data produced by a detector.
Group of detectors which can be treated independently of all others in array.
Definition: KVGroup.h:20
Base class for particle identification in a 2D map.
Definition: KVIDGraph.h:32
Abstract base class for 2D identification grids in e.g. (dE,E) maps.
Definition: KVIDGrid.h:74
Base class for all detectors or associations of detectors in array which can identify charged particl...
Definition: KVIDTelescope.h:85
KVIDGrid * newGrid(bool onlyZ)
virtual Double_t GetIDMapY(Option_t *opt="")
virtual Bool_t IsReadyForID()
void init()
default init
KVIDGrid * CalculateDeltaE_EGrid(const KVNameValueList &AperZ, Int_t npoints=30, Double_t xfactor=1.)
void SetGroup(KVGroup *kvg)
KVList fMultiDetExpressions
used to clean up any multi-detector signal expressions generated to calculate X/Y coordinates
void SetLabelFromURI(const Char_t *uri)
Double_t GetIDGridYCoord(KVIDGraph *) const
virtual Bool_t Identify(KVIdentificationResult *, Double_t x=-1., Double_t y=-1.)
virtual Double_t GetIDMapX(Option_t *opt="")
static KVIDTelescope * MakeIDTelescope(const Char_t *name)
virtual Double_t GetPedestalY(Option_t *opt="")
virtual Bool_t SetIdentificationParameters(const KVMultiDetArray *)
void SetIDGrid(KVIDGraph *)
Bool_t HasMassID() const
KVDetector * GetDetector(UInt_t n) const
virtual Bool_t CheckTheoreticalIdentificationThreshold(KVNucleus *, Double_t=0.0)
UInt_t GetGroupNumber()
virtual void SetIDCode(UShort_t c)
KVGroup * GetGroup() const
virtual Bool_t CanIdentify(Int_t Z, Int_t)
Int_t fCalibStatus
temporary variable holding status code for last call to Calibrate(KVReconstructedNucleus*)
Definition: KVIDTelescope.h:99
virtual Double_t GetPedestalX(Option_t *opt="")
virtual void AddDetector(KVDetector *d)
virtual Double_t GetMeanDEFromID(Int_t &status, Int_t Z, Int_t A=-1, Double_t Eres=-1.0)
Bool_t ReadIdentificationParameterFiles(const KVMultiDetArray *multidet)
const KVList * GetDetectors() const
KVDetectorSignal * GetSignalFromGridVar(const KVString &var, const KVString &axe, KVString &det_labels)
KVIDGraph * GetIDGrid()
void Print(Option_t *opt="") const override
std::unordered_map< KVIDGraph *, GraphCoords > fGraphCoords
X/Y coordinates from detector signals for ID maps.
UShort_t fIDCode
general id code corresponding to correct identification by this type of telescope
Definition: KVIDTelescope.h:89
virtual Int_t GetCalibStatus() const
virtual void CalculateParticleEnergy(KVReconstructedNucleus* nuc);
virtual UShort_t GetIDCode()
Bool_t LoadIdentificationParameters(const KVMultiDetArray *multidet, const TString &_filename="")
void CheckIdentificationBilan(const TString &system)
Set status of ID Telescope for given system.
virtual void RemoveIdentificationParameters()
@ kCalibStatus_NoCalibrations
static void OpenIdentificationBilan(const TString &path)
Open IdentificationBilan.dat file with given path.
void SetHasMassID(Bool_t yes=kTRUE)
virtual void Initialize(void)
Double_t GetIDGridXCoord(KVIDGraph *) const
const Char_t * GetDefaultIDGridClass()
void GetIDGridCoords(Double_t &X, Double_t &Y, KVIDGraph *grid, Double_t x=-1, Double_t y=-1)
UInt_t GetSize() const
KVUnownedList fIDGrids
identification grid(s)
Definition: KVIDTelescope.h:94
Bool_t HasDetector(const KVDetector *d) const
KVUnownedList fDetectors
list of detectors in telescope
Definition: KVIDTelescope.h:92
KVString GetDetectorLabelsForGridCoord(const KVString &axis) const
const KVList * GetListOfIDGrids() const
std::unique_ptr< KVParticleCondition > fMassIDValidity
may be used to limit mass identification to certain Z and/or A range
UInt_t GetDetectorRank(const KVDetector *kvd) const
KVGroup * fGroup
group to which telescope belongs
Definition: KVIDTelescope.h:93
Bool_t IsIndependent() const
static TEnv * fgIdentificationBilan
Definition: KVIDTelescope.h:88
virtual void SetIdentificationStatus(KVIdentificationResult *IDR, const KVNucleus *)
virtual void RemoveGrids()
void addLineToGrid(KVIDGrid *gg, int zz, int aa, int npoints, std::optional< Double_t > einc_max=std::nullopt)
Full result of one attempted particle identification.
Extended TList class which owns its objects by default.
Definition: KVList.h:28
Base class for describing the geometry of a detector array.
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:123
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
Nuclei reconstructed from data measured by a detector array .
Int_t GetSize() const override
TObject * At(Int_t idx) const override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
Extended TList class which does not own its objects by default.
Definition: KVUnownedList.h:17
void SetBit(UInt_t f)
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual Int_t IndexOf(const TObject *obj) const
Double_t y[n]
Double_t x[n]
const Int_t n
KVDetectorSignal * fVarY
KVDetectorSignal * fVarX