ATLAS Offline Software
ALFA_MDGap.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8  AthMessaging("ALFA_MDGap")
9 {
10  memset(&m_faMD, 0, sizeof(m_faMD));
11  memset(&m_fbMD, 0, sizeof(m_fbMD));
12  memset(&m_fRecXPos, 0, sizeof(m_fRecXPos));
13  memset(&m_fRecYPos, 0, sizeof(m_fRecYPos));
14  memset(&m_fOvU, 0, sizeof(m_fOvU));
15  memset(&m_fOvV, 0, sizeof(m_fOvV));
16  memset(&m_iNU, 0, sizeof(m_iNU));
17  memset(&m_iNV, 0, sizeof(m_iNV));
18  memset(&m_iFibSel, 0, sizeof(m_iFibSel));
19  memset(&m_iNumHitsLayer, 0, sizeof(m_iNumHitsLayer));
20 
21  m_fOverlapCut = 0.0;
22  m_iRPot = 0;
23  m_iUVCut = 0;
24 }
25 
27 {
28 }
29 
30 StatusCode ALFA_MDGap::Initialize(Int_t iRPot, Float_t faMD[RPOTSCNT][ALFALAYERSCNT*ALFAPLATESCNT][ALFAFIBERSCNT], Float_t fbMD[RPOTSCNT][ALFALAYERSCNT*ALFAPLATESCNT][ALFAFIBERSCNT], Int_t iUVCut, Float_t fOverlapCut)
31 {
32  m_iRPot = iRPot;
33  m_iUVCut = iUVCut;
34  m_fOverlapCut = fOverlapCut;
35 
36  for (Int_t iPot=0; iPot<RPOTSCNT; iPot++)
37  {
38  for (Int_t iLayer=0; iLayer<ALFALAYERSCNT*ALFAPLATESCNT; iLayer++)
39  {
40  for (Int_t iFiber=0; iFiber<ALFAFIBERSCNT; iFiber++)
41  {
42  m_faMD[iPot][iLayer][iFiber] = faMD[iPot][iLayer][iFiber];
43  m_fbMD[iPot][iLayer][iFiber] = fbMD[iPot][iLayer][iFiber];
44  }
45  }
46  }
47 
48  memset(&m_fRecXPos, 0, sizeof(m_fRecXPos));
49  memset(&m_fRecYPos, 0, sizeof(m_fRecYPos));
50  memset(&m_fOvU, 0, sizeof(m_fOvU));
51  memset(&m_fOvV, 0, sizeof(m_fOvV));
52  memset(&m_iNU, 0, sizeof(m_iNU));
53  memset(&m_iNV, 0, sizeof(m_iNV));
54  memset(&m_iFibSel, 0, sizeof(m_iFibSel));
55  std::fill_n(&m_fRecXPos[0], sizeof(m_fRecXPos)/sizeof(Float_t), -9999.0);
56  std::fill_n(&m_fRecYPos[0], sizeof(m_fRecYPos)/sizeof(Float_t), -9999.0);
57  std::fill_n(&m_fOvU[0], sizeof(m_fOvU)/sizeof(Float_t), -9999.0);
58  std::fill_n(&m_fOvV[0], sizeof(m_fOvV)/sizeof(Float_t), -9999.0);
59  std::fill_n(&m_iFibSel[0], sizeof(m_iFibSel)/sizeof(Int_t), 9999);
60 
61  return StatusCode::SUCCESS;
62 }
63 
64 StatusCode ALFA_MDGap::Execute(const std::list<MDHIT> &ListMDHits)
65 {
66  ATH_MSG_DEBUG("ALFA_MDGap::Execute()");
67 
68  FIBERS structFibers;
69  m_MapLayers.clear();
70 
71  std::list<MDHIT>::const_iterator iter;
72  for (iter=ListMDHits.begin(); iter!=ListMDHits.end(); ++iter)
73  {
74  if (m_iRPot == (*iter).iRPot)
75  {
76  if(m_MapLayers.find((*iter).iPlate)==m_MapLayers.end())
77  {
78  structFibers.ListFibers.clear();
79  m_MapLayers.insert(std::pair<int, FIBERS>((*iter).iPlate, structFibers));
80  m_MapLayers[(*iter).iPlate].ListFibers.push_back((*iter).iFiber);
81  }
82  else m_MapLayers[(*iter).iPlate].ListFibers.push_back((*iter).iFiber);
83  }
84  }
85 
86  // RECONSTRUCTION
87  std::vector<Float_t> b_p, b_n;
88  std::vector<Float_t> Ov_p, Ov_n;
89  std::vector<int> Num_p, Num_n;
90  Int_t FSel_n[ALFAPLATESCNT], FSel_p[ALFAPLATESCNT];
91  Bool_t FGaps_n[ALFAPLATESCNT], FGaps_p[ALFAPLATESCNT];
92  Int_t Gap_Fib_p[ALFAPLATESCNT][2], Gap_Fib_n[ALFAPLATESCNT][2];
93  std::vector<Int_t> GapsID;
94 
95  Int_t Gaps[2][2];
96 // Int_t Gaps_ID[MAXTRACKNUM];
97 // Bool_t FGaps[20];
98 // Int_t GapFib[20][2];
99 
100  Reco_Track(b_p, b_n, Ov_p, Ov_n, Num_p, Num_n, FSel_n, FSel_p, Gaps, GapsID, FGaps_p, FGaps_n, Gap_Fib_p, Gap_Fib_n);
101 
102  Int_t cnt_tr=0;
103  for (UInt_t i=0;i< b_p.size();i++)
104  {
105  m_fRecXPos[cnt_tr]=(b_p[i]-b_n[i])/2.;
106  m_fRecYPos[cnt_tr]=(b_n[i]+b_p[i])/2.;
107 
108  m_fOvU[cnt_tr]= Ov_p[i];
109  m_fOvV[cnt_tr]= Ov_n[i];
110 
111  m_iNU[cnt_tr]= Num_p[i];
112  m_iNV[cnt_tr]= Num_n[i];
113 
114 // Gaps_ID[cnt_tr]=GapsID[i];
115 
116  if(cnt_tr==0)
117  {
118  for (Int_t j=0; j<ALFAPLATESCNT; j++)
119  {
120  m_iFibSel[j*2] = FSel_p[j];
121  m_iFibSel[j*2+1] = FSel_n[j];
122  }
123  }
124 
125 // if (GapsID[i]==1)
126 // {
127 // for (Int_t j=0; j<ALFAPLATESCNT; j++)
128 // {
129 // FGaps[j*2]=FGaps_p[j];
130 // FGaps[j*2+1]=FGaps_n[j];
131 
132 // GapFib[j*2][0]=Gap_Fib_p[j][0];
133 // GapFib[j*2][1]=Gap_Fib_p[j][1];
134 // GapFib[j*2+1][0]=Gap_Fib_n[j][0];
135 // GapFib[j*2+1][1]=Gap_Fib_n[j][1];
136 // }
137 // }
138  cnt_tr++;
139  }
140 
141  return StatusCode::SUCCESS;
142 }
143 
144 StatusCode ALFA_MDGap::Finalize(Float_t (&fRecXPos)[MAXTRACKNUM], Float_t (&fRecYPos)[MAXTRACKNUM])
145 {
146  for (Int_t i=0; i<MAXTRACKNUM; i++)
147  {
148  fRecXPos[i] = m_fRecXPos[i];
149  fRecYPos[i] = m_fRecYPos[i];
150  }
151 
152  return StatusCode::SUCCESS;
153 }
154 
155 /************************************************/
156 /* Making projection and storing in an array */
157 /************************************************/
158 void ALFA_MDGap::Proj_Store(Int_t iFiberSide, Int_t (&iOver)[72000], Float_t fbRef, Int_t iSideFlag)
159 {
160  Float_t fSign;
161  Float_t fXInter, fYInter;
162  Float_t fFibCen;
163 
164  if (m_faMD[m_iRPot][iSideFlag][0]>0) fSign=1.0;
165  else fSign=-1.0;
166 
167  for (int & iBin : iOver)
168  {
169  iBin=0;
170  }
171 
172  std::list<int>::iterator intIter;
173  int iIndex = 0;
174  for (Int_t iLayer=0; iLayer<ALFAPLATESCNT; iLayer++)
175  {
176  iIndex = 2*iLayer+iFiberSide;
177  for (intIter=m_MapLayers[iIndex].ListFibers.begin(); intIter!=m_MapLayers[iIndex].ListFibers.end(); ++intIter)
178  {
179  if (*intIter!=9999)
180  {
181  //Depending on layer orientation, computing the projection of the hit fiber
182  fXInter= fSign*(fbRef-m_fbMD[m_iRPot][iLayer*2+iSideFlag][*intIter])/(1+fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][*intIter]);
183  fYInter= (fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][*intIter]*fbRef+m_fbMD[m_iRPot][iLayer*2+iSideFlag][*intIter])/(1+fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][*intIter])-fbRef;
184  fFibCen = (fYInter-fSign*fXInter)/sqrt(2.0);
185 
186  //Filling the table with the hit fiber
187  for (Int_t iBin=0; iBin<480; iBin++)
188  {
189  iOver[(int)((fFibCen-0.24)*1000)+iBin+36000]++;
190  }
191  }
192  }
193  }
194 }
195 
196 /************************************************/
197 /* Identifying plateau in projection array */
198 /************************************************/
199 void ALFA_MDGap::Find_Proj(const Int_t iOver[72000], Float_t fbRef, Float_t &fb, Float_t &fOv, Int_t&iNum) const
200 {
201  std::vector<int> iSizePlateau;
202  Int_t iNumFib=0;
203  Int_t p_tmp_min;
204 // Int_t p_tmp_max;
205  Float_t p_min;
206  Float_t p_max;
207 
208  //Determine the maximum number of overlapping fibers in both directions
209  for (Int_t i=0;i<72000;i++)
210  {
211  if (iOver[i]>iNumFib) iNumFib=iOver[i];
212  }
213 
214  // Filling array for all values equal to the maximum
215  if (iNumFib>=m_iUVCut)
216  {
217  for (Int_t i=0;i<72000;i++)
218  {
219  if (iOver[i]==iNumFib)
220  {
221  iSizePlateau.push_back(i);
222  }
223  }
224 
225 // Finding first and last position where the maximum is found
226  p_min = -36.0 + Float_t(iSizePlateau.front())*1e-3;
227  p_tmp_min = iSizePlateau.front();
228 
229  p_max = -36.0 + Float_t(iSizePlateau.back())*1e-3;
230 // p_tmp_max = iSizePlateau.back();
231 
232 // Making sure that the plateau belongs to the same track
233  Int_t full_width = iSizePlateau.size();
234 
235  for (Int_t i=0; i<full_width; i++)
236  {
237  if (iSizePlateau[full_width-i-1]-p_tmp_min < 500)
238  {
239 // p_tmp_max = iSizePlateau[full_width-i-1];
240  p_max = -36.0 + Float_t(iSizePlateau[full_width-i-1])*1e-3;
241  break;
242  }
243  }
244 
245  if ((p_max-p_min)<m_fOverlapCut)
246  {
247 // Storing the coordinate of the maximum
248  fb = fbRef+(p_min+p_max)/sqrt(2.0);
249  fOv = p_max-p_min;
250 // iNum = iNumFib;
251  }
252  }
253 
254  iNum = iNumFib;
255 }
256 
257 /************************************************/
258 /************************************************/
259 /* Identifying fibers on the track */
260 /************************************************/
261 /************************************************/
262 
263 void ALFA_MDGap::Finding_Fib(Int_t iFiberSide, Float_t fbRef, Float_t fbRec, Int_t (&iFSel)[10], Int_t iSideFlag)
264 {
265  Float_t b_pos, b_neg;
266  Float_t x, y, x_tmp, y_tmp;
267  Float_t min_dist;
268  Float_t dist_x, dist_y;
269  Float_t dist_full;
270  Float_t fib_dist;
271  Int_t gFib;
272 
273  if (iSideFlag==0)
274  {
275  b_neg= fbRef;
276  b_pos= fbRec;
277  }
278  else
279  {
280  b_neg= fbRec;
281  b_pos= fbRef;
282  }
283 
284  x= (b_pos-b_neg)/2.0;
285  y= (b_neg+b_pos)/2.0;
286 
287  for (int & iLayer : iFSel) iLayer = 9999;
288 
289  //For each layer, we determine the hit fiber which is closest to the track
290  std::list<int>::iterator intIter;
291  int iIndex = 0;
292  for (Int_t iLayer = 0; iLayer<ALFAPLATESCNT; iLayer++)
293  {
294  min_dist=0.24;
295  gFib = 9999;
296 
297  iIndex = 2*iLayer+iFiberSide;
298  for (intIter=m_MapLayers[iIndex].ListFibers.begin(); intIter!=m_MapLayers[iIndex].ListFibers.end(); ++intIter)
299  {
300  if (*intIter!=9999)
301  {
302  x_tmp = (y-m_fbMD[m_iRPot][iLayer*2+iSideFlag][*intIter])/m_faMD[m_iRPot][iLayer*2+iSideFlag][*intIter];
303  y_tmp = m_faMD[m_iRPot][iLayer*2+iSideFlag][*intIter]*x+m_fbMD[m_iRPot][iLayer*2+iSideFlag][*intIter];
304 
305  dist_x = TMath::Abs(x-x_tmp);
306  dist_y = TMath::Abs(y-y_tmp);
307 
308  dist_full = sqrt(dist_x*dist_x+dist_y*dist_y);
309  fib_dist = sqrt(TMath::Power((dist_x+dist_y)/2.0,2)-TMath::Power(dist_full/2.0,2));
310 
311  if (fib_dist <= min_dist)
312  {
313  min_dist = fib_dist;
314  gFib = *intIter;
315 
316  iFSel[iLayer] = gFib;
317  }
318  }
319  }
320  }
321 }
322 
323 /************************************************/
324 /* Finding all tracks */
325 /************************************************/
326 
327 void ALFA_MDGap::Reco_Track(std::vector<Float_t> &b_p, std::vector<Float_t> &b_n,
328  std::vector<Float_t> &Ov_p, std::vector<Float_t> &Ov_n,
329  std::vector<int> &Num_p, std::vector<int> &Num_n,
330  Int_t (&FSel_n)[ALFAPLATESCNT], Int_t (&FSel_p)[ALFAPLATESCNT],
331  Int_t (&Gaps)[2][2], std::vector<Int_t> &GapsID, Bool_t (&FGaps_p)[ALFAPLATESCNT], Bool_t (&FGaps_n)[ALFAPLATESCNT],
332  Int_t (&Gap_Fib_p)[ALFAPLATESCNT][2], Int_t (&Gap_Fib_n)[ALFAPLATESCNT][2])
333 {
334  Int_t Over_p[72000];
335  Int_t Over_n[72000];
336  Int_t Over_copy[72000];
337  Int_t NumU=5;
338  Int_t NumV=5;
339  Float_t b_ref_p = -127.0;
340  Float_t b_ref_n = -127.0;
341  Float_t OvU;
342  Float_t OvV;
343  Float_t b_pos;
344  Float_t b_neg;
345  Bool_t FG_p[ALFAPLATESCNT]; //asi k nicemu - vstup do silentgap
346  Bool_t FG_n[ALFAPLATESCNT]; //asi k nicemu - vstup do silentgap
347  Int_t G_F_p[ALFAPLATESCNT][2]; //asi k nicemu - vstup do silentgap
348  Int_t G_F_n[ALFAPLATESCNT][2]; //asi k nicemu - vstup do silentgap
349  Float_t b_pos_silent;
350  Float_t b_neg_silent;
351  Float_t b_pos_active;
352  Float_t b_neg_active;
353 
354  //clear
355  memset(&FSel_n, 0, sizeof(Int_t));
356  memset(&FSel_p, 0, sizeof(Int_t));
357  memset(&FGaps_n, false, sizeof(Bool_t));
358  memset(&FGaps_p, false, sizeof(Bool_t));
359  memset(&Gap_Fib_n, 0, sizeof(Int_t));
360  memset(&Gap_Fib_p, 0, sizeof(Int_t));
361  std::fill_n(&Gap_Fib_n[0][0], sizeof(Gap_Fib_n)/sizeof(Int_t), 9999);
362  std::fill_n(&Gap_Fib_p[0][0], sizeof(Gap_Fib_p)/sizeof(Int_t), 9999);
363 
364  b_n.clear();
365  b_p.clear();
366  Ov_n.clear();
367  Ov_p.clear();
368  Num_n.clear();
369  Num_p.clear();
370 
371  b_ref_n=-127.0;
372  b_ref_p=-127.0;
373 
374 // First projection step on U side
375 // -------------------------------
376 // filling the array for U side with reference value
377  Proj_Store(0, Over_p, b_ref_n, 0);
378 
379 // Find first maxium
380  Find_Proj(Over_p, b_ref_n, b_pos, OvU, NumU);
381 
382 // Then reconstruction all tracks possible using the second side
383  if (NumU>=m_iUVCut)
384  {
385  //First projection on V side
386  //-------------------------------
387  //filling the array for V side with reference value
388  Proj_Store(1, Over_n, b_ref_p, 1);
389  Find_Proj(Over_n, b_ref_p, b_neg, OvV, NumV);
390 
391  if (NumV>=m_iUVCut)
392  {
393  //Now make the second projection step
394  //-----------------------------------
395  //U side
396  Proj_Store(0, Over_p, b_neg, 0);
397  Find_Proj(Over_p, b_neg, b_pos, OvU, NumU);
398 
399  //V side
400  Proj_Store(1, Over_n, b_pos, 1);
401  Find_Proj(Over_n, b_pos, b_neg, OvV, NumV);
402 
403  //Third projection steps
404  //----------------------
405  //U side
406  Proj_Store(0, Over_p, b_neg, 0);
407  Find_Proj(Over_p, b_neg, b_pos, OvU, NumU);
408 
409  //V side
410  Proj_Store(1, Over_n, b_pos, 1);
411  Find_Proj(Over_n, b_pos, b_neg, OvV, NumV);
412 
413  //We store the information in the vector
414  b_p.push_back(b_pos);
415  Ov_p.push_back(OvU);
416  Num_p.push_back(NumU);
417 
418  b_n.push_back(b_neg);
419  Ov_n.push_back(OvV);
420  Num_n.push_back(NumV);
421 
422  GapsID.push_back(0);
423 
424  //Once done we want to remove the hit belonging to the first track on side V
425  //We first find the corresponding fibers
426  Finding_Fib(0,b_neg, b_pos, FSel_p, 0);
427  Finding_Fib(1,b_pos, b_neg, FSel_n, 1);
428 
429  //Then looking for silent gaps in the plateau
430  //Filling the array with the gap information
431 
432  for (Int_t bin=0;bin<72000;bin++)
433  {
434  Over_copy[bin]=Over_p[bin];
435  }
436  Gaps[0][0] = Silent_Gap(Over_copy, b_neg, b_pos, FSel_p, FGaps_p, Gap_Fib_p, OvU, (Int_t)0);
437  Find_Proj(Over_copy, b_neg, b_pos_silent, OvU, NumU);
438 
439  for (Int_t bin=0;bin<72000;bin++)
440  {
441  Over_copy[bin]=Over_n[bin];
442  }
443  Gaps[1][0] = Silent_Gap(Over_copy, b_pos, b_neg, FSel_n, FGaps_n, Gap_Fib_n, OvV, 1);
444  Find_Proj(Over_copy, b_pos, b_neg_silent, OvV, NumV);
445 
446  if (Gaps[0][0]>0 || Gaps[1][0]>0)
447  {
448  b_p.push_back(b_pos_silent);
449  Ov_p.push_back(OvU);
450  Num_p.push_back(NumU);
451 
452  b_n.push_back(b_neg_silent);
453  Ov_n.push_back(OvV);
454  Num_n.push_back(NumV);
455 
456  GapsID.push_back(1);
457  }
458 
459  //then looking for active gaps in the plateau
460  for (Int_t bin=0;bin<72000;bin++)
461  {
462  Over_copy[bin]=Over_p[bin];
463  }
464  Gaps[0][1] = Active_Gap(0,Over_copy, b_neg, b_pos, FSel_p, OvU, 0);
465  Find_Proj(Over_copy, b_neg, b_pos_active, OvU, NumU);
466 
467  for (Int_t bin=0;bin<72000;bin++)
468  {
469  Over_copy[bin]=Over_n[bin];
470  }
471  Gaps[1][1] = Active_Gap(1,Over_copy, b_pos, b_neg, FSel_n, OvV, 1);
472  Find_Proj(Over_copy, b_pos, b_neg_active, OvV, NumV);
473 
474  if (Gaps[0][1]>0 || Gaps[1][1]>0)
475  {
476  b_p.push_back(b_pos_active);
477  Ov_p.push_back(OvU);
478  Num_p.push_back(NumU);
479 
480  b_n.push_back(b_neg_active);
481  Ov_n.push_back(OvV);
482  Num_n.push_back(NumV);
483 
484  GapsID.push_back(2);
485  }
486 
487  //Then looking for both gaps in the plateau
488  if ((Gaps[0][0]>0 || Gaps[1][0]>0) && (Gaps[0][1]>0 || Gaps[1][1]>0))
489  {
490  for (Int_t bin=0;bin<72000;bin++)
491  {
492  Over_copy[bin]=Over_p[bin];
493  }
494  Silent_Gap(Over_copy, b_neg, b_pos, FSel_p, FG_p, G_F_p, OvU, 0);
495  Active_Gap(0,Over_copy, b_neg, b_pos, FSel_p, OvU, 0);
496  Find_Proj(Over_copy, b_neg, b_pos_active, OvU, NumU);
497 
498  for (Int_t bin=0;bin<72000;bin++)
499  {
500  Over_copy[bin]=Over_n[bin];
501  }
502  Silent_Gap(Over_copy, b_pos, b_neg, FSel_n, FG_n, G_F_n, OvV, 1);
503  Active_Gap(1,Over_copy, b_pos, b_neg, FSel_n, OvV, 1);
504  Find_Proj(Over_copy, b_pos, b_neg_active, OvV, NumV);
505 
506  b_p.push_back(b_pos_active);
507  Ov_p.push_back(OvU);
508  Num_p.push_back(NumU);
509 
510  b_n.push_back(b_neg_active);
511  Ov_n.push_back(OvV);
512  Num_n.push_back(NumV);
513 
514  GapsID.push_back(3);
515  }
516  }
517  }
518 }
519 
520 void ALFA_MDGap::GetData(Int_t (&iNumU)[MAXTRACKNUM], Int_t (&iNumV)[MAXTRACKNUM], Float_t (&fOvU)[MAXTRACKNUM], Float_t (&fOvV)[MAXTRACKNUM], Int_t (&iFibSel)[ALFALAYERSCNT*ALFAPLATESCNT])
521 {
522  for (Int_t iTrack=0; iTrack<MAXTRACKNUM; iTrack++)
523  {
524  iNumU[iTrack] = m_iNU[iTrack];
525  iNumV[iTrack] = m_iNV[iTrack];
526  fOvU[iTrack] = m_fOvU[iTrack];
527  fOvV[iTrack] = m_fOvV[iTrack];
528 
529  for (Int_t iLayer=0; iLayer<ALFALAYERSCNT*ALFAPLATESCNT; iLayer++)
530  {
531  iFibSel[iLayer] = m_iFibSel[iLayer];
532  }
533  }
534 }
535 
536 
537 Int_t ALFA_MDGap::Silent_Gap(Int_t (&Over)[72000], Float_t b_ref, Float_t b_rec, const Int_t FSel[ALFAPLATESCNT], Bool_t (&FGap)[ALFAPLATESCNT], Int_t (&Gap_Fib)[ALFAPLATESCNT][2], Float_t OverLap, Int_t iSideFlag)
538 {
539  Float_t fSign;
540  Float_t fXInter, fYInter;
541  Float_t fFibCen, fFibCen0, fFibCen1;
542 
543  Float_t b_center, gap_size;
544  Int_t Gap_Width;
545 
546  Int_t Found_Gap=0;
547 
548  if (m_faMD[m_iRPot][iSideFlag][0]>0) fSign=1.0;
549  else fSign=-1.0;
550 
551  for(UInt_t iLayer=0; iLayer<ALFAPLATESCNT; iLayer++)
552  {
553  if (FSel[iLayer]==9999)
554  {
555  if (iSideFlag==0 || (iSideFlag==1 && iLayer!=4))
556  {
557  for (Int_t iFiber=0; iFiber<ALFAFIBERSCNT-1; iFiber++)
558  {
559  fXInter= fSign*(b_ref-m_fbMD[m_iRPot][iLayer*2+iSideFlag][iFiber])/(1+fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][iFiber]);
560  fYInter= (fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][iFiber]*b_ref+m_fbMD[m_iRPot][iLayer*2+iSideFlag][iFiber])/(1+fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][iFiber])-b_ref;
561  fFibCen0 = (fYInter-fSign*fXInter)/sqrt(2.);
562 
563  fXInter= fSign*(b_ref-m_fbMD[m_iRPot][iLayer*2+iSideFlag][iFiber+1])/(1+fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][iFiber+1]);
564  fYInter= (fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][iFiber+1]*b_ref+m_fbMD[m_iRPot][iLayer*2+iSideFlag][iFiber+1])/(1+fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][iFiber+1])-b_ref;
565  fFibCen1 = (fYInter-fSign*fXInter)/sqrt(2.);
566 
567  b_center = (fFibCen1+fFibCen0)/2.;
568 
569  fXInter= fSign*(b_ref-b_rec)/2.;
570  fYInter= (b_ref+b_rec)/2.-b_ref;
571  fFibCen = (fYInter-fSign*fXInter)/sqrt(2.);
572 
573  gap_size = TMath::Abs(fFibCen1-fFibCen0)-0.480;
574  Gap_Width = int(gap_size*1000.);
575 
576  if (((b_center+gap_size/2.)<fFibCen+OverLap/2. && (b_center+gap_size/2.)> fFibCen-OverLap/2.) || ((b_center-gap_size/2.)>fFibCen-OverLap/2. && (b_center-gap_size/2.)<fFibCen+OverLap/2.))
577  {
578  Found_Gap++;
579  FGap[iLayer]=true;
580 
581  Gap_Fib[iLayer][0] = iFiber;
582  Gap_Fib[iLayer][1] = iFiber+1;
583 
584  for (Int_t bin=0;bin<Gap_Width;bin++)
585  {
586  Over[(Int_t)((b_center-gap_size/2.)*1000)+bin+36000]++;
587  }
588  }
589  }
590  }
591  }
592  }
593 
594  return Found_Gap;
595 }
596 
597 Int_t ALFA_MDGap::Active_Gap(Int_t iFiberSide, Int_t (&Over)[72000], Float_t b_ref, Float_t b_rec, const Int_t FSel[ALFAPLATESCNT], Float_t OverLap, Int_t iSideFlag)
598 {
599  Float_t fSign;
600  Float_t fXInter, fYInter;
601  Float_t fFibCen, fFibCen0, fFibCen1;
602 
603  Float_t b_center, gap_size;
604  Int_t Gap_Width;
605 
606  Int_t Found_Gap=0;
607 
608  if (m_faMD[m_iRPot][iSideFlag][0]>0) fSign=1.0;
609  else fSign=-1.0;
610 
611  Bool_t bHit[2];
612  Int_t shift;
613 
615  int iIndex = 0;
616  for(UInt_t iLayer=0; iLayer<ALFAPLATESCNT; iLayer++)
617  {
618  iIndex = 2*iLayer+iFiberSide;
619  if (FSel[iLayer]!=9999)
620  {
621  bHit[0]=false;
622  bHit[1]=false;
623 
624  for (iHit=m_MapLayers[iIndex].ListFibers.begin(); iHit!=m_MapLayers[iIndex].ListFibers.end(); ++iHit)
625  {
626  if (*iHit==FSel[iLayer]+1) bHit[0]=true;
627  if (*iHit==FSel[iLayer]-1) bHit[1]=true;
628  }
629 
630  for (UInt_t j=0;j<2;j++)
631  {
632  if (j==0) shift=1;
633  else shift=-1;
634 
635  if(bHit[j])
636  {
637  fXInter= fSign*(b_ref-m_fbMD[m_iRPot][iLayer*2+iSideFlag][FSel[iLayer]])/(1+fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][FSel[iLayer]]);
638  fYInter= (fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][FSel[iLayer]]*b_ref+m_fbMD[m_iRPot][iLayer*2+iSideFlag][FSel[iLayer]])/(1+fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][FSel[iLayer]])-b_ref;
639  fFibCen0 = (fYInter-fSign*fXInter)/sqrt(2.);
640 
641  fXInter= fSign*(b_ref-m_fbMD[m_iRPot][iLayer*2+iSideFlag][FSel[iLayer]+shift])/(1+fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][FSel[iLayer]+shift]);
642  fYInter= (fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][FSel[iLayer]+shift]*b_ref+m_fbMD[m_iRPot][iLayer*2+iSideFlag][FSel[iLayer]+shift])/(1+fSign*m_faMD[m_iRPot][iLayer*2+iSideFlag][FSel[iLayer]+shift])-b_ref;
643  fFibCen1 = (fYInter-fSign*fXInter)/sqrt(2.);
644 
645  b_center = (fFibCen1+fFibCen0)/2.;
646 
647  fXInter= fSign*(b_ref-b_rec)/2.;
648  fYInter= (b_ref+b_rec)/2.-b_ref;
649  fFibCen = (fYInter-fSign*fXInter)/sqrt(2.);
650 
651  gap_size = TMath::Abs(fFibCen1-fFibCen0)-0.480;
652  Gap_Width = int(gap_size*1000.);
653 
654  if (((b_center+gap_size/2.)<fFibCen+OverLap/2. && (b_center+gap_size/2.)> fFibCen-OverLap/2.) || ((b_center-gap_size/2.)>fFibCen-OverLap/2. && (b_center-gap_size/2.)<fFibCen+OverLap/2.))
655  {
656  Found_Gap++;
657 
658  for (Int_t bin=0;bin<Gap_Width;bin++)
659  {
660  Over[(Int_t)((b_center-gap_size/2.)*1000)+bin+36000]++;
661  }
662  }
663  }
664  }
665  }
666  }
667 
668  return Found_Gap;
669 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
MAXTRACKNUM
#define MAXTRACKNUM
Definition: ALFA_MDGap.h:25
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
ALFA_MDGap::m_fOvU
Float_t m_fOvU[MAXTRACKNUM]
Definition: ALFA_MDGap.h:51
ALFA_MDGap::m_fOverlapCut
Float_t m_fOverlapCut
Definition: ALFA_MDGap.h:36
ALFA_MDGap.h
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ALFA_MDGap::Silent_Gap
Int_t Silent_Gap(Int_t(&Over)[72000], Float_t b_ref, Float_t b_rec, const Int_t FSel[ALFAPLATESCNT], Bool_t(&FGap)[ALFAPLATESCNT], Int_t(&Gap_Fib)[ALFAPLATESCNT][2], Float_t OverLap, Int_t iSideFlag)
Definition: ALFA_MDGap.cxx:537
ALFAFIBERSCNT
#define ALFAFIBERSCNT
Definition: ALFA_constants.h:10
ALFA_MDGap::m_fRecYPos
Float_t m_fRecYPos[MAXTRACKNUM]
Definition: ALFA_MDGap.h:50
_FIBERS
Definition: ALFA_LocRec/ALFA_UserObjects.h:30
bin
Definition: BinsDiffFromStripMedian.h:43
RPOTSCNT
#define RPOTSCNT
Definition: ALFA_CLinkAlg.h:26
ALFA_MDGap::Proj_Store
void Proj_Store(Int_t iFiberSide, Int_t(&iOver)[72000], Float_t fbRef, Int_t iSideFlag)
Definition: ALFA_MDGap.cxx:158
ALFA_MDGap::Execute
StatusCode Execute(const std::list< MDHIT > &ListMDHits)
Definition: ALFA_MDGap.cxx:64
ALFA_MDGap::Active_Gap
Int_t Active_Gap(Int_t iFiberSide, Int_t(&Over)[72000], Float_t b_ref, Float_t b_rec, const Int_t FSel[ALFAPLATESCNT], Float_t OverLap, Int_t iSideFlag)
Definition: ALFA_MDGap.cxx:597
ALFA_MDGap::Reco_Track
void Reco_Track(std::vector< Float_t > &b_p, std::vector< Float_t > &b_n, std::vector< Float_t > &Ov_p, std::vector< Float_t > &Ov_n, std::vector< int > &Num_p, std::vector< int > &Num_n, Int_t(&FSel_n)[ALFAPLATESCNT], Int_t(&FSel_p)[ALFAPLATESCNT], Int_t(&Gaps)[2][2], std::vector< Int_t > &GapsID, Bool_t(&FGaps_p)[ALFAPLATESCNT], Bool_t(&FGaps_n)[ALFAPLATESCNT], Int_t(&Gap_Fib_p)[ALFAPLATESCNT][2], Int_t(&Gap_Fib_n)[ALFAPLATESCNT][2])
Definition: ALFA_MDGap.cxx:327
x
#define x
ALFA_MDGap::m_fOvV
Float_t m_fOvV[MAXTRACKNUM]
Definition: ALFA_MDGap.h:52
ALFA_MDGap::Finalize
StatusCode Finalize(Float_t(&fRecXPos)[MAXTRACKNUM], Float_t(&fRecYPos)[MAXTRACKNUM])
Definition: ALFA_MDGap.cxx:144
ALFA_MDGap::m_MapLayers
std::map< Int_t, FIBERS > m_MapLayers
Definition: ALFA_MDGap.h:55
ALFA_MDGap::GetData
void GetData(Int_t(&iNumU)[MAXTRACKNUM], Int_t(&iNumV)[MAXTRACKNUM], Float_t(&fOvU)[MAXTRACKNUM], Float_t(&fOvV)[MAXTRACKNUM], Int_t(&iFibSel)[ALFALAYERSCNT *ALFAPLATESCNT])
Definition: ALFA_MDGap.cxx:520
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ALFA_MDGap::m_iRPot
Int_t m_iRPot
Definition: ALFA_MDGap.h:34
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
ALFA_MDGap::m_faMD
Float_t m_faMD[RPOTSCNT][ALFALAYERSCNT *ALFAPLATESCNT][ALFAFIBERSCNT]
Definition: ALFA_MDGap.h:39
ALFA_MDGap::m_iFibSel
Int_t m_iFibSel[ALFALAYERSCNT *ALFAPLATESCNT]
Definition: ALFA_MDGap.h:47
ALFA_MDGap::Finding_Fib
void Finding_Fib(Int_t iFiberSide, Float_t fbRef, Float_t fbRec, Int_t(&iFSel)[ALFAPLATESCNT], Int_t iSideFlag)
Definition: ALFA_MDGap.cxx:263
_FIBERS::ListFibers
std::list< int > ListFibers
Definition: ALFA_LocRec/ALFA_UserObjects.h:31
ALFALAYERSCNT
#define ALFALAYERSCNT
Definition: ALFA_constants.h:8
ALFA_MDGap::m_iNumHitsLayer
Int_t m_iNumHitsLayer[ALFALAYERSCNT *ALFAPLATESCNT]
Definition: ALFA_MDGap.h:43
ALFA_MDGap::m_iUVCut
Int_t m_iUVCut
Definition: ALFA_MDGap.h:35
ALFA_MDGap::m_iNV
Int_t m_iNV[MAXTRACKNUM]
Definition: ALFA_MDGap.h:46
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
ALFA_MDGap::m_iNU
Int_t m_iNU[MAXTRACKNUM]
Definition: ALFA_MDGap.h:45
y
#define y
ALFA_MDGap::m_fbMD
Float_t m_fbMD[RPOTSCNT][ALFALAYERSCNT *ALFAPLATESCNT][ALFAFIBERSCNT]
Definition: ALFA_MDGap.h:40
ALFA_MDGap::m_fRecXPos
Float_t m_fRecXPos[MAXTRACKNUM]
Definition: ALFA_MDGap.h:49
ALFA_MDGap::ALFA_MDGap
ALFA_MDGap()
Definition: ALFA_MDGap.cxx:7
ALFA_MDGap::~ALFA_MDGap
~ALFA_MDGap()
Definition: ALFA_MDGap.cxx:26
ALFA_MDGap::Find_Proj
void Find_Proj(const Int_t iOver[72000], Float_t fbRef, Float_t &fb, Float_t &fOv, Int_t &fNum) const
Definition: ALFA_MDGap.cxx:199
ALFA_MDGap::Initialize
StatusCode Initialize(Int_t iRPot, Float_t faMD[RPOTSCNT][ALFALAYERSCNT *ALFAPLATESCNT][ALFAFIBERSCNT], Float_t fbMD[RPOTSCNT][ALFALAYERSCNT *ALFAPLATESCNT][ALFAFIBERSCNT], Int_t iUVCut, Float_t fOverlapCut)
Definition: ALFA_MDGap.cxx:30
ALFAPLATESCNT
#define ALFAPLATESCNT
Definition: ALFA_constants.h:9