Changeset 3962 for trunk/MagicSoft/Mars/msignal
- Timestamp:
- 05/04/04 17:29:39 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/msignal
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.cc
r3681 r3962 27 27 // MExtractBlindPixel 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. The "lo-gain" ranges are used for the NSB rejection 33 // whereas the high-gain ranges for blind pixel signal extraction. "High-gain" 34 // ranges can extend to the slices stored as "low-gain" in MRawEvtPixelIter 35 // Defaults are: 36 // 37 // fHiGainFirst = fgHiGainFirst = 12 38 // fHiGainLast = fgHiGainLast = 16 39 // fLoGainFirst = fgLoGainFirst = 0 40 // fLoGainLast = fgLoGainLast = 10 41 // 29 42 ////////////////////////////////////////////////////////////////////////////// 30 43 #include "MExtractBlindPixel.h" … … 40 53 #include "MRawEvtPixelIter.h" 41 54 55 #include "MExtractedSignalBlindPixel.h" 56 42 57 #include "MPedestalCam.h" 43 58 #include "MPedestalPix.h" 44 59 45 #include "MExtractedSignalBlindPixel.h"46 47 60 ClassImp(MExtractBlindPixel); 48 61 49 62 using namespace std; 50 63 51 const Int_t MExtractBlindPixel::fgBlindPixelIdx = 559; 52 const Byte_t MExtractBlindPixel::fgSaturationLimit = 254; 53 const Byte_t MExtractBlindPixel::fgFirst = 3; 54 const Byte_t MExtractBlindPixel::fgLast = 16; 55 64 const Int_t MExtractBlindPixel::fgBlindPixelIdx = 559; 65 const Int_t MExtractBlindPixel::fgNSBFilterLimit = 800; 66 const Byte_t MExtractBlindPixel::fgHiGainFirst = 12; 67 const Byte_t MExtractBlindPixel::fgHiGainLast = 29; 68 const Byte_t MExtractBlindPixel::fgLoGainFirst = 0; 69 const Byte_t MExtractBlindPixel::fgLoGainLast = 10; 56 70 // -------------------------------------------------------------------------- 57 71 // 58 72 // Default constructor. 59 73 // 74 // Initializes: 75 // - fBlindPixelIdx to fgBlindPixelIdx 76 // - fNSBFilterLimit to fgNSBFilterLimit 77 // 78 // Calls: 79 // - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast); 80 // 60 81 MExtractBlindPixel::MExtractBlindPixel(const char *name, const char *title) 61 : fSaturationLimit(fgSaturationLimit)62 82 { 63 83 … … 68 88 69 89 SetBlindPixelIdx(); 70 SetSaturationLimit(); 71 SetRange(); 72 } 73 74 void MExtractBlindPixel::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); 90 SetNSBFilterLimit(); 91 SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast); 92 93 } 94 95 void MExtractBlindPixel::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast) 96 { 97 98 MExtractor::SetRange(hifirst,hilast,lofirst,lolast); 99 100 fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst+1); 101 fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst+1); 102 103 fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples); 104 fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples); 105 82 106 } 83 107 … … 94 118 Int_t MExtractBlindPixel::PreProcess(MParList *pList) 95 119 { 96 fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData")); 97 if (!fRawEvt) 98 { 99 *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl; 100 return kFALSE; 101 } 102 103 fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam")); 104 if (!fPedestals) 105 { 106 *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting." << endl; 107 return kFALSE; 108 } 109 110 fBlindPixel = (MExtractedSignalBlindPixel*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalBlindPixel")); 111 if (!fBlindPixel) 112 return kFALSE; 113 114 fBlindPixel->SetUsedFADCSlices(fFirst, fLast); 115 fBlindPixel->SetBlindPixelIdx(fBlindPixelIdx); 116 117 return kTRUE; 120 121 if (!MExtractor::PreProcess(pList)) 122 return kFALSE; 123 124 fBlindPixel = (MExtractedSignalBlindPixel*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalBlindPixel")); 125 if (!fBlindPixel) 126 return kFALSE; 127 128 fBlindPixel->SetBlindPixelIdx(fBlindPixelIdx); 129 fBlindPixel->SetUsedFADCSlices(fHiGainFirst, fHiGainLast); 130 131 MPedestalPix &pedpix = (*fPedestals)[fBlindPixelIdx]; 132 133 if (&pedpix) 134 { 135 fBlindPixel->SetPed ( pedpix.GetPedestal() * fNumLoGainSamples ); 136 fBlindPixel->SetPedErr ( pedpix.GetPedestalRms()* fNumLoGainSamples 137 / TMath::Sqrt((Float_t)fPedestals->GetTotalEntries()) ); 138 fBlindPixel->SetPedRms ( pedpix.GetPedestalRms()* TMath::Sqrt((Float_t)fNumLoGainSamples) ); 139 fBlindPixel->SetPedRmsErr( fBlindPixel->GetPedErr()/2. ); 140 } 141 142 return kTRUE; 143 } 144 145 // -------------------------------------------------------------------------- 146 // 147 // FindSignalHiGain: 148 // 149 // - Loop from ptr to (ptr+fHiGainLast-fHiGainFirst) 150 // - Sum up contents of *ptr 151 // - If *ptr is greater than fSaturationLimit, raise sat by 1 152 // - If fHiLoLast is set, loop from logain to (logain+fHiLoLast) 153 // - Add contents of *logain to sum 154 // 155 void MExtractBlindPixel::FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Int_t &sum, Byte_t &sat) const 156 { 157 158 Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1; 159 160 while (ptr<end) 161 { 162 sum += *ptr; 163 164 if (*ptr++ >= fSaturationLimit) 165 sat++; 166 } 167 168 if (fHiLoLast == 0) 169 return; 170 171 end = logain + fHiLoLast; 172 while (logain<end) 173 { 174 sum += *logain; 175 176 if (*logain++ >= fSaturationLimit) 177 sat++; 178 } 179 180 } 181 182 // -------------------------------------------------------------------------- 183 // 184 // FindSignalFilter: 185 // 186 // - Loop from ptr to (ptr+fLoGainLast-fLoGainFirst) 187 // - Sum up contents of *ptr 188 // - If *ptr is greater than fSaturationLimit, raise sat by 1 189 // 190 void MExtractBlindPixel::FindSignalFilter(Byte_t *ptr, Int_t &sum, Byte_t &sat) const 191 { 192 193 Byte_t *end = ptr + fLoGainLast - fLoGainFirst + 1; 194 195 while (ptr<end) 196 { 197 sum += *ptr; 198 199 if (*ptr++ >= fSaturationLimit) 200 sat++; 201 } 118 202 } 119 203 … … 126 210 { 127 211 128 MRawEvtPixelIter pixel(fRawEvt); 129 130 fBlindPixel->Clear(); 131 132 pixel.Jump(fBlindPixelIdx); 133 134 const UInt_t nhigain = pixel.GetNumHiGainSamples(); 135 136 Byte_t *ptr = pixel.GetHiGainSamples(); 137 138 // 139 // We need a dedicated signal extractor for the blind pixel 140 // 141 Int_t diff = 0; 142 UInt_t first = fFirst; 143 UInt_t last = fLast; 144 UInt_t sat = 0; 145 146 if (last > nhigain) 147 { 148 diff = last - nhigain; 149 last = nhigain; 150 } 151 152 153 Byte_t *start = ptr + first - 1; 154 Byte_t *end = ptr + last - 1; 155 156 ptr = start; 157 158 Int_t sum = 0; 159 160 while (ptr<=end) 161 { 162 sum += *ptr; 163 164 if (*ptr++ >= fSaturationLimit) 165 sat++; 166 } 167 168 if (diff > 0) 169 { 170 ptr = pixel.GetLoGainSamples(); 171 end = ptr + diff - 1; 172 173 while (ptr<=end) 174 { 175 176 sum += *ptr; 177 178 if (*ptr++ >= fSaturationLimit) 179 sat++; 180 181 } 182 } 183 184 fBlindPixel->SetExtractedSignal(sum); 185 fBlindPixel->SetNumSaturated(sat); 186 fBlindPixel->SetReadyToSave(); 187 188 return kTRUE; 189 } 190 191 Int_t MExtractBlindPixel::PostProcess() 192 { 193 194 MPedestalPix &pedpix = (*fPedestals)[fBlindPixelIdx]; 195 196 if (&pedpix) 197 { 198 fBlindPixel->SetPed ( pedpix.GetPedestal() * fNumSamples ); 199 fBlindPixel->SetPedErr ( pedpix.GetPedestalRms()* fNumSamples / TMath::Sqrt((Float_t)fPedestals->GetTotalEntries()) ); 200 fBlindPixel->SetPedRms ( pedpix.GetPedestalRms()* TMath::Sqrt((Float_t)fNumSamples) ); 201 fBlindPixel->SetPedRmsErr( fBlindPixel->GetPedErr()/2. ); 202 } 203 204 return kTRUE; 205 206 } 207 208 // -------------------------------------------------------------------------- 209 // 210 // Implementation of SavePrimitive. Used to write the call to a constructor 211 // to a macro. In the original root implementation it is used to write 212 // gui elements to a macro-file. 213 // 214 void MExtractBlindPixel::StreamPrimitive(ofstream &out) const 215 { 216 out << " " << ClassName() << " " << GetUniqueName() << "(\""; 217 out << "\"" << fName << "\", \"" << fTitle << "\");" << endl; 218 219 if (fSaturationLimit!=fgSaturationLimit) 220 { 221 out << " " << GetUniqueName() << ".SetSaturationLimit("; 222 out << (int)fSaturationLimit << ");" << endl; 223 } 224 225 const Bool_t arg2 = fNumSamples+fFirst-1 != fgLast; 226 const Bool_t arg1 = arg2 || fFirst != fgFirst; 227 228 if (!arg1) 229 return; 230 231 out << " " << GetUniqueName() << ".SetRange("; 232 out << (int)fFirst; 233 if (arg2) 234 out << ", " << (int)(fNumSamples+fFirst-1); 235 out << ");" << endl; 236 } 212 MRawEvtPixelIter pixel(fRawEvt); 213 214 fBlindPixel->Clear(); 215 216 pixel.Jump(fBlindPixelIdx); 217 218 Int_t sum = 0; 219 Byte_t sat = 0; 220 221 FindSignalFilter(pixel.GetHiGainSamples()+fLoGainFirst, sum, sat); 222 223 if (sum > fNSBFilterLimit) 224 { 225 sum = -1; 226 fBlindPixel->SetExtractedSignal(sum); 227 fBlindPixel->SetNumSaturated(sat); 228 fBlindPixel->SetReadyToSave(); 229 return kTRUE; 230 } 231 232 sum = 0; 233 sat = 0; 234 235 FindSignalHiGain(pixel.GetHiGainSamples()+fLoGainFirst, pixel.GetLoGainSamples(), sum, sat); 236 237 fBlindPixel->SetExtractedSignal(sum); 238 fBlindPixel->SetNumSaturated(sat); 239 fBlindPixel->SetReadyToSave(); 240 241 return kTRUE; 242 } 243 -
trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.h
r3322 r3962 4 4 ///////////////////////////////////////////////////////////////////////////// 5 5 // // 6 // MExtractBlindPixel 6 // MExtractBlindPixel // 7 7 // // 8 8 // Integrates the time slices of the all pixels of a calibration event // … … 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 class MRawEvtPixelIter;20 class MPedestalCam;21 17 class MExtractedSignalBlindPixel; 22 class MExtractBlindPixel : public M Task18 class MExtractBlindPixel : public MExtractor 23 19 { 24 20 private: 25 21 26 static const Int_t fgBlindPixelIdx; 27 static const Byte_t fgSaturationLimit; 28 static const Byte_t fgFirst; 29 static const Byte_t fgLast; 22 static const Int_t fgBlindPixelIdx; 23 static const Int_t fgNSBFilterLimit; 24 static const Byte_t fgHiGainFirst; // First FADC slice Hi-Gain (currently set to: 0) 25 static const Byte_t fgHiGainLast; // Last FADC slice Hi-Gain (currently set to: 11) 26 static const Byte_t fgLoGainFirst; // First FADC slice Lo-Gain (currently set to: 0) 27 static const Byte_t fgLoGainLast; // Last FADC slice Lo-Gain (currently set to: 2) 30 28 31 29 MExtractedSignalBlindPixel *fBlindPixel; // Extracted signal of the Blind Pixel 32 30 33 MRawEvtData *fRawEvt; // raw event data (time slices) 34 MRawRunHeader *fRunHeader; // RunHeader information 35 MPedestalCam *fPedestals; // pointer to the pedestal information 31 Int_t fBlindPixelIdx; 32 Int_t fNSBFilterLimit; 33 34 void FindSignalHiGain(Byte_t *firstused, Byte_t *lowgain, Int_t &sum, Byte_t &sat) const; 35 void FindSignalFilter(Byte_t *ptr, Int_t &sum, Byte_t &sat) const; 36 36 37 Byte_t fFirst;38 Byte_t fLast;39 Byte_t fNumSamples;40 Float_t fSqrtSamples;41 Byte_t fSaturationLimit;42 43 Int_t fBlindPixelIdx;44 37 Int_t PreProcess(MParList *pList); 45 38 Int_t Process(); 46 Int_t PostProcess(); 47 void StreamPrimitive(ofstream &out) const; 48 39 49 40 public: 50 41 … … 52 43 53 44 // Setters 54 void SetRange( const Byte_t first=fgFirst, const Byte_t last=fgLast);55 void Set SaturationLimit(const Byte_t lim=fgSaturationLimit) { fSaturationLimit = lim; }56 void Set BlindPixelIdx( const Int_t idx=fgBlindPixelIdx ) { fBlindPixelIdx = idx; }45 void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0); 46 void SetBlindPixelIdx( const Int_t idx=fgBlindPixelIdx ) { fBlindPixelIdx = idx; } 47 void SetNSBFilterLimit( const Int_t lim=fgNSBFilterLimit ) { fNSBFilterLimit = lim; } 57 48 58 ClassDef(MExtractBlindPixel, 0) // Task to fill the Extracted BlindPixel Containers from raw data49 ClassDef(MExtractBlindPixel, 0) // Signal Extractor for the Blind Pixel 59 50 }; 60 51 -
trunk/MagicSoft/Mars/msignal/MExtractPINDiode.cc
r3951 r3962 41 41 ////////////////////////////////////////////////////////////////////////////// 42 42 #include "MExtractPINDiode.h" 43 #include "MExtractor.h"44 43 45 44 #include <fstream> … … 278 277 } 279 278 280 // --------------------------------------------------------------------------281 //282 // Implementation of SavePrimitive. Used to write the call to a constructor283 // to a macro. In the original root implementation it is used to write284 // gui elements to a macro-file.285 //286 void MExtractPINDiode::StreamPrimitive(ofstream &out) const287 {288 out << " " << ClassName() << " " << GetUniqueName() << "(\"";289 out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;290 291 if (fSaturationLimit!=fgSaturationLimit)292 {293 out << " " << GetUniqueName() << ".SetSaturationLimit(";294 out << (int)fSaturationLimit << ");" << endl;295 }296 297 const Bool_t arg2 = fNumSamples+fHiGainFirst-1 != fgLoGainLast;298 const Bool_t arg1 = arg2 || fHiGainFirst != fgHiGainFirst;299 300 if (!arg1)301 return;302 303 out << " " << GetUniqueName() << ".SetRange(";304 out << (int)fHiGainFirst;305 if (arg2)306 out << ", " << (int)(fNumSamples+fHiGainFirst-1);307 out << ");" << endl;308 } -
trunk/MagicSoft/Mars/msignal/MExtractPINDiode.h
r3951 r3962 40 40 Bool_t ReInit(MParList *pList); 41 41 Int_t Process(); 42 void StreamPrimitive(ofstream &out) const;43 42 44 43 public: -
trunk/MagicSoft/Mars/msignal/MExtractor.cc
r3958 r3962 279 279 void MExtractor::StreamPrimitive(ofstream &out) const 280 280 { 281 } 282 281 282 out << " " << ClassName() << " " << GetUniqueName() << "(\""; 283 out << "\"" << fName << "\", \"" << fTitle << "\");" << endl; 284 285 if (fSaturationLimit!=fgSaturationLimit) 286 { 287 out << " " << GetUniqueName() << ".SetSaturationLimit("; 288 out << (int)fSaturationLimit << ");" << endl; 289 } 290 291 out << " " << GetUniqueName() << ".SetRange("; 292 out << (int)fHiGainFirst; 293 out << ", " << (int)fHiGainLast; 294 out << ", " << (int)fLoGainFirst; 295 out << ", " << (int)fLoGainLast; 296 out << ");" << endl; 297 } 298
Note:
See TracChangeset
for help on using the changeset viewer.