#include <DistRandomiser2D.h>
Inheritance diagram for FastShower::DistRandomiser2D:
Public Methods | |
DistRandomiser2D (const std::string &) | |
std::pair< double, double > | sample () const |
~DistRandomiser2D () | |
void | readData (const std::string &, std::vector< int > &) const |
Private Attributes | |
RandGeneral * | m_yProjection |
std::vector< RandGeneral * > | m_xSlices |
UML: IDistributionClass.unm
Definition at line 25 of file DistRandomiser2D.h.
|
Definition at line 11 of file DistRandomiser2D.cxx. References m_xSlices, m_yProjection, and readData().
00011 { 00012 00013 // get data form file (histogram) 00014 std::vector<int> v; 00015 readData(f,v); 00016 00017 // needed to initialise RandGeneral 00018 std::vector<int>::size_type nn = v.size(); // # of xbins*ybins 00019 int n = (int) std::sqrt(nn); // # of bins 00020 // make sure vector has 50 rows, each with 50 elements 00021 assert(n == 50); 00022 00023 // histograms 00024 double yDist[50], xDist[50], xyDist[50][50]; 00025 00026 // map vector into a matrix 00027 std::vector<int>::const_iterator itr = v.begin(); 00028 std::vector<int>::const_iterator end = v.end(); 00029 for (int j=0; j<n; ++j){ 00030 for (int i=0; i<n; ++i){ 00031 xyDist[i][j] = *itr; 00032 ++itr; 00033 if (itr == end) itr=v.begin(); 00034 } 00035 } 00036 // extract distributions 00037 for (int j=0; j<n; ++j) { 00038 xDist[j] = 0; 00039 for (int i=0; i<n; ++i){ 00040 yDist[i] = 0; 00041 // projection of y onto x-axis 00042 xDist[j] += xyDist[i][j]; 00043 // slice x-axis, project each x-slice onto y-axis 00044 yDist[i] = xyDist[i][j]; 00045 } 00046 // setup distributions of xSlices 00047 m_xSlices.push_back(new RandGeneral(yDist, n, 0)); 00048 //for (int nb=0; nb<n; ++nb) cout<<yDist[nb]<<" "; cout<<endl; 00049 } 00050 // setup distribution 00051 m_yProjection=new RandGeneral(xDist, n, 0); 00052 //for (int nb=0; nb<n; ++nb) cout<<xDist[nb]<<" "; cout<<endl; 00053 } |
|
Definition at line 78 of file DistRandomiser2D.cxx.
00078 { 00079 } |
|
Definition at line 63 of file DistRandomiser2D.cxx. References m_xSlices, and m_yProjection. Referenced by FastShower::HadEcalHcalSharesBase::value().
00063 { 00064 // sample Ecal fraction 00065 double eFrac = 2.0 * m_yProjection->fire(); 00066 // map to bin number (gives Hcal distribution) 00067 int xSlice = (int) (eFrac/0.04); ++xSlice; 00068 // 00069 std::vector<RandGeneral*>::const_iterator itr = m_xSlices.begin(); 00070 for (int i=1; i<xSlice; ++i){++itr;} 00071 assert(itr<m_xSlices.end()); 00072 // sample Hcal fraction 00073 double hFrac = 2.0 * (*itr)->fire(); 00074 std::pair<double,double> ehFracs(eFrac,hFrac); 00075 return ehFracs; 00076 } |
|
Definition at line 56 of file DistRandomiser2D.cxx. Referenced by DistRandomiser2D().
00056 { 00057 ifstream data(f.c_str()); 00058 istream_iterator<int> dataItr(data); 00059 istream_iterator<int> endOfData; 00060 copy(dataItr,endOfData,back_inserter(v)); 00061 } |
|
Definition at line 32 of file DistRandomiser2D.h. Referenced by DistRandomiser2D(), and sample(). |
|
Definition at line 33 of file DistRandomiser2D.h. Referenced by DistRandomiser2D(), and sample(). |