KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVExpSetUp.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Thu Feb 25 14:59:59 2016
2 //Author: bonnet,,,
3 
4 #include "KVExpSetUp.h"
5 #include "KVDataSetManager.h"
6 #include "TClass.h"
8 
9 #include <KVGroup.h>
11 
12 #ifdef WITH_MFM
13 #include "KVMFMDataFileReader.h"
14 #endif
15 
17 
18 
19 
21 void KVExpSetUp::init()
22 {
23  fBuildTarget = kFALSE;
24  fCloseGeometryNow = kFALSE;
25  //modification of the owner mode compare to Mother classes
26  SetOwnsDaughters(kFALSE);
27  SetOwnsDetectors(kFALSE);
28  fIDTelescopes->SetOwner(kFALSE);
29 }
30 
31 
32 
33 
36 
38 {
39  // Default constructor
40  init();
41 }
42 
43 
44 
47 
49 {
50  // Destructor
52 }
53 
54 
55 
56 
62 
64 {
65  // Build the combined arrays
66  //
67  // The name of the setup will be "[det1]-[det2]-..."
68 
69  // default ROOT geometry for all arrays
70  gEnv->SetValue("KVMultiDetArray.ROOTGeometry", "yes");
71 
73 
74  Info("Build", "navigator=%p", GetNavigator());
75 
77  SetNavigator(gnl);
78 
79  TString myname;
80 
81  KVMultiDetArray* tmp(nullptr);
82  Int_t group_offset = 0;// for renumbering groups
83  lmultidetarrayclasses = GetDataSetEnv(fDataSet, "DataSet.ExpSetUp.ClassList", IsA()->GetName());
85 
86  // VERY IMPORTANT: deactivate 'SetParameters(run)' being called by MakeMultiDetector for sub-arrays!
88 
89  while (!lmultidetarrayclasses.End()) {
91  Info("Build", "Build %s %s\n", fDataSet.Data(), sname.Data());
92  gMultiDetArray = nullptr; //otherwise MakeMultiDetector will delete any previously built array
93  tmp = MakeMultiDetector(fDataSet, run, sname.Data());
94  if (tmp) {
95  fMDAList.Add(tmp);
96  if (myname != "") myname += "-";
97  myname += tmp->GetName();
98  }
99  else {
100  Error("Build", "NULL pointer returned by MakeMultiDetector");
101  }
102  }
103 
104  // VERY IMPORTANT: reactivate 'SetParameters(run)' so it is called for us when we return
105  // to the MakeMultiDetector method which called us
107 
109 
110  TIter nxt_mda(&fMDAList);
111  while ((tmp = (KVMultiDetArray*)nxt_mda())) {
113  unique_ptr<KVSeqCollection> groups(tmp->GetStructureTypeList("GROUP"));
114  if (group_offset) {
115  // renumber all groups to keep unique names/numbers
116  TIter next(groups.get());
117  KVGroup* group;
118  while ((group = (KVGroup*)next())) {
119  Int_t group_number = group->GetNumber();
120  group->SetNumber(group_number + group_offset);
121  }
122  }
123  else
124  group_offset += groups->GetEntries();
125 
129 
130  // retrieve correspondance list node path<->detector
131  gnl->AbsorbDetectorPaths(tmp->GetNavigator());
132  }
133 
135 
136  gMultiDetArray = this;
137  SetBit(kIsBuilt);
138  SetName(myname);
139 }
140 
141 
142 
145 
147 {
148  // call Clear(opt) for each multidetector in the setup
149  TIter next_array(&fMDAList);
150  KVMultiDetArray* mda;
151  while ((mda = (KVMultiDetArray*)next_array())) {
152  mda->Clear(opt);
153  }
154 }
155 
156 
157 
161 
163 {
164  // Call FillDetectorList for each array in turn, until DetList gets filled
165  // This is because some arrays may override the KVMultiDetArray::FillDetectorList method
166 
167  TIter next_array(&fMDAList);
168  KVMultiDetArray* mda;
169  while ((mda = (KVMultiDetArray*)next_array())) {
170  mda->FillDetectorList(rnuc, DetList, DetNames);
171  if (!DetList->IsEmpty()) break;
172  }
173 }
174 
175 
176 
181 
183 {
184  // Overrides KVMultiDetArray method
185  // We use the "ARRAY" parameter of the reconstructed particle (if set)
186  // to know which array of the setup detected it.
187 
188  if (NUC->GetParameters()->HasStringParameter("ARRAY")) {
189  KVMultiDetArray* whichArray = GetArray(NUC->GetParameters()->GetStringValue("ARRAY"));
190  if (whichArray) {
191  whichArray->AcceptParticleForAnalysis(NUC);
192  }
193  else
194  Warning("AcceptParticleForAnalysis", "ReconstructedNucleus has ARRAY=%s but no KVMultiDetArray with this name in set-up",
195  NUC->GetParameters()->GetStringValue("ARRAY"));
196  }
197  else {
198  Warning("AcceptParticleForAnalysis", "ReconstructedNucleus has no ARRAY parameter: cannot determine correct KVMultiDetArray");
199  }
200 }
201 
202 
203 
207 
208 void KVExpSetUp::GetDetectorEvent(KVDetectorEvent* detev, const TSeqCollection* fired_params)
209 {
210  // Override KVMultiDetArray method
211  // Call each array in turn and add fired groups to the KVDetectorEvent
212 
213  TIter next_array(&fMDAList);
214  KVMultiDetArray* mda;
215  while ((mda = (KVMultiDetArray*)next_array())) {
216  mda->GetDetectorEvent(detev, fired_params);
217  }
218 }
219 
220 
221 
225 
227 {
228  // Override KVMultiDetArray method
229  // Call each array in turn to get reconstructor for group
230  TIter next_array(&fMDAList);
231  KVMultiDetArray* mda;
232  KVGroupReconstructor* gr(nullptr);
233  while ((mda = (KVMultiDetArray*)next_array())) {
234  if ((gr = mda->GetReconstructorForGroup(g))) break;
235  }
236  return gr;
237 }
238 
239 
240 
242 
244 {
245  TIter next_array(&fMDAList);
246  KVMultiDetArray* mda;
247  while ((mda = (KVMultiDetArray*)next_array())) {
249  }
250 }
251 
252 
253 
256 
258 {
259  // Add contents of fReconParameters of each sub-array to the event parameter list
260  TIter next_array(&fMDAList);
261  KVMultiDetArray* mda;
262  while ((mda = (KVMultiDetArray*)next_array())) {
263  //*(e->GetParameters()) += mda->GetReconParameters();
265  }
266 }
267 
268 
269 
280 
282 {
283  // Calculate multiplicities of particles in each array of the setup.
284  // They will appear in the KVNameValueList as parameters with the name of the array.
285  // e.g.
286  //
287  // "INDRA" = 21
288  // "FAZIA" = 3
289  //
290  // Any option given will be used to determine the type of event iterator used -
291  // see KVEvent::GetNextParticleIterator(Option_t*).
292 
293  m.Clear();
294  for (KVEvent::Iterator it = e->GetNextParticleIterator(opt); it != e->end(); ++it) {
295  m.IncrementValue((*it).GetParameters()->GetStringValue("ARRAY"), 1);
296  }
297 }
298 
299 
300 
302 
304 {
305  TIter next_array(&fMDAList);
306  KVMultiDetArray* mda;
307  TString orig_dbtype = db->GetDBType();
308  while ((mda = (KVMultiDetArray*)next_array())) {
309  db->SetDBType(Form("%sDB", mda->GetName()));
310  mda->MakeCalibrationTables(db);
311  }
312  db->SetDBType(orig_dbtype);
313 }
314 
315 
316 
319 
321 {
322  // Set calibrators for all detectors for the run
323  TIter next_array(&fMDAList);
324  KVMultiDetArray* mda;
325  while ((mda = (KVMultiDetArray*)next_array())) {
326  mda->SetCalibratorParameters(r, mda->GetName());
327  }
328 }
329 
330 
331 
334 
336 {
337  // Check status (present, working) for all detectors for the run
338  TIter next_array(&fMDAList);
339  KVMultiDetArray* mda;
340  while ((mda = (KVMultiDetArray*)next_array())) {
341  mda->SetCurrentRunNumber(r->GetNumber());
342  mda->CheckStatusOfDetectors(r, mda->GetName());
343  }
344 }
345 
346 
347 
351 
353 {
354  // Calling this method disables any selection of "OK" reconstructed particles according
355  // to their identification code status, for all arrays in the setup.
356 
357  TIter next_array(&fMDAList);
358  KVMultiDetArray* mda;
359  while ((mda = (KVMultiDetArray*)next_array())) {
360  mda->AcceptAllIDCodes();
361  }
362 }
363 
364 
365 
369 
371 {
372  // Calling this method disables any selection of "OK" reconstructed particles according
373  // to their calibration code status, for all arrays in the setup.
374 
375  TIter next_array(&fMDAList);
376  KVMultiDetArray* mda;
377  while ((mda = (KVMultiDetArray*)next_array())) {
378  mda->AcceptAllECodes();
379  }
380 }
381 
382 
383 
386 
388 {
389  // Override base method in order to set general identification codes for telescopes in each array
390  TIter next_array(&fMDAList);
391  KVMultiDetArray* mda;
392  while ((mda = (KVMultiDetArray*)next_array())) {
393  mda->InitializeIDTelescopes();
394  }
395 }
396 
397 
398 #ifdef WITH_MFM
399 
405 
406 Bool_t KVExpSetUp::handle_raw_data_event_mfmframe(const MFMCommonFrame& mfmframe)
407 {
408  // Handle single (not merged) MFM frames of raw data. It is assumed
409  // that each frame type corresponds to a different detector array.
410  // Therefore as soon as one of them treats the data in the frame,
411  // we return kTRUE.
412 
413  TIter next_array(&fMDAList);
414  KVMultiDetArray* mda;
415  while ((mda = (KVMultiDetArray*)next_array())) {
416  if (mda->handle_raw_data_event_mfmframe(mfmframe)) {
417  //Info("handle_raw_data_event_mfmframe", "Handled frame for %s", mda->GetName());
418  mda->fHandledRawData = true;
419  return kTRUE;
420  }
421  }
422  return kFALSE;
423 }
424 
425 #endif
426 
427 
428 
431 
433 {
434  // clear all acquisition parameters etc of each array before reading new raw data event
436  TIter next_array(&fMDAList);
437  KVMultiDetArray* mda;
438  while ((mda = (KVMultiDetArray*)next_array())) {
440  }
441 }
442 
443 
444 
446 
448 {
449  TIter next_array(&fMDAList);
450  KVMultiDetArray* mda;
451  while ((mda = (KVMultiDetArray*)next_array())) {
453  }
454 }
455 
456 
int Int_t
KVMultiDetArray * gMultiDetArray
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
ROOT::R::TRInterface & r
#define e(i)
const Bool_t kFALSE
bool Bool_t
const Bool_t kTRUE
const char Option_t
R__EXTERN TEnv * gEnv
R__EXTERN TGeoManager * gGeoManager
char * Form(const char *fmt,...)
static const Char_t * GetDataSetEnv(const Char_t *dataset, const Char_t *type, const Char_t *defval)
Definition: KVBase.cpp:1582
Description of an experimental run in database ,.
Definition: KVDBRun.h:35
Base class to describe database of an experiment ,.
Definition: KVExpDB.h:18
void SetDBType(const TString &s)
Definition: KVExpDB.h:48
TString GetDBType() const
Definition: KVExpDB.h:44
Describe an experimental set-up coupling two or more different detector arrays.
Definition: KVExpSetUp.h:23
void prepare_to_handle_new_raw_data()
clear all acquisition parameters etc of each array before reading new raw data event
Definition: KVExpSetUp.cpp:432
KVExpSetUp()
Default constructor.
Definition: KVExpSetUp.cpp:37
void MakeCalibrationTables(KVExpDB *)
Definition: KVExpSetUp.cpp:303
virtual void AcceptAllECodes()
Definition: KVExpSetUp.cpp:370
void SetCalibratorParameters(KVDBRun *, const TString &="")
Set calibrators for all detectors for the run.
Definition: KVExpSetUp.cpp:320
void GetArrayMultiplicities(KVReconstructedEvent *, KVNameValueList &, Option_t *="")
Definition: KVExpSetUp.cpp:281
KVList fMDAList
list of multidetarrays
Definition: KVExpSetUp.h:26
virtual void AcceptParticleForAnalysis(KVReconstructedNucleus *) const
Definition: KVExpSetUp.cpp:182
void Clear(Option_t *opt="")
call Clear(opt) for each multidetector in the setup
Definition: KVExpSetUp.cpp:146
virtual void AcceptAllIDCodes()
Definition: KVExpSetUp.cpp:352
void FillDetectorList(KVReconstructedNucleus *rnuc, KVHashList *DetList, const KVString &DetNames)
Definition: KVExpSetUp.cpp:162
virtual ~KVExpSetUp()
Destructor.
Definition: KVExpSetUp.cpp:48
void GetDetectorEvent(KVDetectorEvent *detev, const TSeqCollection *fired_params=nullptr)
Definition: KVExpSetUp.cpp:208
void CheckStatusOfDetectors(KVDBRun *, const TString &="")
Check status (present, working) for all detectors for the run.
Definition: KVExpSetUp.cpp:335
virtual void Build(Int_t run=-1)
Definition: KVExpSetUp.cpp:63
void SetReconParametersInEvent(KVReconstructedEvent *) const
Add contents of fReconParameters of each sub-array to the event parameter list.
Definition: KVExpSetUp.cpp:257
void copy_fired_parameters_to_recon_param_list()
Definition: KVExpSetUp.cpp:447
Bool_t handle_raw_data_event_mfmframe(const MFMCommonFrame &)
Definition: KVExpSetUp.cpp:406
void init()
Definition: KVExpSetUp.cpp:21
virtual void InitializeIDTelescopes()
Override base method in order to set general identification codes for telescopes in each array.
Definition: KVExpSetUp.cpp:387
KVString lmultidetarrayclasses
Definition: KVExpSetUp.h:27
virtual KVMultiDetArray * GetArray(const Char_t *name) const
Definition: KVExpSetUp.h:45
KVGroupReconstructor * GetReconstructorForGroup(const KVGroup *) const
Definition: KVExpSetUp.cpp:226
void SetRawDataFromReconEvent(KVNameValueList &)
Definition: KVExpSetUp.cpp:243
void AbsorbDetectorPaths(KVGeoNavigator *GN)
KVUniqueNameList fDetectors
detectors in this structure element
KVUniqueNameList fStructures
daughter structures
const KVSeqCollection * GetDetectors() const
const KVSeqCollection * GetStructures() const
KVSeqCollection * GetStructureTypeList(const Char_t *type) const
Base class for particle reconstruction in one group of a detector array.
Group of detectors which can be treated independently of all others in array.
Definition: KVGroup.h:19
Extended version of ROOT THashList.
Definition: KVHashList.h:28
static KVIonRangeTable * GetRangeTable()
Definition: KVMaterial.cpp:153
Base class for describing the geometry of a detector array.
KVSeqCollection * GetListOfIDTelescopes() const
virtual void GetDetectorEvent(KVDetectorEvent *detev, const TSeqCollection *fired_params=0)
static Bool_t fCloseGeometryNow
virtual void AcceptAllECodes()
void CreateGeoManager(Double_t dx=500, Double_t dy=500, Double_t dz=500)
Bool_t HandledRawData() const
Bool_t fHandledRawData
set to true if multidetector handles data in last call to HandleRawData
KVSeqCollection * fIDTelescopes
deltaE-E telescopes in groups
static Bool_t fMakeMultiDetectorSetParameters
virtual void prepare_to_handle_new_raw_data()
reset acquisition parameters etc. before reading new raw data event
void SetCurrentRunNumber(UInt_t r)
virtual void copy_fired_parameters_to_recon_param_list()
KVGeoNavigator * GetNavigator() const
void SetGeometry(TGeoManager *)
virtual void MakeCalibrationTables(KVExpDB *)
virtual void Clear(Option_t *opt="")
virtual void CheckStatusOfDetectors(KVDBRun *, const TString &="")
virtual void PerformClosedROOTGeometryOperations()
virtual KVGroupReconstructor * GetReconstructorForGroup(const KVGroup *) const
virtual void FillDetectorList(KVReconstructedNucleus *rnuc, KVHashList *DetList, const KVString &DetNames)
virtual Bool_t handle_raw_data_event_mfmframe(const MFMCommonFrame &)
static KVMultiDetArray * MakeMultiDetector(const Char_t *dataset_name, Int_t run=-1, TString classname="KVMultiDetArray")
virtual void SetRawDataFromReconEvent(KVNameValueList &)
virtual void InitializeIDTelescopes()
virtual void AcceptAllIDCodes()
virtual void SetCalibratorParameters(KVDBRun *, const TString &="")
virtual void SetReconParametersInEvent(KVReconstructedEvent *) const
Copy any parameters in fReconParameters in to the reconstructed event parameter list.
TString fDataSet
name of associated dataset, used with MakeMultiDetector()
virtual void AcceptParticleForAnalysis(KVReconstructedNucleus *) const
void SetNavigator(KVGeoNavigator *geo)
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Bool_t HasStringParameter(const Char_t *name) const
const Char_t * GetStringValue(const Char_t *name) const
KVNameValueList * GetParameters() const
Definition: KVParticle.h:735
Propagate particles through array geometry calculating energy losses.
Physical event reconstructed from data measured with a detector array using implemented identificatio...
Nuclei reconstructed from data measured by a detector array ,.
virtual void Add(TObject *obj)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
void Begin(TString delim) const
Definition: KVString.cpp:562
Bool_t End() const
Definition: KVString.cpp:625
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:675
Optimised list in which named objects can only be placed once.
virtual void AddAll(const TCollection *col)
virtual Bool_t IsEmpty() const
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
void CloseGeometry(Option_t *option="d")
virtual const char * GetName() const
virtual void SetName(const char *name)
void SetBit(UInt_t f)
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
const char * Data() const
TGraphErrors * gr
const long double m
Definition: KVUnits.h:70
const long double g
masses
Definition: KVUnits.h:72
auto * l