KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVEventReconstructor.cpp
Go to the documentation of this file.
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  ((KVGroupReconstructor*)fGroupReconstructor[i])->SetGroup(gr);
57  }
58  }
59  }
60  }
61 
62  KVGroupReconstructor::SetDoIdentification(GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoIdentification", kTRUE));
63  KVGroupReconstructor::SetDoCalibration(GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoCalibration", kTRUE));
64  Info("KVEventReconstructor", "Initialised for %u groups of multidetector %s", N, fArray->GetName());
65  if (GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoIdentification", kTRUE) || GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoCalibration", kTRUE)) {
66  if (GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoIdentification", kTRUE)) {
67  Info("KVEventReconstructor", " -- identification of events will be performed");
68  fArray->PrintStatusOfIDTelescopes();
69  }
70  if (GetDataSetEnv(fArray->GetDataSet(), "EventReconstruction.DoCalibration", kTRUE)) {
71  Info("KVEventReconstructor", " -- calibration of events will be performed");
72  fArray->PrintCalibStatusOfDetectors();
73  }
74  }
75  else
76  Info("KVEventReconstructor", " -- no identification or calibration will be performed");
77 }
78 
79 
80 
81 
89 
91 {
92  // This method copies the current state of 'this' object into 'obj'
93  // You should add here any member variables, for example:
94  // (supposing a member variable KVEventReconstructor::fToto)
95  // CastedObj.fToto = fToto;
96  // or
97  // CastedObj.SetToto( GetToto() );
98 
99  KVBase::Copy(obj);
100  //KVEventReconstructor& CastedObj = (KVEventReconstructor&)obj;
101 }
102 
103 
104 
110 
112 {
113  // Reconstruct current event based on state of detectors in array
114  //
115  // The list pointer, if given, can be used to supply a list of fired
116  // acquisition parameters to KVMultiDetArray::GetDetectorEvent
117 
118  if (GetArray()->GetTarget()) {
119  // for target energy loss correction calculation
120  GetArray()->GetTarget()->SetIncoming(kFALSE);
121  GetArray()->GetTarget()->SetOutgoing(kTRUE);
122  }
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  int i = fHitGroups[k];
165  to_merge.Add(((KVGroupReconstructor*)fGroupReconstructor[i])->GetEventFragment());
166  }
167  GetEvent()->MergeEventFragments(&to_merge, "N");// "N" = no group reset
168 }
169 
170 
unsigned int UInt_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
#define e(i)
const Bool_t kFALSE
bool Bool_t
const Bool_t kTRUE
#define N
Base class for KaliVeda framework.
Definition: KVBase.h:141
virtual void Copy(TObject &) const
Make a copy of this object.
Definition: KVBase.cpp:394
Base class for event reconstruction from array data.
void Copy(TObject &obj) const
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.
virtual void Print(Option_t *chopt="") const
virtual void Add(TObject *obj)
TGraphErrors * gr
const long double s
Definition: KVUnits.h:94
void Info(const char *location, const char *va_(fmt),...)
void Warning(const char *location, const char *va_(fmt),...)
auto * a