PandaRoot
MeasurementProducer.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /* Copyright 2008-2010, Technische Universitaet Muenchen,
14  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter
15 
16  This file is part of GENFIT.
17 
18  GENFIT is free software: you can redistribute it and/or modify
19  it under the terms of the GNU Lesser General Public License as published
20  by the Free Software Foundation, either version 3 of the License, or
21  (at your option) any later version.
22 
23  GENFIT is distributed in the hope that it will be useful,
24  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  GNU Lesser General Public License for more details.
27 
28  You should have received a copy of the GNU Lesser General Public License
29  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
30 */
31 
36 #ifndef genfit_MeasurementProducer_h
37 #define genfit_MeasurementProducer_h
38 
39 #include "Exception.h"
40 #include "TrackCand.h"
41 
42 #include <assert.h>
43 #include <TClonesArray.h>
44 
45 namespace genfit {
46 
47 class AbsMeasurement;
48 
53 template <class measurement_T>
55  public:
59  virtual measurement_T *produce(int index, const TrackCandHit *hit) = 0;
61 };
62 
85 template <class hit_T, class measurement_T>
86 class MeasurementProducer : public AbsMeasurementProducer<genfit::AbsMeasurement> {
87  private:
89  TClonesArray *hitArrayTClones_;
90 
91  public:
93  MeasurementProducer(TClonesArray *);
94  virtual ~MeasurementProducer();
95 
99  virtual AbsMeasurement *produce(int index, const TrackCandHit *hit);
100 };
101 
102 template <class hit_T, class measurement_T>
104 {
105  hitArrayTClones_ = theArr;
106  // std::cout << "hit array with " << hitArrayTClones_->GetEntries() << " entries." << std::endl;
107 }
108 
109 template <class hit_T, class measurement_T>
111 {
112  // we don't assume ownership over the hit arrays
113 }
114 
115 template <class hit_T, class measurement_T>
117 {
118  assert(hitArrayTClones_ != nullptr);
119  // std::cout << "hit array with " << hitArrayTClones_->GetEntries() << " entries, looking for entry " << index << "." << std::endl;
120  if (hitArrayTClones_->At(index) == 0) {
121  Exception e("In MeasurementProducer: index for hit in TClonesArray out of bounds", __LINE__, __FILE__);
122  e.setFatal();
123  throw e;
124  }
125  return (new measurement_T((hit_T *)hitArrayTClones_->At(index), hit));
126 }
127 
128 } /* End of namespace genfit */
131 #endif // genfit_MeasurementProducer_h
Abstract interface class for MeasurementProducer.
Hit object for use in TrackCand. Provides IDs and sorting parameters.
Definition: TrackCandHit.h:45
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:59
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:72
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:40