4{
5 Log(2,
"ShowRec.cpp",
"--- void FillGlobalInBTArrayNEW() ---");
6
7
8
9
10
11
12
16
17
18
19 cout << "---!! DOWNSTREAM ORDER ASSUMED !!---"<<endl;
20 cout << "---!! IF PROGRAM CRASH HERE, CHECK YOUR INPUT FP,NP;MP;LP !!---"<<endl;
21
22 cout << "---!! TO BE DONE: WHAT IF BRICK IS IN UPSTREAM ORDERING ??? !!---"<<endl;
23
27
28
29
31
35
36
38 cout << "--- FillGlobalInBTArray: DOWNSTREAM ORDER" <<endl;
39 cout <<
"--- npat = " <<
npat << endl;
40 cout << "--- firstplate = " << firstplate << endl;
41 cout << "--- middleplate = " << middleplate << endl;
42 cout << "--- lastplate = " << lastplate << endl;
43 cout <<
" GLOBAL_gAli->GetPattern(firstplate)->Z() = " <<
GLOBAL_gAli->
GetPattern(firstplate)->
Z() << endl;
44 cout <<
" GLOBAL_gAli->GetPattern(middleplate)->Z() = " <<
GLOBAL_gAli->
GetPattern(middleplate)->
Z() << endl;
46 }
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 cout << "Technical Realisation to be implemented here .... " << endl;
93
94 TObjArray* arrayIntermediate = new TObjArray();
95
96
97
98
99
100
101
102
103
104
105
106
107
108
110
111 if (
gEDBDEBUGLEVEL>2) cout <<
"--- Doing filling InBT case cmd_LT>0"<<endl;
114 TFile * fil = new TFile("linked_tracks.root");
115 TTree*
tr= (TTree*)fil->Get(
"tracks");
116 TClonesArray *seg= new TClonesArray("EdbSegP",60);
117 int nentr = int(
tr->GetEntries());
118 int nseg,n0,npl;
119 tr->SetBranchAddress(
"t.", &
t );
120 tr->SetBranchAddress(
"s", &seg );
121 tr->SetBranchAddress(
"nseg", &nseg );
122 tr->SetBranchAddress(
"n0", &n0 );
123 tr->SetBranchAddress(
"npl", &npl );
124
125
126
127 for (int i=0; i<nentr; i++ ) {
130
131
132 for (int k=0; k<nseg; k++ ) {
133
134 if (
cmd_LT==1 && k>0)
continue;
135 if (
cmd_LT==2 && k<nseg-1)
continue;
136
139
140
141
142
143
144
145
146 Float_t patZ=segment->
Z();
147 if (patZ<GLOBAL_gAli__firstplate_Z || patZ>GLOBAL_gAli__middleplate_Z) continue;
148
149 arrayIntermediate->Add(segment);
150
151 }
152 }
154 delete fil;
155 if (
gEDBDEBUGLEVEL>2) cout <<
"--- Filled " << arrayIntermediate->GetEntries() <<
" Segments into arrayIntermediate."<<endl;
156 }
158 cout << "cmd_LT==0" << endl;
159 for (Int_t nr=0; nr<
npat; ++nr) {
160
161
162
163
164
165
166
167
169
170
171 Bool_t InRange=1;
172 if (patZ<GLOBAL_gAli__firstplate_Z || patZ>GLOBAL_gAli__middleplate_Z) InRange=0;
173
174 if ( !InRange) continue;
175
176
177
180 arrayIntermediate->Add(segment);
181 }
182 }
183 }
184
185 else {
186 cout << "--- Attention: given cmd_LT value does not macht any criterion. " << endl;
187 cout << "--- Dont fill the arrayIntermediate with anything." << endl;
188 }
189
190 cout << "--- Criterion 0) Source done." << endl;
191 cout << "--- Criterion 1) Plate range done." << endl;
192 cout << "--- arrayIntermediate->GetEntries() = " << arrayIntermediate->GetEntries() << endl;
193
194
195
196
197
198
199
200
201 TObjArray* arrayIntermediate2 = new TObjArray();
202
203 Int_t nEnt = arrayIntermediate->GetEntries();
204 Int_t numberMC;
205
206 for (Int_t n=0; n<nEnt; ++n) {
207 segment=(
EdbSegP*) arrayIntermediate->At(n);
208 numberMC = segment->
MCEvt();
209 if (
cmd_MC == 0 ) arrayIntermediate2->Add(segment);
210 if (
cmd_MC == 1 )
if (numberMC>=0) arrayIntermediate2->Add(segment);
211 if (
cmd_MC == 2 )
if (numberMC <0) arrayIntermediate2->Add(segment);
212 }
213 cout << "--- Criterion 2) MC flag range done." << endl;
214 cout << "--- arrayIntermediate2->GetEntries() = " << arrayIntermediate2->GetEntries() << endl;
215
216
217
218
219
220
221
222
223 TObjArray* arrayIntermediate3 = new TObjArray();
224
225
227 arrayIntermediate3 = arrayIntermediate2;
228 }
229 else {
230 nEnt = arrayIntermediate2->GetEntries();
231 Int_t numberPDGId;
232 for (Int_t n=0; n<nEnt; ++n) {
233 segment=(
EdbSegP*) arrayIntermediate2->At(n);
234
235 numberPDGId = segment->
Flag();
236 if (numberPDGId ==
cmd_MCFL ) arrayIntermediate3->Add(segment);
237 }
238 }
239 cout << "--- Criterion 3) PDG-value done." << endl;
240 cout <<
"--- Criterion 3) cmd_MCFL = " <<
cmd_MCFL << endl;
241 cout << "--- arrayIntermediate3->GetEntries() = " << arrayIntermediate3->GetEntries() << endl;
242
243
244
245
246
247
248
249
250
251
252 TObjArray* arrayIntermediate4 = new TObjArray();
254 arrayIntermediate4 = arrayIntermediate3 ;
255 }
256 else {
257
258 TObjArray* arrayIntermediateBG = new TObjArray();
259 TObjArray* arrayIntermediateMC = new TObjArray();
260 TObjArray* arrayIntermediateFHZP = new TObjArray();
261
262 nEnt = arrayIntermediate3->GetEntries();
263 for (Int_t n=0; n<nEnt; ++n) {
264 segment=(
EdbSegP*) arrayIntermediate3->At(n);
265 if ( segment->
MCEvt()<0) arrayIntermediateBG->Add(segment);
266 else arrayIntermediateMC->Add(segment);
267 }
268
269
272 Int_t NarrayIntermediateMC=arrayIntermediateMC->GetEntries();
273 Bool_t OtherSegGreaterPSameMC=kFALSE;
274 Bool_t OtherSegLowerZSameMC=kFALSE;
275 Int_t segMC=-1;
276 Float_t segZ=-1;
277 Int_t segCompMC=-1;
278
279
280
281 Int_t segMCmin=NarrayIntermediateMC;
282 Int_t segMCmax=-1;
283
284 for (Int_t n=0; n<NarrayIntermediateMC; ++n) {
285 seg=(
EdbSegP*) arrayIntermediateMC->At(n);
286 segMC = seg->
MCEvt();
288 if (segMC>segMCmax) segMCmax = segMC;
289 if (segMC<segMCmin) segMCmin = segMC;
290 }
291
292
293
294
295
296
298 if (
cmd_HPLZ == 1) cout <<
"Take highest P() segment per each MCEvt." << endl;
299 if (
cmd_HPLZ == 2) cout <<
"Take lowest Z() segment per each MCEvt." << endl;
300
301
302 Float_t segP, segZ;
303 Float_t segPmax[segMCmax+1];
304 Int_t segn[segMCmax+1];
305 Float_t segZmin[segMCmax+1];
306 Int_t segm[segMCmax+1];
307
308
309 for (Int_t nrMC=segMCmin; nrMC<=segMCmax; ++nrMC) {
310 segPmax[nrMC]=0;
311 segn[nrMC]=-1;
312 segZmin[nrMC]=9999999999;
313 segm[nrMC]=-1;
314 }
315
317 for (Int_t n=0; n<NarrayIntermediateMC; ++n) {
318 seg=(
EdbSegP*) arrayIntermediateMC->At(n);
319 segMC = seg->
MCEvt();
322 if (segP>segPmax[segMC]) {
323 segPmax[segMC] = segP;
324 segn[segMC] = n;
325 }
326 if (segZ<segZmin[segMC]) {
327 segZmin[segMC] = segZ;
328 segm[segMC] = n;
329 }
330
331 if (TMath::Abs(segZ-segZmin[segMC])<0.1) {
332
333 seg2=(
EdbSegP*) arrayIntermediateMC->At(segm[segMC]);
334
335 if ( segP > seg2->
P() ) {
336 segZmin[segMC] = segZ;
337 segm[segMC] = n;
338 }
339 }
340 }
341
342 Int_t SegHPLZNumberInArray=0;
343 for (Int_t nrMC=segMCmin; nrMC<=segMCmax; ++nrMC) {
344 if (segn[nrMC]==-1) continue;
345 if (
cmd_HPLZ == 1) SegHPLZNumberInArray = segn[nrMC];
346 if (
cmd_HPLZ == 2) SegHPLZNumberInArray = segm[nrMC];
347
348
349 seg=(
EdbSegP*) arrayIntermediateMC->At(segn[nrMC]);
350
351
352 seg=(
EdbSegP*) arrayIntermediateMC->At(segm[nrMC]);
353
354
355
356
357 seg=(
EdbSegP*) arrayIntermediateMC->At(SegHPLZNumberInArray);
358 arrayIntermediateFHZP->Add(seg);
359 }
360
361 cout << " Added all FHZP segments. Number of entries = " << arrayIntermediateFHZP->GetEntries() << endl;
362
363 }
364
365 else {
366 cout << "Warning: unsupported cmd_HPLZ value. Do no cut." << endl;
367 arrayIntermediateFHZP = arrayIntermediate3 ;
368 }
369
370
371
372
373 nEnt = arrayIntermediateFHZP->GetEntries();
374 for (Int_t n=0; n<nEnt; ++n) {
375 segment=(
EdbSegP*) arrayIntermediateFHZP->At(n);
376 arrayIntermediate4->Add(segment);
377 }
378 nEnt = arrayIntermediateBG->GetEntries();
379 for (Int_t n=0; n<nEnt; ++n) {
380 segment=(
EdbSegP*) arrayIntermediateBG->At(n);
381 arrayIntermediate4->Add(segment);
382 }
383
384 }
385
386 cout << "--- Criterion 4) criterion HPLZ " << endl;
387 cout <<
"--- Criterion 4) cmd_HPLZ = " <<
cmd_HPLZ << endl;
388 cout << "--- arrayIntermediate4->GetEntries() = " << arrayIntermediate4->GetEntries() << endl;
389
390 cout << "---- " << endl << endl;
391 cout << "TODO HERE: CRITERION 5 VTX IP CUT ... " << endl;
392 cout << "TODO HERE: CRITERION 5 VTX IP CUT ... " << endl;
393 cout << "WARNING As of July 4th 2018, the VTX IP CUT is not yet implemented " << endl;
394 cout << "in the new FillGlobalInBTArrayNEW() function. TO BE DONE !!! " << endl;
395 cout << "TODO HERE: CRITERION 5 VTX IP CUT ... " << endl;
396 cout << "TODO HERE: CRITERION 5 VTX IP CUT ... " << endl;
397 cout << "---- " << endl << endl;
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
416
417 cout << "GLOBAL_InBTArray filling done.................."<<endl;
419 cout << "--- GLOBAL_InBTArray->GetEntries() = 0 . RETURN FILL FUNCTION !" << endl;
420 return;
421 }
422
427 cout <<
"--- GLOBAL_InBTArray->GetEntries() = " <<
GLOBAL_InBTArray->GetEntries() << endl;
428 cout << "--- GLOBAL_InBTArray->At(0) = " << endl;
430 cout << "--- GLOBAL_InBTArray->At(Last) = " << endl;
432 }
433
436 for (Int_t n=0; n<GLOBAL_InBTArrayN; ++n) {
439 }
440 }
441
442
443 cout << "What to do, if GLOBAL_InBTArray has zero entries???" << endl;
444 cout << "Only logical would be that the program stops." << endl;
445 return;
446}
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
TTree * tr
Definition: Shower_E_FromShowerRoot.C:5
Int_t npat
Definition: Xi2HatStartScript.C:33
EdbPVRec * GLOBAL_gAli
Definition: ShowRec.h:73
TObjArray * GLOBAL_ShowerSegArray
Definition: ShowRec.h:76
Int_t cmd_LT
Definition: ShowRec.h:19
Int_t cmd_FP
Definition: ShowRec.h:15
Int_t cmd_MCFL
Definition: ShowRec.h:21
Int_t cmd_MP
Definition: ShowRec.h:17
Int_t cmd_LP
Definition: ShowRec.h:16
Int_t cmd_MC
Definition: ShowRec.h:20
TObjArray * GLOBAL_InBTArray
Definition: ShowRec.h:74
Int_t Npatterns() const
Definition: EdbPattern.h:366
EdbPattern * GetPattern(int id) const
Definition: EdbPattern.cxx:1721
Float_t Z() const
Definition: EdbSegP.h:153
Float_t P() const
Definition: EdbSegP.h:152
void PrintNice() const
Definition: EdbSegP.cxx:392
Int_t MCEvt() const
Definition: EdbSegP.h:145
Int_t Flag() const
Definition: EdbSegP.h:149
Float_t Z() const
Definition: EdbPattern.h:84
Int_t GetN() const
Definition: EdbPattern.h:65
EdbSegP * GetSegment(int i) const
Definition: EdbPattern.h:66
Definition: EdbPattern.h:113
Int_t cmd_HPLZ
Definition: ShowRec.h:26
TTree * t
Definition: check_shower.C:4
gEDBDEBUGLEVEL
Definition: energy.C:7
EdbSegP * s2
Definition: tlg2couples.C:30