FairRoot/PandaRoot
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 */
29 #ifndef GFRECOHITPRODUCER_H
30 #define GFRECOHITPRODUCER_H
31 
32 #include<vector>
33 #include<map>
34 #include<assert.h>
35 #include<iostream>
36 
37 #include "TClonesArray.h"
38 
39 #include "GFException.h"
40 
41 class GFAbsRecoHit;
42 
48 public:
52  virtual GFAbsRecoHit* produce(int index)=0;
53  virtual ~GFAbsRecoHitProducer();
54 };
55 
56 
79 template <class hit_T,class recoHit_T>
81  private:
83  TClonesArray* hitArrayTClones;
84  //std::vector<GFAbsRecoHit*>* hitArrayVector;
85  public:
86 
88  GFRecoHitProducer(TClonesArray*);
89  //GFRecoHitProducer(std::vector<GFAbsRecoHit*>*);
90  virtual ~GFRecoHitProducer();
91 
95  virtual GFAbsRecoHit* produce(int index);
96 };
99 template <class hit_T,class recoHit_T>
101  hitArrayTClones = theArr;
102  //hitArrayVector = NULL;
103 }
104 /*
105 template <class hit_T,class recoHit_T>
106  GFRecoHitProducer<hit_T,recoHit_T>::GFRecoHitProducer(std::vector<GFAbsRecoHit*>* theArr) {
107  hitArrayTClones = NULL;
108  hitArrayVector = theArr;
109 }
110 */
111 
112 template <class hit_T,class recoHit_T>
114  //we dont assume ownership over the hit arrays
115 }
116 
117 
118 template <class hit_T,class recoHit_T>
120  assert(hitArrayTClones!=NULL);
121  //assert(hitArrayTClones!=NULL || hitArrayVector!=NULL);//at least one exists
122  //assert(!(hitArrayTClones!=NULL && hitArrayVector!=NULL));//but not both
123  //if(hitArrayTClones!=NULL){
124  //the ROOT guys really use 0 and not NULL grrr...
125  if(hitArrayTClones->At(index) == 0) {
126  GFException e("In GFRecoHitProducer: index for hit in TClonesArray out of bounds",__LINE__,__FILE__);
127  e.setFatal();
128  throw e;
129  }
130  return ( new recoHit_T( (hit_T*) hitArrayTClones->At(index) ) );
131  //}
132  //else{//after assertions this is save: the hitArrayVector is good
133  // if(index >= hitArrayVector->size()) {
134  // GFException e("In GFRecoHitProducer: index for hit in std::vector out of bounds",__LINE__,__FILE__);
135  // e.setFatal();
136  // throw e;
137  // }
138  // return ( new recoHit_T( (hit_T*) hitArrayVector->at(index) ) );
139  //}
140 }
141 
142 
143 #endif
144 
145 
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()
Base Class for representing a Hit in GENFIT.
Definition: GFAbsRecoHit.h:73
Abstract interface class for GFRecoHitProducer.
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:45
TClonesArray * hitArrayTClones
pointer to array with cluster data
void setFatal(bool b=true)
set fatal flag. if this is true, the fit stops for this current track repr.
Definition: GFException.h:77
GFRecoHitProducer(TClonesArray *)
Constructor takes pointer to the cluster array.