PandaRoot
GFBookkeeping.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 */
31 
32 #ifndef GFBOOKKEEPING_H
33 #define GFBOOKKEEPING_H
34 
35 #include "TObject.h"
36 #include "TMatrixT.h"
37 #include <vector>
38 #include <cassert>
39 #include <iostream>
40 #include <utility>
41 #include <map>
42 #include "GFDetPlane.h"
43 
44 class GFBookkeeping : public TObject {
45  private:
46  // the string keys will in general be different, so this cant
47  // be unified to one container
48  std::map<std::string, TMatrixT<double> *> fMatrices;
49  std::map<std::string, GFDetPlane *> fPlanes;
50  /* this is a work-around: we want to save doubles, but ROOT has problems
51  * with TObjects that contain map<string,double*>. We take a 1x1 matrix
52  * as a work-around to hold the double internally */
53  std::map<std::string, TMatrixT<double> *> fNumbers;
54  std::vector<unsigned int> fFailedHits;
55  int fNhits;
56 
57  public:
58  void reset();
59  void setNhits(int n)
60  {
61  fNhits = n;
62  reset();
63  }
64 
65  void bookMatrices(std::string key);
66  void bookGFDetPlanes(std::string key);
67  void bookNumbers(std::string key, double val = 0.);
68 
69  void setMatrix(std::string key, unsigned int index, const TMatrixT<double> &mat);
70  void setDetPlane(std::string key, unsigned int index, const GFDetPlane &pl);
71  void setNumber(std::string key, unsigned int index, const double &num);
72 
73  bool getMatrix(std::string key, unsigned int index, TMatrixT<double> &mat);
74  bool getDetPlane(std::string key, unsigned int index, GFDetPlane &pl);
75  bool getNumber(std::string key, unsigned int index, double &num);
76 
77  std::vector<std::string> getMatrixKeys();
78  std::vector<std::string> getGFDetPlaneKeys();
79  std::vector<std::string> getNumberKeys();
80 
81  void addFailedHit(unsigned int);
82  unsigned int hitFailed(unsigned int);
83  unsigned int getNumFailed();
84 
85  GFBookkeeping() { fNhits = -1; }
87  virtual ~GFBookkeeping() { clearAll(); }
88 
89  void clearAll();
90  void clearFailedHits();
91 
92  void Print();
93 
94  private:
95  // protect from call of net yet defined assignement operator
96  GFBookkeeping &operator=(const GFBookkeeping &) { return *this; }
97 
98  public:
99  ClassDef(GFBookkeeping, 2)
100 };
101 
102 #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:70
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:59
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:87
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()