Changeset 18155 for trunk/Mars
- Timestamp:
- 02/19/15 10:37:24 (10 years ago)
- Location:
- trunk/Mars/mdrs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mdrs/MDrsCalibrationTime.cc
r18151 r18155 59 59 gSystem->ExpandPathName(fname); 60 60 61 string msg;62 61 try 63 62 { 64 msg = DrsCalibrateTime::ReadFitsImp(fname.Data()); 63 fits file(fname.Data()); 64 if (!file) 65 throw runtime_error(strerror(errno)); 66 67 if (file.GetStr("TELESCOP")!="FACT") 68 { 69 std::ostringstream msg; 70 msg << "Not a valid FACT file (TELESCOP not FACT in header)"; 71 throw runtime_error(msg.str()); 72 } 73 74 if (file.GetNumRows()!=1) 75 throw runtime_error("Number of rows in table is not 1."); 76 77 fNumSamples = file.GetUInt("NROI"); 78 fNumChannels = file.GetUInt("NCH"); 79 fNumEntries = file.GetUInt("NBTIME"); 80 81 const double *d = reinterpret_cast<double*>(file.SetPtrAddress("CellOffset")); 82 if (!file.GetNextRow()) 83 throw runtime_error("Read error."); 84 85 fOffsets.assign(d, d+fNumSamples*fNumChannels), 86 fDelays.resize(0); 65 87 } 66 88 catch (const exception &e) 67 89 { 68 msg = e.what(); 90 *fLog << err << "Error reading from " << fname << ": " << e.what() << endl; 91 return false; 69 92 } 70 93 71 if (msg.empty()) 72 { 73 *fLog << inf << "Read DRS calibration file " << fname << endl; 74 return true; 75 } 76 77 *fLog << err << "Error reading from " << fname << ": " << msg << endl; 78 return false; 94 *fLog << inf << "Read DRS calibration file " << fname << endl; 95 return true; 79 96 } 80 97 … … 88 105 } 89 106 90 string msg;91 107 try 92 108 { 93 msg = DrsCalibrateTime::WriteFitsImp(fname); 109 ofits file(fname.c_str()); 110 if (!file) 111 throw runtime_error(strerror(errno)); 112 113 file.SetDefaultKeys(); 114 file.AddColumnDouble(fNumSamples*fNumChannels, "CellOffset", "samples", "Integral cell offset"); 115 116 file.SetInt("ADCRANGE", 2000, "Dynamic range of the ADC in mV"); 117 file.SetInt("DACRANGE", 2500, "Dynamic range of the DAC in mV"); 118 file.SetInt("ADC", 12, "Resolution of ADC in bits"); 119 file.SetInt("DAC", 16, "Resolution of DAC in bits"); 120 file.SetInt("NPIX", 1440, "Number of channels in the camera"); 121 file.SetInt("NTM", 0, "Number of time marker channels"); 122 file.SetInt("NROI", fNumSamples, "Region of interest"); 123 file.SetInt("NCH", fNumChannels, "Number of chips"); 124 file.SetInt("NBTIME", fNumEntries, "Num of entries for time calibration"); 125 126 file.WriteTableHeader("DrsCellTimes"); 127 //file.SetInt("NIGHT", night, "Night as int"); 128 129 /* 130 file.SetStr("DATE-OBS", fDateObs, "First event of whole DRS calibration"); 131 file.SetStr("DATE-END", fDateEnd, "Last event of whole DRS calibration"); 132 file.SetStr("RUN-BEG", fDateRunBeg[0], "First event of run 0"); 133 file.SetStr("RUN-END", fDateRunEnd[0], "Last event of run 0"); 134 */ 135 136 if (!file.WriteRow(fOffsets.data(), fOffsets.size()*sizeof(double))) 137 throw runtime_error("Write error."); 94 138 } 95 139 catch (const exception &e) 96 140 { 97 msg = e.what(); 141 *fLog << err << "Error writing to " << fname << ": " << e.what() << endl; 142 return false; 98 143 } 99 144 100 if (msg.empty()) 101 { 102 *fLog << inf << "Wrote DRS calibration file " << fname << endl; 103 return true; 104 } 105 106 *fLog << err << "Error writing to " << fname << ": " << msg << endl; 107 return false; 145 *fLog << inf << "Wrote DRS calibration file " << fname << endl; 146 return true; 108 147 } -
trunk/Mars/mdrs/MDrsCalibrationTime.h
r18154 r18155 12 12 class TGraph; 13 13 14 class MDrsCalibrationTime : public MParContainer , public DrsCalibrateTime14 class MDrsCalibrationTime : public MParContainer//, public DrsCalibrateTime 15 15 { 16 int64_t fNumEntries; 17 18 size_t fNumSamples; 19 size_t fNumChannels; 20 21 std::vector<double> fOffsets; 16 22 std::vector<double> fDelays; 17 23 … … 19 25 MDrsCalibrationTime(const char *name=0, const char *title=0) 20 26 { 21 fName = name ? name: "MDrsCalibrationTime";27 fName = name ? name : "MDrsCalibrationTime"; 22 28 fTitle = title ? title : ""; 23 29 } … … 25 31 void InitSize(uint16_t channels, uint16_t samples) 26 32 { 27 //fDelays.clear(); 28 //fDelays.resize(channels); 29 30 DrsCalibrateTime::InitSize(channels, samples); 33 fNumSamples = samples; 34 fNumChannels = channels; 31 35 } 32 36 33 37 void SetCalibration(const DrsCalibrateTime &cal) 34 38 { 35 *static_cast<DrsCalibrateTime*>(this) = cal; 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); 36 48 } 37 49 … … 39 51 void SetDelays(const TGraph &g); 40 52 41 double GetOffset( int hw, int spos, float tm) const53 double GetOffset(uint32_t hw, uint32_t spos, float tm) const 42 54 { 43 return Offset(hw/9, fmod(tm+spos, 1024)) - Offset(hw/9, spos); 55 const uint32_t ch = (hw/9)*fNumSamples; 56 return fOffsets[ch + fmod(tm+spos, fNumSamples)] - fOffsets[ch + spos]; 44 57 } 45 58 … … 52 65 bool WriteFits(const std::string &fname) const; 53 66 54 ClassDef(MDrsCalibrationTime, 2) // A list of histograms storing the Fadc spektrum of one pixel67 ClassDef(MDrsCalibrationTime, 3) // A list of histograms storing the Fadc spektrum of one pixel 55 68 }; 56 69 -
trunk/Mars/mdrs/MHDrsCalibrationTime.cc
r17760 r18155 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 2013 <mailto:tbretz@phys .ethz.ch>19 ! 20 ! Copyright: MAGIC Software Development, 2000-201 418 ! Author(s): Thomas Bretz 2013 <mailto:tbretz@physik.rwth-aachen.de> 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2015 21 21 ! 22 22 ! … … 37 37 #include "MStatusDisplay.h" 38 38 39 #include "MDrsCalibrationTime.h" 39 40 #include "MPedestalSubtractedEvt.h" 40 41 -
trunk/Mars/mdrs/MHDrsCalibrationTime.h
r14922 r18155 2 2 #define MARS_MHDrsCalibrationTime 3 3 4 #ifndef MARS_DrsCalib rationTime5 #include " MDrsCalibrationTime.h"4 #ifndef MARS_DrsCalib 5 #include "DrsCalib.h" 6 6 #endif 7 7 … … 23 23 MDrsCalibrationTime *fCal; //! 24 24 25 MDrsCalibrationTime fData; //25 DrsCalibrateTime fData; // 26 26 27 27 void InitHistogram();
Note:
See TracChangeset
for help on using the changeset viewer.