SND@LHC Software
Loading...
Searching...
No Matches
genfit::MeasurementFactory< measurement_T > Class Template Reference

Factory object to create AbsMeasurement objects from digitized and clustered data. More...

#include <MeasurementFactory.h>

Public Member Functions

 MeasurementFactory ()
 
virtual ~MeasurementFactory ()
 
void addProducer (int detID, AbsMeasurementProducer< measurement_T > *hitProd)
 Register a producer module to the factory.
 
void clear ()
 Clear all hit producers.
 
measurement_T * createOne (int detID, int index, const TrackCandHit *hit) const
 Create a Measurement.
 
std::vector< measurement_T * > createMany (const TrackCand &cand) const
 Create a collection of Measurements.
 

Private Attributes

std::map< int, AbsMeasurementProducer< measurement_T > * > hitProdMap_
 

Detailed Description

template<class measurement_T>
class genfit::MeasurementFactory< measurement_T >

Factory object to create AbsMeasurement objects from digitized and clustered data.

The MeasurementFactory is used to automatically fill Track objects with hit data. For each detector type that is used, one AbsMeasurementProducer has to be registered in the factory. The factory can the use the index information from a TrackCand object to load the indexed hits into the Track.

See also
AbsMeasurementProducer
TrackCand

Definition at line 51 of file MeasurementFactory.h.

Constructor & Destructor Documentation

◆ MeasurementFactory()

template<class measurement_T >
genfit::MeasurementFactory< measurement_T >::MeasurementFactory ( )
inline

Definition at line 57 of file MeasurementFactory.h.

57{};

◆ ~MeasurementFactory()

template<class measurement_T >
virtual genfit::MeasurementFactory< measurement_T >::~MeasurementFactory ( )
inlinevirtual

Definition at line 58 of file MeasurementFactory.h.

58{ clear(); }
void clear()
Clear all hit producers.

Member Function Documentation

◆ addProducer()

template<class measurement_T >
void genfit::MeasurementFactory< measurement_T >::addProducer ( int  detID,
AbsMeasurementProducer< measurement_T > *  hitProd 
)

Register a producer module to the factory.

For each type of hit a separate producer is needed. The type of hit is identified by the detector ID (detID). This index corresponds to the detector ID that is stored in the TrackCand.

Definition at line 97 of file MeasurementFactory.h.

97 {
98 typename std::map<int, AbsMeasurementProducer<measurement_T>*>::iterator it = hitProdMap_.find(detID);
99 if(it == hitProdMap_.end()) {
100 hitProdMap_[detID] = hitProd;
101 } else {
102 Exception exc("MeasurementFactory: detID already in use",__LINE__,__FILE__);
103 exc.setFatal();
104 std::vector<double> numbers;
105 numbers.push_back(detID);
106 exc.setNumbers("detID",numbers);
107 throw exc;
108 }
109}
std::map< int, AbsMeasurementProducer< measurement_T > * > hitProdMap_

◆ clear()

template<class measurement_T >
void genfit::MeasurementFactory< measurement_T >::clear ( )

Clear all hit producers.

Definition at line 112 of file MeasurementFactory.h.

112 {
113 typename std::map<int, AbsMeasurementProducer<measurement_T>*>::iterator it=hitProdMap_.begin();
114 while(it!=hitProdMap_.end()){
115 delete it->second;
116 ++it;
117 }
118 hitProdMap_.clear();
119}

◆ createMany()

template<class measurement_T >
std::vector< measurement_T * > genfit::MeasurementFactory< measurement_T >::createMany ( const TrackCand cand) const

Create a collection of Measurements.

This is the standard way to prepare the hit collection for a Track. The resulting collection can contain hits from several detectors. The order of the hits is the same as in the TrackCand. It is assumed that this order is already along the Track.

Measurements have to implement a constructor which takes the cluster object from which the Measurement is build as the only parameter.

See also
AbsMeasurementProducer

Definition at line 138 of file MeasurementFactory.h.

138 {
139 typename std::vector<measurement_T*> hitVec;
140 unsigned int nHits=cand.getNHits();
141 for(unsigned int i=0;i<nHits;i++) {
142 int detID, index;
143 const TrackCandHit* hit = cand.getHit(i);
144 cand.getHit(i, detID, index);
145 hitVec.push_back( MeasurementFactory<measurement_T>::createOne(hit->getDetId(), hit->getHitId(), hit) );
146 }
147 return hitVec;
148}
measurement_T * createOne(int detID, int index, const TrackCandHit *hit) const
Create a Measurement.
int i
Definition ShipAna.py:86

◆ createOne()

template<class measurement_T >
measurement_T * genfit::MeasurementFactory< measurement_T >::createOne ( int  detID,
int  index,
const TrackCandHit hit 
) const

Create a Measurement.

Measurements have to implement a Constructor which takes the cluster object from which the Measurement is build as the only parameter.

See also
AbsMeasurementProducer

Definition at line 122 of file MeasurementFactory.h.

122 {
123 typename std::map<int, AbsMeasurementProducer<measurement_T>*>::const_iterator it = hitProdMap_.find(detID);
124
125 if(it != hitProdMap_.end()) {
126 return it->second->produce(index, hit);
127 } else {
128 Exception exc("MeasurementFactory: no hitProducer for this detID available",__LINE__,__FILE__);
129 exc.setFatal();
130 std::vector<double> numbers;
131 numbers.push_back(detID);
132 exc.setNumbers("detID", numbers);
133 throw exc;
134 }
135}

Member Data Documentation

◆ hitProdMap_

template<class measurement_T >
std::map<int, AbsMeasurementProducer<measurement_T>*> genfit::MeasurementFactory< measurement_T >::hitProdMap_
private

Definition at line 53 of file MeasurementFactory.h.


The documentation for this class was generated from the following file: