LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
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 */
20 
21 #include<iostream>
22 
23 
25 }
26 
28  clear();
29 }
30 
32  if(fHitProdMap[detID] != NULL) {
33  GFException exc("GFRecoHitFactory: detID already in use",__LINE__,__FILE__);
34  exc.setFatal();
35  std::vector<double> numbers;
36  numbers.push_back(detID);
37  exc.setNumbers("detID",numbers);
38  throw exc;
39  }
40  else {
41  fHitProdMap[detID] = hitProd;
42  }
43 }
44 
47  while(it!=fHitProdMap.end()){
48  delete it->second;
49  ++it;
50  }
51  fHitProdMap.clear();
52 }
53 
55  if(fHitProdMap[detID] != NULL) {
56  return (genf::GFAbsRecoHit*)(fHitProdMap[detID]->produce(index));
57  }
58 
59 
60  else {
61  GFException exc("GFRecoHitFactory: no hitProducer for this detID available",__LINE__,__FILE__);
62  exc.setFatal();
63  std::vector<double> numbers;
64  numbers.push_back(detID);
65  exc.setNumbers("detID",numbers);
66  throw exc;
67  }
68 }
69 
70 std::vector<genf::GFAbsRecoHit*> genf::GFRecoHitFactory::createMany(const GFTrackCand& cand){
71  std::vector<genf::GFAbsRecoHit*> hitVec;
72  unsigned int nHits=cand.getNHits();
73  for(unsigned int i=0;i<nHits;i++) {
74  unsigned int detID;
75  unsigned int index;
76  cand.getHit(i,detID,index);
77  hitVec.push_back( createOne(detID,index) );
78  }
79  return hitVec;
80 }
81 
GFException & setNumbers(std::string, const std::vector< double > &)
set list of numbers with description
Definition: GFException.cxx:32
std::map< int, GFAbsRecoHitProducer * > fHitProdMap
GFAbsRecoHit * createOne(int detID, int index)
Create a RecoHit.
intermediate_table::iterator iterator
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:84
unsigned int getNHits() const
Definition: GFTrackCand.h:116
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:50
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:80