CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RadialInterval.cc
Go to the documentation of this file.
1 //FAMOS header
4 
5 #include <cmath>
6 
7 RadialInterval::RadialInterval(double RC,unsigned nSpots,double energy,
8  const RandomEngine* engine)
9  :
10  theR(RC),theNumberOfSpots(nSpots),theSpotEnergy(energy),random(engine)
11 {
12 
13  currentRad=0.;
15  currentUlim=0.;
16  nInter=0;
17 }
18 
19 void RadialInterval::addInterval(double radius, double spotf)
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 }
65 
67 {
68  double rm2=rm*rm;
69  return (rm2/(rm2+theR*theR));
70 }
71 
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 > spotE
TRandom random
Definition: MVATrainer.cc:138
double gaussShoot(double mean=0.0, double sigma=1.0) const
Definition: RandomEngine.h:37
RadialInterval(double RC, unsigned nSpots, double energy, const RandomEngine *engine)
Standard constructor Rc: mean Radius.
T sqrt(T t)
Definition: SSEVec.h:28
string rm
Definition: submit.py:76
double currentEnergyFraction
std::vector< double > uMin
std::vector< double > spotfraction
const RandomEngine * random
std::vector< double > uMax
std::vector< unsigned > nspots
unsigned theNumberOfSpots
double energyFractionInRadius(double rm)
std::vector< double > dspotsunscaled
double theSpotEnergy
void addInterval(double, double)