CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

RadialInterval Class Reference

#include <RadialInterval.h>

List of all members.

Public Member Functions

void addInterval (double, double)
void compute ()
unsigned getNumberOfSpots (unsigned i) const
 Number of spots in a given interval.
double getSpotEnergy (unsigned i) const
 Spot energy in a given interval.
double getUmax (unsigned i) const
 Upper limit of the argument in the radius generator.
double getUmin (unsigned i) const
 Lower limit of the argument in the radius generator.
unsigned nIntervals () const
 Number of intervals.
 RadialInterval (double RC, unsigned nSpots, double energy, const RandomEngine *engine)
 Standard constructor Rc: mean Radius.
 ~RadialInterval ()

Private Member Functions

double energyFractionInRadius (double rm)

Private Attributes

double currentEnergyFraction
double currentRad
double currentUlim
std::vector< double > dspotsunscaled
unsigned nInter
std::vector< unsigned > nspots
const RandomEnginerandom
std::vector< double > spotE
std::vector< double > spotfraction
unsigned theNumberOfSpots
double theR
double theSpotEnergy
std::vector< double > uMax
std::vector< double > uMin

Detailed Description

Definition at line 13 of file RadialInterval.h.


Constructor & Destructor Documentation

RadialInterval::RadialInterval ( double  RC,
unsigned  nSpots,
double  energy,
const RandomEngine engine 
)

Standard constructor Rc: mean Radius.

Definition at line 7 of file RadialInterval.cc.

References currentEnergyFraction, currentRad, currentUlim, and nInter.

RadialInterval::~RadialInterval ( ) [inline]

Definition at line 19 of file RadialInterval.h.

{;}

Member Function Documentation

void RadialInterval::addInterval ( double  radius,
double  spotf 
)

Add an interval : first argument is the radius, the second is the fraction of spots in this interval R>10 <-> infinity

Definition at line 19 of file RadialInterval.cc.

References currentEnergyFraction, currentUlim, dspotsunscaled, energyFractionInRadius(), RandomEngine::gaussShoot(), nInter, nspots, CosmicsPD_Skims::radius, random, spotE, spotfraction, mathSSE::sqrt(), theNumberOfSpots, theR, theSpotEnergy, uMax, and uMin.

Referenced by EMShower::compute(), and EMShower::setIntervals().

{
  double radiussq=radius*radius;
  double enFrac=energyFractionInRadius(radius);
  if(radius>10) enFrac=1.;
  double energyFrac=enFrac-currentEnergyFraction;
  currentEnergyFraction=enFrac;
  //  std::cout << " Rad " << nInter << " Energy frac " << energyFrac << std::endl;
  
  // Calculates the number of spots. Add binomial fluctuations
  double dspot = random->gaussShoot(theNumberOfSpots*energyFrac,
                            sqrt(energyFrac*(1.-energyFrac)*theNumberOfSpots));
  //  std::cout << " Normal : " << theNumberOfSpots*energyFrac << " "<< dspot << std::endl;
  unsigned nspot=(unsigned)(dspot*spotf+0.5);
//  if(nspot<100) 
//    {
//      spotf=1.;
//      nspot=(unsigned)(theNumberOfSpots*energyFrac+0.5);
//    }
  
  dspotsunscaled.push_back(dspot);
  spotfraction.push_back(spotf);

  double spotEnergy=theSpotEnergy/spotf;
  //  std::cout << " The number of spots " << theNumberOfSpots << " " << nspot << std::endl;

  // This is not correct for the last interval, but will be overriden later
  nspots.push_back(nspot);
  spotE.push_back(spotEnergy);
  // computes the limits
  double umax = radiussq/(radiussq+theR*theR);
  if(radius>10)
    {
      umax=1.;
    }

  // Stores the limits
  uMax.push_back(umax);          
  uMin.push_back(currentUlim);           
  currentUlim=umax;

  // Stores the energy
  //  std::cout << " SpotE " << theSpotEnergy<< " " << spotf << " " << theSpotEnergy/spotf<< std::endl;

  ++nInter;
}
void RadialInterval::compute ( )

Most of the calculation are made in addInterval but the normal number of spots has to be set

Definition at line 72 of file RadialInterval.cc.

References dspotsunscaled, nInter, nspots, spotfraction, and theNumberOfSpots.

Referenced by EMShower::compute().

