BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
HadronSaturation.h
Go to the documentation of this file.
1//********************************************************************************
2// This file is part of the Widget, a package for performing dE/dx calibration.
3//
4// Author: Jake Bennett
5// Date: July 8, 2015
6//
7// HadronSaturation is a class designed to perform the hadron saturation
8// correction. This entails taking the means and errors prepared by the
9// WidgetPrep class and fitting in bins of cos(theta).
10//
11// For additional details, see the Widget document.
12//
13//********************************************************************************
14#ifndef HADRONCORRECTION_H
15#define HADRONCORRECTION_H
16
17#include <string>
18#include <iostream>
19#include <vector>
20#include <fstream>
21
22#include "TFile.h"
23#include "TTree.h"
24#include "TF1.h"
25#include "TH1F.h"
26#include "TH2F.h"
27#include "TString.h"
28#include "TRandom.h"
29#include "TMath.h"
30#include "TFitter.h"
31#include "TGraphErrors.h"
32#include "TCanvas.h"
33
35
36 public:
37
39 HadronSaturation( double alpha, double gamma, double delta, double power, double ratio );
40 virtual ~HadronSaturation() { clear(); };
41
42 // set the parameters
43 void setParameters( double par[] );
44
45 // set the parameters
46 void setParameters( std::string parfile );
47
48 // fill the vectors below
49 void fillSample( TString infilename );
50
51 // print a sample of events
52 void printEvents( int firstevent, int nevents );
53
54 // perform the hadron saturation fit
55 void fitSaturation();
56
57 // clear the vectors
58 void clear();
59
60 // set the number of cosine bins
61 void setCosBins( int nbins ){ m_cosbins = nbins; }
62
63 // set the hadron saturation function flag
64 void setFlag( int flag ){ m_flag = flag; }
65
66 // some helper functions for the hadron saturation correction
67 double myFunction( double alpha, double gamma, double delta, double power, double ratio );
68 static void minuitFunction( int& nDim, double* gout, double& result, double* para, int flg );
69
70 double D2I( double cosTheta, double D, double alpha, double gamma, double delta, double power, double ratio ) const;
71 double I2D( double cosTheta, double I, double alpha, double gamma, double delta, double power, double ratio ) const;
72
73 // define these here to be used in other classes
74 double D2I( double cosTheta, double D = 1 ) const {
75
76 double absCosTheta = fabs(cosTheta);
77 double projection = pow(absCosTheta, m_power) + m_delta;
78 double chargeDensity = D / projection;
79 double numerator = 1 + m_alpha * chargeDensity;
80 double denominator = 1 + m_gamma * chargeDensity;
81
82 double I = D * m_ratio * numerator / denominator;
83
84 return I;
85 }
86
87 double I2D( double cosTheta, double I = 1 ) const {
88
89 double absCosTheta = fabs(cosTheta);
90 double projection = pow(absCosTheta, m_power) + m_delta;
91
92 double a = m_alpha/projection;
93 double b = 1 - m_gamma/projection * (I/m_ratio);
94 double c = -1.0 * I/m_ratio;
95
96 if( b == 0 && a == 0 ){
97 std::cout << "both a and b coefficiants for hadron correction are 0" << std::endl;
98 return I;
99 }
100
101 double D = (a != 0) ? (-b + sqrt(b * b - 4.0 * a * c)) / (2.0 * a) : -c / b;
102 if( D < 0 ){
103 std::cout << "D is less 0! will try another solution" << std::endl;
104 D = (a != 0) ? (-b - sqrt(b * b + 4.0 * a * c)) / (2.0 * a) : -c / b;
105 if( D < 0 ){
106 std::cout << "D is still less 0! just return uncorrectecd value" << std::endl;
107 return I;
108 }
109 }
110
111 return D;
112 }
113
114 private:
115
116 // flag for saturation function
117 int m_flag;
118
119 // the number of cosine bins
120 int m_cosbins;
121
122 // the parameters for the hadron saturation correction
123 double m_alpha;
124 double m_gamma;
125 double m_delta;
126 double m_power;
127 double m_ratio;
128
129 std::vector< double > m_dedx; // a vector to hold dE/dx measurements
130 std::vector< double > m_dedxerror; // a vector to hold dE/dx errors
131 std::vector< double > m_betagamma; // a vector to hold beta-gamma values
132 std::vector< double > m_costheta; // a vector to hold cos(theta) values
133
134};
135#endif
const int nbins
const double delta
const DifComplex I
const double alpha
void printEvents(int firstevent, int nevents)
double myFunction(double alpha, double gamma, double delta, double power, double ratio)
void setFlag(int flag)
double I2D(double cosTheta, double I, double alpha, double gamma, double delta, double power, double ratio) const
void setCosBins(int nbins)
void fillSample(TString infilename)
double D2I(double cosTheta, double D, double alpha, double gamma, double delta, double power, double ratio) const
double I2D(double cosTheta, double I=1) const
void setParameters(double par[])
virtual ~HadronSaturation()
double D2I(double cosTheta, double D=1) const
static void minuitFunction(int &nDim, double *gout, double &result, double *para, int flg)
const double b
Definition: slope.cxx:9