source: branches/Corsika7405Compatibility/mdrs/MDrsCalibrationTime.h@ 19690

Last change on this file since 19690 was 18155, checked in by tbretz, 10 years ago
We now precalculate the DRS offsets. This is faster and allows to read and write them directly to a fits file.
File size: 1.7 KB
Line 
1#ifndef MARS_MDrsCalibrationTime
2#define MARS_MDrsCalibrationTime
3
4#ifndef MARS_MParContainer
5#include "MParContainer.h"
6#endif
7#ifndef MARS_DrsCalib
8#include "DrsCalib.h"
9#endif
10
11class TH1;
12class TGraph;
13
14class MDrsCalibrationTime : public MParContainer//, public DrsCalibrateTime
15{
16 int64_t fNumEntries;
17
18 size_t fNumSamples;
19 size_t fNumChannels;
20
21 std::vector<double> fOffsets;
22 std::vector<double> fDelays;
23
24public:
25 MDrsCalibrationTime(const char *name=0, const char *title=0)
26 {
27 fName = name ? name : "MDrsCalibrationTime";
28 fTitle = title ? title : "";
29 }
30
31 void InitSize(uint16_t channels, uint16_t samples)
32 {
33 fNumSamples = samples;
34 fNumChannels = channels;
35 }
36
37 void SetCalibration(const DrsCalibrateTime &cal)
38 {
39 fNumEntries = cal.fNumEntries,
40 fNumSamples = cal.fNumSamples,
41 fNumChannels = cal.fNumChannels,
42
43 fOffsets.resize(fNumSamples*fNumChannels);
44
45 for (size_t c=0; c<fNumChannels; c++)
46 for (size_t s=0; s<fNumSamples; s++)
47 fOffsets[c*fNumSamples+s] = cal.Offset(c, s);
48 }
49
50 bool SetDelays(const TH1 &cam);
51 void SetDelays(const TGraph &g);
52
53 double GetOffset(uint32_t hw, uint32_t spos, float tm) const
54 {
55 const uint32_t ch = (hw/9)*fNumSamples;
56 return fOffsets[ch + fmod(tm+spos, fNumSamples)] - fOffsets[ch + spos];
57 }
58
59 double GetDelay(int hw) const
60 {
61 return fDelays.size()==0 ? 0 : fDelays[hw];
62 }
63
64 bool ReadFits(TString fname);
65 bool WriteFits(const std::string &fname) const;
66
67 ClassDef(MDrsCalibrationTime, 3) // A list of histograms storing the Fadc spektrum of one pixel
68};
69
70#endif
71
Note: See TracBrowser for help on using the repository browser.