Changeset 3911 for trunk/MagicSoft/Mars/msignal
- Timestamp:
- 04/30/04 15:47:11 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/msignal
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/msignal/MExtractPINDiode.cc
r3322 r3911 27 27 // MExtractPINDiode 28 28 // 29 // Extracts the signal from a fixed window in a given range. 30 // 31 // Call: SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast) 32 // to modify the ranges. Ranges have to be an even number. In case of odd 33 // ranges, the last slice will be reduced by one. 34 // Defaults are: 35 // 36 // fHiGainFirst = fgHiGainFirst = 3 37 // fHiGainLast = fgHiGainLast = 14 38 // fLoGainFirst = fgLoGainFirst = 3 39 // fLoGainLast = fgLoGainLast = 14 40 // 29 41 ////////////////////////////////////////////////////////////////////////////// 30 42 #include "MExtractPINDiode.h" 43 #include "MExtractor.h" 31 44 32 45 #include <fstream> … … 49 62 using namespace std; 50 63 51 const UInt_t MExtractPINDiode::fgPINDiodeIdx = 1 ;52 const Byte_t MExtractPINDiode::fg SaturationLimit = 254;53 const Byte_t MExtractPINDiode::fg First = 1;54 const Byte_t MExtractPINDiode::fgL ast = 30;55 64 const UInt_t MExtractPINDiode::fgPINDiodeIdx = 100; 65 const Byte_t MExtractPINDiode::fgHiGainFirst = 0; 66 const Byte_t MExtractPINDiode::fgHiGainLast = 14; 67 const Byte_t MExtractPINDiode::fgLoGainFirst = 0; 68 const Byte_t MExtractPINDiode::fgLoGainLast = 14; 56 69 // -------------------------------------------------------------------------- 57 70 // 58 71 // Default constructor. 59 72 // 73 // Calls: 74 // - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast) 75 // - SetPINDiodeIdx() 76 // 60 77 MExtractPINDiode::MExtractPINDiode(const char *name, const char *title) 61 : fSaturationLimit(fgSaturationLimit)62 78 { 63 79 … … 65 81 fTitle = title ? title : "Task to extract the signal from the FADC slices"; 66 82 67 AddToBranchList("MRawEvtData.*"); 68 83 SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast); 69 84 SetPINDiodeIdx(); 70 SetSaturationLimit(); 71 SetRange(); 72 } 73 74 void MExtractPINDiode::SetRange(Byte_t first, Byte_t last) 75 { 76 77 fNumSamples = last-first+1; 78 fFirst = first; 79 fLast = last; 80 81 fSqrtSamples = TMath::Sqrt((Float_t)fNumSamples); 82 } 83 84 // -------------------------------------------------------------------------- 85 // 86 // The PreProcess searches for the following input containers: 87 // - MRawEvtData 88 // - MPedestalCam 85 } 86 87 // -------------------------------------------------------------------------- 88 // 89 // SetRange: 90 // 91 // Checks: 92 // - if the window defined by (fHiGainLast-fHiGainFirst-1) are odd, subtract one 93 // - if the window defined by (fLoGainLast-fLoGainFirst-1) are odd, subtract one 94 // - if the Hi Gain window is smaller than 2, set fHiGainLast to fHiGainFirst+1 95 // - if the Lo Gain window is smaller than 2, set fLoGainLast to fLoGainFirst+1 96 // 97 // Calls: 98 // - MExtractor::SetRange(hifirst,hilast,lofirst,lolast); 99 // 100 // Sets: 101 // - fNumHiGainSamples to: (Float_t)(fHiGainLast-fHiGainFirst+1) 102 // - fNumLoGainSamples to: (Float_t)(fLoGainLast-fLoGainFirst+1) 103 // - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples) 104 // - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples) 105 // 106 void MExtractPINDiode::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast) 107 { 108 109 const Byte_t window = hilast-hifirst+1+lolast-lofirst+1; 110 const Byte_t weven = window & ~1; 111 112 if (weven != window) 113 { 114 *fLog << warn << GetDescriptor() 115 << Form("%s%2i%s%2i",": Total window size has to be even, set last slice from " 116 ,(int)lolast," to ",(int)(lolast-1)) << endl; 117 lolast -= 1; 118 } 119 120 if (window<2) 121 { 122 *fLog << warn << GetDescriptor() 123 << Form("%s%2i%s%2i",": Total window is smaller than 2 FADC sampes, set last slice from" 124 ,(int)lolast," to ",(int)(lofirst+1)) << endl; 125 hilast = hifirst+1; 126 } 127 128 129 MExtractor::SetRange(hifirst,hilast,lofirst,lolast); 130 131 fNumSamples = fHiGainLast-fHiGainFirst+1+fLoGainLast-fLoGainFirst+1; 132 fSqrtSamples = TMath::Sqrt((Float_t)fNumSamples); 133 134 } 135 136 // -------------------------------------------------------------------------- 137 // 138 // Calls: 139 // - MExtractor::PreProcess 89 140 // 90 141 // The following output containers are also searched and created if … … 95 146 Int_t MExtractPINDiode::PreProcess(MParList *pList) 96 147 { 97 fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData")); 98 if (!fRawEvt) 99 { 100 *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl; 101 return kFALSE; 102 } 103 104 105 fPINDiode = (MExtractedSignalPINDiode*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalPINDiode")); 106 if (!fPINDiode) 107 return kFALSE; 108 109 fPINDiode->SetUsedFADCSlices(fFirst, fLast); 110 111 fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam")); 112 113 if (!fPedestals) 114 { 115 *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl; 116 return kFALSE; 117 } 118 119 const MPedestalPix &ped = (*fPedestals)[fPINDiodeIdx]; 148 149 if (!MExtractor::PreProcess(pList)) 150 return kFALSE; 151 152 fPINDiode = (MExtractedSignalPINDiode*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalPINDiode")); 153 if (!fPINDiode) 154 return kFALSE; 155 156 fPINDiode->SetUsedFADCSlices(fHiGainFirst, fLoGainLast); 157 158 const MPedestalPix &ped = (*fPedestals)[fPINDiodeIdx]; 120 159 121 160 if (&ped) … … 134 173 } 135 174 136 void MExtractPINDiode::FindSignal (Byte_t *ptr, Int_t size, UInt_t &sum, UInt_t &sum2, UInt_t &sat, UInt_t &max) const137 { 138 139 Byte_t *end = ptr + size;140 175 void MExtractPINDiode::FindSignalandVarianceHiGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const 176 { 177 178 Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1; 179 141 180 while (ptr<end) 142 181 { 143 182 sum += *ptr; 144 183 sum2 += *ptr * *ptr; 145 if (*ptr > max) 146 max = *ptr; 184 185 if (*ptr++ >= fSaturationLimit) 186 sat++; 187 } 188 } 189 190 void MExtractPINDiode::FindSignalandVarianceLoGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const 191 { 192 193 Byte_t *end = ptr + fLoGainLast - fLoGainFirst + 1; 194 195 while (ptr<end) 196 { 197 sum += *ptr; 198 sum2 += *ptr * *ptr; 147 199 148 200 if (*ptr++ >= fSaturationLimit) … … 151 203 } 152 204 205 206 153 207 // -------------------------------------------------------------------------- 154 208 // … … 159 213 { 160 214 161 MRawEvtPixelIter pixel(fRawEvt); 162 163 fPINDiode->Clear(); 164 165 pixel.Jump(fPINDiodeIdx); 166 167 UInt_t sum = 0; 168 UInt_t sum2 = 0; 169 UInt_t sat = 0; 170 UInt_t max = 0; 171 172 FindSignal(pixel.GetHiGainSamples()+fFirst-1, 173 fRawEvt->GetNumHiGainSamples(), 174 sum, sum2, sat, max); 175 FindSignal(pixel.GetLoGainSamples(), 176 fLast-fRawEvt->GetNumLoGainSamples(), 177 sum, sum2, sat, max); 178 179 180 const Float_t var = ((Float_t)sum2 - (Float_t)sum*sum/fNumSamples)/(fNumSamples-1); 181 const Float_t rms = TMath::Sqrt(var); 182 183 // 184 // FIXME: The following formulae have to be revised!! 185 // 186 fPINDiode->SetExtractedSignal(sum - fPedestal*fNumSamples, fPedRms*fSqrtSamples); 187 fPINDiode->SetExtractedRms (rms, rms/2./fSqrtSamples); 188 fPINDiode->SetExtractedTime (max, rms/fSqrtSamples); 189 fPINDiode->SetSaturation(sat); 190 191 if (sat) 192 *fLog << warn << "WARNING - saturation occurred in the PIN Diode " << endl; 193 194 fPINDiode->SetReadyToSave(); 195 196 return kTRUE; 215 216 MRawEvtPixelIter pixel(fRawEvt); 217 218 fPINDiode->Clear(); 219 220 pixel.Jump(fPINDiodeIdx); 221 222 Int_t sum = 0; 223 Int_t sum2 = 0; 224 Byte_t sat = 0; 225 Int_t max = 0; 226 227 // 228 // Calculate first the time: 229 // 230 const Int_t maxhi = pixel.GetIdxMaxHiGainSample(); 231 const Int_t maxlo = pixel.GetIdxMaxLoGainSample(); 232 233 if (maxhi > maxlo) 234 max = maxhi; 235 else 236 max = maxlo + pixel.GetNumHiGainSamples(); 237 238 FindSignalandVarianceHiGain(pixel.GetHiGainSamples()+fHiGainFirst,sum,sum2,sat); 239 FindSignalandVarianceLoGain(pixel.GetLoGainSamples()+fLoGainFirst,sum,sum2,sat); 240 241 const Float_t var = ((Float_t)sum2 - (Float_t)sum*sum/fNumSamples)/(fNumSamples-1); 242 const Float_t rms = TMath::Sqrt(var); 243 244 // 245 // FIXME: The following formulae have to be revised!! 246 // 247 fPINDiode->SetExtractedSignal(sum - fPedestal*fNumSamples, fPedRms*fSqrtSamples); 248 fPINDiode->SetExtractedRms (rms, rms/2./fSqrtSamples); 249 fPINDiode->SetExtractedTime (max, rms/fSqrtSamples); 250 fPINDiode->SetSaturation(sat); 251 fPINDiode->SetReadyToSave(); 252 253 return kTRUE; 197 254 } 198 255 … … 214 271 } 215 272 216 const Bool_t arg2 = fNumSamples+f First-1 != fgLast;217 const Bool_t arg1 = arg2 || f First != fgFirst;273 const Bool_t arg2 = fNumSamples+fHiGainFirst-1 != fgLoGainLast; 274 const Bool_t arg1 = arg2 || fHiGainFirst != fgHiGainFirst; 218 275 219 276 if (!arg1) … … 221 278 222 279 out << " " << GetUniqueName() << ".SetRange("; 223 out << (int)f First;280 out << (int)fHiGainFirst; 224 281 if (arg2) 225 out << ", " << (int)(fNumSamples+f First-1);282 out << ", " << (int)(fNumSamples+fHiGainFirst-1); 226 283 out << ");" << endl; 227 284 } -
trunk/MagicSoft/Mars/msignal/MExtractPINDiode.h
r3322 r3911 11 11 ///////////////////////////////////////////////////////////////////////////// 12 12 13 #ifndef MARS_M Task14 #include "M Task.h"13 #ifndef MARS_MExtractor 14 #include "MExtractor.h" 15 15 #endif 16 16 17 class MRawEvtData;18 class MRawRunHeader;19 20 class MPedestalCam;21 17 class MExtractedSignalPINDiode; 22 class MExtractPINDiode : public M Task18 class MExtractPINDiode : public MExtractor 23 19 { 24 20 private: 25 21 26 22 static const UInt_t fgPINDiodeIdx; 27 static const Byte_t fgSaturationLimit; 28 static const Byte_t fgFirst; 29 static const Byte_t fgLast; 23 static const Byte_t fgHiGainFirst; // First FADC slice Hi-Gain (currently set to: 3) 24 static const Byte_t fgHiGainLast; // Last FADC slice Hi-Gain (currently set to: 14) 25 static const Byte_t fgLoGainFirst; // First FADC slice Lo-Gain (currently set to: 3) 26 static const Byte_t fgLoGainLast; // Last FADC slice Lo-Gain (currently set to: 14) 30 27 31 MPedestalCam *fPedestals; // Pedestals of all pixels in the camera32 28 MExtractedSignalPINDiode *fPINDiode; // Extracted signal of the PIN Diode 33 29 34 MRawEvtData *fRawEvt; // raw event data (time slices)35 MRawRunHeader *fRunHeader; // RunHeader information36 37 Byte_t fFirst;38 Byte_t fLast;39 Byte_t fNumSamples;40 Float_t fSqrtSamples;41 Byte_t fSaturationLimit;42 30 UInt_t fPINDiodeIdx; 43 44 31 Float_t fPedestal; 45 32 Float_t fPedRms; 33 Int_t fNumSamples; 34 Float_t fSqrtSamples; 46 35 47 void FindSignal(Byte_t *ptr, Int_t size, UInt_t &sum, UInt_t &sum2, UInt_t &sat, UInt_t &max) const; 48 36 void FindSignalandVarianceHiGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const; 37 void FindSignalandVarianceLoGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const; 38 49 39 Int_t PreProcess(MParList *pList); 50 40 Int_t Process(); … … 56 46 57 47 // Setters 58 void SetRange(const Byte_t hifirst=fgFirst, 59 const Byte_t hilast=fgLast); 60 void SetSaturationLimit(const Byte_t lim=fgSaturationLimit) { fSaturationLimit = lim; } 48 void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0); 61 49 void SetPINDiodeIdx( const UInt_t idx=fgPINDiodeIdx ) { fPINDiodeIdx = idx; } 62 50 63 ClassDef(MExtractPINDiode, 0) // Task to fill the Extracted PINDiode Containers from raw data51 ClassDef(MExtractPINDiode, 0) // Signal Extractor for the PIN Diode 64 52 }; 65 53
Note:
See TracChangeset
for help on using the changeset viewer.