3{
4 Log(2,
"ShowRec.cpp",
"--- void ReconstructShowers_N3() ---");
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
31 }
32 else {
34 }
35
36
37
38
39
40 TFile* N3_ALG_ANN_TrainingsFile;
42 N3_ALG_ANN_TrainingsFile =
new TFile(Form(
"N3_ALG_ANN_TrainingsFile_PARASET_%d.root",
GLOBAL_PARASETNR),
"RECREATE");
43 }
44
45
46
47 TTree *
simu =
new TTree(
"TreeSignalBackgroundBT",
"TreeSignalBackgroundBT");
50
51
52
53
54
55
56
57
58 TTree *simu_SG = new TTree("TreeSignalBT", "TreeSignalBT");
59 simu_SG->Branch(
"N3_Type", &
N3_Type,
"N3_Type/I");
60 simu_SG->Branch(
"N3_Inputvar",
N3_Inputvar,
"N3_Inputvar[24]/D");
61 TTree *simu_BG = new TTree("TreeBackgroundBT", "TreeBackgroundBT");
62 simu_BG->Branch(
"N3_Type", &
N3_Type,
"N3_Type/I");
63 simu_BG->Branch(
"N3_Inputvar",
N3_Inputvar,
"N3_Inputvar[24]/D");
64
65
66
67
68
69
70
74 }
75
76
77
81 Float_t local_gAli_pat_interim_halfsize=0;
82
85
86
87
88
90
91
92
94
95
96
97
99
101
105
106 Int_t local_NBT=0;
107 Int_t local_NBTMC=0;
108 Int_t local_NBTallMC=0;
109 Int_t local_NBTeMC=0;
110 float_t local_pure=-1;
111 float_t local_purall=-1;
112 Int_t npat_int=0;
113 Int_t npat_total=0;
114 Int_t npatN=0;
115 Int_t npat_Neff=0;
116 Int_t NBT_Neff=0;
117 Int_t NBTMC_Neff=0;
118 Int_t NBTMCe_Neff=0;
119
120
122 cout << endl << endl << "--- Starting Shower for Number " << i << " now: "<<endl;
124 }
125
126
127
128
129
131
133
134
135
136
138
139
140
141
142
143 for (Int_t loop=0; loop<24; ++loop)
N3_Inputvar[loop]=0;
144 Int_t NaddedSGToTrainTree=0;
145 Int_t NaddedBGToTrainTree=0;
146
147
148
149
150
151 Int_t local_gAli_npat=local_gAli->
Npatterns();
152
153 if (
gEDBDEBUGLEVEL>2) cout <<
"--- local_gAli_npat= " << local_gAli_npat << endl;
154
155
156
157 for (Int_t patterloop_cnt=local_gAli_npat-1; patterloop_cnt>=0; --patterloop_cnt) {
158 if (
gEDBDEBUGLEVEL>3) cout <<
"--- --- Doing patterloop_cnt= " << patterloop_cnt << endl;
159
160
161
162
163
165 Int_t btloop_cnt_N=TestPattern->
GetN();
166
167 for (Int_t btloop_cnt=0; btloop_cnt<btloop_cnt_N; ++btloop_cnt) {
170
171
172
173
174
177
178
179
180
181
183
184
185
186
188
189
191
192
195
196
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217 Float_t mindeltaZ=0;
218 Float_t mindT=0;
219 Float_t mindR=0;
220 Float_t mindMinDist=0;
221 Int_t nDifferentSegs=-1;
222 Int_t OffsetNVar=4;
223
224
225
226 Int_t deltaNpl[5]= {0,-1,1,-2,2};
227 Int_t dNpl=0;
228
229
230 for (Int_t loop_deltaNpl = 0; loop_deltaNpl<5; ++loop_deltaNpl) {
235 OffsetNVar+=4;
236 }
237
238
239 OffsetNVar=4;
240
242
243 dNpl=deltaNpl[loop_deltaNpl];
244 mindT=0;
245 mindR=0;
246 mindMinDist=0;
247 nDifferentSegs=-1;
248
249
250
251 N3_FindBestCompliments( seg, TestPattern, local_gAli, dNpl, mindeltaZ, mindT, mindR, mindMinDist, nDifferentSegs );
252
253
254
259 OffsetNVar+=4;
260 }
261
262
263
264
265
266
267
268
269
271 cout << "*******************************************************************"<<endl;
272 cout << "Print out all variables for BT i ___ connected with InBT : *****"<<endl;
273 OffsetNVar=0;
274 printf(
"BT i->ID(), Type, dZ, dR, dT, dMinDist: %07d %d %.03f %.03f %.03f %.03f\n",seg->
ID(),
N3_Type,
N3_Inputvar[OffsetNVar+0],
N3_Inputvar[OffsetNVar+1],
N3_Inputvar[OffsetNVar+2],
N3_Inputvar[OffsetNVar+3]);
275 OffsetNVar=4;
276 cout << "Print out all variables for BT i NOT connected with InBT : *****"<<endl;
277 for (Int_t loop_deltaNpl = 0; loop_deltaNpl<5; ++loop_deltaNpl) {
278 dNpl=deltaNpl[loop_deltaNpl];
279 printf(
"BT i->ID(), Type, dNpl, mindR, mindT, mindMinDist nDifferentSegs, : %07d %d %d %.03f %.03f %.03f %.03f %d \n",seg->
ID(),
N3_Type, dNpl,
N3_Inputvar[OffsetNVar+0],
N3_Inputvar[OffsetNVar+1],
N3_Inputvar[OffsetNVar+2],
N3_Inputvar[OffsetNVar+3]);
280 OffsetNVar+=4;
281 }
282 cout << "*******************************************************************"<<endl;
283 }
284
285
286
287
288
289
290
294 simu_SG->Fill();
295 NaddedSGToTrainTree++;
296 }
297 else {
298
299
300 Double_t currentBGSGRatio= Double_t (NaddedBGToTrainTree)/(1+Double_t(NaddedSGToTrainTree));
301 Double_t currentBGTotalRatio= Double_t (NaddedBGToTrainTree)/(1+Double_t(NaddedSGToTrainTree+NaddedBGToTrainTree));
302
303
304
305
306 Bool_t addBGTrack=kFALSE;
307 Double_t UniformTestNumber=gRandom->Uniform();
308
309
310
311
312 if ( UniformTestNumber > currentBGTotalRatio) addBGTrack=kTRUE;
314
315
316
317 if (addBGTrack) {
319 simu_BG->Fill();
320 NaddedBGToTrainTree++;
321 }
322 }
323
324 }
325 else {
327
328
329
330
331
332
333
334
335
336 Double_t EvalValue=0;
337 Double_t N3_Evalvar4[4];
338 Double_t N3_Evalvar8[8];
339 Double_t N3_Evalvar12[12];
340 Double_t N3_Evalvar16[16];
341 Double_t N3_Evalvar20[20];
342 Double_t N3_Evalvar24[24];
343
347 }
351 }
355 }
359 }
363 }
364 else {
367 }
368
369
370
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
426
427
428
429
430
431
432
433
434
435 }
436
437
438
439
440
441
443
444
445
446
447
448
449 if (seg->
X()==InBT->
X()&&seg->
Y()==InBT->
Y()) {
450
451 ;
452 }
453 else {
454
455
457 }
458 }
459
460
462 CalcTrackDensity(pat_interim,local_gAli_pat_interim_halfsize,npat_int,npat_total,npatN);
463
464
466 }
467
469
470
471
472
473
474
475 delete InBTClone;
476
477
478
479
480
481
483 Int_t NBT=0;
484 Int_t NBTMC=0;
485 Int_t NBTallMC=0;
486 Int_t NBTeMC=0;
487 Double_t eff, purall, pure;
489
490
496 }
498 }
499
500
501
502
505
506
507
508
509
512 }
513
514
515
516
517
518
521 delete local_gAli;
522 local_gAli=0;
524
525 }
526
527
528
532
533
534
535
536
537
538
540 cout << " Now write NN SG/BG Trees with the Inputvariables: --------------------"<<endl;
541 simu_SG->Print();
542 simu_BG->Print();
544 cout << " Now show first entry of SG/BG Trees with the Inputvariables: --------------------"<<endl;
545 cout << " Signal Tree: --------------------"<<endl;
546 simu_SG->Show(0);
547 cout << " Background Tree: --------------------"<<endl;
548 simu_BG->Show(0);
550 cout << "--------------------"<<endl;
551
552
554 cout <<
"void ReconstructShowers_N3() N3_TMLP_ANN->GetStructure() " <<
N3_TMLP_ANN->GetStructure() << endl;
555
556
557
558
559
560 cout << " ------------------------------------------------------------" << endl;
561 cout << " NOW TRAIN THE NETWORK .... " << endl;
563 cout << " NOW TRAIN THE NETWORK .... done." << endl;
564 cout << " Dump Weights into the file .... " << endl;
567 cout << " Dump Weights into the file done. " << endl;
568
569
570 cout << " Use TMLPAnalyzer to see what it looks for " << endl;
574
575 ana->GatherInformations();
576
579
582
585
586 ana->DrawNetwork(0,
"N3_Type==1",
"N3_Type==0");
588
589 cout << " Use TMLPAnalyzer to see what it looks for... done." << endl;
590 cout << " ------------------------------------------------------------" << endl;
591 cout << " NOW WRITE FILES to THE ROOT FILES .... " << endl;
593
594
595 simu_SG->Write();
596 simu_BG->Write();
598 }
602 N3_ALG_ANN_TrainingsFile->Close();
603 cout << " NOW WRITE FILES to THE ROOT FILES .... done. " << endl;
604
605 }
606
607 Log(2,
"ShowRec.cpp",
"--- void ReconstructShowers_N3() done.");
608 return;
609}
void N3_Dump_ALG_MLP_weights(TMultiLayerPerceptron *mlp, Int_t parasetnr)
Definition: ShowRec_Alg_N3.cpp:697
void N3_FindBestCompliments(EdbSegP *seg, EdbPattern *TestPattern, EdbPVRec *local_gAli, Int_t Downstream, Float_t &mindeltaZ, Float_t &mindT, Float_t &mindR, Float_t &mindMinDist, Int_t &nDifferentSegs)
Definition: ShowRec_Alg_N3.cpp:773
void N3_Create_ALG_MLP(TTree *simu, Int_t parasetnr)
Definition: ShowRec_Alg_N3.cpp:656
void N3_Load_ALG_MLP_weights(TMultiLayerPerceptron *mlp, Int_t parasetnr)
Definition: ShowRec_Alg_N3.cpp:683
Double_t N3_OutputValue
Definition: ShowRec_Alg_N3.h:15
Int_t N3_Type
Definition: ShowRec_Alg_N3.h:12
Double_t N3_ANN_OUTPUTTHRESHOLD
Definition: ShowRec_Alg_N3.h:24
Int_t N3_ANN_EQUALIZESGBG
Definition: ShowRec_Alg_N3.h:25
Int_t N3_ANN_PLATE_DELTANMAX
Definition: ShowRec_Alg_N3.h:20
Double_t N3_Inputvar[24]
Definition: ShowRec_Alg_N3.h:8
Int_t N3_ANN_NTRAINEPOCHS
Definition: ShowRec_Alg_N3.h:22
void CalcTrackDensity(EdbPattern *pat_interim, Float_t pat_interim_halfsize, Int_t &npat_int, Int_t &npat_total, Int_t &npatN)
Definition: ShowRec.cpp:8749
void TransferShowerObjectArrayIntoEntryOfTreebranchShowerTree(TTree *treebranchtree, TObjArray *segarray)
Definition: ShowRec.cpp:7940
void CalcEffPurOfShower2(TObjArray *arr, Int_t &NBT, Int_t &NBTMC, Int_t &NBTallMC, Int_t &NBTeMC, Double_t &purall, Double_t &pure, Int_t NBT_Neff, Int_t NBTMC_Neff, Int_t NBTMCe_Neff)
Definition: ShowRec.cpp:7631
void PrintShowerObjectArray(TObjArray *segarray)
Definition: ShowRec.cpp:6967
EdbPVRec * TransformEdbPVRec(EdbPVRec *gAli, EdbSegP *InitiatorBT)
DEBUG OPENMP TEST!!!!!!!
Definition: ShowRec.cpp:6299
void CalcEfficencyNumbers(EdbPattern *pat_interim, Int_t MCCheck, Int_t &NBT_Neff, Int_t &NBTMC_Neff, Int_t &NBTMCe_Neff)
Definition: ShowRec.cpp:8771
Int_t GLOBAL_INBTSHOWERNR
Definition: ShowRec.h:80
Double_t GLOBAL_trckdens
Definition: ShowRec.h:39
EdbPVRec * GLOBAL_gAli
Definition: ShowRec.h:73
Int_t cmd_OUTPUTLEVEL
Definition: ShowRec.h:33
Int_t GLOBAL_PARASETNR
Definition: ShowRec.h:79
Int_t GLOBAL_EvtBT_FlagArray[99999]
Definition: ShowRec.h:51
TObjArray * GLOBAL_ShowerSegArray
Definition: ShowRec.h:76
Int_t GLOBAL_InBT_MC
Definition: ShowRec.h:43
Double_t GLOBAL_EvtBT_EArray[99999]
Definition: ShowRec.h:52
Int_t GLOBAL_EvtBT_MCArray[99999]
Definition: ShowRec.h:51
TTree * TREE_ShowRecEff
Definition: ShowRec.h:62
Float_t shower_trackdensb
Definition: ShowRec.h:395
Int_t GLOBAL_InBT_Flag
Definition: ShowRec.h:43
Double_t GLOBAL_EvtBT_E
Definition: ShowRec.h:50
Double_t GLOBAL_InBT_TanTheta
Definition: ShowRec.h:44
Double_t GLOBAL_InBT_E
Definition: ShowRec.h:44
Double_t CUT_PARAMETER[10]
Definition: ShowRec.h:78
Int_t GLOBAL_EvtBT_MC
Definition: ShowRec.h:49
Int_t GLOBAL_InBTArrayEntries
Definition: ShowRec.h:75
Double_t GLOBAL_EvtBT_TanThetaArray[99999]
Definition: ShowRec.h:52
Double_t GLOBAL_EvtBT_TanTheta
Definition: ShowRec.h:50
TTree * TREE_ShowShower
Definition: ShowRec.h:68
Int_t GLOBAL_EvtBT_Flag
Definition: ShowRec.h:49
TObjArray * GLOBAL_InBTArray
Definition: ShowRec.h:74
Definition: EdbPVRec.h:148
Int_t Npatterns() const
Definition: EdbPattern.h:366
EdbPattern * GetPattern(int id) const
Definition: EdbPattern.cxx:1721
Float_t P() const
Definition: EdbSegP.h:152
Float_t Theta() const
Definition: EdbSegP.h:184
Int_t MCEvt() const
Definition: EdbSegP.h:145
Int_t Flag() const
Definition: EdbSegP.h:149
Int_t GetN() const
Definition: EdbPattern.h:65
Int_t cmd_ALN3DUMP
Definition: ShowRec.h:35
Double_t GetDistToAxis(EdbSegP *segAxis, EdbSegP *segTest)
Definition: ShowRecCalculatingFunctions.cpp:185
Int_t cmd_ALN3TRAIN
Definition: ShowRec.h:34
TCanvas * mlpa_canvas
Definition: testBGReduction_By_ANN.C:66