Changeset 4628
- Timestamp:
- 08/16/04 14:59:34 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mcalib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc
r4624 r4628 21 21 ! Author(s): Markus Gaug 04/2004 <mailto:markus@ifae.es> 22 22 ! Author(s): Hendrik Bartko 08/2004 <mailto:hbartko@mppmu.mpg.de> 23 ! Author(s): Thomas Bretz 08/2004 <mailto:tbretz@astro.uni-wuerzburg.de> 23 24 ! 24 25 ! Copyright: MAGIC Software Development, 2000-2004 … … 47 48 // The calibration modes which exclude non-valid pixels are the following: 48 49 // 49 // kFfactor: calibrates using the F-Factor method50 // kBlindpixel: calibrates using the BlindPixel method51 // kBlindpixel: calibrates using the BlindPixel method52 // kFlatCharge: perform a charge flat-flatfielding. Outer pixels are area-corrected.53 // kDummy: calibrates with fixed conversion factors of 1 and errors of 0.50 // kFfactor: calibrates using the F-Factor method 51 // kBlindpixel: calibrates using the BlindPixel method 52 // kBlindpixel: calibrates using the BlindPixel method 53 // kFlatCharge: perform a charge flat-flatfielding. Outer pixels are area-corrected. 54 // kDummy: calibrates with fixed conversion factors of 1 and errors of 0. 54 55 // 55 56 // The calibration modes which include all pixels regardless of their validity is: 56 57 // 57 // kNone: calibrates with fixed conversion factors of 1 and errors of 0. 58 // 59 // Use the kDummy and kNone methods ONLY FOR DEBUGGING! 58 // kNone: calibrates with fixed conversion factors of 1 and errors of 0. 59 // 60 // Use the kDummy and kNone methods ONLY FOR DEBUGGING! 61 // 62 // 63 // This class can calibrate data and/or pedestals. To switch off calibration of data 64 // set the Calibration Mode to kSkip. To switch on pedestal calibration call either 65 // SetPedestalFlag(MCalibrateData::kRun) (calibration is done once in ReInit) 66 // SetPedestalFlag(MCalibrateData::kEvent) (calibration is done for each event) 67 // 68 // By calling SetNamePedADCContainer() and/or SetNamePedPhotContainer() you 69 // can control the name of the MPedestalCam and/or MPedPhotCam container which is used. 70 // 71 // Assume you want to calibrate "MPedestalCam" once and "MPedestalFromLoGain" [MPedestalCam] 72 // event-by-event, so: 73 // MCalibrateData cal1; 74 // cal1.SetCalibrationMode(MCalibrateData::kSkip); 75 // cal1.SetPedestalFlag(MCalibrateData::kRun); 76 // MCalibrateData cal2; 77 // cal2.SetCalibrationMode(MCalibrateData::kSkip); 78 // cal2.SetNamePedADCContainer("MPedestalFromLoGain"); 79 // cal2.SetNamePedPhotContainer("MPedPhotFromLoGain") 80 // cal2.SetPedestalFlag(MCalibrateData::kEvent); 81 // 60 82 // 61 83 // Input Containers: 62 // MPedestalCam 63 // MExtractedSignalCam 64 // MCalibrationChargeCam 65 // MCalibrationQECam 84 // [MPedestalCam] 85 // [MExtractedSignalCam] 86 // [MCalibrationChargeCam] 87 // [MCalibrationQECam] 88 // MBadPixelsCam 66 89 // 67 90 // Output Containers: 68 // MPedPhotCam69 // MCerPhotEvt91 // [MPedPhotCam] 92 // [MCerPhotEvt] 70 93 // 71 94 // See also: MJCalibration, MJPedestal, MJExtractSignal, MJExtractCalibTest … … 123 146 // 124 147 MCalibrateData::MCalibrateData(CalibrationMode_t calmode,const char *name, const char *title) 125 : fGeomCam(NULL), fPedestal(NULL),148 : fGeomCam(NULL), fPedestal(NULL), 126 149 fBadPixels(NULL), fCalibrations(NULL), fQEs(NULL), fSignals(NULL), 127 fPedPhot(NULL), fCerPhotEvt(NULL)150 fPedPhot(NULL), fCerPhotEvt(NULL), fPedestalFlag(kNo) 128 151 { 129 152 … … 132 155 133 156 SetCalibrationMode(); 134 SetPedestalFlag();135 157 136 158 SetNamePedADCContainer(); 137 159 SetNamePedPhotContainer(); 138 139 160 } 140 161 … … 160 181 // input containers 161 182 162 fPedestal = (MPedestalCam*)pList->FindObject(AddSerialNumber(fNamePedADCContainer), "MPedestalCam");163 if (!fPedestal)164 {165 *fLog << err << AddSerialNumber(fNamePedADCContainer) << " [MPedestalCam] not found ... aborting" << endl;166 return kFALSE;167 }168 169 fSignals = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));170 if (!fSignals)171 {172 *fLog << err << AddSerialNumber("MExtractedSignalCam") << " not found ... aborting" << endl;173 return kFALSE;174 }175 176 183 fBadPixels = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam")); 177 184 if (!fBadPixels) … … 181 188 } 182 189 190 fSignals = 0; 191 fCerPhotEvt = 0; 192 if (fCalibrationMode>kSkip) 193 { 194 fSignals = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam")); 195 if (!fSignals) 196 { 197 *fLog << err << AddSerialNumber("MExtractedSignalCam") << " not found ... aborting" << endl; 198 return kFALSE; 199 } 200 201 fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj(AddSerialNumber("MCerPhotEvt")); 202 if (!fCerPhotEvt) 203 return kFALSE; 204 } 205 206 fCalibrations = 0; 207 fQEs = 0; 183 208 if (fCalibrationMode>kNone) 184 209 { … … 198 223 } 199 224 200 // output containers 201 202 fPedPhot = (MPedPhotCam*)pList->FindCreateObj("MPedPhotCam", AddSerialNumber(fNamePedPhotContainer)); 203 if (!fPedPhot) 204 return kFALSE; 205 206 fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj(AddSerialNumber("MCerPhotEvt")); 207 if (!fCerPhotEvt) 208 return kFALSE; 225 fPedestal = 0; 226 fPedPhot = 0; 227 if (fPedestalFlag) 228 { 229 fPedestal = (MPedestalCam*)pList->FindObject(AddSerialNumber(fNamePedADCContainer), "MPedestalCam"); 230 if (!fPedestal) 231 { 232 *fLog << err << AddSerialNumber(fNamePedADCContainer) << " [MPedestalCam] not found ... aborting" << endl; 233 return kFALSE; 234 } 235 236 fPedPhot = (MPedPhotCam*)pList->FindCreateObj("MPedPhotCam", AddSerialNumber(fNamePedPhotContainer)); 237 if (!fPedPhot) 238 return kFALSE; 239 } 209 240 210 241 return kTRUE; … … 225 256 Bool_t MCalibrateData::ReInit(MParList *pList) 226 257 { 227 228 fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam")); 229 if (!fGeomCam) 230 { 231 *fLog << err << "No MGeomCam found... aborting." << endl; 232 return kFALSE; 233 } 234 235 if(fCalibrationMode == kBlindPixel && !fQEs->IsBlindPixelMethodValid()) 236 { 237 *fLog << warn << GetDescriptor() 238 << ": Blind pixel calibration method not valid, switching to default F-factor method" << endl; 239 fCalibrationMode = kFfactor; 240 } 241 242 if(fCalibrationMode == kPinDiode && !fQEs->IsPINDiodeMethodValid()) 243 { 244 *fLog << warn << GetDescriptor() 245 << ": PIN diode calibration method not valid, switching to default F-factor method" << endl; 246 fCalibrationMode = kFfactor; 247 } 248 249 if(fCalibrationMode == kCombined && !fQEs->IsCombinedMethodValid()) 250 { 251 *fLog << warn << GetDescriptor() 252 << ": Combined calibration method not valid, switching to default F-factor method" << endl; 253 fCalibrationMode = kFfactor; 254 } 255 256 // 257 // output information or warnings: 258 // 259 switch(fCalibrationMode) 258 fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam")); 259 if (!fGeomCam) 260 { 261 *fLog << err << "No MGeomCam found... aborting." << endl; 262 return kFALSE; 263 } 264 265 if(fCalibrationMode == kBlindPixel && !fQEs->IsBlindPixelMethodValid()) 266 { 267 *fLog << warn << "Blind pixel calibration method not valid, switching to F-factor method" << endl; 268 fCalibrationMode = kFfactor; 269 } 270 271 if(fCalibrationMode == kPinDiode && !fQEs->IsPINDiodeMethodValid()) 272 { 273 *fLog << warn << "PIN diode calibration method not valid, switching to F-factor method" << endl; 274 fCalibrationMode = kFfactor; 275 } 276 277 if(fCalibrationMode == kCombined && !fQEs->IsCombinedMethodValid()) 278 { 279 *fLog << warn << "Combined calibration method not valid, switching to F-factor method" << endl; 280 fCalibrationMode = kFfactor; 281 } 282 283 // 284 // output information or warnings: 285 // 286 switch(fCalibrationMode) 260 287 { 261 288 case kBlindPixel: 262 break;289 break; 263 290 case kFfactor: 264 break;291 break; 265 292 case kPinDiode: 266 *fLog << err << GetDescriptor() 267 << ": PIN Diode Calibration mode not yet available " << endl; 268 return kFALSE; 269 break; 293 *fLog << err << "PIN Diode Calibration mode not yet available!" << endl; 294 return kFALSE; 295 break; 270 296 case kCombined: 271 *fLog << err << GetDescriptor() 272 << ": Combined Calibration mode not yet available " << endl; 273 return kFALSE; 274 break; 297 *fLog << err << "Combined Calibration mode not yet available!" << endl; 298 return kFALSE; 299 break; 275 300 case kFlatCharge: 276 *fLog << warn << GetDescriptor() 277 << ": WARNING: Flat-fielding charges - only for muon calibration! " << endl; 278 break; 301 *fLog << warn << "WARNING - Flat-fielding charges - only for muon calibration!" << endl; 302 break; 279 303 case kDummy: 280 *fLog << warn << GetDescriptor() 281 << ": WARNING: Dummy calibration, no calibration applied!!" << endl; 282 break; 304 *fLog << warn << "WARNING - Dummy calibration, no calibration applied!" << endl; 305 break; 283 306 case kNone: 284 *fLog << warn << GetDescriptor() 285 << ": WARNING: No calibration applied!!" << endl; 286 break; 307 *fLog << warn << "WARNING - No calibration applied!" << endl; 308 break; 287 309 default: 288 *fLog << warn << GetDescriptor() 289 << ": WARNING: Calibration mode value (" 290 << fCalibrationMode << ") not known" << endl; 291 return kFALSE; 292 } 293 294 if (TestPedestalFlag(kRun)) 295 if (!CalibratePedestal()) 310 *fLog << warn << "WARNING - Calibration mode value (" << fCalibrationMode << ") not known" << endl; 311 return kFALSE; 312 } 313 314 if (TestPedestalFlag(kRun)) 315 if (!CalibratePedestal()) 296 316 return kFALSE; 297 317 298 return kTRUE; 299 } 300 301 318 return kTRUE; 319 } 302 320 303 321 // -------------------------------------------------------------------------- … … 316 334 if ((Int_t)fPedestal->GetSize() != fSignals->GetSize()) 317 335 { 318 *fLog << err << " MCalibrateData::ReInit(); sizes of MPedestalCam and MCalibrationCam are different"319 << endl;336 *fLog << err << "Sizes of MPedestalCam and MCalibrationCam are different" << endl; 337 return kFALSE; 320 338 } 321 339 … … 326 344 327 345 // pedestals/(used FADC slices) in [ADC] counts 328 Float_t pedes = ped.GetPedestal() * slices;329 Float_t pedrms = ped.GetPedestalRms() * TMath::Sqrt(slices);346 const Float_t pedes = ped.GetPedestal() * slices; 347 const Float_t pedrms = ped.GetPedestalRms() * TMath::Sqrt(slices); 330 348 331 349 // … … 337 355 Float_t calibConvVar; 338 356 Float_t calibFFactor; 339 340 if ( !GetConversionFactor(pixid, hiloconv, hiloconverr, 341 calibConv, calibConvVar, calibFFactor )) 357 if (!GetConversionFactor(pixid, hiloconv, hiloconverr, 358 calibConv, calibConvVar, calibFFactor)) 342 359 continue; 343 360 … … 345 362 // pedestals/(used FADC slices) in [number of photons] 346 363 // 347 Float_t pedphot = pedes * calibConv;348 Float_t pedphotrms = pedrms * calibConv;364 const Float_t pedphot = pedes * calibConv; 365 const Float_t pedphotrms = pedrms * calibConv; 349 366 350 367 (*fPedPhot)[pixid].Set(pedphot, pedphotrms); … … 492 509 for (UInt_t pixidx=0; pixidx<npix; pixidx++) 493 510 { 494 if ( 495 calibrationConversionFactor, calibrationConversionFactorErr, calibFFactor))511 if (!GetConversionFactor(pixidx, hiloconv, hiloconverr, 512 calibrationConversionFactor, calibrationConversionFactorErr, calibFFactor)) 496 513 continue; 497 514 498 MExtractedSignalPix &sig = 515 MExtractedSignalPix &sig = (*fSignals)[pixidx]; 499 516 500 517 Float_t signal; … … 520 537 nphot = signal*calibrationConversionFactor; 521 538 nphotErr = calibFFactor*TMath::Sqrt(TMath::Abs(nphot)); 539 522 540 // 523 541 // The following part is the commented first version of the error calculation … … 580 598 void MCalibrateData::StreamPrimitive(ofstream &out) const 581 599 { 582 583 out << " " << ClassName() << " " << GetUniqueName() << "(\""; 584 out << "\"" << fName << "\", \"" << fTitle << "\");" << endl; 585 586 if (TestPedestalFlag(kEvent)) 587 out << " " << GetUniqueName() << ".EnablePedestalType(kEvent)" << endl; 588 if (TestPedestalFlag(kRun)) 589 out << " " << GetUniqueName() << ".EnablePedestalType(kRun)" << endl; 590 591 if (fCalibrationMode != kDefault) 592 out << " " << GetUniqueName() << ".SetCalibrationMode(" << fCalibrationMode << ")" << endl; 593 594 if (fNamePedADCContainer != fgNamePedADCContainer) 595 { 596 out << " " << GetUniqueName() << ".SetNamePedADCContainer("; 597 out << fNamePedADCContainer.Data() << ");" << endl; 598 } 599 600 if (fNamePedPhotContainer != fgNamePedPhotContainer) 601 { 602 out << " " << GetUniqueName() << ".SetNamePedPhotContainer("; 603 out << fNamePedPhotContainer.Data() << ");" << endl; 604 } 605 } 600 out << " " << ClassName() << " " << GetUniqueName() << "(\""; 601 out << "\"" << fName << "\", \"" << fTitle << "\");" << endl; 602 603 if (TestPedestalFlag(kEvent)) 604 out << " " << GetUniqueName() << ".EnablePedestalType(MCalibrateData::kEvent)" << endl; 605 if (TestPedestalFlag(kRun)) 606 out << " " << GetUniqueName() << ".EnablePedestalType(MCalibrateData::kRun)" << endl; 607 608 if (fCalibrationMode != kDefault) 609 { 610 out << " " << GetUniqueName() << ".SetCalibrationMode(MCalibrateData::"; 611 switch (fCalibrationMode) 612 { 613 case kSkip: out << "kSkip"; break; 614 case kNone: out << "kNone"; break; 615 case kFlatCharge: out << "kFlatCharge"; break; 616 case kBlindPixel: out << "kBlindPixel"; break; 617 case kFfactor: out << "kFfactor"; break; 618 case kPinDiode: out << "kPinDiode"; break; 619 case kCombined: out << "kCombined"; break; 620 case kDummy: out << "kDummy"; break; 621 default: out << (int)fCalibrationMode; break; 622 } 623 out << ")" << endl; 624 } 625 626 if (fNamePedADCContainer != fgNamePedADCContainer) 627 { 628 out << " " << GetUniqueName() << ".SetNamePedADCContainer("; 629 out << fNamePedADCContainer.Data() << ");" << endl; 630 } 631 632 if (fNamePedPhotContainer != fgNamePedPhotContainer) 633 { 634 out << " " << GetUniqueName() << ".SetNamePedPhotContainer("; 635 out << fNamePedPhotContainer.Data() << ");" << endl; 636 } 637 } -
trunk/MagicSoft/Mars/mcalib/MCalibrateData.h
r4624 r4628 34 34 { 35 35 private: 36 37 36 static const TString fgNamePedADCContainer; //! "MPedestalCam" 38 37 static const TString fgNamePedPhotContainer; //! "MPedPhotCam" … … 45 44 MExtractedSignalCam *fSignals; //! Integrated charge in FADCs counts 46 45 47 MPedPhotCam *fPedPhot; // Pedestals/(used slices) [photons]48 MCerPhotEvt *fCerPhotEvt; // Cerenkov Photon Event used for calculation46 MPedPhotCam *fPedPhot; //! Pedestals/(used slices) [photons] 47 MCerPhotEvt *fCerPhotEvt; //! Cerenkov Photon Event used for calculation 49 48 50 49 UShort_t fCalibrationMode; // Flag defining the calibration mode (CalibrationMode_t) 51 50 Byte_t fPedestalFlag; // Flags defining to calibrate the pedestal each event or each run 52 51 53 TString fNamePedADCContainer; // name of fPedestal54 TString fNamePedPhotContainer; // name of fPedPhot52 TString fNamePedADCContainer; // name of fPedestal 53 TString fNamePedPhotContainer; // name of fPedPhot 55 54 56 55 Bool_t CalibratePedestal(); … … 69 68 enum CalibrationMode_t 70 69 { 71 k None= 0,72 k FlatCharge= 1,73 k BlindPixel= 2,74 k Ffactor= 3,75 k PinDiode= 4,76 k Combined= 5,77 k Dummy= 6,78 k Skip= 770 kSkip = 0, 71 kNone = 1, 72 kFlatCharge = 2, 73 kBlindPixel = 3, 74 kFfactor = 4, 75 kPinDiode = 5, 76 kCombined = 6, 77 kDummy = 7 79 78 }; 80 79
Note:
See TracChangeset
for help on using the changeset viewer.