EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFRecoHitFactory.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GFRecoHitFactory.cxx
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 */
19 #include "GFRecoHitFactory.h"
20 
21 #include<iostream>
22 
23 
25 }
26 
28  clear();
29 }
30 
31 void GFRecoHitFactory::addProducer(int detID, GFAbsRecoHitProducer* hitProd, void *ptr) {
32  if(fHitProdMap[detID].first != 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] = std::pair<GFAbsRecoHitProducer*, void*>(hitProd, ptr);
42  }
43 }
44 
46  std::map<int, std::pair<GFAbsRecoHitProducer*, void*> >::iterator it=fHitProdMap.begin();
47  while(it!=fHitProdMap.end()){
48  delete it->second.first;
49  ++it;
50  }
51  fHitProdMap.clear();
52 }
53 
54 GFAbsRecoHit* GFRecoHitFactory::createOne(int detID, int index) {
55  if(fHitProdMap[detID].first != NULL) {
56  return fHitProdMap[detID].first->produce(index, fHitProdMap[detID].second);
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<GFAbsRecoHit*> GFRecoHitFactory::createMany(const GFTrackCand& cand){
71  std::vector<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