LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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 */
28 #ifndef GFRECOHITPRODUCER_H
29 #define GFRECOHITPRODUCER_H
30 
31 #include <string>
32 
33 #include "TClonesArray.h"
34 
36 
37 class GFAbsRecoHit;
38 
44 public:
48  virtual GFAbsRecoHit* produce(int index) = 0;
49  virtual ~GFAbsRecoHitProducer();
50 };
51 
74 template <class hit_T, class recoHit_T>
76 private:
78  TClonesArray* hitArrayTClones;
79  //std::vector<GFAbsRecoHit*>* hitArrayVector;
80 public:
82  GFRecoHitProducer(TClonesArray*);
83  //GFRecoHitProducer(std::vector<GFAbsRecoHit*>*);
84  virtual ~GFRecoHitProducer();
85 
89  virtual GFAbsRecoHit* produce(int index);
90 };
93 template <class hit_T, class recoHit_T>
95 {
96  hitArrayTClones = theArr;
97  //hitArrayVector = NULL;
98 }
99 /*
100 template <class hit_T,class recoHit_T>
101  GFRecoHitProducer<hit_T,recoHit_T>::GFRecoHitProducer(std::vector<GFAbsRecoHit*>* theArr) {
102  hitArrayTClones = NULL;
103  hitArrayVector = theArr;
104 }
105 */
106 
107 template <class hit_T, class recoHit_T>
109 {
110  //we dont assume ownership over the hit arrays
111 }
112 
113 template <class hit_T, class recoHit_T>
115 {
116  if (!hitArrayTClones) throw GFException("GFRecoHitProducer(): no hit set up", __LINE__, __FILE__);
117  //assert(hitArrayTClones!=NULL || hitArrayVector!=NULL);//at least one exists
118  //assert(!(hitArrayTClones!=NULL && hitArrayVector!=NULL));//but not both
119  //if(hitArrayTClones!=NULL){
120  //the ROOT guys really use 0 and not NULL grrr...
121  if (hitArrayTClones->At(index) == 0) {
122  throw GFException(
123  "In GFRecoHitProducer: index for hit in TClonesArray out of bounds", __LINE__, __FILE__)
124  .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 #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:47
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:75
GFRecoHitProducer(TClonesArray *)
Constructor takes pointer to the cluster array.