ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
AFPTDBasicTool Class Reference

Class reconstructing tracks using basic Kalman filter. More...

#include <AFPTDBasicTool.h>

Inheritance diagram for AFPTDBasicTool:
Collaboration diagram for AFPTDBasicTool:

Public Member Functions

 AFPTDBasicTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual ~AFPTDBasicTool () override
 
virtual StatusCode initialize () override
 Read parameters from job options and print tool configuration. More...
 
virtual StatusCode finalize () override
 Does nothing. More...
 
StatusCode reconstructTracks (std::unique_ptr< xAOD::AFPToFTrackContainer > &outputContainer, const EventContext &ctx) const override
 Does actual tracks reconstruction. More...
 
const std::string & outputContainerName () const override
 

Private Member Functions

void fillTrainWithBars (std::vector< const xAOD::AFPToFHit * > my_trainBars[4], SG::ReadHandle< xAOD::AFPToFHitContainer > &hitContainer) const
 Fills Station with ToF hits, dividing them into stations. More...
 
void clearTrains (std::vector< const xAOD::AFPToFHit * > my_trainBars[4]) const
 clear station from bars saved in #my_trainBars; More...
 
void saveToXAOD (const AFPTDBasicToolTrack &recoTrack, std::unique_ptr< xAOD::AFPToFTrackContainer > &containerToFill, SG::ReadHandle< xAOD::AFPToFHitContainer > &hitContainer) const
 Save reconstructed track to the xAOD container. More...
 

Private Attributes

Gaudi::Property< std::string > m_tracksContainerName {this, "tracksContainerName", "AFPToFTrackContainer", "Name of the container in which ToF tracks are saved"}
 Name of the xAOD container to which tracks will be saved. More...
 
Gaudi::Property< int > m_stationID {this, "stationID", 0, "ID number of station for which tracks should be reconstructed"}
 AFP station ID for which tracks will be reconstructed. More...
 
SG::ReadHandleKey< xAOD::AFPToFHitContainerm_hitContainerKey {this, "AFPToFHitContainerKey", "AFPToFHitContainer", "Name of the container with ToF hits from which ToF tracks are to be reconstructed"}
 Name of the xAOD container with ToF hits to be used in track reconstruction. More...
 
Gaudi::Property< unsigned int > m_minHitsNumber {this, "minHitsNumber", 3, "Minimal number of bars in track. If there are less bars, track is rejected"}
 Minimal number of bars in track. If there are less bars, track is rejected (Default = 3) More...
 
Gaudi::Property< double > m_maxAllowedLength {this, "maxAllowedLength", 100, "Maximal length of the bar signal at which bar can be joined to the track"}
 
ToolHandle< AFP::IToFLocParamDBToolm_tofLocParamDBTool {this, "tofLocParamDBTool", "AFP__ToFLocParamDBTool", "Tool to access DB to get the local ToF parameters"}
 @ brief Tool for accessing DB to get the local ToF parameters More...
 

Detailed Description

Class reconstructing tracks using basic Kalman filter.

The idea of the reconstruction is presented in the talk https://indico.cern.ch/event/275484/contributions/1618277/attachments/499062/689421/mdyndal_2013-10-15_AFP_Gen.pdf

Definition at line 42 of file AFPTDBasicTool.h.

Constructor & Destructor Documentation

◆ AFPTDBasicTool()

AFPTDBasicTool::AFPTDBasicTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 19 of file AFPTDBasicTool.cxx.

21  :
22  base_class ( type, name, parent )
23 {
24 
25 }

◆ ~AFPTDBasicTool()

virtual AFPTDBasicTool::~AFPTDBasicTool ( )
inlineoverridevirtual

Definition at line 50 of file AFPTDBasicTool.h.

50 {}

Member Function Documentation

◆ clearTrains()

void AFPTDBasicTool::clearTrains ( std::vector< const xAOD::AFPToFHit * >  my_trainBars[4]) const
inlineprivate

clear station from bars saved in #my_trainBars;

Definition at line 90 of file AFPTDBasicTool.h.

91  {my_trainBars[0].clear(); my_trainBars[1].clear(); my_trainBars[2].clear(); my_trainBars[3].clear();}

◆ fillTrainWithBars()

void AFPTDBasicTool::fillTrainWithBars ( std::vector< const xAOD::AFPToFHit * >  my_trainBars[4],
SG::ReadHandle< xAOD::AFPToFHitContainer > &  hitContainer 
) const
private

Fills Station with ToF hits, dividing them into stations.

Definition at line 48 of file AFPTDBasicTool.cxx.

