FairRoot/PandaRoot
Public Member Functions | Private Attributes | List of all members
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...
 

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

Constructor & Destructor Documentation

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

Definition at line 57 of file MeasurementFactory.h.

57 {};
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

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.

References genfit::Exception::setFatal(), and genfit::Exception::setNumbers().

Referenced by PndRecoDafFit2::Init(), and PndRecoKalmanFit2::Init().

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_
template<class measurement_T >
void genfit::MeasurementFactory< measurement_T >::clear ( void  )

Clear all hit producers.

Definition at line 112 of file MeasurementFactory.h.

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

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 }
std::map< int, AbsMeasurementProducer< measurement_T > * > hitProdMap_
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 138 of file MeasurementFactory.h.

References genfit::TrackCandHit::getDetId(), genfit::TrackCand::getHit(), genfit::TrackCandHit::getHitId(), genfit::TrackCand::getNHits(), hit, i, and nHits.

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 }
Int_t i
Definition: run_full.C:25
int nHits
Definition: RiemannTest.C:16
PndSdsMCPoint * hit
Definition: anasim.C:70
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 122 of file MeasurementFactory.h.

References genfit::Exception::setFatal(), and genfit::Exception::setNumbers().

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 }
std::map< int, AbsMeasurementProducer< measurement_T > * > hitProdMap_
PndSdsMCPoint * hit
Definition: anasim.C:70

Member Data Documentation

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: