19 #include "GaudiKernel/MsgStream.h"
29 declareInterface<MuonTrackStatisticsTool>(
this);
37 return StatusCode::SUCCESS;
47 return StatusCode::SUCCESS;
53 for (; counterTruth_it != counterTruth_itEnd; ++counterTruth_it) {
57 return StatusCode::SUCCESS;
64 if (TruthMap.empty())
return StatusCode::SUCCESS;
67 DetailedTrackTruthCollection::const_iterator it_start = TruthMap.begin();
68 DetailedTrackTruthCollection::const_iterator it_end = TruthMap.end();
69 DetailedTrackTruthCollection::const_iterator
it = it_start;
72 for (
it = it_start;
it != it_end; ++
it) {
98 <<
"Index: " << (*it).first.index() <<
" " << (*it).second
99 <<
" (Pixel, SCT, TRT, MDT, RPC, TGC, CSC) ");
101 for (
unsigned int i = 0;
i < (*it).second.trajectory().
size();
i++) {
103 if (!(*it).second.trajectory().at(
i).cptr()) {
104 ATH_MSG_DEBUG(
" has a null pointer: " << (*it).second.trajectory().at(
i).cptr());
106 ATH_MSG_DEBUG(
" - pdg_id: " << (*it).second.trajectory().at(
i).cptr()->pdg_id());
107 ATH_MSG_DEBUG(
" - status: " << (*it).second.trajectory().at(
i).cptr()->status());
113 return StatusCode::SUCCESS;
120 for (; counter_it != counter_itEnd; ++counter_it) {
124 return StatusCode::SUCCESS;
131 if (tracks.
empty())
return StatusCode::SUCCESS;
137 for (;
it != it_end; ++
it) {
139 if (!
track->trackSummary() || !
track->trackSummary()->muonTrackSummary())
continue;
142 double chi2dof = ((*it)->fitQuality()->chiSquared()) / ((*it)->fitQuality()->doubleNumberDoF());
152 return StatusCode::SUCCESS;
156 TString temp_string(trkLoc);
158 if (temp_string.Contains(
"Truth") &&
m_doTruth) {
159 ATH_MSG_INFO(
"MuonTrackStatisticsTool calling addTrackCounters for truth: " << trkLoc);
163 }
else if (!temp_string.Contains(
"Truth")) {
164 ATH_MSG_INFO(
"MuonTrackStatisticsTool calling addTrackCounters for reco: " << trkLoc);
173 std::ostringstream sout;
175 std::vector<MuonTrackStatisticsTool::TrackCounters*>::const_iterator counter_it =
m_allCounters.begin();
176 std::vector<MuonTrackStatisticsTool::TrackCounters*>::const_iterator counter_itEnd =
m_allCounters.end();
177 std::vector<MuonTrackStatisticsTool::TruthTrackCounters*>::const_iterator truthcounter_it_start =
m_allTruthCounters.begin();
178 std::vector<MuonTrackStatisticsTool::TruthTrackCounters*>::const_iterator truthcounter_itEnd =
m_allTruthCounters.end();
179 std::vector<MuonTrackStatisticsTool::TruthTrackCounters*>::const_iterator truthcounter_it =
m_allTruthCounters.begin();
190 for (; counter_it != counter_itEnd; ++counter_it) {
191 if ((*counter_it)->nEvents != 0 && (*counter_it)->nTracks != 0) {
192 trksPerEvent = (
double)(*counter_it)->nTracks / (*counter_it)->nEvents;
193 hitsPerTrk = (
double)(*counter_it)->nHits / (*counter_it)->nTracks;
194 etaPerTrk = (
double)(*counter_it)->nEtaHits / (*counter_it)->nTracks;
195 tetaPerTrk = (
double)(*counter_it)->nEtaTrig / (*counter_it)->nTracks;
196 phiPerTrk = (
double)(*counter_it)->nPhiHits / (*counter_it)->nTracks;
197 scatPerTrk = (
double)(*counter_it)->nScatter / (*counter_it)->nTracks;
198 holePerTrk = (
double)(*counter_it)->nHoles / (*counter_it)->nTracks;
199 chi2PerTrk = (*counter_it)->summedchi2 / (*counter_it)->nTracks;
212 int TruthTrackCounter = -1;
213 double trksPerTrtrk = -1;
216 for (truthcounter_it = truthcounter_it_start; truthcounter_it != truthcounter_itEnd; ++truthcounter_it) {
219 TruthTrackCounter = (*truthcounter_it)->nTracks;
220 ATH_MSG_INFO(
"MuonTrackStatisticsTool - Found matching TruthCollection for: " << (*counter_it)->trackLocation);
224 if (TruthTrackCounter == 0 && (*counter_it)->nTracks == 0) {
226 }
else if (TruthTrackCounter == 0 && (*counter_it)->nTracks != 0) {
229 trksPerTrtrk = (
double)(*counter_it)->nTracks / (
double)TruthTrackCounter;
234 ATH_MSG_INFO(
"MuonTrackStatisticsTool - Could not find matching TruthCollection for: " << (*counter_it)->trackLocation);
237 sout <<
">>>> MuonTrackStatisticsAlg Summary: Track Container = " << (*counter_it)->trackLocation << std::endl;
238 sout <<
"----------------------------------------------------------------------------------------------------------------------"
241 sout <<
"|| Events || Tracks || Trk/Evt || Hit/Trk || Eta/Trk ||"
242 <<
" TrigEta/T || Phi/Trk || Scat/Tk || Hole/Tk || Ch2/dof/T || Trks/TruthT ||" << std::endl;
244 sout <<
"|| " << std::setw(7) << (*counter_it)->nEvents <<
" || " << std::setw(7) << (*counter_it)->nTracks <<
" || "
245 << std::setw(7) << trksPerEvent <<
" || " << std::setw(7) << hitsPerTrk <<
" || " << std::setw(7) << etaPerTrk <<
" || "
246 << std::setw(9) << tetaPerTrk <<
" || " << std::setw(7) << phiPerTrk <<
" || " << std::setw(7) << scatPerTrk <<
" || "
247 << std::setw(7) << holePerTrk <<
" || " << std::setw(9) << chi2PerTrk <<
" || " << std::setw(11) <<
"NOT DEFINED"
248 <<
" || " << std::endl;
249 sout <<
"----------------------------------------------------------------------------------------------------------------------"
252 sout << std::endl << std::endl;
253 }
else if (trksPerTrtrk < 0 && !
m_doTruth) {
256 sout <<
">>>> MuonTrackStatisticsAlg Summary: Track Container = " << (*counter_it)->trackLocation << std::endl;
257 sout <<
"--------------------------------------------------------------------------------------------------------------------"
259 sout <<
"|| Events || Tracks || Trk/Evt || Hit/Trk || Eta/Trk ||"
260 <<
" TrigEta/T || Phi/Trk || Scat/Tk || Hole/Tk || Ch2/dof/T ||" << std::endl;
262 sout <<
"|| " << std::setw(7) << (*counter_it)->nEvents <<
" || " << std::setw(7) << (*counter_it)->nTracks <<
" || "
263 << std::setw(7) << trksPerEvent <<
" || " << std::setw(7) << hitsPerTrk <<
" || " << std::setw(7) << etaPerTrk <<
" || "
264 << std::setw(9) << tetaPerTrk <<
" || " << std::setw(7) << phiPerTrk <<
" || " << std::setw(7) << scatPerTrk <<
" || "
265 << std::setw(7) << holePerTrk <<
" || " << std::setw(9) << chi2PerTrk <<
" || " << std::endl;
266 sout <<
"--------------------------------------------------------------------------------------------------------------------"
268 sout << std::endl << std::endl;
272 sout <<
">>>> MuonTrackStatisticsAlg Summary: Track Container = " << (*counter_it)->trackLocation << std::endl;
273 sout <<
"----------------------------------------------------------------------------------------------------------------------"
276 sout <<
"|| Events || Tracks || Trk/Evt || Hit/Trk || Eta/Trk ||"
277 <<
" TrigEta/T || Phi/Trk || Scat/Tk || Hole/Tk || Ch2/dof/T || Trks/TruthT ||" << std::endl;
279 sout <<
"|| " << std::setw(7) << (*counter_it)->nEvents <<
" || " << std::setw(7) << (*counter_it)->nTracks <<
" || "
280 << std::setw(7) << trksPerEvent <<
" || " << std::setw(7) << hitsPerTrk <<
" || " << std::setw(7) << etaPerTrk <<
" || "
281 << std::setw(9) << tetaPerTrk <<
" || " << std::setw(7) << phiPerTrk <<
" || " << std::setw(7) << scatPerTrk <<
" || "
282 << std::setw(7) << holePerTrk <<
" || " << std::setw(9) << chi2PerTrk <<
" || " << std::setw(11) << trksPerTrtrk <<
" || "
284 sout <<
"----------------------------------------------------------------------------------------------------------------------"
287 sout << std::endl << std::endl;
292 for (truthcounter_it = truthcounter_it_start; truthcounter_it != truthcounter_itEnd; ++truthcounter_it) {
293 double TruthTrksPerEvent;
294 double PIXELhitsPerTrk;
295 double SCThitsPerTrk;
296 double TRThitsPerTrk;
297 double MDThitsPerTrk;
298 double RPChitsPerTrk;
299 double TGChitsPerTrk;
300 double CSChitsPerTrk;
303 sout <<
">>>> MuonTrackStatisticsAlg Summary: Track Container = " << (*truthcounter_it)->trackLocation << std::endl;
304 for (
unsigned int i = 0;
i < 3;
i++) {
305 if ((*truthcounter_it)->nEvents != 0 && (*truthcounter_it)->nTracks != 0) {
306 TruthTrksPerEvent = (
double)(*truthcounter_it)->nTracks / (*truthcounter_it)->nEvents;
307 PIXELhitsPerTrk = (
double)(*truthcounter_it)->nPIXELhits[
i] / (*truthcounter_it)->nTracks;
308 SCThitsPerTrk = (
double)(*truthcounter_it)->nSCThits[
i] / (*truthcounter_it)->nTracks;
309 TRThitsPerTrk = (
double)(*truthcounter_it)->nTRThits[
i] / (*truthcounter_it)->nTracks;
310 MDThitsPerTrk = (
double)(*truthcounter_it)->nMDThits[
i] / (*truthcounter_it)->nTracks;
311 RPChitsPerTrk = (
double)(*truthcounter_it)->nRPChits[
i] / (*truthcounter_it)->nTracks;
312 TGChitsPerTrk = (
double)(*truthcounter_it)->nTGChits[
i] / (*truthcounter_it)->nTracks;
313 CSChitsPerTrk = (
double)(*truthcounter_it)->nCSChits[
i] / (*truthcounter_it)->nTracks;
316 TruthTrksPerEvent = 0;
327 sout <<
"------------------------------------------------------------------------------------------------------------------"
328 "----------------------------"
331 sout <<
"-------------------------------------------------------->>>> SubDetStat is COMMON "
332 "<<<<--------------------------------------------------------"
335 sout <<
"-------------------------------------------------------->>>> SubDetStat is ONTRUTH "
336 "<<<<-------------------------------------------------------"
339 sout <<
"-------------------------------------------------------->>>> SubDetStat is ONTRACK "
340 "<<<<-------------------------------------------------------"
342 sout <<
"------------------------------------------------------------------------------------------------------------------"
343 "----------------------------"
345 sout <<
"|| Events || Tracks || Trk/Evt || PIXELhits/Trk || SCThits/Trk ||"
346 <<
" TRThits/Trk || MDThits/Trk || RPChits/Trk || TGChits/Trk || CSChits/Trk ||" << std::endl;
348 sout <<
"|| " << std::setw(7) << (*truthcounter_it)->nEvents <<
" || " << std::setw(7) << (*truthcounter_it)->nTracks
349 <<
" || " << std::setw(7) << TruthTrksPerEvent <<
" || " << std::setw(13) << PIXELhitsPerTrk <<
" || " << std::setw(11)
350 << SCThitsPerTrk <<
" || " << std::setw(11) << TRThitsPerTrk <<
" || " << std::setw(11) << MDThitsPerTrk <<
" || "
351 << std::setw(11) << RPChitsPerTrk <<
" || " << std::setw(11) << TGChitsPerTrk <<
" || " << std::setw(11)
352 << CSChitsPerTrk <<
" || " << std::endl;
355 sout <<
"----------------------------------------------------------------------------------------------------------------------"
356 "------------------------"
358 sout << std::endl << std::endl;