GFRecoHitProducer.h
Go to the documentation of this file.
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert
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 /** @addtogroup genfit
20  * @{ */
21 
22 
23 /**
24  * @author Christian H&ouml;ppner (Technische Universit&auml;t M&uuml;nchen, original author)
25  * @author Sebastian Neubert (Technische Universit&auml;t M&uuml;nchen, original author)
26  *
27  */
28 
29 #ifndef GFRECOHITPRODUCER_H
30 #define GFRECOHITPRODUCER_H
31 
32 #include <string>
33 
34 #include "TClonesArray.h"
35 
37 
38 class GFAbsRecoHit;
39 
40 /** @brief Abstract interface class for GFRecoHitProducer
41  *
42  * Defines the very basic interface of a producer.
43  */
45 public:
46  /** @brief Virtual abstract method to produce a RecoHit.
47  * Implemented in GFRecoHitProducer
48  */
49  virtual GFAbsRecoHit* produce(int index)=0;
50  virtual ~GFAbsRecoHitProducer();
51 };
52 
53 
54 /** @brief Template class for a hit producer module
55  *
56  * A GFRecoHitProducer module is used by RecoHitFactory to create RecoHits for
57  * one specific detector type.
58  *
59  * It is assumed that each detector has as output of its digitization /
60  * clustering some sort of cluster class which stores all information that
61  * corresponds to a measured hit in that detector. The RecoHit producer
62  * converts this information into a class that can be handled by genfit.
63  * This class is realized as a RecoHit (a class inherting from GFAbsRecoHit).
64  *
65  * In order to use the GFRecoHitProducer facility a
66  * RecoHit has to implement a constructor which takes as an argument
67  * a pointer to the cluster class. This constructor serves as the initializing
68  * constructor for the RecoHit.
69  *
70  * The GFRecoHitProducer will fetch the cluster objects from a TClonesArray and
71  * use the initializing constructor to build the corresponding RecoHit.
72  *
73  * @param hit_t template parameter specifying cluster class
74  * @param recoHit_t template parameter specifying recoHit
75  */
76 template <class hit_T,class recoHit_T>
78  private:
79  /** @brief pointer to array with cluster data */
80  TClonesArray* hitArrayTClones;
81  //std::vector<GFAbsRecoHit*>* hitArrayVector;
82  public:
83 
84  /** @brief Constructor takes pointer to the cluster array */
85  GFRecoHitProducer(TClonesArray*);
86  //GFRecoHitProducer(std::vector<GFAbsRecoHit*>*);
87  virtual ~GFRecoHitProducer();
88 
89  /** @brief Create a RecoHit from the cluster at position index
90  * in TClonesArray
91  */
92  virtual GFAbsRecoHit* produce(int index);
93 };
94 /** @} */
95 
96 template <class hit_T,class recoHit_T>
98  hitArrayTClones = theArr;
99  //hitArrayVector = NULL;
100 }
101 /*
102 template <class hit_T,class recoHit_T>
103  GFRecoHitProducer<hit_T,recoHit_T>::GFRecoHitProducer(std::vector<GFAbsRecoHit*>* theArr) {
104  hitArrayTClones = NULL;
105  hitArrayVector = theArr;
106 }
107 */
108 
109 template <class hit_T,class recoHit_T>
111  //we dont assume ownership over the hit arrays
112 }
113 
114 
115 template <class hit_T,class recoHit_T>
117  if (!hitArrayTClones)
118  throw GFException("GFRecoHitProducer(): no hit set up", __LINE__, __FILE__);
119  //assert(hitArrayTClones!=NULL || hitArrayVector!=NULL);//at least one exists
120  //assert(!(hitArrayTClones!=NULL && hitArrayVector!=NULL));//but not both
121  //if(hitArrayTClones!=NULL){
122  //the ROOT guys really use 0 and not NULL grrr...
123  if(hitArrayTClones->At(index) == 0) {
124  throw GFException("In GFRecoHitProducer: index for hit in TClonesArray out of bounds",__LINE__,__FILE__).setFatal();
125  }
126  return ( new recoHit_T( (hit_T*) hitArrayTClones->At(index) ) );
127  //}
128  //else{//after assertions this is save: the hitArrayVector is good
129  // if(index >= hitArrayVector->size()) {
130  // GFException e("In GFRecoHitProducer: index for hit in std::vector out of bounds",__LINE__,__FILE__);
131  // e.setFatal();
132  // throw e;
133  // }
134  // return ( new recoHit_T( (hit_T*) hitArrayVector->at(index) ) );
135  //}
136 }
137 
138 
139 #endif
virtual GFAbsRecoHit * produce(int index)=0
Virtual abstract method to produce a RecoHit. Implemented in GFRecoHitProducer.
virtual GFAbsRecoHit * produce(int index)
Create a RecoHit from the cluster at position index in TClonesArray.
Template class for a hit producer module.
virtual ~GFRecoHitProducer()
Abstract interface class for GFRecoHitProducer.
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:48
TClonesArray * hitArrayTClones
pointer to array with cluster data
GFException & setFatal(bool b=true)
set fatal flag. if this is true, the fit stops for this current track repr.
Definition: GFException.h:78
GFRecoHitProducer(TClonesArray *)
Constructor takes pointer to the cluster array.