4 TFile *f = TFile::Open(
"M0001/pxar.root");
14 for (
int i = 0; i < 16; ++i) {
17 h = (TH1D*)gDirectory->Get(Form(
"dist_thr_calSMap_VthrComp_C%d_V0", i));
18 nPeaks = s.Search(h, 5,
"", 0.01);
19 cout <<
"found " << nPeaks <<
" peaks in " << h->GetName() << endl;
20 cutDead = fitPeaks(h, s, nPeaks);
21 bbprob =
static_cast<int>(h->Integral(cutDead, h->FindBin(255)));
22 cout <<
"dead bumps: " << bbprob << endl;
24 pl->DrawLine(cutDead, 0, cutDead, h->GetMaximum());
33 int fitPeaks(TH1D *h, TSpectrum &s,
int npeaks) {
35 Float_t *xpeaks = s.GetPositionX();
37 double lcuts[3]; lcuts[0] = lcuts[1] = lcuts[2] = 255.;
39 double peak, sigma, rms;
41 for (
int p = 0; p < npeaks; ++p) {
42 double xp = xpeaks[p];
45 cout <<
"do not fit peak at " << xp << endl;
48 name = Form(
"gauss_%d", p);
49 f =
new TF1(name.c_str(),
"gaus(0)", 0., 256.);
50 int bin = h->GetXaxis()->FindBin(xp);
51 double yp = h->GetBinContent(bin);
52 f->SetParameters(yp, xp, 2.);
55 peak = h->GetFunction(name.c_str())->GetParameter(1);
56 sigma = h->GetFunction(name.c_str())->GetParameter(2);
58 lcuts[0] = peak + 3*sigma;
59 if (h->Integral(h->FindBin(peak + 10.*sigma), 250) > 10.) {
60 lcuts[1] = peak + 5*sigma;
62 lcuts[1] = peak + 10*sigma;
65 lcuts[1] = peak - 3*sigma;
66 lcuts[2] = peak - sigma;
71 int startbin = (int)(0.5*(lcuts[0] + lcuts[1]));
72 int endbin = (int)(lcuts[1]);
73 if (endbin <= startbin) {
74 endbin = (int)(lcuts[2]);
75 if (endbin < startbin) {
83 for (
int i = startbin; i <= endbin; ++i) {
84 if (h->GetBinContent(i) < minval) {
85 if (1 == fittedPeaks) {
86 if (0 == h->Integral(i, i+4)) {
87 minval = h->GetBinContent(i);
93 minval = h->GetBinContent(i);
99 cout <<
"cut for dead bump bonds: " << minbin <<
" (obtained for minval = " << minval <<
")"
100 <<
" start: " << startbin <<
" .. " << endbin
101 <<
" last peak: " << peak <<
" sigma: " << sigma
102 <<
" lcuts[0] = " << lcuts[0] <<
" lcuts[1] = " << lcuts[1]