source: fact/tools/rootmacros/FPedestalAllPx.c@ 20096

Last change on this file since 20096 was 12170, checked in by neise, 13 years ago
small fix: Thomas and Werner
File size: 2.2 KB
Line 
1#include <cstdio>
2int FPedestalAllPx(
3 fits &datafile,
4 vector<int16_t> &data,
5 vector<int16_t> &data_offset,
6 vector<float> &drs_basemean,
7 vector<float> &drs_gainmean,
8 vector<float> &drs_triggeroffsetmean,
9 UInt_t data_px,
10 UInt_t data_roi,
11 float pedestal_mean[],
12 float pedestal_rms[] )
13{
14// TCanvas *canv_base = new TCanvas( "canv_base", "Determine the baseline", 100, 520, 700, 500 );
15// canv_base->SetLogy();
16
17 char title_base[500];
18 char name_base[50];
19 TH1F* baseline[data_px];
20 for(int i=0; i<data_px; i++) {
21
22 std::sprintf(title_base,"Baseline of Px %i",i);
23 std::sprintf(name_base,"base%i",i);
24
25 baseline[i] = new TH1F(name_base,title_base,2000,-99.5,100.5);
26 baseline[i]->GetXaxis()->SetTitle("Sample value (mV)");
27 baseline[i]->GetYaxis()->SetTitle("Entries");
28 }
29
30//-------------------------------------------
31//Find the baseline
32//-------------------------------------------
33 for (size_t i=0; ( i<datafile.GetNumRows() ); i++)
34 {
35 datafile.GetRow(i);
36 if( i%50 == 0 ) cout << "Loop variable: " << i << endl;
37
38 //Iterate over the pixels
39 for (int j=0; j<data_px; j++)
40 {
41// size_t j=pixelnr; //Fix the Pixel to a SoftID
42
43 //Iterate over the slices
44 for (UInt_t k=0; k<data_roi; k++)
45 {
46 UInt_t drs_calib_offset = (k+data_offset[j])%data_roi;
47 float sample = (data[j*data_roi+k]*2000/4096.-drs_basemean[j*data_roi+drs_calib_offset]-drs_triggeroffsetmean[j*data_roi+k])/drs_gainmean[j*data_roi+drs_calib_offset]*1907.35;
48 baseline[j]->Fill(sample);
49
50 //Original code
51 //UInt_t drs_calib_offset = (k+data_offset[j])%data_roi;
52 //float sample = (data[j*data_roi+k]*2000/4096.-drs_basemean[j*data_roi+drs_calib_offset]-drs_triggeroffsetmean[j*data_roi+k])/drs_gainmean[j*data_roi+drs_calib_offset]*1907.35;
53 //baseline->Fill(sample);
54 }
55 }
56 }
57
58 for (int j=0; j<data_px; j++) {
59 pedestal_mean[j] = baseline[j]->GetXaxis()->GetBinCenter(baseline[j]->GetMaximumBin());
60 pedestal_rms[j] = baseline[j]->GetRMS();
61 }
62// std::cout << "Value of maximal probability Px 1348: " << pedestal_mean[1348] << " +- " << pedestal_rms[1348] << std::endl;
63
64// canv_base->cd();
65// baseline->Draw();
66// canv_base->Modified();
67// canv_base->Update();
68
69 return 0;
70}
Note: See TracBrowser for help on using the repository browser.