PandaRoot
MeasurementProducer.h
Go to the documentation of this file.
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
24 #ifndef genfit_MeasurementProducer_h
25 #define genfit_MeasurementProducer_h
26 
27 #include "Exception.h"
28 #include "TrackCand.h"
29 
30 #include <assert.h>
31 #include <TClonesArray.h>
32 
33 namespace genfit {
34 
35 class AbsMeasurement;
36 
41 template <class measurement_T>
43  public:
47  virtual measurement_T *produce(int index, const TrackCandHit *hit) = 0;
49 };
50 
73 template <class hit_T, class measurement_T>
74 class MeasurementProducer : public AbsMeasurementProducer<genfit::AbsMeasurement> {
75  private:
77  TClonesArray *hitArrayTClones_;
78 
79  public:
81  MeasurementProducer(TClonesArray *);
82  virtual ~MeasurementProducer();
83 
87  virtual AbsMeasurement *produce(int index, const TrackCandHit *hit);
88 };
89 
90 template <class hit_T, class measurement_T>
92 {
93  hitArrayTClones_ = theArr;
94  // std::cout << "hit array with " << hitArrayTClones_->GetEntries() << " entries." << std::endl;
95 }
96 
97 template <class hit_T, class measurement_T>
99 {
100  // we don't assume ownership over the hit arrays
101 }
102 
103 template <class hit_T, class measurement_T>
105 {
106  assert(hitArrayTClones_ != nullptr);
107  // std::cout << "hit array with " << hitArrayTClones_->GetEntries() << " entries, looking for entry " << index << "." << std::endl;
108  if (hitArrayTClones_->At(index) == 0) {
109  Exception e("In MeasurementProducer: index for hit in TClonesArray out of bounds", __LINE__, __FILE__);
110  e.setFatal();
111  throw e;
112  }
113  return (new measurement_T((hit_T *)hitArrayTClones_->At(index), hit));
114 }
115 
116 } /* End of namespace genfit */
119 #endif // genfit_MeasurementProducer_h
Abstract interface class for MeasurementProducer.
Hit object for use in TrackCand. Provides IDs and sorting parameters.
Definition: TrackCandHit.h:33
virtual AbsMeasurement * produce(int index, const TrackCandHit *hit)
Create a Measurement from the cluster at position index in TClonesArray.
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: Exception.h:47
MeasurementProducer(TClonesArray *)
Constructor takes pointer to the hit array.
Contains the measurement and covariance in raw detector coordinates.
void setFatal(bool b=true)
Set fatal flag.
Definition: Exception.h:60
virtual measurement_T * produce(int index, const TrackCandHit *hit)=0
Virtual abstract method to produce a Measurement. Implemented in MeasurementProducer.
Template class for a measurement producer module.
Matrix inversion tools.
Definition: AbsBField.h:28