PionBinData.cxx

Go to the documentation of this file.
00001 #include "AtlfastAlgs/PionBinData.h"
00002 
00003 namespace Atlfast 
00004 {
00005 
00006   //-----------------------------------------------
00007   // PUBLIC - Constructor
00008   //-----------------------------------------------
00009   PionBinData::PionBinData( BinID& id,
00010                             vector< ParameterResolutions* > core,
00011                             vector< ParameterResolutions* > tails,
00012                             vector< ParameterResolutions* > fractions,
00013                             vector< ParameterResolutions* > correlations,
00014                             int randSeed
00015                           ) :
00016                m_id(id),
00017                m_cores(core),    
00018                m_tails(tails),
00019                m_fractions(fractions),
00020                m_correlations(correlations)
00021 {
00022     m_randomEngine = new HepJamesRandom(randSeed);
00023 }    
00024 
00025 
00026   PionBinData::~PionBinData()
00027   {
00028     delete m_randomEngine;
00029     for (size_t i=0; i < m_fractions.size(); i++)
00030       delete m_fractions[i];
00031     for (size_t i=0; i < m_correlations.size(); i++)
00032       delete m_correlations[i];
00033     for (size_t i=0; i < m_cores.size(); i++)
00034       delete m_cores[i];
00035     for (size_t i=0; i < m_tails.size(); i++)
00036       delete m_tails[i];
00037   }
00038   
00039   //--------------------------------------------------------------------
00040   // PUBLIC - HepSymMatrix getMatrix(random)
00041   // returns appropriate Sigma (=covariance) matrix
00042   //
00043   // NOTE: the representation of Sigma is determined by the track 
00044   //       representation implicitly given in the parameter files,
00045   //       i.e., (d0, z0, phi0, cot(theta0), q/pT), which is for 
00046   //       internal use only.
00047   //
00048   //       The main advantage of this representation is that in 
00049   //       the context of the ID, for a solenoidal field, the three
00050   //       transverse track parameters (d0, phi0, q/pT) are to a 
00051   //       good approximation uncorrelated with the two longitudinal 
00052   //       ones (z0, cot(theta0)).  
00053   //
00054   //       Sigma has to be converted into the representation used 
00055   //       by Common Tracking, i.e. (d0, z0, phi0, theta0, q/p), 
00056   //       when it is written to CBNTs or AODs.  
00057   //--------------------------------------------------------------------
00058   HepSymMatrix PionBinData::getMatrix( const TrackTrajectory& traj ) const
00059   {
00060     HepSymMatrix Sigma(5,0);
00061 
00062     double fraction, random[5];
00063 
00064     // order of parameters: d0, z0, phi0, cot(theta0), q/pT
00065     // introduce "correlation" between core <--> tails
00066     random[0] = m_randomEngine->flat();
00067     random[1] = m_randomEngine->flat();
00068     random[2] = random[0];
00069     random[3] = random[1];
00070     random[4] = random[0];
00071 
00072     // diagonals
00073     for ( int param = 0; param < 5; param++ )
00074     {
00075       fraction = m_fractions[param]->resolution(traj);
00076       if ( fraction > 1.0 )  fraction = 1.0;
00077       Sigma[param][param] = ( random[param] < fraction )  ?
00078                             std::pow( m_cores[param]->resolution(traj), 2 )  :
00079                             std::pow( m_tails[param]->resolution(traj), 2 );
00080     }
00081     
00082     // off-diagonals 
00083     // NOTE: m_correlations[] holds correlation coefficients, need covariances
00084 
00085     // (1,3) ... cov(d0,phi0)
00086     // (1,5) ... cov(d0,q/pT)
00087     // (3,5) ... cov(phi0,q/pT)
00088     double rho13 = m_correlations[0]->resolution(traj);
00089     double rho15 = m_correlations[1]->resolution(traj);
00090     double rho35 = m_correlations[2]->resolution(traj);
00091 
00092     // covariance sub-matrix of transverse parameters needs to be positive definite
00093     // in order that its square root (cf. PionMatrixManager) exists
00094     double det3 = 1 - rho13 * rho13 - rho15 * rho15 - rho35 * rho35 - 2 * rho13 * rho15 * rho35;
00095     if ( det3 < 0 )  rho13 = rho15 = rho35 = 0;
00096     
00097     // make sure that correlation coefficients stay within [-1,+1]
00098     if ( std::abs(rho13) > 1 )  rho13 *= 0.99 / std::abs(rho13);
00099     if ( std::abs(rho15) > 1 )  rho15 *= 0.99 / std::abs(rho15);
00100     if ( std::abs(rho35) > 1 )  rho35 *= 0.99 / std::abs(rho35);
00101     
00102     Sigma(1,3) = Sigma(3,1) = rho13 * std::sqrt( Sigma(1,1) * Sigma(3,3) );
00103     Sigma(1,5) = Sigma(5,1) = rho15 * std::sqrt( Sigma(1,1) * Sigma(5,5) );
00104     Sigma(3,5) = Sigma(5,3) = rho35 * std::sqrt( Sigma(3,3) * Sigma(5,5) );
00105 
00106 
00107     // (2,4) ... cov(z0,cot(theta0))
00108     double rho24 = m_correlations[3]->resolution(traj);
00109     // make sure that correlation coefficient stays within [-1,+1]
00110     if ( std::abs(rho24) > 1 )  rho24 *= 0.99 / std::abs(rho24);
00111     Sigma(2,4) = Sigma(4,2) = rho24 * std::sqrt( Sigma(2,2) * Sigma(4,4) );
00112 
00113     // DONE!
00114     return Sigma;
00115     
00116   }
00117   
00118 } //namespace bracket

Generated on Mon Sep 24 14:19:12 2007 for AtlfastAlgs by  doxygen 1.5.1