{
  //  std::cout << " The number of Spots " << theNumberOfSpots << std::endl;
  //  std::cout << " Size : " << nInter << " " << nspots.size() << " " << dspotsunscaled.size() << std::endl;
  double ntotspots=0.;
  for(unsigned irad=0;irad<nInter-1;++irad)
    {
      ntotspots+=dspotsunscaled[irad];
      //    std::cout << " In the loop " << ntotspots << std::endl;
    }

  // This can happen (fluctuations)
  if(ntotspots>theNumberOfSpots) ntotspots=(double)theNumberOfSpots;
  //  std::cout << " Sous-total " << ntotspots << std::endl;
  dspotsunscaled[nInter-1]=(double)theNumberOfSpots-ntotspots;
  
  nspots[nInter-1]=(unsigned)(dspotsunscaled[nInter-1]*spotfraction[nInter-1]+0.5);
  //    std::cout << " Nlast " << nspots[nInter-1] << std::endl;
}
double RadialInterval::energyFractionInRadius ( double  rm) [private]

Definition at line 66 of file RadialInterval.cc.

References submit::rm, and theR.

Referenced by addInterval().

{
  double rm2=rm*rm;
  return (rm2/(rm2+theR*theR));
}
unsigned RadialInterval::getNumberOfSpots ( unsigned  i) const [inline]

Number of spots in a given interval.

Definition at line 34 of file RadialInterval.h.

References i, and nspots.

Referenced by EMShower::compute().

                                                     { 
    //    std::cout << " getNumberOfSpots " << i << " " << nspots.size() << std::endl;
    return nspots[i];
  }
double RadialInterval::getSpotEnergy ( unsigned  i) const [inline]

Spot energy in a given interval.

Definition at line 30 of file RadialInterval.h.

References i, and spotE.

Referenced by EMShower::compute().

                                                { 
    //    std::cout << " getSpotEnergy " << i << " " << spotE.size() << std::endl;
    return spotE[i];}
double RadialInterval::getUmax ( unsigned  i) const [inline]

Upper limit of the argument in the radius generator.

Definition at line 44 of file RadialInterval.h.

References i, and uMax.

Referenced by EMShower::compute().

                                          {
    //    std::cout << " getUmax " << i << " " << uMax.size() << std::endl;
    return uMax[i];
  }
double RadialInterval::getUmin ( unsigned  i) const [inline]

Lower limit of the argument in the radius generator.

Definition at line 39 of file RadialInterval.h.

References i, and uMin.

Referenced by EMShower::compute().

                                          {
    //    std::cout << " getUmin " << i << " " << uMin.size() << std::endl;
    return uMin[i];
  }
unsigned RadialInterval::nIntervals ( ) const [inline]

Number of intervals.

Definition at line 28 of file RadialInterval.h.

References nInter.

Referenced by EMShower::compute().

{ return nInter;}

Member Data Documentation

Definition at line 51 of file RadialInterval.h.

Referenced by addInterval(), and RadialInterval().

double RadialInterval::currentRad [private]

Definition at line 50 of file RadialInterval.h.

Referenced by RadialInterval().

double RadialInterval::currentUlim [private]

Definition at line 52 of file RadialInterval.h.

Referenced by addInterval(), and RadialInterval().

std::vector<double> RadialInterval::dspotsunscaled [private]

Definition at line 62 of file RadialInterval.h.

Referenced by addInterval(), and compute().

unsigned RadialInterval::nInter [private]

Definition at line 56 of file RadialInterval.h.

Referenced by addInterval(), compute(), nIntervals(), and RadialInterval().

std::vector<unsigned> RadialInterval::nspots [private]

Definition at line 60 of file RadialInterval.h.

Referenced by addInterval(), compute(), and getNumberOfSpots().

Definition at line 70 of file RadialInterval.h.

Referenced by addInterval().

std::vector<double> RadialInterval::spotE [private]

Definition at line 61 of file RadialInterval.h.

Referenced by addInterval(), and getSpotEnergy().

std::vector<double> RadialInterval::spotfraction [private]

Definition at line 63 of file RadialInterval.h.

Referenced by addInterval(), and compute().

Definition at line 54 of file RadialInterval.h.

Referenced by addInterval(), and compute().

double RadialInterval::theR [private]

Definition at line 53 of file RadialInterval.h.

Referenced by addInterval(), and energyFractionInRadius().

Definition at line 55 of file RadialInterval.h.

Referenced by addInterval().

std::vector<double> RadialInterval::uMax [private]

Definition at line 59 of file RadialInterval.h.

Referenced by addInterval(), and getUmax().

std::vector<double> RadialInterval::uMin [private]

Definition at line 58 of file RadialInterval.h.

Referenced by addInterval(), and getUmin().