KaliVeda  1.13/01
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  std::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 
147 
149 {
150  // Overrides KVMultiDetArray method
151  // We use the "ARRAY" parameter of the reconstructed particle (if set)
152  // to know which array of the setup detected it.
153 
154  if (NUC->GetParameters()->HasStringParameter("ARRAY")) {
155  KVMultiDetArray* whichArray = GetArray(NUC->GetParameters()->GetStringValue("ARRAY"));
156  if (whichArray) {
157  whichArray->AcceptParticleForAnalysis(NUC);
158  }
159  else
160  Warning("AcceptParticleForAnalysis", "ReconstructedNucleus has ARRAY=%s but no KVMultiDetArray with this name in set-up",
161  NUC->GetParameters()->GetStringValue("ARRAY"));
162  }
163  else {
164  Warning("AcceptParticleForAnalysis", "ReconstructedNucleus has no ARRAY parameter: cannot determine correct KVMultiDetArray");
165  }
166 }
167 
168 
169 
180 
182 {
183  // Calculate multiplicities of particles in each array of the setup.
184  // They will appear in the KVNameValueList as parameters with the name of the array.
185  // e.g.
186  //
187  // "INDRA" = 21
188  // "FAZIA" = 3
189  //
190  // Any option given will be used to determine the type of event iterator used -
191  // see KVEvent::GetNextParticleIterator(Option_t*).
192 
193  m.Clear();
194  for (KVReconstructedEvent::Iterator it = e->GetNextParticleIterator(opt); it != e->end(); ++it) {
195  m.IncrementValue((*it).GetParameters()->GetStringValue("ARRAY"), 1);
196  }
197 }
198 
199 
200 
208 
210 {
211  // Set fRawDataReader pointer in each sub-array and call prepare_to_handle_new_raw_data()
212  // for each sub-array, before treating raw data.
213  //
214  // copy fired signals & detectors of sub-arrays to main lists
215  //
216  // copy any reconstruction parameters from sub-arrays to main list
217 
218  TIter next_array(&fMDAList);
219  KVMultiDetArray* mda;
220  std::vector<std::thread> threads;
221  while ((mda = (KVMultiDetArray*)next_array())) {
222  threads.push_back(std::thread([ = ]() {
223  mda->fRawDataReader = rawdata;
225  }));
226  }
227  for (auto& th : threads) {
228  if (th.joinable()) th.join();
229  }
231  // copy fired signals & detectors of sub-arrays to main lists
232  next_array.Reset();
233  while ((mda = (KVMultiDetArray*)next_array())) {
237  }
238  return true;
239  }
240  return false;
241 }
242 
243 
int Int_t
KVMultiDetArray * gMultiDetArray
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
#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
static const Char_t * GetDataSetEnv(const Char_t *dataset, const Char_t *type, const Char_t *defval)
Definition: KVBase.cpp:1619
Describe an experimental set-up coupling two or more different detector arrays.
Definition: KVExpSetUp.h:24
KVExpSetUp()
Default constructor.
Definition: KVExpSetUp.cpp:37
void GetArrayMultiplicities(KVReconstructedEvent *, KVNameValueList &, Option_t *="")
Definition: KVExpSetUp.cpp:181
KVList fMDAList
list of multidetarrays
Definition: KVExpSetUp.h:46
virtual void AcceptParticleForAnalysis(KVReconstructedNucleus *) const
Definition: KVExpSetUp.cpp:148
virtual ~KVExpSetUp()
Destructor.
Definition: KVExpSetUp.cpp:48
virtual void Build(Int_t run=-1)
Definition: KVExpSetUp.cpp:63
Bool_t HandleRawDataEvent(KVRawDataReader *)
Definition: KVExpSetUp.cpp:209
void init()
Definition: KVExpSetUp.cpp:21
KVString lmultidetarrayclasses
Definition: KVExpSetUp.h:47
virtual KVMultiDetArray * GetArray(const Char_t *name) const
Definition: KVExpSetUp.h:117
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
Group of detectors which can be treated independently of all others in array.
Definition: KVGroup.h:19
static KVIonRangeTable * GetRangeTable()
Definition: KVMaterial.cpp:166
Base class for describing the geometry of a detector array.
KVSeqCollection * GetListOfIDTelescopes() const
KVNameValueList & GetReconParameters()
static Bool_t fCloseGeometryNow
void CreateGeoManager(Double_t dx=500, Double_t dy=500, Double_t dz=500)
KVSeqCollection * fIDTelescopes
deltaE-E telescopes in groups
static Bool_t fMakeMultiDetectorSetParameters
void prepare_to_handle_new_raw_data()
reset acquisition parameters etc. before reading new raw data event
KVGeoNavigator * GetNavigator() const
void SetGeometry(TGeoManager *)
virtual void PerformClosedROOTGeometryOperations()
static KVMultiDetArray * MakeMultiDetector(const Char_t *dataset_name, Int_t run=-1, TString classname="KVMultiDetArray")
KVRawDataReader * fRawDataReader
last raw data reader object used in call to HandleRawData
virtual Bool_t HandleRawDataEvent(KVRawDataReader *)
KVUniqueNameList fFiredDetectors
list of fired detectors after reading raw data event
KVNameValueList fReconParameters
general purpose list of parameters for storing information on data reconstruction
TString fDataSet
name of associated dataset, used with MakeMultiDetector()
virtual void AcceptParticleForAnalysis(KVReconstructedNucleus *) const
void SetNavigator(KVGeoNavigator *geo)
KVUnownedList fFiredSignals
list of fired signals after reading raw data event
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:816
Propagate particles through array geometry calculating energy losses.
Abstract base class for reading raw (DAQ) data.
Event containing KVReconstructedNucleus nuclei reconstructed from hits in detectors.
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:565
Bool_t End() const
Definition: KVString.cpp:634
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:695
Optimised list in which named objects can only be placed once.
virtual void AddAll(const TCollection *col)
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
void CloseGeometry(Option_t *option="d")
void Reset()
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
const long double m
Definition: KVUnits.h:70