49 {
50  ATH_MSG_DEBUG("AFPTDBasicTool::fillTrainWithBars");
51  ATH_MSG_DEBUG("Total number of AFP ToF hits read in = " << hitContainer->size());
52  // retrieve ToF bars
53  try {
54  // fill station with ToF hits
55  for (const xAOD::AFPToFHit* theHit : *hitContainer)
56  if (theHit->stationID() == m_stationID) // check if hit is from the correct station
57  my_trainBars[theHit->trainID()].push_back(theHit);
58  }
59  catch (const std::out_of_range& outOfRange) {
60  ATH_MSG_WARNING("Bar with station outside expected range. Aborting track reconstruction.");
61  clearTrains(my_trainBars);
62  }
63 }

◆ finalize()

StatusCode AFPTDBasicTool::finalize ( )
overridevirtual

Does nothing.

Definition at line 41 of file AFPTDBasicTool.cxx.

42 {
43  ATH_MSG_DEBUG("AFPTDBasicTool::finalize()");
44  return StatusCode::SUCCESS;
45 }

◆ initialize()

StatusCode AFPTDBasicTool::initialize ( )
overridevirtual

Read parameters from job options and print tool configuration.

Definition at line 27 of file AFPTDBasicTool.cxx.

28 {
29  // print information about initialised stations
30  ATH_MSG_DEBUG("AFPTDBasicTool::initialize()");
31  ATH_MSG_INFO("Station with ID="<<m_stationID <<" will have minimum number of "<<m_minHitsNumber <<" bars.");
32  ATH_MSG_INFO("Maximal length of signal at which bar can be joined to the track m_maxAllowedLength = "<<m_maxAllowedLength);
33 
34  CHECK( m_tofLocParamDBTool.retrieve() );
35  CHECK( m_hitContainerKey.initialize( SG::AllowEmpty ) );
36 
37  return StatusCode::SUCCESS;
38 }

◆ outputContainerName()

const std::string& AFPTDBasicTool::outputContainerName ( ) const
inlineoverride

Definition at line 65 of file AFPTDBasicTool.h.

65 {return m_tracksContainerName;}

◆ reconstructTracks()

StatusCode AFPTDBasicTool::reconstructTracks ( std::unique_ptr< xAOD::AFPToFTrackContainer > &  outputContainer,
const EventContext &  ctx 
) const
override

Does actual tracks reconstruction.

  1. Reads ToF hits from the xAOD container.
  2. The output list is saved to xAOD containers and objects.

Definition at line 65 of file AFPTDBasicTool.cxx.

66 {
67 
68  if (m_hitContainerKey.empty()) {
69  // this is allowed, there might be no AFP data in the input
70  return StatusCode::SUCCESS;
71  }
72 
74  if(!hitContainer.isValid())
75  {
76  // this is allowed, there might be no AFP data in the input
77  return StatusCode::SUCCESS;
78  }
79 
80  // prepare list for storing reconstructed ToF tracks
81  std::list<AFPTDBasicToolTrack> reconstructedTracks;
82 
83  std::vector<const xAOD::AFPToFHit*> my_trainBars[4];
84 
85  clearTrains(my_trainBars);
86  fillTrainWithBars(my_trainBars, hitContainer);
87 
88  ATH_MSG_DEBUG( "Number of AFP ToF hits in each train = " << my_trainBars[0].size()<<", "<<my_trainBars[1].size()<<", "<<my_trainBars[2].size()<<", "<<my_trainBars[3].size());
89 
90  // ===== do tracks reconstruction =====
91 
92  nlohmann::json dataTLP;
93  bool dataTLP_init{false};
94 
95  for (int k=0; k<4; k++)
96  {
97  unsigned int TrSize = my_trainBars[k].size();
98  double TrTime = 0.;
99  double weight = 0;
100  unsigned int TrSat = 0;
101  if ( TrSize >= m_minHitsNumber )
102  {
103  for (unsigned int l=0; l<TrSize; l++)
104  {
105  // for l-th hit in the k-th train, not necessary l-th bar
106  if ( my_trainBars[k].at(l)->pulseLength() < m_maxAllowedLength)
107  {
108  if(!dataTLP_init)
109  {
110  // read from DB only if necessary
111  dataTLP=m_tofLocParamDBTool->parametersData(ctx);
112  dataTLP_init=true;
113  }
114 
115  const AFP::ToFLocParamData TLP=m_tofLocParamDBTool->parameters(dataTLP, m_stationID, my_trainBars[k].at(l)->trainID(), my_trainBars[k].at(l)->barInTrainID());
116 
117  TrTime += (my_trainBars[k].at(l)->time()-TLP.barTimeOffset())*TLP.barWeight();
118  weight += TLP.barWeight();
119  }
120  else
121  {
122  TrSat++;
123  }
124  }
125  // time average
126  if( TrSize!=TrSat) TrTime /= weight;
127 
128  ATH_MSG_DEBUG("Track reconstruction complete: stationID = " + std::to_string(m_stationID) + ", train time = " + std::to_string(TrTime) + ", train size = " + std::to_string(TrSize));
129  reconstructedTracks.emplace_back(m_stationID,k,TrTime, TrSize, TrSat);
130  AFPTDBasicToolTrack& theTrack = reconstructedTracks.back();
131  for(unsigned int l=0; l<TrSize; l++) theTrack.addBar(my_trainBars[k].at(l));
132  }
133  }
134 
135  // === Save result to xAOD ===
136  // save to xAOD
137 
138  for (const AFPTDBasicToolTrack& track : reconstructedTracks)
139  saveToXAOD(track, outputContainer, hitContainer);
140  return StatusCode::SUCCESS;
141 }

