KaliVeda
Toolkit for HIC analysis
KVDataPatchList.cpp
1 //Created by KVClassFactory on Thu Jan 30 11:06:10 2014
2 //Author: John Frankland,,,
3 
4 #include "KVDataPatchList.h"
5 #include "KVDataPatch.h"
6 #include <TPluginManager.h>
7 
9 
10 KVUniqueNameList* KVDataPatchList::fPatchList = nullptr;
11 
12 
15 
16 void KVDataPatchList::FillPatchList()
17 {
18  // Fill static list of patches from KVDataPatch plugin list
19 
20  KVString plugins = GetListOfPlugins("KVDataPatch");
21  if (plugins == "") {
22  Info("FillPatchList", "No data patch plugins defined");
23  return;
24  }
25  plugins.Begin(" ");
26  while (!plugins.End()) {
27  KVString plug = plugins.Next(kTRUE);
28  TPluginHandler* h = LoadPlugin("KVDataPatch", GetPluginURI("KVDataPatch", plug));
29  if (h) {
30  KVDataPatch* p = (KVDataPatch*)h->ExecPlugin(0);
31  fPatchList->Add(p);
32  }
33  else
34  KVError::Warning(this, "FillPatchList", "Cannot load plugin data patch %s", plug.Data());
35  }
36 }
37 
38 
39 
41 
42 void KVDataPatchList::init()
43 {
44  fEventPatches = kFALSE;
45  fParticlePatches = kFALSE;
46  if (!fPatchList) {
47  fPatchList = new KVUniqueNameList;
48  FillPatchList();
49  }
50 }
51 
52 
53 
65 
66 void KVDataPatchList::InitializePatchList(TString dataset, TString datatype, Int_t runnumber,
67  TString dataseries, Int_t datareleasenumber, const TList* streamerinfolist)
68 {
69  // Fill lists of active patches for given data
70  //
71  // If the configuration variable
72  //
73  //~~~
74  // [dataset].DataAnalysis.ApplyDataPatches
75  //~~~
76  //
77  // is set to a value equivalent to (bool)false (i.e. one of 'no', 'off', 'false'),
78  // no patches will be initialised
79 
80  if(!GetDataSetEnv<bool>(dataset, "DataAnalysis.ApplyDataPatches"))
81  return;
82 
83  KVError::Info(this, "InitializePatchList()",
84  "Initializing patches for |%s|%s|%04d|%s|%02d|",
85  dataset.Data(), datatype.Data(), runnumber, dataseries.Data(), datareleasenumber);
86  fActiveEventPatches.Clear();
87  fActiveParticlePatches.Clear();
88  fEventPatches = kFALSE;
89  fParticlePatches = kFALSE;
90  TIter nxtP(fPatchList);
91  KVDataPatch* patch;
92  while ((patch = (KVDataPatch*)nxtP())) {
93  if (patch->IsRequired(dataset, datatype, runnumber, dataseries, datareleasenumber, streamerinfolist)) {
94  if (patch->IsEventPatch()) {
95  fActiveEventPatches.Add(patch);
96  fEventPatches = kTRUE;
97  }
98  if (patch->IsParticlePatch()) {
99  fActiveParticlePatches.Add(patch);
100  fParticlePatches = kTRUE;
101  }
102  }
103  }
104 }
105 
106 
107 
110 
112 {
113  // Apply all currently active patches to event
114 
115  if (fEventPatches) {
116  // Apply event-level patches
117  TIter nxt(&fActiveEventPatches);
118  KVDataPatch* patch;
119  while ((patch = (KVDataPatch*)nxt())) patch->ApplyToEvent(event);
120  }
121  if (fParticlePatches) {
122  // Apply particle-level patches
123  TIter nxt(&fActiveParticlePatches);
124  KVDataPatch* patch;
125  for(auto & rnuc : *event)
126  {
127  while ((patch = (KVDataPatch*)nxt())) patch->ApplyToParticle(&rnuc);
128  nxt.Reset();
129  }
130  }
131 }
132 
133 
134 
137 
139 {
140  // Print list of currently active patches
141  if (!fEventPatches && !fParticlePatches) {
142  Info("Print", "No currently active data patches");
143  return;
144  }
145  if (fEventPatches) {
146  Info("Print", "Currently active event-level patches:");
147  fActiveEventPatches.Print();
148  }
149  if (fParticlePatches) {
150  Info("Print", "Currently active particle-level patches:");
151  fActiveParticlePatches.Print();
152  }
153 }
154 
155 
int Int_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
const char Option_t
winID h TVirtualViewer3D TVirtualGLPainter p
static const Char_t * GetListOfPlugins(const Char_t *base)
Definition: KVBase.cpp:1251
static const Char_t * GetPluginURI(const Char_t *base, const Char_t *plugin)
Definition: KVBase.cpp:1168
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition: KVBase.cpp:795
List of corrections to be applied to reconstructed calibrated data.
void InitializePatchList(TString dataset, TString datatype, Int_t runnumber, TString dataseries, Int_t datareleasenumber, const TList *streamerinfolist)
void Print(Option_t *="") const override
Print list of currently active patches.
void Apply(KVReconstructedEvent *)
Apply all currently active patches to event.
Correction to be applied to reconstructed calibrated data.
Definition: KVDataPatch.h:55
virtual void ApplyToParticle(KVReconstructedNucleus *)=0
virtual void ApplyToEvent(KVReconstructedEvent *)=0
virtual Bool_t IsParticlePatch()=0
virtual Bool_t IsRequired(TString dataset, TString datatype, Int_t runnumber, TString dataseries, Int_t datareleasenumber, const TList *streamerinfolist)=0
virtual Bool_t IsEventPatch()=0
Event containing KVReconstructedNucleus nuclei reconstructed from hits in detectors.
void Clear(Option_t *option="") override
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.
void Add(TObject *obj) override
virtual void Print(Option_t *option, const char *wildcard, Int_t recurse=1) const
void Reset()
virtual void Info(const char *method, const char *msgfmt,...) const
const char * Data() const
TH1 * h
void Warning(UserClass p, const char *location, const char *va_(fmt),...)
Definition: KVError.h:125
void Info(UserClass p, const char *location, const char *va_(fmt),...)
Definition: KVError.h:134
ClassImp(TPyArg)