Go to the documentation of this file.00001 #include "ForIA/AnalysisTools/PhiGrid.hh"
00002 #include "ForIA/Utils.hh"
00003
00004 namespace ForIA{
00005
00006 PhiGrid::PhiGrid(): m_canChangeSettings(true), m_haveSetNSegments(false), m_nSegments(0),
00007 m_etaMin(-5.), m_updateGrid(true), m_updateEta(true){
00008
00009 }
00010
00012 bool PhiGrid::setNSegments(int nSegs){
00013 if(!m_canChangeSettings) return false;
00014
00015 m_nSegments = nSegs;
00016 m_phi2Bin = ((double) m_nSegments) * 0.5 / M_PI;
00017 m_eta2Bin = ((double) m_nSegments) / 10.;
00018 m_haveSetNSegments = true;
00019 return true;
00020 }
00021
00022 int PhiGrid::nSegments()const{
00023 return m_nSegments;
00024 }
00025
00027 GridPtr PhiGrid::grid()const{
00028
00029 if(m_updateGrid) update();
00030
00031 return m_grid;
00032 }
00033
00035 GridPtr PhiGrid::etaGrid(IFourMomentumConstPtr centre)const{
00036 if(m_updateEta) updateEta(centre);
00037
00038 return m_etaGrid;
00039 }
00040
00042 GridMultiplicityPtr PhiGrid::multiplicity()const{
00043 if(m_updateGrid) update();
00044
00045 return m_multiplicity;
00046 }
00047
00049 void PhiGrid::update()const{
00050
00051 vector<double> *tmpGrid = new vector<double>(m_nSegments, 0.);
00052 vector<unsigned int> *tmpMult = new vector<unsigned int>(m_nSegments, 0);
00053
00054 for(MomentumVector::const_iterator vec = m_momenta.begin();
00055 vec != m_momenta.end(); ++vec){
00056 double phi = mod2Pi((*vec)->phi());
00057 double dBin = phi * m_phi2Bin;
00058 int bin = (int) dBin;
00059 (*tmpGrid)[bin] += (*vec)->PT();
00060 (*tmpMult)[bin] += 1;
00061 }
00062
00063 m_grid = GridPtr(tmpGrid);
00064 m_multiplicity = GridMultiplicityPtr(tmpMult);
00065 m_updateGrid = false;
00066 return;
00067 }
00068
00070 void PhiGrid::updateEta(IFourMomentumConstPtr centre)const{
00071
00072 double eta0 = 0.;
00073
00074 if(centre !=0 ){
00075 eta0 = centre->eta();
00076 }
00077
00078 vector<double> *tmpGrid = new vector<double>(m_nSegments, 0.);
00079
00080 for(MomentumVector::const_iterator vec = m_momenta.begin();
00081 vec != m_momenta.end(); ++vec){
00082
00083 double eta = (*vec)->eta() - eta0 - m_etaMin;
00084
00085
00086 double dBin = eta * m_eta2Bin;
00087 int bin = (int) dBin;
00088
00089 (*tmpGrid)[bin] += (*vec)->PT();
00090 }
00091
00092 m_etaGrid = GridPtr(tmpGrid);
00093 m_updateEta = false;
00094
00095 return;
00096 }
00097
00099 bool PhiGrid::setFourMomenta(const MomentumVector &momenta){
00100 if(!m_haveSetNSegments) return false;
00101 m_canChangeSettings=false;
00102 m_momenta = momenta;
00103 m_updateGrid = true;
00104 m_updateEta = true;
00105
00106 return true;
00107 }
00108
00109 }