|
ATLAS Offline Software
|
Go to the documentation of this file.
19 #include "GaudiKernel/SmartDataPtr.h"
20 #include "CLHEP/Units/SystemOfUnits.h"
69 static const char *
const s_linestr =
"----------------------------------------------------------------------------------------------------------------------------------------------";
70 static const char *
const s_linestr2 =
"..............................................................................................................................................";
75 m_idDictMgr (nullptr),
76 m_truthToTrack (
"Trk::TruthToTrack"),
77 m_trkSummaryTool (
"Trk::TrackSummaryTool/InDetTrackSummaryTool"),
78 m_updatorHandle (
"Trk::KalmanUpdator/TrkKalmanUpdator"),
80 m_residualPullCalculator (
"Trk::ResidualPullCalculator/ResidualPullCalculator"),
81 m_McTrackCollection_key (
"TruthEvent"),
82 m_trackSelectorTool (
"InDet::InDetDetailedTrackSelectorTool"),
83 m_UseTrackSummary (true),
84 m_printSecondary (false),
88 m_maxEtaTransition (1.6),
91 m_fakeTrackCut2 (0.7),
92 m_matchTrackCut (0.5),
93 m_maxRStartPrimary ( 25.0*
CLHEP::
mm),
94 m_maxRStartSecondary ( 360.0*
CLHEP::
mm),
95 m_maxZStartPrimary ( 200.0*
CLHEP::
mm),
96 m_maxZStartSecondary (2000.0*
CLHEP::
mm),
97 m_minREndPrimary ( 400.0*
CLHEP::
mm),
98 m_minREndSecondary (1000.0*
CLHEP::
mm),
99 m_minZEndPrimary (2300.0*
CLHEP::
mm),
101 m_minZEndSecondary (3200.0*
CLHEP::
mm),
102 m_useTrackSelection (false),
104 m_minEtaFORWARD (2.5),
105 m_maxEtaFORWARD (4.2),
107 m_events_processed (0)
116 "Measurement updator to calculate unbiased track states");
118 "Tool to calculate residuals and pulls");
160 if (sc1.isFailure()) {
162 return StatusCode::FAILURE;
166 ATH_MSG_ERROR(
"No reco track collection specified! Aborting.");
167 return StatusCode::FAILURE;
174 <<
" TrackTruthCollection keys."
175 <<
" You have to specify one TrackTruthCollection for each"
176 <<
" TrackCollection! Exiting."
178 return StatusCode::FAILURE;
185 ATH_MSG_FATAL(
"Could not retrieve measurement updator tool: "
187 return StatusCode::FAILURE;
192 "No Updator for unbiased track states given, use normal states!");
200 "No residual/pull calculator for general hit residuals configured."
203 "It is recommended to give R/P calculators to the det-specific tool"
204 <<
" handle lists then.");
207 <<
" (to calculate residuals and pulls) ");
210 ATH_MSG_INFO(
"Generic hit residuals&pulls will be calculated in one or both "
211 <<
"available local coordinates");
235 unsigned int nCollections = 0;
247 if (sc3.isFailure()) {
249 return StatusCode::FAILURE;
256 return StatusCode :: SUCCESS;
276 return StatusCode::SUCCESS;
289 std::vector <std::pair<HepMC::ConstGenParticlePtr,int> > GenSignal;
291 unsigned int inTimeStart = 0;
292 unsigned int inTimeEnd = 0;
299 ATH_MSG_ERROR(
"No reco track collection specified! Aborting.");
300 return StatusCode::FAILURE;
304 std::vector< SG::ReadHandle<TrackTruthCollection> > truth_track_collections;
307 if (truth_track_collections.size() != rec_track_collections.size()) {
308 ATH_MSG_ERROR(
"Different number of reco and truth track collections (" << rec_track_collections.size() <<
"!=" << truth_track_collections.size() <<
")" );
312 ATH_MSG_ERROR(
"Number expected reco track collections does not match the actual number of such collections ("
313 <<
m_SignalCounters.size() <<
"!=" << rec_track_collections.size() <<
")" );
316 std::vector< SG::ReadHandle<TrackCollection> >
::iterator rec_track_collections_iter = rec_track_collections.begin();
317 std::vector< SG::ReadHandle<TrackTruthCollection> >
::iterator truth_track_collections_iter = truth_track_collections.begin();
318 for (std::vector <class TrackStatHelper *>::const_iterator statHelper
321 ++statHelper, ++rec_track_collections_iter) {
322 assert( rec_track_collections_iter != rec_track_collections.end());
325 const TrackCollection * RecCollection = &(**rec_track_collections_iter);
328 if (RecCollection)
ATH_MSG_DEBUG(
"Retrieved " << RecCollection->
size() <<
" reconstructed tracks from storegate");
332 assert( truth_track_collections_iter != truth_track_collections.end());
333 TruthMap = &(**truth_track_collections_iter);
334 if (TruthMap)
ATH_MSG_DEBUG(
"Retrieved " << TruthMap->size() <<
" TrackTruth elements from storegate");
335 ++truth_track_collections_iter;
340 std::vector <const Trk::Track *> RecTracks, RecSignal;
344 " RecTracks.size()=" << RecTracks.size()
345 <<
", GenSignal.size()=" << GenSignal.size());
348 (*statHelper)->addEvent (RecCollection,
363 it < RecCollection->
end(); ++
it){
364 std::vector<const Trk::RIO_OnTrack*> rioOnTracks;
366 (*it)->measurementsOnTrack()->stdcont() );
374 return StatusCode::SUCCESS;
387 for (std::vector <class TrackStatHelper *>::const_iterator collection =
388 m_SignalCounters.begin(); collection != m_SignalCounters.end();
391 delete (*collection);
393 m_SignalCounters.clear();
394 return StatusCode::SUCCESS;
405 if (
sc.isFailure()) {
407 return StatusCode::FAILURE;
411 sc =
detStore()->retrieve(m_idHelper,
"AtlasID");
412 if (
sc.isFailure()) {
414 return StatusCode::FAILURE;
421 return StatusCode::FAILURE;
425 return StatusCode::FAILURE;
429 sc =
detStore()->retrieve(m_idDictMgr,
"IdDict");
430 if (
sc.isFailure()) {
432 return StatusCode::FAILURE;
434 const IdDictDictionary* dict = m_idDictMgr->manager()->find_dictionary(
"InnerDetector");
437 return StatusCode::FAILURE;
441 if (dict->
file_name().find(
"SLHC")!=std::string::npos) isSLHC=
true;
446 return StatusCode::FAILURE;
451 if (m_UseTrackSummary) {
452 if (m_trkSummaryTool.retrieve().isFailure() ) {
454 << m_trkSummaryTool);
455 return StatusCode::FAILURE;
460 m_trkSummaryTool.disable();
465 if (m_truthToTrack.retrieve().isFailure() ) {
467 return StatusCode::FAILURE;
472 m_truthToTrack.disable();
476 if(m_useTrackSelection){
477 if ( m_trackSelectorTool.retrieve().isFailure() ) {
478 ATH_MSG_FATAL(
"Failed to retrieve tool " << m_trackSelectorTool);
479 return StatusCode::FAILURE;
484 m_trackSelectorTool.disable();
486 return StatusCode :: SUCCESS;
489 StatusCode InDet :: InDetRecStatisticsAlg :: resetStatistics() {
491 m_events_processed = 0;
493 for (std::vector<InDet::TrackStatHelper *>::const_iterator
counter =
494 m_SignalCounters.begin();
498 return StatusCode :: SUCCESS;
502 std::vector <const Trk::Track *> & RecTracks ,
503 std::vector <const Trk::Track *> & RecSignal,
507 it != RecCollection->
end(); ++
it){
508 RecTracks.push_back(*
it);
510 (*it)->trackParameters();
512 if(!trackpara->
empty()){
516 RecSignal.push_back(*
it);
527 void InDet :: InDetRecStatisticsAlg ::
529 std::vector <std::pair<HepMC::ConstGenParticlePtr,int> > & GenSignal,
530 unsigned int ,
unsigned int ,
533 if (! SimTracks)
return;
535 unsigned int nb_mc_event = SimTracks->size();
536 std::unique_ptr<PileUpType> put = std::make_unique<PileUpType>(SimTracks);
547 for(
unsigned int ievt=0; ievt<nb_mc_event; ++ievt)
549 const HepMC::GenEvent* genEvent = SimTracks->at(ievt);
550 counter.m_counter[kN_gen_tracks_processed] += genEvent->particles_size();
551 for (
const auto&
particle: *genEvent){
557 if (std::abs(
charge)<0.5)
continue;
558 if (std::abs(
particle->momentum().perp()) > m_minPt &&
559 std::abs(
particle->momentum().pseudoRapidity()) < m_maxEta ) {
560 std::pair<HepMC::ConstGenParticlePtr,int> thisPair(
particle,ievt);
561 GenSignal.push_back(thisPair);
569 template <
class T_Stream>
573 RestoreStream(T_Stream &
out) : m_stream(&
out),m_precision(
out.precision()) { }
574 ~RestoreStream() { (*m_stream).precision(m_precision); }
581 void InDet :: InDetRecStatisticsAlg :: printStatistics() {
582 if (!msgLvl(MSG::INFO))
return;
584 ATH_MSG_INFO(
" ********** Beginning InDetRecStatistics Statistics Table ***********");
585 ATH_MSG_INFO(
"For documentation see https://twiki.cern.ch/twiki/bin/view/Atlas/InDetRecStatistics");
586 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 )");
587 ATH_MSG_INFO(
" ********************************************************************");
589 std::stringstream outstr;
590 int def_precision(outstr.precision());
593 << std::setiosflags(std::ios::fixed | std::ios::showpoint)
594 << std::setw(7) << std::setprecision(2)
597 <<
"\tProcessed : " << m_events_processed
598 <<
" events, " << m_counter.m_counter[kN_rec_tracks_processed]
599 <<
" reconstructed tracks with " << m_counter.m_counter[kN_spacepoints_processed]
600 <<
" hits, and " << m_counter.m_counter[kN_gen_tracks_processed]
601 <<
" truth particles" <<
"\n"
602 <<
"\tProblem objects : " << m_counter.m_counter[kN_rec_tracks_without_perigee]
603 <<
" tracks without perigee, "
604 << m_counter.m_counter[kN_unknown_hits] <<
" unknown hits" <<
"\n"
605 <<
"\t" <<
"Reco TrackCollections : ";
607 for (std::vector <class TrackStatHelper *>::const_iterator collection =
608 m_SignalCounters.begin();
609 collection != m_SignalCounters.end(); ++collection)
617 outstr <<
"\"" << (*collection)->key() <<
"\"";
626 <<
"\t" <<
"TrackTruthCollections : ";
628 for (std::vector <class TrackStatHelper *>::const_iterator collection = m_SignalCounters.begin();
629 collection != m_SignalCounters.end(); ++collection)
637 outstr <<
"\"" << (*collection)->Truthkey() <<
"\"";
644 << s_linestr2 <<
"\n"
645 <<
"Cuts and Settings for Statistics Table" <<
"\n"
646 <<
"\t" <<
"TrackSummary Statistics" <<
"\t"
647 << (m_UseTrackSummary ?
"YES" :
"NO") <<
"\n"
648 <<
"\t" <<
"Signal \t" <<
"pT > "
649 << m_minPt/1000 <<
" GeV/c, |eta| < " << m_maxEta <<
"\t\t"
650 <<
"\t" <<
"Primary track start \t" <<
"R < "
651 << m_maxRStartPrimary <<
"mm and |z| < "
652 << m_maxZStartPrimary <<
"mm" <<
"\n"
653 <<
"\t" <<
"Barrel \t" << 0.0
654 <<
"< |eta| < " << m_maxEtaBarrel <<
"\t\t\t"
655 <<
"\t" <<
"Primary track end \t" <<
"R > "
656 << m_minREndPrimary <<
"mm or |z| > " << m_minZEndPrimary
658 <<
"\t" <<
"Transition Region \t" << m_maxEtaBarrel
659 <<
"< |eta| < " << m_maxEtaTransition <<
"\t\t\t"
660 <<
"\t" <<
"Secondary (non-Primary) start \t"
661 <<
" R < " << m_maxRStartSecondary <<
"mm and"
662 <<
" |z| < " << m_maxZStartSecondary <<
" mm" <<
"\n"
663 <<
"\t" <<
"Endcap \t" << m_maxEtaTransition
664 <<
"< |eta| < " << m_maxEtaEndcap <<
"\t\t\t"
665 <<
"\t" <<
"Secondary (non-primary) end \t"
666 <<
" R > " << m_minREndSecondary <<
"mm or"
667 <<
" |z| > " << m_minREndSecondary <<
"mm" <<
"\n"
668 <<
"\t" <<
"Forward \t"
669 <<
"|eta| > " << m_minEtaFORWARD <<
"\n"
670 <<
"\t" <<
"Low prob tracks #1 \t" <<
"< "
671 << m_fakeTrackCut <<
" of hits from single Truth Track "
673 <<
"\t" <<
"Low prob tracks #2 \t" <<
"< "
674 << m_fakeTrackCut2 <<
" of hits from single Truth Track "
676 <<
"\t" <<
"No link tracks \t Track has no link associated to an HepMC Particle" <<
"\n"
677 <<
"\t" <<
"Good reco tracks \t" <<
"> "
678 << m_matchTrackCut <<
" of hits from single Truth Track + a link !";
682 MsgStream &
out =
msg(MSG::INFO);
684 RestoreStream<MsgStream> restore(
out);
685 out <<
"\n" << s_linestr2 <<
"\n";
686 m_SignalCounters.back()->print(
out);
688 if (m_UseTrackSummary) {
691 << s_linestr2 <<
"\n"
692 <<
"Detailed Statistics for Hits on Reconstructed tracks, using TrackSummary: (Preselection of tracks as described above.)" <<
"\n"
693 << s_linestr2 <<
"\n"
694 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n"
695 <<
" Reco Tracks .........................................hits/track....................................................... " <<
"\n"
696 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n"
697 <<
" in BARREL tracks/event " << track_stummary_type_header <<
"\n"
698 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n";
702 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n"
703 <<
" in TRANSITION region tracks/event " << track_stummary_type_header <<
"\n"
704 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------"
709 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n"
710 <<
" in ENDCAP tracks/event " << track_stummary_type_header <<
"\n"
711 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n";
715 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n"
716 <<
" in FORWARD region tracks/event " << track_stummary_type_header <<
"\n"
717 <<
"----------------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n";
721 if(m_printSecondary){
723 outstr <<
"\n" << std::setprecision(def_precision)
725 <<
"Statistics for Secondaries (non-Primaries)"<<
"\n"
726 <<
"\t" <<
"Secondary track start \t"
727 <<
" R < " << m_maxRStartSecondary <<
"mm and"
728 <<
" |z| < " << m_maxZStartSecondary <<
" mm" <<
"\n"
729 <<
"\t" <<
"Secondary track end \t"
730 <<
" R > " << m_minREndSecondary <<
"mm or"
731 <<
" |z| > " << m_minZEndSecondary <<
"mm";
734 out <<
"\n" << s_linestr2 <<
"\n";
735 m_SignalCounters.back()->printSecondary(
out);
741 ATH_MSG_INFO(
" ********** Ending InDetRecStatistics Statistics Table ***********");
747 void InDet :: InDetRecStatisticsAlg ::printTrackSummary (MsgStream &
out,
enum eta_region eta_reg)
749 bool printed = m_SignalCounters.back()->printTrackSummaryRegion(
out,
TRACK_ALL, eta_reg);
753 <<
"----------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n";
759 <<
"----------------------------------------------------------------------------------------------------------------------------------------------" <<
"\n";
769 float InDet :: InDetRecStatisticsAlg :: calculatePull(
const float residual,
773 ErrorSum = sqrt(
pow(trkErr, 2) +
pow(hitErr, 2));
774 if (ErrorSum != 0) {
return residual/ErrorSum; }
791 if ( trkParameters->covariance() ) {
794 unbiasedTrkParameters =
799 if (!unbiasedTrkParameters) {
801 <<
"use normal parameters");
807 <<
"Unbiased track states can not be calculated "
808 <<
"(ie. pulls and residuals will be too small)");
815 return unbiasedTrkParameters;
835 <<
" 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)
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.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
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.
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.
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 ...
const std::string & file_name(void) const
Access to file name.
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.
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.