 |
ATLAS Offline Software
|
Go to the documentation of this file.
19 #include "GaudiKernel/SmartDataPtr.h"
20 #include "CLHEP/Units/SystemOfUnits.h"
71 static const char *
const s_linestr =
"----------------------------------------------------------------------------------------------------------------------------------------------";
72 static const char *
const s_linestr2 =
"..............................................................................................................................................";
77 m_idDictMgr (nullptr),
78 m_truthToTrack (
"Trk::TruthToTrack"),
79 m_trkSummaryTool (
"Trk::TrackSummaryTool/InDetTrackSummaryTool"),
80 m_updatorHandle (
"Trk::KalmanUpdator/TrkKalmanUpdator"),
82 m_residualPullCalculator (
"Trk::ResidualPullCalculator/ResidualPullCalculator"),
83 m_McTrackCollection_key (
"TruthEvent"),
84 m_trackSelectorTool (
"InDet::InDetDetailedTrackSelectorTool"),
85 m_UseTrackSummary (true),
86 m_printSecondary (false),
90 m_maxEtaTransition (1.6),
93 m_fakeTrackCut2 (0.7),
94 m_matchTrackCut (0.5),
95 m_maxRStartPrimary ( 25.0*
CLHEP::
mm),
96 m_maxRStartSecondary ( 360.0*
CLHEP::
mm),
97 m_maxZStartPrimary ( 200.0*
CLHEP::
mm),
98 m_maxZStartSecondary (2000.0*
CLHEP::
mm),
99 m_minREndPrimary ( 400.0*
CLHEP::
mm),
100 m_minREndSecondary (1000.0*
CLHEP::
mm),
101 m_minZEndPrimary (2300.0*
CLHEP::
mm),
103 m_minZEndSecondary (3200.0*
CLHEP::
mm),
104 m_useTrackSelection (false),
106 m_minEtaFORWARD (2.5),
107 m_maxEtaFORWARD (4.2),
109 m_events_processed (0)
118 "Measurement updator to calculate unbiased track states");
120 "Tool to calculate residuals and pulls");
162 if (sc1.isFailure()) {
164 return StatusCode::FAILURE;
168 ATH_MSG_ERROR(
"No reco track collection specified! Aborting.");
169 return StatusCode::FAILURE;
176 <<
" TrackTruthCollection keys."
177 <<
" You have to specify one TrackTruthCollection for each"
178 <<
" TrackCollection! Exiting."
180 return StatusCode::FAILURE;
187 ATH_MSG_FATAL(
"Could not retrieve measurement updator tool: "
189 return StatusCode::FAILURE;
194 "No Updator for unbiased track states given, use normal states!");
202 "No residual/pull calculator for general hit residuals configured."
205 "It is recommended to give R/P calculators to the det-specific tool"
206 <<
" handle lists then.");
209 <<
" (to calculate residuals and pulls) ");
212 ATH_MSG_INFO(
"Generic hit residuals&pulls will be calculated in one or both "
213 <<
"available local coordinates");
237 unsigned int nCollections = 0;
249 if (sc3.isFailure()) {
251 return StatusCode::FAILURE;
258 return StatusCode :: SUCCESS;
278 return StatusCode::SUCCESS;
291 std::vector <std::pair<HepMC::ConstGenParticlePtr,int> > GenSignal;
293 unsigned int inTimeStart = 0;
294 unsigned int inTimeEnd = 0;
301 ATH_MSG_ERROR(
"No reco track collection specified! Aborting.");
302 return StatusCode::FAILURE;
306 std::vector< SG::ReadHandle<TrackTruthCollection> > truth_track_collections;
309 if (truth_track_collections.size() != rec_track_collections.size()) {
310 ATH_MSG_ERROR(
"Different number of reco and truth track collections (" << rec_track_collections.size() <<
"!=" << truth_track_collections.size() <<
")" );
314 ATH_MSG_ERROR(
"Number expected reco track collections does not match the actual number of such collections ("
315 <<
m_SignalCounters.size() <<
"!=" << rec_track_collections.size() <<
")" );
318 std::vector< SG::ReadHandle<TrackCollection> >
::iterator rec_track_collections_iter = rec_track_collections.begin();
319 std::vector< SG::ReadHandle<TrackTruthCollection> >
::iterator truth_track_collections_iter = truth_track_collections.begin();
320 for (std::vector <class TrackStatHelper *>::const_iterator statHelper
323 ++statHelper, ++rec_track_collections_iter) {
324 assert( rec_track_collections_iter != rec_track_collections.end());
327 const TrackCollection * RecCollection = &(**rec_track_collections_iter);
330 if (RecCollection)
ATH_MSG_DEBUG(
"Retrieved " << RecCollection->
size() <<
" reconstructed tracks from storegate");
334 assert( truth_track_collections_iter != truth_track_collections.end());
335 TruthMap = &(**truth_track_collections_iter);
336 if (TruthMap)
ATH_MSG_DEBUG(
"Retrieved " << TruthMap->size() <<
" TrackTruth elements from storegate");
337 ++truth_track_collections_iter;
342 std::vector <const Trk::Track *> RecTracks, RecSignal;
346 " RecTracks.size()=" << RecTracks.size()
347 <<
", GenSignal.size()=" << GenSignal.size());
350 (*statHelper)->addEvent (RecCollection,
365 it < RecCollection->
end(); ++
it){
366 std::vector<const Trk::RIO_OnTrack*> rioOnTracks;
368 (*it)->measurementsOnTrack()->stdcont() );
376 return StatusCode::SUCCESS;
389 for (std::vector <class TrackStatHelper *>::const_iterator collection =
390 m_SignalCounters.begin(); collection != m_SignalCounters.end();
393 delete (*collection);
395 m_SignalCounters.clear();
396 return StatusCode::SUCCESS;
407 if (
sc.isFailure()) {
409 return StatusCode::FAILURE;
413 sc =
detStore()->retrieve(m_idHelper,
"AtlasID");
414 if (
sc.isFailure()) {
416 return StatusCode::FAILURE;
423 return StatusCode::FAILURE;
427 return StatusCode::FAILURE;
431 sc =
detStore()->retrieve(m_idDictMgr,
"IdDict");
432 if (
sc.isFailure()) {
434 return StatusCode::FAILURE;
436 const IdDictDictionary* dict = m_idDictMgr->manager()->find_dictionary(
"InnerDetector");
439 return StatusCode::FAILURE;
443 if (dict->
file_name().find(
"SLHC")!=std::string::npos) isSLHC=
true;
448 return StatusCode::FAILURE;
453 if (m_UseTrackSummary) {
454 if (m_trkSummaryTool.retrieve().isFailure() ) {
456 << m_trkSummaryTool);
457 return StatusCode::FAILURE;
462 m_trkSummaryTool.disable();
467 if (m_truthToTrack.retrieve().isFailure() ) {
469 return StatusCode::FAILURE;
474 m_truthToTrack.disable();
478 if(m_useTrackSelection){
479 if ( m_trackSelectorTool.retrieve().isFailure() ) {
480 ATH_MSG_FATAL(
"Failed to retrieve tool " << m_trackSelectorTool);
481 return StatusCode::FAILURE;
486 m_trackSelectorTool.disable();
488 return StatusCode :: SUCCESS;
491 StatusCode InDet :: InDetRecStatisticsAlg :: resetStatistics() {
493 m_events_processed = 0;
495 for (std::vector<InDet::TrackStatHelper *>::const_iterator
counter =
496 m_SignalCounters.begin();
500 return StatusCode :: SUCCESS;
504 std::vector <const Trk::Track *> & RecTracks ,
505 std::vector <const Trk::Track *> & RecSignal,
509 it != RecCollection->
end(); ++
it){
510 RecTracks.push_back(*
it);
512 (*it)->trackParameters();
514 if(!trackpara->
empty()){
518 RecSignal.push_back(*
it);
529 void InDet :: InDetRecStatisticsAlg ::
531 std::vector <std::pair<HepMC::ConstGenParticlePtr,int> > & GenSignal,
532 unsigned int ,
unsigned int ,
535 if (! SimTracks)
return;
537 unsigned int nb_mc_event = SimTracks->size();
538 std::unique_ptr<PileUpType> put = std::make_unique<PileUpType>(SimTracks);
549 for(
unsigned int ievt=0; ievt<nb_mc_event; ++ievt)
551 const HepMC::GenEvent* genEvent = SimTracks->at(ievt);
552 counter.m_counter[kN_gen_tracks_processed] += genEvent->particles_size();
553 for (
const auto&
particle: *genEvent){
559 if (std::abs(
charge)<0.5)
continue;
560 if (std::abs(
particle->momentum().perp()) > m_minPt &&
561 std::abs(
particle->momentum().pseudoRapidity()) < m_maxEta ) {
562 std::pair<HepMC::ConstGenParticlePtr,int> thisPair(
particle,ievt);
563 GenSignal.push_back(thisPair);
571 template <
class T_Stream>
575 RestoreStream(T_Stream &
out) : m_stream(&
out),m_precision(
out.precision()) { }
576 ~RestoreStream() { (*m_stream).precision(m_precision); }
583 void InDet :: InDetRecStatisticsAlg :: printStatistics() {
586 ATH_MSG_INFO(
" ********** Beginning InDetRecStatistics Statistics Table ***********");
587 ATH_MSG_INFO(
"For documentation see https://twiki.cern.ch/twiki/bin/view/Atlas/InDetRecStatistics");
588 ATH_MSG_INFO(
"(or for guaranteed latest version: http://atlas-sw.cern.ch/cgi-bin/viewcvs-atlas.cgi/offline/InnerDetector/InDetValidation/InDetRecStatistics/doc/mainpage.h?&view=markup )");
589 ATH_MSG_INFO(
" ********************************************************************");
591 std::stringstream outstr;
592 int def_precision(outstr.precision());
595 << std::setiosflags(std::ios::fixed | std::ios::showpoint)
596 << std::setw(7) << std::setprecision(2)
599 <<
"\tProcessed : " << m_events_processed
600 <<
" events, " << m_counter.m_counter[kN_rec_tracks_processed]
601 <<
" reconstructed tracks with " << m_counter.m_counter[kN_spacepoints_processed]
602 <<
" hits, and " << m_counter.m_counter[kN_gen_tracks_processed]
603 <<
" truth particles" <<
"\n"
604 <<
"\tProblem objects : " << m_counter.m_counter[kN_rec_tracks_without_perigee]
605 <<
" tracks without perigee, "
606 << m_counter.m_counter[kN_unknown_hits] <<
" unknown hits" <<
"\n"
607 <<
"\t" <<
"Reco TrackCollections : ";
609 for (std::vector <class TrackStatHelper *>::const_iterator collection =
610 m_SignalCounters.begin();
611 collection != m_SignalCounters.end(); ++collection)
619 outstr <<
"\"" << (*collection)->key() <<
"\"";
628 <<
"\t" <<
"TrackTruthCollections : ";
630 for (std::vector <class TrackStatHelper *>::const_iterator collection = m_SignalCounters.begin();
631 collection != m_SignalCounters.end(); ++collection)
639 outstr <<
"\"" << (*collection)->Truthkey() <<
"\"";
646 << s_linestr2 <<
"\n"
647 <<
"Cuts and Settings for Statistics Table" <<
"\n"
648 <<
"\t" <<
"TrackSummary Statistics" <<
"\t"
649 << (m_UseTrackSummary ?
"YES" :
"NO") <<
"\n"
650 <<
"\t" <<
"Signal \t" <<
"pT > "
651 << m_minPt/1000 <<
" GeV/c, |eta| < " << m_maxEta <<
"\t\t"
652 <<
"\t" <<
"Primary track start \t" <<
"R < "
653 << m_maxRStartPrimary <<
"mm and |z| < "
654 << m_maxZStartPrimary <<
"mm" <<
"\n"
655 <<
"\t" <<
"Barrel \t" << 0.0
656 <<
"< |eta| < " << m_maxEtaBarrel <<
"\t\t\t"
657 <<
"\t" <<
"Primary track end \t" <<
"R > "
658 << m_minREndPrimary <<
"mm or |z| > " << m_minZEndPrimary
660 <<
"\t" <<
"Transition Region \t" << m_maxEtaBarrel
661 <<
"< |eta| < " << m_maxEtaTransition <<
"\t\t\t"
662 <<
"\t" <<
"Secondary (non-Primary) start \t"
663 <<
" R < " << m_maxRStartSecondary <<
"mm and"
664 <<
" |z| < " << m_maxZStartSecondary <<
" mm" <<
"\n"
665 <<
"\t" <<
"Endcap \t" << m_maxEtaTransition
666 <<
"< |eta| < " << m_maxEtaEndcap <<
"\t\t\t"
667 <<
"\t" <<
"Secondary (non-primary) end \t"
668 <<
" R > " << m_minREndSecondary <<
"mm or"
669 <<
" |z| > " << m_minREndSecondary <<
"mm" <<
"\n"
670 <<
"\t" <<
"Forward \t"
671 <<
"|eta| > " << m_minEtaFORWARD <<
"\n"
672 <<
"\t" <<
"Low prob tracks #1 \t" <<
"< "
673 << m_fakeTrackCut <<
" of hits from single Truth Track "
675 <<
"\t" <<
"Low prob tracks #2 \t" <<
"< "
676 << m_fakeTrackCut2 <<
" of hits from single Truth Track "
678 <<
"\t" <<
"No link tracks \t Track has no link associated to an HepMC Particle" <<
"\n"
679 <<
"\t" <<
"Good reco tracks \t" <<
"> "
680 << m_matchTrackCut <<
" of hits from single Truth Track + a link !";
686 RestoreStream<MsgStream> restore(
out);
687 out <<
"\n" << s_linestr2 <<
"\n";
688 m_SignalCounters.back()->print(
out);
690 if (m_UseTrackSummary) {
693 << s_linestr2 <<
"\n"
694 <<
"Detailed Statistics for Hits on Reconstructed tracks, using TrackSummary: (Preselection of tracks as described above.)" <<
"\n"
695 << s_linestr2 <<
"\n"
696 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n"
697 <<
" Reco Tracks .........................................hits/track....................................................... " <<
"\n"
698 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n"
699 <<
" in BARREL tracks/event " << track_stummary_type_header <<
"\n"
700 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n";
704 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n"
705 <<
" in TRANSITION region tracks/event " << track_stummary_type_header <<
"\n"
706 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------"
711 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n"
712 <<
" in ENDCAP tracks/event " << track_stummary_type_header <<
"\n"
713 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n";
717 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n"
718 <<
" in FORWARD region tracks/event " << track_stummary_type_header <<
"\n"
719 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n";
723 if(m_printSecondary){
725 outstr <<
"\n" << std::setprecision(def_precision)
727 <<
"Statistics for Secondaries (non-Primaries)"<<
"\n"
728 <<
"\t" <<
"Secondary track start \t"
729 <<
" R < " << m_maxRStartSecondary <<
"mm and"
730 <<
" |z| < " << m_maxZStartSecondary <<
" mm" <<
"\n"
731 <<
"\t" <<
"Secondary track end \t"
732 <<
" R > " << m_minREndSecondary <<
"mm or"
733 <<
" |z| > " << m_minZEndSecondary <<
"mm";
736 out <<
"\n" << s_linestr2 <<
"\n";
737 m_SignalCounters.back()->printSecondary(
out);
743 ATH_MSG_INFO(
" ********** Ending InDetRecStatistics Statistics Table ***********");
749 void InDet :: InDetRecStatisticsAlg ::printTrackSummary (MsgStream &
out,
enum eta_region eta_reg)
751 bool printed = m_SignalCounters.back()->printTrackSummaryRegion(
out,
TRACK_ALL, eta_reg);
755 <<
"----------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n";
761 <<
"----------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n";
771 float InDet :: InDetRecStatisticsAlg :: calculatePull(
const float residual,
775 ErrorSum = sqrt(
pow(trkErr, 2) +
pow(hitErr, 2));
776 if (ErrorSum != 0) {
return residual/ErrorSum; }
793 if ( trkParameters->covariance() ) {
796 unbiasedTrkParameters =
801 if (!unbiasedTrkParameters) {
803 <<
"use normal parameters");
809 <<
"Unbiased track states can not be calculated "
810 <<
"(ie. pulls and residuals will be too small)");
817 return unbiasedTrkParameters;
837 <<
" can not determine detector type");
def retrieve(aClass, aKey=None)
JetConstituentVector::iterator iterator
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
Identifier getIdentifier(const Trk::MeasurementBase *measurement)
const PixelID * m_pixelID
get pixel layer from hit ID
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
const AtlasDetectorID * m_idHelper
Used to find out the sub-det from PRD->identify().
Const iterator class for DataVector/DataList.
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
@ kN_rec_tracks_processed
number of reconstructed tracks processed
static std::string getSummaryTypeHeader()
bool isNucleus(const T &p)
PDG rule 16 Nuclear codes are given as 10-digit numbers ±10LZZZAAAI.
std::atomic< bool > m_pullWarning
warn only once, if pull cannot be calculated
float m_minZEndSecondary
If track has end vertex, this is min Z of end vertex to be considered secondary.
ToolHandle< Trk::IResidualPullCalculator > m_residualPullCalculator
The residual and pull calculator tool handle.
ToolHandle< Trk::IExtendedTrackSummaryTool > m_trkSummaryTool
tool to get track summary information from track
StatusCode resetStatistics()
Clear statistics counters, called before each track collection is processed.
float m_maxRStartPrimary
Maximum R of start vertex to be considered primary.
StatusCode getServices()
Get various services such as StoreGate, dictionaries, detector managers etc.
std::atomic< bool > m_UpdatorWarning
warn only once, if unbiased track states can not be calculated
void selectGenSignal(const McEventCollection *, std::vector< std::pair< HepMC::ConstGenParticlePtr, int > > &, unsigned int, unsigned int, CounterLocal &counter) const
Select charged,stable particles which pass pt and eta cuts for analysis.
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
@ kN_rec_tracks_without_perigee
number of tracks w/o perigee
float m_minREndSecondary
If track has end vertex, this is min R of end vertex to be considered secondary.
#define ATH_MSG_VERBOSE(x)
const std::string & key() const
Return the StoreGate ID for the referenced object.
bool m_UseTrackSummary
Flag to print detailed statistics for each track collection.
const std::string & file_name() const
Access to file name.
bool m_useTrackSelection
Use track selector tool.
StatusCode execute(const EventContext &ctx) const
Calculation of statistics.
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadHandleKey< McEventCollection > m_McTrackCollection_key
void SetCuts(const struct cuts &)
Sets the cuts such as the eta regions (barrel, transition,endcap) and the hit fraction fake cuts and ...
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
virtual std::unique_ptr< TrackParameters > removeFromState(const TrackParameters &, const Amg::Vector2D &, const Amg::MatrixX &) const =0
the reverse updating or inverse KalmanFilter removes a measurement from the track state,...
bool m_printSecondary
Flag to print hit information for secondary tracks.
::StatusCode StatusCode
StatusCode definition for legacy code.
ToolHandle< Trk::IUpdator > m_updatorHandle
Tool handle of updator for unbiased states.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::atomic< long > m_events_processed
number of events processed
const SCT_ID * m_sctID
get sct layer from hit ID
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
const T * front() const
Access the first element in the collection as an rvalue.
ToolHandle< Trk::ITruthToTrack > m_truthToTrack
tool to create track parameters from a gen particle
std::vector< class TrackStatHelper * > m_SignalCounters
Vector of TrackStatHelper objects, one for each track collection.
float m_maxEta
Maximum Eta cut for tracks used by the algorithm.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
float m_matchTrackCut
Minimum number of hits from a truth track to be considered a matched reco track.
Trk::IUpdator * m_updator
updator for unbiased states
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
McEventCollection::const_iterator in_time_minimum_bias_event_begin() const
extract the in-time minimum bias McEvent Particles from the McEventCollection A pair of iterators is ...
float m_maxEtaTransition
define max eta of transition region
double pT() const
Access method for transverse momentum.
float m_minPt
Minimum Pt cut for tracks used by the algorithm.
ToolHandle< Trk::ITrackSelectorTool > m_trackSelectorTool
IdDictManager is the interface to identifier dictionaries.
double charge(const T &p)
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
float m_fakeTrackCut2
Second definition of maximum probability for which a track will be considered a fake.
float m_minZEndPrimary
If track has end vertex, this is min Z of end vertex to be considered primary.
#define ATH_MSG_WARNING(x)
float m_maxRStartSecondary
Maximum R of start vertex to be considered secondary.
McEventCollection::const_iterator in_time_minimum_bias_event_end() const
float m_maxZStartSecondary
Maximum Z of start vertex to be considered secondary.
float m_maxEtaEndcap
define max eta of eta region
StatusCode initialize()
Initialization of services, track collections, creates TrackStatHelper for each Track Collection.
Identifier identify() const
return the identifier -extends MeasurementBase
SG::ReadHandleKeyArray< TrackTruthCollection > m_TrackTruthCollection_keys
double eta() const
Access method for pseudorapidity - from momentum.
bool m_doTruth
Use truth information.
std::atomic< int > m_isUnbiased
if can get unbiased residuals
float m_maxZStartPrimary
Maximum Z of start vertex to be considered primary.
float m_fakeTrackCut
Maximum probability for which a track will be considered a fake.
float m_maxEtaBarrel
define max eta of barrel region
InDetRecStatisticsAlg(const std::string &name, ISvcLocator *pSvcLocator)
Default Constructor.
unsigned int indexOfMaxAssignProb() const
Index of the ROT with the highest assignment probability.
constexpr int pow(int base, int exp) noexcept
SG::ReadHandleKeyArray< TrackCollection > m_RecTrackCollection_keys
size_type size() const noexcept
Returns the number of elements in the collection.
const Trk::TrackParameters * getUnbiasedTrackParameters(const Trk::TrackParameters *, const Trk::MeasurementBase *)
Get Unbiased Track Parameters.
float m_minREndPrimary
If track has end vertex, this is min R of end vertex to be considered primary.
bool empty() const noexcept
Returns true if the collection is empty.
@ kN_spacepoints_processed
number of space points processed
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
void selectRecSignal(const TrackCollection *, std::vector< const Trk::Track * > &, std::vector< const Trk::Track * > &, CounterLocal &counter) const
Select for analysis reconstructed tracks passing Pt and eta cuts.