All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFRecoHitFactory.cxx
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 */
23 
24 
26 }
27 
29  clear();
30 }
31 
33  if(fHitProdMap[detID] != NULL) {
34  GFException exc("GFRecoHitFactory: detID already in use",__LINE__,__FILE__);
35  exc.setFatal();
36  std::vector<double> numbers;
37  numbers.push_back(detID);
38  exc.setNumbers("detID",numbers);
39  throw exc;
40  }
41  else {
42  fHitProdMap[detID] = hitProd;
43  }
44 }
45 
47  std::map<int, GFAbsRecoHitProducer*>::iterator it=fHitProdMap.begin();
48  while(it!=fHitProdMap.end()){
49  delete it->second;
50  ++it;
51  }
52  fHitProdMap.clear();
53 }
54 
56  if(fHitProdMap[detID] != NULL) {
57  return (genf::GFAbsRecoHit*)(fHitProdMap[detID]->produce(index));
58  }
59 
60 
61  else {
62  GFException exc("GFRecoHitFactory: no hitProducer for this detID available",__LINE__,__FILE__);
63  exc.setFatal();
64  std::vector<double> numbers;
65  numbers.push_back(detID);
66  exc.setNumbers("detID",numbers);
67  throw exc;
68  }
69 }
70 
71 std::vector<genf::GFAbsRecoHit*> genf::GFRecoHitFactory::createMany(const GFTrackCand& cand){
72  std::vector<genf::GFAbsRecoHit*> hitVec;
73  unsigned int nHits=cand.getNHits();
74  for(unsigned int i=0;i<nHits;i++) {
75  unsigned int detID;
76  unsigned int index;
77  cand.getHit(i,detID,index);
78  hitVec.push_back( createOne(detID,index) );
79  }
80  return hitVec;
81 }
GFException & setNumbers(std::string, const std::vector< double > &)
set list of numbers with description
Definition: GFException.cxx:34
GFAbsRecoHit * createOne(int detID, int index)
Create a RecoHit.
std::vector< GFAbsRecoHit * > createMany(const GFTrackCand &cand)
Creat a collection of RecoHits.
void addProducer(int detID, GFAbsRecoHitProducer *hitProd)
Register a producer module to the factory.
Abstract interface class for GFRecoHitProducer.
void getHit(unsigned int i, unsigned int &detId, unsigned int &hitId) const
Get detector ID and cluster index (hitId) for hit number i.
Definition: GFTrackCand.h:85
unsigned int getNHits() const
Definition: GFTrackCand.h:117
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:48
void clear()
Clear all hit producers.
GFException & setFatal(bool b=true)
set fatal flag. if this is true, the fit stops for this current track repr.
Definition: GFException.h:78