Hi there,

I have a TTree containing decay products, with energies given by pure theory (conservation of energy, momentum etc.), in the proportions predicted by pure theory (QFT decay width).

I would like to create distributions of what those particle energies would be reconstructed as after passing through an crystal calorimeter.

I have a crystal ball function:

```
double crystalball_function(double x, double alpha, double n, double sigma, double mean) {
// evaluate the crystal ball function
if (sigma < 0.) return 0.;
double z = (x - mean)/sigma;
if (alpha < 0) z = -z;
double abs_alpha = std::abs(alpha);
// double C = n/abs_alpha * 1./(n-1.) * std::exp(-alpha*alpha/2.);
// double D = std::sqrt(M_PI/2.)*(1.+ROOT::Math::erf(abs_alpha/std::sqrt(2.)));
// double N = 1./(sigma*(C+D));
if (z > - abs_alpha)
return std::exp(- 0.5 * z * z);
else {
//double A = std::pow(n/abs_alpha,n) * std::exp(-0.5*abs_alpha*abs_alpha);
double nDivAlpha = n/abs_alpha;
double AA = std::exp(-0.5*abs_alpha*abs_alpha);
double B = nDivAlpha -abs_alpha;
double arg = nDivAlpha/(B-z);
return AA * std::pow(arg,n);
}
}
```

And I get entries from sampleTree1 to write to sampleTree2

```
TChain *sampleTree1 = new TChain("sample","");
sampleTree1->Add("filenames");
Double_t x,y;
sampleTree1->SetBranchAddress("x",&x);
sampleTree1->SetBranchAddress("y",&y);
double alpha=1.19, double n=10, double sigma=3,49, double mean=70;
TTree *sampleTree2 = new TTree("sampleTree2","sampleTree2");
Double_t truex=0,truey=0,genweight=0, reconx=0,recony=0;
sampleTree2->Branch("truex",&truex);
sampleTree2->Branch("truey",&truey);
sampleTree2->Branch("reconx", &reconx);
sampleTree2->Branch("recony", &recony);
double smear1=1,smear2=1,smear3=1,smear4=1;
for (Long64_t jentry=0; jentry<nentries; jentry++) {
nb = sampleTree1->GetEntry(jentry); nbytes += nb;
truex=x;
truey=y;
reconx=crystalBall(x,alpha, n, sigma, mean);
recony=crystalBall(y,alpha, n, sigma, mean);
sampledTree2->Fill();
}
```

I am confused because when I do this I get reconstructed values that are exactly proportional to the true values–just a straight line plot. Shouldn’t the crystal ball function smear the value? Or do I need to insert a smearing manually in some other way (how?).

Many thanks!

EDIT: my basic question is equivalent to: how would I smear a ttree full of mono-energetic particles so that when I plot the resulting smeared energy, it looks like a crystal ball function?