KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVUpDater.cpp
Go to the documentation of this file.
1 /*
2 $Id: KVUpDater.cpp,v 1.4 2006/10/19 14:32:43 franklan Exp $
3 $Revision: 1.4 $
4 $Date: 2006/10/19 14:32:43 $
5 $Author: franklan $
6 */
7 
8 #include "KVUpDater.h"
9 #include "TPluginManager.h"
10 #include "KVBase.h"
11 #include "Riostream.h"
12 #include "KVMultiDetArray.h"
13 #include "KVIDTelescope.h"
14 #include "KVIDGridManager.h"
15 #include "KVDetector.h"
16 #include "KVCalibrator.h"
17 #include "KVExpDB.h"
18 
19 using namespace std;
20 
21 
24 
26 KVUpDater::KVUpDater() : fArray(nullptr)
27 {
28  //Default ctor for KVUpDater object.
29 }
30 
31 
32 
33 
36 
37 KVUpDater::~KVUpDater()
38 {
39  //Destructor.
40 }
41 
42 
43 
45 
47 {
48  fArray = a;
49 }
50 
51 
52 
58 
60 {
61  //Looks for plugin (see $KVROOT/KVFiles/.kvrootrc) with name 'uri'(=name of dataset),
62  //loads plugin library, creates object and returns pointer.
63  //If no plugin defined for dataset, instanciates a KVUpDater (default)
64 
65  //check and load plugin library
66  TPluginHandler* ph;
67  KVUpDater* upd = 0;
68  if (!(ph = KVBase::LoadPlugin("KVUpDater", uri))) {
69  upd = new KVUpDater;
70  }
71  else {
72  upd = (KVUpDater*) ph->ExecPlugin(0);
73  }
74  upd->fDataSet = uri;
75  upd->SetArray(a);
76  return upd;
77 }
78 
79 
80 
90 
91 void KVUpDater::SetParameters(UInt_t run, Bool_t physics_parameters_only)
92 {
93  // Set parameters of multidetector for this run
94  //
95  //This will:
96  // set the target corresponding to the run
97  // set detector statuses (present/working) for the run
98  //If physics_parameters_only==false:
99  // set calibration parameters for the run
100  // set identification parameters for the run
101 
102  if (!gExpDB) return;
103  cout << "Setting parameters of multidetector array for run " << run << ":" <<
104  endl;
105  KVDBRun* kvrun = gExpDB->GetDBRun(run);
106  if (!kvrun) {
107  Error("SetParameters(UInt_t)", "Run %u not found in database!", run);
108  return;
109  }
110  SetTarget(kvrun);
111  CheckStatusOfDetectors(kvrun);
112  if (!physics_parameters_only) {
113  SetCalibrationParameters(run);
114  SetIdentificationParameters(run);
115  }
116 }
117 
118 
119 
120 
125 
127 {
128  //Set target used during this run
129  //If no target is found in the database, the existing target (if there is one)
130  //will be removed, and the multidetector array will have no target defined.
131 
132  cout << "--> Setting Target:" << endl;
133 
134  //remove existing target
135  fArray->SetTarget(0);
136  if (!kvrun->GetSystem() || !kvrun->GetSystem()->GetTarget()) {
137  cout << " No target defined for run." << endl;
138  return;
139  }
140 
141  fArray->SetTarget((KVTarget*) kvrun->GetSystem()->GetTarget());
142 
143  cout << " " << fArray->GetTarget()->
144  GetName() << " Total Thickness: " << fArray->GetTarget()->
145  GetTotalThickness()
146  << " mg/cm2" << endl;
147 }
148 
149 
150 
151 
156 
158 {
159  // Set identification parameters for this run.
160  // Will call gMultiDetArray->InitializeIDTelescopes() in order to initialize
161  // identifications & set status IsReadyForID() of each ID telescope for run.
162 
163  cout << "Setting identification parameters of multidetector array for run " << run << ":" <<
164  endl;
165  SetIDGrids(run);
166  fArray->InitializeIDTelescopes();
167 }
168 
169 
170 
171 
176 
178 {
179  // Use global ID grid manager gIDGridManager to set identification grids for all
180  // ID telescopes for this run. First, any previously set grids are removed.
181  // Then all grids for current run are set in the associated ID telescopes.
182 
183  cout << "--> Setting Identification Grids" << endl;
184  TIter next_idt(fArray->GetListOfIDTelescopes());
185  KVIDTelescope* idt;
186  while ((idt = (KVIDTelescope*) next_idt())) {
187  idt->RemoveGrids();
188  }
189  fArray->SetGridsInTelescopes(run);
190 }
191 
192 
193 
194 
197 
199 {
200  //Set calibration parameters for this run.
201 
202  cout << "Setting calibration parameters of multidetector array for run " << run << ":" <<
203  endl;
204  KVDBRun* kvrun = gExpDB->GetDBRun(run);
205  if (!kvrun) {
206  Error("SetParameters(UInt_t)", "Run %u not found in database!", run);
207  return;
208  }
209  SetCalibParameters(kvrun);
210 }
211 
212 
213 
216 
218 {
219  // Check status (present, working) of each detector for run
220  cout << "Checking detectors statuses of multidetector array for run " << r->GetName() << ":" <<
221  endl;
222  fArray->CheckStatusOfDetectors(r);
223 }
224 
225 
226 
229 
231 {
232  // Override in child classes to set specific calibrations.
233  fArray->SetCalibratorParameters(r, fArray->GetName());
234 }
235 
236 
unsigned int UInt_t
KVExpDB * gExpDB
Definition: KVExpDB.cpp:12
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
ROOT::R::TRInterface & r
char Char_t
bool Bool_t
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition: KVBase.cpp:756
Description of an experimental run in database ,.
Definition: KVDBRun.h:35
KVDBSystem * GetSystem() const
Definition: KVDBRun.cpp:242
KVTarget * GetTarget() const
Definition: KVDBSystem.h:78
KVDBRun * GetDBRun(Int_t number) const
Definition: KVExpDB.h:74
Base class for all detectors or associations of detectors in array which can identify charged particl...
Definition: KVIDTelescope.h:88
virtual void RemoveGrids()
Base class for describing the geometry of a detector array.
Calculation/correction of energy losses of particles through an experimental target.
Definition: KVTarget.h:126
Abstract class implementing necessary methods for setting multidetector parameters for each run of th...
Definition: KVUpDater.h:24
virtual void SetParameters(UInt_t, Bool_t physics_parameters_only=kFALSE)
Definition: KVUpDater.cpp:91
static KVUpDater * MakeUpDater(const Char_t *uri, KVMultiDetArray *)
Definition: KVUpDater.cpp:59
TString fDataSet
name of dataset associated
Definition: KVUpDater.h:27
virtual void SetCalibrationParameters(UInt_t)
Set calibration parameters for this run.
Definition: KVUpDater.cpp:198
virtual void CheckStatusOfDetectors(KVDBRun *)
Check status (present, working) of each detector for run.
Definition: KVUpDater.cpp:217
virtual void SetIdentificationParameters(UInt_t)
Definition: KVUpDater.cpp:157
void SetArray(KVMultiDetArray *)
Definition: KVUpDater.cpp:46
virtual void SetIDGrids(UInt_t)
Definition: KVUpDater.cpp:177
virtual void SetTarget(KVDBRun *)
Definition: KVUpDater.cpp:126
virtual void SetCalibParameters(KVDBRun *)
Override in child classes to set specific calibrations.
Definition: KVUpDater.cpp:230
virtual const char * GetName() const
Longptr_t ExecPlugin(int nargs, const T &... params)
void Error(const char *location, const char *va_(fmt),...)
auto * a