ATLAS Offline Software
TBTrackToCaloAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 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  // General access to Tools :
72  IToolSvc* p_toolSvc = 0;
73  ATH_CHECK( service("ToolSvc", p_toolSvc) );
74 
75  IAlgTool* algTool = 0;
76 
77  StatusCode sc = p_toolSvc->retrieveTool("ExtrapolTrackToCaloTool", algTool,this);
78  //m_toCalo=dynamic_cast<IExtrapolTrackToCaloTool*>(algTool);
79  //m_toCalo=dynamic_cast<IExtrapolateToCaloTool*>(algTool);
80  m_toCalo=dynamic_cast<TBExtrapolTrackToCaloTool*>(algTool);
81  if(sc.isFailure() || !m_toCalo) {
82  ATH_MSG_ERROR ( "Cannot get ExtrapolTrackToCaloTool" );
83  return StatusCode::FAILURE;
84  }
85 
86  IAlgTool* tool = 0;
87  ATH_CHECK( p_toolSvc->retrieveTool("TBCaloCoordinate", tool) );
88  m_calo_tb_coord = dynamic_cast<ICaloCoordinateTool*>(tool);
89 
90  // retrived via the Extrapolator to make sure that jobOpt setting is consistent.
92  if (!m_calodepth) {
93  ATH_MSG_ERROR ( "Cannot get CaloDepthTool" );
94  return StatusCode::FAILURE;
95  }
96 
97  ATH_MSG_INFO ( "TBTrackToCaloAlg initialisation OK" );
98  return StatusCode::SUCCESS;
99 }
100 
101 // Execute method:
103 {
104  ATH_MSG_DEBUG ( "TBTrackToCaloAlg::execute()" );
105 
106  // just a simple test ( trick to trigger position reading )
107  // PrintBeamPosition();
108 
109  // Create the impacts :
110  /*found_a_track =*/ CreateTrkImpactInCalo();
111 
112  // Example 1 : you want to read them and compare to clusters
113 
114  /*
115  if (found_a_track) {
116  PrintImpact();
117  //CompareImpactWithCluster();
118  }
119  */
120 
121  // Example 2 : you want to know the list of cells crossed by the track
122  // bool found_cells = PrintCellsCrossed();
124  return StatusCode::SUCCESS;
125 }
126 
127 // Finalize method:
129 {
130  ATH_MSG_DEBUG ( "TBTrackToCaloAlg::finalize()" );
131 
132  return StatusCode::SUCCESS;
133 }
134 
135 
136 // Loop on Tracks/TrackParticles and create ImpactInCaloCollection
138 {
139  bool got_a_track = false;
140 
141  ATH_MSG_DEBUG ( "TBTrackToCaloAlg::CreateTrkImpactInCalo()" );
142 
143  //create and record new ImpactInCalo container
144  ImpactInCaloCollection* outputContainer = new ImpactInCaloCollection();
145  StatusCode sc=evtStore()->record(outputContainer,m_ImpactInCalosOutputName,false); //"false" indicates it can't be modified by another algorithm
146  if(sc != StatusCode::SUCCESS){
147  ATH_MSG_ERROR ( " Could not record ImpactInCaloCollection"
149  return got_a_track ;
150  }
151 
152  m_particle = 0;
153  m_tracks = 0;
154 
155  if( m_trkinput == "TrackParticleCandidates")
156  {
157  if (m_TrackParticleName == "") {
158  ATH_MSG_ERROR ("m_TrackParticleName not set" );
159  return true;
160  }
161 
162  sc = evtStore()->retrieve(m_particle, m_TrackParticleName);
163 
164  if (sc.isFailure()) ATH_MSG_ERROR ("TrackParticle not found: will only play with calo " << m_TrackParticleName );
165  else {
166  ATH_MSG_DEBUG ("TrackParticle found in StoreGate" );
167  for (const Rec::TrackParticle* tp : *m_particle) {
168  const Trk::Track* tr = tp->originalTrack();
169 
170  ImpactInCalo * imp = GetImpactsInCalo(tr, got_a_track);
171  if(imp) outputContainer->push_back(imp);
172  else ATH_MSG_DEBUG (" ImpactInCalo pointer not valid for this track");
173  }
174  }
175  }
176 
177  else
178  {
179  if (m_TrackName == "") {
180  ATH_MSG_ERROR ("m_TrackName not set" );
181  return true;
182  }
183 
184  sc = evtStore()->retrieve(m_tracks, m_TrackName);
185 
186  if (sc.isFailure()) ATH_MSG_ERROR ("Tracks not found: will only play with calo " << m_TrackName );
187  else {
188  ATH_MSG_DEBUG ("Tracks found in StoreGate" );
189  for (const Trk::Track* tr : *m_tracks) {
190  ImpactInCalo * imp = GetImpactsInCalo(tr, got_a_track);
191  if(imp) outputContainer->push_back(imp);
192  else ATH_MSG_DEBUG (" ImpactInCalo pointer not valid for this track");
193  }
194  }
195  }
196 
197  return got_a_track;
198 }
199 
201 {
202  Amg::Vector3D* pt_calo_ctb = new Amg::Vector3D;
203  Amg::Vector3D* pt_calo_local = new Amg::Vector3D;
204 
206  const CaloDetDescrManager* caloDDMgr = *caloMgrHandle;
207 
208  double trketa = 0.;
209  // take the last measured point to find out if I am in barrel or endcap :
210  const DataVector <const Trk::TrackParameters>* paramvec = track->trackParameters();
211  if (paramvec) {
212  for (const Trk::TrackParameters* params : *paramvec)
213  trketa = params->eta();
214  }
215  else
216  ATH_MSG_ERROR ( " No track parameters for this track ??? do nothing " );
217 
218  double distbar = 0.;
219  double distec = 0.;
220  double offset = 0.;
221  double trketa_at = 0.;
222  double trkphi_at = 0.;
223  bool result = false;
225 
226  // PreSampler :
227  double x_ctb_0 = 0;
228  double y_ctb_0 = 0;
229  double z_ctb_0 = 0;
230  double etaCaloLocal_0 = 0;
231  double phiCaloLocal_0 = 0;
232  double trketa_at_0 = 0.;
233  double trkphi_at_0 = 0.;
234  // Strip :
235  double x_ctb_1 = 0;
236  double y_ctb_1 = 0;
237  double z_ctb_1 = 0;
238  double etaCaloLocal_1 = 0;
239  double phiCaloLocal_1 = 0;
240  double trketa_at_1 = 0.;
241  double trkphi_at_1 = 0.;
242  // Middle :
243  double x_ctb_2 = 0;
244  double y_ctb_2 = 0;
245  double z_ctb_2 = 0;
246  double etaCaloLocal_2 = 0;
247  double phiCaloLocal_2 = 0;
248  double trketa_at_2 = 0.;
249  double trkphi_at_2 = 0.;
250  // Back :
251  double x_ctb_3 = 0;
252  double y_ctb_3 = 0;
253  double z_ctb_3 = 0;
254  double etaCaloLocal_3 = 0;
255  double phiCaloLocal_3 = 0;
256  double trketa_at_3 = 0.;
257  double trkphi_at_3 = 0.;
258  // Tiles :
259  double x_ctb_tile = 0;
260  double y_ctb_tile = 0;
261  double z_ctb_tile = 0;
262  double etaCaloLocal_tile = 0;
263  double phiCaloLocal_tile = 0;
264  double trketa_at_tile = 0.;
265  double trkphi_at_tile = 0.;
266 
267  if (paramvec) {
268 
269  // PS :
270  distbar = CaloDepthTool::deta(CaloCell_ID::PreSamplerB,trketa,caloDDMgr);
271  distec = CaloDepthTool::deta(CaloCell_ID::PreSamplerE,trketa,caloDDMgr);
272 
273  ATH_MSG_DEBUG ( " TrackTo ...PS : for eta= " << trketa << " dist to Barrel =" << distbar
274  << " to endcap =" << distec );
275  if (distbar < 0 ) sample = CaloCell_ID::PreSamplerB;
276  else if (distec < 0 ) sample = CaloCell_ID::PreSamplerE;
277  else if ( distbar < distec) sample = CaloCell_ID::PreSamplerB;
279  ATH_MSG_DEBUG ( " => will shoot in sample " << sample );
280 
282  pt_calo_ctb,pt_calo_local,trketa_at,trkphi_at);
283 
284  if (result) {
285  got_a_track=true;
286  x_ctb_0 = pt_calo_ctb->x();
287  y_ctb_0 = pt_calo_ctb->y();
288  z_ctb_0 = pt_calo_ctb->z();
289  etaCaloLocal_0 = pt_calo_local->eta();
290  phiCaloLocal_0 = pt_calo_local->phi();
291  trketa_at_0 = trketa_at;
292  trkphi_at_0 = trkphi_at;
293 
294  ATH_MSG_DEBUG ( "Extrapolation to PreSamplerB gives: "
295  << " etaCaloLocal=" << pt_calo_local->eta()
296  << " phiCaloLocal=" << pt_calo_local->phi() );
297  }
298 
299  // strip :
300  distbar = CaloDepthTool::deta(CaloCell_ID::EMB1,trketa,caloDDMgr);
301  distec = CaloDepthTool::deta(CaloCell_ID::EME1,trketa,caloDDMgr);
302 
303  ATH_MSG_DEBUG ( " TrackTo ...Strip : for eta= " << trketa << " dist to Barrel =" << distbar
304  << " to endcap =" << distec );
305  if (distbar < 0 ) sample = CaloCell_ID::EMB1;
306  else if (distec < 0 ) sample = CaloCell_ID::EME1;
307  else if ( distbar < distec) sample = CaloCell_ID::EMB1;
308  else sample = CaloCell_ID::EME1;
309  ATH_MSG_DEBUG ( " => will shoot in sample " << sample );
310 
312  pt_calo_ctb,pt_calo_local,trketa_at,trkphi_at);
313 
314  if (result) {
315  got_a_track=true;
316  x_ctb_1 = pt_calo_ctb->x();
317  y_ctb_1 = pt_calo_ctb->y();
318  z_ctb_1 = pt_calo_ctb->z();
319  etaCaloLocal_1 = pt_calo_local->eta();
320  phiCaloLocal_1 = pt_calo_local->phi();
321  trketa_at_1 = trketa_at;
322  trkphi_at_1 = trkphi_at;
323 
324  ATH_MSG_DEBUG ( "Extrapolation to EMB1 gives: "
325  << " etaCaloLocal=" << pt_calo_local->eta()
326  << " phiCaloLocal=" << pt_calo_local->phi() );
327  }
328 
329 
330  // middle :
331  distbar = CaloDepthTool::deta(CaloCell_ID::EMB2,trketa,caloDDMgr);
332  distec = CaloDepthTool::deta(CaloCell_ID::EME2,trketa,caloDDMgr);
333 
334  ATH_MSG_DEBUG ( " TrackTo ...Middle : for eta= " << trketa << " dist to Barrel =" << distbar
335  << " to endcap =" << distec );
336  if (distbar < 0 ) sample = CaloCell_ID::EMB2;
337  else if (distec < 0 ) sample = CaloCell_ID::EME2;
338  else if ( distbar < distec) sample = CaloCell_ID::EMB2;
339  else sample = CaloCell_ID::EME2;
340  ATH_MSG_DEBUG ( " => will shoot in sample " << sample );
341 
343  pt_calo_ctb,pt_calo_local,trketa_at,trkphi_at);
344 
345  if (result) {
346  got_a_track=true;
347  x_ctb_2 = pt_calo_ctb->x();
348  y_ctb_2 = pt_calo_ctb->y();
349  z_ctb_2 = pt_calo_ctb->z();
350  etaCaloLocal_2 = pt_calo_local->eta();
351  phiCaloLocal_2 = pt_calo_local->phi();
352  trketa_at_2 = trketa_at;
353  trkphi_at_2 = trkphi_at;
354 
355  ATH_MSG_DEBUG ( "Extrapolation to EMB2 gives: "
356  << " etaCaloLocal=" << pt_calo_local->eta()
357  << " phiCaloLocal=" << pt_calo_local->phi() );
358  }
359 
360  // Back :
361  //
362  // there is a real gap between 1.35 (end of EMB3) and 1.5 (start of EMEC3)
363  // => for TrackToCalo chooses the closest. One could choose to stay in
364  // barrel as long as not in endcap
365  // In both cases, m_calodepth will see that you are outside the accpetance and
366  // will use the backup solution (egparametrisation right now, rel 10.0.2).
367  //
368 
369  distbar = CaloDepthTool::deta(CaloCell_ID::EMB3,trketa,caloDDMgr);
370  distec = CaloDepthTool::deta(CaloCell_ID::EME3,trketa,caloDDMgr);
371 
372  ATH_MSG_DEBUG ( " TrackTo ...Back : for eta= " << trketa << " dist to Barrel =" << distbar
373  << " to endcap =" << distec );
374  if (distbar < 0 ) sample = CaloCell_ID::EMB3;
375  else if (distec < 0 ) sample = CaloCell_ID::EME3;
376  else if ( distbar < distec) sample = CaloCell_ID::EMB3;
377  else sample = CaloCell_ID::EME3;
378  ATH_MSG_DEBUG ( " => will shoot in sample " << sample );
379 
381  pt_calo_ctb,pt_calo_local,trketa_at,trkphi_at);
382 
383  if (result) {
384  got_a_track=true;
385  x_ctb_3 = pt_calo_ctb->x();
386  y_ctb_3 = pt_calo_ctb->y();
387  z_ctb_3 = pt_calo_ctb->z();
388  etaCaloLocal_3 = pt_calo_local->eta();
389  phiCaloLocal_3 = pt_calo_local->phi();
390  trketa_at_3 = trketa_at;
391  trkphi_at_3 = trkphi_at;
392 
393  ATH_MSG_DEBUG ( "Extrapolation to EMB3 gives: "
394  << " etaCaloLocal=" << pt_calo_local->eta()
395  << " phiCaloLocal=" << pt_calo_local->phi() );
396  }
397 
398  // Tile or HEC0 :
399  distbar = CaloDepthTool::deta(CaloCell_ID::TileBar0,trketa,caloDDMgr);
400  distec = CaloDepthTool::deta(CaloCell_ID::HEC0,trketa,caloDDMgr);
401 
402  ATH_MSG_DEBUG ( " TrackTo ...Tile : for eta= " << trketa << " dist to Barrel =" << distbar
403  << " to endcap =" << distec );
404  if (distbar < 0 ) sample = CaloCell_ID::TileBar0;
405  else if (distec < 0 ) sample = CaloCell_ID::HEC0;
406  else if ( distbar > distec && distec < 10. ) sample = CaloCell_ID::HEC0;
408  ATH_MSG_DEBUG ( " => will shoot in sample " << sample );
409 
411  pt_calo_ctb,pt_calo_local,trketa_at,trkphi_at);
412 
413  if (result) {
414  got_a_track=true;
415  x_ctb_tile = pt_calo_ctb->x();
416  y_ctb_tile = pt_calo_ctb->y();
417  z_ctb_tile = pt_calo_ctb->z();
418  etaCaloLocal_tile = pt_calo_local->eta();
419  phiCaloLocal_tile = pt_calo_local->phi();
420  trketa_at_tile = trketa_at;
421  trkphi_at_tile = trkphi_at;
422 
423  ATH_MSG_DEBUG ( "Extrapolation to TileBar0 gives: "
424  << " etaCaloLocal=" << pt_calo_local->eta()
425  << " phiCaloLocal=" << pt_calo_local->phi() );
426  }
427  }
428 
429  ImpactInCalo * imp= new ImpactInCalo(x_ctb_0, y_ctb_0, z_ctb_0, etaCaloLocal_0, phiCaloLocal_0, trketa_at_0, trkphi_at_0,
430  x_ctb_1, y_ctb_1, z_ctb_1, etaCaloLocal_1, phiCaloLocal_1, trketa_at_1, trkphi_at_1,
431  x_ctb_2, y_ctb_2, z_ctb_2, etaCaloLocal_2, phiCaloLocal_2, trketa_at_2, trkphi_at_2,
432  x_ctb_3, y_ctb_3, z_ctb_3, etaCaloLocal_3, phiCaloLocal_3, trketa_at_3, trkphi_at_3,
433  x_ctb_tile, y_ctb_tile, z_ctb_tile, etaCaloLocal_tile, phiCaloLocal_tile, trketa_at_tile, trkphi_at_tile);
434 
435  if(pt_calo_ctb) delete pt_calo_ctb;
436  if(pt_calo_local) delete pt_calo_local;
437 
438  return imp;
439 }
440 
441 
442 
443 
444 // Retreive ImpactInCaloCollection and compare to CaloClusters
446 {
447  StatusCode sc1, sc2;
448 
449  ATH_MSG_DEBUG ( "TBTrackToCaloAlg::CompareImpactWithCluster()" );
450 
451  // loop on clusters
452 
453  const CaloClusterContainer* cluster_container = nullptr;
454  sc1=evtStore()->retrieve(cluster_container,m_cluster_container);
455 
456  const ImpactInCaloCollection* impact_collection;
457  sc2=evtStore()->retrieve(impact_collection,m_ImpactInCalosOutputName);
458 
459  if(sc1 == StatusCode::SUCCESS && sc2 == StatusCode::SUCCESS ){
460 
461  typedef ImpactInCaloCollection::const_iterator impact_iterator;
462  impact_iterator f_imp = impact_collection->begin();
463  impact_iterator l_imp = impact_collection->end();
464 
465  for (const CaloCluster* cluster : *cluster_container) {
466  double hecluster = cluster->energy()/GeV;
467  double heta = cluster->eta();
468  double hphi = cluster->phi();
469 
470  ATH_MSG_INFO ( "Found a cluster : E= " << hecluster
471  << "(GeV), etaCaloLocal=" << heta
472  << ", phiCaloLocal=" << hphi );
473 
474  for ( ; f_imp!=l_imp; ++f_imp){
475  const ImpactInCalo* impact = (*f_imp);
476 
477  ATH_MSG_INFO
478  ( "==> Comparison between cluster and impact in Middle : deta="
479  << heta-impact->etaCaloLocal_2()
480  << " , dphi=" << hphi-impact->phiCaloLocal_2() );
481  }
482  }
483  }
484  else {
485  if (sc1 != StatusCode::SUCCESS)
486  ATH_MSG_ERROR ("Clusters not found"
487  << m_cluster_container );
488  if (sc2 != StatusCode::SUCCESS)
489  ATH_MSG_ERROR ("ImpactInCalos not found"
491  }
492 }
493 
494 // Retreive ImpactInCaloCollection and print content
496 {
497  StatusCode sc;
498 
499  ATH_MSG_INFO ( " Method PrintImpacts : " );
500 
501  ATH_MSG_INFO ( " " );
502  ATH_MSG_INFO ( " Start with Impacts : " );
503 
504  const ImpactInCaloCollection* impact_collection;
505  sc=evtStore()->retrieve(impact_collection,m_ImpactInCalosOutputName);
506 
507  if(sc == StatusCode::SUCCESS ){
508 
509  for (const ImpactInCalo* impact : *impact_collection) {
510  const double impcosPhi = std::cos(impact->phiCaloLocal_1());
511  const double impeta = impact->etaCaloLocal_1();
512 
513  ATH_MSG_INFO ( "Found an impact in strips : parameters are eta = " << impeta
514  << " cosPhi = " << impcosPhi );
515 
516  //impact->print();
517  }
518  }
519  else {
520  ATH_MSG_ERROR ("ImpactInCalos not found"
522  }
523 
524  if (m_tracks) {
525 
526  ATH_MSG_INFO ( " " );
527  ATH_MSG_INFO (" Now loop on Trk::Track collection " );
528  ATH_MSG_INFO ( " " );
529 
530  for (const Trk::Track* tr : *m_tracks) {
531  const Trk::Perigee *aMeasPer=
532  dynamic_cast<const Trk::Perigee*>(tr->perigeeParameters());
533  if (aMeasPer==0){
534  ATH_MSG_ERROR ( "Could not get Trk::MeasuredPerigee" );
535  }
536  else {
537 
538  const double trkcosPhi = cos(aMeasPer->parameters()[Trk::phi]);
539  const double trketa = aMeasPer->eta();
540 
541  ATH_MSG_INFO ( "Found a Trk::Track : parameters are eta = " << trketa
542  << " cosPhi = " << trkcosPhi );
543  }
544  }
545  }
546 
547  if (m_particle) {
548 
549  ATH_MSG_INFO ( " " );
550  ATH_MSG_INFO (" Now loop on Trk::TrackParticle collection " );
551  ATH_MSG_INFO ( " " );
552 
554  itr != m_particle->end(); ++itr )
555  {
556  const Trk::Perigee *aMeasPer=
557  dynamic_cast<const Trk::Perigee*>(((*itr)->originalTrack())->perigeeParameters());
558  if (aMeasPer==0){
559  ATH_MSG_ERROR ( "Could not get TrkParticle::MeasuredPerigee" );
560  }
561  else {
562 
563  const double partcosPhi = cos(aMeasPer->parameters()[Trk::phi]);
564  const double parteta = aMeasPer->eta();
565 
566  ATH_MSG_INFO ( "Found a trackparticle : parameters are eta = " << parteta
567  << " cosPhi = " << partcosPhi );
568  }
569  }
570  }
571 }
572 
573 // List of cells crossed by Trk::Tracks in CaloSample
574 // ( neta and nphi are the total window width, e.g .5x5 )
575 CaloCellList*
577  const CaloCell_ID::CaloSample sam,
578  int neta, int nphi)
579 {
580  CaloCellList* my_list = 0;
581 
582  // Retreive CaloCell's from StoreGate :
583 
584  const CaloCellContainer* cell_container;
585  StatusCode sc=evtStore()->retrieve(cell_container,m_cell_container);
586  if ( sc != StatusCode::SUCCESS ) return 0;
587 
589  const CaloDetDescrManager* caloDDMgr = *caloMgrHandle;
590 
591  // Where is the track shooting ?
592  double offset = 0.;
593  double trketa_at = 0.;
594  double trkphi_at = 0.;
595  Amg::Vector3D* pt_ctb = new Amg::Vector3D();
596  Amg::Vector3D* pt_local = new Amg::Vector3D();
597  bool result = m_toCalo->
598  TrackSeenByCalo(trk,sam,offset,pt_ctb,pt_local,trketa_at,trkphi_at);
599 
600  if (!result) {
601  delete pt_ctb;
602  delete pt_local;
603  return 0;
604  }
605 
606  double eta = pt_local->eta();
607  double phi = pt_local->phi();
608 
609  // CaloCellList needs both enums: subCalo and CaloSample
610  CaloCell_ID::SUBCALO subcalo;
611  bool barrel;
612  int sampling_or_module;
613  CaloDetDescrManager::decode_sample (subcalo, barrel, sampling_or_module, sam);
614 
615  // Get the corresponding grannularities : needs to know where you are
616  // the easiest is to look for the CaloDetDescrElement
617  const CaloDetDescrElement* dde =
618  caloDDMgr->get_element(subcalo,sampling_or_module,barrel,eta,phi);
619 
620  double deta = int(neta/2)*dde->deta();
621  double dphi = int(nphi/2)*dde->dphi();
622 
623  //std::cout << "zone is ..." << eta << " " << phi << " "
624  // << deta << " " << dphi << " " << std::endl;
625  // Construct the list :
626  my_list = new CaloCellList(caloDDMgr, cell_container,subcalo);
627  my_list->select(eta,phi,deta,dphi, (int) sam);
628 
629  // cleanup
630  delete pt_ctb;
631  delete pt_local;
632 
633  return my_list ;
634 }
635 
637 {
638 
639  // Get the messaging service, print where you are
640  ATH_MSG_INFO ( "TBTrackToCaloAlg::PrintCellsCrossed()" );
641 
642  // Here we are :
644  int neta = 5;
645  int nphi = 5;
646 
647  // get tracks from TDS
648  if (m_TrackName == "") {
649  ATH_MSG_ERROR ("m_TrackName not set" );
650  return true;
651  }
652 
653  StatusCode sc = evtStore()->retrieve(m_tracks, m_TrackName);
654  if (sc.isFailure()){
655  ATH_MSG_ERROR ("Tracks not found: will only play with calo "
656  << m_TrackName );
657  }
658  else{
659  ATH_MSG_DEBUG ("Tracks found in StoreGate" );
660 
661  for (const Trk::Track* tr : *m_tracks) {
662 
663  const Trk::Perigee *aMeasPer=
664  dynamic_cast<const Trk::Perigee*>(tr->perigeeParameters());
665  if (aMeasPer==0){
666  ATH_MSG_ERROR ( "Could not get Trk::MeasuredPerigee" );
667  }
668  else {
669  double d0 = aMeasPer->parameters()[Trk::d0];
670  double z0 = aMeasPer->parameters()[Trk::z0];
671  double phi0 = aMeasPer->parameters()[Trk::phi0];
672  double theta = aMeasPer->parameters()[Trk::theta];
673  double qOverP = aMeasPer->parameters()[Trk::qOverP];
674  ATH_MSG_INFO ( " " );
675  ATH_MSG_INFO ( "Found a track: parameters are " << d0 << " "
676  << z0 << " " << phi0 << " " << theta << " " << qOverP );
677  }
678 
679  // Warning : if anything fails, CellsCrossedByTrack will
680  // simply return a null pointer
681  // if it works, it does a new CaloCellList
682  // ==> the client has to do the delete !!!!
683 
684  CaloCellList* my_list = CellsCrossedByTrack(tr, sam, neta, nphi);
685 
686  if (my_list) {
687 
688  for (const CaloCell* cell : *my_list)
689  ATH_MSG_INFO ( "found cell ! eta=" << cell->eta()
690  << " phi=" << cell->phi() << " energy=" << cell->energy() );
691 
692  delete my_list;
693 
694  }
695  else
696  ATH_MSG_ERROR (" :-( extrapolation did not work");
697  }
698  }
699 
700  return true;
701 }
702 
703 // A little check : where is the beam ?
705 {
706  // Get the messaging service, print where you are
707  ATH_MSG_INFO ( "TBTrackToCaloAlg::PrintBeamPosition()" );
708 
709  ATH_MSG_INFO ( "Just a check... beam direction in calo : " );
711  Amg::Vector3D beam (1.,0.,0.);
713 }
714 
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
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TBTrackToCaloAlg::CompareImpactWithCluster
void CompareImpactWithCluster()
Definition: TBTrackToCaloAlg.cxx:445
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:64
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:79
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:71
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:70
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:704
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:100
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
TBTrackToCaloAlg::finalize
virtual StatusCode finalize() override
Definition: TBTrackToCaloAlg.cxx:128
CaloCell_ID_FCS::TileBar0
@ TileBar0
Definition: FastCaloSim_CaloCell_ID.h:31
Trk::theta
@ theta
Definition: ParamDefs.h:72
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:581
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:636
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:195
Trk::d0
@ d0
Definition: ParamDefs.h:69
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:137
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:495
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:73
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:102
Trk::phi
@ phi
Definition: ParamDefs.h:81
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:576
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
Trk::phi0
@ phi0
Definition: ParamDefs.h:71
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:200
TrackParticleContainer.h