KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVIdentificationResult.h
Go to the documentation of this file.
1 #ifndef KVIDENTIFICATIONRESULT_H
2 #define KVIDENTIFICATIONRESULT_H
3 
4 #include "KVBase.h"
5 #include "TString.h"
6 #include <unordered_map>
7 
39 public:
51 
52  using grid_infos = std::unordered_map<std::string, std::vector<TString>>; //infos from each grid used to identify particle
54 
55  enum {
56  deltaEpedestal_UNKNOWN, // status unknown, case not treated
57  deltaEpedestal_YES, // the particle to identify has a delta-E consistent with pedestal
58  deltaEpedestal_NO // the particle to identify has a delta-E > pedestal
59  };
60 
62  IDattempted(0), IDOK(0), IDcode(-1),
63  Zident(0), Aident(0), IDquality(-1), Z(-1), A(-1), PID(-1.0), deltaEpedestal(deltaEpedestal_UNKNOWN)
64  {};
65 
67  {
69  id.Copy(*this);
70  }
71  void Clear(Option_t* opt = "");
72  void Copy(TObject&) const;
73  void Print(Option_t* opt = "") const;
75  {
76  i.Copy(*this);
77  return *this;
78  }
79 
80  void SetIDType(const Char_t* t)
81  {
83  SetType(t);
84  }
85  const Char_t* GetIDType() const
86  {
88  return GetType();
89  }
90  void SetComment(const Char_t* c)
91  {
93  SetLabel(c);
94  }
95  const Char_t* GetComment() const
96  {
98  return GetLabel();
99  }
100  void SetGridName(const Char_t* n)
101  {
103  SetName(n);
104  }
105  const Char_t* GetGridName() const
106  {
108  return GetName();
109  }
110 
111  void AddFlag(std::string grid_name, TString flag)
112  {
114  flags[grid_name].push_back(flag);
115  }
116 
117  Bool_t HasFlag(std::string grid_name, TString flag)
118  {
120  auto fv = flags.find(grid_name);
121  if (fv != flags.end()) return (std::find(fv->second.begin(), fv->second.end(), flag) != fv->second.end());
122  return kFALSE;
123  }
124 
125  Bool_t HasFlagWhichBegins(std::string grid_name, TString flag_beginning)
126  {
128  auto fv = flags.find(grid_name);
129  if (fv != flags.end()) {
130  for (auto& f : fv->second) {
131  if (f.BeginsWith(flag_beginning)) return kTRUE;
132  }
133  }
134  return kFALSE;
135  }
136 
137  TString GetFlagWhichBegins(std::string grid_name, TString flag_beginning)
138  {
140  auto fv = flags.find(grid_name);
141  if (fv != flags.end()) {
142  for (auto& f : fv->second) {
143  if (f.BeginsWith(flag_beginning)) return f;
144  }
145  }
146  return "";
147  }
148 
150  {
153  return HasFlag(GetGridName(), flag);
154  }
155 
157  {
160  return HasFlagWhichBegins(GetGridName(), flag_beginning);
161  }
162 
164  {
167  return GetFlagWhichBegins(GetGridName(), flag_beginning);
168  }
169 
170  Bool_t HasFlag_AnyGrid(TString flag, std::string& grid_name)
171  {
174 
175  for (auto& fv : flags) {
176  grid_name = fv.first;
177  if (HasFlag(grid_name, flag)) return kTRUE;
178  }
179  return kFALSE;
180  }
181 
182  Bool_t HasFlagWhichBegins_AnyGrid(TString flag_beginning, std::string& grid_name)
183  {
186  for (auto& fv : flags) {
187  grid_name = fv.first;
188  if (HasFlagWhichBegins(grid_name, flag_beginning)) return kTRUE;
189  }
190  return kFALSE;
191  }
192 
193  TString GetFlagWhichBegins_AnyGrid(TString flag_beginning, std::string& grid_name)
194  {
197  for (auto& fv : flags) {
198  grid_name = fv.first;
199  auto f = GetFlagWhichBegins(grid_name, flag_beginning);
200  if (f.Length()) return f;
201  }
202  return "";
203  }
204 
205  ClassDef(KVIdentificationResult, 4) //Full result of one attempted particle identification
206 };
207 
208 #endif
int Int_t
#define f(i)
#define c(i)
char Char_t
const Bool_t kFALSE
bool Bool_t
double Double_t
const Bool_t kTRUE
const char Option_t
#define ClassDef(name, id)
Base class for KaliVeda framework.
Definition: KVBase.h:135
void SetLabel(const Char_t *lab)
Definition: KVBase.h:188
const Char_t * GetLabel() const
Definition: KVBase.h:192
const Char_t * GetType() const
Definition: KVBase.h:170
virtual void SetType(const Char_t *str)
Definition: KVBase.h:166
virtual void Copy(TObject &) const
Make a copy of this object.
Definition: KVBase.cpp:397
Full result of one attempted particle identification.
Bool_t IDattempted
=kTRUE if identification was attempted
Bool_t HasFlagWhichBegins(std::string grid_name, TString flag_beginning)
KVIdentificationResult & operator=(const KVIdentificationResult &i)
Bool_t IDOK
general quality of identification, =kTRUE if acceptable identification made
void SetGridName(const Char_t *n)
void Print(Option_t *opt="") const
void Copy(TObject &) const
Copy this to obj.
void SetComment(const Char_t *c)
void AddFlag(std::string grid_name, TString flag)
void Clear(Option_t *opt="")
Reset to initial values.
Bool_t IdentifyingGridHasFlagWhichBegins(TString flag_beginning)
TString Rejecting_Cut
name of cut in grid which rejected particle for identification
Bool_t HasFlagWhichBegins_AnyGrid(TString flag_beginning, std::string &grid_name)
std::unordered_map< std::string, std::vector< TString > > grid_infos
Bool_t Aident
= kTRUE if A of particle established
Double_t PID
= "real" Z if Zident==kTRUE and Aident==kFALSE, "real" A if Zident==Aident==kTRUE
const Char_t * GetIDType() const
Bool_t IdentifyingGridHasFlag(TString flag)
Int_t deltaEpedestal
special code for handling particles which give no signal in deltaE
Bool_t HasFlag_AnyGrid(TString flag, std::string &grid_name)
TString GetFlagWhichBegins_AnyGrid(TString flag_beginning, std::string &grid_name)
TString IdentifyingGridGetFlagWhichBegins(TString flag_beginning)
const Char_t * GetComment() const
KVIdentificationResult(const KVIdentificationResult &id)
const Char_t * GetGridName() const
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
Int_t IDcode
a general identification code for this type of identification
TString GetFlagWhichBegins(std::string grid_name, TString flag_beginning)
Bool_t HasFlag(std::string grid_name, TString flag)
void SetIDType(const Char_t *t)
Bool_t Zident
=kTRUE if Z of particle established
virtual const char * GetName() const
virtual void SetName(const char *name)
const Int_t n