KaliVeda
Toolkit for HIC analysis
KVExpSetUp.cpp
1 //Created by KVClassFactory on Thu Feb 25 14:59:59 2016
2 //Author: bonnet,,,
3 
4 #include "KVExpSetUp.h"
5 #include "TClass.h"
6 #include "KVReconstructedNucleus.h"
7 
8 #include <KVGroup.h>
9 #include <KVRangeTableGeoNavigator.h>
10 
12 
13 
14 
16 void KVExpSetUp::init()
17 {
18  fBuildTarget = kFALSE;
19  fCloseGeometryNow = kFALSE;
20  //modification of the owner mode compare to Mother classes
21  SetOwnsDaughters(kFALSE);
22  SetOwnsDetectors(kFALSE);
23  fIDTelescopes->SetOwner(kFALSE);
24 }
25 
26 
27 
28 
31 
33 {
34  // Default constructor
35  init();
36 }
37 
38 
39 
42 
44 {
45  // Destructor
47 }
48 
49 
50 
51 
57 
59 {
60  // Build the combined arrays
61  //
62  // The name of the setup will be "[det1]-[det2]-..."
63 
64  // default ROOT geometry for all arrays
65  gEnv->SetValue("KVMultiDetArray.ROOTGeometry", "yes");
66 
68 
69  Info("Build", "navigator=%p", GetNavigator());
70 
72  SetNavigator(gnl);
73 
74  TString myname;
75 
76  KVMultiDetArray* tmp(nullptr);
77  Int_t group_offset = 0;// for renumbering groups
78  lmultidetarrayclasses = GetDataSetEnv(fDataSet, "DataSet.ExpSetUp.ClassList", IsA()->GetName());
80 
81  // VERY IMPORTANT: deactivate 'SetParameters(run)' being called by MakeMultiDetector for sub-arrays!
83 
84  while (!lmultidetarrayclasses.End()) {
86  Info("Build", "Build %s %s\n", fDataSet.Data(), sname.Data());
87  gMultiDetArray = nullptr; //otherwise MakeMultiDetector will delete any previously built array
88  tmp = MakeMultiDetector(fDataSet, run, sname.Data());
89  if (tmp) {
90  fMDAList.Add(tmp);
91  if (myname != "") myname += "-";
92  myname += tmp->GetName();
93  }
94  else {
95  Error("Build", "NULL pointer returned by MakeMultiDetector");
96  }
97  }
98 
99  // VERY IMPORTANT: reactivate 'SetParameters(run)' so it is called for us when we return
100  // to the MakeMultiDetector method which called us
102 
104 
105  TIter nxt_mda(&fMDAList);
106  while ((tmp = (KVMultiDetArray*)nxt_mda())) {
108  std::unique_ptr<KVSeqCollection> groups(tmp->GetStructureTypeList("GROUP"));
109  if (group_offset) {
110  // renumber all groups to keep unique names/numbers
111  TIter next(groups.get());
112  KVGroup* group;
113  while ((group = (KVGroup*)next())) {
114  Int_t group_number = group->GetNumber();
115  group->SetNumber(group_number + group_offset);
116  }
117  }
118  else
119  group_offset += groups->GetEntries();
120 
124 
125  // retrieve correspondance list node path<->detector
126  gnl->AbsorbDetectorPaths(tmp->GetNavigator());
127  }
128 
130 
131  gMultiDetArray = this;
132  SetBit(kIsBuilt);
133  SetName(myname);
134 }
135 
136 
137 
142 
144 {
145  // Overrides KVMultiDetArray method
146  // We use the "ARRAY" parameter of the reconstructed particle (if set)
147  // to know which array of the setup detected it.
148 
149  if (NUC->GetParameters()->HasStringParameter("ARRAY")) {
150  KVMultiDetArray* whichArray = GetArray(NUC->GetParameters()->GetStringValue("ARRAY"));
151  if (whichArray) {
152  whichArray->AcceptParticleForAnalysis(NUC);
153  }
154  else
155  Warning("AcceptParticleForAnalysis", "ReconstructedNucleus has ARRAY=%s but no KVMultiDetArray with this name in set-up",
156  NUC->GetParameters()->GetStringValue("ARRAY"));
157  }
158  else {
159  Warning("AcceptParticleForAnalysis", "ReconstructedNucleus has no ARRAY parameter: cannot determine correct KVMultiDetArray");
160  }
161 }
162 
163 
164 
175 
177 {
178  // Calculate multiplicities of particles in each array of the setup.
179  // They will appear in the KVNameValueList as parameters with the name of the array.
180  // e.g.
181  //
182  // "INDRA" = 21
183  // "FAZIA" = 3
184  //
185  // Any option given will be used to determine the type of event iterator used -
186  // see KVEvent::GetNextParticleIterator(Option_t*).
187 
188  m.Clear();
189  for (KVReconstructedEvent::Iterator it = e->GetNextParticleIterator(opt); it != e->end(); ++it) {
190  m.IncrementValue((*it).GetParameters()->GetStringValue("ARRAY"), 1);
191  }
192 }
193 
194 
195 
203 
205 {
206  // Set fRawDataReader pointer in each sub-array and call prepare_to_handle_new_raw_data()
207  // for each sub-array, before treating raw data.
208  //
209  // copy fired signals & detectors of sub-arrays to main lists
210  //
211  // copy any reconstruction parameters from sub-arrays to main list
212 
213  TIter next_array(&fMDAList);
214  KVMultiDetArray* mda;
215  std::vector<std::thread> threads;
216  while ((mda = (KVMultiDetArray*)next_array())) {
217  threads.push_back(std::thread([ = ]() {
218  mda->fRawDataReader = rawdata;
220  }));
221  }
222  for (auto& th : threads) {
223  if (th.joinable()) th.join();
224  }
226  // copy fired signals & detectors of sub-arrays to main lists
227  next_array.Reset();
228  while ((mda = (KVMultiDetArray*)next_array())) {
232  }
233  return true;
234  }
235  return false;
236 }
237 
238 
int Int_t
#define e(i)
bool Bool_t
constexpr Bool_t kFALSE
constexpr 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:25
KVExpSetUp()
Default constructor.
Definition: KVExpSetUp.cpp:32
void GetArrayMultiplicities(KVReconstructedEvent *, KVNameValueList &, Option_t *="")
Definition: KVExpSetUp.cpp:176
KVList fMDAList
list of multidetarrays
Definition: KVExpSetUp.h:47
virtual void AcceptParticleForAnalysis(KVReconstructedNucleus *) const
Definition: KVExpSetUp.cpp:143
virtual ~KVExpSetUp()
Destructor.
Definition: KVExpSetUp.cpp:43
virtual void Build(Int_t run=-1)
Definition: KVExpSetUp.cpp:58
Bool_t HandleRawDataEvent(KVRawDataReader *)
Definition: KVExpSetUp.cpp:204
void init()
Definition: KVExpSetUp.cpp:16
KVString lmultidetarrayclasses
Definition: KVExpSetUp.h:48
virtual KVMultiDetArray * GetArray(const Char_t *name) const
Definition: KVExpSetUp.h:118
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:20
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:815
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:73
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()
const char * GetName() const override
virtual void SetName(const char *name)
TClass * IsA() const override
virtual void Clear(Option_t *="")
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
TMarker m
ClassImp(TPyArg)