ATLAS Offline Software
TBTrackToCaloAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // TBTrackToCaloAlg.cxx
7 // Implementation file for class TBTrackToCaloAlg
9 
10 #include "TBTrackToCaloAlg.h"
12 
13 // Gaudi includes
14 #include "GaudiKernel/IToolSvc.h"
15 
16 // Tracking includes
18 //#include "TrkParameters/MeasuredPerigee.h"
19 //#include "TrkParameters/Perigee.h"
20 #include <vector>
22 #include "Particle/TrackParticle.h"
23 
24 //#include "TrackToCalo/ImpactInCalo.h"
25 
26 #include "CaloEvent/CaloCluster.h"
27 #include "CaloEvent/CaloClusterContainer.h"
29 #include "CaloUtils/CaloCellList.h"
30 #include "CaloEvent/CaloCell.h"
34 
35 //#include "ITrackToCalo/IExtrapolTrackToCaloTool.h"
36 //#include "RecoToolInterfaces/IExtrapolateToCaloTool.h"
37 #include "ImpactInCaloCollection.h"
38 #include "AthenaKernel/Units.h"
39 
40 using Athena::Units::GeV;
41 
42 
43 // Constructor with parameters:
45  ISvcLocator *pSvcLocator) :
46  AthAlgorithm(name,pSvcLocator),
47  m_TrackName("Tracks"),
48  m_tracks(0),
49  m_calodepth(nullptr)
50 {
51  // Get parameter values from jobOptions file
52  declareProperty("TrackName", m_TrackName);
53  declareProperty("TrackParticleName", m_TrackParticleName);
54  declareProperty("ClusterContainerName", m_cluster_container);
55  declareProperty("CaloCellContainerName", m_cell_container);
56  declareProperty("ImpactInCaloContainerName", m_ImpactInCalosOutputName);
57  declareProperty("TrackInputType", m_trkinput);
58  m_calo_id = 0;
59  m_calo_tb_coord = 0;
60  m_particle = 0;
61  m_toCalo = 0;
62 }
63 
64 // Initialize method:
66 {
67  ATH_MSG_DEBUG ( "TBTrackToCaloAlg::initialize()" );
68 
69  ATH_CHECK(detStore()->retrieve(m_calo_id,"CaloCell_ID"));
70 
71  IAlgTool* algTool = 0;
72 
73  StatusCode sc = toolSvc()->retrieveTool("ExtrapolTrackToCaloTool", algTool,this);
74  //m_toCalo=dynamic_cast<IExtrapolTrackToCaloTool*>(algTool);
75  //m_toCalo=dynamic_cast<IExtrapolateToCaloTool*>(algTool);
76  m_toCalo=dynamic_cast<TBExtrapolTrackToCaloTool*>(algTool);
77  if(sc.isFailure() || !m_toCalo) {
78  ATH_MSG_ERROR ( "Cannot get ExtrapolTrackToCaloTool" );
79  return StatusCode::FAILURE;
80  }
81 
82  IAlgTool* tool = 0;
83  ATH_CHECK( toolSvc()->retrieveTool("TBCaloCoordinate", tool) );
84  m_calo_tb_coord = dynamic_cast<ICaloCoordinateTool*>(tool);
85 
86  // retrived via the Extrapolator to make sure that jobOpt setting is consistent.
88  if (!m_calodepth) {
89  ATH_MSG_ERROR ( "Cannot get CaloDepthTool" );
90  return StatusCode::FAILURE;
91  }
92 
93  ATH_MSG_INFO ( "TBTrackToCaloAlg initialisation OK" );
94  return StatusCode::SUCCESS;
95 }
96 
97 // Execute method:
99 {
100  ATH_MSG_DEBUG ( "TBTrackToCaloAlg::execute()" );
101 
102  // just a simple test ( trick to trigger position reading )
103  // PrintBeamPosition();
104 
105  // Create the impacts :
106  /*found_a_track =*/ CreateTrkImpactInCalo();
107 
108  // Example 1 : you want to read them and compare to clusters
109 
110  /*
111  if (found_a_track) {
112  PrintImpact();
113  //CompareImpactWithCluster();
114  }
115  */
116 
117  // Example 2 : you want to know the list of cells crossed by the track
118  // bool found_cells = PrintCellsCrossed();
120  return StatusCode::SUCCESS;
121 }
122 
123 // Finalize method:
125 {
126  ATH_MSG_DEBUG ( "TBTrackToCaloAlg::finalize()" );
127 
128  return StatusCode::SUCCESS;
129 }
130 
131 
132 // Loop on Tracks/TrackParticles and create ImpactInCaloCollection
134 {
135  bool got_a_track = false;
136 
137  ATH_MSG_DEBUG ( "TBTrackToCaloAlg::CreateTrkImpactInCalo()" );
138 
139  //create and record new ImpactInCalo container
140  ImpactInCaloCollection* outputContainer = new ImpactInCaloCollection();
141  StatusCode sc=evtStore()->record(outputContainer,m_ImpactInCalosOutputName,false); //"false" indicates it can't be modified by another algorithm
142  if(sc != StatusCode::SUCCESS){
143  ATH_MSG_ERROR ( " Could not record ImpactInCaloCollection"
145  return got_a_track ;
146  }
147 
148  m_particle = 0;
149  m_tracks = 0;
150 
151  if( m_trkinput == "TrackParticleCandidates")
152  {
153  if (m_TrackParticleName == "") {
154  ATH_MSG_ERROR ("m_TrackParticleName not set" );
155  return true;
156  }
157 
158  sc = evtStore()->retrieve(m_particle, m_TrackParticleName);
159 
160  if (sc.isFailure()) ATH_MSG_ERROR ("TrackParticle not found: will only play with calo " << m_TrackParticleName );
161  else {
162  ATH_MSG_DEBUG ("TrackParticle found in StoreGate" );
163  for (const Rec::TrackParticle* tp : *m_particle) {
164  const Trk::Track* tr = tp->originalTrack();
165 
166  ImpactInCalo * imp = GetImpactsInCalo(tr, got_a_track);
167  if(imp) outputContainer->push_back(imp);
168  else ATH_MSG_DEBUG (" ImpactInCalo pointer not valid for this track");
169  }
170  }
171  }
172 
173  else
174  {
175  if (m_TrackName == "") {
176  ATH_MSG_ERROR ("m_TrackName not set" );
177  return true;
178  }
179 
180  sc = evtStore()->retrieve(m_tracks, m_TrackName);
181 
182  if (sc.isFailure()) ATH_MSG_ERROR ("Tracks not found: will only play with calo " << m_TrackName );
183  else {
184  ATH_MSG_DEBUG ("Tracks found in StoreGate" );
185  for (const Trk::Track* tr : *m_tracks) {
186  ImpactInCalo * imp = GetImpactsInCalo(tr, got_a_track);
187  if(imp) outputContainer->push_back(imp);
188  else ATH_MSG_DEBUG (" ImpactInCalo pointer not valid for this track");
189  }
190  }
191  }
192 
193  return got_a_track;
194 }
195 
197 {
198  Amg::Vector3D* pt_calo_ctb = new Amg::Vector3D;
199  Amg::Vector3D* pt_calo_local = new Amg::Vector3D;
200 
202  const CaloDetDescrManager* caloDDMgr = *caloMgrHandle;
203 
204  double trketa = 0.;
205  // take the last measured point to find out if I am in barrel or endcap :
206  const DataVector <const Trk::TrackParameters>* paramvec = track->trackParameters();
207  if (paramvec) {
208  for (const Trk::TrackParameters* params : *paramvec)
209  trketa = params->eta();
210  }
211  else
212  ATH_MSG_ERROR ( " No track parameters for this track ??? do nothing " );
213 
214  double distbar = 0.;
215  double distec = 0.;
216  double offset = 0.;
217  double trketa_at = 0.;
218  double trkphi_at = 0.;
219  bool result = false;
221 
222  // PreSampler :
223  double x_ctb_0 = 0;
224  double y_ctb_0 = 0;
225  double z_ctb_0 = 0;
226  double etaCaloLocal_0 = 0;
227  double phiCaloLocal_0 = 0;
228  double trketa_at_0 = 0.;
229  double trkphi_at_0 = 0.;
230  // Strip :
231  double x_ctb_1 = 0;
232  double y_ctb_1 = 0;
233  double z_ctb_1 = 0;
234  double etaCaloLocal_1 = 0;
235  double phiCaloLocal_1 = 0;
236  double trketa_at_1 = 0.;
237  double trkphi_at_1 = 0.;
238  // Middle :
239  double x_ctb_2 = 0;
240  double y_ctb_2 = 0;
241  double z_ctb_2 = 0;
242  double etaCaloLocal_2 = 0;
243  double phiCaloLocal_2 = 0;
244  double trketa_at_2 = 0.;
245  double trkphi_at_2 = 0.;
246  // Back :
247  double x_ctb_3 = 0;
248  double y_ctb_3 = 0;
249  double z_ctb_3 = 0;
250  double etaCaloLocal_3 = 0;
251  double phiCaloLocal_3 = 0;
252  double trketa_at_3 = 0.;
253  double trkphi_at_3 = 0.;
254  // Tiles :
255  double x_ctb_tile = 0;
256  double y_ctb_tile = 0;
257  double z_ctb_tile = 0;
258  double etaCaloLocal_tile = 0;
259  double phiCaloLocal_tile = 0;
260  double trketa_at_tile = 0.;
261  double trkphi_at_tile = 0.;
262 
263  if (paramvec) {
264 
265  // PS :
266  distbar = CaloDepthTool::deta(CaloCell_ID::PreSamplerB,trketa,caloDDMgr);
267  distec = CaloDepthTool::deta(CaloCell_ID::PreSamplerE,trketa,caloDDMgr);
268 
269  ATH_MSG_DEBUG ( " TrackTo ...PS : for eta= " << trketa << " dist to Barrel =" << distbar
270  << " to endcap =" << distec );
271  if (distbar < 0 ) sample = CaloCell_ID::PreSamplerB;
272  else if (distec < 0 ) sample = CaloCell_ID::PreSamplerE;
273  else if ( distbar < distec) sample = CaloCell_ID::PreSamplerB;
275  ATH_MSG_DEBUG ( " => will shoot in sample " << sample );
276 
278  pt_calo_ctb,pt_calo_local,trketa_at,trkphi_at);
279 
280  if (result) {
281  got_a_track=true;
282  x_ctb_0 = pt_calo_ctb->x();
283  y_ctb_0 = pt_calo_ctb->y();
284  z_ctb_0 = pt_calo_ctb->z();
285  etaCaloLocal_0 = pt_calo_local->eta();
286  phiCaloLocal_0 = pt_calo_local->phi();
287  trketa_at_0 = trketa_at;
288  trkphi_at_0 = trkphi_at;
289 
290  ATH_MSG_DEBUG ( "Extrapolation to PreSamplerB gives: "
291  << " etaCaloLocal=" << pt_calo_local->eta()
292  << " phiCaloLocal=" << pt_calo_local->phi() );
293  }
294 
295  // strip :
296  distbar = CaloDepthTool::deta(CaloCell_ID::EMB1,trketa,caloDDMgr);
297  distec = CaloDepthTool::deta(CaloCell_ID::EME1,trketa,caloDDMgr);
298 
299  ATH_MSG_DEBUG ( " TrackTo ...Strip : for eta= " << trketa << " dist to Barrel =" << distbar
300  << " to endcap =" << distec );
301  if (distbar < 0 ) sample = CaloCell_ID::EMB1;
302  else if (distec < 0 ) sample = CaloCell_ID::EME1;
303  else if ( distbar < distec) sample = CaloCell_ID::EMB1;
304  else sample = CaloCell_ID::EME1;
305  ATH_MSG_DEBUG ( " => will shoot in sample " << sample );
306 
308  pt_calo_ctb,pt_calo_local,trketa_at,trkphi_at);
309 
310  if (result) {
311  got_a_track=true;
312  x_ctb_1 = pt_calo_ctb->x();
313  y_ctb_1 = pt_calo_ctb->y();
314  z_ctb_1 = pt_calo_ctb->z();
315  etaCaloLocal_1 = pt_calo_local->eta();
316  phiCaloLocal_1 = pt_calo_local->phi();
317  trketa_at_1 = trketa_at;
318  trkphi_at_1 = trkphi_at;
319 
320  ATH_MSG_DEBUG ( "Extrapolation to EMB1 gives: "
321  << " etaCaloLocal=" << pt_calo_local->eta()
322  << " phiCaloLocal=" << pt_calo_local->phi() );
323  }
324 
325 
326  // middle :
327  distbar = CaloDepthTool::deta(CaloCell_ID::EMB2,trketa,caloDDMgr);
328  distec = CaloDepthTool::deta(CaloCell_ID::EME2,trketa,caloDDMgr);
329 
330  ATH_MSG_DEBUG ( " TrackTo ...Middle : for eta= " << trketa << " dist to Barrel =" << distbar
331  << " to endcap =" << distec );
332  if (distbar < 0 ) sample = CaloCell_ID::EMB2;
333  else if (distec < 0 ) sample = CaloCell_ID::EME2;
334  else if ( distbar < distec) sample = CaloCell_ID::EMB2;
335  else sample = CaloCell_ID::EME2;
336  ATH_MSG_DEBUG ( " => will shoot in sample " << sample );
337 
339  pt_calo_ctb,pt_calo_local,trketa_at,trkphi_at);
340 
341  if (result) {
342  got_a_track=true;
343  x_ctb_2 = pt_calo_ctb->x();
344  y_ctb_2 = pt_calo_ctb->y();
345  z_ctb_2 = pt_calo_ctb->z();
346  etaCaloLocal_2 = pt_calo_local->eta();
347  phiCaloLocal_2 = pt_calo_local->phi();
348  trketa_at_2 = trketa_at;
349  trkphi_at_2 = trkphi_at;
350 
351  ATH_MSG_DEBUG ( "Extrapolation to EMB2 gives: "
352  << " etaCaloLocal=" << pt_calo_local->eta()
353  << " phiCaloLocal=" << pt_calo_local->phi() );
354  }
355 
356  // Back :
357  //
358  // there is a real gap between 1.35 (end of EMB3) and 1.5 (start of EMEC3)
359  // => for TrackToCalo chooses the closest. One could choose to stay in
360  // barrel as long as not in endcap
361  // In both cases, m_calodepth will see that you are outside the accpetance and
362  // will use the backup solution (egparametrisation right now, rel 10.0.2).
363  //
364 
365  distbar = CaloDepthTool::deta(CaloCell_ID::EMB3,trketa,caloDDMgr);
366  distec = CaloDepthTool::deta(CaloCell_ID::EME3,trketa,caloDDMgr);
367 
368  ATH_MSG_DEBUG ( " TrackTo ...Back : for eta= " << trketa << " dist to Barrel =" << distbar
369  << " to endcap =" << distec );
370  if (distbar < 0 ) sample = CaloCell_ID::EMB3;
371  else if (distec < 0 ) sample = CaloCell_ID::EME3;
372  else if ( distbar < distec) sample = CaloCell_ID::EMB3;
373  else sample = CaloCell_ID::EME3;
374  ATH_MSG_DEBUG ( " => will shoot in sample " << sample );
375 
377  pt_calo_ctb,pt_calo_local,trketa_at,trkphi_at);
378 
379  if (result) {
380  got_a_track=true;
381  x_ctb_3 = pt_calo_ctb->x();
382  y_ctb_3 = pt_calo_ctb->y();
383  z_ctb_3 = pt_calo_ctb->z();
384  etaCaloLocal_3 = pt_calo_local->eta();
385  phiCaloLocal_3 = pt_calo_local->phi();
386  trketa_at_3 = trketa_at;
387  trkphi_at_3 = trkphi_at;
388 
389  ATH_MSG_DEBUG ( "Extrapolation to EMB3 gives: "
390  << " etaCaloLocal=" << pt_calo_local->eta()
391  << " phiCaloLocal=" << pt_calo_local->phi() );
392  }
393 
394  // Tile or HEC0 :
395  distbar = CaloDepthTool::deta(CaloCell_ID::TileBar0,trketa,caloDDMgr);
396  distec = CaloDepthTool::deta(CaloCell_ID::HEC0,trketa,caloDDMgr);
397 
398  ATH_MSG_DEBUG ( " TrackTo ...Tile : for eta= " << trketa << " dist to Barrel =" << distbar
399  << " to endcap =" << distec );
400  if (distbar < 0 ) sample = CaloCell_ID::TileBar0;
401  else if (distec < 0 ) sample = CaloCell_ID::HEC0;
402  else if ( distbar > distec && distec < 10. ) sample = CaloCell_ID::HEC0;
404  ATH_MSG_DEBUG ( " => will shoot in sample " << sample );
405 
407  pt_calo_ctb,pt_calo_local,trketa_at,trkphi_at);
408 
409  if (result) {
410  got_a_track=true;
411  x_ctb_tile = pt_calo_ctb->x();
412  y_ctb_tile = pt_calo_ctb->y();
413  z_ctb_tile = pt_calo_ctb->z();
414  etaCaloLocal_tile = pt_calo_local->eta();
415  phiCaloLocal_tile = pt_calo_local->phi();
416  trketa_at_tile = trketa_at;
417  trkphi_at_tile = trkphi_at;
418 
419  ATH_MSG_DEBUG ( "Extrapolation to TileBar0 gives: "
420  << " etaCaloLocal=" << pt_calo_local->eta()
421  << " phiCaloLocal=" << pt_calo_local->phi() );
422  }
423  }
424 
425  ImpactInCalo * imp= new ImpactInCalo(x_ctb_0, y_ctb_0, z_ctb_0, etaCaloLocal_0, phiCaloLocal_0, trketa_at_0, trkphi_at_0,
426  x_ctb_1, y_ctb_1, z_ctb_1, etaCaloLocal_1, phiCaloLocal_1, trketa_at_1, trkphi_at_1,
427  x_ctb_2, y_ctb_2, z_ctb_2, etaCaloLocal_2, phiCaloLocal_2, trketa_at_2, trkphi_at_2,
428  x_ctb_3, y_ctb_3, z_ctb_3, etaCaloLocal_3, phiCaloLocal_3, trketa_at_3, trkphi_at_3,
429  x_ctb_tile, y_ctb_tile, z_ctb_tile, etaCaloLocal_tile, phiCaloLocal_tile, trketa_at_tile, trkphi_at_tile);
430 
431  if(pt_calo_ctb) delete pt_calo_ctb;
432  if(pt_calo_local) delete pt_calo_local;
433 
434  return imp;
435 }
436 
437 
438 
439 
440 // Retreive ImpactInCaloCollection and compare to CaloClusters
442 {
443  StatusCode sc1, sc2;
444 
445  ATH_MSG_DEBUG ( "TBTrackToCaloAlg::CompareImpactWithCluster()" );
446 
447  // loop on clusters
448 
449  const CaloClusterContainer* cluster_container = nullptr;
450  sc1=evtStore()->retrieve(cluster_container,m_cluster_container);
451 
452  const ImpactInCaloCollection* impact_collection;
453  sc2=evtStore()->retrieve(impact_collection,m_ImpactInCalosOutputName);
454 
455  if(sc1 == StatusCode::SUCCESS && sc2 == StatusCode::SUCCESS ){
456 
457  typedef ImpactInCaloCollection::const_iterator impact_iterator;
458  impact_iterator f_imp = impact_collection->begin();
459  impact_iterator l_imp = impact_collection->end();
460 
461  for (const CaloCluster* cluster : *cluster_container) {
462  double hecluster = cluster->energy()/GeV;
463  double heta = cluster->eta();
464  double hphi = cluster->phi();
465 
466  ATH_MSG_INFO ( "Found a cluster : E= " << hecluster
467  << "(GeV), etaCaloLocal=" << heta
468  << ", phiCaloLocal=" << hphi );
469 
470  for ( ; f_imp!=l_imp; ++f_imp){
471  const ImpactInCalo* impact = (*f_imp);
472 
473  ATH_MSG_INFO
474  ( "==> Comparison between cluster and impact in Middle : deta="
475  << heta-impact->etaCaloLocal_2()
476  << " , dphi=" << hphi-impact->phiCaloLocal_2() );
477  }
478  }
479  }
480  else {
481  if (sc1 != StatusCode::SUCCESS)
482  ATH_MSG_ERROR ("Clusters not found"
483  << m_cluster_container );
484  if (sc2 != StatusCode::SUCCESS)
485  ATH_MSG_ERROR ("ImpactInCalos not found"
487  }
488 }
489 
490 // Retreive ImpactInCaloCollection and print content
492 {
493  StatusCode sc;
494 
495  ATH_MSG_INFO ( " Method PrintImpacts : " );
496 
497  ATH_MSG_INFO ( " " );
498  ATH_MSG_INFO ( " Start with Impacts : " );
499 
500  const ImpactInCaloCollection* impact_collection;
501  sc=evtStore()->retrieve(impact_collection,m_ImpactInCalosOutputName);
502 
503  if(sc == StatusCode::SUCCESS ){
504 
505  for (const ImpactInCalo* impact : *impact_collection) {
506  const double impcosPhi = std::cos(impact->phiCaloLocal_1());
507  const double impeta = impact->etaCaloLocal_1();
508 
509  ATH_MSG_INFO ( "Found an impact in strips : parameters are eta = " << impeta
510  << " cosPhi = " << impcosPhi );
511 
512  //impact->print();
513  }
514  }
515  else {
516  ATH_MSG_ERROR ("ImpactInCalos not found"
518  }
519 
520  if (m_tracks) {
521 
522  ATH_MSG_INFO ( " " );
523  ATH_MSG_INFO (" Now loop on Trk::Track collection " );
524  ATH_MSG_INFO ( " " );
525 
526  for (const Trk::Track* tr : *m_tracks) {
527  const Trk::Perigee *aMeasPer=
528  dynamic_cast<const Trk::Perigee*>(tr->perigeeParameters());
529  if (aMeasPer==0){
530  ATH_MSG_ERROR ( "Could not get Trk::MeasuredPerigee" );
531  }
532  else {
533 
534  const double trkcosPhi = cos(aMeasPer->parameters()[Trk::phi]);
535  const double trketa = aMeasPer->eta();
536 
537  ATH_MSG_INFO ( "Found a Trk::Track : parameters are eta = " << trketa
538  << " cosPhi = " << trkcosPhi );
539  }
540  }
541  }
542 
543  if (m_particle) {
544 
545  ATH_MSG_INFO ( " " );
546  ATH_MSG_INFO (" Now loop on Trk::TrackParticle collection " );
547  ATH_MSG_INFO ( " " );
548 
550  itr != m_particle->end(); ++itr )
551  {
552  const Trk::Perigee *aMeasPer=
553  dynamic_cast<const Trk::Perigee*>(((*itr)->originalTrack())->perigeeParameters());
554  if (aMeasPer==0){
555  ATH_MSG_ERROR ( "Could not get TrkParticle::MeasuredPerigee" );
556  }
557  else {
558 
559  const double partcosPhi = cos(aMeasPer->parameters()[Trk::phi]);
560  const double parteta = aMeasPer->eta();
561 
562  ATH_MSG_INFO ( "Found a trackparticle : parameters are eta = " << parteta
563  << " cosPhi = " << partcosPhi );
564  }
565  }
566  }
567 }
568 
569 // List of cells crossed by Trk::Tracks in CaloSample
570 // ( neta and nphi are the total window width, e.g .5x5 )
571 CaloCellList*
573  const CaloCell_ID::CaloSample sam,
574  int neta, int nphi)
575 {
576  CaloCellList* my_list = 0;
577 
578  // Retreive CaloCell's from StoreGate :
579 
580  const CaloCellContainer* cell_container;
581  StatusCode sc=evtStore()->retrieve(cell_container,m_cell_container);
582  if ( sc != StatusCode::SUCCESS ) return 0;
583 
585  const CaloDetDescrManager* caloDDMgr = *caloMgrHandle;
586 
587  // Where is the track shooting ?
588  double offset = 0.;
589  double trketa_at = 0.;
590  double trkphi_at = 0.;
591  Amg::Vector3D* pt_ctb = new Amg::Vector3D();
592  Amg::Vector3D* pt_local = new Amg::Vector3D();
593  bool result = m_toCalo->
594  TrackSeenByCalo(trk,sam,offset,pt_ctb,pt_local,trketa_at,trkphi_at);
595 
596  if (!result) {
597  delete pt_ctb;
598  delete pt_local;
599  return 0;
600  }
601 
602  double eta = pt_local->eta();
603  double phi = pt_local->phi();
604 
605  // CaloCellList needs both enums: subCalo and CaloSample
606  CaloCell_ID::SUBCALO subcalo;
607  bool barrel;
608  int sampling_or_module;
609  CaloDetDescrManager::decode_sample (subcalo, barrel, sampling_or_module, sam);
610 
611  // Get the corresponding grannularities : needs to know where you are
612  // the easiest is to look for the CaloDetDescrElement
613  const CaloDetDescrElement* dde =
614  caloDDMgr->get_element(subcalo,sampling_or_module,barrel,eta,phi);
615 
616  double deta = int(neta/2)*dde->deta();
617  double dphi = int(nphi/2)*dde->dphi();
618 
619  //std::cout << "zone is ..." << eta << " " << phi << " "
620  // << deta << " " << dphi << " " << std::endl;
621  // Construct the list :
622  my_list = new CaloCellList(caloDDMgr, cell_container,subcalo);
623  my_list->select(eta,phi,deta,dphi, (int) sam);
624 
625  // cleanup
626  delete pt_ctb;
627  delete pt_local;
628 
629  return my_list ;
630 }
631 
633 {
634 
635  // Get the messaging service, print where you are
636  ATH_MSG_INFO ( "TBTrackToCaloAlg::PrintCellsCrossed()" );
637 
638  // Here we are :
640  int neta = 5;
641  int nphi = 5;
642 
643  // get tracks from TDS
644  if (m_TrackName == "") {
645  ATH_MSG_ERROR ("m_TrackName not set" );
646  return true;
647  }
648 
649  StatusCode sc = evtStore()->retrieve(m_tracks, m_TrackName);
650  if (sc.isFailure()){
651  ATH_MSG_ERROR ("Tracks not found: will only play with calo "
652  << m_TrackName );
653  }
654  else{
655  ATH_MSG_DEBUG ("Tracks found in StoreGate" );
656 
657  for (const Trk::Track* tr : *m_tracks) {
658 
659  const Trk::Perigee *aMeasPer=
660  dynamic_cast<const Trk::Perigee*>(tr->perigeeParameters());
661  if (aMeasPer==0){
662  ATH_MSG_ERROR ( "Could not get Trk::MeasuredPerigee" );
663  }
664  else {
665  double d0 = aMeasPer->parameters()[Trk::d0];
666  double z0 = aMeasPer->parameters()[Trk::z0];
667  double phi0 = aMeasPer->parameters()[Trk::phi0];
668  double theta = aMeasPer->parameters()[Trk::theta];
669  double qOverP = aMeasPer->parameters()[Trk::qOverP];
670  ATH_MSG_INFO ( " " );
671  ATH_MSG_INFO ( "Found a track: parameters are " << d0 << " "
672  << z0 << " " << phi0 << " " << theta << " " << qOverP );
673  }
674 
675  // Warning : if anything fails, CellsCrossedByTrack will
676  // simply return a null pointer
677  // if it works, it does a new CaloCellList
678  // ==> the client has to do the delete !!!!
679 
680  CaloCellList* my_list = CellsCrossedByTrack(tr, sam, neta, nphi);
681 
682  if (my_list) {
683 
684  for (const CaloCell* cell : *my_list)
685  ATH_MSG_INFO ( "found cell ! eta=" << cell->eta()
686  << " phi=" << cell->phi() << " energy=" << cell->energy() );
687 
688  delete my_list;
689 
690  }
691  else
692  ATH_MSG_ERROR (" :-( extrapolation did not work");
693  }
694  }
695 
696  return true;
697 }
698 
699 // A little check : where is the beam ?
701 {
702  // Get the messaging service, print where you are
703  ATH_MSG_INFO ( "TBTrackToCaloAlg::PrintBeamPosition()" );
704 
705  ATH_MSG_INFO ( "Just a check... beam direction in calo : " );
707  Amg::Vector3D beam (1.,0.,0.);
709 }
710 
CaloDetDescrElement::deta
float deta() const
cell deta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:356
TBTrackToCaloAlg::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: TBTrackToCaloAlg.h:132
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TBTrackToCaloAlg::m_ImpactInCalosOutputName
std::string m_ImpactInCalosOutputName
Definition: TBTrackToCaloAlg.h:124
TBTrackToCaloAlg.h
ImpactInCaloCollection
Definition: ImpactInCaloCollection.h:13
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TBTrackToCaloAlg::CompareImpactWithCluster
void CompareImpactWithCluster()
Definition: TBTrackToCaloAlg.cxx:441
CaloCellList
Definition: CaloCellList.h:40
get_generator_info.result
result
Definition: get_generator_info.py:21
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
TrackParameters.h
TrackParticle.h
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCellList::select
void select(double eta, double phi, double deta, double dphi)
Definition: CaloCellList.cxx:67
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TBExtrapolTrackToCaloTool::getCaloDepth
CaloDepthTool * getCaloDepth()
access to the private tool used to define the extrapolation depth, needed to play with delta-eta
Definition: TBExtrapolTrackToCaloTool.cxx:412
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CaloCellList.h
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
CaloClusterContainer
Storable container for CaloCluster.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloClusterContainer.h:37
ImpactInCalo
The ImpactInCalo collection is created by the TrackToCaloAlg algorithm, which loops on all Tracks of ...
Definition: ImpactInCalo.h:33
InDetAccessor::phi0
@ phi0
Definition: InDetAccessor.h:33
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
CaloDepthTool.h
Declaration of CaloDepthTool. Created by Claire Bourdarios, 25.10.2004.
TBTrackToCaloAlg::m_TrackName
std::string m_TrackName
Definition: TBTrackToCaloAlg.h:112
ImpactInCalo::etaCaloLocal_2
double etaCaloLocal_2() const
Definition: ImpactInCalo.h:107
ParticleTest.tp
tp
Definition: ParticleTest.py:25
CaloCell.h
Trk::z0
@ z0
Definition: ParamDefs.h:64
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
InDetAccessor::qOverP
@ qOverP
perigee
Definition: InDetAccessor.h:35
TBTrackToCaloAlg::m_TrackParticleName
std::string m_TrackParticleName
Definition: TBTrackToCaloAlg.h:114
TBExtrapolTrackToCaloTool
This class takes a given TrkTrack, extrapolates it to the Calo and returns the variables needed to co...
Definition: TBExtrapolTrackToCaloTool.h:83
TBTrackToCaloAlg::PrintBeamPosition
void PrintBeamPosition()
Definition: TBTrackToCaloAlg.cxx:700
TBTrackToCaloAlg::m_toCalo
TBExtrapolTrackToCaloTool * m_toCalo
Definition: TBTrackToCaloAlg.h:125
TBExtrapolTrackToCaloTool::TrackSeenByCalo
bool TrackSeenByCalo(const Trk::Track *trk, const CaloCell_ID::CaloSample sample, const double offset, Amg::Vector3D *pt_ctb, Amg::Vector3D *pt_local)
The "do-it-all" method which combines the 3 steps.
Definition: TBExtrapolTrackToCaloTool.cxx:207
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
TBTrackToCaloAlg::m_trkinput
std::string m_trkinput
Definition: TBTrackToCaloAlg.h:116
TBTrackToCaloAlg::m_cell_container
std::string m_cell_container
Definition: TBTrackToCaloAlg.h:120
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
TBTrackToCaloAlg::m_calo_id
const CaloCell_ID * m_calo_id
Definition: TBTrackToCaloAlg.h:121
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
TBTrackToCaloAlg::m_calodepth
CaloDepthTool * m_calodepth
Definition: TBTrackToCaloAlg.h:126
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:113
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
TBTrackToCaloAlg::finalize
virtual StatusCode finalize() override
Definition: TBTrackToCaloAlg.cxx:124
CaloCell_ID_FCS::TileBar0
@ TileBar0
Definition: FastCaloSim_CaloCell_ID.h:31
Trk::theta
@ theta
Definition: ParamDefs.h:66
ICaloCoordinateTool::transform_ctb_to_calo
virtual Amg::Transform3D * transform_ctb_to_calo()=0
method accessing the transformations
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
TBTrackToCaloAlg::m_cluster_container
std::string m_cluster_container
Definition: TBTrackToCaloAlg.h:119
CaloCell_Base_ID::SUBCALO
SUBCALO
enumeration of sub calorimeters
Definition: CaloCell_Base_ID.h:46
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
CaloCluster
Principal data class for CaloCell clusters.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
CaloPhiRange.h
CaloPhiRange class declaration.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloDepthTool::deta
static double deta(const CaloCell_ID::SUBCALO subcalo, const int sampling_or_module, const bool barrel, const double eta, const CaloDetDescrManager *caloDD)
How far are you (in eta) from a given sample or - if you are in - how far are you from the edge ?
Definition: CaloDepthTool.cxx:142
Trk::ParametersBase
Definition: ParametersBase.h:55
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
TBTrackToCaloAlg::initialize
virtual StatusCode initialize() override
Definition: TBTrackToCaloAlg.cxx:65
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
ICaloCoordinateTool
This (clean) interface is implemented in the (rather dirty) ICaloCoordinateTool class,...
Definition: ICaloCoordinateTool.h:65
AthAlgorithm
Definition: AthAlgorithm.h:47
ImpactInCalo::phiCaloLocal_2
double phiCaloLocal_2() const
Definition: ImpactInCalo.h:108
jobOptions.beam
beam
Definition: jobOptions.SuperChic_ALP2.py:16
TBTrackToCaloAlg::PrintCellsCrossed
bool PrintCellsCrossed()
Definition: TBTrackToCaloAlg.cxx:632
ICaloCoordinateTool.h
ICaloCoordinateTool interface declaration 30.9.2004 Creation of the class TBCalocoordinate by claire....
TBTrackToCaloAlg::m_tracks
const TrackCollection * m_tracks
Definition: TBTrackToCaloAlg.h:113
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Trk::d0
@ d0
Definition: ParamDefs.h:63
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
Trk::perigeeParameters
@ perigeeParameters
Definition: MeasurementType.h:19
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
TBExtrapolTrackToCaloTool.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TBTrackToCaloAlg::CreateTrkImpactInCalo
bool CreateTrkImpactInCalo()
Definition: TBTrackToCaloAlg.cxx:133
TBTrackToCaloAlg::m_calo_tb_coord
ICaloCoordinateTool * m_calo_tb_coord
Definition: TBTrackToCaloAlg.h:130
Units.h
Wrapper to avoid constant divisions when using units.
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
Rec::TrackParticle
Definition: Reconstruction/Particle/Particle/TrackParticle.h:47
CaloCell_ID_FCS::HEC0
@ HEC0
Definition: FastCaloSim_CaloCell_ID.h:27
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
TBTrackToCaloAlg::PrintImpact
void PrintImpact()
Definition: TBTrackToCaloAlg.cxx:491
CaloDetDescrElement::dphi
float dphi() const
cell dphi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:358
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloCell_ID_FCS::PreSamplerE
@ PreSamplerE
Definition: FastCaloSim_CaloCell_ID.h:23
CaloCell_ID_FCS::PreSamplerB
@ PreSamplerB
Definition: FastCaloSim_CaloCell_ID.h:19
ICaloCoordinateTool::read_table_position
virtual void read_table_position()=0
clients who want the real position must call this
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
CaloDetDescrManager_Base::decode_sample
static void decode_sample(CaloCell_ID::SUBCALO &subCalo, bool &barrel, int &sampling_or_module, CaloCell_ID::CaloSample sample)
translate between the 2 ways to label a sub-detector:
Definition: CaloDetDescrManager.cxx:1468
DetectorZone::barrel
@ barrel
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
ImpactInCaloCollection.h
TBTrackToCaloAlg::execute
virtual StatusCode execute() override
Definition: TBTrackToCaloAlg.cxx:98
Trk::phi
@ phi
Definition: ParamDefs.h:75
TBTrackToCaloAlg::TBTrackToCaloAlg
TBTrackToCaloAlg()
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
TBTrackToCaloAlg::CellsCrossedByTrack
CaloCellList * CellsCrossedByTrack(const Trk::Track *trk, const CaloCell_ID::CaloSample sam, int neta, int nphi)
Definition: TBTrackToCaloAlg.cxx:572
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
Trk::phi0
@ phi0
Definition: ParamDefs.h:65
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
TBTrackToCaloAlg::m_particle
const Rec::TrackParticleContainer * m_particle
Definition: TBTrackToCaloAlg.h:115
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
TBTrackToCaloAlg::GetImpactsInCalo
ImpactInCalo * GetImpactsInCalo(const Trk::Track *track, bool &got_a_track)
Definition: TBTrackToCaloAlg.cxx:196
TrackParticleContainer.h