Changeset 18282 for branches/MarsGapdTimeJitter/mdrs
- Timestamp:
- 08/18/15 10:28:44 (9 years ago)
- Location:
- branches/MarsGapdTimeJitter
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MarsGapdTimeJitter
- Property svn:mergeinfo changed
-
branches/MarsGapdTimeJitter/mdrs/MCalibrateDrsTimes.cc
r17759 r18282 152 152 continue; 153 153 154 const Float_t signal = (*fSignals)[sw].GetArrivalTime(); 154 const Float_t signal = (*fSignals)[sw].GetArrivalTimeHiGain(); 155 const Float_t slope = (*fSignals)[sw].GetArrivalTimeHiGainError(); 155 156 const Float_t offset = fCalib ? fCalib->GetOffset(hw, start[hw], signal) : 0; 156 const Float_t delay = fCalib ? fCalib->GetDelay(sw) : 0; 157 const Float_t offset2 = (fCalib && (signal-slope)>=0) ? fCalib->GetOffset(hw, start[hw], signal-slope) : 0; 158 const Float_t delay = fCalib ? fCalib->GetDelay(hw) : 0; 157 159 158 160 //if (fIsTimeMarker) … … 160 162 161 163 // convert from slices to ns 162 const Float_t utime = 1000*(signal )/fFreq-delay; // [ns] 163 const Float_t time = 1000*(signal-offset)/fFreq-delay; // [ns] 164 const Float_t utime = 1000*(signal )/fFreq-delay; // [ns] 165 const Float_t time = 1000*(signal-offset)/fFreq-delay; // [ns] 166 const Float_t slopecal = (slope-offset+offset2)<0 ? -1 : 1000*(slope-offset+offset2)/fFreq; // [ns] 167 const Float_t uslope = slope<0 ? -1 : 1000*(slope)/fFreq; // [ns] 164 168 165 169 /* … … 172 176 { 173 177 (*fArrivalTime)[idx[j]].SetArrivalTime(time); 178 (*fArrivalTime)[idx[j]].SetTimeSlope(slopecal); 174 179 if (fArrivalTimeU) 180 { 175 181 (*fArrivalTimeU)[idx[j]].SetArrivalTime(utime); 182 (*fArrivalTimeU)[idx[j]].SetTimeSlope(uslope); 183 } 176 184 } 177 185 } -
branches/MarsGapdTimeJitter/mdrs/MDrsCalibration.h
r17758 r18282 30 30 } 31 31 32 bool ReadFits(TString str)32 bool ReadFits(TString fname) 33 33 { 34 gSystem->ExpandPathName( str);34 gSystem->ExpandPathName(fname); 35 35 36 const std::string msg = ReadFitsImp(str.Data()); 36 std::string msg; 37 try 38 { 39 msg = ReadFitsImp(fname.Data()); 40 } 41 catch (const std::exception &e) 42 { 43 msg = e.what(); 44 } 45 37 46 if (msg.empty()) 47 { 48 *fLog << inf << "Read DRS calibration file " << fname << std::endl; 38 49 return true; 50 } 39 51 40 *fLog << err << msg << std::endl;52 *fLog << err << "Error reading from " << fname << ": " << msg << std::endl; 41 53 return false; 42 54 } -
branches/MarsGapdTimeJitter/mdrs/MDrsCalibrationTime.cc
r14922 r18282 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 2013 <mailto:t homas.bretz@epfl.ch>18 ! Author(s): Thomas Bretz 2013 <mailto:tbretz@physik.rwth-aachen.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-201 320 ! Copyright: MAGIC Software Development, 2000-2015 21 21 ! 22 22 ! … … 31 31 32 32 #include <TH1.h> 33 #include <TGraph.h> 33 34 34 35 ClassImp(MDrsCalibrationTime); … … 48 49 return true; 49 50 } 51 52 void MDrsCalibrationTime::SetDelays(const TGraph &g) 53 { 54 fDelays.assign(g.GetY(), g.GetY()+g.GetN()); 55 } 56 57 bool MDrsCalibrationTime::ReadFits(TString fname) 58 { 59 gSystem->ExpandPathName(fname); 60 61 try 62 { 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); 87 } 88 catch (const exception &e) 89 { 90 *fLog << err << "Error reading from " << fname << ": " << e.what() << endl; 91 return false; 92 } 93 94 *fLog << inf << "Read DRS calibration file " << fname << endl; 95 return true; 96 } 97 98 bool MDrsCalibrationTime::WriteFits(const string &fname) const 99 { 100 const Bool_t exists = !gSystem->AccessPathName(fname.c_str(), kFileExists); 101 if (exists) 102 { 103 *fLog << err << "File '" << fname << "' already exists." << endl; 104 return false; 105 } 106 107 try 108 { 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."); 138 } 139 catch (const exception &e) 140 { 141 *fLog << err << "Error writing to " << fname << ": " << e.what() << endl; 142 return false; 143 } 144 145 *fLog << inf << "Wrote DRS calibration file " << fname << endl; 146 return true; 147 } -
branches/MarsGapdTimeJitter/mdrs/MDrsCalibrationTime.h
r17697 r18282 10 10 11 11 class TH1; 12 class TGraph; 12 13 13 class MDrsCalibrationTime : public MParContainer , public DrsCalibrateTime14 class MDrsCalibrationTime : public MParContainer//, public DrsCalibrateTime 14 15 { 16 int64_t fNumEntries; 17 18 size_t fNumSamples; 19 size_t fNumChannels; 20 21 std::vector<double> fOffsets; 15 22 std::vector<double> fDelays; 16 23 … … 18 25 MDrsCalibrationTime(const char *name=0, const char *title=0) 19 26 { 20 fName = name ? name: "MDrsCalibrationTime";27 fName = name ? name : "MDrsCalibrationTime"; 21 28 fTitle = title ? title : ""; 22 29 } … … 24 31 void InitSize(uint16_t channels, uint16_t samples) 25 32 { 26 //fDelays.clear(); 27 //fDelays.resize(channels); 28 29 DrsCalibrateTime::InitSize(channels, samples); 33 fNumSamples = samples; 34 fNumChannels = channels; 30 35 } 31 36 32 37 void SetCalibration(const DrsCalibrateTime &cal) 33 38 { 34 *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); 35 48 } 36 49 37 50 bool SetDelays(const TH1 &cam); 51 void SetDelays(const TGraph &g); 38 52 39 double GetOffset( int hw, int spos, float tm) const53 double GetOffset(uint32_t hw, uint32_t spos, float tm) const 40 54 { 41 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]; 42 57 } 43 58 44 double GetDelay(int sw) const59 double GetDelay(int hw) const 45 60 { 46 return fDelays.size()==0 ? 0 : fDelays[ sw];61 return fDelays.size()==0 ? 0 : fDelays[hw]; 47 62 } 48 63 49 ClassDef(MDrsCalibrationTime, 2) // A list of histograms storing the Fadc spektrum of one pixel 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 50 68 }; 51 69 -
branches/MarsGapdTimeJitter/mdrs/MHDrsCalibrationTime.cc
r17760 r18282 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 -
branches/MarsGapdTimeJitter/mdrs/MHDrsCalibrationTime.h
r14922 r18282 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.