◆ saveToXAOD()

void AFPTDBasicTool::saveToXAOD ( const AFPTDBasicToolTrack recoTrack,
std::unique_ptr< xAOD::AFPToFTrackContainer > &  containerToFill,
SG::ReadHandle< xAOD::AFPToFHitContainer > &  hitContainer 
) const
private

Save reconstructed track to the xAOD container.

Definition at line 143 of file AFPTDBasicTool.cxx.

144 {
145  ATH_MSG_DEBUG("AFPTDBasicTool::saveToXAOD");
146  auto *track = containerToFill->push_back(std::make_unique<xAOD::AFPToFTrack>());
147 
148  track->setStationID(recoTrack.m_stationID);
149  track->setTrainID(recoTrack.m_trainID);
150  track->setTrainTime(recoTrack.m_trainTime);
151  track->setTrainSize(recoTrack.m_trainSize);
152  track->setTrainNSat(recoTrack.m_trainNSat);
153  track->setAlgID(0);
154 // add links to bars
155  ATH_MSG_DEBUG("Track time: (time="<<track->trainTime()<<", size="<<track->trainSize()<<", train id="<<track->trainID()<<") station: (st="<<track->stationID()<<")");
156  for (const xAOD::AFPToFHit* theHit : recoTrack.barInTrain()) {
158  barLink.toContainedElement(*hitContainer, theHit);
159  track->addBar(barLink);
160 
161  ATH_MSG_DEBUG("bar time="<<theHit->time()<<" bar in train ="<<theHit->barInTrainID()<<", trin id ="<<theHit->trainID()<<")");
162  }
163 
164 }

Member Data Documentation

◆ m_hitContainerKey

SG::ReadHandleKey<xAOD::AFPToFHitContainer> AFPTDBasicTool::m_hitContainerKey {this, "AFPToFHitContainerKey", "AFPToFHitContainer", "Name of the container with ToF hits from which ToF tracks are to be reconstructed"}
private

Name of the xAOD container with ToF hits to be used in track reconstruction.

Definition at line 76 of file AFPTDBasicTool.h.

◆ m_maxAllowedLength

Gaudi::Property<double> AFPTDBasicTool::m_maxAllowedLength {this, "maxAllowedLength", 100, "Maximal length of the bar signal at which bar can be joined to the track"}
private

Definition at line 81 of file AFPTDBasicTool.h.

◆ m_minHitsNumber

Gaudi::Property<unsigned int> AFPTDBasicTool::m_minHitsNumber {this, "minHitsNumber", 3, "Minimal number of bars in track. If there are less bars, track is rejected"}
private

Minimal number of bars in track. If there are less bars, track is rejected (Default = 3)

Definition at line 79 of file AFPTDBasicTool.h.

◆ m_stationID

Gaudi::Property<int> AFPTDBasicTool::m_stationID {this, "stationID", 0, "ID number of station for which tracks should be reconstructed"}
private

AFP station ID for which tracks will be reconstructed.

Definition at line 73 of file AFPTDBasicTool.h.

◆ m_tofLocParamDBTool

ToolHandle<AFP::IToFLocParamDBTool> AFPTDBasicTool::m_tofLocParamDBTool {this, "tofLocParamDBTool", "AFP__ToFLocParamDBTool", "Tool to access DB to get the local ToF parameters"}
private

@ brief Tool for accessing DB to get the local ToF parameters

