PandaRoot
GFRecoHitProducer.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /* Copyright 2008-2010, Technische Universitaet Muenchen,
14  Authors: Christian Hoeppner & Sebastian Neubert
15 
16  This file is part of GENFIT.
17 
18  GENFIT is free software: you can redistribute it and/or modify
19  it under the terms of the GNU Lesser General Public License as published
20  by the Free Software Foundation, either version 3 of the License, or
21  (at your option) any later version.
22 
23  GENFIT is distributed in the hope that it will be useful,
24  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  GNU Lesser General Public License for more details.
27 
28  You should have received a copy of the GNU Lesser General Public License
29  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
30 */
40 #ifndef GFRECOHITPRODUCER_H
41 #define GFRECOHITPRODUCER_H
42 
43 #include <vector>
44 #include <map>
45 #include <assert.h>
46 #include <iostream>
47 
48 #include "TClonesArray.h"
49 
50 #include "GFException.h"
51 
52 class GFAbsRecoHit;
53 
59  public:
63  virtual GFAbsRecoHit *produce(int index) = 0;
64  virtual ~GFAbsRecoHitProducer();
65 };
66 
89 template <class hit_T, class recoHit_T>
91  private:
93  TClonesArray *hitArrayTClones;
94  // std::vector<GFAbsRecoHit*>* hitArrayVector;
95  public:
97  GFRecoHitProducer(TClonesArray *);
98  // GFRecoHitProducer(std::vector<GFAbsRecoHit*>*);
99  virtual ~GFRecoHitProducer();
100 
104  virtual GFAbsRecoHit *produce(int index);
105 };
108 template <class hit_T, class recoHit_T>
110 {
111  hitArrayTClones = theArr;
112  // hitArrayVector = nullptr;
113 }
114 /*
115 template <class hit_T,class recoHit_T>
116  GFRecoHitProducer<hit_T,recoHit_T>::GFRecoHitProducer(std::vector<GFAbsRecoHit*>* theArr) {
117  hitArrayTClones = nullptr;
118  hitArrayVector = theArr;
119 }
120 */
121 
122 template <class hit_T, class recoHit_T>
124 {
125  // we dont assume ownership over the hit arrays
126 }
127 
128 template <class hit_T, class recoHit_T>
130 {
131  assert(hitArrayTClones != nullptr);
132  // assert(hitArrayTClones!=nullptr || hitArrayVector!=nullptr);//at least one exists
133  // assert(!(hitArrayTClones!=nullptr && hitArrayVector!=nullptr));//but not both
134  // if(hitArrayTClones!=nullptr){
135  // the ROOT guys really use 0 and not nullptr grrr...
136  if (hitArrayTClones->At(index) == 0) {
137  GFException e("In GFRecoHitProducer: index for hit in TClonesArray out of bounds", __LINE__, __FILE__);
138  e.setFatal();
139  throw e;
140  }
141  return (new recoHit_T((hit_T *)hitArrayTClones->At(index)));
142  //}
143  // else{//after assertions this is save: the hitArrayVector is good
144  // if(index >= hitArrayVector->size()) {
145  // GFException e("In GFRecoHitProducer: index for hit in std::vector out of bounds",__LINE__,__FILE__);
146  // e.setFatal();
147  // throw e;
148  // }
149  // return ( new recoHit_T( (hit_T*) hitArrayVector->at(index) ) );
150  //}
151 }
152 
153 #endif
virtual GFAbsRecoHit * produce(int index)=0
Virtual abstract method to produce a RecoHit. Implemented in GFRecoHitProducer.
virtual GFAbsRecoHit * produce(int index)
Create a RecoHit from the cluster at position index in TClonesArray.
Template class for a hit producer module.
virtual ~GFRecoHitProducer()
virtual ~GFAbsRecoHitProducer()
Base Class for representing a Hit in GENFIT.
Definition: GFAbsRecoHit.h:83
Abstract interface class for GFRecoHitProducer.
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:56
void setFatal(bool b=true)
set fatal flag. if this is true, the fit stops for this current track repr.
Definition: GFException.h:86
GFRecoHitProducer(TClonesArray *)
Constructor takes pointer to the cluster array.