ROOTPWA
TFitBin.h
Go to the documentation of this file.
1 
2 //
3 // Copyright 2009 Sebastian Neubert
4 //
5 // This file is part of rootpwa
6 //
7 // rootpwa is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // rootpwa is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
19 //
21 //-----------------------------------------------------------
22 // File and Version Information:
23 // $Id$
24 //
25 // Description:
26 // Data storage class for PWA fit result of one mass bin
27 //
28 // Environment:
29 // Software developed for the COMPASS experiment at CERN
30 //
31 // Author List:
32 // Sebastian Neubert TUM (original author)
33 //
34 //
35 //-----------------------------------------------------------
36 
37 
38 #ifndef TFITBIN_HH
39 #define TFITBIN_HH
40 
41 
42 #include <iostream>
43 #include <iomanip>
44 #include <vector>
45 #include <map>
46 #include <string>
47 #include <complex>
48 
49 #include "TObject.h"
50 #include "TComplex.h"
51 #include "TMatrixT.h"
52 #include "TString.h"
53 
54 #include "TCMatrix.h"
55 
56 
58 class TFitBin : public TObject {
59 public:
60 
61  TFitBin();
62  virtual ~TFitBin();
63 
64  void fill(const std::vector<TComplex>& prodAmps,
65  const std::vector<std::pair<int, int> >& indices,
66  const std::vector<TString>& prodAmpNames,
67  const int nevt,
68  const unsigned int nmbEvents,
69  const double massBinCenter,
70  const TCMatrix& normIntegral,
71  const TMatrixD& fitParCovMatrix,
72  const double logLikelihood,
73  const int rank);
74 
75  // Operations ----------------------
76  Double_t norm(const char* tag) const;
77  Double_t normI(Int_t i) const {return norm(_wavenames[i].Data());}
78  Double_t intens() const; // total intensity
79  Double_t intens(const char* tag) const; // added intensity of waves containing tag
80  Double_t intens(Int_t i) const;
81  Double_t phase(Int_t i, Int_t j) const; // phase difference between wave i and j
82  Double_t phaseErr(Int_t i, Int_t j) const;
83  Double_t coh(Int_t i, Int_t j) const; // coherence between wave i and j
84  Double_t mass() const {return _mass;}
85  Double_t logli() const {return _logli;}
86  Double_t getInt(Int_t i, Int_t j, bool re) const {if(re)return getInt(i,j).Re();else return getInt(i,j).Im();}
87  UInt_t rawEvents() const {return _rawevents;}
88 
89  Int_t nwaves() const {return _wavetitles.size();}
90  TString wavename(unsigned int i) const {return _wavenames[i];}
91  TString waveDesignator(unsigned int i) const {return _wavetitles[i];}
92  unsigned int namps() const { return _amps.size();}
93  TComplex amp(unsigned int i) const { return _amps.at(i);}
94  void getParameters(double* par) const; // returns by filling the par array
95  double getParameter(const char* name) const;
96 
97  Double_t err(const char* tag) const;
98  Double_t err(Int_t i) const;
99 
100  void listwaves() const;
101  void Reset();
102  void PrintParameters() const;
103  void printAmpsGenPW(std::ostream& s) const;
104 
105  // accessors that allow copying of TFitBin
106  const std::vector<TComplex>& prodAmps() const { return _amps; }
107  const std::vector<std::pair<int, int> >& fitParCovIndices() const { return _indices; }
108  const std::vector<TString>& prodAmpNames() const { return _wavenames; }
109  const std::vector<TString>& waveNames() const { return _wavetitles; }
110  const std::map<int,int>& prodAmpIndexMap() const { return _wavemap; }
111 
112  int normNmbEvents() const { return _nevt; }
113  unsigned int nmbEvents() const { return _rawevents; }
114  Double_t massBinCenter() const { return _mass; }
115  const TCMatrix& normIntegral() const { return _int; }
116  const TMatrixD& fitParCovMatrix() const { return _errm; }
117  Double_t logLikelihood() const { return _logli; }
118  Int_t rank() const { return _rank; }
120 
121 private:
122 
123  std::vector<TComplex> _amps;
124  std::vector<std::pair<int, int> > _indices;
125  std::vector<TString> _wavenames;
126  std::vector<TString> _wavetitles;
127  std::map<int,int> _wavemap;
128 
129  int _nevt;
130  unsigned int _rawevents;
133  TMatrixD _errm;
137 
138 
139  // Private Methods -----------------
140  TMatrixD getErr(unsigned int i) const {return getErr(_indices[i]);}
141  TMatrixD getErr(std::pair<int,int>) const; // returns cov matrix for complex parameter i
142  void getCov(const char* tag, TMatrixD& C, std::vector<int>& cpar) const;
143  void getCov(int i, int j, TMatrixD& C) const;
144 
145  // Waves indices run over all ranks. In the integral each wave appears only
146  // once (without notion of rank). So we have to map this:
147  TComplex getInt(int i, int j) const;
148 
149  TComplex spinDens(int i, int j) const;
150  TMatrixD spinDensErr(int i, int j) const;
151  TMatrixD M(const TComplex& c) const;
152  // the rank should be encoded into the second parameter of the wave
153  int rankofwave(int i) const ;
154  TString wavetitle(int i) const {if(_wavenames[i].Contains("V_"))return _wavenames[i](2,1000); else return _wavenames[i](3,1000);}
155 
156  void buildWaveMap();
157 
158 public:
159  ClassDef(TFitBin,8)
160 
161 };
162 
163 
164 #endif // TFITBIN_HH
165 
166 
167 //--------------------------------------------------------------
168 // $Log$
169 //--------------------------------------------------------------