13 const std::string& name, ISvcLocator* svc_locator)
21 ATH_MSG_INFO(
"Initializing HGTD_TrkTimePerformanceStudies ...");
29 bookEffSubdir(track_tool->name(), time_tool->name(),
"m_eff_vs_eta",
30 ";|#eta| ;frequency", 32, 2.4, 4.0);
32 "m_eff_gt50pcprimes_vs_eta",
";|#eta| ;frequency", 32, 2.4,
35 "m_eff_gt50pcprimes_vs_eta_mistag",
";|#eta| ;frequency",
39 std::string name =
"m_eff_vs_eta_primesfrac" + primes_fraction_i;
41 ";|#eta| ;frequency", 32, 2.4, 4.0);
43 std::string name_res =
44 "m_hist_timeres_outlier_cases" + primes_fraction_i;
46 ";t_{reco} - t_{truth} [ns]; number of tracks", 200,
56 return StatusCode::SUCCESS;
64 track_particles_hdl.
cptr();
66 for (
const auto* track : *track_particles) {
70 const float trk_eta = track->eta();
72 if (!track_tool->trackPassesSelection(track)) {
79 auto purity = time_tool->fracPrimaryHits(*track);
80 int n_potential_primes = time_tool->numberPotentialPrimaryHits(*track);
81 bool has_time = time_tool->expertHasTime(*track);
85 switch (n_potential_primes) {
102 }
else if (purity > 0.01 and purity < 0.48) {
104 }
else if (purity > 0.48 and purity < 0.52) {
106 }
else if (purity > 0.52 and purity < 0.98) {
108 }
else if (purity > 0.98) {
112 bool morethanhalfprimes =
116 fillEffSubDir(track_tool->name(), time_tool->name(),
"m_eff_vs_eta",
117 has_time, std::abs(trk_eta));
119 bool count_primesfrac_category_as_good =
false;
121 if (i ==
static_cast<size_t>(primes_fraction)) {
122 count_primesfrac_category_as_good = has_time;
124 count_primesfrac_category_as_good =
false;
128 count_primesfrac_category_as_good, std::abs(trk_eta));
133 if (truth_particle and truth_vertex) {
134 float track_time = time_tool->expertTime(*track);
135 float truth_time = time_tool->getTruthTime(*truth_vertex);
136 float time_res = track_time - truth_time;
138 "m_hist_timeres_outlier_cases" +
143 "m_eff_gt50pcprimes_vs_eta", morethanhalfprimes,
146 "m_eff_gt50pcprimes_vs_eta_mistag",
147 not morethanhalfprimes, std::abs(trk_eta));
150 "m_eff_gt50pcprimes_vs_eta",
false, std::abs(trk_eta));
152 "m_eff_gt50pcprimes_vs_eta_mistag",
false,
159 return StatusCode::SUCCESS;
164 if (not truth_particle) {
171 truth_event_container_hdl.
cptr();
173 if (not truth_event_container or truth_event_container->
empty()) {
175 <<
" container in this event");
180 auto truth_hs_event = truth_event_container->
at(0);
181 if (not truth_hs_event) {
184 int n_hs_truthparticles = truth_hs_event->nTruthParticles();
185 auto truth_hs_vtx = truth_event_container->
at(0)->signalProcessVertex();
187 for (
int i = 0; i < n_hs_truthparticles; i++) {
188 if (not truth_hs_event->truthParticle(i)) {
191 if (not truth_hs_event->truthParticle(i)->isSimulationParticle() and
192 truth_hs_event->truthParticle(i)->isStable() and
193 truth_hs_event->truthParticle(i)->isCharged() and
194 truth_hs_event->truthParticle(i)->index() == truth_particle->index()) {
202 pileup_truth_container_hdl.
cptr();
209 if (not pileup_truth_container) {
211 <<
" container in this event");
216 for (
size_t pu_event = 0; pu_event < pileup_truth_container->
size();
218 auto truth_pu_event = pileup_truth_container->
at(pu_event);
219 auto truth_pu_vertex = truth_pu_event->truthVertex(1);
220 int n_pu_truthparticles = truth_pu_event->nTruthParticles();
222 for (
int i = 0; i < n_pu_truthparticles; i++) {
223 if (not truth_pu_event->truthParticle(i)) {
226 if (not truth_pu_event->truthParticle(i)->isSimulationParticle() and
227 truth_pu_event->truthParticle(i)->isStable() and
228 truth_pu_event->truthParticle(i)->isCharged() and
229 truth_particle->index() ==
230 truth_pu_event->truthParticle(i)->index()) {
231 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 fillEffSubDir(const std::string &trk_sel_name, const std::string &wp_name, const std::string &hist_name, Ts... args)
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 fillSubdir(const std::string &trk_sel_name, const std::string &time_wp, const std::string &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".