PandaRoot
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 "TObject.h"
24 #include "TMatrixT.h"
25 #include <vector>
26 #include <cassert>
27 #include <iostream>
28 #include <utility>
29 #include <map>
30 #include "GFDetPlane.h"
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> *> 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> *> 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> &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> &mat);
62  bool getDetPlane(std::string key, unsigned int index, GFDetPlane &pl);
63  bool getNumber(std::string key, unsigned int index, double &num);
64 
65  std::vector<std::string> getMatrixKeys();
66  std::vector<std::string> getGFDetPlaneKeys();
67  std::vector<std::string> getNumberKeys();
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 clearAll();
78  void clearFailedHits();
79 
80  void Print();
81 
82  private:
83  // protect from call of net yet defined assignement operator
84  GFBookkeeping &operator=(const GFBookkeeping &) { return *this; }
85 
86  public:
87  ClassDef(GFBookkeeping, 2)
88 };
89 
90 #endif
std::vector< std::string > getGFDetPlaneKeys()
unsigned int getNumFailed()
void setNumber(std::string key, unsigned int index, const double &num)
unsigned int hitFailed(unsigned int)
Detector plane genfit geometry class.
Definition: GFDetPlane.h:58
bool getDetPlane(std::string key, unsigned int index, GFDetPlane &pl)
void addFailedHit(unsigned int)
void bookGFDetPlanes(std::string key)
void setDetPlane(std::string key, unsigned int index, const GFDetPlane &pl)
void setNhits(int n)
Definition: GFBookkeeping.h:47
std::vector< std::string > getNumberKeys()
void bookNumbers(std::string key, double val=0.)
void setMatrix(std::string key, unsigned int index, const TMatrixT< double > &mat)
virtual ~GFBookkeeping()
Definition: GFBookkeeping.h:75
void bookMatrices(std::string key)
bool getNumber(std::string key, unsigned int index, double &num)
bool getMatrix(std::string key, unsigned int index, TMatrixT< double > &mat)
std::vector< std::string > getMatrixKeys()
void clearFailedHits()