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