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  int nrecon = 0;
43  while ((gr = (KVGroup*)it())) {
44  UInt_t i = gr->GetNumber();
45  if (i > N || i < 1) {
46  Warning("KVEventReconstructor", "Groups in array %s are not numbered the way I like...%u", a->GetName(), i);
47  gr->Print();
48  }
49  else {
50  if (fGroupReconstructor[i]) {
51  Warning("KVEventReconstructor", "%s array has non-unique group numbers!!!", a->GetName());
52  }
53  else {
54  fGroupReconstructor[i] = a->GetReconstructorForGroup(gr);
55  if (fGroupReconstructor[i]) {
56  ++nrecon;
57  ((KVGroupReconstructor*)fGroupReconstructor[i])->SetReconEventClass(e->IsA());
58  }
59  }
60  }
61  }
62 
63  KVGroupReconstructor::SetDoIdentification(GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoIdentification", kFALSE));
64  KVGroupReconstructor::SetDoCalibration(GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoCalibration", kFALSE));
65  Info("KVEventReconstructor", "Initialised for %u groups of multidetector %s", nrecon, fArray->GetName());
66  if (GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoIdentification", kFALSE) || GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoCalibration", kFALSE)) {
67  if (GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoIdentification", kFALSE)) {
68  fArray->InitializeIDTelescopes();
69  Info("KVEventReconstructor", " -- identification of events will be performed");
70  fArray->PrintStatusOfIDTelescopes();
71  }
72  if (GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoCalibration", kFALSE)) {
73  Info("KVEventReconstructor", " -- calibration of events will be performed");
74  fArray->PrintCalibStatusOfDetectors();
75  if (GetArray()->GetTarget()) {
76  // for target energy loss correction calculation
77  GetArray()->GetTarget()->SetOutgoing();
78  }
79  }
80  }
81  else
82  Info("KVEventReconstructor", " -- no identification or calibration will be performed");
83 }
84 
85 
86 
87 
95 
97 {
98  // This method copies the current state of 'this' object into 'obj'
99  // You should add here any member variables, for example:
100  // (supposing a member variable KVEventReconstructor::fToto)
101  // CastedObj.fToto = fToto;
102  // or
103  // CastedObj.SetToto( GetToto() );
104 
105  KVBase::Copy(obj);
106  //KVEventReconstructor& CastedObj = (KVEventReconstructor&)obj;
107 }
108 
109 
110 
116 
118 {
119  // Reconstruct current event based on state of detectors in array
120  //
121  // The list pointer, if given, can be used to supply a list of fired
122  // detectors to KVMultiDetArray::GetDetectorEvent
123 
124  GetEvent()->Clear("N");// No Group Reset (would not reset groups with no reconstructed particles)
125  detev.Clear("N");// reset all groups (but not acquisition parameters), even if no particles were reconstructed in them
126 
127  GetArray()->GetDetectorEvent(&detev, fired);
128 
129  fNGrpRecon = 0;
130  fHitGroups.clear();
131  fHitGroups.reserve(detev.GetGroups()->GetEntries());
132  TIter it(detev.GetGroups());
133  KVGroup* group;
134  while ((group = (KVGroup*)it())) {
135  KVGroupReconstructor* grec = (KVGroupReconstructor*)fGroupReconstructor[group->GetNumber()];
136  if (grec) {
137  fHitGroups[fNGrpRecon] = group->GetNumber();
138  grec->Process();
139  ++fNGrpRecon;
140  }
141  }
142 
143  // merge resulting event fragments
144  MergeGroupEventFragments();
145 
146  // copy any parameters stocked in the detector(s) during reconstruction in the reconstructed event
147  GetArray()->SetReconParametersInEvent(GetEvent());
148 }
149 
150 
151 
155 
157 {
158  // After processing has finished in groups, call this method to produce
159  // a final merged event containing particles from all groups
160 
161  TList to_merge;
162 
163  for (int k = 0; k < fNGrpRecon; ++k) {
164  auto grp_rcon = GetReconstructor(fHitGroups[k]);
165  to_merge.Add(grp_rcon->GetEventFragment());
166  grp_rcon->Clear();
167  }
168  GetEvent()->MergeEventFragments(&to_merge, "N");// "N" = no group reset
169 }
170 
171 
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:397
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:20
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)