GFBookkeeping.h
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 */
19 
20 
21 
22 #ifndef GFBOOKKEEPING_H
23 #define GFBOOKKEEPING_H
24 
25 #include"TObject.h"
26 #include"TMatrixT.h"
27 #include<vector>
28 #include<map>
29 #include"GFDetPlane.h"
30 #include"GFException.h"
31 
32 namespace genf {
33 
34 class GFBookkeeping : public TObject {
35  private:
36 
37  //the string keys will in general be different, so this cant
38  //be unified to one container
39  std::map<std::string, TMatrixT<Double_t>* > fMatrices;
40  std::map<std::string, GFDetPlane* > fPlanes;
41  /* this is a work-around: we want to save doubles, but ROOT has problems
42  * with TObjects that contain map<string,double*>. We take a 1x1 matrix
43  * as a work-around to hold the double internally */
44  std::map<std::string, TMatrixT<Double_t>* > fNumbers;
45  std::vector< unsigned int > fFailedHits;
46  int fNhits;
47 
48  public:
49  void reset();
50  void setNhits(int n){fNhits=n; reset();}
51 
53  void bookGFDetPlanes(std::string key);
54  void bookNumbers(std::string key,double val=0.);
55 
56  void setMatrix(std::string key,unsigned int index,const TMatrixT<Double_t>& mat);
57  void setDetPlane(std::string key,unsigned int index,const GFDetPlane& pl);
58  void setNumber(std::string key,unsigned int index, const double& num);
59 
60  bool getMatrix(std::string key, unsigned int index, TMatrixT<Double_t>& mat) const;
61  bool getDetPlane(std::string key, unsigned int index, GFDetPlane& pl) const;
62  bool getNumber(std::string key, unsigned int index, double& num) const;
63 
64  std::vector< std::string > getMatrixKeys() const;
65  std::vector< std::string > getGFDetPlaneKeys() const;
66  std::vector< std::string > getNumberKeys() const;
67 
68  void addFailedHit(unsigned int);
69  unsigned int hitFailed(unsigned int);
70  unsigned int getNumFailed();
71 
72  GFBookkeeping(): fNhits(-1) {}
74  virtual ~GFBookkeeping(){clearAll();}
75 
76  void Streamer(TBuffer&); // Added this, cuz compiler complains elsewise. EC, 28-Dec-2010.
77  void clearAll();
78  void clearFailedHits();
79 
80  void Print(std::ostream& out = std::cout) const;
81 
82  private:
83  //protect from call of net yet defined assignement operator
84  GFBookkeeping& operator=(const GFBookkeeping& /* rhs */) = delete; // {return *this;}
85 
86  virtual void Print(Option_t*) const
87  { throw GFException(std::string(__func__) + "::Print(Option_t*) not available", __LINE__, __FILE__).setFatal(); }
88 
89  // public:
90  //ClassDef(GFBookkeeping,2)
91 
92 };
93 
94 } // namespace genf
95 #endif
void setDetPlane(std::string key, unsigned int index, const GFDetPlane &pl)
std::map< std::string, TMatrixT< Double_t > * > fNumbers
Definition: GFBookkeeping.h:44
std::string string
Definition: nybbler.cc:12
Generic Interface to magnetic fields in GENFIT.
Definition: GFAbsBField.h:35
void Print(std::ostream &out=std::cout) const
std::map< std::string, TMatrixT< Double_t > * > fMatrices
Definition: GFBookkeeping.h:39
void setNumber(std::string key, unsigned int index, const double &num)
virtual ~GFBookkeeping()
Definition: GFBookkeeping.h:74
void setNhits(int n)
Definition: GFBookkeeping.h:50
void setMatrix(std::string key, unsigned int index, const TMatrixT< Double_t > &mat)
void addFailedHit(unsigned int)
GFBookkeeping & operator=(const GFBookkeeping &)=delete
def key(type, name=None)
Definition: graph.py:13
void bookGFDetPlanes(std::string key)
std::void_t< T > n
unsigned int hitFailed(unsigned int)
std::vector< unsigned int > fFailedHits
Definition: GFBookkeeping.h:45
bool getNumber(std::string key, unsigned int index, double &num) const
virtual void Print(Option_t *) const
Definition: GFBookkeeping.h:86
void Streamer(TBuffer &)
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:48
void bookMatrices(std::string key)
std::vector< std::string > getMatrixKeys() const
std::vector< std::string > getGFDetPlaneKeys() const
bool getMatrix(std::string key, unsigned int index, TMatrixT< Double_t > &mat) const
void bookNumbers(std::string key, double val=0.)
GFException & setFatal(bool b=true)
set fatal flag. if this is true, the fit stops for this current track repr.
Definition: GFException.h:78
std::vector< std::string > getNumberKeys() const
std::map< std::string, GFDetPlane * > fPlanes
Definition: GFBookkeeping.h:40
bool getDetPlane(std::string key, unsigned int index, GFDetPlane &pl) const
unsigned int getNumFailed()