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