ATLAS Offline Software
Loading...
Searching...
No Matches
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.
virtual StatusCode finalize () override
 Does nothing.
StatusCode reconstructTracks (std::unique_ptr< xAOD::AFPToFTrackContainer > &outputContainer, const EventContext &ctx) const override
 Does actual tracks reconstruction.
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.
void clearTrains (std::vector< const xAOD::AFPToFHit * > my_trainBars[4]) const
 clear station from bars saved in #my_trainBars;
void saveToXAOD (const AFPTDBasicToolTrack &recoTrack, std::unique_ptr< xAOD::AFPToFTrackContainer > &containerToFill, SG::ReadHandle< xAOD::AFPToFHitContainer > &hitContainer) const
 Save reconstructed track to the xAOD container.

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.
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.
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.
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)
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

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}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Property< int > m_stationID
AFP station ID for which tracks will be reconstructed.
void clearTrains(std::vector< const xAOD::AFPToFHit * > my_trainBars[4]) const
clear station from bars saved in my_trainBars;
AFPToFHit_v1 AFPToFHit
Definition AFPToFHit.h:12

◆ 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}
#define ATH_MSG_INFO(x)
#define CHECK(...)
Evaluate an expression and check for errors.
Gaudi::Property< unsigned int > m_minHitsNumber
Minimal number of bars in track. If there are less bars, track is rejected (Default = 3)
SG::ReadHandleKey< xAOD::AFPToFHitContainer > m_hitContainerKey
Name of the xAOD container with ToF hits to be used in track reconstruction.
Gaudi::Property< double > m_maxAllowedLength
ToolHandle< AFP::IToFLocParamDBTool > m_tofLocParamDBTool
@ brief Tool for accessing DB to get the local ToF parameters

◆ outputContainerName()

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

Definition at line 65 of file AFPTDBasicTool.h.

Gaudi::Property< std::string > m_tracksContainerName
Name of the xAOD container to which tracks will be saved.

◆ 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
73 SG::ReadHandle<xAOD::AFPToFHitContainer> hitContainer( m_hitContainerKey, ctx );
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}
void addBar(const xAOD::AFPToFHit *bar)
Adds a new bar to the track.
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.
void saveToXAOD(const AFPTDBasicToolTrack &recoTrack, std::unique_ptr< xAOD::AFPToFTrackContainer > &containerToFill, SG::ReadHandle< xAOD::AFPToFHitContainer > &hitContainer) const
Save reconstructed track to the xAOD container.
double barTimeOffset() const
Time offset for this particular bar.
double barWeight() const
Weight for this particular bar.
time(flags, cells_name, *args, **kw)
l
Printing final latex table to .tex output file.

◆ 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()) {
157 ElementLink< xAOD::AFPToFHitContainer > barLink;
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}
const std::list< const xAOD::AFPToFHit * > & barInTrain() const

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.

76{this, "AFPToFHitContainerKey", "AFPToFHitContainer", "Name of the container with ToF hits from which ToF tracks are to be reconstructed"};

◆ 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.

81{this, "maxAllowedLength", 100, "Maximal length of the bar signal at which bar can be joined to the track"};

◆ 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.

79{this, "minHitsNumber", 3, "Minimal number of bars in track. If there are less bars, track is rejected"};

◆ 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.

73{this, "stationID", 0, "ID number of station for which tracks should be reconstructed"};

◆ 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.

84{this, "tofLocParamDBTool", "AFP__ToFLocParamDBTool", "Tool to access DB to get the local ToF parameters"};

◆ 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.

70{this, "tracksContainerName", "AFPToFTrackContainer", "Name of the container in which ToF tracks are saved"};

The documentation for this class was generated from the following files: