EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeasurementProducer.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MeasurementProducer.h
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 
34 namespace genfit {
35 
36 class AbsMeasurement;
37 
42 template <class measurement_T>
44 public:
48  virtual measurement_T* produce(int index, const TrackCandHit* hit) = 0;
50 };
51 
52 
75 template <class hit_T, class measurement_T>
76 class MeasurementProducer : public AbsMeasurementProducer<genfit::AbsMeasurement> {
77  private:
79  TClonesArray* hitArrayTClones_;
80 
81  public:
83  MeasurementProducer(TClonesArray*);
84  virtual ~MeasurementProducer();
85 
89  virtual AbsMeasurement* produce(int index, const TrackCandHit* hit);
90 };
91 
92 
93 template <class hit_T, class measurement_T>
95  hitArrayTClones_ = theArr;
96  //std::cout << "hit array with " << hitArrayTClones_->GetEntries() << " entries." << std::endl;
97 }
98 
99 template <class hit_T, class measurement_T>
101  // we don't assume ownership over the hit arrays
102 }
103 
104 template <class hit_T, class measurement_T>
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 
117 } /* End of namespace genfit */
120 #endif // genfit_MeasurementProducer_h