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 61 of file MeasurementFactory.h.

Constructor & Destructor Documentation

◆ MeasurementFactory()

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

Definition at line 66 of file MeasurementFactory.h.

66 {};

◆ ~MeasurementFactory()

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

Definition at line 67 of file MeasurementFactory.h.

67 { 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 104 of file MeasurementFactory.h.

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

105 {
106  typename std::map<int, AbsMeasurementProducer<measurement_T> *>::iterator it = hitProdMap_.find(detID);
107  if (it == hitProdMap_.end()) {
108  hitProdMap_[detID] = hitProd;
109  } else {
110  Exception exc("MeasurementFactory: detID already in use", __LINE__, __FILE__);
111  exc.setFatal();
112  std::vector<double> numbers;
113  numbers.push_back(detID);
114  exc.setNumbers("detID", numbers);
115  throw exc;
116  }
117 }

◆ clear()

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

Clear all hit producers.

Definition at line 120 of file MeasurementFactory.h.

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

121 {
122  typename std::map<int, AbsMeasurementProducer<measurement_T> *>::iterator it = hitProdMap_.begin();
123  while (it != hitProdMap_.end()) {
124  delete it->second;
125  ++it;
126  }
127  hitProdMap_.clear();
128 }

◆ 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 148 of file MeasurementFactory.h.

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

149 {
150  typename std::vector<measurement_T *> hitVec;
151  unsigned int nHits = cand.getNHits();
152  for (unsigned int i = 0; i < nHits; i++) {
153  int detID, index;
154  const TrackCandHit *hit = cand.getHit(i);
155  cand.getHit(i, detID, index);
156  hitVec.push_back(MeasurementFactory<measurement_T>::createOne(hit->getDetId(), hit->getHitId(), hit));
157  }
158  return hitVec;
159 }
measurement_T * createOne(int detID, int index, const TrackCandHit *hit) const
Create a Measurement.
unsigned int i
Definition: P4_F32vec4.h:33

◆ 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 131 of file MeasurementFactory.h.

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

132 {
133  typename std::map<int, AbsMeasurementProducer<measurement_T> *>::const_iterator it = hitProdMap_.find(detID);
134 
135  if (it != hitProdMap_.end()) {
136  return it->second->produce(index, hit);
137  } else {
138  Exception exc("MeasurementFactory: no hitProducer for this detID available", __LINE__, __FILE__);
139  exc.setFatal();
140  std::vector<double> numbers;
141  numbers.push_back(detID);
142  exc.setNumbers("detID", numbers);
143  throw exc;
144  }
145 }

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