ATLAS Offline Software
Loading...
Searching...
No Matches
ALFA_MDMultiple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <algorithm> // std::copy
7
9 AthMessaging("ALFA_MDMultiple")
10{
11 memset(&m_iNumHitsLayer, 0.0, sizeof(m_iNumHitsLayer));
12
13 m_fOverlapCut = 0.0;
16 m_iRPot = 0;
17 m_iUVCut = 0;
18}
19
20StatusCode ALFA_MDMultiple::Initialize(Int_t iRPot, Float_t faMD[RPOTSCNT][ALFALAYERSCNT*ALFAPLATESCNT][ALFAFIBERSCNT], Float_t fbMD[RPOTSCNT][ALFALAYERSCNT*ALFAPLATESCNT][ALFAFIBERSCNT], Int_t iMultiplicityCut, Int_t iNumLayerCut, Int_t iUVCut, Float_t fOverlapCut)
21{
22 ATH_MSG_DEBUG("ALFA_MDMultiple::Initialize()");
23
24 m_iRPot = iRPot;
25 m_iUVCut = iUVCut;
26 m_iNumLayerCut = iNumLayerCut;
27 m_iMultiplicityCut = iMultiplicityCut;
28 m_fOverlapCut = fOverlapCut;
29
30 for (Int_t iPot=0; iPot<RPOTSCNT; iPot++)
31 {
32 for (Int_t iLayer=0; iLayer<ALFALAYERSCNT*ALFAPLATESCNT; iLayer++)
33 {
34 for (Int_t iFiber=0; iFiber<ALFAFIBERSCNT; iFiber++)
35 {
36 m_faMD[iPot][iLayer][iFiber] = faMD[iPot][iLayer][iFiber];
37 m_fbMD[iPot][iLayer][iFiber] = fbMD[iPot][iLayer][iFiber];
38 }
39 }
40 }
41
42// std::cout << "m_iMultiplicityCut, m_iUVCut = " << m_iMultiplicityCut << ", " << m_iUVCut << std::endl;
43
44 return StatusCode::SUCCESS;
45}
46
47StatusCode ALFA_MDMultiple::Execute(const std::list<MDHIT> &ListMDHits)
48{
49 ATH_MSG_DEBUG("ALFA_MDMultiple::Execute()");
50
51 FIBERS structFibers;
52 m_MapLayers.clear();
53
54 std::list<MDHIT>::const_iterator iter;
55 for (iter=ListMDHits.begin(); iter!=ListMDHits.end(); ++iter)
56 {
57 if (m_iRPot == (*iter).iRPot)
58 {
59 if(m_MapLayers.find((*iter).iPlate)==m_MapLayers.end())
60 {
61 structFibers.ListFibers.clear();
62 m_MapLayers.insert(std::pair<int, FIBERS>((*iter).iPlate, structFibers));
63 m_MapLayers[(*iter).iPlate].ListFibers.push_back((*iter).iFiber);
64 }
65 else m_MapLayers[(*iter).iPlate].ListFibers.push_back((*iter).iFiber);
66 }
67 }
68
69 // RECONSTRUCTION
70 std::vector<double> b_p, b_n;
71 std::vector<double> Ov_p, Ov_n;
72 std::vector<int> Num_p, Num_n;
73 std::vector<int> FSel_n[ALFAPLATESCNT], FSel_p[ALFAPLATESCNT];
74 std::vector<int> iTrackMatch[2];
75
76
77 //Checking that the multiplicity cut conditions are satisfied
78 //At least more than UV_cut layers have a multiplicity lower than multi_cut
79
80 {
81 Reco_Track(b_p, b_n, Ov_p, Ov_n, Num_p, Num_n, FSel_n, FSel_p, iTrackMatch);
82
83 //Now sorting the tracks using NumU+NumV criteria -------------------------------
84 Int_t iCntSort=0;
85 Int_t iMaxSum=0;
86 std::vector<Int_t> MaxTrackID;
87 Int_t iTmpMaxTrackID = -1;
88
89// std::cout << "b_p.size = " << b_p.size() << std::endl;
90 while (iCntSort<(Int_t)b_p.size())
91 {
92 iMaxSum=0;
93 for (Int_t i=0; i<(Int_t)b_p.size(); i++)
94 {
95 //Checking that the maximum was not already used
96 Bool_t MaxUsed=false;
97
98 for (int j : MaxTrackID)
99 {
100 if (i==j) {MaxUsed = true; break;}
101 }
102
103 if (((Num_p[i]+Num_n[i])>iMaxSum) && (!MaxUsed))
104 {
105 iMaxSum = Num_p[i]+Num_n[i];
106 iTmpMaxTrackID=i;
107 }
108 }
109 MaxTrackID.push_back(iTmpMaxTrackID);
110 iCntSort++;
111 }
112
113
114 for (int i : MaxTrackID)
115 {
116 m_fRecXPos.push_back((b_p[i]-b_n[i])/2.0);
117 m_fRecYPos.push_back((b_p[i]+b_n[i])/2.0);
118
119 m_fOvU.push_back(Ov_p[i]);
120 m_fOvV.push_back(Ov_n[i]);
121 m_iNU.push_back(Num_p[i]);
122 m_iNV.push_back(Num_n[i]);
123
124 m_iTrackMatch[0].push_back(iTrackMatch[0][i]);
125 m_iTrackMatch[1].push_back(iTrackMatch[1][i]);
126
127 for (Int_t iPlate=0; iPlate<ALFAPLATESCNT; iPlate++)
128 {
129 m_iFibSel[2*iPlate].push_back(FSel_p[iPlate][i]);
130 m_iFibSel[2*iPlate+1].push_back(FSel_n[iPlate][i]);
131 }
132 }
133 }
134
135
136 return StatusCode::SUCCESS;
137}
138
139StatusCode ALFA_MDMultiple::Finalize(Float_t (&fRecXPos)[MAXTRACKNUM], Float_t (&fRecYPos)[MAXTRACKNUM])
140{
141 ATH_MSG_DEBUG("ALFA_MDMultiple::Finalize()");
142
143 Int_t iTrackNum=0, iSize=0;
144 std::fill_n(&fRecXPos[0], sizeof(fRecXPos)/sizeof(Float_t), -9999.0);
145 std::fill_n(&fRecYPos[0], sizeof(fRecYPos)/sizeof(Float_t), -9999.0);
146
147 iSize = std::min(m_fRecXPos.size(), m_fRecYPos.size());
148 iTrackNum = (iSize < MAXTRACKNUM)? iSize : MAXTRACKNUM;
149
150 for (Int_t i=0; i<iTrackNum; i++)
151 {
152 fRecXPos[i] = m_fRecXPos.at(i);
153 fRecYPos[i] = m_fRecYPos.at(i);
154 }
155
156 return StatusCode::SUCCESS;
157}
158
159/************************************************/
160/* Making projection and storing in an array */
161/************************************************/
162void ALFA_MDMultiple::Proj_Store(Int_t iFiberSide, std::span<Int_t> iOver, Float_t fbRef, Int_t iSideFlag)
163{
164 ATH_MSG_DEBUG("ALFA_MDMultiple::Pro_Store()");
165
166 Float_t fSign;
167 Float_t fXInter, fYInter;
168 Float_t FibCen;
169
170 if (m_faMD[m_iRPot][iSideFlag][0]>0) fSign=1.0;
171 else fSign=-1.0;
172
173 for (int & iBin : iOver)
174 {
175 iBin=0;
176 }
177
178 for (UInt_t iLayer=0; iLayer!=ALFAPLATESCNT; ++iLayer)
179 {
180 const unsigned int thisSideLayer = iLayer*2+iSideFlag;
181 const unsigned int thisLayer = 2*iLayer+iFiberSide;
182 const std::list<int> & thisFiberContainer = m_MapLayers[thisLayer].ListFibers;
183 for (const auto & thisFiber:thisFiberContainer)
184 {
185 if (thisFiber!=9999)
186 {
187 //Depending on layer orientation, computing the projection of the hit fiber
188 fXInter= fSign*(fbRef-m_fbMD[m_iRPot][thisSideLayer][thisFiber])/(1+fSign*m_faMD[m_iRPot][thisSideLayer][thisFiber]);
189 fYInter= (fSign*m_faMD[m_iRPot][thisSideLayer][thisFiber]*fbRef+m_fbMD[m_iRPot][thisSideLayer][thisFiber])/(1+fSign*m_faMD[m_iRPot][thisSideLayer][thisFiber])-fbRef;
190 FibCen = (fYInter-fSign*fXInter)/sqrt(2.0);
191
192 //Filling the table with the hit fiber
193 for (Int_t iBin=0; iBin<480; iBin++)
194 {
195 iOver[(int)((FibCen-0.24)*1000)+iBin+36000]++;
196 }
197 }
198 }
199 }
200}
201
202/************************************************/
203/* Making projection and storing in an array */
204/************************************************/
205void ALFA_MDMultiple::Proj_Store(const std::vector<Int_t> (&FiberHit)[ALFAPLATESCNT], std::span<Int_t> iOver, Float_t fbRef, Int_t iSideFlag)
206{
207 ATH_MSG_DEBUG("ALFA_MDMultiple::Pro_Store()");
208
209 Float_t fSign;
210 Float_t fXInter, fYInter;
211 Float_t FibCen;
212
213 if (m_faMD[m_iRPot][iSideFlag][0]>0) fSign=1.0;
214 else fSign=-1.0;
215
216 for (int & iBin : iOver)
217 {
218 iBin=0;
219 }
220
221 int iHit = 9999;
222 for (Int_t iLayer=0; iLayer<ALFAPLATESCNT; iLayer++)
223 {
224 for (UInt_t j=0; j<FiberHit[iLayer].size(); j++)
225 {
226 iHit = FiberHit[iLayer][j];
227 if (iHit!=9999)
228 {
229 //Depending on layer orientation, computing the projection of the hit fiber
230 fXInter= fSign*(fbRef-m_fbMD[m_iRPot][iLayer*2+iSideFlag][iHit])/(1+fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][iHit]);
231 fYInter= (fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][iHit]*fbRef+m_fbMD[m_iRPot][iLayer*2+iSideFlag][iHit])/(1+fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][iHit])-fbRef;
232 FibCen = (fYInter-fSign*fXInter)/sqrt(2.0);
233
234 //Filling the table with the hit fiber
235 for (Int_t iBin=0; iBin<480; iBin++)
236 {
237 iOver[(int)((FibCen-0.24)*1000)+iBin+36000]++;
238 }
239 }
240 }
241 }
242}
243
244/************************************************/
245/* Identifying plateau in projection array */
246/************************************************/
247void ALFA_MDMultiple::Find_Proj(const std::span<const Int_t>& iOver, Float_t fbRef, Float_t &fb, Float_t &fOv, Int_t &iNum)
248{
249 ATH_MSG_DEBUG("ALFA_MDMultiple::Find_Proj()");
250
251 std::vector<int> iSizePlateau;
252 Int_t iNumFib=0;
253 Int_t p_tmp_min;
254// Int_t p_tmp_max;
255 Float_t p_min;
256 Float_t p_max;
257
258 //Determine the maximum number of overlapping fibers in both directions
259 for (Int_t i=0;i<72000;i++)
260 {
261 if (iOver[i]>iNumFib) iNumFib=iOver[i];
262 }
263
264 // Filling array for all values equal to the maximum
265 if (iNumFib>=m_iUVCut)
266 {
267 for (Int_t i=0;i<72000;i++)
268 {
269 if (iOver[i]==iNumFib)
270 {
271 iSizePlateau.push_back(i);
272 }
273 }
274
275// Finding first and last position where the maximum is found
276 p_min = -36.0 + double(iSizePlateau.front())*1e-3;
277 p_tmp_min = iSizePlateau.front();
278
279 p_max = -36.0 + double(iSizePlateau.back())*1e-3;
280// p_tmp_max = iSizePlateau.back();
281
282// Making sure that the plateau belongs to the same track
283 Int_t full_width = iSizePlateau.size();
284
285 for (Int_t i=0; i<full_width; i++)
286 {
287 if (iSizePlateau[full_width-i-1]-p_tmp_min < 500)
288 {
289// p_tmp_max = iSizePlateau[full_width-i-1];
290 p_max = -36.0 + double(iSizePlateau[full_width-i-1])*1e-3;
291
292 break;
293 }
294 }
295
296 if ((p_max-p_min)<m_fOverlapCut)
297 {
298// Storing the coordinate of the maximum
299 fb = fbRef+(p_min+p_max)/sqrt(2.0);
300 fOv = p_max-p_min;
301 }
302 }
303
304 iNum = iNumFib;
305}
306
307/************************************************/
308/************************************************/
309/* Identifying fibers on the track */
310/************************************************/
311/************************************************/
312
313void ALFA_MDMultiple::Finding_Fib(Int_t iFiberSide, Float_t fbRef, Float_t fbRec, Int_t (&iFSel)[10], Int_t iSideFlag)
314{
315 ATH_MSG_DEBUG("ALFA_MDMultiple::Finding_Fib()");
316
317 Float_t b_pos, b_neg;
318 Float_t x, y, x_tmp, y_tmp;
319 Float_t min_dist;
320 Float_t dist_x, dist_y;
321 Float_t dist_full;
322 Float_t fib_dist;
323
324 if (iSideFlag==0)
325 {
326 b_neg= fbRef;
327 b_pos= fbRec;
328 }
329 else
330 {
331 b_neg= fbRec;
332 b_pos= fbRef;
333 }
334
335 x= (b_pos-b_neg)/2.0;
336 y= (b_neg+b_pos)/2.0;
337
338 for (int & iLayer : iFSel) iLayer = 9999;
339
340 //For each layer, we determine the hit fiber which is closest to the track
341 std::list<int>::iterator intIter;
342 for (Int_t iLayer = 0; iLayer<ALFAPLATESCNT; iLayer++)
343 {
344 min_dist=0.24;
345
346 const unsigned int thisSideLayer = iLayer*2+iSideFlag;
347 const unsigned int thisLayer = 2*iLayer+iFiberSide;
348 const std::list<int> & thisFiberContainer = m_MapLayers[thisLayer].ListFibers;
349 for (const auto & thisFiber:thisFiberContainer)
350 {
351 if (thisFiber != 9999)
352 {
353 x_tmp = (y-m_fbMD[m_iRPot][thisSideLayer][thisFiber])/m_faMD[m_iRPot][thisSideLayer][thisFiber];
354 y_tmp = m_faMD[m_iRPot][thisSideLayer][thisFiber]*x+m_fbMD[m_iRPot][thisSideLayer][thisFiber];
355
356 dist_x = TMath::Abs(x-x_tmp);
357 dist_y = TMath::Abs(y-y_tmp);
358
359 dist_full = sqrt(dist_x*dist_x+dist_y*dist_y);
360 fib_dist = sqrt(TMath::Power((dist_x+dist_y)/2.0,2)-TMath::Power(dist_full/2.0,2));
361
362 if (fib_dist <= min_dist)
363 {
364 min_dist = fib_dist;
365 iFSel[iLayer] = thisFiber;
366 }
367 }
368 }
369
370 }
371}
372
373/************************************************/
374/* Finding all tracks */
375/************************************************/
376
377void ALFA_MDMultiple::Reco_Track(std::vector<double> &b_p, std::vector<double> &b_n,
378 std::vector<double> &Ov_p, std::vector<double> &Ov_n,
379 std::vector<int> &Num_p, std::vector<int> &Num_n,
380 std::vector<int> (&FSel_n)[ALFAPLATESCNT], std::vector<int> (&FSel_p)[ALFAPLATESCNT],
381 std::vector<int> (&iTrackMatch)[2])
382{
383 ATH_MSG_DEBUG("ALFA_MDMultiple::Reco_Track()");
384
385// Int_t FSel_pos[ALFAPLATESCNT];
386 Int_t FSel_neg[ALFAPLATESCNT];
387 Int_t FSel_pos_tmp[ALFAPLATESCNT];
388 std::vector<Int_t> Over_p(72000);
389 std::vector<Int_t> Over_n(72000);
390 Int_t cnt_step_U=0;
391 Int_t cnt_step_V=0;
392 Int_t NumU=0;
393 Int_t NumV=0;
394 Float_t b_ref_p;
395 Float_t b_ref_n;
396 Float_t OvU;
397 Float_t OvV;
398 Float_t b_pos;
399 Float_t b_neg;
400
401 std::list<int>::iterator intIter;
402
403
404 //clear
405 for (Int_t i=0; i<ALFAPLATESCNT; i++)
406 {
407 FSel_n[i].clear();
408 FSel_p[i].clear();
409 }
410 b_n.clear();
411 b_p.clear();
412 Ov_n.clear();
413 Ov_p.clear();
414 Num_n.clear();
415 Num_p.clear();
416
417 int iNumUFiberHits = 0;
418 int iNumVFiberHits = 0;
419
420 std::vector<Int_t> Fiber_MB_tmp[ALFAPLATESCNT];
421 std::vector<Int_t> Fiber_MB_n[ALFAPLATESCNT];
422
423 for (UInt_t iLayer=0; iLayer!=ALFAPLATESCNT; ++iLayer)
424 {
425 Fiber_MB_n[iLayer].clear();
426 const unsigned int thisLayer=2*iLayer+1;
427 const std::list<int> & thisFiberContainer = m_MapLayers[thisLayer].ListFibers;
428 for (const auto & thisFiber:thisFiberContainer)
429 {
430// std::cout << "thisFiber: " << thisFiber << std::endl;
431 Fiber_MB_n[iLayer].push_back(thisFiber);
432 }
433 }
434 do
435 {
436 b_ref_n=-127.0;
437 b_ref_p=-127.0;
438
439// First projection step on U side
440// -------------------------------
441// filling the array for U side with reference value
442 Proj_Store(0, Over_p, b_ref_n, 0);
443// Proj_Store(1, Over_p, b_ref_n, 0); //just for test
444// Proj_Store(1, Over_p, b_ref_n, 1); //just for test
445
446// Find first maxium
447 Find_Proj(Over_p, b_ref_n, b_pos, OvU, NumU);
448
449 Finding_Fib(0, b_ref_n, b_pos, FSel_pos_tmp, 0);
450// Finding_Fib(1, b_ref_n, b_pos, FSel_pos_tmp, 0); //just for test
451// Finding_Fib(1, b_ref_n, b_pos, FSel_pos_tmp, 1); //just for test
452 for (int i=0; i<ALFAPLATESCNT; i++)
453 {
454 Fiber_MB_tmp[i].clear();
455 Fiber_MB_tmp[i].push_back(FSel_pos_tmp[i]);
456 }
457
458// // added ----------
459// std::cout << "FSel_pos after 1st U proj: ";
460// for (Int_t iLayer=0; iLayer<ALFAPLATESCNT; iLayer++)
461// {
462// std::cout << " " << FSel_pos[iLayer];
463// }
464// std::cout << std::endl;
465
466 //Then reconstruction all tracks possible using the second side
467 for (UInt_t iLayer=0; iLayer<ALFAPLATESCNT; iLayer++)
468 {
469 m_MapLayers[2*iLayer+1].ListFibers.clear();
470// m_MapLayers[2*iLayer].ListFibers.clear(); //just for test
471 for (unsigned int i=0; i<Fiber_MB_n[iLayer].size(); i++)
472 {
473 m_MapLayers[2*iLayer+1].ListFibers.push_back(Fiber_MB_n[iLayer][i]);
474// m_MapLayers[2*iLayer].ListFibers.push_back(Fiber_MB_n[iLayer][i]); //just for test
475 }
476 }
477
478// std::cout << "NumU " << NumU << std::endl;
479
480// Then reconstruct all tracks possible using the second side
481 if (NumU>=m_iUVCut)
482 {
483 cnt_step_V=0;
484 do
485 {
486 // New Part to apply the multiplicity cut at each iteration
487 iNumUFiberHits=0;
488 iNumVFiberHits=0;
489 for (UInt_t iLayer=0;iLayer<ALFAPLATESCNT;iLayer++)
490 {
491 if ((Int_t)m_MapLayers[2*iLayer].ListFibers.size()<=m_iMultiplicityCut && !m_MapLayers[2*iLayer].ListFibers.empty()) iNumUFiberHits++;
492 if ((Int_t)m_MapLayers[2*iLayer+1].ListFibers.size()<=m_iMultiplicityCut && !m_MapLayers[2*iLayer+1].ListFibers.empty()) iNumVFiberHits++;
493// if ((Int_t)m_MapLayers[2*iLayer+1].ListFibers.size()<=m_iMultiplicityCut && m_MapLayers[2*iLayer+1].ListFibers.size()>0) iNumUFiberHits++; //just for test
494// if ((Int_t)m_MapLayers[2*iLayer].ListFibers.size()<=m_iMultiplicityCut && m_MapLayers[2*iLayer].ListFibers.size()>0) iNumVFiberHits++; //just for test
495 }
496
497// std::cout << "2nd multiplicity cut " << iNumUFiberHits << " " << iNumVFiberHits << std::endl;
498
499 if (iNumUFiberHits>=m_iNumLayerCut && iNumVFiberHits>=m_iNumLayerCut)
500 {
501 //First projection on V side
502 //-------------------------------
503 //filling the array for V side with reference value
504 Proj_Store(1, Over_n, b_ref_p, 1);
505// Proj_Store(0, Over_n, b_ref_p, 1); //just for test
506// Proj_Store(0, Over_n, b_ref_p, 0); //just for test
507 Find_Proj(Over_n, b_ref_p, b_neg, OvV, NumV);
508
509// std::cout << "NumV " << NumV << std::endl;
510
511 if (NumV>=m_iUVCut)
512 {
513 //Now make the second projection step
514 //-----------------------------------
515 //U side
516// Proj_Store(0, Over_p, b_neg, 0);
517 // Proj_Store(1, Over_p, b_neg, 0); //just for test
518 Proj_Store(Fiber_MB_tmp, Over_p, b_neg, 0);
519// Proj_Store(Fiber_MB_tmp, Over_p, b_neg, 1); //just for test
520 Find_Proj(Over_p, b_neg, b_pos, OvU, NumU);
521
522 //V side
523 Proj_Store(1, Over_n, b_pos, 1);
524// Proj_Store(0, Over_n, b_pos, 1); //just for test
525// Proj_Store(0, Over_n, b_pos, 0); //just for test
526 Find_Proj(Over_n, b_pos, b_neg, OvV, NumV);
527
528 //Third projection steps
529 //----------------------
530 //U side
531// Proj_Store(0, Over_p, b_neg, 0);
532 // Proj_Store(1, Over_p, b_neg, 0); //just for test
533 Proj_Store(Fiber_MB_tmp, Over_p, b_neg, 0);
534// Proj_Store(Fiber_MB_tmp, Over_p, b_neg, 1); //just for test
535 Find_Proj(Over_p, b_neg, b_pos, OvU, NumU);
536
537 //V side
538 Proj_Store(1, Over_n, b_pos, 1);
539// Proj_Store(0, Over_n, b_pos, 1); //just for test
540// Proj_Store(0, Over_n, b_pos, 0); //just for test
541 Find_Proj(Over_n, b_pos, b_neg, OvV, NumV);
542
543 // //We store the information in the vector
544 b_p.push_back(b_pos);
545 Ov_p.push_back(OvU);
546 Num_p.push_back(NumU);
547
548 b_n.push_back(b_neg);
549 Ov_n.push_back(OvV);
550 Num_n.push_back(NumV);
551
552 iTrackMatch[0].push_back(cnt_step_U);
553 iTrackMatch[1].push_back(cnt_step_V);
554
555 //Once done we want to remove the hit belonging to the first track on side V
556 //We first find the corresponding fibers
557// Finding_Fib(0,b_neg, b_pos, FSel_pos, 0);
558 Finding_Fib(1,b_pos, b_neg, FSel_neg, 1);
559// Finding_Fib(1,b_neg, b_pos, FSel_pos, 0); //just for test
560// Finding_Fib(0,b_pos, b_neg, FSel_neg, 1); //just for test
561// Finding_Fib(1,b_neg, b_pos, FSel_pos, 1); //just for test
562// Finding_Fib(0,b_pos, b_neg, FSel_neg, 0); //just for test
563
564 for (Int_t iLayer=0; iLayer<ALFAPLATESCNT; iLayer++)
565 {
566 FSel_n[iLayer].push_back(FSel_neg[iLayer]);
567// FSel_p[iLayer].push_back(FSel_pos[iLayer]);
568 FSel_p[iLayer].push_back(FSel_pos_tmp[iLayer]);
569 }
570
571 //added -----------------------------------------------------
572// std::cout << "FSel_n ";
573// for (Int_t iLayer=0; iLayer<ALFAPLATESCNT; iLayer++)
574// {
575// std::cout << " " << FSel_neg[iLayer];
576// }
577// std::cout << std::endl;
578// std::cout << "FSel_p ";
579// for (Int_t iLayer=0; iLayer<ALFAPLATESCNT; iLayer++)
580// {
581// std::cout << " " << FSel_pos[iLayer];
582// }
583// std::cout << std::endl;
584
585 //Removing fibers used for the first track for V Side
586 for (Int_t iLayer=0; iLayer<ALFAPLATESCNT; ++iLayer)
587 {
588 // coverity bug 30038 fixed bellow
589// std::list<int>::iterator itBeg = m_MapLayers[2*iLayer+1].ListFibers.begin();
590// std::list<int>::iterator itEnd = m_MapLayers[2*iLayer+1].ListFibers.end();
591// for (; itBeg != itEnd; itBeg++)
592// {
593// if (*itBeg == (int)FSel_neg[iLayer])
594// {
595// m_MapLayers[2*iLayer+1].ListFibers.erase(itBeg);
596// break;
597// }
598// }
599
600 const unsigned int thisLayer=2*iLayer+1;
601 const std::list<int> & thisFiberContainer = m_MapLayers[thisLayer].ListFibers;
602 for (const auto & thisFiber:thisFiberContainer)
603 {
604 if (thisFiber == (int)FSel_neg[iLayer])
605 {
606 auto it = std::find(begin(thisFiberContainer), end(thisFiberContainer), thisFiber);
607 m_MapLayers[2*iLayer+1].ListFibers.erase(it);
608 break;
609 }
610 }
611
612
613// for (intIter=m_MapLayers[2*iLayer+1].ListFibers.begin(); intIter!=m_MapLayers[2*iLayer+1].ListFibers.end(); intIter++)
615// {
617// if (*intIter==(int)FSel_neg[iLayer])
618// {
620// m_MapLayers[2*iLayer+1].ListFibers.erase(intIter);
622// break;
623// }
624// }
625 }
626 cnt_step_V++;
627 }
628 }
629 else NumV = 0;
630 }
631 while (NumV>=m_iUVCut);
632
633// When we cannot find tracks anymore for the V side, and that all combinations with the U side has been done, we start again with the U side
634// But first we remove the fibers belonging to this track
635
636// std::cout << "cnt_step_V " << cnt_step_V << std::endl;
637
638// Int_t iNumErasedFibs=0;
639 if (cnt_step_V>0)
640 {
641 for (Int_t iLayer=0; iLayer<ALFAPLATESCNT; iLayer++)
642 {
643 std::list<int>::iterator itBeg = m_MapLayers[2*iLayer].ListFibers.begin();
644 std::list<int>::iterator itEnd = m_MapLayers[2*iLayer].ListFibers.end();
645 for (; itBeg != itEnd; ++itBeg)
646 {
647 if (*itBeg == (int)FSel_pos_tmp[iLayer])
648 {
649 m_MapLayers[2*iLayer].ListFibers.erase(itBeg);
650 break;
651 }
652 }
653
654
655// for (intIter=m_MapLayers[2*iLayer].ListFibers.begin(); intIter!=m_MapLayers[2*iLayer].ListFibers.end(); intIter++)
657// {
659// if (*intIter==(int)FSel_pos_tmp[iLayer])
660// {
662// m_MapLayers[2*iLayer].ListFibers.erase(intIter);
665// break;
666// }
667
668// }
669 }
670 }
671 else
672 {
673 if (NumV>0)
674 {
675// Finding_Fib(0, b_ref_n, b_pos, FSel_pos, 0);
676// Finding_Fib(1, b_ref_n, b_pos, FSel_pos, 0); //just for test
677
678 for (Int_t iLayer=0; iLayer<ALFAPLATESCNT; iLayer++)
679 {
680 std::list<int>::iterator itBeg = m_MapLayers[2*iLayer].ListFibers.begin();
681 std::list<int>::iterator itEnd = m_MapLayers[2*iLayer].ListFibers.end();
682 for (; itBeg != itEnd; ++itBeg)
683 {
684 if (*itBeg == (int)FSel_pos_tmp[iLayer])
685 {
686 m_MapLayers[2*iLayer].ListFibers.erase(itBeg);
687 break;
688 }
689 }
690
691
692// for (intIter=m_MapLayers[2*iLayer].ListFibers.begin(); intIter!=m_MapLayers[2*iLayer].ListFibers.end(); intIter++)
694// {
696// if (*intIter==(int)FSel_pos_tmp[iLayer])
697// {
698// // *intIter = 9999;
699// m_MapLayers[2*iLayer].ListFibers.erase(intIter);
702// break;
703// }
704// }
705 }
706 }
707 else break;
708 }
709 cnt_step_U++;
710// if (iNumErasedFibs==0) NumU=0;
711 }
712 }
713 while (NumU>=m_iUVCut);
714}
715
716void ALFA_MDMultiple::GetData(Int_t (&iNumU)[MAXTRACKNUM], Int_t (&iNumV)[MAXTRACKNUM], Float_t (&fOvU)[MAXTRACKNUM], Float_t (&fOvV)[MAXTRACKNUM], Int_t (&iFibSel)[MAXTRACKNUM][ALFALAYERSCNT*ALFAPLATESCNT])
717{
718 ATH_MSG_DEBUG("ALFA_MDMultiple::GetData()");
719
720 Int_t iTrackNum;
721 Int_t iSize;
722 std::fill_n(&fOvU[0], sizeof(fOvU)/sizeof(Float_t), -9999.0);
723 std::fill_n(&fOvV[0], sizeof(fOvV)/sizeof(Float_t), -9999.0);
724 std::fill_n(&iNumU[0], sizeof(iNumU)/sizeof(Int_t), -9999);
725 std::fill_n(&iNumV[0], sizeof(iNumV)/sizeof(Int_t), -9999);
726 std::fill_n(&iFibSel[0][0], sizeof(iFibSel)/sizeof(Int_t), -9999);
727
728 iTrackNum=0;
729 iSize=0;
730 for (auto & iLayer : m_iFibSel)
731 {
732 iSize = std::max(static_cast<Int_t>(iLayer.size()), iSize);
733 }
734 iTrackNum = (iSize < MAXTRACKNUM)? iSize : MAXTRACKNUM;
735 for (Int_t iTrack=0; iTrack<iTrackNum; iTrack++)
736 {
737 for (Int_t iLayer=0; iLayer<ALFALAYERSCNT*ALFAPLATESCNT; iLayer++)
738 {
739 iFibSel[iTrack][iLayer] = m_iFibSel[iLayer].at(iTrack);
740 }
741 }
742
743 iTrackNum=0;
744 iSize=0;
745 iSize = std::min(m_fOvU.size(), m_fOvV.size());
746 iTrackNum = (iSize < MAXTRACKNUM)? iSize : MAXTRACKNUM;
747 for (Int_t iTrack=0; iTrack<iTrackNum; iTrack++)
748 {
749 fOvU[iTrack] = m_fOvU.at(iTrack);
750 fOvV[iTrack] = m_fOvV.at(iTrack);
751 }
752
753 iTrackNum=0;
754 iSize=0;
755 iSize = std::min(m_iNU.size(), m_iNV.size());
756 iTrackNum = (iSize < MAXTRACKNUM)? iSize : MAXTRACKNUM;
757 for (Int_t iTrack=0; iTrack<iTrackNum; iTrack++)
758 {
759 iNumU[iTrack] = m_iNU.at(iTrack);
760 iNumV[iTrack] = m_iNV.at(iTrack);
761 }
762}
#define RPOTSCNT
struct _FIBERS FIBERS
#define MAXTRACKNUM
#define ALFALAYERSCNT
#define ALFAPLATESCNT
#define ALFAFIBERSCNT
#define ATH_MSG_DEBUG(x)
#define y
#define x
std::vector< Int_t > m_iFibSel[ALFALAYERSCNT *ALFAPLATESCNT]
StatusCode Initialize(Int_t iRPot, Float_t faMD[RPOTSCNT][ALFALAYERSCNT *ALFAPLATESCNT][ALFAFIBERSCNT], Float_t fbMD[RPOTSCNT][ALFALAYERSCNT *ALFAPLATESCNT][ALFAFIBERSCNT], Int_t iMultiplicityCut, Int_t iNumLayerCut, Int_t iUVCut, Float_t fOverlapCut)
Float_t m_fbMD[RPOTSCNT][ALFALAYERSCNT *ALFAPLATESCNT][ALFAFIBERSCNT]
StatusCode Execute(const std::list< MDHIT > &ListMDHits)
void Proj_Store(Int_t iFiberSide, std::span< Int_t > iOver, Float_t fbRef, Int_t iSideFlag)
void Reco_Track(std::vector< double > &b_p, std::vector< double > &b_n, std::vector< double > &Ov_p, std::vector< double > &Ov_n, std::vector< int > &Num_p, std::vector< int > &Num_n, std::vector< int >(&FSel_n)[ALFAPLATESCNT], std::vector< int >(&FSel_p)[ALFAPLATESCNT], std::vector< int >(&Track_match)[2])
std::vector< Float_t > m_fRecXPos
void Finding_Fib(Int_t iFiberSide, Float_t fbRef, Float_t fbRec, Int_t(&iFSel)[ALFAPLATESCNT], Int_t iSideFlag)
std::map< int, FIBERS > m_MapLayers
std::vector< Int_t > m_iNV
Float_t m_faMD[RPOTSCNT][ALFALAYERSCNT *ALFAPLATESCNT][ALFAFIBERSCNT]
std::vector< Float_t > m_fRecYPos
StatusCode Finalize(Float_t(&fRecXPos)[MAXTRACKNUM], Float_t(&fRecYPos)[MAXTRACKNUM])
std::vector< Int_t > m_iTrackMatch[2]
void GetData(Int_t(&iNumU)[MAXTRACKNUM], Int_t(&iNumV)[MAXTRACKNUM], Float_t(&fOvU)[MAXTRACKNUM], Float_t(&fOvV)[MAXTRACKNUM], Int_t(&iFibSel)[MAXTRACKNUM][ALFALAYERSCNT *ALFAPLATESCNT])
std::vector< Int_t > m_iNU
std::vector< Float_t > m_fOvU
void Find_Proj(const std::span< const Int_t > &iOver, Float_t fbRef, Float_t &fb, Float_t &fOv, Int_t &fNum)
Int_t m_iNumHitsLayer[ALFALAYERSCNT *ALFAPLATESCNT]
std::vector< Float_t > m_fOvV
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
std::list< int > ListFibers