ATLAS Offline Software
D3PDMaker/TileD3PDMaker/src/TrackTools.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*
6  * File: TrackTools.cxx
7  * Author: Marco van Woerden <mvanwoer@cern.ch>, Archil Durglishvili <archil.durglishvili@cern.ch>
8  * Description: Track tools.
9  *
10  * Created in February 2013.
11  * Updated in November 2014
12  */
14 #include "TrackTools.h"
15 
16 //=============================================
17 TrackTools::TrackTools(const std::string&type,
18  const std::string&name,
19  const IInterface*parent) :
21 m_caloExtensionTool("Trk::ParticleCaloExtensionTool/ParticleCaloExtensionTool"),
22 m_caloCellAssociationTool("Rec::ParticleCaloCellAssociationTool/ParticleCaloCellAssociationTool"), //At the moment this tool is not needed
23 m_trackIsolationTool("TrackIsolationTool")
24 {
25 //============================================
26  // INTERFACING
27  declareInterface<ITrackTools>(this);
28 
29  declareProperty("TrackIsolationTool", m_trackIsolationTool );
30  declareProperty("ParticleCaloExtensionTool",m_caloExtensionTool );
31  declareProperty("ParticleCaloCellAssociationTool",m_caloCellAssociationTool ); //At the moment this tool is not needed
32 } // TRACKTOOLS::TRACKTOOLS
33 
34 //========================
36 //=======================
37 } // TRACKTOOLS::~TRACKTOOLS
38 
39 //==================================
41 //=================================
42 
43  ATH_MSG_INFO( "Initializing TrackTools" );
44 
45  ATH_CHECK(m_caloExtensionTool.retrieve());
46  ATH_CHECK(m_caloCellAssociationTool.retrieve()); //At the moment this tool is not needed
47  ATH_CHECK(m_trackIsolationTool.retrieve());
48 
49  return StatusCode::SUCCESS;
50 } // TrackTools::initialize
51 
52 //================================
54 //===============================
55  ATH_MSG_INFO( "Finalizing TrackTools" );
56  return StatusCode::SUCCESS;
57 } // TRACKTOOLS::FINALIZE
58 
59 //==================================================================================================
60 std::unique_ptr<const Trk::TrackParameters> TrackTools::getTrackInCellSampling(const TRACK* track, CaloSampling::CaloSample sampling){
61 //==================================================================================================
62  if( !m_caloExtensionTool.empty() ){
63  std::unique_ptr<Trk::CaloExtension> extension =
64  m_caloExtensionTool->caloExtension(Gaudi::Hive::currentContext(), *track);
65  if (!extension)
66  return nullptr;
67 
68  Trk::TrackParametersIdHelper parsIdHelper;
69 
70  std::map<CaloSampling::CaloSample,const Trk::CurvilinearParameters*> Samplings;
71 
72  // loop over calo layers, keep track of previous layer
73  auto cur = extension->caloLayerIntersections().begin();
74  auto prev = cur;
75  for( ; cur != extension->caloLayerIntersections().end() ; ++cur ){
76  // check that prev and cur are not the same, if not fill if the previous was an entry layer
77  if( prev != cur && parsIdHelper.isEntryToVolume((*prev).cIdentifier()) )
78  {
79  TrackParametersIdentifier id = (*prev).cIdentifier();
80  CaloSampling::CaloSample sample = parsIdHelper.caloSample(id);
81  Samplings[sample] = &(*prev);
82  }
83  prev=cur;
84  }
85  if(!Samplings[sampling]) {return nullptr ;}
86  else {return std::make_unique<const Trk::CurvilinearParameters> (*(Samplings[sampling]));}
87  }
88  return nullptr;
89 }
90 
91 //==================================================================================================
93 //==================================================================================================
94  std::vector<double> coordinates;
95  if( !m_caloExtensionTool.empty() ){
96  std::unique_ptr<Trk::CaloExtension> extension =
97  m_caloExtensionTool->caloExtension(Gaudi::Hive::currentContext(), *track);
98  if (!extension)
99  return coordinates;
100 
101  Trk::TrackParametersIdHelper parsIdHelper;
102 
103  std::map<CaloSampling::CaloSample,const Trk::TrackParameters*> Samplings;
104 
105  // loop over calo layers, keep track of previous layer
106  auto cur = extension->caloLayerIntersections().begin();
107  auto prev = cur;
108  for( ; cur != extension->caloLayerIntersections().end() ; ++cur ){
109  // check that prev and cur are not the same, if not fill if the previous was an entry layer
110  if( prev != cur && parsIdHelper.isEntryToVolume((*prev).cIdentifier()) )
111  {
112  TrackParametersIdentifier id = (*prev).cIdentifier();
113  CaloSampling::CaloSample sample = parsIdHelper.caloSample(id);
114  Samplings[sample] = &(*prev);
115  }
116  prev=cur;
117  }
118  if(!(Samplings[sampling])) return coordinates;
119  coordinates.push_back(Samplings[sampling]->position().x());
120  coordinates.push_back(Samplings[sampling]->position().y());
121  coordinates.push_back(Samplings[sampling]->position().z());
122  coordinates.push_back(Samplings[sampling]->position().eta());
123  coordinates.push_back(Samplings[sampling]->position().phi());
124  }
125  return coordinates;
126 } // getXYZEtaPhiInCellSampling
127 
128 
129 //==========================================================================================================
130 std::vector< double > TrackTools::getXYZEtaPhiInCellSampling(const TRACK* track, const CaloCell *cell){
131 //==========================================================================================================
132  std::vector<double> coordinates;
133 
134  if(!cell || !track) return coordinates;
135  // GET CELL DESCRIPTOR AND SAMPLING
136  const CaloDetDescrElement* dde = cell->caloDDE();
137  if(!dde) return coordinates;
138  CaloSampling::CaloSample sampling = dde->getSampling();
139 
140  return getXYZEtaPhiInCellSampling(track,sampling);
141 } // getXYZEtaPhiInCellSampling
142 
143 
144 //=====================================================================================================
145 std::vector< std::vector<double> > TrackTools::getXYZEtaPhiPerLayer(const TRACK* track){
146 //====================================================================================================
147  std::vector< std::vector<double> > coordinates(11);
148 
149  for(unsigned int sample=0 ; sample<21; ++sample) //Samplings:http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.def
150  {
151  std::vector<double> TrkPars(5);
152  std::vector<double> XYZEtaPhi = getXYZEtaPhiInCellSampling( track, (CaloSampling::CaloSample)sample );
153  TrkPars[0] = ( XYZEtaPhi.size()!=5 ) ? -9999. : XYZEtaPhi[0] ;
154  TrkPars[1] = ( XYZEtaPhi.size()!=5 ) ? -9999. : XYZEtaPhi[1] ;
155  TrkPars[2] = ( XYZEtaPhi.size()!=5 ) ? -9999. : XYZEtaPhi[2] ;
156  TrkPars[3] = ( XYZEtaPhi.size()!=5 ) ? -9999. : XYZEtaPhi[3] ;
157  TrkPars[4] = ( XYZEtaPhi.size()!=5 ) ? -9999. : XYZEtaPhi[4] ;
158  int lay=-1;
159  if (sample==0 || sample==4 ){lay=0;}
160  else if(sample==1 || sample==5 ){lay=1;}
161  else if(sample==2 || sample==6 ){lay=2;}
162  else if(sample==3 || sample==7 ){lay=3;}
163  else if(sample==12 || sample==18){lay=4;}
164  else if(sample==13 || sample==19){lay=5;}
165  else if(sample==15 || sample==17){lay=5;}
166  else if(sample==14 || sample==20){lay=6;}
167  else if(sample==16) {lay=6;}
168  else if(sample==8 ){lay=7;}
169  else if(sample==9 ){lay=8;}
170  else if(sample==10 ){lay=9;}
171  else if(sample==11 ){lay=10;}
172  if(lay!=-1) coordinates[lay] = TrkPars;
173  } // FOR
174 
175  return coordinates;
176 } // TrackTools::getXYZEtaPhiPerLayer
177 
178 //=====================================================================================================
179 std::vector< std::vector<double> > TrackTools::getXYZEtaPhiPerSampling(const TRACK* track){
180 //====================================================================================================
181  std::vector< std::vector<double> > coordinates;
182 
183  for(unsigned int s=0 ; s<21; ++s) //Samplings: http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.def
184  {
185  std::vector<double> TrkPars(5);
186  std::vector<double> XYZEtaPhi = getXYZEtaPhiInCellSampling( track, (CaloSampling::CaloSample)s );
187  TrkPars[0] = ( XYZEtaPhi.size()!=5 ) ? -9999. : XYZEtaPhi[0] ;
188  TrkPars[1] = ( XYZEtaPhi.size()!=5 ) ? -9999. : XYZEtaPhi[1] ;
189  TrkPars[2] = ( XYZEtaPhi.size()!=5 ) ? -9999. : XYZEtaPhi[2] ;
190  TrkPars[3] = ( XYZEtaPhi.size()!=5 ) ? -9999. : XYZEtaPhi[3] ;
191  TrkPars[4] = ( XYZEtaPhi.size()!=5 ) ? -9999. : XYZEtaPhi[4] ;
192  coordinates.push_back(TrkPars);
193  } // FOR
194 
195  return coordinates;
196 } // TrackTools::getXYZEtaPhiPerSampling
197 
198 
199 //======================================================================
201  const CaloCellContainer* input,
203  double cone,
204  bool includelar){
205 //======================================================================
206  // CELLS WITHIN CONE AROUND TRACK
209  for(;icell!=end;++icell){
210  const CaloCell* cell = (*icell);
211  const CaloDetDescrElement* dde = cell->caloDDE();
212 
213  // REASONS TO SKIP THIS CELL OR BREAK THE LOOP
214  if(!dde) continue;
215  if(!includelar && dde->getSubCalo() == CaloCell_ID::LAREM) continue;
216  if(dde->getSubCalo() != CaloCell_ID::LAREM && dde->getSubCalo() != CaloCell_ID::TILE) continue;
217 
218  std::vector<double> coordinates = getXYZEtaPhiInCellSampling(track,dde->getSampling());
219  if(coordinates.size()!=5) continue;
220 
221  double deltaR = KinematicUtils::deltaR( cell->eta(),coordinates[3], cell->phi(),coordinates[4]);
222 
223  if(deltaR<=cone)
224  {
225  unsigned int i=0;
226  while(i!=output->size()){if(output->at(i)==cell){break;}i++;}
227  if(i==output->size())
228  {
229  output->push_back(cell);
230  }
231  }
232  } // FOR
233 } // TrackTools::getCellsWithinConeAroundTrack
234 
235 //======================================================================================
237 //======================================================================================
238 
239  ATH_MSG_DEBUG("in TrackInCaloTools::getPathInsideCell" );
240 
241  // GET CELL DESCRIPTOR AND SAMPLING
242  const CaloDetDescrElement* dde = cell->caloDDE();
243  if(!dde) return 0.;
244  int sampling = dde->getSampling();
245  int sampling_entrance = 0;
246  int sampling_exit = 0;
247  switch(sampling){
248  case 12: sampling_entrance = 12; sampling_exit = 14; break;
249  case 13: sampling_entrance = 12; sampling_exit = 14; break;
250  case 14: sampling_entrance = 12; sampling_exit = 14; break;
251  case 15: sampling_entrance = 13; sampling_exit = 14; break;
252  case 16: sampling_entrance = 12; sampling_exit = 13; break;
253  case 17: sampling_entrance = 17; sampling_exit = 19; break;
254  case 18: sampling_entrance = 18; sampling_exit = 20; break;
255  case 19: sampling_entrance = 18; sampling_exit = 20; break;
256  case 20: sampling_entrance = 18; sampling_exit = 20; break;
257  default: return 0.;
258  } // SWITCH
259 
260  std::unique_ptr<const Trk::TrackParameters> pars_entrance =
262  std::unique_ptr<const Trk::TrackParameters> pars_exit =
264 
265  if( !pars_entrance || !pars_exit ) return 0.;
266 
267  return getPath(cell, pars_entrance.get(), pars_exit.get());
268 } // TrackTools::getPathInsideCell
269 
270 //=====================================================================================================================================
272 //====================================================================================================================================
273  ATH_MSG_DEBUG("IN getPath...");
274 
275  // OBTAIN LAYER INDICES FOR LINEAR INTERPOLATION
276  unsigned int SampleID = cell->caloDDE()->getSampling();
277 
278  // OBTAIN TRACK AND CELL PARAMETERS
279  double pathl = 0.;
280  double Layer1X(exit->position().x()),Layer1Y(exit->position().y()),Layer1Z(exit->position().z());
281  double Layer2X(entrance->position().x()),Layer2Y(entrance->position().y()),Layer2Z(entrance->position().z());
282 
283  double CellPhi(cell->caloDDE()->phi()),CellDPhi(cell->caloDDE()->dphi());
284  double CellPhimin = CellPhi-CellDPhi/2.;
285  double CellPhimax = CellPhi+CellDPhi/2.;
286  double CellEta(cell->caloDDE()->eta());
287  double CellZ(cell->caloDDE()->z()),CellDZ(cell->caloDDE()->dz());
288  double CellZmin = CellZ-CellDZ/2.;
289  double CellZmax = CellZ+CellDZ/2.;
290  double CellR(cell->caloDDE()->r()),CellDR(cell->caloDDE()->dr());
291  double CellRmin = CellR-CellDR/2.;
292  double CellRmax = CellR+CellDR/2.;
293 
294  // TILECAL GEOMETRY
295  double RLBAmin = 2300;
296  double RLBAmax = 2600;
297  double RLBBmin = 2600;
298  double RLBBmax = 2990;
299  double RLBCmin = 2990;
300  double RLBCmax = 3440;
301  double RLBDmin = 3440;
302  double RLBDmax = 3820;
303 
304  double REBAmin = 2300;
305  double REBAmax = 2600;
306  double REBBmin = 2600;
307  double REBBmax = 3140;
308  double REBDmin = 3140;
309  double REBDmax = 3820;
310 
311  double RITC_D4_min = 3630 - 380./2.;
312  double RITC_C10_min = 3215 - 450./2.;
313  double RITC_E1_min = 2803 - 313./2.;
314  double RITC_E2_min = 2476 - 341./2.;
315  double RITC_E3_min = 2066 - 478./2.;
316  double RITC_E4_min = 1646 - 362./2.;
317 
318  double RITC_D4_max = 3630 + 380./2.;
319  double RITC_C10_max = 3215 + 450./2.;
320  double RITC_E1_max = 2803 + 313./2.;
321  double RITC_E2_max = 2476 + 341./2.;
322  double RITC_E3_max = 2066 + 478./2.;
323  double RITC_E4_max = 1646 + 362./2.;
324 
325  double ZITC_D4_a = 3405;
326  double ZITC_C10_a = 3511;
327  double ZITC_E1_a = 3552;
328  // double ZITC_E2_a = 3552;
329  double ZITC_E3_a = 3536;
330  // double ZITC_E4_a = 3536;
331 
332  double ZITC_D4_c = 3395;
333  double ZITC_C10_c = 3501;
334  double ZITC_E1_c = 3542;
335  // double ZITC_E2_c = 3542;
336  double ZITC_E3_c = 3526;
337  // double ZITC_E4_c = 3526;
338 
339  double ZDITC_D4 = 309.;
340  double ZDITC_C10 = 95.;
341  double ZDITC_E1 = 12.;
342  // double ZDITC_E2 = 12.;
343  double ZDITC_E3 = 6.;
344  // double ZDITC_E4 = 6.;
345 
346  double CellZB[9] = {141.495, 424.49, 707.485, 999.605, 1300.855, 1615.8, 1949., 2300.46, 2651.52};
347  double CellDZB[9] = {282.99, 283., 282.99, 301.25, 301.25, 328.64, 337.76, 365.16, 336.96};
348  double CellZC[9] = {159.755, 483.83, 812.465, 1150.23, 1497.125, 1857.71, 2241.12, 2628.695,0};
349  double CellDZC[9] = {319.51, 328.64, 328.63, 346.9, 346.89, 374.28, 392.54, 382.61,0};
350 
351  double CellXimp[2], CellYimp[2], CellZimp[2];
352  // double Sxz(0), Syz(0), Sxy(0);
353  double X(0), Y(0), Z(0), R(0), Phi(0);
354  double DeltaPhi;
355 
356  int etaInd(-1);
357 
358  float samplecellmap[81] = {
359  12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
360  13, 13, 13, 13, 13, 13, 13, 13, 13,
361  14, 14, 14, 14,
362  16, 15, 17, 17, 17, 17, //** ITC
363  18, 18, 18, 18, 18,
364  19, 19, 19, 19, 19,
365  20, 20,
366  12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
367  13, 13, 13, 13, 13, 13, 13, 13, 13,
368  14, 14, 14,
369  16, 15, 17, 17, 17, 17, //** ITC
370  18, 18, 18, 18, 18,
371  19, 19, 19, 19, 19,
372  20, 20
373  };
374  float etacellmap[81] = { 0.05,0.15,0.25,0.35,0.45,0.55,0.65,0.75,0.85,0.95,
375  0.05,0.15,0.25,0.35,0.45,0.55,0.65,0.75,0.85,
376  0.0, 0.2,0.4,0.6,
377  0.8579205,0.9583722,1.0589020,1.1593041,1.3098471,1.5103633,
378  1.1594202,1.2586680,1.3579534,1.4572804,1.556651,
379  1.0586925,1.1580252,1.2573844,1.3567756,1.4562022,
380  1.0074122,1.2063241,
381  -0.05,-0.15,-0.25,-0.35,-0.45,-0.55,-0.65,-0.75,-0.85,-0.95,
382  -0.05,-0.15,-0.25,-0.35,-0.45,-0.55,-0.65,-0.75,-0.85,
383  -0.2,-0.4,-0.6,
384  -0.855940, -0.956279, -1.056676, -1.156978,-1.307385,-1.507772,
385  -1.157065,-1.256501,-1.355965,-1.455460,-1.554988,
386  -1.056519,-1.156018,-1.255538,-1.355081,-1.454651,
387  -1.005559,-1.204743
388  };
389 
390  for(int i=0; i<81; i++){
391  if(SampleID==samplecellmap[i] && fabs(CellEta-etacellmap[i])<0.001) etaInd = i;
392  } // FOR
393 
394  // COMPUTE PATH
395  bool compute = true;
396  int lBC(0);
397  while(compute){
398  if(lBC==1 && (etaInd==18 || etaInd==59) ) break;
399  int Np = 0;
400  if(sqrt((Layer1X-Layer2X)*(Layer1X-Layer2X)+(Layer1Y-Layer2Y)*(Layer1Y-Layer2Y)) < 3818.5){
401  if(SampleID == 15){
402  CellRmin = RITC_C10_min;
403  CellRmax = RITC_C10_max;
404  if(CellEta > 0){
405  if(CellZmin < ZITC_C10_a-ZDITC_C10/2.) CellZmin = ZITC_C10_a-ZDITC_C10/2.;
406  if(CellZmax > ZITC_C10_a+ZDITC_C10/2.) CellZmax = ZITC_C10_a+ZDITC_C10/2.;
407  } // IF
408  else if(CellEta < 0){
409  if(CellZmin < -ZITC_C10_c-ZDITC_C10/2.) CellZmin = -ZITC_C10_c-ZDITC_C10/2.;
410  if(CellZmax > -ZITC_C10_c+ZDITC_C10/2.) CellZmax = -ZITC_C10_c+ZDITC_C10/2.;
411  } // ELSE IF
412  } // IF
413  else if(SampleID == 16){
414  CellRmin=RITC_D4_min;
415  CellRmax=RITC_D4_max;
416  if(CellEta > 0){
417  if(CellZmin < ZITC_D4_a-ZDITC_D4/2.) CellZmin = ZITC_D4_a-ZDITC_D4/2.;
418  if(CellZmax > ZITC_D4_a+ZDITC_D4/2.) CellZmax = ZITC_D4_a+ZDITC_D4/2.;
419  } // IF
420  else if(CellEta < 0){
421  if(CellZmin < -ZITC_D4_c-ZDITC_D4/2.) CellZmin = -ZITC_D4_c-ZDITC_D4/2.;
422  if(CellZmax > -ZITC_D4_c+ZDITC_D4/2.) CellZmax = -ZITC_D4_c+ZDITC_D4/2.;
423  } // ELSE IF
424  } // ELSE IF
425  else if(SampleID == 17){
426  if( etaInd==25 || etaInd==65 ){
427  CellRmax = RITC_E1_max;
428  CellRmin = RITC_E1_min;
429  } // IF
430  else if( etaInd==26 || etaInd==66 ){
431  CellRmax = RITC_E2_max;
432  CellRmin = RITC_E2_min;
433  } // ELSE IF
434  else if( etaInd==27 || etaInd==67 ){
435  CellRmax = RITC_E3_max;
436  CellRmin = RITC_E3_min;
437  } // ELSE IF
438  else if( etaInd==28 || etaInd==68 ){
439  CellRmax = RITC_E4_max;
440  CellRmin = RITC_E4_min;
441  } // ELSE IF
442  if( (etaInd>=25 && etaInd<=26) || (etaInd>=65 && etaInd<=66) ){
443  if(CellEta > 0){
444  if(CellZmin < ZITC_E1_a-ZDITC_E1/2.) CellZmin=ZITC_E1_a-ZDITC_E1/2.;
445  if(CellZmax > ZITC_E1_a+ZDITC_E1/2.) CellZmax=ZITC_E1_a+ZDITC_E1/2.;
446  } // IF
447  else if(CellEta < 0){
448  if(CellZmin < -ZITC_E1_c-ZDITC_E1/2.) CellZmin= -ZITC_E1_c-ZDITC_E1/2.;
449  if(CellZmax > -ZITC_E1_c+ZDITC_E1/2.) CellZmax= -ZITC_E1_c+ZDITC_E1/2.;
450  } // ELSE
451  } // IF
452  else if( (etaInd>=27 && etaInd<=28) || (etaInd>=67 && etaInd<=68) ){
453  if(CellEta > 0){
454  if(CellZmin < ZITC_E3_a-ZDITC_E3/2.) CellZmin=ZITC_E3_a-ZDITC_E3/2.;
455  if(CellZmax > ZITC_E3_a+ZDITC_E3/2.) CellZmax=ZITC_E3_a+ZDITC_E3/2.;
456  } // IF
457  else if(CellEta < 0){
458  if(CellZmin < -ZITC_E3_c-ZDITC_E3/2.) CellZmin= -ZITC_E3_c-ZDITC_E3/2.;
459  if(CellZmax > -ZITC_E3_c+ZDITC_E3/2.) CellZmax= -ZITC_E3_c+ZDITC_E3/2.;
460  } // ELSE IF
461  } // ELSE
462  } // ELSE IF
463  else if(SampleID == 12){
464  CellRmin = RLBAmin;
465  CellRmax = RLBAmax;
466 
467  if(CellZmin <-2802.5439) CellZmin=-2802.5439;
468  if(CellZmax > 2802.5454) CellZmax=2802.5454;
469  } // ELSE IF
470  else if(SampleID == 13 && lBC == 0){
471  CellRmin = RLBBmin;
472  CellRmax = RLBBmax;
473  int cpos = fabs(CellEta)/0.1;
474  CellZ = CellZB[cpos];
475  if(CellEta < 0) CellZ=-CellZ;
476  CellDZ = CellDZB[cpos];
477  CellZmin = CellZ-CellDZ/2;
478  CellZmax = CellZ+CellDZ/2;
479  if(CellZmin <-2802.5439) CellZmin=-2802.5439;
480  if(CellZmax > 2802.5454) CellZmax=2802.5454;
481  } // ELSE IF
482  else if(SampleID == 13 && lBC == 1){
483  CellRmin = RLBCmin;
484  CellRmax = RLBCmax;
485  int cpos = fabs(CellEta)/0.1;
486  if(cpos >= 8) return 0;
487  CellZ = CellZC[cpos];
488  if(CellEta < 0) CellZ=-CellZ;
489  CellDZ = CellDZC[cpos];
490  CellZmin = CellZ-CellDZ/2;
491  CellZmax = CellZ+CellDZ/2;
492  if(CellZmin <-2802.5439) CellZmin=-2802.5439;
493  if(CellZmax >2802.5454) CellZmax=2802.5454;
494  } // ELSE IF
495  else if(SampleID == 14){
496  CellRmin = RLBDmin;
497  CellRmax = RLBDmax;
498  if(CellZmin <-2802.5439) CellZmin=-2802.5439;
499  if(CellZmax >2802.5454) CellZmax=2802.5454;
500  } // ELSE IF
501  if(SampleID == 18){
502  CellRmin = REBAmin;
503  CellRmax = REBAmax;
504  if(CellEta > 0){
505  if(CellZmin <3574.5027) CellZmin=3574.4978;
506  if(CellZmax >6130.0039) CellZmax=6130.0039;
507  } // IF
508  else if(CellEta < 0){
509  if(CellZmin <-6120.0018) CellZmin=-6120.0018;
510  if(CellZmax >-3564.5006) CellZmax=-3564.5006;
511  } // IF
512  } // IF
513  if(SampleID == 19){
514  CellRmin = REBBmin;
515  CellRmax = REBBmax;
516  if(CellEta > 0){
517  if(CellZmin <3574.5027) CellZmin=3574.4978;
518  if(CellZmax >6130.0039) CellZmax=6130.0039;
519  } // IF
520  else if(CellEta < 0){
521  if(CellZmin <-6120.0018) CellZmin=-6120.0018;
522  if(CellZmax >-3564.5006) CellZmax=-3564.5006;
523  } // ELSE IF
524  } // IF
525  if(SampleID == 20){
526  CellRmin = REBDmin;
527  CellRmax = REBDmax;
528  if(CellEta > 0){
529  if(CellZmin <3574.5027) CellZmin=3574.4978;
530  if(CellZmax >6130.0039) CellZmax=6130.0039;
531  } // IF
532  else if(CellEta < 0){
533  if(CellZmin <-6120.0018) CellZmin=-6120.0018;
534  if(CellZmax >-3564.5006) CellZmax=-3564.5006;
535  } // ELSE IF
536  } // IF
537 
538  // CALCULATE POINTS OF INTERSECTION
539  // INTERSECTIONS R PLANES
540  double Radius(CellRmin);
541 
542  double x0int(exit->position().x()), x1int(entrance->position().x()),
543  y0int(exit->position().y()), y1int(entrance->position().y()),
544  z0int(exit->position().z()), z1int(entrance->position().z());
545  double S((y1int-y0int)/(x1int-x0int));
546  double a(1+S*S), b(2*S*y0int-2*S*S*x0int), c(y0int*y0int-Radius*Radius+S*S*x0int*x0int-2*y0int*S*x0int);
547  double x1((-b+sqrt(b*b-4*a*c))/(2*a)), x2((-b-sqrt(b*b-4*a*c))/(2*a));
548  double y1(y0int+S*(x1-x0int)), y2(y0int+S*(x2-x0int));
549  double S1 = ((z1int-z0int)/(x1int-x0int));//, R1(sqrt(x1*x1+y1*y1)), R2(sqrt(x2*x2+y2*y2));
550  double z1(z0int+S1*(x1-x0int)), z2(z0int+S1*(x2-x0int));
551 
552  X = x1;
553  Y = y1;
554  Z = z1;
555 
556  if( ((x1-x0int)*(x1-x0int)+(y1-y0int)*(y1-y0int)+(z1-z0int)*(z1-z0int)) >
557  ((x2-x0int)*(x2-x0int)+(y2-y0int)*(y2-y0int)+(z2-z0int)*(z2-z0int)) ){
558  X=x2;
559  Y=y2;
560  Z=z2;
561  } // IF
562 
563  Phi = acos(X/sqrt(X*X+Y*Y));
564  if(Y <= 0) Phi = -Phi;
565  R = CellRmin;
566 
567  if(Z>=CellZmin && Z<=CellZmax && Phi>=CellPhimin && Phi<=CellPhimax){
568  CellXimp[Np]=X;
569  CellYimp[Np]=Y;
570  CellZimp[Np]=Z;
571  Np=Np+1;
572 
573  } // IF
574 
575  Radius = CellRmax;
576 
577  c = y0int*y0int-Radius*Radius+S*S*x0int*x0int-2*y0int*S*x0int;
578  x1 = ((-b+sqrt(b*b-4*a*c))/(2*a));
579  x2 = ((-b-sqrt(b*b-4*a*c))/(2*a));
580  y1 = (y0int+S*(x1-x0int));
581  y2 = (y0int+S*(x2-x0int));
582  z1 = (z0int+S1*(x1-x0int));
583  z2 = (z0int+S1*(x2-x0int));
584  S1 = ((z1int-z0int)/(x1int-x0int));
585 
586  X = x1;
587  Y = y1;
588  Z = z1;
589 
590  if( ((x1-x0int)*(x1-x0int)+(y1-y0int)*(y1-y0int)+(z1-z0int)*(z1-z0int)) >
591  ((x2-x0int)*(x2-x0int)+(y2-y0int)*(y2-y0int)+(z2-z0int)*(z2-z0int)) ){
592  X = x2;
593  Y = y2;
594  Z = z2;
595  } // IF
596 
597  Phi=std::acos(X/sqrt(X*X+Y*Y));
598  if (Y <= 0) Phi=-Phi;
599  R=CellRmax;
600 
601  if(Z>=CellZmin && Z<=CellZmax && Phi>=CellPhimin && Phi<=CellPhimax){
602  CellXimp[Np]=X; CellYimp[Np]=Y; CellZimp[Np]=Z;
603  Np=Np+1;
604 
605  } // IF
606 
607  // INTERSECTIONS Z PLANES
608  if(Np < 2){
609  double Sxz = (Layer2X-Layer1X)/(Layer2Z-Layer1Z);
610  double Syz = (Layer2Y-Layer1Y)/(Layer2Z-Layer1Z);
611  Z = CellZmin;
612  X = Layer1X+Sxz*(Z-Layer1Z);
613  Y = Layer1Y+Syz*(Z-Layer1Z);
614  R = sqrt(X*X+Y*Y);
615  Phi = std::acos(X/R);
616  if(Y <= 0) Phi=-Phi;
617  if(R>=CellRmin && R<=CellRmax && Phi>=CellPhimin && Phi<=CellPhimax){
618  CellXimp[Np]=X; CellYimp[Np]=Y; CellZimp[Np]=Z;
619  Np=Np+1;
620 
621  } // IF
622  } // IF
623 
624  if(Np < 2){
625  double Sxz = (Layer2X-Layer1X)/(Layer2Z-Layer1Z);
626  double Syz = (Layer2Y-Layer1Y)/(Layer2Z-Layer1Z);
627  Z = CellZmax;
628  X = Layer1X+Sxz*(Z-Layer1Z);
629  Y = Layer1Y+Syz*(Z-Layer1Z);
630  R = sqrt(X*X+Y*Y);
631  Phi = std::acos(X/R);
632  if(Y <= 0) Phi=-Phi;
633  if(R>=CellRmin && R<=CellRmax && Phi>=CellPhimin && Phi<=CellPhimax){
634  CellXimp[Np]=X; CellYimp[Np]=Y; CellZimp[Np]=Z;
635  Np=Np+1;
636 
637  } // IF
638  } // IF
639 
640  // INTERSECTIONS PHI PLANES
641  if(Np < 2){
642  double Sxy=(Layer2X-Layer1X)/(Layer2Y-Layer1Y);
643  double Sxz=(Layer2X-Layer1X)/(Layer2Z-Layer1Z);
644  X = (Layer1X-Sxy*Layer1Y)/(1-Sxy*tan(CellPhimin));
645  Y = X*std::tan(CellPhimin);
646  Z = Layer1Z+(1/Sxz)*(X-Layer1X);
647  R = sqrt(X*X+Y*Y);
648  Phi = std::acos(X/R);
649  if(Y <= 0) Phi=-Phi;
650  DeltaPhi=fabs(Phi-CellPhimin);
651  if(DeltaPhi > 3.141593) DeltaPhi=fabs(Phi+CellPhimin);
652  if(R>=CellRmin && R<=CellRmax && Z>=CellZmin && Z<=CellZmax && DeltaPhi<0.0001){
653  CellXimp[Np]=X; CellYimp[Np]=Y; CellZimp[Np]=Z;
654  Np=Np+1;
655  } // IF
656  } // IF
657  if(Np < 2){
658  double Sxy=(Layer2X-Layer1X)/(Layer2Y-Layer1Y);
659  double Sxz=(Layer2X-Layer1X)/(Layer2Z-Layer1Z);
660  X = (Layer1X-Sxy*Layer1Y)/(1-Sxy*tan(CellPhimax));
661  Y = X*std::tan(CellPhimax);
662  Z = Layer1Z+(1/Sxz)*(X-Layer1X);
663  R = sqrt(X*X+Y*Y);
664  Phi=acos(X/R);
665  if(Y <= 0) Phi=-Phi;
666  DeltaPhi=fabs(Phi-CellPhimax);
667  if(DeltaPhi > 3.141593) DeltaPhi=fabs(Phi+CellPhimax);
668  if(R>=CellRmin && R<=CellRmax && Z>=CellZmin && Z<=CellZmax && DeltaPhi<0.0001){
669  CellXimp[Np]=X; CellYimp[Np]=Y; CellZimp[Np]=Z;
670  Np=Np+1;
671  } // IF
672  } // IF
673 
674  // CALCULATE PATH IF TWO INTERSECTIONS WERE FOUND
675  if(Np == 2){
676 
677  pathl += sqrt( (CellXimp[0]-CellXimp[1])*(CellXimp[0]-CellXimp[1]) +
678  (CellYimp[0]-CellYimp[1])*(CellYimp[0]-CellYimp[1]) +
679  (CellZimp[0]-CellZimp[1])*(CellZimp[0]-CellZimp[1]) );
680  } // IF
681  } // IF
682  if(SampleID == 13 && lBC == 0) ++lBC;
683  else compute = false;
684  } // WHILE (FOR LBBC LAYER)
685 
686  return pathl;
687 } // TrackTools::getPath
688 
689 //=====================================================
690 int TrackTools::retrieveIndex(int sampling, float eta){
691 //====================================================
692  // STORE ETA MAP
693  float etamap[81] = { -0.95,-0.85,-0.75,-0.65,-0.55,-0.45,-0.35,-0.25,-0.15,-0.05, // CELLS A-10 TO A-1 (SAMPLING 12) INDICES 0:9
694  0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75, 0.85, 0.95, // CELLS A1 TO A10 (SAMPLING 12) INDICES 10:19
695  -0.85,-0.75,-0.65,-0.55,-0.45,-0.35,-0.25,-0.15,-0.05, // CELLS BC-9 TO BC-1 (SAMPLING 13) INDICES 20:28
696  0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75, 0.85, // CELLS BC1 TO BC9 (SAMPLING 13) INDICES 29:37
697  -0.60,-0.40,-0.20, // CELLS D-3 TO D-1 (SAMPLING 14) INDICES 38:40
698  0.00, 0.20, 0.40, 0.60, // CELLS D0 TO D3 (SAMPLING 14) INDICES 41:44
699  -0.956279,0.9583722, // CELLS C-10 TO C10 (SAMPLING 15) INDICES 45:46
700  -0.855940,0.8579205, // CELLS D-4 TO D4 (SAMPLING 16) INDICES 47:48
701  -1.507772,-1.307385,-1.156978,-1.056676, // CELLS E-4 TO E-1 (SAMPLING 17) INDICES 49:52
702  1.0589020,1.1593041,1.3098471,1.5103633, // CELLS E1 TO E4 (SAMPLING 17) INDICES 53:56
703  -1.554988,-1.455460,-1.355965,-1.256501,-1.157065, // CELLS A-16 TO A-12 (SAMPLING 18) INDICES 57:61
704  1.1594202,1.258668,1.3579534,1.4572804,1.5566510, // CELLS A12 TO A16 (SAMPLING 18) INDICES 62:66
705  -1.454651,-1.355081,-1.255538,-1.156018,-1.056519, // CELLS B-15 TO B-11 (SAMPLING 19) INDICES 67:71
706  1.0586925,1.1580252,1.2573844,1.3567756,1.4562022, // CELLS B11 TO B15 (SAMPLING 19) INDICES 72:76
707  -1.204743,-1.005559, // CELLS D-6 TO D-5 (SAMPLING 20) INDICES 77:78
708  1.0074122,1.2063241}; // CELLS D5 TO D6 (SAMPLING 20) INDICES 79:80
709  // CALCULATE INDEX
710  int index(999),i_start(999),i_end(999);
711  switch(sampling){
712  case 12: i_start = 0; i_end = 19; break;
713  case 13: i_start = 20; i_end = 37; break;
714  case 14: i_start = 38; i_end = 44; break;
715  case 15: i_start = 45; i_end = 46; break;
716  case 16: i_start = 47; i_end = 48; break;
717  case 17: i_start = 49; i_end = 56; break;
718  case 18: i_start = 57; i_end = 66; break;
719  case 19: i_start = 67; i_end = 76; break;
720  case 20: i_start = 77; i_end = 80; break;
721  default: break;
722  } // SWITCH
723 
724  if(i_start==999 || i_end==999) return -1;
725 
726  index = i_start;
727 
728  for(int i=i_start;i<=i_end;++i) index = fabs(eta-etamap[i]) <= fabs(eta-etamap[index]) ? i : index;
729  return index;
730 } // TRACKTOOLS::RETRIEVEINDEX
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
S1
struct TBPatternUnitContext S1
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
WriteCellNoiseToCool.icell
icell
Definition: WriteCellNoiseToCool.py:339
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
IDTPM::R
float R(const U &p)
Definition: TrackParametersHelper.h:101
beamspotman.cur
def cur
Definition: beamspotman.py:671
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
index
Definition: index.py:1
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Monitored::Z
@ Z
Definition: HistogramFillerUtils.h:24
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
TrackTools::getXYZEtaPhiPerSampling
std::vector< std::vector< double > > getXYZEtaPhiPerSampling(const TRACK *track)
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.cxx:179
TrackTools.h
TrackTools::getPath
double getPath(const CaloCell *cell, const Trk::TrackParameters *entrance, const Trk::TrackParameters *exit)
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.cxx:271
Trk::TrackParametersIdHelper::caloSample
CaloSampling::CaloSample caloSample(TrackParametersIdentifier id) const
CaloSample encoded in id, returns CaloSampling::Unknown if id is not valid
Definition: TrackParametersIdHelper.h:91
Phi
@ Phi
Definition: RPCdef.h:8
TrackTools::m_trackIsolationTool
ToolHandle< xAOD::ITrackIsolationTool > m_trackIsolationTool
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.h:79
x
#define x
Trk::TrackParametersIdHelper::isEntryToVolume
bool isEntryToVolume(TrackParametersIdentifier id) const
returns true if the id belongs to the volume entrance
Definition: TrackParametersIdHelper.h:81
JetTiledMap::S
@ S
Definition: TiledEtaPhiMap.h:44
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
Monitored::X
@ X
Definition: HistogramFillerUtils.h:24
CaloDetDescrElement::getSubCalo
CaloCell_ID::SUBCALO getSubCalo() const
cell subcalo
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:433
TrackTools::TrackTools
TrackTools(const std::string &type, const std::string &name, const IInterface *parent)
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.cxx:17
TrackTools::getXYZEtaPhiPerLayer
std::vector< std::vector< double > > getXYZEtaPhiPerLayer(const TRACK *track)
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.cxx:145
TrackTools::retrieveIndex
int retrieveIndex(int sampling, float eta)
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.cxx:690
GeoPrimitives.h
Trk::TrackParametersIdHelper
helper class to encode and decode a TrackParametersIdentifier
Definition: TrackParametersIdHelper.h:18
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
z
#define z
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
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCell_Base_ID::TILE
@ TILE
Definition: CaloCell_Base_ID.h:46
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
Trk::ParametersBase
Definition: ParametersBase.h:55
TrackTools::getTrackInCellSampling
std::unique_ptr< const Trk::TrackParameters > getTrackInCellSampling(const TRACK *track, CaloSampling::CaloSample sampling)
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.cxx:60
TrackTools::~TrackTools
~TrackTools()
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.cxx:35
calibdata.exit
exit
Definition: calibdata.py:236
TrackParametersIdentifier
unsigned int TrackParametersIdentifier
Definition: TrackParametersIdHelper.h:13
TrackTools::getCellsWithinConeAroundTrack
void getCellsWithinConeAroundTrack(const xAOD::TrackParticle *track, const CaloCellContainer *input, ConstDataVector< CaloCellContainer > *output, double cone, bool includelar)
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.cxx:200
merge.output
output
Definition: merge.py:17
Monitored::Y
@ Y
Definition: HistogramFillerUtils.h:24
python.TriggerEDMRun2.Samplings
Samplings
Definition: TriggerEDMRun2.py:76
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
TrackTools::initialize
StatusCode initialize()
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.cxx:40
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
TrackTools::m_caloCellAssociationTool
ToolHandle< Rec::IParticleCaloCellAssociationTool > m_caloCellAssociationTool
Tool to make the step-wise extrapolation.
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.h:76
DeMoScan.index
string index
Definition: DeMoScan.py:362
TrackTools::finalize
StatusCode finalize()
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.cxx:53
a
TList * a
Definition: liststreamerinfos.cxx:10
y
#define y
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloDetDescrElement::getSampling
CaloCell_ID::CaloSample getSampling() const
cell sampling
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:395
ConstDataVector< CaloCellContainer >
TrackTools::m_caloExtensionTool
ToolHandle< Trk::IParticleCaloExtensionTool > m_caloExtensionTool
Tool to make the step-wise extrapolation.
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.h:51
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrackTools::getXYZEtaPhiInCellSampling
std::vector< double > getXYZEtaPhiInCellSampling(const TRACK *track, const CaloCell *cell)
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.cxx:130
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
KinematicUtils::deltaR
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: D3PDMaker/TileD3PDMaker/src/ITrackTools.h:114
TrackTools::getPathInsideCell
double getPathInsideCell(const TRACK *track, const CaloCell *cell)
Definition: D3PDMaker/TileD3PDMaker/src/TrackTools.cxx:236
Trk::CaloExtension::caloLayerIntersections
const std::vector< CurvilinearParameters > & caloLayerIntersections() const
access to the intersections with the calorimeter layers.
Definition: CaloExtension.h:76
AthAlgTool
Definition: AthAlgTool.h:26
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:46
makeComparison.deltaR
float deltaR
Definition: makeComparison.py:36
python.compressB64.c
def c
Definition: compressB64.py:93