Changeset 8452 for trunk/MagicSoft/Mars/mcalib
- Timestamp:
- 04/27/07 11:05:11 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mcalib
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h
r8429 r8452 16 16 #pragma link C++ class MCalibConstCam+; 17 17 #pragma link C++ class MCalibConstPix+; 18 19 #pragma link C++ class MCalibrationIntensityCam+;20 #pragma link C++ class MCalibrationIntensityChargeCam+;21 18 22 19 #pragma link C++ class MCalibrationCam+; -
trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc
r8428 r8452 30 30 // Input Containers: 31 31 // MParList 32 // MCalibrationIntensityChargeCam33 32 // 34 33 // Output Containers: 35 // MCalibrationIntensityChargeCam36 34 // 37 35 // Class version 2: … … 55 53 #include "MHCalibrationCam.h" 56 54 57 #include "MCalibrationIntensityChargeCam.h"58 59 55 #include "MBadPixelsCam.h" 60 56 61 57 #include "MCalibrationQECam.h" 62 58 #include "MCalibrationBlindCam.h" 59 #include "MCalibrationChargeCam.h" 63 60 #include "MCalibrationChargePix.h" 64 61 #include "MCalibrationChargeCalc.h" … … 83 80 MCalibCalcFromPast::MCalibCalcFromPast(const char *name, const char *title) 84 81 : fGeom(NULL), fParList(NULL), fRunHeader(NULL), 85 f IntensCharge(NULL), fBlindCam(NULL), fQECam(NULL), fBadPixels(NULL),82 fCharge(NULL), fBlindCam(NULL), fQECam(NULL), fBadPixels(NULL), 86 83 fChargeCalc(NULL), fRelTimeCalc(NULL), fCalibrate(NULL), 87 84 fNumCam(0), fNumEvents(0), fUpdateWithFFactorMethod(kTRUE), fUpdateNumPhes(kTRUE), … … 133 130 134 131 // 135 // Look for the M BadPixels IntensityCam132 // Look for the MCalibrationQECam 136 133 // 137 134 fQECam = (MCalibrationQECam*)pList->FindObject("MCalibrationQECam"); … … 143 140 144 141 // 145 // Look for the MFillH-class "MHCalibrationBlindCam". In case yes, initialize the 146 // corresponding IntensityCam 142 // Look for the MFillH-class "MHCalibrationBlindCam". 147 143 // 148 144 if (pList->FindObject(AddSerialNumber("MHCalibrationBlindCam"))) … … 156 152 157 153 // 158 // Look for the MFillH-class "MHCalibrationChargeCam". In case yes, initialize the 159 // corresponding IntensityCam 154 // Look for the MFillH-class "MHCalibrationChargeCam". 160 155 // 161 156 if (pList->FindObject(AddSerialNumber("MHCalibrationChargeCam"))) 162 157 { 163 158 164 fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam"); 165 if (!fIntensCharge) 166 return kFALSE; 167 168 MCalibrationChargeCam *chargeinit = (MCalibrationChargeCam*)pList->FindObject("MCalibrationChargeCam"); 169 170 if (chargeinit) 171 fIntensCharge->SetCam(chargeinit,0); 172 else 173 *fLog << "Could not find initial MCalibrationChargeCam, cannot initialize intensity cam" << endl; 159 fCharge = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam"); 160 if (!fCharge) 161 return kFALSE; 174 162 175 163 if (!fChargeCalc) … … 194 182 195 183 // 196 // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the 197 // corresponding IntensityCam 184 // Look for the MFillH name "FillRelTimeCam". 198 185 // 199 186 if (pList->FindObject(AddSerialNumber("MHCalibrationRelTimeCam"))) 200 187 { 201 // if (!pList->FindCreateObj("MCalibrationIntensityRelTimeCam"))202 // return kFALSE;203 204 188 if (!fRelTimeCalc) 205 189 fRelTimeCalc = (MCalibrationRelTimeCalc*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCalc")); … … 252 236 // 253 237 // - Initializes new containers in the 254 // - Intensity Cams, if the number of calibration events has reach fNumEventsDump.238 // - if the number of calibration events has reach fNumEventsDump. 255 239 // - Executes Finalize() of the MCalibration*Calc classes in that case. 256 240 // - Sets the latest MCalibrationChargeCam as update class into MCalibrateData 257 // - Initialize new MCalibration*Cams into the intensity cams.241 // - clean MCalibration*Cams 258 242 // 259 243 Int_t MCalibCalcFromPast::Process() … … 263 247 264 248 // Replace the old cams by (empty) new ones 265 // MCalibrationChargeCam: f IntensCharge249 // MCalibrationChargeCam: fCharge 266 250 // MCalibrationQECam: fIntensQE 267 251 // MCalibrationBlindCam: fIntensBlind … … 276 260 *fLog << inf << "Finalize calibration histograms:" << endl; 277 261 278 // This fills the IntensityCam which are newly created by262 // This fills the Cams which are cleared by 279 263 // ReInitialize with the result of the last calib cycle 280 264 Finalize("MHCalibrationChargeCam"); … … 299 283 if (fUpdateNumPhes) 300 284 { 301 MCalibrationChargePix &avpix =(MCalibrationChargePix&)f IntensCharge->GetCam()->GetAverageArea(0);285 MCalibrationChargePix &avpix =(MCalibrationChargePix&)fCharge->GetAverageArea(0); 302 286 fPhes [fNumPhes] = avpix.GetPheFFactorMethod(); 303 287 fPhesVar[fNumPhes] = avpix.GetPheFFactorMethodVar(); … … 329 313 330 314 if (fCalibrate) 331 return fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL 332 : (MCalibrationChargeCam*)fIntensCharge->GetCam() ); 315 return fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL : fCharge); 333 316 334 317 return kTRUE; … … 358 341 // -------------------------------------------------------------------------- 359 342 // 360 // Re-Intitializes new containers inside the Intensity Cams. 361 // From now on, a call to the IntensityCam functions returns pointers 362 // to the newly created Containers. 343 // Clear contents of cams 363 344 // 364 345 Bool_t MCalibCalcFromPast::ReInitialize() … … 391 372 // IF SIMPLE ENOUGH, REMOVE THE FUNCTION! 392 373 393 if (fIntensCharge) 394 { 395 *fLog << "MCalibrationChargeCam..."; 396 MCalibrationChargeCam *cold = (MCalibrationChargeCam*)fIntensCharge->GetCam(); 397 398 fIntensCharge->AddToList(Form("MCalibrationChargeCam%04d",fNumCam),*fGeom); 399 400 MCalibrationChargeCam *cnew = (MCalibrationChargeCam*)fIntensCharge->GetCam(); 401 cnew->SetRunNumber(runnumber); 402 403 if (cold) 404 { 405 cnew->MergeHiLoConversionFactors(*cold); 406 fIntensCharge->DeleteOldCam(cold); 407 } 374 if (fCharge) 375 { 376 *fLog << "MCalibrationChargeCam..."; 377 fCharge->Clear(); 378 fCharge->SetRunNumber(runnumber); 408 379 } 409 380 -
trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.h
r8427 r8452 17 17 class MCalibrationRelTimeCalc; 18 18 class MCalibrateData; 19 class MCalibration IntensityChargeCam;19 class MCalibrationChargeCam; 20 20 class MCalibrationBlindCam; 21 21 class MCalibrationQECam; … … 32 32 MParList *fParList; //! Parameter List 33 33 MRawRunHeader *fRunHeader; //! Run header storing the run number 34 MCalibration IntensityChargeCam *fIntensCharge;//! Intensity Charge Cam (to be created)34 MCalibrationChargeCam *fCharge; //! Intensity Charge Cam (to be created) 35 35 36 36 MCalibrationBlindCam *fBlindCam; //! Blind Cam -
trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.cc
r8428 r8452 33 33 // MCalibrationPattern 34 34 // MParList 35 // MCalibrationIntensityChargeCam36 35 // 37 36 // Output Containers: 38 // MCalibrationIntensityChargeCam39 37 // 40 38 ////////////////////////////////////////////////////////////////////////////// … … 55 53 #include "MBadPixelsCam.h" 56 54 57 #include "MCalibrationIntensityChargeCam.h"58 59 55 #include "MCalibrationPattern.h" 60 56 #include "MCalibrationQECam.h" … … 76 72 // 77 73 MCalibColorSteer::MCalibColorSteer(const char *name, const char *title) 78 : fCalibPattern(NULL), fGeom(NULL), fParList(NULL), 79 fIntensCharge(NULL), 74 : fCalibPattern(NULL), fGeom(NULL), fParList(NULL), fCharge(NULL), 80 75 fBad(NULL), fChargeCalc(NULL), fRelTimeCalc(NULL), fHistCopy(kFALSE) 81 76 { … … 148 143 149 144 // 150 // Look for the MFillH name "FillChargeCam". In case yes, initialize the 151 // corresponding IntensityCam 145 // Look for the MFillH name "FillChargeCam". 152 146 // 153 147 if (pList->FindObject(AddSerialNumber("MHCalibrationChargeCam"))) … … 155 149 *fLog << inf << "Found MHCalibrationChargeCam ... " << flush; 156 150 157 f IntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");158 if (!f IntensCharge)151 fCharge = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam"); 152 if (!fCharge) 159 153 return kFALSE; 160 154 … … 172 166 173 167 // 174 // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the 175 // corresponding IntensityCam 168 // Look for the MFillH name "FillRelTimeCam". 176 169 // 177 170 if (pList->FindObject(AddSerialNumber("MHCalibrationRelTimeCam"))) … … 199 192 // -------------------------------------------------------------------------- 200 193 // 201 // Reads the pattern from MCalibrationPattern and initializes new containers in the202 // Intensity Cams, if the pattern has changed. Executes Finalize of the194 // Reads the pattern from MCalibrationPattern and clear 195 // Cams, if the pattern has changed. Executes Finalize of the 203 196 // MCalibration*Calc classes in that case. 204 197 // … … 256 249 // -------------------------------------------------------------------------- 257 250 // 258 // Reads the pattern from MCalibrationPattern and initializes new containers in the259 // Intensity Cams, if the pattern has changed. Executes Finalize of the251 // Reads the pattern from MCalibrationPattern and clear 252 // Cams, if the pattern has changed. Executes Finalize of the 260 253 // MCalibration*Calc classes in that case. 261 254 // … … 290 283 291 284 hist->Finalize(); 292 CopyHist(name);285 //CopyHist(name); 293 286 hist->ResetHists(); 294 287 hist->SetColor( fCalibPattern->GetPulserColor()); … … 298 291 // -------------------------------------------------------------------------- 299 292 // 300 // Re-Intitializes new containers inside the Intensity Cams. 301 // From now on, a call to the IntensityCam functions returns pointers 302 // to the newly created Containers. 293 // Clear cams 303 294 // 304 295 Bool_t MCalibColorSteer::ReInitialize() … … 310 301 311 302 fBad->Clear(); // FIXME:::::: MERGE PreExcl!!!! 312 fQECam->Clear(); 303 304 if (fQECam) 305 fQECam->Clear(); 313 306 314 307 fBlindCam->Clear(); 315 308 fBlindCam->SetPulserColor(fCalibPattern->GetPulserColor()); 316 309 317 fRelTimeCam->Clear(); 318 fRelTimeCam->SetPulserColor(fCalibPattern->GetPulserColor()); 319 320 if (fIntensCharge) 321 { 322 MCalibrationChargeCam *oldcam = (MCalibrationChargeCam*)fIntensCharge->GetCam(); 323 fIntensCharge->AddToList(Form("MCalibrationChargeCam%s",namep.Data()),*fGeom); 324 MCalibrationChargeCam *cam = (MCalibrationChargeCam*)fIntensCharge->GetCam(); 325 cam->SetPulserColor(fCalibPattern->GetPulserColor()); 326 if (!cam->MergeHiLoConversionFactors(*oldcam)) 327 return kFALSE; 328 *fLog << inf << "New MCalibrationChargeCam with name: " << cam->GetName() << endl; 329 } 310 if (fRelTimeCam) 311 { 312 fRelTimeCam->Clear(); 313 fRelTimeCam->SetPulserColor(fCalibPattern->GetPulserColor()); 314 } 315 316 if (fCharge) 317 { 318 fCharge->Clear(); 319 fCharge->SetPulserColor(fCalibPattern->GetPulserColor()); 320 } 330 321 331 322 return kTRUE; … … 360 351 return result; 361 352 } 362 363 // --------------------------------------------------------------------------364 //365 // Copies the histogram classes into the intensity cams366 //367 void MCalibColorSteer::CopyHist(const char* name)368 {369 MHCalibrationCam *hcam = (MHCalibrationCam*)fParList->FindObject(name);370 TString n(name);371 if (n.Contains("ChargeCam"))372 {373 if (fIntensCharge)374 fIntensCharge->AddHist((MHCalibrationCam*)hcam->Clone());375 }376 // if (n.Contains("Blind"))377 // if (fIntensBlind)378 // fIntensBlind->AddHist((MHCalibrationCam*)hcam->Clone());379 380 // if (n.Contains("RelTime"))381 // if (fIntensRelTime)382 // fIntensRelTime->AddHist((MHCalibrationCam*)hcam->Clone());383 }384 385 // -------------------------------------------------------------------------- -
trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.h
r8428 r8452 16 16 class MRawRunHeader; 17 17 class MCalibrationChargeCalc; 18 class MCalibrationChargeCam; 18 19 class MCalibrationRelTimeCalc; 19 class MCalibrationIntensityChargeCam;20 20 class MCalibrationRelTimeCam; 21 21 class MCalibrationBlindCam; … … 30 30 MGeomCam *fGeom; //! 31 31 MParList *fParList; //! 32 MCalibration IntensityChargeCam *fIntensCharge;//!32 MCalibrationChargeCam *fCharge; //! 33 33 MCalibrationRelTimeCam *fRelTimeCam; //! 34 34 MCalibrationBlindCam *fBlindCam; //! 35 35 MCalibrationQECam *fQECam; //! 36 36 MBadPixelsCam *fBad; //! 37 37 38 38 MCalibrationChargeCalc *fChargeCalc; //! 39 39 MCalibrationRelTimeCalc *fRelTimeCalc; //! 40 40 41 41 MCalibrationCam::PulserColor_t fColor; 42 42 Float_t fStrength; 43 43 44 44 Bool_t fHistCopy; // Decide whether MHCalibrationCams will get copied 45 45 46 46 Int_t PreProcess(MParList *pList); 47 47 Int_t Process(); 48 48 Int_t PostProcess(); 49 49 50 50 Bool_t ReInitialize(); 51 51 Bool_t Finalize(const char* name); 52 52 53 void CopyHist(const char* name);53 //void CopyHist(const char* name); 54 54 TString GetNamePattern(); 55 55 56 56 public: 57 57 MCalibColorSteer(const char *name=NULL, const char *title=NULL); -
trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc
r8425 r8452 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MCalibrateData.cc,v 1.6 7 2007-04-20 11:48:08tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MCalibrateData.cc,v 1.68 2007-04-27 10:04:46 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 114 114 #include "MPedestalPix.h" 115 115 116 #include "MCalibrationIntensityChargeCam.h"117 116 #include "MCalibrationChargeCam.h" 118 117 #include "MCalibrationChargePix.h" … … 155 154 // 156 155 MCalibrateData::MCalibrateData(CalibrationMode_t calmode,const char *name, const char *title) 157 : fGeomCam(NULL), fBadPixels(NULL), fCalibrations(NULL), fIntensCalib(NULL),156 : fGeomCam(NULL), fBadPixels(NULL), fCalibrations(NULL), 158 157 fQEs(NULL), fSignals(NULL), fCerPhotEvt(NULL), fCalibConstCam(NULL), 159 158 fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.), fScaleFactor(1.) … … 238 237 if (fCalibrationMode>kNone) 239 238 { 240 fIntensCalib = (MCalibrationIntensityChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityChargeCam"));241 if (fIntensCalib)242 *fLog << inf << "Found MCalibrationIntensityChargeCam ... " << endl;243 244 239 fCalibrations = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam")); 245 240 if (!fCalibrations) … … 465 460 if (fCalibrationMode > kNone) 466 461 { 467 468 const MCalibrationCam *chargecam = fIntensCalib ? fIntensCalib->GetCam() : fCalibrations; 469 if (chargecam->GetSize() != npixels) 462 if (fCalibrations->GetSize() != npixels) 470 463 { 471 464 *fLog << "Size mismatch between MGeomCam and MCalibrationChargeCam... abort!" << endl; … … 478 471 return kFALSE; 479 472 } 480 481 473 } 474 482 475 fCalibConsts .Set(npixels); 483 476 fCalibFFactors.Set(npixels); … … 512 505 fHiLoConv.Reset(); 513 506 fHiLoConvErr.Reset(); 514 515 MCalibrationChargeCam *chargecam = NULL;516 if (updatecam)517 chargecam = fCalibrations;518 else519 chargecam = fIntensCalib ? (MCalibrationChargeCam*)fIntensCalib->GetCam() : fCalibrations;520 507 521 508 // … … 546 533 } 547 534 548 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(* chargecam)[pixidx];549 const MCalibrationChargePix &avpix = (MCalibrationChargePix&) chargecam->GetAverageArea(0);535 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCalibrations)[pixidx]; 536 const MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCalibrations->GetAverageArea(0); 550 537 551 538 hiloconv = pix.GetConversionHiLo (); 552 539 hiloconverr= pix.GetConversionHiLoSigma(); 553 540 554 541 calibConv = pix.GetMeanConvFADC2Phe(); 555 542 calibConvVar = pix.GetMeanConvFADC2PheVar(); 556 543 calibFFactor = pix.GetMeanFFactorFADC2Phot(); 557 544 558 545 const MCalibrationQEPix &qe = (MCalibrationQEPix&)(*fQEs)[pixidx]; 559 546 -
trunk/MagicSoft/Mars/mcalib/MCalibrateData.h
r8425 r8452 20 20 class MCalibrationChargeCam; 21 21 class MCalibrationQECam; 22 23 class MCalibrationIntensityChargeCam;24 22 25 23 class MCalibrateData : public MTask … … 63 61 MBadPixelsCam *fBadPixels; //! Bad Pixels information 64 62 MCalibrationChargeCam *fCalibrations; //! Calibration constants 65 MCalibrationIntensityChargeCam *fIntensCalib; //! Calibration constants from interlaced calib.66 63 MCalibrationQECam *fQEs; //! Quantum efficiencies 67 64 MExtractedSignalCam *fSignals; //! Integrated charge in FADCs counts -
trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
r8427 r8452 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.17 6 2007-04-20 13:21:11tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.177 2007-04-27 10:04:46 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 200 200 // - TString fOutputFile 201 201 // 202 // ClassVersion 6: 203 // - Bool_t fContinousCalibration 204 // 202 205 ////////////////////////////////////////////////////////////////////////////// 203 206 #include "MCalibrationChargeCalc.h" … … 220 223 #include "MPedestalCam.h" 221 224 #include "MPedestalPix.h" 222 223 #include "MCalibrationIntensityChargeCam.h"224 225 225 226 #include "MHCalibrationChargeCam.h" … … 362 363 363 364 fBadPixels = NULL; 364 fIntensCam = NULL;365 365 fCam = NULL; 366 366 fHCam = NULL; … … 440 440 // Search for the following input containers and abort if not existing: 441 441 // - MGeomCam 442 // - MCalibration IntensityChargeCam or MCalibrationChargeCam442 // - MCalibrationChargeCam 443 443 // - MCalibrationQECam 444 444 // - MBadPixelsCam … … 455 455 // It defines the PixId of every pixel in: 456 456 // 457 // - MCalibrationIntensityChargeCam458 457 // - MCalibrationChargeCam 459 458 // - MCalibrationQECam … … 495 494 496 495 // 497 // Intensity containers496 // MCalibrationChargeCam 498 497 // 499 fIntensCam = (MCalibrationIntensityChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityChargeCam")); 500 if (fIntensCam) 501 *fLog << inf << "Found MCalibrationIntensityChargeCam... " << flush; 502 else 503 { 504 fCam = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam")); 505 if (!fCam) 506 { 507 *fLog << err << "Cannot find MCalibrationChargeCam ... abort." << endl; 508 *fLog << "Maybe you forget to call an MFillH for the MHCalibrationChargeCam before..." << endl; 509 return kFALSE; 510 } 511 } 512 498 fCam = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam")); 499 if (!fCam) 500 { 501 *fLog << err << "Cannot find MCalibrationChargeCam ... abort." << endl; 502 *fLog << "Maybe you forget to call an MFillH for the MHCalibrationChargeCam before..." << endl; 503 return kFALSE; 504 } 505 513 506 // 514 507 // Blind pixel calibration … … 550 543 // Further initialization 551 544 // 552 MCalibrationChargeCam *chargecam = fIntensCam 553 ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam; 554 555 const UInt_t npixels = fGeom->GetNumPixels(); 556 557 for (UInt_t i=0; i<npixels; i++) 558 { 559 560 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i]; 561 562 if ((*fBadPixels)[i].IsBad()) 563 { 564 MCalibrationQEPix &pqe = (MCalibrationQEPix&)(*fQECam)[i]; 565 pix.SetExcluded(); 566 pqe.SetExcluded(); 567 continue; 568 } 569 570 if (IsDebug()) 571 pix.SetDebug(); 572 } 545 if (IsDebug()) 546 { 547 const UInt_t npixels = fGeom->GetNumPixels(); 548 for (UInt_t i=0; i<npixels; i++) 549 (*fCam)[i].SetDebug(); 550 } 573 551 574 552 fResultFlags.Set(fGeom->GetNumAreas()); … … 606 584 // Now retrieve the colour and check if not various colours have been used 607 585 // 608 if (!fIntensCam) 609 { 610 if (fPulserColor != MCalibrationCam::kNONE) 611 { 612 *fLog << warn << "Multiple colours used simultaneously!" << flush; 613 fHCam->Finalize(); 614 if (fHBlindCam) 615 fHBlindCam->Finalize(); 616 617 Finalize(); 618 619 fHCam->ResetHists(); 620 if (fHBlindCam) 621 fHBlindCam->ResetHists(); 622 623 *fLog << inf << "Starting next calibration... " << flush; 624 625 fHCam->SetColor(col); 626 if (fHBlindCam) 627 fHBlindCam->SetColor(col); 628 629 fCam->SetPulserColor(col); 630 if (fBlindCam) 631 fBlindCam->SetPulserColor(col); 632 } 633 } 586 if (!fContinousCalibration && fPulserColor != MCalibrationCam::kNONE) 587 { 588 *fLog << warn << "Multiple colours used simultaneously!" << flush; 589 fHCam->Finalize(); 590 if (fHBlindCam) 591 fHBlindCam->Finalize(); 592 593 Finalize(); 594 595 fHCam->ResetHists(); 596 if (fHBlindCam) 597 fHBlindCam->ResetHists(); 598 599 *fLog << inf << "Starting next calibration... " << flush; 600 601 fHCam->SetColor(col); 602 if (fHBlindCam) 603 fHBlindCam->SetColor(col); 604 605 fCam->SetPulserColor(col); 606 if (fBlindCam) 607 fBlindCam->SetPulserColor(col); 608 } 634 609 635 610 // … … 655 630 // Distribute new color to all containers 656 631 // 632 fCam->SetPulserColor(col); 633 if (fBlindCam) 634 fBlindCam->SetPulserColor(col); 635 657 636 fHCam->SetColor(col); 658 637 if (fHBlindCam) 659 638 fHBlindCam->SetColor(col); 660 661 MCalibrationChargeCam *chargecam = fIntensCam662 ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam;663 664 chargecam->SetPulserColor(col);665 666 if (fBlindCam)667 fBlindCam->SetPulserColor(col);668 639 if (fPINDiode) 669 640 fPINDiode->SetColor(col); … … 724 695 // Call FinalizeUnsuitablePixels() 725 696 // 726 // Call MParContainer::SetReadyToSave() for f IntensCam, fCam, fQECam, fBadPixels and727 // 697 // Call MParContainer::SetReadyToSave() for fCam, fQECam, fBadPixels and 698 // fBlindCam and fPINDiode if they exist 728 699 // 729 700 // Print out some statistics … … 749 720 } 750 721 751 MCalibrationChargeCam *chargecam = fIntensCam ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam;752 753 722 // 754 723 // First loop over pixels, call FinalizePedestals and FinalizeCharges … … 759 728 { 760 729 761 MCalibrationChargePix &pix = (MCalibrationChargePix&)(* chargecam)[pixid];730 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[pixid]; 762 731 // 763 732 // Check if the pixel has been excluded from the fits … … 786 755 if (nvalid == 0) 787 756 { 788 if (!fIntensCam)757 if (!fContinousCalibration) 789 758 { 790 759 *fLog << warn << GetDescriptor() << ": All pixels have non-valid calibration. " … … 801 770 802 771 const MPedestalPix &ped = fPedestals->GetAverageArea(aidx); 803 MCalibrationChargePix &pix = (MCalibrationChargePix&) chargecam->GetAverageArea(aidx);772 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx); 804 773 const MArrayI &arr = fHCam->GetAverageAreaNum(); 805 774 … … 814 783 pix.SetSigma (pix.GetSigma()/pix.GetFFactorFADC2Phe()); 815 784 816 FinalizeCharges(pix, chargecam->GetAverageBadArea(aidx),"area id");817 FinalizeArrivalTimes(pix, chargecam->GetAverageBadArea(aidx), "area id");785 FinalizeCharges(pix, fCam->GetAverageBadArea(aidx),"area id"); 786 FinalizeArrivalTimes(pix, fCam->GetAverageBadArea(aidx), "area id"); 818 787 } 819 788 … … 825 794 const MPedestalPix &ped = fPedestals->GetAverageSector(sector); 826 795 827 MCalibrationChargePix &pix = (MCalibrationChargePix&) chargecam->GetAverageSector(sector);796 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(sector); 828 797 FinalizePedestals(ped,pix, 0); 829 798 } … … 840 809 // 841 810 if (FinalizeFFactorMethod()) 842 chargecam->SetFFactorMethodValid(kTRUE);811 fCam->SetFFactorMethodValid(kTRUE); 843 812 else 844 813 { 845 814 *fLog << warn << "Could not calculate the photons flux from the F-Factor method " << endl; 846 chargecam->SetFFactorMethodValid(kFALSE);847 if (!f IntensCam)848 815 fCam->SetFFactorMethodValid(kFALSE); 816 if (!fContinousCalibration) 817 return kFALSE; 849 818 } 850 819 … … 916 885 "Deviating F-Factor: "); 917 886 918 chargecam->SetReadyToSave();919 fQECam 887 fCam->SetReadyToSave(); 888 fQECam->SetReadyToSave(); 920 889 fBadPixels->SetReadyToSave(); 921 890 … … 1109 1078 if (!cal.CalcConvFFactor()) 1110 1079 { 1111 *fLog << warn << desc << "Could not calculate the Conv. FADC counts to Phes" << endl;1080 *fLog << warn << desc << "Could not calculate the conv. FADC cts to phes" << endl; 1112 1081 bad.SetUncalibrated(MBadPixelsPix::kDeviatingNumPhes); 1113 1082 return kFALSE; … … 1149 1118 // - MBadPixelsPix::kLoGainOverFlow 1150 1119 // 1151 // - Call MCalibrationPix::SetExcluded() for the bad pixels1152 //1153 1120 // Sets pixel to MBadPixelsPix::kUnreliableRun, if one of the following flags is set: 1154 1121 // - MBadPixelsPix::kChargeSigmaNotValid … … 1176 1143 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun ); 1177 1144 } 1178 1145 1179 1146 if (IsCheckDeviatingBehavior()) 1180 1147 { … … 1182 1149 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun ); 1183 1150 } 1184 1151 1185 1152 if (IsCheckHistOverflow()) 1186 1153 { 1187 1154 if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOverFlow )) 1188 1155 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun ); 1189 1156 1190 1157 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOverFlow )) 1191 1158 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun ); 1192 1159 } 1193 1160 1194 1161 if (IsCheckArrivalTimes()) 1195 1162 { … … 1235 1202 Bool_t MCalibrationChargeCalc::FinalizeFFactorMethod() 1236 1203 { 1237 MCalibrationChargeCam *chargecam = fIntensCam1238 ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam;1239 1240 1204 const Int_t npixels = fGeom->GetNumPixels(); 1241 1205 const Int_t nareas = fGeom->GetNumAreas(); … … 1260 1224 for (Int_t i=0; i<npixels; i++) 1261 1225 { 1262 MCalibrationChargePix &pix = (MCalibrationChargePix&)(* chargecam)[i];1226 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 1263 1227 1264 1228 MBadPixelsPix &bad = (*fBadPixels)[i]; … … 1385 1349 { 1386 1350 1387 MCalibrationChargePix &pix = (MCalibrationChargePix&)(* chargecam)[i];1351 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 1388 1352 1389 1353 if (!pix.IsFFactorMethodValid()) … … 1440 1404 { 1441 1405 1442 MCalibrationChargePix &apix = (MCalibrationChargePix&) chargecam->GetAverageArea(aidx);1406 MCalibrationChargePix &apix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx); 1443 1407 1444 1408 if (numareavalid[aidx] == 1) … … 1495 1459 } 1496 1460 1497 MCalibrationChargePix &spix = (MCalibrationChargePix&) chargecam->GetAverageSector(sector);1461 MCalibrationChargePix &spix = (MCalibrationChargePix&)fCam->GetAverageSector(sector); 1498 1462 1499 1463 if (sectorweights[sector] < 0. || sectorphes[sector] <= 0.) … … 1524 1488 { 1525 1489 1526 MCalibrationChargePix &pix = (MCalibrationChargePix&)(* chargecam)[i];1490 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 1527 1491 1528 1492 MBadPixelsPix &bad = (*fBadPixels)[i]; … … 1534 1498 { 1535 1499 const Int_t aidx = (*fGeom)[i].GetAidx(); 1536 MCalibrationChargePix &apix = (MCalibrationChargePix&) chargecam->GetAverageArea(aidx);1500 MCalibrationChargePix &apix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx); 1537 1501 1538 1502 pix.SetPheFFactorMethod ( apix.GetPheFFactorMethod() ); … … 1726 1690 } 1727 1691 1728 MCalibrationChargeCam *chargecam = fIntensCam 1729 ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam; 1730 1731 MCalibrationChargePix &avpix = (MCalibrationChargePix&)chargecam->GetAverageArea(0); 1692 MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCam->GetAverageArea(0); 1732 1693 MCalibrationQEPix &qepix = (MCalibrationQEPix&) fQECam->GetAverageArea(0); 1733 1694 … … 1757 1718 // Set the results in the MCalibrationChargeCam 1758 1719 // 1759 chargecam->SetNumPhotonsFFactorMethod (avphotons);1720 fCam->SetNumPhotonsFFactorMethod (avphotons); 1760 1721 1761 1722 if (avphotrelvar > 0.) 1762 chargecam->SetNumPhotonsFFactorMethodErr(TMath::Sqrt( avphotrelvar * avphotons * avphotons));1723 fCam->SetNumPhotonsFFactorMethodErr(TMath::Sqrt( avphotrelvar * avphotons * avphotons)); 1763 1724 1764 1725 TArrayF lowlim (nareas); … … 1775 1736 { 1776 1737 1777 MCalibrationChargePix &pix = (MCalibrationChargePix&)(* chargecam)[i];1778 MCalibrationQEPix &qpix = (MCalibrationQEPix&) (*fQECam) 1738 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 1739 MCalibrationQEPix &qpix = (MCalibrationQEPix&) (*fQECam)[i]; 1779 1740 1780 1741 MBadPixelsPix &bad = (*fBadPixels)[i]; … … 1895 1856 { 1896 1857 1897 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i]; 1898 1858 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 1899 1859 MBadPixelsPix &bad = (*fBadPixels)[i]; 1900 1860 … … 1920 1880 { 1921 1881 1922 MCalibrationChargePix &pix = (MCalibrationChargePix&)(* chargecam)[i];1923 MCalibrationQEPix &qpix = (MCalibrationQEPix&) (*fQECam)[i];1882 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 1883 MCalibrationQEPix &qpix = (MCalibrationQEPix&)(*fQECam)[i]; 1924 1884 1925 1885 if ((*fBadPixels)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) … … 1957 1917 return; 1958 1918 1959 MCalibrationChargeCam *chargecam = fIntensCam1960 ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam;1961 1962 1963 1919 // 1964 1920 // Set the results in the MCalibrationChargeCam … … 1969 1925 const Float_t photons = fBlindCam->GetFluxInsidePlexiglass() * (*fGeom)[0].GetA() 1970 1926 / fQECam->GetPlexiglassQE(); 1971 chargecam->SetNumPhotonsBlindPixelMethod(photons);1927 fCam->SetNumPhotonsBlindPixelMethod(photons); 1972 1928 1973 1929 const Float_t photrelvar = fBlindCam->GetFluxInsidePlexiglassRelVar() … … 1975 1931 1976 1932 if (photrelvar > 0.) 1977 chargecam->SetNumPhotonsBlindPixelMethodErr(TMath::Sqrt( photrelvar * photons * photons));1933 fCam->SetNumPhotonsBlindPixelMethodErr(TMath::Sqrt( photrelvar * photons * photons)); 1978 1934 } 1979 1935 … … 2002 1958 } 2003 1959 2004 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i];2005 MGeomPix &geo = (*fGeom)[i];1960 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 1961 MGeomPix &geo = (*fGeom)[i]; 2006 1962 2007 1963 const Float_t qe = pix.GetPheFFactorMethod() … … 2046 2002 const UInt_t npixels = fGeom->GetNumPixels(); 2047 2003 2048 MCalibrationChargeCam *chargecam = fIntensCam2049 ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam;2050 2051 2004 if (!fPINDiode) 2052 2005 return; … … 2080 2033 continue; 2081 2034 } 2082 2083 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i];2084 MGeomPix &geo = (*fGeom)[i];2085 2086 const Float_t qe = pix.GetPheFFactorMethod() 2035 2036 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 2037 MGeomPix &geo = (*fGeom)[i]; 2038 2039 const Float_t qe = pix.GetPheFFactorMethod() 2087 2040 / fPINDiode->GetFluxOutsidePlexiglass() 2088 2041 / geo.GetA(); … … 2129 2082 // 2130 2083 // - Print out statistics about BadPixels of type UnsuitableType_t 2131 // - store numbers of bad pixels of each type in fCam or fIntensCam2084 // - store numbers of bad pixels of each type in fCam 2132 2085 // 2133 2086 Bool_t MCalibrationChargeCalc::FinalizeUnsuitablePixels() … … 2143 2096 TArrayI unsuit(nareas); 2144 2097 TArrayI unrel(nareas); 2145 2146 MCalibrationChargeCam *chargecam = fIntensCam ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam;2147 2098 2148 2099 Int_t unsuitcnt=0; … … 2159 2110 unrelcnt += unrel[aidx]; 2160 2111 2161 chargecam->SetNumUnsuitable(unsuit[aidx], aidx);2162 chargecam->SetNumUnreliable(unrel[aidx], aidx);2112 fCam->SetNumUnsuitable(unsuit[aidx], aidx); 2113 fCam->SetNumUnreliable(unrel[aidx], aidx); 2163 2114 } 2164 2115 2165 2116 TArrayI counts(nareas); 2166 for (Int_t i=0; i< chargecam->GetSize(); i++)2117 for (Int_t i=0; i<fCam->GetSize(); i++) 2167 2118 { 2168 MCalibrationPix &pix = (*chargecam)[i];2119 const MCalibrationPix &pix = (*fCam)[i]; 2169 2120 if (pix.IsHiGainSaturation()) 2170 2121 { -
trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h
r8425 r8452 23 23 class MCalibrationChargePINDiode; 24 24 class MHCalibrationChargeBlindCam; 25 class MCalibrationIntensityBlindCam;26 25 class MCalibrationBlindCam; 27 26 class MCalibrationChargePix; 28 class MCalibrationIntensityChargeCam;29 27 class MCalibrationChargeCam; 30 28 class MHCalibrationChargeCam; … … 81 79 82 80 Int_t fNumProcessed; // Number of processed events (for Intensity calibration) 83 81 82 Bool_t fContinousCalibration; 83 84 84 // Pointers 85 85 // MBadPixelsIntensityCam *fIntensBad; //! Bad Pixels 86 86 MBadPixelsCam *fBadPixels; //! Bad Pixels 87 MCalibrationIntensityChargeCam *fIntensCam; //! Intensity Calibration results of all pixels88 87 MCalibrationChargeCam *fCam; //! Calibrated Charges results of all pixels 89 88 MHCalibrationChargeCam *fHCam; //! Charges histograms of all pixels 90 MCalibrationIntensityBlindCam *fIntensBlind; //! Intensity Calibration results of the Blind Pixels91 89 MCalibrationBlindCam *fBlindCam; //! Calibrated Charges of the Blind Pixels 92 90 MHCalibrationChargeBlindCam *fHBlindCam; //! Charges histograms of the Blind Pixels … … 198 196 void SetUseExternalNumPhes(const Bool_t b=kTRUE) { b ? SETBIT(fFlags, kUseExternalNumPhes) : CLRBIT(fFlags, kUseExternalNumPhes); } 199 197 198 void SetContinousCalibration(const Bool_t b=kTRUE) { fContinousCalibration = b; } 199 200 200 // pointers 201 201 void SetPedestals(MPedestalCam *cam) { fPedestals=cam; } … … 217 217 void SetPheErrUpperLimit ( const Float_t f=fgPheErrUpperLimit ) { fPheErrUpperLimit = f; } 218 218 void SetPulserColor ( const MCalibrationCam::PulserColor_t col ) { fPulserColor = col; } 219 220 ClassDef(MCalibrationChargeCalc, 5) // Task calculating Calibration Containers and Quantum Efficiencies219 220 ClassDef(MCalibrationChargeCalc, 6) // Task calculating Calibration Containers and Quantum Efficiencies 221 221 }; 222 222 -
trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
r8106 r8452 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCam.cc,v 1. 69 2006-10-17 17:18:40tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCam.cc,v 1.70 2007-04-27 10:04:46 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 216 216 void MCalibrationChargeCam::Clear(Option_t *o) 217 217 { 218 218 // DO NOT RESET THE HI-/LO-GAIN CONSTANTS 219 219 SetFFactorMethodValid ( kFALSE ); 220 220 221 fNumPhotonsBlindPixelMethod = 0.; 222 fNumPhotonsFFactorMethod = 0.; 223 fNumPhotonsPINDiodeMethod = 0.; 224 fNumPhotonsBlindPixelMethodErr = 0.; 225 fNumPhotonsFFactorMethodErr = 0.; 226 fNumPhotonsPINDiodeMethodErr = 0.; 221 fNumPhotonsBlindPixelMethod = 0.; 222 fNumPhotonsFFactorMethod = 0.; 223 fNumPhotonsPINDiodeMethod = 0.; 224 fNumPhotonsBlindPixelMethodErr = 0.; 225 fNumPhotonsFFactorMethodErr = 0.; 226 fNumPhotonsPINDiodeMethodErr = 0.; 227 227 228 228 MCalibrationCam::Clear(); 229 230 return;231 229 } 232 230 -
trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc
r8428 r8452 64 64 #include "MLogManip.h" 65 65 66 #include "MMath.h" 67 66 68 #include "MParList.h" 67 69 … … 81 83 using namespace std; 82 84 83 const Float_t MCalibrationRelTimeCalc::fgRelTimeResolutionLimit = 0.05;85 const Float_t MCalibrationRelTimeCalc::fgRelTimeResolutionLimit = 5.0; 84 86 85 87 // -------------------------------------------------------------------------- 86 88 // 87 // Default constructor. 89 // Default constructor. 88 90 // 89 91 // Sets all pointers to NULL … … 98 100 : fGeom(NULL), fFlags(0) 99 101 { 100 102 101 103 fName = name ? name : "MCalibrationRelTimeCalc"; 102 104 fTitle = title ? title : "Task to finalize the relative time calibration"; 103 105 104 106 SetCheckFitResults ( kFALSE ); 105 SetCheckDeviatingBehavior( k FALSE);107 SetCheckDeviatingBehavior( kTRUE ); 106 108 SetCheckHistOverflow ( kFALSE ); 107 109 SetCheckOscillations ( kFALSE ); … … 164 166 } 165 167 166 const UInt_t npixels = fGeom->GetNumPixels(); 167 for (UInt_t i=0; i<npixels; i++) 168 if (IsDebug()) 168 169 { 169 MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i]; 170 171 if ((*fBadPixels)[i].IsBad()) 172 { 173 pix.SetExcluded(); 174 continue; 175 } 176 177 if (IsDebug()) 178 pix.SetDebug(); 170 const UInt_t npixels = fGeom->GetNumPixels(); 171 for (UInt_t i=0; i<npixels; i++) 172 (*fCam)[i].SetDebug(); 179 173 } 180 174 … … 233 227 234 228 PrintUncalibrated(MBadPixelsPix::kDeviatingTimeResolution, 235 Form("%s%2.1f%s","Time resol. less than ", fRelTimeResolutionLimit, " FADC sl. from Mean:"));229 Form("%s%2.1f%s","Time resol. less than ", fRelTimeResolutionLimit, " med-dev from median:")); 236 230 PrintUncalibrated(MBadPixelsPix::kRelTimeOscillating, 237 231 "Pixels with changing Rel. Times over time:"); … … 245 239 // ---------------------------------------------------------------------------------------------------- 246 240 // 247 // 248 // First loop: Calculate a mean and mean RMS of time resolution per area index 249 // Include only pixels which are not MBadPixelsPix::kUnsuitableRun or 250 // MBadPixelsPix::kUnreliableRun (see FinalizeBadPixels()) 251 // 252 // Second loop: Exclude those deviating by more than fRelTimeResolutionLimit FADC slices 253 // from the mean (obtained in first loop). Set 254 // MBadPixelsPix::kDeviatingTimeResolution if excluded. 255 // 241 // Check for outliers. They are marked with 242 // MBadPixelsPix::kDeviatingTimeResolution 243 // 256 244 void MCalibrationRelTimeCalc::FinalizeRelTimes() 257 245 { 258 259 const UInt_t npixels = fGeom->GetNumPixels(); 260 const UInt_t nareas = fGeom->GetNumAreas(); 261 262 TArrayF lowlim (nareas); 263 TArrayF upplim (nareas); 264 TArrayF areasum (nareas); 265 TArrayI numareavalid (nareas); 266 TArrayI useunreliable(nareas); 267 268 // 269 // Apero loop: Count number of unreliable pixels: 270 // 271 for (UInt_t i=0; i<npixels; i++) 272 { 273 MBadPixelsPix &bad = (*fBadPixels)[i]; 274 const Int_t aidx = (*fGeom)[i].GetAidx(); 275 276 if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) 277 continue; 278 279 if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun)) 280 continue; 281 282 numareavalid[aidx] ++; 283 } 284 285 for (UInt_t aidx=0; aidx<nareas; aidx++) 286 if (numareavalid[aidx] < 100) 287 useunreliable[aidx] = 1; 288 289 numareavalid.Reset(); 290 // 291 // First loop: Get mean time resolution the RMS 292 // The loop is only to recognize later pixels with very deviating numbers 293 // 294 for (UInt_t i=0; i<npixels; i++) 295 { 296 297 const MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i]; 298 299 if (pix.IsExcluded()) 300 continue; 301 302 MBadPixelsPix &bad = (*fBadPixels)[i]; 303 if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) 304 continue; 305 306 const Int_t aidx = (*fGeom)[i].GetAidx(); 307 308 if (!useunreliable[aidx]) 309 if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun)) 310 continue; 311 312 const Float_t res = pix.GetTimePrecision(); 313 314 areasum [aidx] += res; 315 // areasum2 [aidx] += res*res; 316 numareavalid[aidx] ++; 317 } 318 319 320 for (UInt_t aidx=0; aidx<nareas; aidx++) 321 { 322 if (numareavalid[aidx] < 20) 246 const Int_t npixels = fGeom->GetNumPixels(); 247 const Int_t nareas = fGeom->GetNumAreas(); 248 249 // Create an array capable of holding all pixels 250 TArrayF arr(npixels); 251 252 for (Int_t aidx=0; aidx<nareas; aidx++) 253 { 254 Int_t n = 0; 255 for (Int_t i=0; i<npixels; i++) 323 256 { 324 *fLog << warn << "Area " << setw(4) << aidx << ": Less than 20 pixels with valid time resolution found." << endl; 325 continue; 257 // Check for this aidx only 258 if ((*fGeom)[i].GetAidx()!=aidx) 259 continue; 260 261 // check if pixel may not contain a valid value 262 if ((*fBadPixels)[i].IsUnsuitable()) 263 continue; 264 265 // check if it was excluded for some reason 266 const MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i]; 267 if (pix.IsExcluded()) 268 continue; 269 270 // if TimePrecision is valid fill it into array 271 if (pix.GetTimePrecision()>0) 272 arr[n++] = pix.GetTimePrecision(); 326 273 } 327 274 328 // Calculate the rms out of sum2: 329 /* 330 areasum2[aidx] = (areasum2[aidx] - areasum[aidx]*areasum[aidx]/numareavalid[aidx]); 331 areasum2[aidx] /= (numareavalid[aidx]-1.); 332 */ 333 areasum [aidx] /= numareavalid[aidx]; 334 lowlim [aidx] = 0; 335 upplim [aidx] = areasum [aidx] + fRelTimeResolutionLimit; 336 337 } 338 *fLog << endl; 339 340 341 for (UInt_t i=0; i<npixels; i++) 342 { 343 344 MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i]; 345 346 if (pix.IsExcluded()) 347 continue; 348 349 MBadPixelsPix &bad = (*fBadPixels)[i]; 350 if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) 351 continue; 352 353 const Float_t res = pix.GetTimePrecision(); 354 const Int_t aidx = (*fGeom)[i].GetAidx(); 355 356 if ( res < lowlim[aidx] || res > upplim[aidx] ) 275 // Check the ratio of valid entries to the ratio of pixels 276 const Float_t ratio = 100*n/fGeom->GetNumPixWithAidx(aidx); 277 if (3*ratio<2) 278 *fLog << warn << "Area " << setw(4) << aidx << ": Only " << ratio << "% pixels with valid time resolution found." << endl; 279 280 // Calculate median and median deviation 281 Double_t med; 282 const Double_t dev = MMath::MedianDev(n, arr.GetArray(), med); 283 284 // Now find the outliers 285 for (Int_t i=0; i<npixels; i++) 357 286 { 358 *fLog << warn << "Pixel " << setw(4) << i << ": Deviating time resolution: " 359 << Form("%4.2f",res) << " out of range [" 360 << Form("%4.2f,%4.2f",lowlim[aidx],upplim[aidx]) << "]" << endl; 361 bad.SetUncalibrated( MBadPixelsPix::kDeviatingTimeResolution); 362 pix.SetExcluded(); 287 // Search only within this aidx 288 if ((*fGeom)[i].GetAidx()!=aidx) 289 continue; 290 291 // skip pixels already known to be unsuitable 292 if ((*fBadPixels)[i].IsUnsuitable()) 293 continue; 294 295 // check if a pixel has been excluded. This 296 const MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i]; 297 298 // Check if time precision is valid (might be invalid 299 // for example in cae of empty histograms) 300 const Float_t res = pix.GetTimePrecision(); 301 if (res<0) //FIXME!!! How does this happen? 302 { 303 *fLog << warn << "Pixel " << setw(4) << i << ": Time resolution not calculated." << endl; 304 (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kDeviatingTimeResolution); 305 continue; 306 } 307 308 // Now compare to a lower and upper limit 309 const Float_t lolim = TMath::Max(med-fRelTimeResolutionLimit*dev, 0.); 310 const Float_t hilim = TMath::Max(med+fRelTimeResolutionLimit*dev, 0.); 311 312 if (res<=lolim || res>=hilim) 313 { 314 *fLog << warn << "Pixel " << setw(4) << i << ": Deviating time resolution: " 315 << Form("%4.2f", res) << " out of range " 316 << Form("[%4.2f,%4.2f]", lolim, hilim) << endl; 317 318 (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kDeviatingTimeResolution); 319 } 363 320 } 364 321 } … … 373 330 // - MBadPixelsPix::kRelTimeRelErrNotValid 374 331 // 375 // - Call MCalibrationPix::SetExcluded() for the bad pixels376 //377 332 void MCalibrationRelTimeCalc::FinalizeBadPixels() 378 333 { … … 380 335 for (Int_t i=0; i<fBadPixels->GetSize(); i++) 381 336 { 382 383 337 MBadPixelsPix &bad = (*fBadPixels)[i]; 384 338 385 339 if (IsCheckDeviatingBehavior()) 386 340 if (bad.IsUncalibrated(MBadPixelsPix::kDeviatingTimeResolution)) 387 bad.SetUnsuitable(MBadPixelsPix::kUn reliableRun);341 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun); 388 342 389 343 if (IsCheckFitResults()) … … 394 348 if (bad.IsUncalibrated(MBadPixelsPix::kRelTimeOscillating)) 395 349 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun); 396 397 if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))398 {399 MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i];400 pix.SetExcluded();401 }402 350 } 403 351 … … 460 408 void MCalibrationRelTimeCalc::PrintUncalibrated(const char *text, Int_t in, Int_t out) const 461 409 { 462 *fLog << " " << setfill(' ') << setw( 56) << setiosflags(ios::left) << text;410 *fLog << " " << setfill(' ') << setw(48) << setiosflags(ios::left) << text; 463 411 *fLog << " Inner: " << Form("%3i", in); 464 412 *fLog << " Outer: " << Form("%3i", out); -
trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.cc
r5047 r8452 131 131 *fLog << all << GetDescriptor() << ":" << endl; 132 132 int id = 0; 133 133 134 134 *fLog << all << "Calibrated pixels:" << endl; 135 135 *fLog << all << endl; … … 138 138 MCalibrationRelTimePix *pix; 139 139 while ((pix=(MCalibrationRelTimePix*)Next())) 140 141 142 if (!pix->IsExcluded())143 { 144 145 *fLog << all146 << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Pix ",pix->GetPixId(),147 ": Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),148 " Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())149 140 { 141 if (!pix->IsExcluded()) 142 { 143 *fLog << all 144 << "Pix " << Form("%4i", pix->GetPixId()) << ": " 145 << " Offset: " 146 << Form("%4.2f +- %4,2f", pix->GetTimeOffset(), pix->GetTimeOffsetErr()) 147 << " Precision: " 148 << Form("%4.2f +- %4.2f", pix->GetTimePrecision(), pix->GetTimePrecisionErr()) 149 << endl; 150 150 id++; 151 152 153 151 } 152 } 153 154 154 *fLog << all << id << " pixels" << endl; 155 155 id = 0; 156 157 156 157 158 158 *fLog << all << endl; 159 159 *fLog << all << "Excluded pixels:" << endl; 160 160 *fLog << all << endl; 161 161 162 162 id = 0; 163 163 … … 177 177 while ((pix=(MCalibrationRelTimePix*)Next5())) 178 178 { 179 *fLog << all 180 << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Area ",pix->GetPixId(), 181 ": Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(), 182 " Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr()) 179 *fLog << all 180 << "Average Area " << Form("%4i", pix->GetPixId()) << ":" 181 << "Offset: " 182 << Form("%4.2f +- %4,2f", pix->GetTimeOffset(), pix->GetTimeOffsetErr()) 183 << " Precision: " 184 << Form("%4.2f +- %4.2f", pix->GetTimePrecision(), pix->GetTimePrecisionErr()) 183 185 << endl; 184 186 } … … 187 189 while ((pix=(MCalibrationRelTimePix*)Next5())) 188 190 { 189 *fLog << all 190 << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Sector ",pix->GetPixId(), 191 ": Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(), 192 " Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr()) 191 *fLog << all 192 << "Average Sector " << Form("%4i", pix->GetPixId()) << ":" 193 << "Offset: " 194 << Form("%4.2f +- %4.2f", pix->GetTimeOffset(), pix->GetTimeOffsetErr()) 195 << " Precision: " 196 << Form("%4.2f +- %4.2f", pix->GetTimePrecision(), pix->GetTimePrecisionErr()) 193 197 << endl; 194 198 } … … 232 236 return kFALSE; 233 237 val = pix.GetMean(); 234 break;238 return val!=-1.; 235 239 case 1: 236 240 if (pix.IsExcluded()) … … 257 261 } 258 262 259 return val !=-1.;260 261 } 262 263 return val>=0; 264 265 } 266 -
trunk/MagicSoft/Mars/mcalib/Makefile
r8429 r8452 39 39 MCalibrationPatternDecode.cc \ 40 40 MCalibrateRelTimes.cc \ 41 MCalibrationIntensityCam.cc \42 MCalibrationIntensityChargeCam.cc \43 41 MCalibrationCam.cc \ 44 42 MCalibrationPix.cc \
Note:
See TracChangeset
for help on using the changeset viewer.