Commit 43057214 authored by Niels Van Eldik's avatar Niels Van Eldik Committed by Graeme Stewart
Browse files

correctly initialize all vectors (MuonTrackFindingEvent-01-00-01)

parent 3dc8cf84
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MUPATCANDIDATEBASE_H
#define MUPATCANDIDATEBASE_H
#include "TrkParameters/TrackParameters.h"
#include <vector>
#include <set>
#include "MuonIdHelpers/MuonStationIndex.h"
#include "Identifier/Identifier.h"
#include "MuonTrackFindingEvent/MuPatHit.h"
namespace Trk {
class MeasurementBase;
}
namespace Muon {
/**
@brief track candidate entry object.
The purpose of the class is to provide a common interface for tracks and segments.
It give access to:
- the eta hits
- the phi hits
- the fake phi hits (PseudoMeasurements)
- the all hits
- the MuPatHitList (order listed used to sort the hits)
- a set with hamber Identifier on the track
- a set of chamber layers on the track
- a set of station layers on the track
- a flag whether the track/segment has a measured momentum
- number of mdt hits in the first multi layer
- number of mdt hits in the second multi layer
- number of csc eta hits
- number of csc phi hits
- number of rpc eta hits
- number of rpc phi hits
- number of tgc eta hits
- number of tgc phi hits
- a flag whether the candidate has endcap hits
- a flag whether the candidate has small chambers
- a flag whether the candidate has large chambers
- a flag whether the candidate has a small/large overlap
*/
class MuPatCandidateBase {
friend class MuPatCandidateTool;
public:
typedef std::vector<const Trk::MeasurementBase*> MeasVec;
typedef std::set<MuonStationIndex::ChIndex>::iterator chamber_iterator;
typedef std::set<MuonStationIndex::ChIndex>::const_iterator const_chamber_iterator;
typedef std::set<MuonStationIndex::StIndex>::iterator station_iterator;
typedef std::set<MuonStationIndex::StIndex>::const_iterator const_station_iterator;
public:
/** @brief constructor. */
MuPatCandidateBase();
/** @brief constructor. The constructor takes ownership of the entryPars but not of the hits. */
MuPatCandidateBase( const MeasVec& etaHits, const MeasVec& phiHits, const MeasVec& fakePhiHits, const MeasVec& allHits );
/** @brief destructor. */
virtual ~MuPatCandidateBase();
/** @brief return all eta hits on the entry */
const MeasVec& etaHits() const;
/** @brief return all phi hits on the entry */
const MeasVec& phiHits() const;
/** @brief return all fake phi hits on the entry */
const MeasVec& fakePhiHits() const;
/** @brief return all hits on the entry. (Does not including the fake phi hits) */
const MeasVec& hits() const;
/** @brief returns whether entry contains a small chamber */
bool hasSmallChamber() const;
/** @brief returns whether entry contains a small chamber */
bool hasLargeChamber() const;
/** @brief returns whether there is at least one small/large overlap in the same station layer */
bool hasSLOverlap() const;
/** @brief return track parameters representing the entry */
virtual const Trk::TrackParameters& entryPars() const = 0;
/** @brief returns whether the entry contains endcap hits */
bool hasEndcap() const;
/** @brief set whether entry has endcap hits */
void hasEndcap(bool hasEC);
/** @brief returns whether entry has a momentum measurement */
bool hasMomentum() const;
/** @brief returns set with contained stationIndices */
const std::set<MuonStationIndex::StIndex>& stations() const;
/** @brief returns set with contained chamberIndices */
const std::set<MuonStationIndex::ChIndex>& chambers() const;
/** @brief returns whether the ChamberIndex is already contained in candidate */
bool containsChamber( MuonStationIndex::ChIndex chIndex ) const;
/** @brief returns whether the StationIndex is already contained in candidate */
bool containsStation( MuonStationIndex::StIndex chIndex ) const;
/** @brief returns a reference to the hit list */
const MuPatHitList& hitList() const { return m_hitList; }
/** @brief returns set with contained chamber ids */
const std::set<Identifier>& chamberIds() const;
/** @brief checks whether the two entries contain the same chamber */
bool shareChambers( const MuPatCandidateBase& entry ) const;
protected:
// all non-const functions protected, only accessible by derived classes and MCTBEntryHandler and MuPatHitHandler
/** @brief set whether entry has at least one small/large overlap in the same station layer */
void hasSLOverlap(bool hasSL);
/** @brief set whether entry has small chamber */
void hasSmallChamber(bool hasSmall);
/** @brief set whether entry has large chamber */
void hasLargeChamber(bool hasLarge);
/** @brief set eta hits on the entry */
void setEtaHits( const MeasVec& hits);
/** @brief set phi hits on the entry */
void setPhiHits( const MeasVec& hits);
/** @brief set fake phi hits on the entry */
void setFakePhiHits( const MeasVec& hits);
/** @brief set all hits on the entry */
void setAllHits( const MeasVec& hits);
/** @brief returns a reference to the hit list */
MuPatHitList& hitList() { return m_hitList; }
/** @brief returns set with contained chamber ids */
std::set<Identifier>& chamberIds();
/** @brief clear the list of contained chambers. Will also clear the list of contained stations and list of chamber Ids. */
void clearChambers();
/** @brief add the chamber to the list of contained chambers. Will also add the corresponding station. */
void addChamber( MuonStationIndex::ChIndex chIndex );
/** Set the list of chambers and update list of stations */
void setChambers( const std::set<MuonStationIndex::ChIndex>& chambers );
private:
MeasVec m_etaHits; //<! vector containing all eta measurements
MeasVec m_phiHits; //<! vector containing all phi measurements
MeasVec m_fakePhiHits; //<! vector containing all fake phi measurements
MeasVec m_allHits; //<! vector containing all measurements (except fake phi measurements)
MuPatHitList m_hitList;
std::set<Identifier> m_chamberIds; //<! set to store chamber Ids of hits associated with candidate
protected:
std::set<MuonStationIndex::ChIndex> m_chambers; //<! set to store chamber indices of segments associated with candidate
std::set<MuonStationIndex::StIndex> m_stations; //<! set to store station indices of segments associated with candidate
bool m_hasMomentum;
public:
/** public hit counters */
unsigned int nmdtHitsMl1;
unsigned int nmdtHitsMl2;
unsigned int ncscHitsEta;
unsigned int ncscHitsPhi;
unsigned int nrpcHitsEta;
unsigned int nrpcHitsPhi;
unsigned int ntgcHitsEta;
unsigned int ntgcHitsPhi;
private:
bool m_hasEndcap;
bool m_hasSmallChamber;
bool m_hasLargeChamber;
bool m_hasSLOverlap;
};
inline const std::set<MuonStationIndex::StIndex>& MuPatCandidateBase::stations() const {
return m_stations;
}
inline const std::set<MuonStationIndex::ChIndex>& MuPatCandidateBase::chambers() const {
return m_chambers;
}
inline const std::set<Identifier>& MuPatCandidateBase::chamberIds() const {
return m_chamberIds;
}
/** @brief returns set with contained chamber ids */
inline std::set<Identifier>& MuPatCandidateBase::chamberIds() {
return m_chamberIds;
}
inline void MuPatCandidateBase::addChamber( MuonStationIndex::ChIndex chIndex ) {
m_chambers.insert( chIndex );
m_stations.insert( MuonStationIndex::toStationIndex(chIndex) );
}
inline bool MuPatCandidateBase::hasSmallChamber() const {
return m_hasSmallChamber;
}
inline bool MuPatCandidateBase::hasLargeChamber() const {
return m_hasLargeChamber;
}
inline bool MuPatCandidateBase::hasSLOverlap() const {
return m_hasSLOverlap;
}
inline void MuPatCandidateBase::hasSmallChamber(bool hasSmall) {
m_hasSmallChamber = hasSmall;
}
inline void MuPatCandidateBase::hasLargeChamber(bool hasLarge) {
m_hasLargeChamber = hasLarge;
}
inline void MuPatCandidateBase::hasSLOverlap(bool hasSL) {
m_hasSLOverlap = hasSL;
}
inline const MuPatCandidateBase::MeasVec& MuPatCandidateBase::MuPatCandidateBase::etaHits() const {
return m_etaHits;
}
inline const MuPatCandidateBase::MeasVec& MuPatCandidateBase::phiHits() const {
return m_phiHits;
}
inline const MuPatCandidateBase::MeasVec& MuPatCandidateBase::fakePhiHits() const {
return m_fakePhiHits;
}
inline const MuPatCandidateBase::MeasVec& MuPatCandidateBase::hits() const {
return m_allHits;
}
inline void MuPatCandidateBase::setEtaHits( const MuPatCandidateBase::MeasVec& hits) {
m_etaHits = hits;
}
inline void MuPatCandidateBase::setPhiHits( const MuPatCandidateBase::MeasVec& hits) {
m_phiHits = hits;
}
inline void MuPatCandidateBase::setFakePhiHits( const MuPatCandidateBase::MeasVec& hits) {
m_fakePhiHits = hits;
}
inline void MuPatCandidateBase::setAllHits( const MuPatCandidateBase::MeasVec& hits) {
m_allHits = hits;
}
inline bool MuPatCandidateBase::hasEndcap() const { return m_hasEndcap; }
inline void MuPatCandidateBase::hasEndcap(bool hasEC) { m_hasEndcap = hasEC; }
inline bool MuPatCandidateBase::containsChamber( MuonStationIndex::ChIndex chIndex ) const {
return m_chambers.find(chIndex) != m_chambers.end();
}
inline bool MuPatCandidateBase::containsStation( MuonStationIndex::StIndex stIndex ) const {
return m_stations.find(stIndex) != m_stations.end();
}
inline void MuPatCandidateBase::clearChambers() {
m_chambers.clear();
m_stations.clear();
m_chamberIds.clear();
}
inline bool MuPatCandidateBase::hasMomentum() const {
return m_hasMomentum;
}
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MUPATHIT_H
#define MUPATHIT_H
#include "Identifier/Identifier.h"
#include "TrkParameters/TrackParameters.h"
#include <list>
namespace Trk {
class MeasurementBase;
class ResidualPull;
}
namespace Muon {
class MuPatHit {
public:
enum Type { UnknownType = -1, MDT = 0, RPC = 1, TGC = 2, CSC = 3, PREC = 4, Pseudo = 5, Scatterer = 6 };
enum Status { UnknownStatus = -1, OnTrack = 0, Outlier, NotOnTrack };
enum HitSelection { UnknownSelection = -1, Precise = 0, Broad = 1 };
struct Info {
Info() : id(),measuresPhi(false),type(UnknownType),selection(UnknownSelection),status(UnknownStatus) {}
Identifier id;
bool measuresPhi;
Type type;
HitSelection selection;
Status status;
};
/** @brief construction taking all members as argument, ownership is taken only of the broadMeas.
@param pars predicted TrackParameters at the surface of the measurement
@param presMeas precisely calibrated measurement
@param broadMeas measurement with enlarged errors
@param presResPull residual and pull of the hit for the precise measurement
@param broadResPull residual and pull of the hit for the broad measurement
@param id Hit Identifier (can be invalid (Pseudos), user should check validity)
@param type Hit type enum
@param measuresPhi boolean indicating whether this is an eta or phi measurement
@param used enum indicating the hit status
*/
MuPatHit( const Trk::TrackParameters* pars, const Trk::MeasurementBase* presMeas, const Trk::MeasurementBase* broadMeas,
const Info& info );
/** @brief copy constructor */
MuPatHit( const MuPatHit& hit );
/** assignment operator */
MuPatHit& operator=( const MuPatHit& );
/** destructor */
~MuPatHit();
/** @brief returns a reference to the TrackParameters */
const Trk::TrackParameters& parameters() const;
/** @brief returns a reference to the selected measurement */
const Trk::MeasurementBase& measurement() const;
/** @brief returns a reference to the hit info */
const Info& info() const;
/** @brief returns a reference to the hit info */
Info& info();
/** @brief clones the MuPatHit */
MuPatHit* clone() const { return new MuPatHit(*this); }
/** @brief returns precise measurement */
const Trk::MeasurementBase& preciseMeasurement() const;
/** @brief returns broad measurement */
const Trk::MeasurementBase& broadMeasurement() const;
/** @brief update the track parameters and residual of a MuPatHit */
void updateParameters( const Trk::TrackParameters* pars );
/** @brief reset the maximum number of objects counter */
static void resetMaxNumberOfInstantiations();
/** @brief maximum number of objects of this type in memory */
static unsigned int maxNumberOfInstantiations();
/** current number of objects of this type in memory */
static unsigned int numberOfInstantiations();
/** @brief reset the copy constructor counter */
static void resetNumberOfCopies();
/** @brief number of times the copy constructor was called since last reset */
static unsigned int numberOfCopies();
private:
//
// private static functions
//
/** @brief Keeping track of number of object instances */
static void addInstance();
/** @brief Keeping track of number of object instances */
static void removeInstance();
//
// private static data members
//
static unsigned int s_numberOfInstantiations; //<! current number of objects of this type in memory
static unsigned int s_maxNumberOfInstantiations; //<! maximum number of objects of this type in memory
static unsigned int s_numberOfCopies; //<! number of times the copy constructor was called since last reset
//
// private member functions
//
/** no default constructor */
MuPatHit() : m_pars(0),m_precisionMeas(0),m_broadMeas(0) { }
/** @brief clean memory */
void cleanUp();
/** @brief copy hit */
void copy( const MuPatHit& hit );
// private member data
const Trk::TrackParameters* m_pars;
const Trk::MeasurementBase* m_precisionMeas;
const Trk::MeasurementBase* m_broadMeas;
Info m_info;
}; // class MuPatHit
/**
List of MuPatHit pointers.
*/
typedef std::list<MuPatHit*> MuPatHitList;
typedef MuPatHitList::const_iterator MuPatHitCit;
typedef MuPatHitList::iterator MuPatHitIt;
//
// static inline functions implementations
//
inline unsigned int MuPatHit::numberOfInstantiations() {
return s_numberOfInstantiations;
}
inline unsigned int MuPatHit::maxNumberOfInstantiations() {
return s_maxNumberOfInstantiations;
}
inline unsigned int MuPatHit::numberOfCopies() {
return s_numberOfCopies;
}
inline void MuPatHit::addInstance() {
++s_numberOfInstantiations;
if ( s_numberOfInstantiations > s_maxNumberOfInstantiations ) {
s_maxNumberOfInstantiations = s_numberOfInstantiations;
}
}
inline void MuPatHit::removeInstance() {
if ( s_numberOfInstantiations > 0 ) --s_numberOfInstantiations;
}
//
// inline member functions implementations
//
inline const Trk::TrackParameters& MuPatHit::parameters() const { return *m_pars; }
inline const Trk::MeasurementBase& MuPatHit::measurement() const {
if( info().selection == Precise ) return *m_precisionMeas;
return *m_broadMeas;
}
inline const Trk::MeasurementBase& MuPatHit::preciseMeasurement() const { return *m_precisionMeas; }
inline const Trk::MeasurementBase& MuPatHit::broadMeasurement() const { return *m_broadMeas; }
inline const MuPatHit::Info& MuPatHit::info() const { return m_info; }
inline MuPatHit::Info& MuPatHit::info() { return m_info; }
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MUPATSEGMENT_H
#define MUPATSEGMENT_H
#include "MuonTrackFindingEvent/MuPatCandidateBase.h"
#include "Identifier/Identifier.h"
#include "MuonSegment/MuonSegment.h"
#include "MuonSegment/MuonSegmentQuality.h"
#include "MuonIdHelpers/MuonStationIndex.h"
#include "TrkParameters/TrackParameters.h"
#include <set>
namespace Muon {
class MuPatTrack;
/**
@brief segment candidate object.
The purpose of the segment candidate is three folded:
- provide the generic MuPatCandidateBase interface for tracks
- keep track of tracks the segment is accociated to
- cache additional information that cannot be stored on the track
The following information is cached:
- the segment quality integer calculated by the MuonSegmentSelectionTool
- the MuonSegmentQuality
- a AtaPlane that represents the segment and allows extrapolation
- the index of the segment in the order list of segments in the track steering cache
- an integer (usedInFit) showing on how many track candidates the segment is included
- the identifier of the chamber with most hits on the segment
- a string summarizing the segment that can be used for dumping it to screen
- a chamber index
- a station index
- a flag indicating whether the segment is in the barrel or endcap
- a flag indicating whether the segment contains MDT hits
*/
class MuPatSegment : public MuPatCandidateBase {
public:
MuPatSegment();
~MuPatSegment();
MuPatSegment( const MuPatSegment& info );
MuPatSegment& operator=( const MuPatSegment& info );
int quality;
const MuonSegmentQuality* segQuality;
const MuonSegment* segment;
const Trk::AtaPlane* segPars;
int segmentIndex; //!< index of segment within station
int usedInFit;
Identifier chid;