|
1 | 1 | #include "lutCovm.hh" |
2 | 2 |
|
3 | | -TGraph * |
4 | | -lutRead_dca(const char *filename = "lutCovm.dat", double eta = 0.) |
| 3 | +TGraph* lutRead_dca(const char* filename = "lutCovm.dat", |
| 4 | + double eta = 0., |
| 5 | + double nch = 100.) |
5 | 6 | { |
6 | | - |
| 7 | + |
7 | 8 | // input file |
8 | 9 | ifstream lutFile(filename, std::ofstream::binary); |
9 | 10 |
|
10 | 11 | // read header |
11 | 12 | lutHeader_t lutHeader; |
12 | | - lutFile.read(reinterpret_cast<char *>(&lutHeader), sizeof(lutHeader)); |
| 13 | + lutFile.read(reinterpret_cast<char*>(&lutHeader), sizeof(lutHeader)); |
13 | 14 | lutHeader.print(); |
14 | 15 |
|
15 | 16 | // entries |
16 | 17 | const int nnch = lutHeader.nchmap.nbins; |
17 | 18 | const int nrad = lutHeader.radmap.nbins; |
18 | 19 | const int neta = lutHeader.etamap.nbins; |
19 | 20 | const int npt = lutHeader.ptmap.nbins; |
20 | | - lutEntry_t lutTable[nnch][nrad][neta][npt]; |
21 | | - |
| 21 | + lutEntry_t lutTable; |
| 22 | + |
| 23 | + const int nch_bin = lutHeader.nchmap.find(nch); |
| 24 | + const int rad_bin = lutHeader.radmap.find(0.); |
| 25 | + const int eta_bin = lutHeader.etamap.find(eta); |
| 26 | + |
| 27 | + // create graph of pt resolution at eta = 0 |
| 28 | + auto gpt = new TGraph(); |
| 29 | + gpt->SetName(filename); |
| 30 | + gpt->SetTitle(filename); |
| 31 | + gpt->GetXaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); |
| 32 | + gpt->GetYaxis()->SetTitle("pointing resolution (#mum)"); |
| 33 | + |
22 | 34 | // read entries |
23 | 35 | for (int inch = 0; inch < nnch; ++inch) { |
24 | 36 | for (int irad = 0; irad < nrad; ++irad) { |
25 | 37 | for (int ieta = 0; ieta < neta; ++ieta) { |
26 | 38 | for (int ipt = 0; ipt < npt; ++ipt) { |
27 | | - lutFile.read(reinterpret_cast<char *>(&lutTable[inch][irad][ieta][ipt]), sizeof(lutEntry_t)); |
28 | | - // lutTable[inch][irad][ieta][ipt].print(); |
| 39 | + lutFile.read(reinterpret_cast<char*>(&lutTable), sizeof(lutEntry_t)); |
| 40 | + // lutTable.print(); |
| 41 | + auto lutEntry = &lutTable; |
| 42 | + if (!lutEntry->valid) { |
| 43 | + std::cout << " ipt = " << ipt << " is not valid " << std::endl; |
| 44 | + continue; |
| 45 | + } |
| 46 | + if (nch_bin != inch) { |
| 47 | + continue; |
| 48 | + } |
| 49 | + if (eta_bin != ieta) { |
| 50 | + continue; |
| 51 | + } |
| 52 | + if (rad_bin != irad) { |
| 53 | + continue; |
| 54 | + } |
| 55 | + auto cen = lutEntry->pt; |
| 56 | + auto val = sqrt(lutEntry->covm[0]) * 1.e4; |
| 57 | + gpt->SetPoint(gpt->GetN(), cen, val); |
29 | 58 | } |
30 | 59 | } |
31 | 60 | } |
32 | 61 | } |
33 | 62 |
|
34 | 63 | lutFile.close(); |
35 | 64 |
|
36 | | - // create graph of pt resolution at eta = 0 |
37 | | - auto inch = lutHeader.nchmap.find(0.); |
38 | | - auto irad = lutHeader.radmap.find(0.); |
39 | | - auto ieta = lutHeader.etamap.find(eta); |
40 | | - auto gpt = new TGraph(); |
41 | | - gpt->SetName(filename); |
42 | | - gpt->SetTitle(filename); |
43 | | - gpt->GetXaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); |
44 | | - gpt->GetYaxis()->SetTitle("pointing resolution (#mum)"); |
45 | | - for (int ipt = 0; ipt < npt; ++ipt) { |
46 | | - auto lutEntry = &lutTable[inch][irad][ieta][ipt]; |
47 | | - if (!lutEntry->valid) { |
48 | | - std::cout << " ipt = " << ipt << " is not valid " << std::endl; |
49 | | - continue; |
50 | | - } |
51 | | - auto cen = lutEntry->pt; |
52 | | - auto val = sqrt(lutEntry->covm[0]) * 1.e4; |
53 | | - gpt->SetPoint(gpt->GetN(), cen, val); |
54 | | - } |
55 | | - |
56 | 65 | return gpt; |
57 | | - |
58 | 66 | } |
0 commit comments