FEDRA emulsion software from the OPERA Collaboration
EdbShowAlgE.h
Go to the documentation of this file.
1#ifndef ROOT_EdbShowAlgE
2#define ROOT_EdbShowAlgE
3
4#include "TROOT.h"
5#include "TFile.h"
6#include "TVector3.h"
7#include "TIndexCell.h"
8#include "TArrayF.h"
9#include "TBenchmark.h"
10#include "TMultiLayerPerceptron.h"
11#include "TMLPAnalyzer.h"
12#include "TCanvas.h"
13#include "TObjString.h"
14
15#include "EdbVertex.h"
16#include "EdbPVRec.h"
17#include "EdbPhys.h"
18#include "EdbMath.h"
20#include "EdbLog.h"
21#include "EdbPattern.h"
22#include "EdbShowerP.h"
23
24using namespace std;
25
26//______________________________________________________________________________
27//___
28//___ Declaration of EdbShowAlgE Class:
29//___
30//___
31//___ STILL TO WRITE
32//___
33//______________________________________________________________________________
34
35
36
37
38
39
40//______________________________________________________________________________
41
42class EdbShowAlgE : public TObject {
43
44private:
45
46 // Parametrization Name: this name sets imprtant variables depending on the parametrization:
49 Int_t eShowAlgEPlatesN; // used only to set names and distingiush. Not used for any reconstructon
50 //or measurement!
51
52
54
55
56
57 // TObjArray storing Reconstructed Showers:
58 TObjArray* eRecoShowerArray;
60
61
62 // TObjArray storing TMultiLayerPerceptron for different shower film length:
63 TObjArray* eMLPArray;
64 Int_t eMLPArrayN; // (==eMLP_InputNeuronsArrayN)
65
66 // Wheter this is used as Training or RunMethod:
68 Bool_t eDoANNRun;
69
70 // Variables as arrays for the In/Outut of the ANN.
71 // They have to be given in Float_t* array, to root specifications of
72 // the implementation... (?? where to read this ??)
73
74 // TODO CHECK THIS !!!!!
75 // With the new gcc --version 7.30 (shipped with Ubuntu 18.04)
76 // compilation does stop here with an error (as of 2018/03/28).
77 // Why?
78
79 // It seems like (found in an old root post) when putting
80 // the ! behind the commend behind the variable, then
81 // somehow it ist made transient and the cint (now cling) can handle
82 // this.
83
84// Float_t eInANN[70];
85 Float_t* eInANN = new Float_t[70];
86 // Float_t* eInANN; // worked with gcc 4.4, but with gcc 7.3
87 Float_t eOutANN;
88 // Float_t* eInfoANN; // worked with gcc 4.4, but with gcc 7.3
89 Float_t* eInfoANN = new Float_t[70];
90
91 // Histograms storing the eInANN distributions:
92 TH1F* eInANN_Hist[70];
93
94
95
96
97 TMultiLayerPerceptron* eMLP_Simple;
98
101
102 TString eMLP_Layout;
105
106
110
112
116
120
121
122
123 // Reset All Default Variables:
124 void Set0();
125
126 // Set Default Variables
127 void Init();
128 void Init(TString ParaName);
129
130 // Create Input Histos
131 void CreateInputHistos();
132
133 // Fill Input Histos with Entries by eMLP_SimpleTree:
135
136 // Simple Layout Creation function: n:n+1:n:inputtype
137 TString CreateMLPLayout(Int_t NrOfANNInputNeurons);
138
139
140
141
142
143 void ClearPlateBinning();
145 void AddWeightFilePlate(TString tmpString, Int_t dospec);
146
147 Bool_t CheckStringToShowAlgEParaName(TString tmpString2);
148
149 // Helper Function:
150 int GetLastBinHistoFilles(TH1* h);
151
152
153public:
154
156 EdbShowAlgE(TString ShowAlgEParaName);
157 EdbShowAlgE(TObjArray* RecoShowerArray);
158 EdbShowAlgE(TObjArray* RecoShowerArray, TString ShowAlgEParaName);
159
160
161 virtual ~EdbShowAlgE(); // virtual constructor due to inherited class
162
163
164
165
166
167
168
169
170 // Set Functions
171 inline void SetRecoShowerArray(TObjArray* RecoShowerArray) {
173 }
174
175 inline void SetMLPLayout(TString layout) {
176 eMLP_Layout = layout;
177 }
178 inline void SetMLPWeightFileName(TString weightfilename) {
179 eMLP_WeightFileName = weightfilename;
180 }
181 inline void SetMLPInputFileName(TString MLP_InputFileName) {
182 eMLP_InputFileName = MLP_InputFileName;
183 }
184 inline void SetMLPTrainEpochs(Int_t nep) {
185 eMLP_TrainEpochs = nep;
186 }
187 inline void SetMLPArrayN(Int_t MLPArrayN) {
188 eMLPArrayN = MLPArrayN;
189 }
190
191 inline void SetPlatesN(Int_t ShowAlgEPlatesN) {
192 eShowAlgEPlatesN = ShowAlgEPlatesN;
193 }
194
195
196 void SetDoTrain(Int_t type);
197 void SetDoRun(Int_t type);
198
199 void SetInputHistosPara(Int_t ParaType);
204
205 void SetWriteMLPWeightFile(Int_t type);
206 void SetWriteMLPInputFile(Int_t type);
207 void SetReadMLPInputFile(Int_t type);
208
209 void ReadMLPInputFile();
210 void WriteMLPInputFile();
211
212
213 // Get Functions
214 inline TMultiLayerPerceptron* GetMLP() const {
215 return eMLP_Simple;
216 }
217
218 inline TH1F* GetHistInANN(Int_t nr) const {
219 return eInANN_Hist[nr];
220 }
221
222 inline TString GetMLPLayout() {
223 return eMLP_Layout;
224 }
225 inline TString GetMLPWeightFileName() {
226 return eMLP_WeightFileName;
227 }
228 inline TString GetMLPInputFileName() {
229 return eMLP_InputFileName;
230 }
231 inline Int_t SetMLPTrainEpochs() {
232 return eMLP_TrainEpochs;
233 }
234
235
237 void Print();
238
239
240
241 // Main functions for using this ShowerAlgorithm Object.
242 // Structure is made similar to OpRelease, where
243 // Initialize, Execute, Finalize
244 // give the three columns of the whole thing.
245 // Since these functions depend on the algorithm type they are made virtual
246 // and implemented in the inherited classes.
247 virtual void Initialize();
248 virtual void Execute();
249 virtual void Finalize();
250
251
252
254
255// void TESTTRAIN();
256 void Create_MLP();
257 void Create_MLPTree();
258 void Fill_MLPTree();
259// void Train_MLP();
260// void Run_MLP();
261
262 void TESTRUN();
263 void SetInputHistos(TH1F* h, Int_t nbin, Double_t lower, Double_t upper);
264
265
266
267
268
269 // CreateStandardWeightFileStrings
273 void ResetPlateBinning();
274
275 Int_t CheckPlateAndPlateBinning(Int_t Plate);
276 void AddWeightFile(TString tmpString, Int_t Plate, TString tmpString2);
277
278
279 void CreateMLPLayouts();
280 void CreateMLPLayouts_FJ();
281 void CreateMLPLayouts_LT();
282 void CreateMLPLayouts_YC();
283 void CreateMLPLayouts_JC();
284 void CreateMLPLayouts_XX();
285 void CreateMLPLayouts_YY();
286 void CreateMLPLayout_YC(Int_t nr);
287 void CreateMLPLayout_XX(Int_t nr);
288 void CreateMLPLayout_YY(Int_t nr);
289
290
294
298
300
301
302 void CreateMLPs();
303 void CreateMLPArray();
304 void LoadMLPWeights();
305 void LoadMLPWeights(Int_t nr);
306
307 void SetBinsInputHistos();
312
313
314 void FillMLP_SimpleTree_YC(EdbShowerP* show, Int_t ShowAlgEParaNr);
316 void FillMLP_SimpleTree_XX(EdbShowerP* show, Int_t ShowAlgEParaNr);
318 void FillMLP_SimpleTree_YY(EdbShowerP* show, Int_t ShowAlgEParaNr);
320 void FillMLP_SimpleTree();
321
322 void WriteMLP_SimpleTree(TString filename);
323
324 void Train();
325 void Run();
326 void DumpWeights();
327
328
329 int GetMLPArrayNr(Int_t NPlToCheck);
330
332
333
334 // Read parameters out of default.par file
335 int ReadShowAlgEPar(const char *file);
336
337
338
339 ClassDef(EdbShowAlgE,1); // Root Class Definition for my Objects
340};
341
342
343//______________________________________________________________________________
344
345#endif /* ROOT_EdbShowAlg */
const char filename[256]
Definition: RecDispNU.C:83
TObjArray * RecoShowerArray
Definition: Shower_E_FromShowerRoot.C:12
Definition: EdbShowAlgE.h:42
TH1F * GetHistInANN(Int_t nr) const
Definition: EdbShowAlgE.h:218
void CreateInputNeuronsArray_YC()
Definition: EdbShowAlgE.cxx:1951
void CreateInputHistos()
Definition: EdbShowAlgE.cxx:1145
Int_t SetMLPTrainEpochs()
Definition: EdbShowAlgE.h:231
TString GetMLPLayout()
Definition: EdbShowAlgE.h:222
void SetWriteMLPWeightFile(Int_t type)
Definition: EdbShowAlgE.cxx:1015
Int_t eMLP_InputNeurons
Definition: EdbShowAlgE.h:113
void Set0()
Definition: EdbShowAlgE.cxx:100
void SetInputHistosPara_YC()
Definition: EdbShowAlgE.cxx:1205
TObjArray * eRecoShowerArray
Definition: EdbShowAlgE.h:58
int ReadShowAlgEPar(const char *file)
DEBUG ---------------------------— TEST DEVOPLEMENT.
Definition: EdbShowAlgE.cxx:802
void SetBinsInputHistos_FJ()
Definition: EdbShowAlgE.cxx:2216
void PrintWeightFileStrings()
Definition: EdbShowAlgE.cxx:1560
void CreateMLPLayouts_YC()
Definition: EdbShowAlgE.cxx:1660
void FillMLP_SimpleTree_YY()
Definition: EdbShowAlgE.cxx:629
void SetDoTrain(Int_t type)
Definition: EdbShowAlgE.cxx:995
TString eMLP_Layout
Definition: EdbShowAlgE.h:102
TString GetMLPInputFileName()
Definition: EdbShowAlgE.h:228
void FillInputNeuronsArray_YC()
Definition: EdbShowAlgE.cxx:1975
void FillMLP_SimpleTree()
Definition: EdbShowAlgE.cxx:540
void SetBinsInputHistos_YY()
Definition: EdbShowAlgE.cxx:2254
void Create_MLP()
DEBUG ---------------------------— TEST DEVOPLEMENT.
Definition: EdbShowAlgE.cxx:774
void ResetWeightFileNameArray()
Definition: EdbShowAlgE.cxx:1363
Int_t eMLP_TrainEpochs
Definition: EdbShowAlgE.h:111
void ReadMLPInputFile()
Definition: EdbShowAlgE.cxx:527
virtual void Initialize()
Definition: EdbShowAlgE.cxx:242
void SetInputHistosPara_YY()
Definition: EdbShowAlgE.cxx:1247
void SetInputHistos(TH1F *h, Int_t nbin, Double_t lower, Double_t upper)
Definition: EdbShowAlgE.cxx:1180
void WriteMLP_SimpleTree(TString filename)
Definition: EdbShowAlgE.cxx:652
void Init()
Definition: EdbShowAlgE.cxx:163
void SetInputHistosPara_FJ()
Definition: EdbShowAlgE.cxx:1214
void CreateMLPLayouts_JC()
Definition: EdbShowAlgE.cxx:1684
void TESTRUN()
Definition: EdbShowAlgE.cxx:420
TArrayI * eMLP_InputNeuronsArray
Definition: EdbShowAlgE.h:114
void SetInputHistosPara(Int_t ParaType)
Definition: EdbShowAlgE.cxx:1190
TMultiLayerPerceptron * GetMLP() const
Definition: EdbShowAlgE.h:214
void Create_MLPTree()
Definition: EdbShowAlgE.cxx:1047
void CreateMLPLayout_YY(Int_t nr)
Definition: EdbShowAlgE.cxx:1855
TString GetMLPWeightFileName()
Definition: EdbShowAlgE.h:225
void CreateMLPLayouts_LT()
Definition: EdbShowAlgE.cxx:1650
void Fill_MLPTree()
Definition: EdbShowAlgE.cxx:1072
void FillMLP_SimpleTree_XX()
Definition: EdbShowAlgE.cxx:607
void SetWriteMLPInputFile(Int_t type)
Definition: EdbShowAlgE.cxx:1026
int GetLastBinHistoFilles(TH1 *h)
Definition: EdbShowAlgE.cxx:2490
TString eShowAlgEParaName
Definition: EdbShowAlgE.h:47
void CreateMLPLayouts()
Definition: EdbShowAlgE.cxx:1599
void SetMLPLayout(TString layout)
Definition: EdbShowAlgE.h:175
Bool_t eMLP_SimpleIsDone
Definition: EdbShowAlgE.h:99
void CreateMLPs()
Definition: EdbShowAlgE.cxx:2093
Float_t eOutANN
Definition: EdbShowAlgE.h:87
ClassDef(EdbShowAlgE, 1)
void SetRecoShowerArray(TObjArray *RecoShowerArray)
Definition: EdbShowAlgE.h:171
void ResetPlateBinning()
Definition: EdbShowAlgE.cxx:1316
void SetMLPArrayN(Int_t MLPArrayN)
Definition: EdbShowAlgE.h:187
void SetInputHistosPara_XX()
Definition: EdbShowAlgE.cxx:1223
void FillInputNeuronsArray_YY()
Definition: EdbShowAlgE.cxx:2068
void Run()
Definition: EdbShowAlgE.cxx:285
TString eMLP_InputFileName
Definition: EdbShowAlgE.h:117
Int_t eShowAlgEPlatesN
Definition: EdbShowAlgE.h:49
void AddWeightFile(TString tmpString, Int_t Plate, TString tmpString2)
Definition: EdbShowAlgE.cxx:1498
void SetDoRun(Int_t type)
Definition: EdbShowAlgE.cxx:1004
void SetBinsInputHistos_YC()
Definition: EdbShowAlgE.cxx:2225
TString CreateMLPLayout(Int_t NrOfANNInputNeurons)
Definition: EdbShowAlgE.cxx:1299
Int_t eMLP_InputNeuronsArrayN
Definition: EdbShowAlgE.h:115
TObjArray * eMLP_LayoutArray
Definition: EdbShowAlgE.h:103
virtual void Execute()
Definition: EdbShowAlgE.cxx:248
void SetMLPWeightFileName(TString weightfilename)
Definition: EdbShowAlgE.h:178
TCanvas * GetHistoCanvas()
Definition: EdbShowAlgE.cxx:1161
void Print()
Definition: EdbShowAlgE.cxx:262
TMultiLayerPerceptron * eMLP_Simple
Definition: EdbShowAlgE.h:97
Bool_t eMLP_ReadMLPInputFile
Definition: EdbShowAlgE.h:119
Bool_t eDoANNRun
Definition: EdbShowAlgE.h:68
void Train()
Definition: EdbShowAlgE.cxx:690
Int_t eRecoShowerArrayN
Definition: EdbShowAlgE.h:59
void WriteMLPInputFile()
Definition: EdbShowAlgE.cxx:506
void SetBinsInputHistos()
Definition: EdbShowAlgE.cxx:2185
void CreateStandardWeightFileStrings()
Definition: EdbShowAlgE.cxx:1402
Float_t * eInANN
Definition: EdbShowAlgE.h:85
Int_t eMLPArrayN
Definition: EdbShowAlgE.h:64
void SetReadMLPInputFile(Int_t type)
Definition: EdbShowAlgE.cxx:1036
void CreateInputNeuronsArray_YY()
Definition: EdbShowAlgE.cxx:2044
void CreateInputNeuronsArray()
Definition: EdbShowAlgE.cxx:1915
Int_t eShowAlgEParaNr
Definition: EdbShowAlgE.h:48
TString eMLP_WeightFileName
Definition: EdbShowAlgE.h:108
TObjArray * eMLPArray
Definition: EdbShowAlgE.h:63
void CreateMLPLayouts_YY()
Definition: EdbShowAlgE.cxx:1717
Bool_t eMLP_WriteWeightFile
Definition: EdbShowAlgE.h:107
Bool_t eMLP_WriteMLPInputFile
Definition: EdbShowAlgE.h:118
void FillInputHistosPara_XX()
Definition: EdbShowAlgE.cxx:1269
void CreateMLPLayout_YC(Int_t nr)
Definition: EdbShowAlgE.cxx:1740
TH1F * eInANN_Hist[70]
Definition: EdbShowAlgE.h:92
Int_t CheckPlateAndPlateBinning(Int_t Plate)
Definition: EdbShowAlgE.cxx:1581
TString eMLP_WeightFileNameArray[10]
Definition: EdbShowAlgE.h:109
void SetPlatesN(Int_t ShowAlgEPlatesN)
Definition: EdbShowAlgE.h:191
Bool_t CheckStringToShowAlgEParaName(TString tmpString2)
Definition: EdbShowAlgE.cxx:2480
void CreateMLPArray()
Definition: EdbShowAlgE.cxx:2147
void FillMLP_SimpleTree_YC()
Definition: EdbShowAlgE.cxx:584
virtual void Finalize()
Definition: EdbShowAlgE.cxx:255
void DumpWeights()
Definition: EdbShowAlgE.cxx:668
void AddWeightFilePlate(TString tmpString, Int_t dospec)
Definition: EdbShowAlgE.cxx:1437
Bool_t eDoANNTrain
Definition: EdbShowAlgE.h:67
void ClearPlateBinning()
Definition: EdbShowAlgE.cxx:1338
void CreateMLPLayout_XX(Int_t nr)
Definition: EdbShowAlgE.cxx:1799
void SetBinsInputHistos_XX()
Definition: EdbShowAlgE.cxx:2239
void CreateMLPLayouts_XX()
Definition: EdbShowAlgE.cxx:1694
void LoadMLPWeights()
Definition: EdbShowAlgE.cxx:2157
void CreateMLPLayouts_FJ()
Definition: EdbShowAlgE.cxx:1640
Float_t * eInfoANN
Definition: EdbShowAlgE.h:89
virtual ~EdbShowAlgE()
Definition: EdbShowAlgE.cxx:91
TTree * eMLP_SimpleTree
Definition: EdbShowAlgE.h:100
Bool_t eMLP_LayoutArrayIsDone
Definition: EdbShowAlgE.h:104
void FillInputNeuronsArray_XX()
Definition: EdbShowAlgE.cxx:2020
TArrayI * eShowAlgEPlateBinning
Definition: EdbShowAlgE.h:53
int GetMLPArrayNr(Int_t NPlToCheck)
Definition: EdbShowAlgE.cxx:397
void CreateStandardMLPArrayN()
Definition: EdbShowAlgE.cxx:1374
void CreateInputNeuronsArray_XX()
Definition: EdbShowAlgE.cxx:1996
void SetMLPTrainEpochs(Int_t nep)
Definition: EdbShowAlgE.h:184
void SetMLPInputFileName(TString MLP_InputFileName)
Definition: EdbShowAlgE.h:181
Definition: EdbShowerP.h:28
TFile * file
Definition: write_pvr.C:3
Definition: AlignmentCint.cxx:51
new TCanvas()
Int_t type
Definition: testBGReduction_By_ANN.C:15