Changeset 2911
- Timestamp:
- 01/26/04 13:50:17 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2910 r2911 4 4 5 5 -*-*- END OF LINE -*-*- 6 7 2004/01/26: Markus Gaug 8 9 * manalysis/MArrivalTime.[h,cc]: 10 * manalysis/MArrivalTimeCalc.[h,cc]: 11 - moved calculation of arrival time from MArrivalTime to 12 MArrivalTimeCalc. MArrivalTime does not do any Process -job any 13 more 14 - TSpline5 now on stack. 15 6 16 7 17 2004/01/26: Thomas Bretz -
trunk/MagicSoft/Mars/manalysis/MArrivalTime.cc
r2910 r2911 65 65 void MArrivalTime::Reset() 66 66 { 67 // Do not use 'TArray::Reset()' or memset. It sets all single 68 // bytes to -1 (in other words, it fills the array with 0xff) 69 for (int i=0; i<fData.GetSize(); i++) 70 fData[i] = -1; 67 // 68 // Do not use 'TArray::Reset()' or memset. It sets all single 69 // bytes to -1 (in other words, it fills the array with 0xff) 70 for (int i=0; i<fData.GetSize(); i++) 71 fData[i] = -1; 71 72 } 72 73 … … 80 81 // Set the arrival time in one pixel 81 82 // 82 void MArrivalTime::SetTime( Int_t i,Float_t t)83 void MArrivalTime::SetTime(const Int_t i, const Float_t t) 83 84 { 84 85 fData[i] = t; 85 }86 87 // -------------------------------------------------------------------------88 //89 // Calculates the arrival time for each pixel90 // Possible Methods91 // Case 1: Spline5 (From TSpline5 Root Class)92 //93 //94 void MArrivalTime::Calc(const Byte_t *fadcSamples, const Short_t nSlice,95 const Short_t idx)96 {97 98 //Some casts are needed because TSpline5 constructor accepts only Double_t values99 Double_t ptr[nSlice];100 101 for (Int_t i = 0; i < nSlice; i++)102 ptr[i]=(Double_t)fadcSamples[i];103 104 TSpline5 *spline = new TSpline5("spline",(Double_t) 0,105 (Double_t)(nSlice - 1),ptr,nSlice);106 //Now find the maximum evaluating the spline function at every 1/10 time slice107 Double_t abscissa=0.0;108 Double_t maxAb=0.0;109 Double_t maxOrd=0.0;110 Double_t swap;111 while (abscissa <= nSlice - 1)112 {113 swap=spline->Eval(abscissa);114 if (swap > maxOrd)115 {116 maxOrd = swap;117 maxAb = abscissa;118 }119 abscissa += 0.1;120 }121 fData[idx]=maxAb;122 86 } 123 87 -
trunk/MagicSoft/Mars/manalysis/MArrivalTime.h
r2910 r2911 38 38 UInt_t GetNumPixels() const { return fData.GetSize(); } 39 39 40 void SetTime(Int_t i, Float_t time);41 const TArrayF &GetData() const { return fData; }42 Double_t operator[](int i) { return fData[i]; }43 44 void Calc(const Byte_t *fadcSamples, const Short_t nSlice, const Short_t idx);45 40 void EvalClusters(const MRawEvtData &evt, const MGeomCam &geom); 46 41 void CheckNeighbours(const MRawEvtData &evt, const MGeomCam &geom, 47 42 Short_t idx, Short_t *dimCluster); 43 44 void SetTime(const Int_t i, const Float_t time); 45 46 const TArrayF &GetData() const { return fData; } 47 48 Double_t operator[](int i) { return fData[i]; } 48 49 49 50 Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const; -
trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.cc
r2910 r2911 61 61 MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title) 62 62 { 63 63 64 fName = name ? name : "MArrivalTimeCalc"; 64 65 fTitle = title ? title : "Calculate photons arrival time"; … … 111 112 } 112 113 113 114 114 // -------------------------------------------------------------------------- 115 115 // … … 119 119 Int_t MArrivalTimeCalc::Process() 120 120 { 121 MRawEvtPixelIter pixel(fRawEvt); 122 123 while (pixel.Next()) 124 { 125 const UInt_t idx = pixel.GetPixelId(); 126 127 // If pixel is saturated we use LoGains 128 if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain()) 121 122 MRawEvtPixelIter pixel(fRawEvt); 123 124 while (pixel.Next()) 125 { 126 127 const UInt_t idx = pixel.GetPixelId(); 128 Float_t max = 0.; 129 130 131 // 132 // If pixel is saturated we use LoGains 133 // 134 if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain()) 135 { 136 137 const Short_t nslices = fRawEvt->GetNumLoGainSamples(); 138 max = Calc(pixel.GetLoGainSamples(),nslices); 139 } 140 141 142 // 143 // Use HiGains 144 // 145 else if (pixel.HasLoGain()) 146 { 147 148 const Short_t nslices = fRawEvt->GetNumHiGainSamples(); 149 max = Calc(pixel.GetHiGainSamples(),nslices); 150 } 151 152 // 153 // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1 154 // 155 fArrTime->SetTime(idx,max); 156 157 } 158 159 fArrTime->SetReadyToSave(); 160 161 return kTRUE; 162 } 163 164 // 165 // Calculates the arrival time for each pixel 166 // Possible Methods 167 // Case 1: Spline5 (From TSpline5 Root Class) 168 // 169 // 170 Float_t MArrivalTimeCalc::Calc(const Byte_t *fadcSamples, const Short_t nslices) 171 { 172 173 // 174 // Initialize a double pointer with filled FADC slices 175 // 176 Double_t ptr[nslices]; 177 178 // 179 // Initialize the spline 180 // 181 for (Int_t i = 0; i < nslices; i++) 182 ptr[i]=(Double_t)fadcSamples[i]; 183 184 TSpline5 spline("spline",0.,(Double_t)(nslices - 1),ptr,nslices); 185 186 // 187 // Now find the maximum evaluating the spline function at every 1/10 time slice 188 // 189 Double_t abscissa=0.0; 190 Double_t maxAb=0.0; 191 Double_t maxOrd=0.0; 192 Double_t swap = 0.0; 193 194 while (abscissa <= nslices - 1) 195 { 196 197 swap = spline.Eval(abscissa); 198 199 if (swap > maxOrd) 129 200 { 130 const Byte_t *ptr = pixel.GetLoGainSamples(); 131 const Short_t nSlice = fRawEvt->GetNumLoGainSamples(); 132 fArrTime->Calc(ptr, nSlice, idx); 201 maxOrd = swap; 202 maxAb = abscissa; 133 203 } 134 // Use HiGains 135 else 136 { 137 const Byte_t *ptr = pixel.GetHiGainSamples(); 138 const Short_t nSlice = fRawEvt->GetNumHiGainSamples(); 139 fArrTime->Calc(ptr, nSlice, idx); 140 } 141 // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1 142 } 143 144 fArrTime->SetReadyToSave(); 145 146 return kTRUE; 147 } 204 abscissa += 0.1; 205 } 206 207 return (Float_t)maxAb; 208 } 209 -
trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.h
r2910 r2911 7 7 8 8 class MRawEvtData; 9 class MRawRunHeader; 9 10 class MArrivalTime; 10 11 11 12 class MArrivalTimeCalc : public MTask 12 13 { 13 private:14 MRawEvtData *fRawEvt; // raw event data (time slices)15 MArrivalTime *fArrTime; // Container with the photons arrival times16 14 15 MRawEvtData *fRawEvt; // raw event data (time slices) 16 MRawRunHeader *fRunHeader; // RunHeader information 17 18 MArrivalTime *fArrTime; // Container with the photons arrival times 19 20 Int_t PreProcess(MParList *pList); 17 21 Bool_t ReInit(MParList *pList); 18 Int_t PreProcess(MParList *pList); 19 Int_t Process(); 20 Int_t PostProcess() {return kTRUE;} 22 Int_t Process(); 23 Int_t PostProcess() {return kTRUE;} 21 24 25 Float_t Calc(const Byte_t *fadcSamples, const Short_t nslices); 26 22 27 public: 23 28 MArrivalTimeCalc(const char *name=NULL, const char *title=NULL);
Note:
See TracChangeset
for help on using the changeset viewer.