13 const std::string& name, ISvcLocator* svc_locator)
21 ATH_MSG_INFO(
"Initializing HGTD_TrkTimePerformanceStudies ...");
25 const std::string titleStr{
";|#eta| ;frequency"};
27 const auto & tname = track_tool->name();
29 const auto & timetoolName = time_tool->name();
30 static const std::string effVsEta{
"m_eff_vs_eta"};
31 bookEffSubdir(tname, timetoolName, effVsEta, titleStr, 32, 2.4, 4.0);
32 static const std::string primesVsEta{
"m_eff_gt50pcprimes_vs_eta"};
33 bookEffSubdir(tname, timetoolName, primesVsEta, titleStr, 32, 2.4, 4.0);
34 static const std::string primesVsEtaMistag{
"m_eff_gt50pcprimes_vs_eta_mistag"};
35 bookEffSubdir(tname, timetoolName, primesVsEtaMistag, titleStr, 32, 2.4, 4.0);
37 std::string name =
"m_eff_vs_eta_primesfrac" + primes_fraction_i;
38 bookEffSubdir(tname, timetoolName, name, titleStr, 32, 2.4, 4.0);
39 std::string name_res =
"m_hist_timeres_outlier_cases" + primes_fraction_i;
40 static const std::string thisTitle{
";t_{reco} - t_{truth} [ns]; number of tracks"};
50 return StatusCode::SUCCESS;
58 track_particles_hdl.
cptr();
60 for (
const auto* track : *track_particles) {
64 const float trk_eta = track->eta();
66 if (!track_tool->trackPassesSelection(track)) {
73 auto purity = time_tool->fracPrimaryHits(*track);
74 int n_potential_primes = time_tool->numberPotentialPrimaryHits(*track);
75 bool has_time = time_tool->expertHasTime(*track);
79 switch (n_potential_primes) {
96 }
else if (purity > 0.01 and purity < 0.48) {
98 }
else if (purity > 0.48 and purity < 0.52) {
100 }
else if (purity > 0.52 and purity < 0.98) {
102 }
else if (purity > 0.98) {
106 bool morethanhalfprimes =
109 fillEffSubDir(track_tool->name(), time_tool->name(),
"m_eff_vs_eta",
110 has_time, std::abs(trk_eta));
112 bool count_primesfrac_category_as_good =
false;
114 if (i ==
static_cast<size_t>(primes_fraction)) {
115 count_primesfrac_category_as_good = has_time;
117 count_primesfrac_category_as_good =
false;
121 count_primesfrac_category_as_good, std::abs(trk_eta));
126 if (truth_particle and truth_vertex) {
127 float track_time = time_tool->expertTime(*track);
128 float truth_time = time_tool->getTruthTime(*truth_vertex);
129 float time_res = track_time - truth_time;
131 "m_hist_timeres_outlier_cases" +
136 "m_eff_gt50pcprimes_vs_eta", morethanhalfprimes,
139 "m_eff_gt50pcprimes_vs_eta_mistag",
140 not morethanhalfprimes, std::abs(trk_eta));
143 "m_eff_gt50pcprimes_vs_eta",
false, std::abs(trk_eta));
145 "m_eff_gt50pcprimes_vs_eta_mistag",
false,
152 return StatusCode::SUCCESS;
157 if (not truth_particle) {
164 truth_event_container_hdl.
cptr();
166 if (not truth_event_container or truth_event_container->
empty()) {
168 <<
" container in this event");
173 auto truth_hs_event = truth_event_container->
at(0);
174 if (not truth_hs_event) {
177 int n_hs_truthparticles = truth_hs_event->nTruthParticles();
178 auto truth_hs_vtx = truth_event_container->
at(0)->signalProcessVertex();
180 for (
int i = 0; i < n_hs_truthparticles; i++) {
181 if (not truth_hs_event->truthParticle(i)) {
184 if (not truth_hs_event->truthParticle(i)->isSimulationParticle() and
185 truth_hs_event->truthParticle(i)->isStable() and
186 truth_hs_event->truthParticle(i)->isCharged() and
187 truth_hs_event->truthParticle(i)->index() == truth_particle->index()) {
195 pileup_truth_container_hdl.
cptr();
202 if (not pileup_truth_container) {
204 <<
" container in this event");
209 for (
size_t pu_event = 0; pu_event < pileup_truth_container->
size();
211 auto truth_pu_event = pileup_truth_container->
at(pu_event);
212 auto truth_pu_vertex = truth_pu_event->truthVertex(1);
213 int n_pu_truthparticles = truth_pu_event->nTruthParticles();
215 for (
int i = 0; i < n_pu_truthparticles; i++) {
216 if (not truth_pu_event->truthParticle(i)) {
219 if (not truth_pu_event->truthParticle(i)->isSimulationParticle() and
220 truth_pu_event->truthParticle(i)->isStable() and
221 truth_pu_event->truthParticle(i)->isCharged() and
222 truth_particle->index() ==
223 truth_pu_event->truthParticle(i)->index()) {
224 return truth_pu_vertex;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_INFO(x,...)
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
void bookSubdir(const std::string &trk_sel_name, const std::string &time_wp, const std::string &hist_name, const std::string &title, Ts... args)
Templated function for booking histograms The type of the histogram is passed as a template parameter...
virtual StatusCode initialize()
HGTD_AnalysisAlgBase(const std::string &name, ISvcLocator *svc_locator)
void bookEffSubdir(const std::string &trk_sel_name, const std::string &time_wp, const std::string &hist_name, const std::string &title, Ts... args)
void fillEffSubDir(std::string_view trk_sel_name, std::string_view wp_name, std::string_view hist_name, Ts... args)
void fillSubdir(std::string_view trk_sel_name, std::string_view time_wp, std::string_view hist_name, Ts... args)
const_pointer_type cptr()
Dereference the pointer.
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any).
TruthEventContainer_v1 TruthEventContainer
Declare the latest version of the truth event container.
TruthPileupEventContainer_v1 TruthPileupEventContainer
Declare the latest version of the truth event container.
TruthVertex_v1 TruthVertex
Typedef to implementation.
TruthParticle_v1 TruthParticle
Typedef to implementation.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".