EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFRecoHitProducer.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GFRecoHitProducer.h
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 GFAbsRecoHit* produce(int index, void *ptr = 0) = 0;
54  virtual ~GFAbsRecoHitProducer();
55 };
56 
57 
80 template <class hit_T,class recoHit_T>
82  private:
84  TClonesArray* hitArrayTClones;
85  //std::vector<GFAbsRecoHit*>* hitArrayVector;
86  public:
87 
89  GFRecoHitProducer(TClonesArray*);
90  //GFRecoHitProducer(std::vector<GFAbsRecoHit*>*);
91  virtual ~GFRecoHitProducer();
92 
96  virtual GFAbsRecoHit* produce(int index, void *ptr = 0);
97 };
100 template <class hit_T,class recoHit_T>
102  hitArrayTClones = theArr;
103  //hitArrayVector = NULL;
104 }
105 /*
106 template <class hit_T,class recoHit_T>
107  GFRecoHitProducer<hit_T,recoHit_T>::GFRecoHitProducer(std::vector<GFAbsRecoHit*>* theArr) {
108  hitArrayTClones = NULL;
109  hitArrayVector = theArr;
110 }
111 */
112 
113 template <class hit_T,class recoHit_T>
115  //we dont assume ownership over the hit arrays
116 }
117 
118 
119 template <class hit_T,class recoHit_T>
121  assert(hitArrayTClones!=NULL);
122  //assert(hitArrayTClones!=NULL || hitArrayVector!=NULL);//at least one exists
123  //assert(!(hitArrayTClones!=NULL && hitArrayVector!=NULL));//but not both
124  //if(hitArrayTClones!=NULL){
125  //the ROOT guys really use 0 and not NULL grrr...
126  if(hitArrayTClones->At(index) == 0) {
127  GFException e("In GFRecoHitProducer: index for hit in TClonesArray out of bounds",__LINE__,__FILE__);
128  e.setFatal();
129  throw e;
130  }
131  return ( new recoHit_T( (hit_T*) hitArrayTClones->At(index), ptr) );
132  //}
133  //else{//after assertions this is save: the hitArrayVector is good
134  // if(index >= hitArrayVector->size()) {
135  // GFException e("In GFRecoHitProducer: index for hit in std::vector out of bounds",__LINE__,__FILE__);
136  // e.setFatal();
137  // throw e;
138  // }
139  // return ( new recoHit_T( (hit_T*) hitArrayVector->at(index) ) );
140  //}
141 }
142 
143 
144 #endif
145 
146