PandaRoot
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. More...
 
void clear ()
 Clear all hit producers. More...
 
measurement_T * createOne (int detID, int index, const TrackCandHit *hit) const
 Create a Measurement. More...
 
std::vector< measurement_T * > createMany (const TrackCand &cand) const
 Create a collection of Measurements. More...
 

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 used an AbsMeasurementProducer has to be registered in the factory. The factory can then use the index information from a TrackCand object to load the indexed hits into the Track.

See also
AbsMeasurementProducer
TrackCand

Definition at line 49 of file MeasurementFactory.h.

Constructor & Destructor Documentation

◆ MeasurementFactory()

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

Definition at line 54 of file MeasurementFactory.h.

54 {};

◆ ~MeasurementFactory()

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

Definition at line 55 of file MeasurementFactory.h.

55 { 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 92 of file MeasurementFactory.h.

Referenced by genfit::MeasurementFactory< genfit::AbsMeasurement >::~MeasurementFactory().

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

◆ clear()

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

Clear all hit producers.

Definition at line 108 of file MeasurementFactory.h.

Referenced by genfit::MeasurementFactory< genfit::AbsMeasurement >::~MeasurementFactory().

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

◆ 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 built as the only parameter.

See also
AbsMeasurementProducer

Definition at line 136 of file MeasurementFactory.h.

Referenced by genfit::MeasurementFactory< genfit::AbsMeasurement >::~MeasurementFactory().

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

◆ 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 built as the only parameter.

See also
AbsMeasurementProducer

Definition at line 119 of file MeasurementFactory.h.

Referenced by genfit::MeasurementFactory< genfit::AbsMeasurement >::~MeasurementFactory().

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

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