Ignore:
Timestamp:
04/27/07 11:05:11 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mcalib
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h

    r8429 r8452  
    1616#pragma link C++ class MCalibConstCam+;
    1717#pragma link C++ class MCalibConstPix+;
    18 
    19 #pragma link C++ class MCalibrationIntensityCam+;
    20 #pragma link C++ class MCalibrationIntensityChargeCam+;
    2118
    2219#pragma link C++ class MCalibrationCam+;
  • trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc

    r8428 r8452  
    3030//  Input Containers:
    3131//   MParList
    32 //   MCalibrationIntensityChargeCam
    3332//
    3433//  Output Containers:
    35 //   MCalibrationIntensityChargeCam
    3634//
    3735// Class version 2:
     
    5553#include "MHCalibrationCam.h"
    5654
    57 #include "MCalibrationIntensityChargeCam.h"
    58 
    5955#include "MBadPixelsCam.h"
    6056
    6157#include "MCalibrationQECam.h"
    6258#include "MCalibrationBlindCam.h"
     59#include "MCalibrationChargeCam.h"
    6360#include "MCalibrationChargePix.h"
    6461#include "MCalibrationChargeCalc.h"
     
    8380MCalibCalcFromPast::MCalibCalcFromPast(const char *name, const char *title)
    8481    : fGeom(NULL), fParList(NULL), fRunHeader(NULL),
    85     fIntensCharge(NULL), fBlindCam(NULL), fQECam(NULL), fBadPixels(NULL),
     82    fCharge(NULL), fBlindCam(NULL), fQECam(NULL), fBadPixels(NULL),
    8683    fChargeCalc(NULL), fRelTimeCalc(NULL), fCalibrate(NULL),
    8784    fNumCam(0), fNumEvents(0), fUpdateWithFFactorMethod(kTRUE), fUpdateNumPhes(kTRUE),
     
    133130
    134131  //
    135   // Look for the MBadPixels Intensity Cam
     132  // Look for the MCalibrationQECam
    136133  //
    137134  fQECam = (MCalibrationQECam*)pList->FindObject("MCalibrationQECam");
     
    143140
    144141  //
    145   // Look for the MFillH-class "MHCalibrationBlindCam". In case yes, initialize the
    146   // corresponding IntensityCam
     142  // Look for the MFillH-class "MHCalibrationBlindCam".
    147143  //
    148144  if (pList->FindObject(AddSerialNumber("MHCalibrationBlindCam")))
     
    156152
    157153  //
    158   // Look for the MFillH-class "MHCalibrationChargeCam". In case yes, initialize the
    159   // corresponding IntensityCam
     154  // Look for the MFillH-class "MHCalibrationChargeCam".
    160155  //
    161156  if (pList->FindObject(AddSerialNumber("MHCalibrationChargeCam")))
    162157  {
    163158
    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;
    174162
    175163    if (!fChargeCalc)
     
    194182
    195183  //
    196   // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the
    197   // corresponding IntensityCam
     184  // Look for the MFillH name "FillRelTimeCam".
    198185  //
    199186  if (pList->FindObject(AddSerialNumber("MHCalibrationRelTimeCam")))
    200187  {
    201     // if (!pList->FindCreateObj("MCalibrationIntensityRelTimeCam"))
    202     //    return kFALSE;
    203 
    204188    if (!fRelTimeCalc)
    205189      fRelTimeCalc   = (MCalibrationRelTimeCalc*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCalc"));
     
    252236//
    253237// - 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.
    255239// - Executes Finalize() of the MCalibration*Calc classes in that case.
    256240// - Sets the latest MCalibrationChargeCam as update class into MCalibrateData
    257 // - Initialize new MCalibration*Cams into the intensity cams.
     241// - clean MCalibration*Cams
    258242//
    259243Int_t MCalibCalcFromPast::Process()
     
    263247
    264248  // Replace the old cams by (empty) new ones
    265   // MCalibrationChargeCam: fIntensCharge
     249  // MCalibrationChargeCam: fCharge
    266250  // MCalibrationQECam:     fIntensQE
    267251  // MCalibrationBlindCam:  fIntensBlind
     
    276260  *fLog << inf << "Finalize calibration histograms:" << endl;
    277261
    278   // This fills the IntensityCam which are newly created by
     262  // This fills the Cams which are cleared by
    279263  // ReInitialize with the result of the last calib cycle
    280264  Finalize("MHCalibrationChargeCam");
     
    299283        if (fUpdateNumPhes)
    300284        {
    301           MCalibrationChargePix &avpix =(MCalibrationChargePix&)fIntensCharge->GetCam()->GetAverageArea(0);
     285          MCalibrationChargePix &avpix =(MCalibrationChargePix&)fCharge->GetAverageArea(0);
    302286          fPhes   [fNumPhes] = avpix.GetPheFFactorMethod();
    303287          fPhesVar[fNumPhes] = avpix.GetPheFFactorMethodVar();
     
    329313
    330314  if (fCalibrate)
    331     return fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL
    332                                                : (MCalibrationChargeCam*)fIntensCharge->GetCam() );
     315    return fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL : fCharge);
    333316
    334317  return kTRUE;
     
    358341// --------------------------------------------------------------------------
    359342//
    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
    363344//
    364345Bool_t MCalibCalcFromPast::ReInitialize()
     
    391372  // IF SIMPLE ENOUGH, REMOVE THE FUNCTION!
    392373
    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);
    408379  }
    409380
  • trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.h

    r8427 r8452  
    1717class MCalibrationRelTimeCalc;
    1818class MCalibrateData;
    19 class MCalibrationIntensityChargeCam;
     19class MCalibrationChargeCam;
    2020class MCalibrationBlindCam;
    2121class MCalibrationQECam;
     
    3232  MParList                        *fParList;         //! Parameter List
    3333  MRawRunHeader                   *fRunHeader;       //! Run header storing the run number
    34   MCalibrationIntensityChargeCam  *fIntensCharge;    //! Intensity Charge Cam (to be created)
     34  MCalibrationChargeCam           *fCharge;          //! Intensity Charge Cam (to be created)
    3535
    3636  MCalibrationBlindCam            *fBlindCam;        //! Blind  Cam
  • trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.cc

    r8428 r8452  
    3333//   MCalibrationPattern
    3434//   MParList
    35 //   MCalibrationIntensityChargeCam
    3635//
    3736//  Output Containers:
    38 //   MCalibrationIntensityChargeCam
    3937//
    4038//////////////////////////////////////////////////////////////////////////////
     
    5553#include "MBadPixelsCam.h"
    5654
    57 #include "MCalibrationIntensityChargeCam.h"
    58 
    5955#include "MCalibrationPattern.h"
    6056#include "MCalibrationQECam.h"
     
    7672//
    7773MCalibColorSteer::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),
    8075      fBad(NULL), fChargeCalc(NULL), fRelTimeCalc(NULL), fHistCopy(kFALSE)
    8176{
     
    148143
    149144  //
    150   // Look for the MFillH name "FillChargeCam". In case yes, initialize the
    151   // corresponding IntensityCam
     145  // Look for the MFillH name "FillChargeCam".
    152146  //
    153147  if (pList->FindObject(AddSerialNumber("MHCalibrationChargeCam")))
     
    155149      *fLog << inf << "Found MHCalibrationChargeCam ... " << flush;
    156150
    157       fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");
    158       if (!fIntensCharge)
     151      fCharge = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam");
     152      if (!fCharge)
    159153          return kFALSE;
    160154
     
    172166
    173167  //
    174   // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the
    175   // corresponding IntensityCam
     168  // Look for the MFillH name "FillRelTimeCam".
    176169  //
    177170  if (pList->FindObject(AddSerialNumber("MHCalibrationRelTimeCam")))
     
    199192// --------------------------------------------------------------------------
    200193//
    201 // Reads the pattern from MCalibrationPattern and initializes new containers in the
    202 // Intensity Cams, if the pattern has changed. Executes Finalize of the
     194// Reads the pattern from MCalibrationPattern and clear
     195// Cams, if the pattern has changed. Executes Finalize of the
    203196// MCalibration*Calc classes in that case.
    204197//
     
    256249// --------------------------------------------------------------------------
    257250//
    258 // Reads the pattern from MCalibrationPattern and initializes new containers in the
    259 // Intensity Cams, if the pattern has changed. Executes Finalize of the
     251// Reads the pattern from MCalibrationPattern and clear
     252// Cams, if the pattern has changed. Executes Finalize of the
    260253// MCalibration*Calc classes in that case.
    261254//
     
    290283
    291284  hist->Finalize();
    292   CopyHist(name);
     285  //CopyHist(name);
    293286  hist->ResetHists();
    294287  hist->SetColor( fCalibPattern->GetPulserColor());
     
    298291// --------------------------------------------------------------------------
    299292//
    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
    303294//
    304295Bool_t MCalibColorSteer::ReInitialize()
     
    310301
    311302  fBad->Clear(); // FIXME:::::: MERGE PreExcl!!!!
    312   fQECam->Clear();
     303
     304  if (fQECam)
     305      fQECam->Clear();
    313306
    314307  fBlindCam->Clear();
    315308  fBlindCam->SetPulserColor(fCalibPattern->GetPulserColor());
    316309
    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  }
    330321
    331322  return kTRUE;
     
    360351  return result;
    361352}
    362 
    363 // --------------------------------------------------------------------------
    364 //
    365 // Copies the histogram classes into the intensity cams
    366 //
    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  
    1616class MRawRunHeader;
    1717class MCalibrationChargeCalc;
     18class MCalibrationChargeCam;
    1819class MCalibrationRelTimeCalc;
    19 class MCalibrationIntensityChargeCam;
    2020class MCalibrationRelTimeCam;
    2121class MCalibrationBlindCam;
     
    3030  MGeomCam                        *fGeom;            //!
    3131  MParList                        *fParList;         //!
    32   MCalibrationIntensityChargeCam  *fIntensCharge;    //!
     32  MCalibrationChargeCam           *fCharge;          //!
    3333  MCalibrationRelTimeCam          *fRelTimeCam;      //!
    3434  MCalibrationBlindCam            *fBlindCam;        //!
    3535  MCalibrationQECam               *fQECam;           //!
    3636  MBadPixelsCam                   *fBad;             //!
    37  
     37
    3838  MCalibrationChargeCalc          *fChargeCalc;      //!
    3939  MCalibrationRelTimeCalc         *fRelTimeCalc;     //!
    40                                                      
     40
    4141  MCalibrationCam::PulserColor_t   fColor;
    4242  Float_t                          fStrength;
    4343
    4444  Bool_t                           fHistCopy;        // Decide whether MHCalibrationCams will get copied
    45  
     45
    4646  Int_t  PreProcess(MParList *pList);
    4747  Int_t  Process();
    4848  Int_t  PostProcess();
    49  
     49
    5050  Bool_t ReInitialize();
    5151  Bool_t Finalize(const char* name);
    5252
    53   void    CopyHist(const char* name);
     53  //void    CopyHist(const char* name);
    5454  TString GetNamePattern();
    55  
     55
    5656public:
    5757    MCalibColorSteer(const char *name=NULL, const char *title=NULL);
  • trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc

    r8425 r8452  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MCalibrateData.cc,v 1.67 2007-04-20 11:48:08 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MCalibrateData.cc,v 1.68 2007-04-27 10:04:46 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    114114#include "MPedestalPix.h"
    115115
    116 #include "MCalibrationIntensityChargeCam.h"
    117116#include "MCalibrationChargeCam.h"
    118117#include "MCalibrationChargePix.h"
     
    155154//
    156155MCalibrateData::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),
    158157      fQEs(NULL), fSignals(NULL), fCerPhotEvt(NULL), fCalibConstCam(NULL),
    159158    fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.), fScaleFactor(1.)
     
    238237    if (fCalibrationMode>kNone)
    239238    {
    240         fIntensCalib = (MCalibrationIntensityChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityChargeCam"));
    241         if (fIntensCalib)
    242           *fLog << inf << "Found MCalibrationIntensityChargeCam ... " << endl;
    243 
    244239        fCalibrations = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
    245240        if (!fCalibrations)
     
    465460    if (fCalibrationMode > kNone)
    466461    {
    467 
    468         const MCalibrationCam *chargecam = fIntensCalib ? fIntensCalib->GetCam() : fCalibrations;
    469         if (chargecam->GetSize() != npixels)
     462        if (fCalibrations->GetSize() != npixels)
    470463        {
    471464            *fLog << "Size mismatch between MGeomCam and MCalibrationChargeCam... abort!" << endl;
     
    478471            return kFALSE;
    479472        }
    480       }
    481    
     473    }
     474
    482475    fCalibConsts  .Set(npixels);
    483476    fCalibFFactors.Set(npixels);
     
    512505    fHiLoConv.Reset();
    513506    fHiLoConvErr.Reset();
    514 
    515     MCalibrationChargeCam *chargecam = NULL;
    516     if (updatecam)
    517         chargecam = fCalibrations;
    518     else
    519         chargecam = fIntensCalib ? (MCalibrationChargeCam*)fIntensCalib->GetCam() : fCalibrations;
    520507
    521508    //
     
    546533             }
    547534           
    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);
    550537
    551538            hiloconv   = pix.GetConversionHiLo     ();
    552539            hiloconverr= pix.GetConversionHiLoSigma();
    553            
     540
    554541            calibConv    = pix.GetMeanConvFADC2Phe();
    555542            calibConvVar = pix.GetMeanConvFADC2PheVar();
    556543            calibFFactor = pix.GetMeanFFactorFADC2Phot();
    557            
     544
    558545            const MCalibrationQEPix &qe = (MCalibrationQEPix&)(*fQEs)[pixidx];
    559546
  • trunk/MagicSoft/Mars/mcalib/MCalibrateData.h

    r8425 r8452  
    2020class MCalibrationChargeCam;
    2121class MCalibrationQECam;
    22 
    23 class MCalibrationIntensityChargeCam;
    2422
    2523class MCalibrateData : public MTask
     
    6361  MBadPixelsCam                  *fBadPixels;     //! Bad Pixels information
    6462  MCalibrationChargeCam          *fCalibrations;  //! Calibration constants
    65   MCalibrationIntensityChargeCam *fIntensCalib;   //! Calibration constants from interlaced calib.
    6663  MCalibrationQECam              *fQEs;           //! Quantum efficiencies
    6764  MExtractedSignalCam            *fSignals;       //! Integrated charge in FADCs counts
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r8427 r8452  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.176 2007-04-20 13:21:11 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.177 2007-04-27 10:04:46 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    200200//   -  TString fOutputFile
    201201//
     202//  ClassVersion 6:
     203//   -  Bool_t fContinousCalibration
     204//
    202205//////////////////////////////////////////////////////////////////////////////
    203206#include "MCalibrationChargeCalc.h"
     
    220223#include "MPedestalCam.h"
    221224#include "MPedestalPix.h"
    222 
    223 #include "MCalibrationIntensityChargeCam.h"
    224225
    225226#include "MHCalibrationChargeCam.h"
     
    362363
    363364    fBadPixels   = NULL;
    364     fIntensCam   = NULL;
    365365    fCam         = NULL;
    366366    fHCam        = NULL;
     
    440440// Search for the following input containers and abort if not existing:
    441441//  - MGeomCam
    442 // -  MCalibrationIntensityChargeCam or MCalibrationChargeCam
     442// -  MCalibrationChargeCam
    443443//  - MCalibrationQECam
    444444//  - MBadPixelsCam
     
    455455// It defines the PixId of every pixel in:
    456456//
    457 // - MCalibrationIntensityChargeCam
    458457// - MCalibrationChargeCam
    459458// - MCalibrationQECam
     
    495494 
    496495    //
    497     // Intensity containers
     496    // MCalibrationChargeCam
    498497    //
    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
    513506  //
    514507  // Blind pixel calibration
     
    550543  // Further initialization
    551544  //
    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  }
    573551
    574552  fResultFlags.Set(fGeom->GetNumAreas());
     
    606584  // Now retrieve the colour and check if not various colours have been used
    607585  //
    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  }
    634609
    635610  //
     
    655630  // Distribute new color to all containers
    656631  //
     632  fCam->SetPulserColor(col);
     633  if (fBlindCam)
     634    fBlindCam->SetPulserColor(col);
     635
    657636  fHCam->SetColor(col);
    658637  if (fHBlindCam)
    659638    fHBlindCam->SetColor(col);
    660 
    661   MCalibrationChargeCam *chargecam = fIntensCam
    662     ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
    663 
    664   chargecam->SetPulserColor(col);
    665 
    666   if (fBlindCam)
    667     fBlindCam->SetPulserColor(col);
    668639  if (fPINDiode)
    669640    fPINDiode->SetColor(col);
     
    724695// Call  FinalizeUnsuitablePixels()
    725696// 
    726 // Call MParContainer::SetReadyToSave() for fIntensCam, fCam, fQECam, fBadPixels and
    727 //                                          fBlindCam and fPINDiode if they exist
     697// Call MParContainer::SetReadyToSave() for fCam, fQECam, fBadPixels and
     698//      fBlindCam and fPINDiode if they exist
    728699//
    729700// Print out some statistics
     
    749720      }
    750721
    751   MCalibrationChargeCam *chargecam = fIntensCam   ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
    752 
    753722  //
    754723  // First loop over pixels, call FinalizePedestals and FinalizeCharges
     
    759728    {
    760729
    761       MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[pixid];
     730      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[pixid];
    762731      //
    763732      // Check if the pixel has been excluded from the fits
     
    786755  if (nvalid == 0)
    787756  {
    788     if (!fIntensCam)
     757      if (!fContinousCalibration)
    789758      {
    790759        *fLog << warn << GetDescriptor() << ": All pixels have non-valid calibration. "
     
    801770
    802771      const MPedestalPix    &ped = fPedestals->GetAverageArea(aidx);
    803       MCalibrationChargePix &pix = (MCalibrationChargePix&)chargecam->GetAverageArea(aidx);
     772      MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
    804773      const MArrayI &arr         = fHCam->GetAverageAreaNum();
    805774
     
    814783      pix.SetSigma (pix.GetSigma()/pix.GetFFactorFADC2Phe());
    815784
    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");
    818787    }
    819788 
     
    825794      const MPedestalPix     &ped = fPedestals->GetAverageSector(sector);
    826795
    827       MCalibrationChargePix &pix = (MCalibrationChargePix&)chargecam->GetAverageSector(sector);
     796      MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(sector);
    828797      FinalizePedestals(ped,pix, 0);
    829798    }
     
    840809  //
    841810  if (FinalizeFFactorMethod())
    842     chargecam->SetFFactorMethodValid(kTRUE);
     811    fCam->SetFFactorMethodValid(kTRUE);
    843812  else
    844813    {
    845814      *fLog << warn << "Could not calculate the photons flux from the F-Factor method " << endl;
    846       chargecam->SetFFactorMethodValid(kFALSE);
    847       if (!fIntensCam)
    848         return kFALSE;
     815      fCam->SetFFactorMethodValid(kFALSE);
     816      if (!fContinousCalibration)
     817          return kFALSE;
    849818    }
    850819
     
    916885                    "Deviating F-Factor:                     ");
    917886
    918   chargecam->SetReadyToSave();
    919   fQECam    ->SetReadyToSave();
     887  fCam->SetReadyToSave();
     888  fQECam->SetReadyToSave();
    920889  fBadPixels->SetReadyToSave();
    921890
     
    11091078  if (!cal.CalcConvFFactor())
    11101079    {
    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;
    11121081      bad.SetUncalibrated(MBadPixelsPix::kDeviatingNumPhes);
    11131082      return kFALSE;
     
    11491118// - MBadPixelsPix::kLoGainOverFlow
    11501119//
    1151 // - Call MCalibrationPix::SetExcluded() for the bad pixels
    1152 //
    11531120// Sets pixel to MBadPixelsPix::kUnreliableRun, if one of the following flags is set:
    11541121// - MBadPixelsPix::kChargeSigmaNotValid
     
    11761143            bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
    11771144        }
    1178      
     1145
    11791146      if (IsCheckDeviatingBehavior())
    11801147        {
     
    11821149            bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
    11831150        }
    1184      
     1151
    11851152      if (IsCheckHistOverflow())
    11861153        {
    11871154          if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOverFlow   ))
    11881155            bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
    1189          
     1156
    11901157          if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOverFlow   ))
    11911158            bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
    11921159        }
    1193      
     1160
    11941161      if (IsCheckArrivalTimes())
    11951162        {
     
    12351202Bool_t MCalibrationChargeCalc::FinalizeFFactorMethod()
    12361203{
    1237   MCalibrationChargeCam *chargecam = fIntensCam
    1238     ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
    1239 
    12401204  const Int_t npixels  = fGeom->GetNumPixels();
    12411205  const Int_t nareas   = fGeom->GetNumAreas();
     
    12601224  for (Int_t i=0; i<npixels; i++)
    12611225    {
    1262       MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i];
     1226      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
    12631227
    12641228      MBadPixelsPix &bad = (*fBadPixels)[i];
     
    13851349    {
    13861350     
    1387       MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i];
     1351      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
    13881352
    13891353      if (!pix.IsFFactorMethodValid())
     
    14401404    {
    14411405
    1442       MCalibrationChargePix &apix = (MCalibrationChargePix&)chargecam->GetAverageArea(aidx);
     1406      MCalibrationChargePix &apix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
    14431407
    14441408      if (numareavalid[aidx] == 1)
     
    14951459        }
    14961460     
    1497       MCalibrationChargePix &spix = (MCalibrationChargePix&)chargecam->GetAverageSector(sector);
     1461      MCalibrationChargePix &spix = (MCalibrationChargePix&)fCam->GetAverageSector(sector);
    14981462
    14991463      if (sectorweights[sector] < 0. || sectorphes[sector] <= 0.)
     
    15241488    {
    15251489     
    1526       MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i];
     1490      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
    15271491
    15281492      MBadPixelsPix &bad = (*fBadPixels)[i];
     
    15341498        {
    15351499          const Int_t            aidx = (*fGeom)[i].GetAidx();
    1536           MCalibrationChargePix &apix = (MCalibrationChargePix&)chargecam->GetAverageArea(aidx);
     1500          MCalibrationChargePix &apix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
    15371501
    15381502          pix.SetPheFFactorMethod   ( apix.GetPheFFactorMethod()    );
     
    17261690    }
    17271691 
    1728   MCalibrationChargeCam *chargecam = fIntensCam
    1729     ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
    1730 
    1731   MCalibrationChargePix &avpix = (MCalibrationChargePix&)chargecam->GetAverageArea(0);
     1692  MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCam->GetAverageArea(0);
    17321693  MCalibrationQEPix     &qepix = (MCalibrationQEPix&)    fQECam->GetAverageArea(0);
    17331694
     
    17571718  // Set the results in the MCalibrationChargeCam
    17581719  //
    1759   chargecam->SetNumPhotonsFFactorMethod (avphotons);
     1720  fCam->SetNumPhotonsFFactorMethod (avphotons);
    17601721
    17611722  if (avphotrelvar > 0.)
    1762     chargecam->SetNumPhotonsFFactorMethodErr(TMath::Sqrt( avphotrelvar * avphotons * avphotons)); 
     1723    fCam->SetNumPhotonsFFactorMethodErr(TMath::Sqrt( avphotrelvar * avphotons * avphotons));
    17631724
    17641725  TArrayF lowlim           (nareas);
     
    17751736    {
    17761737     
    1777       MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*chargecam)[i];
    1778       MCalibrationQEPix     &qpix  = (MCalibrationQEPix&)    (*fQECam)   [i];
     1738      MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*fCam)[i];
     1739      MCalibrationQEPix     &qpix  = (MCalibrationQEPix&)    (*fQECam)[i];
    17791740
    17801741      MBadPixelsPix &bad = (*fBadPixels)[i];
     
    18951856    {
    18961857     
    1897       MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*chargecam)[i];
    1898 
     1858      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
    18991859      MBadPixelsPix &bad = (*fBadPixels)[i];
    19001860
     
    19201880    {
    19211881     
    1922       MCalibrationChargePix &pix  = (MCalibrationChargePix&)(*chargecam)[i];
    1923       MCalibrationQEPix     &qpix = (MCalibrationQEPix&)    (*fQECam)   [i];
     1882      MCalibrationChargePix &pix  = (MCalibrationChargePix&)(*fCam)[i];
     1883      MCalibrationQEPix     &qpix = (MCalibrationQEPix&)(*fQECam)[i];
    19241884
    19251885      if ((*fBadPixels)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
     
    19571917    return;
    19581918
    1959   MCalibrationChargeCam *chargecam = fIntensCam
    1960     ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
    1961 
    1962 
    19631919  //
    19641920  // Set the results in the MCalibrationChargeCam
     
    19691925      const Float_t photons = fBlindCam->GetFluxInsidePlexiglass() * (*fGeom)[0].GetA()
    19701926                           / fQECam->GetPlexiglassQE();
    1971       chargecam->SetNumPhotonsBlindPixelMethod(photons);
     1927      fCam->SetNumPhotonsBlindPixelMethod(photons);
    19721928         
    19731929      const Float_t photrelvar = fBlindCam->GetFluxInsidePlexiglassRelVar()
     
    19751931 
    19761932      if (photrelvar > 0.)
    1977         chargecam->SetNumPhotonsBlindPixelMethodErr(TMath::Sqrt( photrelvar * photons * photons)); 
     1933        fCam->SetNumPhotonsBlindPixelMethodErr(TMath::Sqrt( photrelvar * photons * photons));
    19781934    }
    19791935 
     
    20021958        }
    20031959     
    2004       MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*chargecam)[i];
    2005       MGeomPix              &geo   =                         (*fGeom)    [i];
     1960      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
     1961      MGeomPix &geo = (*fGeom)[i];
    20061962
    20071963      const Float_t qe        = pix.GetPheFFactorMethod()
     
    20462002  const UInt_t npixels  = fGeom->GetNumPixels();
    20472003
    2048   MCalibrationChargeCam *chargecam = fIntensCam
    2049     ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
    2050 
    20512004  if (!fPINDiode)
    20522005    return;
     
    20802033          continue;
    20812034        }
    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()
    20872040                               / fPINDiode->GetFluxOutsidePlexiglass()
    20882041                               / geo.GetA();
     
    21292082//
    21302083// - Print out statistics about BadPixels of type UnsuitableType_t
    2131 // - store numbers of bad pixels of each type in fCam or fIntensCam
     2084// - store numbers of bad pixels of each type in fCam
    21322085//
    21332086Bool_t MCalibrationChargeCalc::FinalizeUnsuitablePixels()
     
    21432096  TArrayI unsuit(nareas);
    21442097  TArrayI unrel(nareas);
    2145 
    2146   MCalibrationChargeCam *chargecam = fIntensCam ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam;
    21472098
    21482099  Int_t unsuitcnt=0;
     
    21592110      unrelcnt    += unrel[aidx];
    21602111
    2161       chargecam->SetNumUnsuitable(unsuit[aidx], aidx);
    2162       chargecam->SetNumUnreliable(unrel[aidx],  aidx);
     2112      fCam->SetNumUnsuitable(unsuit[aidx], aidx);
     2113      fCam->SetNumUnreliable(unrel[aidx],  aidx);
    21632114  }
    21642115
    21652116  TArrayI counts(nareas);
    2166   for (Int_t i=0; i<chargecam->GetSize(); i++)
     2117  for (Int_t i=0; i<fCam->GetSize(); i++)
    21672118  {
    2168       MCalibrationPix &pix = (*chargecam)[i];
     2119      const MCalibrationPix &pix = (*fCam)[i];
    21692120      if (pix.IsHiGainSaturation())
    21702121      {
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h

    r8425 r8452  
    2323class MCalibrationChargePINDiode;
    2424class MHCalibrationChargeBlindCam;
    25 class MCalibrationIntensityBlindCam;
    2625class MCalibrationBlindCam;
    2726class MCalibrationChargePix;
    28 class MCalibrationIntensityChargeCam;
    2927class MCalibrationChargeCam;
    3028class MHCalibrationChargeCam;
     
    8179
    8280  Int_t   fNumProcessed;                       // Number of processed events (for Intensity calibration)
    83  
     81
     82  Bool_t fContinousCalibration;
     83
    8484  // Pointers
    8585//  MBadPixelsIntensityCam         *fIntensBad;      //!  Bad Pixels
    8686  MBadPixelsCam                  *fBadPixels;      //!  Bad Pixels
    87   MCalibrationIntensityChargeCam *fIntensCam;      //!  Intensity Calibration results of all pixels   
    8887  MCalibrationChargeCam          *fCam;            //!  Calibrated Charges results of all pixels
    8988  MHCalibrationChargeCam         *fHCam;           //!  Charges histograms of all pixels   
    90   MCalibrationIntensityBlindCam  *fIntensBlind;    //!  Intensity Calibration results of the Blind Pixels
    9189  MCalibrationBlindCam           *fBlindCam;       //!  Calibrated Charges of the Blind Pixels
    9290  MHCalibrationChargeBlindCam    *fHBlindCam;      //!  Charges histograms of the Blind Pixels 
     
    198196  void SetUseExternalNumPhes(const Bool_t b=kTRUE)     { b ? SETBIT(fFlags, kUseExternalNumPhes)         : CLRBIT(fFlags, kUseExternalNumPhes); }
    199197
     198  void SetContinousCalibration(const Bool_t b=kTRUE)   { fContinousCalibration = b; }
     199
    200200  // pointers
    201201  void SetPedestals(MPedestalCam *cam) { fPedestals=cam; }
     
    217217  void SetPheErrUpperLimit     ( const Float_t f=fgPheErrUpperLimit       ) { fPheErrUpperLimit  = f;    }   
    218218  void SetPulserColor          ( const MCalibrationCam::PulserColor_t col ) { fPulserColor       = col;  }
    219  
    220   ClassDef(MCalibrationChargeCalc, 5)   // Task calculating Calibration Containers and Quantum Efficiencies
     219
     220  ClassDef(MCalibrationChargeCalc, 6)   // Task calculating Calibration Containers and Quantum Efficiencies
    221221};
    222222
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc

    r8106 r8452  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCam.cc,v 1.69 2006-10-17 17:18:40 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCam.cc,v 1.70 2007-04-27 10:04:46 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    216216void MCalibrationChargeCam::Clear(Option_t *o)
    217217{
    218 
     218  // DO NOT RESET THE HI-/LO-GAIN CONSTANTS
    219219  SetFFactorMethodValid    ( kFALSE );
    220220
    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.;
    227227
    228228  MCalibrationCam::Clear();
    229 
    230   return;
    231229}
    232230
  • trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc

    r8428 r8452  
    6464#include "MLogManip.h"
    6565
     66#include "MMath.h"
     67
    6668#include "MParList.h"
    6769
     
    8183using namespace std;
    8284
    83 const Float_t MCalibrationRelTimeCalc::fgRelTimeResolutionLimit = 0.05;
     85const Float_t MCalibrationRelTimeCalc::fgRelTimeResolutionLimit = 5.0;
    8486
    8587// --------------------------------------------------------------------------
    8688//
    87 // Default constructor. 
     89// Default constructor.
    8890//
    8991// Sets all pointers to NULL
     
    98100    : fGeom(NULL), fFlags(0)
    99101{
    100        
     102
    101103  fName  = name  ? name  : "MCalibrationRelTimeCalc";
    102104  fTitle = title ? title : "Task to finalize the relative time calibration";
    103105
    104106  SetCheckFitResults       ( kFALSE );
    105   SetCheckDeviatingBehavior( kFALSE );
     107  SetCheckDeviatingBehavior( kTRUE );
    106108  SetCheckHistOverflow     ( kFALSE );
    107109  SetCheckOscillations     ( kFALSE );
     
    164166  }
    165167
    166   const UInt_t npixels = fGeom->GetNumPixels();
    167   for (UInt_t i=0; i<npixels; i++)
     168  if (IsDebug())
    168169  {
    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();
    179173  }
    180174
     
    233227
    234228  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:"));
    236230  PrintUncalibrated(MBadPixelsPix::kRelTimeOscillating,   
    237231                    "Pixels with changing Rel. Times over time:");
     
    245239// ----------------------------------------------------------------------------------------------------
    246240//
    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//
    256244void MCalibrationRelTimeCalc::FinalizeRelTimes()
    257245{
    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++)
    323256        {
    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();
    326273        }
    327274
    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++)
    357286        {
    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            }
    363320        }
    364321    }
     
    373330// - MBadPixelsPix::kRelTimeRelErrNotValid
    374331//
    375 // - Call MCalibrationPix::SetExcluded() for the bad pixels
    376 //
    377332void MCalibrationRelTimeCalc::FinalizeBadPixels()
    378333{
     
    380335  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
    381336    {
    382 
    383337      MBadPixelsPix &bad = (*fBadPixels)[i];
    384338
    385339      if (IsCheckDeviatingBehavior())
    386340          if (bad.IsUncalibrated(MBadPixelsPix::kDeviatingTimeResolution))
    387               bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
     341              bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
    388342
    389343      if (IsCheckFitResults())
     
    394348          if (bad.IsUncalibrated(MBadPixelsPix::kRelTimeOscillating))
    395349              bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
    396 
    397       if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
    398       {
    399           MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i];
    400           pix.SetExcluded();
    401       }
    402350    }
    403351
     
    460408void MCalibrationRelTimeCalc::PrintUncalibrated(const char *text, Int_t in, Int_t out) const
    461409{
    462     *fLog << " " << setfill(' ') << setw(56) << setiosflags(ios::left) << text;
     410    *fLog << " " << setfill(' ') << setw(48) << setiosflags(ios::left) << text;
    463411    *fLog << " Inner: " << Form("%3i", in);
    464412    *fLog << " Outer: " << Form("%3i", out);
  • trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.cc

    r5047 r8452  
    131131  *fLog << all << GetDescriptor() << ":" << endl;
    132132  int id = 0;
    133  
     133
    134134  *fLog << all << "Calibrated pixels:" << endl;
    135135  *fLog << all << endl;
     
    138138  MCalibrationRelTimePix *pix;
    139139  while ((pix=(MCalibrationRelTimePix*)Next()))
    140     {
    141      
    142       if (!pix->IsExcluded())
    143         {                           
    144 
    145           *fLog << all
    146                 << 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                 << endl;
     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;
    150150          id++;
    151         }
    152     }
    153  
     151      }
     152  }
     153
    154154  *fLog << all << id << " pixels" << endl;
    155155  id = 0;
    156  
    157    
     156
     157
    158158  *fLog << all << endl;
    159159  *fLog << all << "Excluded pixels:" << endl;
    160160  *fLog << all << endl;
    161  
     161
    162162  id = 0;
    163163
     
    177177  while ((pix=(MCalibrationRelTimePix*)Next5()))
    178178  {
    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())
    183185          << endl;
    184186  }
     
    187189  while ((pix=(MCalibrationRelTimePix*)Next5()))
    188190  {
    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())
    193197          << endl;
    194198  }
     
    232236        return kFALSE;
    233237      val = pix.GetMean();
    234       break;
     238      return val!=-1.;
    235239    case 1:
    236240      if (pix.IsExcluded())
     
    257261    }
    258262
    259   return val!=-1.;
    260 
    261 }
    262 
     263  return val>=0;
     264
     265}
     266
  • trunk/MagicSoft/Mars/mcalib/Makefile

    r8429 r8452  
    3939           MCalibrationPatternDecode.cc \
    4040           MCalibrateRelTimes.cc \
    41            MCalibrationIntensityCam.cc \
    42            MCalibrationIntensityChargeCam.cc \
    4341           MCalibrationCam.cc \
    4442           MCalibrationPix.cc  \
Note: See TracChangeset for help on using the changeset viewer.