CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
RadialInterval Class Reference

#include <RadialInterval.h>

Public Member Functions

void addInterval (double, double)
 
void compute ()
 
unsigned getNumberOfSpots (unsigned i) const
 Number of spots in a given interval. More...
 
double getSpotEnergy (unsigned i) const
 Spot energy in a given interval. More...
 
double getUmax (unsigned i) const
 Upper limit of the argument in the radius generator. More...
 
double getUmin (unsigned i) const
 Lower limit of the argument in the radius generator. More...
 
unsigned nIntervals () const
 Number of intervals. More...
 
 RadialInterval (double RC, unsigned nSpots, double energy, const RandomEngineAndDistribution *engine)
 Standard constructor Rc: mean Radius. More...
 
 ~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 RandomEngineAndDistributionrandom
 
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 RandomEngineAndDistribution engine 
)

Standard constructor Rc: mean Radius.

Definition at line 7 of file RadialInterval.cc.

References currentEnergyFraction, currentRad, currentUlim, and nInter.

9  :
10  theR(RC),theNumberOfSpots(nSpots),theSpotEnergy(energy),random(engine)
11 {
12 
13  currentRad=0.;
15  currentUlim=0.;
16  nInter=0;
17 }
const RandomEngineAndDistribution * random
double currentEnergyFraction
unsigned theNumberOfSpots
double theSpotEnergy
RadialInterval::~RadialInterval ( )
inline

Definition at line 19 of file RadialInterval.h.

References addInterval(), and compute().

19 {;}

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(), RandomEngineAndDistribution::gaussShoot(), nInter, nspots, TCMET_cfi::radius, random, spotE, spotfraction, mathSSE::sqrt(), theNumberOfSpots, theR, theSpotEnergy, uMax, and uMin.

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

20 {
21  double radiussq=radius*radius;
22  double enFrac=energyFractionInRadius(radius);
23  if(radius>10) enFrac=1.;
24  double energyFrac=enFrac-currentEnergyFraction;
25  currentEnergyFraction=enFrac;
26  // std::cout << " Rad " << nInter << " Energy frac " << energyFrac << std::endl;
27 
28  // Calculates the number of spots. Add binomial fluctuations
29  double dspot = random->gaussShoot(theNumberOfSpots*energyFrac,
30  sqrt(energyFrac*(1.-energyFrac)*theNumberOfSpots));
31  // std::cout << " Normal : " << theNumberOfSpots*energyFrac << " "<< dspot << std::endl;
32  unsigned nspot=(unsigned)(dspot*spotf+0.5);
33 // if(nspot<100)
34 // {
35 // spotf=1.;
36 // nspot=(unsigned)(theNumberOfSpots*energyFrac+0.5);
37 // }
38 
39  dspotsunscaled.push_back(dspot);
40  spotfraction.push_back(spotf);
41 
42  double spotEnergy=theSpotEnergy/spotf;
43  // std::cout << " The number of spots " << theNumberOfSpots << " " << nspot << std::endl;
44 
45  // This is not correct for the last interval, but will be overriden later
46  nspots.push_back(nspot);
47  spotE.push_back(spotEnergy);
48  // computes the limits
49  double umax = radiussq/(radiussq+theR*theR);
50  if(radius>10)
51  {
52  umax=1.;
53  }
54 
55  // Stores the limits
56  uMax.push_back(umax);
57  uMin.push_back(currentUlim);
58  currentUlim=umax;
59 
60  // Stores the energy
61  // std::cout << " SpotE " << theSpotEnergy<< " " << spotf << " " << theSpotEnergy/spotf<< std::endl;
62 
63  ++nInter;
64 }
std::vector< double > spotE
const RandomEngineAndDistribution * random
T sqrt(T t)
Definition: SSEVec.h:18
double currentEnergyFraction
std::vector< double > uMin
std::vector< double > spotfraction
std::vector< double > uMax
std::vector< unsigned > nspots
unsigned theNumberOfSpots
double energyFractionInRadius(double rm)
std::vector< double > dspotsunscaled
double gaussShoot(double mean=0.0, double sigma=1.0) const
double theSpotEnergy
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(), and ~RadialInterval().

73 {
74  // std::cout << " The number of Spots " << theNumberOfSpots << std::endl;
75  // std::cout << " Size : " << nInter << " " << nspots.size() << " " << dspotsunscaled.size() << std::endl;
76  double ntotspots=0.;
77  for(unsigned irad=0;irad<nInter-1;++irad)
78  {
79  ntotspots+=dspotsunscaled[irad];
80  // std::cout << " In the loop " << ntotspots << std::endl;
81  }
82 
83  // This can happen (fluctuations)
84  if(ntotspots>theNumberOfSpots) ntotspots=(double)theNumberOfSpots;
85  // std::cout << " Sous-total " << ntotspots << std::endl;
86  dspotsunscaled[nInter-1]=(double)theNumberOfSpots-ntotspots;
87 
88  nspots[nInter-1]=(unsigned)(dspotsunscaled[nInter-1]*spotfraction[nInter-1]+0.5);
89  // std::cout << " Nlast " << nspots[nInter-1] << std::endl;
90 }
std::vector< double > spotfraction
std::vector< unsigned > nspots
unsigned theNumberOfSpots
std::vector< double > dspotsunscaled
double RadialInterval::energyFractionInRadius ( double  rm)
private

Definition at line 66 of file RadialInterval.cc.

References submit::rm, and theR.

Referenced by addInterval().

67 {
68  double rm2=rm*rm;
69  return (rm2/(rm2+theR*theR));
70 }
rm
Definition: submit.py:77
unsigned RadialInterval::getNumberOfSpots ( unsigned  i) const
inline

Number of spots in a given interval.

Definition at line 34 of file RadialInterval.h.

References mps_fire::i, and nspots.

Referenced by EMShower::compute().

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

Spot energy in a given interval.

Definition at line 30 of file RadialInterval.h.

References mps_fire::i, and spotE.

Referenced by EMShower::compute().

30  {
31  // std::cout << " getSpotEnergy " << i << " " << spotE.size() << std::endl;
32  return spotE[i];}
std::vector< double > spotE
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 mps_fire::i, and uMax.

Referenced by EMShower::compute().

44  {
45  // std::cout << " getUmax " << i << " " << uMax.size() << std::endl;
46  return uMax[i];
47  }
std::vector< double > uMax
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 mps_fire::i, and uMin.

Referenced by EMShower::compute().

39  {
40  // std::cout << " getUmin " << i << " " << uMin.size() << std::endl;
41  return uMin[i];
42  }
std::vector< double > uMin
unsigned RadialInterval::nIntervals ( ) const
inline

Number of intervals.

Definition at line 28 of file RadialInterval.h.

References nInter.

Referenced by EMShower::compute().

28 { return nInter;}

Member Data Documentation

double RadialInterval::currentEnergyFraction
private

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().

const RandomEngineAndDistribution* RadialInterval::random
private

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().

unsigned RadialInterval::theNumberOfSpots
private

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().

double RadialInterval::theSpotEnergy
private

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().