LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 */
23 
25 
27 {
28  clear();
29 }
30 
32 {
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 {
49  while (it != fHitProdMap.end()) {
50  delete it->second;
51  ++it;
52  }
53  fHitProdMap.clear();
54 }
55 
57 {
58  if (fHitProdMap[detID] != NULL) {
59  return (genf::GFAbsRecoHit*)(fHitProdMap[detID]->produce(index));
60  }
61 
62  else {
63  GFException exc(
64  "GFRecoHitFactory: no hitProducer for this detID available", __LINE__, __FILE__);
65  exc.setFatal();
66  std::vector<double> numbers;
67  numbers.push_back(detID);
68  exc.setNumbers("detID", numbers);
69  throw exc;
70  }
71 }
72 
73 std::vector<genf::GFAbsRecoHit*> genf::GFRecoHitFactory::createMany(const GFTrackCand& cand)
74 {
75  std::vector<genf::GFAbsRecoHit*> hitVec;
76  unsigned int nHits = cand.getNHits();
77  for (unsigned int i = 0; i < nHits; i++) {
78  unsigned int detID;
79  unsigned int index;
80  cand.getHit(i, detID, index);
81  hitVec.push_back(createOne(detID, index));
82  }
83  return hitVec;
84 }
intermediate_table::iterator iterator
GFException & setNumbers(std::string, const std::vector< double > &)
set list of numbers with description
Definition: GFException.cxx:40
GFAbsRecoHit * createOne(int detID, int index)
Create a RecoHit.
std::map< int, GFAbsRecoHitProducer * > fHitProdMap
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:93
unsigned int getNHits() const
Definition: GFTrackCand.h:134
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:47
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:75