ATLAS Offline Software
Loading...
Searching...
No Matches
TRTAlign::HistoChisqProjection Class Reference

#include <TRTAlignHistoChisqProjection.h>

Collaboration diagram for TRTAlign::HistoChisqProjection:

Public Member Functions

 HistoChisqProjection (const char *name, int dim, int nbins, float xmin, float xmax)
 ~HistoChisqProjection ()
 HistoChisqProjection (const HistoChisqProjection &)=delete
HistoChisqProjectionoperator= (const HistoChisqProjection &)=delete
void add (const CLHEP::HepMatrix &deriv, const CLHEP::HepSymMatrix &weight, const CLHEP::HepSymMatrix &variance, const CLHEP::HepVector &residual)
void add (const CLHEP::HepMatrix &deriv, const CLHEP::HepSymMatrix &weight, const CLHEP::HepSymMatrix &variance, const CLHEP::HepVector &residual, const CLHEP::HepSymMatrix &secondweight)
CLHEP::HepVector getFittedHalfDChisqDX (std::ostream &os=std::cout) const
CLHEP::HepVector getNormalHalfDChisqDX () const
void setDirectory (TDirectory *dir)

Private Member Functions

void addfirst (const CLHEP::HepMatrix &derivative, const CLHEP::HepSymMatrix &weight, const CLHEP::HepSymMatrix &variance, const CLHEP::HepVector &residual)
void addsecond (const CLHEP::HepMatrix &derivative, const CLHEP::HepSymMatrix &weight)

Private Attributes

int m_dim
TH2 * m_h2
TH2 * m_unweightedh2
std::vector< double > m_integrals
CLHEP::HepVector m_halfdChisqdX
CLHEP::HepSymMatrix m_halfd2ChisqdX2

Detailed Description

Definition at line 23 of file TRTAlignHistoChisqProjection.h.

Constructor & Destructor Documentation

◆ HistoChisqProjection() [1/2]

TRTAlign::HistoChisqProjection::HistoChisqProjection ( const char * name,
int dim,
int nbins,
float xmin,
float xmax )

Definition at line 14 of file TRTAlignHistoChisqProjection.cxx.

15 : m_dim(dim), m_integrals(dim,0),m_halfdChisqdX(dim,0)
16 {
17 m_h2 = new TH2F("h2",name,dim,-0.5,dim-0.5,nbins,xmin,xmax) ;
18 m_unweightedh2 = new TH2F("unweightedh2",name,dim,-0.5,dim-0.5,nbins,xmin,xmax) ;
19 m_h2->Sumw2() ;
20 } ;
double xmax
Definition listroot.cxx:61
double xmin
Definition listroot.cxx:60
TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)

◆ ~HistoChisqProjection()

TRTAlign::HistoChisqProjection::~HistoChisqProjection ( )

◆ HistoChisqProjection() [2/2]

TRTAlign::HistoChisqProjection::HistoChisqProjection ( const HistoChisqProjection & )
delete

Member Function Documentation

◆ add() [1/2]

void TRTAlign::HistoChisqProjection::add ( const CLHEP::HepMatrix & deriv,
const CLHEP::HepSymMatrix & weight,
const CLHEP::HepSymMatrix & variance,
const CLHEP::HepVector & residual )
inline

Definition at line 33 of file TRTAlignHistoChisqProjection.h.

34 {
35 addfirst( deriv, weight, variance, residual ) ;
36 addsecond( deriv, weight ) ;
37 }
void addfirst(const CLHEP::HepMatrix &derivative, const CLHEP::HepSymMatrix &weight, const CLHEP::HepSymMatrix &variance, const CLHEP::HepVector &residual)
void addsecond(const CLHEP::HepMatrix &derivative, const CLHEP::HepSymMatrix &weight)

◆ add() [2/2]

void TRTAlign::HistoChisqProjection::add ( const CLHEP::HepMatrix & deriv,
const CLHEP::HepSymMatrix & weight,
const CLHEP::HepSymMatrix & variance,
const CLHEP::HepVector & residual,
const CLHEP::HepSymMatrix & secondweight )
inline

Definition at line 40 of file TRTAlignHistoChisqProjection.h.

42 {
43 addfirst( deriv, weight, variance, residual ) ;
44 addsecond( deriv, secondweight ) ;
45 }

◆ addfirst()

void TRTAlign::HistoChisqProjection::addfirst ( const CLHEP::HepMatrix & derivative,
const CLHEP::HepSymMatrix & weight,
const CLHEP::HepSymMatrix & variance,
const CLHEP::HepVector & residual )
private

Definition at line 22 of file TRTAlignHistoChisqProjection.cxx.

