KaliVeda
Toolkit for HIC analysis
KVFilterGroupReconstructor.h
1 #ifndef __KVFILTERGROUPRECONSTRUCTOR_H
2 #define __KVFILTERGROUPRECONSTRUCTOR_H
3 
4 #include "KVGroupReconstructor.h"
5 #include "KVDataQualityAudit.h"
6 #include <unordered_map>
21 
22  const KVDataQualityAudit* fDataQAudit = nullptr;
23 
24 protected:
25  std::unique_ptr<KVEvent> fSimEvent;
26  std::unordered_map<std::string, int> hits;
27  std::unordered_map<KVReconstructedNucleus*, TList> part_correspond;
29 
30  std::unordered_map<std::string, double> energy_loss;
31  std::unordered_map<std::string, int> number_uncalibrated;
32  std::unordered_map<std::string, int> number_unidentified;
37 
39  {
41  return idt->GetName();
42  }
44  {
45  return fDataQAudit->HasTelescope(n);
46  }
47  bool has_audit() const
48  {
49  return fDataQAudit!=nullptr;
50  }
51  static std::unordered_map<std::string,bool> audit_id_extensions;
52  bool can_extend_identification_beyond_audit(const std::string& id_label)
53  {
54  return audit_id_extensions[id_label];
55  }
56 
57 public:
58  static void EnableIDExtensionBeyondAudit(const TString& idlab)
59  {
62 
63  ::Info("KVFilterGroupReconstructor::EnableIDExtensionBeyondAudit()", "%s", idlab.Data());
64  audit_id_extensions[idlab.Data()]=true;
65  audit_id_extensions["initialised"]=true;
66  }
67 
69  {
70  }
71 
73  {
75 
76  fSimEvent.reset(static_cast<KVEvent*>(e->IsA()->New()));
77  }
78  void AddSimParticle(const KVNucleus* n)
79  {
83 
84  KVNucleus* nuc;
85 
86  n->Copy(*(nuc = fSimEvent->AddNucleus()));
87  auto traj = GetGroup()->FindReconTraj(n->GetParameters()->GetStringValue("TRAJECTORY"));
88  if(!traj)
89  {
93  KVString s_traj(n->GetParameters()->GetStringValue("TRAJECTORY"));
94 
96  s_traj.Begin("/");
98  auto stop_det = GetGroup()->GetDetector(s_traj.Next());
100  int most_dets_on_traj = 0;
101  KVGeoDNTrajectory* best_traj = nullptr;
102  for(auto _traj : *stop_det->GetNode()->GetTrajectories())
103  {
104  traj = dynamic_cast<KVGeoDNTrajectory*>(_traj);
105  s_traj.Begin("/");
108  int ndets=0;
109  while(!s_traj.End())
110  {
111  ndets+=traj->Contains(s_traj.Next());
112  }
113  if(ndets>most_dets_on_traj)
114  {
115  most_dets_on_traj=ndets;
116  best_traj=const_cast<KVGeoDNTrajectory*>(traj);
117  }
118  }
119 
120  if(!best_traj)
121  {
122  Error("AddSimParticle", "Could not find trajectory to suit this particle:");
123  n->Print();
124  GetGroup()->Print();
125  }
126  else
127  {
129  traj = GetGroup()->GetTrajectoryForReconstruction(best_traj,stop_det->GetNode());
131  }
132 
134  nuc->SetParameter("TRAJECTORY", traj->GetPathString());
135  }
136  traj->IterateFrom();
137  double de_tot=0;
138  while (auto node = traj->GetNextNode()) {
139  ++hits[node->GetName()];
140  ++number_unidentified[node->GetName()];
144  if((np = nuc->GetParameters()->FindParameter(node->GetName())) && np->IsDouble())
145  de_tot += np->GetDouble();
146  }
147  nuc->SetParameter("TOTAL_DE", de_tot);
149  nuc->SetE(de_tot);
150  }
151  void Clear(Option_t* = "") override
152  {
154  fSimEvent->Clear();
155  hits.clear();
156  part_correspond.clear();
157  energy_loss.clear();
158  number_uncalibrated.clear();
159  number_unidentified.clear();
160  }
161  void ReconstructParticle(KVReconstructedNucleus* part, const KVGeoDNTrajectory* traj, const KVGeoDetectorNode* node) override;
162  void IdentifyParticle(KVReconstructedNucleus& PART) override;
163  void CalibrateParticle(KVReconstructedNucleus* PART) override;
164 
166  {
167  fDataQAudit = DQA;
168  }
169 
170  ClassDefOverride(KVFilterGroupReconstructor, 1) //Reconstruct simulated events after filtering
171 };
172 
173 #endif
#define e(i)
const char Option_t
#define ClassDefOverride(name, id)
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 np
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 g
void Error(const char *method, const char *msgfmt,...) const override
Definition: KVBase.cpp:1674
Audit of experimental data identification and calibrations.
Bool_t HasTelescope(const TString &tel_name) const
Abstract base class container for multi-particle events.
Definition: KVEvent.h:67
Reconstruct particles in group of detectors after filtering simulated events.
bool can_extend_identification_beyond_audit(const std::string &id_label)
KVReconstructedNucleus * current_nuc_recon
temporary, store argument to ReconstructParticle
std::unordered_map< std::string, int > hits
count simulated particles in stopping detectors
void IdentifyParticle(KVReconstructedNucleus &PART) override
static std::unordered_map< std::string, bool > audit_id_extensions
void PerformSecondaryAnalysis()
After first round of identification in group, try to identify remaining particles.
std::unique_ptr< KVEvent > fSimEvent
experimental data on identification thresholds & capabilities
void Clear(Option_t *="") override
std::unordered_map< std::string, double > energy_loss
energy losses in detectors
KVReconNucTrajectory * get_recon_traj_for_particle(const KVGeoDNTrajectory *, const KVGeoDetectorNode *node) override
static void EnableIDExtensionBeyondAudit(const TString &idlab)
void AddSimParticle(const KVNucleus *n)
std::unordered_map< KVReconstructedNucleus *, TList > part_correspond
correspondence between reconstructed and simulated particles
virtual TString get_id_telescope_name_for_audit(KVIDTelescope *idt) const
void ReconstructParticle(KVReconstructedNucleus *part, const KVGeoDNTrajectory *traj, const KVGeoDetectorNode *node) override
void check_identification_threshold(KVNucleus *, KVIDTelescope *idt, KVIdentificationResult *IDR)
std::unordered_map< std::string, int > number_uncalibrated
number of particles for which the energy contribution of detector has not yet been set
const KVDataQualityAudit * fDataQAudit
KVFilterGroupReconstructor(const KVGroup *g=nullptr)
void identify_particle(KVIDTelescope *idt, KVIdentificationResult *IDR, KVReconstructedNucleus &nuc) override
bool audit_has_telescope_with_name(const TString &n) const
std::unordered_map< std::string, int > number_unidentified
number of particles hitting detector aas yet unidentified
void SetDataQualityAudit(const KVDataQualityAudit *DQA)
void CalibrateParticle(KVReconstructedNucleus *PART) override
Path taken by particles through multidetector geometry.
KVGeoDetectorNode * GetNode(const Char_t *name) const
Information on relative positions of detectors & particle trajectories.
void Print(Option_t *option="") const override
virtual KVDetector * GetDetector(const Char_t *name) const
Return detector in this structure with given name.
Base class for particle reconstruction in one group of a detector array.
KVGroup * GetGroup() const
Group of detectors which can be treated independently of all others in array.
Definition: KVGroup.h:20
const KVGeoDNTrajectory * FindReconTraj(const KVString &path)
Definition: KVGroup.h:111
const KVGeoDNTrajectory * GetTrajectoryForReconstruction(const KVGeoDNTrajectory *t, const KVGeoDetectorNode *n) const
Definition: KVGroup.h:117
Base class for all detectors or associations of detectors in array which can identify charged particl...
Definition: KVIDTelescope.h:85
Full result of one attempted particle identification.
KVNamedParameter * FindParameter(const Char_t *name) const
return the parameter object with the asking name
A generic named parameter storing values of different types.
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:123
KVNameValueList * GetParameters() const
Definition: KVParticle.h:818
void SetE(Double_t a)
Definition: KVParticle.h:597
void SetParameter(const Char_t *name, ValType value) const
Definition: KVParticle.h:822
Path through detector array used to reconstruct detected particle.
Nuclei reconstructed from data measured by a detector array .
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
void Begin(TString delim) const
Definition: KVString.cpp:565
Bool_t End() const
Definition: KVString.cpp:634
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:695
const char * GetName() const override
virtual void Info(const char *method, const char *msgfmt,...) const
const char * Data() const
const Int_t n