Definition at line 84 of file AFPTDBasicTool.h.

◆ m_tracksContainerName

Gaudi::Property<std::string> AFPTDBasicTool::m_tracksContainerName {this, "tracksContainerName", "AFPToFTrackContainer", "Name of the container in which ToF tracks are saved"}
private

Name of the xAOD container to which tracks will be saved.

Definition at line 70 of file AFPTDBasicTool.h.


The documentation for this class was generated from the following files:
AFPTDBasicToolTrack::m_trainSize
int m_trainSize
Definition: AFPTDBasicToolTrack.h:30
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
json
nlohmann::json json
Definition: HistogramDef.cxx:9
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AFPTDBasicToolTrack::addBar
void addBar(const xAOD::AFPToFHit *bar)
Adds a new bar to the track.
Definition: AFPTDBasicToolTrack.h:38
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
xAOD::AFPToFHit_v1
Class representing a hit in ToF detector.
Definition: AFPToFHit_v1.h:20
AFPTDBasicTool::m_tofLocParamDBTool
ToolHandle< AFP::IToFLocParamDBTool > m_tofLocParamDBTool
@ brief Tool for accessing DB to get the local ToF parameters
Definition: AFPTDBasicTool.h:84
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
AFPTDBasicToolTrack::m_trainID
int m_trainID
Definition: AFPTDBasicToolTrack.h:29
AFPTDBasicTool::saveToXAOD
void saveToXAOD(const AFPTDBasicToolTrack &recoTrack, std::unique_ptr< xAOD::AFPToFTrackContainer > &containerToFill, SG::ReadHandle< xAOD::AFPToFHitContainer > &hitContainer) const
Save reconstructed track to the xAOD container.
Definition: AFPTDBasicTool.cxx:143
AFPTDBasicTool::m_tracksContainerName
Gaudi::Property< std::string > m_tracksContainerName
Name of the xAOD container to which tracks will be saved.
Definition: AFPTDBasicTool.h:70
AFPTDBasicToolTrack::barInTrain
const std::list< const xAOD::AFPToFHit * > & barInTrain() const
Definition: AFPTDBasicToolTrack.h:35
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AFPTDBasicTool::clearTrains
void clearTrains(std::vector< const xAOD::AFPToFHit * > my_trainBars[4]) const
clear station from bars saved in #my_trainBars;
Definition: AFPTDBasicTool.h:90
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AFPTDBasicToolTrack::m_stationID
int m_stationID
Definition: AFPTDBasicToolTrack.h:28
AFPTDBasicToolTrack::m_trainNSat
int m_trainNSat
Definition: AFPTDBasicToolTrack.h:31
AFP::ToFLocParamData::barTimeOffset
double barTimeOffset() const
Time offset for this particular bar.
Definition: ToFLocParamData.h:44
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
AFPTDBasicTool::m_minHitsNumber
Gaudi::Property< unsigned int > m_minHitsNumber
Minimal number of bars in track. If there are less bars, track is rejected (Default = 3)
Definition: AFPTDBasicTool.h:79
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
AFPTDBasicToolTrack::m_trainTime
double m_trainTime
Definition: AFPTDBasicToolTrack.h:32
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AFP::ToFLocParamData::barWeight
double barWeight() const
Weight for this particular bar.
Definition: ToFLocParamData.h:41
AFPTDBasicTool::m_hitContainerKey
SG::ReadHandleKey< xAOD::AFPToFHitContainer > m_hitContainerKey
Name of the xAOD container with ToF hits to be used in track reconstruction.
Definition: AFPTDBasicTool.h:76
AFP::ToFLocParamData
Class storing information about alignment.
Definition: ToFLocParamData.h:24
AFPTDBasicTool::fillTrainWithBars
void fillTrainWithBars(std::vector< const xAOD::AFPToFHit * > my_trainBars[4], SG::ReadHandle< xAOD::AFPToFHitContainer > &hitContainer) const
Fills Station with ToF hits, dividing them into stations.
Definition: AFPTDBasicTool.cxx:48
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
AFPTDBasicTool::m_stationID
Gaudi::Property< int > m_stationID
AFP station ID for which tracks will be reconstructed.
Definition: AFPTDBasicTool.h:73
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
AFPTDBasicToolTrack
Class representing a reconstructed basic ToF track.
Definition: AFPTDBasicToolTrack.h:21
fitman.k
k
Definition: fitman.py:528
AFPTDBasicTool::m_maxAllowedLength
Gaudi::Property< double > m_maxAllowedLength
Definition: AFPTDBasicTool.h:81