24 {
25 int dimr = weight.num_row() ;
26 CLHEP::HepMatrix derivtimesweight(deriv*weight) ;
27
28 for(int irow=1; irow<=dimr; ++irow) {
29 double thissigma = sqrt( variance.fast(irow,irow) ) ;
30
31 for(int ipar=0; ipar<m_dim; ++ipar) {
32 double thisweight = derivtimesweight(ipar+1, irow ) * thissigma ;
33 double thispull = residual(irow) / thissigma ;
34 if( thisweight< 0 ) {
35 thisweight*=-1 ;
36 thispull*=-1 ;
37 }
38 m_h2->Fill( double(ipar), thispull, thisweight ) ;
39 m_unweightedh2->Fill( double(ipar), thispull ) ;
40 m_integrals[ipar] += thisweight ;
41 m_halfdChisqdX(ipar+1) += thisweight*thispull ;
42 }
43 }
44 }

◆ addsecond()

void TRTAlign::HistoChisqProjection::addsecond ( const CLHEP::HepMatrix & derivative,
const CLHEP::HepSymMatrix & weight )
private

Definition at line 46 of file TRTAlignHistoChisqProjection.cxx.

47 {
48 m_halfd2ChisqdX2 += weight.similarity(deriv) ;
49 }

◆ getFittedHalfDChisqDX()

CLHEP::HepVector TRTAlign::HistoChisqProjection::getFittedHalfDChisqDX ( std::ostream & os = std::cout) const

Definition at line 67 of file TRTAlignHistoChisqProjection.cxx.

68 {
69 CLHEP::HepVector halfDChisqDX(m_dim,0) ;
70 // perform a fit to each hist
71 TF1 f1("mygaus",gausfunc,m_h2->GetYaxis()->GetXmin(),m_h2->GetYaxis()->GetXmax(),3) ;
72 for(int ipar=1; ipar<=m_dim; ++ipar) {
73 char hisname[256] ;
74 sprintf(hisname,"tmph1_%d",ipar) ;
75 TH1* tmph1 = m_h2->ProjectionY(hisname,ipar,ipar,"e") ; // the 'e' triggers the error calculation (quite important!)
76 binwidth = tmph1->GetXaxis()->GetBinWidth(1) ;
77 tmph1->SetDirectory(m_h2->GetDirectory()) ;
78 f1.SetParameter(0,tmph1->Integral());
79 f1.SetParLimits(0,0.5*tmph1->Integral(),2*tmph1->Integral()) ;
80 f1.SetParameter(1,0) ;
81 f1.SetParameter(2,tmph1->GetRMS()) ;
82 tmph1->Fit(&f1,"Q0I") ;
83 tmph1->GetListOfFunctions()->Add(f1.Clone()) ;
84 halfDChisqDX(ipar) = f1.GetParameter(1) * m_integrals[ipar-1] ;
85 os << "fitresult: " << f1.GetParameter(1) << " weight: " << m_integrals[ipar-1] << " integrated mean: "
86 << m_halfdChisqdX(ipar) / m_integrals[ipar-1] << std::endl ;
87 }
88 return halfDChisqDX ;
89 }
bool binwidth
Definition listroot.cxx:58
double gausfunc(double *x, double *par)

◆ getNormalHalfDChisqDX()

CLHEP::HepVector TRTAlign::HistoChisqProjection::getNormalHalfDChisqDX ( ) const
inline

Definition at line 48 of file TRTAlignHistoChisqProjection.h.

48{ return m_halfdChisqdX ; }

◆ operator=()

HistoChisqProjection & TRTAlign::HistoChisqProjection::operator= ( const HistoChisqProjection & )
delete

◆ setDirectory()

void TRTAlign::HistoChisqProjection::setDirectory ( TDirectory * dir)

Definition at line 91 of file TRTAlignHistoChisqProjection.cxx.

92 {
93 m_h2->SetDirectory(dir) ;
94 m_unweightedh2->SetDirectory(dir) ;
95 }

Member Data Documentation

◆ m_dim

int TRTAlign::HistoChisqProjection::m_dim
private

Definition at line 59 of file TRTAlignHistoChisqProjection.h.

◆ m_h2

TH2* TRTAlign::HistoChisqProjection::m_h2
private

Definition at line 60 of file TRTAlignHistoChisqProjection.h.

◆ m_halfd2ChisqdX2

CLHEP::HepSymMatrix TRTAlign::HistoChisqProjection::m_halfd2ChisqdX2
private

Definition at line 64 of file TRTAlignHistoChisqProjection.h.

◆ m_halfdChisqdX

CLHEP::HepVector TRTAlign::HistoChisqProjection::m_halfdChisqdX
private

Definition at line 63 of file TRTAlignHistoChisqProjection.h.

◆ m_integrals

std::vector<double> TRTAlign::HistoChisqProjection::m_integrals
private

Definition at line 62 of file TRTAlignHistoChisqProjection.h.

◆ m_unweightedh2

TH2* TRTAlign::HistoChisqProjection::m_unweightedh2
private

Definition at line 61 of file TRTAlignHistoChisqProjection.h.


The documentation for this class was generated from the following files: