KaliVeda
Toolkit for HIC analysis
KVEventReconstructor.cpp
1 #include "KVEventReconstructor.h"
2 #include "KVDetectorEvent.h"
3 #include "KVGroupReconstructor.h"
4 #include "KVTarget.h"
5 
6 #include <iostream>
7 using namespace std;
8 
10 
11 
12 
24  : KVBase("KVEventReconstructor", Form("Reconstruction of events in array %s", a->GetName())),
25  fArray(a), fEvent(e), fGroupReconstructor(a->GetNumberOfGroups(), 1)
26 {
27  // Default constructor
28  // Set up group reconstructor for every group of the array.
29  // It is assumed that these are all numbered uniquely & sensibly ;)
30  //
31  // Identification & calibration are enabled or not depending on the following
32  // (possibly-dataset-dependent) variables:
33  //
34  // EventReconstruction.DoIdentification
35  // EventReconstruction.DoCalibration
36 
37  fGroupReconstructor.SetOwner();
38  unique_ptr<KVSeqCollection> gr_list(a->GetStructureTypeList("GROUP"));
39  KVGroup* gr;
40  TIter it(gr_list.get());
41  unsigned int N = gr_list->GetEntries();
42  while ((gr = (KVGroup*)it())) {
43  UInt_t i = gr->GetNumber();
44  if (i > N || i < 1) {
45  Warning("KVEventReconstructor", "Groups in array %s are not numbered the way I like...%u", a->GetName(), i);
46  gr->Print();
47  }
48  else {
49  if (fGroupReconstructor[i]) {
50  Warning("KVEventReconstructor", "%s array has non-unique group numbers!!!", a->GetName());
51  }
52  else {
53  fGroupReconstructor[i] = a->GetReconstructorForGroup(gr);
54  if (fGroupReconstructor[i]) {
55  ((KVGroupReconstructor*)fGroupReconstructor[i])->SetReconEventClass(e->IsA());
56  }
57  }
58  }
59  }
60 
61  KVGroupReconstructor::SetDoIdentification(GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoIdentification", kFALSE));
62  KVGroupReconstructor::SetDoCalibration(GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoCalibration", kFALSE));
63  Info("KVEventReconstructor", "Initialised for %u groups of multidetector %s", N, fArray->GetName());
64  if (GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoIdentification", kFALSE) || GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoCalibration", kFALSE)) {
65  if (GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoIdentification", kFALSE)) {
66  fArray->InitializeIDTelescopes();
67  Info("KVEventReconstructor", " -- identification of events will be performed");
68  //fArray->PrintStatusOfIDTelescopes();
69  }
70  if (GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoCalibration", kFALSE)) {
71  Info("KVEventReconstructor", " -- calibration of events will be performed");
72  //fArray->PrintCalibStatusOfDetectors();
73  if (GetArray()->GetTarget()) {
74  // for target energy loss correction calculation
75  GetArray()->GetTarget()->SetOutgoing();
76  }
77  }
78  }
79  else
80  Info("KVEventReconstructor", " -- no identification or calibration will be performed");
81 }
82 
83 
84 
85 
93 
95 {
96  // This method copies the current state of 'this' object into 'obj'
97  // You should add here any member variables, for example:
98  // (supposing a member variable KVEventReconstructor::fToto)
99  // CastedObj.fToto = fToto;
100  // or
101  // CastedObj.SetToto( GetToto() );
102 
103  KVBase::Copy(obj);
104  //KVEventReconstructor& CastedObj = (KVEventReconstructor&)obj;
105 }
106 
107 
108 
114 
116 {
117  // Reconstruct current event based on state of detectors in array
118  //
119  // The list pointer, if given, can be used to supply a list of fired
120  // detectors to KVMultiDetArray::GetDetectorEvent
121 
122  GetEvent()->Clear("N");// No Group Reset (would not reset groups with no reconstructed particles)
123  detev.Clear("N");// reset all groups (but not acquisition parameters), even if no particles were reconstructed in them
124 
125  GetArray()->GetDetectorEvent(&detev, fired);
126 
127  fNGrpRecon = 0;
128  fHitGroups.clear();
129  fHitGroups.reserve(detev.GetGroups()->GetEntries());
130  TIter it(detev.GetGroups());
131  KVGroup* group;
132  while ((group = (KVGroup*)it())) {
133  KVGroupReconstructor* grec = (KVGroupReconstructor*)fGroupReconstructor[group->GetNumber()];
134  if (grec) {
135  fHitGroups[fNGrpRecon] = group->GetNumber();
136  grec->Process();
137  ++fNGrpRecon;
138  }
139  }
140 
141  // merge resulting event fragments
142  MergeGroupEventFragments();
143 
144  // copy any parameters stocked in the detector(s) during reconstruction in the reconstructed event
145  GetArray()->SetReconParametersInEvent(GetEvent());
146 }
147 
148 
149 
153 
155 {
156  // After processing has finished in groups, call this method to produce
157  // a final merged event containing particles from all groups
158 
159  TList to_merge;
160 
161  for (int k = 0; k < fNGrpRecon; ++k) {
162  auto grp_rcon = GetReconstructor(fHitGroups[k]);
163  to_merge.Add(grp_rcon->GetEventFragment());
164  grp_rcon->Clear();
165  }
166  GetEvent()->MergeEventFragments(&to_merge, "N");// "N" = no group reset
167 }
168 
169 
unsigned int UInt_t
#define e(i)
bool Bool_t
constexpr Bool_t kFALSE
#define N
Base class for KaliVeda framework.
Definition: KVBase.h:139
void Copy(TObject &) const override
Make a copy of this object.
Definition: KVBase.cpp:373
Base class for event reconstruction from array data.
void Copy(TObject &obj) const override
virtual void ReconstructEvent(const TSeqCollection *=nullptr)
Base class for particle reconstruction in one group of a detector array.
static void SetDoCalibration(bool on=kTRUE)
static void SetDoIdentification(bool on=kTRUE)
Group of detectors which can be treated independently of all others in array.
Definition: KVGroup.h:19
Base class for describing the geometry of a detector array.
Event containing KVReconstructedNucleus nuclei reconstructed from hits in detectors.
void Print(Option_t *chopt="") const override
void Add(TObject *obj) override
virtual const char * GetName() const
TGraphErrors * gr
void Info(const char *location, const char *fmt,...)
void Warning(const char *location, const char *fmt,...)
TArc a
ClassImp(TPyArg)