![]() |
|
|||
File indexing completed on 2025-08-05 08:18:21
0001 /* Copyright 2008-2010, Technische Universitaet Muenchen, 0002 Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter 0003 0004 This file is part of GENFIT. 0005 0006 GENFIT is free software: you can redistribute it and/or modify 0007 it under the terms of the GNU Lesser General Public License as published 0008 by the Free Software Foundation, either version 3 of the License, or 0009 (at your option) any later version. 0010 0011 GENFIT is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 GNU Lesser General Public License for more details. 0015 0016 You should have received a copy of the GNU Lesser General Public License 0017 along with GENFIT. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 /** @addtogroup genfit 0021 * @{ 0022 */ 0023 0024 #ifndef genfit_MeasurementProducer_h 0025 #define genfit_MeasurementProducer_h 0026 0027 #include "Exception.h" 0028 #include "TrackCand.h" 0029 0030 #include <assert.h> 0031 #include <TClonesArray.h> 0032 0033 0034 namespace genfit { 0035 0036 class AbsMeasurement; 0037 0038 /** @brief Abstract interface class for MeasurementProducer 0039 * 0040 * Defines the very basic interface of a producer. 0041 */ 0042 template <class measurement_T> 0043 class AbsMeasurementProducer { 0044 public: 0045 /** @brief Virtual abstract method to produce a Measurement. 0046 * Implemented in MeasurementProducer 0047 */ 0048 virtual measurement_T* produce(int index, const TrackCandHit* hit) = 0; 0049 virtual ~AbsMeasurementProducer() {}; 0050 }; 0051 0052 0053 /** @brief Template class for a measurement producer module 0054 * 0055 * A MeasurementProducer module is used by MeasurementFactory to create Measurements for 0056 * one specific detector type. 0057 * 0058 * It is assumed that each detector has as output of its digitization / 0059 * clustering some sort of hit or cluster class which stores all information that 0060 * corresponds to a measured hit in that detector. The MeasurementProducer 0061 * converts this information into a class that can be handled by genfit. 0062 * This class is realized as a Measurement (a class inheriting from AbsMeasurement). 0063 * 0064 * In order to use the MeasurementProducer facility, a 0065 * Measurement has to implement a constructor which takes as an argument 0066 * a pointer to the cluster class and a TrackCandHit. This constructor serves as the initializing 0067 * constructor for the Measurement. 0068 * 0069 * The MeasurementProducer will fetch the cluster objects from a TClonesArray and 0070 * use the initializing constructor to build the corresponding Measurement. 0071 * 0072 * @param hit_t template parameter specifying hit/cluster class 0073 * @param measurement_T template parameter specifying Measurement 0074 */ 0075 template <class hit_T, class measurement_T> 0076 class MeasurementProducer : public AbsMeasurementProducer<genfit::AbsMeasurement> { 0077 private: 0078 /** @brief pointer to array with cluster data */ 0079 TClonesArray* hitArrayTClones_; 0080 0081 public: 0082 /** @brief Constructor takes pointer to the hit array */ 0083 explicit MeasurementProducer(TClonesArray*); 0084 virtual ~MeasurementProducer(); 0085 0086 /** @brief Create a Measurement from the cluster at position index 0087 * in TClonesArray 0088 */ 0089 virtual AbsMeasurement* produce(int index, const TrackCandHit* hit); 0090 }; 0091 0092 0093 template <class hit_T, class measurement_T> 0094 MeasurementProducer<hit_T, measurement_T>::MeasurementProducer(TClonesArray* theArr) { 0095 hitArrayTClones_ = theArr; 0096 //std::cout << "hit array with " << hitArrayTClones_->GetEntries() << " entries." << std::endl; 0097 } 0098 0099 template <class hit_T, class measurement_T> 0100 MeasurementProducer<hit_T, measurement_T>::~MeasurementProducer() { 0101 // we don't assume ownership over the hit arrays 0102 } 0103 0104 template <class hit_T, class measurement_T> 0105 AbsMeasurement* MeasurementProducer<hit_T, measurement_T>::produce(int index, const TrackCandHit* hit) { 0106 assert(hitArrayTClones_ != nullptr); 0107 //std::cout << "hit array with " << hitArrayTClones_->GetEntries() << " entries, looking for entry " << index << "." << std::endl; 0108 if(hitArrayTClones_->At(index) == 0) { 0109 Exception e("In MeasurementProducer: index for hit in TClonesArray out of bounds",__LINE__,__FILE__); 0110 e.setFatal(); 0111 throw e; 0112 } 0113 return ( new measurement_T( (hit_T*) hitArrayTClones_->At(index), hit ) ); 0114 } 0115 0116 0117 } /* End of namespace genfit */ 0118 /** @} */ 0119 0120 #endif // genfit_MeasurementProducer_h
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |