21 Float_t
computeSd(Float_t* avg, Int_t n_entries, TTree*
t, Float_t* gen_);
25 vector<UShort_t>* order,
26 vector<Float_t>* dict,
34 using namespace std::chrono;
35 return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).
count();
41 logFile.open (
"log.csv");
42 logFile <<
"file,points,variable,dltSD,bits,dltdltSD/dltSD,avg,LB,UB,msec" << endl;
49 TFile *
f =
new TFile(filename,
"read");
50 TTree *
t = (TTree*)f->Get(
"ntp_trkres");
54 t->SetBranchAddress(
"v1",&genv1_);
55 t->SetBranchAddress(
"v2",&genv2_);
56 Int_t n_entries = (Int_t)t->GetEntries();
60 Float_t dltSD =
computeSd(&avg, n_entries, t, &genv1_);
61 for (Int_t numBits = 3; numBits < 12; ++numBits) {
62 vector<UShort_t> v1_order;
63 vector<Float_t> v1_dict;
64 vector<size_t> v1_cnt;
66 Float_t dltdltSD =
approx(&v1_order, &v1_dict, &v1_cnt, n_entries, t, &genv1_, (
size_t) pow(2, numBits));
69 << v1_order.size() <<
",dphi,"
72 << dltdltSD / dltSD <<
","
74 << avg - 4 * dltSD <<
","
75 << avg + 4 * dltSD <<
","
77 output_before_vs_after(filename +
"_dltPHI_" + numBits +
"bits.csv", &v1_order, &v1_dict, n_entries, t, &genv1_);
82 dltSD =
computeSd(&avg, n_entries, t, &genv2_);
83 for (Int_t numBits = 3; numBits < 12; ++numBits) {
84 vector<UShort_t> v2_order;
85 vector<Float_t> v2_dict;
86 vector<size_t> v2_cnt;
88 Float_t dltdltSD =
approx(&v2_order, &v2_dict, &v2_cnt, n_entries, t, &genv2_, (
size_t) pow(2, numBits));
91 << v2_order.size() <<
",dz,"
94 << dltdltSD / dltSD <<
","
96 << avg - 4 * dltSD <<
","
97 << avg + 4 * dltSD <<
","
99 output_before_vs_after(filename +
"_dltZ_" + numBits +
"bits.csv", &v2_order, &v2_dict, n_entries, t, &genv2_);
103 Float_t
computeSd(Float_t* avg, Int_t n_entries, TTree*
t, Float_t* gen_)
105 Double_t sumSquared = 0;
107 for (Int_t
j = 0 ;
j < n_entries;
j++){
110 sumSquared += (Double_t) *gen_ * (Double_t) *gen_;
111 sum += (Double_t) *gen_;
114 Double_t _avg = sum / (Double_t) n_entries;
117 return sqrt((sumSquared / (Double_t) n_entries) - _avg * _avg);
123 myfile.open(filename);
124 myfile <<
"before,after" << endl;
125 for (Int_t
j = 0 ;
j < n_entries;
j++){
127 myfile << *gen_ <<
"," << dict->at(order->at(
j)) << endl;