Changeset 7189


Ignore:
Timestamp:
07/14/05 16:03:32 (19 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r7188 r7189  
    2020
    2121                                                 -*-*- END OF LINE -*-*-
     22 2005/07/14 Thomas Bretz
     23
     24   * mbadpixels/MBadPixelCam.[h,cc]:
     25     - added new function GetNumSuitable
     26
     27   * mcalib/MCalibrationChargeCalc.cc:
     28      simplified FinalizeUnsuitablePixels()
     29
     30
    2231
    2332 2005/07/13 Abelardo Moralejo (2005/07/12)
     
    6473       also absolute calibration (=SIZE in phes) is made.
    6574
     75  * mcalib/MCalibrateData.cc
     76    - In PreProcess, changed initialization of fRenormFactor. Formerly
     77      it was fixed to MCalibrationQEPix::gkDefaultAverageQE. Now we check
     78      first if there is a valid average QE for inner pixels in
     79      MCalibrationQECam, and if so, we inititalize fRenormFactor with it.
     80      Else, the default gkDefaultAverageQE is taken. fRenormFactor is
     81      used to convert back from photons to "equivalent inner pixel phes"
     82      in the (now default) case of calibrating in phes.
     83
    6684
    6785
     
    287305     - check for existence of pointer fRawEvt in PostProcess.
    288306
     307   * mcalib/MCalibrationChargeCalc.[h,cc]
     308     - implement possibility to set reference number of photo-electrons from
     309       outside (stored in fExternalNumPhes).
     310
     311   * mcalib/MCalibrateData.[h,cc], mcalib/MCalibCalcFromPast.cc,
     312     mjobs/MJCalibrateSignal.cc:
     313     - write calibration constants now in separate
     314       MCalibrationIntensityConstCam. This is necessary since with the
     315       introduction of the averageing of mean photo-electrons, the
     316       MCalibrationIntensityChargeCam does not hold the correct conv.
     317       factors any more.
     318
     319   * mcalib/MCalibrateData.[h,cc]
     320     - get also pointers to the IntensityCams and use them if exist
     321       (previously, only the first calibration cam was used together
     322       with the updatecam.)
     323
     324
     325
     326 2005/07/13 Markus Gaug (2005/06/17)
     327
     328   * mcalib/MCalibrationIntensityCam.[h,cc]
     329     - take out some un-used or commented code (variables fOffsets and
     330       fSlopes). These data members were not in the streamter either.
     331     - put some of the most-used code from the .cc file into the .h file
     332     - add new function: SetCam().
     333
    289334
    290335
     
    305350     - In CalibrateData, the sigma is used for the statistical error of the
    306351       converted signal to equiv. high-gain charges.
     352
     353   * mcalib/MCalibCalcFromPast.[h,cc]
     354     - implement the mean photo-electron averageing for a desired number of
     355       calibration updates.
     356
     357   * mcalib/MCalibrateData.cc
     358     - use MCalibrationChargePix::GetConversionHiLoSigma() to calculate the
     359       error (was previously MCalibrationChargePix::GetConversionHiLoErr().
     360
     361  * callisto.cc
     362    - calculate first fixed window pedestal in MJPedestalY2,
     363      then sliding window pedestal in MJPedestalY3 (order reversed).
     364
    307365
    308366
     
    347405      now, depending on the study, one wants to make.
    348406
     407  * mcalib/MCalibrationChargeCalc.[h,cc]
     408    - set a limit to the number of un-suitable and un-reliables pixels
     409      for the run to succeed: 0.1 unsuitables and 0.3 un-reliables
     410    - set UseExtractorRes to kTRUE, will raise the number of
     411      photo-electrons for the spline extractor by 1-2% (correctly).
     412    - re-normalize the pedestal RMS of the event-by-event averaged
     413      area events to the sqrt of the number of used pixels.
     414    - re-normalize the sigma of the event-by-event averaged area events
     415      by 1/F-Factor.
     416    - introduce switch to choose if un-reliables should be used for the
     417      calculation of mean number of phes (default: kTRUE).
     418    - print out the number of high-gain saturated pixels.
     419
     420
     421
     422 2005/07/13 Markus Gaug (2005/06/10)
     423
     424  * mjobs/MJCalibrateSignal.[h,cc]
     425    - skip also the PIN Diode events from the data calibration.
     426
    349427
    350428
     
    357435     - introduce flags to steer the setting of unreliability like done
    358436       in MCalibrationChargeCalc. Can be steered from the conf-file.
     437
     438   * mbadpixels/MBadPixelsIntensityCam.[h,cc]
     439     - implement two Get and Draw-functions to display bad pixels over
     440       time like in the mcalib/MCalibrationIntensityChargeCam
     441
     442
     443
     444 2005/07/13 Markus Gaug (2005/06/03)
     445
     446   * mhcalib/MHCalibrationPulseTimeCam.cc
     447     -  fill arrays only if IsOscillations() was asked. This is a speed
     448        bug and could cause important memory leaks. It does not affect the
     449        outcome of an analysis, however.
    359450
    360451
  • trunk/MagicSoft/Mars/NEWS

    r7188 r7189  
    7676     a good precision is needed.
    7777
     78   - callisto: Set UseExtractorRes to kTRUE, will raise the number of
     79     photo-electrons for the spline extractor by 1-2% (correctly).
     80
    7881   - star: fixed a bug which caused MEffectiveOnTime containers not to
    7982     be written. In the worst case they were skipped almost all, in the
     
    9699
    97100   - ganymed: optimized palettes for MHDisp
     101
     102   - ganymed: Fixed an important bug when using ThetaSq as fit function:
     103     The result for the sigma of the gauss(sqrt(x)) fit was a factor
     104     sqrt(2) to large
    98105
    99106   - sponde: the zenith angle distribution is now weighted instead of
  • trunk/MagicSoft/Mars/callisto.cc

    r7179 r7189  
    358358        job1.SetExtractionFundamental();
    359359        // job1.SetPathOut(kOutpathC); // not yet needed
    360         // job1.SetPathIn(kInpathC);   // not yet needed
     360        // job1.SetPathIn(kInpathC);   // DO NOT CALL IT. IT WOULD READ THE XEXTRACTOR FROM calib-file
    361361
    362362        if (!job1.Process())
     
    387387        job2.SetDeadPixelCheck();
    388388        // job1.SetPathOut(kOutpathC); // not yet needed
    389         // job1.SetPathIn(kInpathC);   // not yet needed
     389        // job1.SetPathIn(kInpathC);   // DO NOT CALL IT. IT WOULD READ THE XEXTRACTOR FROM calib-file
    390390
    391391        //job2.SetExtractorResolution();
     
    488488        job1.SetOverwrite(kOverwrite);
    489489        job1.SetPathData(kInpathD);
    490         job1.SetPathIn(kInpathY);
     490        job1.SetPathIn(kInpathY);   // --> READ Extractor from calib-file
    491491        job1.SetDataType(kDataType);
    492492        //job1.SetPathOut(kOutpathY);   // not yet needed
     
    525525
    526526        job2.SetUseData();
    527         job2.SetExtractionWithExtractor();
     527        job2.SetExtractionWithExtractorRndm();
    528528        job2.SetExtractor(job1.GetExtractor());
    529529        job2.SetPedestals(job1.GetPedestalCam());
     
    563563
    564564        job3.SetUseData();
    565         job3.SetExtractionWithExtractorRndm();
    566         job3.SetExtractor(job1.GetExtractor());
     565        job3.SetExtractionWithExtractor();
     566        job3.SetExtractor(job2.GetExtractor());
    567567        job3.SetPedestals(job1.GetPedestalCam());
    568568        job3.SetBadPixels(job1.GetBadPixels());
  • trunk/MagicSoft/Mars/callisto.rc

    r7188 r7189  
    376376
    377377# -------------------------------------------------------------------------
    378 # use the entire results obtained with the F-Factor method (including a
    379 # new number of mean photo-electrons)
     378# Configure the interlaced calibration updates
    380379# -------------------------------------------------------------------------
    381380#MJCalibrateSignal.MCalibCalcFromPast.UpdateWithFFactorMethod: yes
     381#MJCalibrateSignal.MCalibCalcFromPast.NumEventsDump: 500
     382#MJCalibrateSignal.MCalibCalcFromPast.UpdateNumPhes: yes
     383#MJCalibrateSignal.MCalibCalcFromPast.NumPhesDump: 10
     384#MJCalibrateSignal.MCalibrationChargeCalc.Debug: no
    382385
    383386# -------------------------------------------------------------------------
     
    431434#MJCalibrateSignal.MHCalibrationChargeCam.HiGainLast:   1899.5
    432435MJCalibrateSignal.MHCalibrationChargeCam.LoGainNbins:   250
    433 #MJCalibrateSignal.MHCalibrationChargeCam.LoGainFirst:  -99.
    434 #MJCalibrateSignal.MHCalibrationChargeCam.LoGainLast:   901.
     436MJCalibrateSignal.MHCalibrationChargeCam.LoGainFirst:   -98
     437MJCalibrateSignal.MHCalibrationChargeCam.LoGainLast:    902
    435438#MJCalibrateSignal.MHCalibrationChargeCam.TimeLowerLimit: 1.
    436439#MJCalibrateSignal.MHCalibrationChargeCam.TimeUpperLimit: 3.
  • trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc

    r7127 r7189  
    8888#MJPedestalC1.ExtractSignal.Resolution:        0.05
    8989#MJPedestalC1.ExtractSignal.RiseTimeHiGain:    0.5
    90 MJPedestalC1.ExtractSignal.FallTimeHiGain:     0.5
     90#MJPedestalC1.ExtractSignal.FallTimeHiGain:     0.5
    9191#MJPedestalC1.ExtractSignal.LoGainStretch:     1.5
    9292#MJPedestalC1.ExtractSignal.ExtractionType: Integral <default>
     
    339339#MJPedestalY2.PulsePosCheck: yes
    340340MJPedestalY2.ExtractWinLeft:  3.0
    341 MJPedestalY2.ExtractWinRight: 2.0
     341MJPedestalY2.ExtractWinRight: 2.5
    342342#MJCalibrateSignal.ModifiedExtractWin: yes
    343343# -------------------------------------------------------------------------
     
    389389
    390390# -------------------------------------------------------------------------
    391 # Use this if you want to change to time from run headers instead of event time
    392 # -------------------------------------------------------------------------
    393 #MJCalibrateSignal.MPointingPosInterpolate.TimeMode: eventtime, runtime
     391# Configure the interlaced calibration updates
     392# -------------------------------------------------------------------------
     393#MJCalibrateSignal.MCalibCalcFromPast.UpdateWithFFactorMethod: yes
     394#MJCalibrateSignal.MCalibCalcFromPast.NumEventsDump: 500
     395#MJCalibrateSignal.MCalibCalcFromPast.UpdateNumPhes: yes
     396#MJCalibrateSignal.MCalibCalcFromPast.NumPhesDump: 10
     397#MJCalibrateSignal.MCalibrationChargeCalc.Debug: no
    394398
    395399# -------------------------------------------------------------------------
     
    440444#MJCalibrateSignal.MHCalibrationChargeCam.HiGainLast:   1899.5
    441445MJCalibrateSignal.MHCalibrationChargeCam.LoGainNbins:   250
    442 #MJCalibrateSignal.MHCalibrationChargeCam.LoGainFirst:  -100.5
    443 #MJCalibrateSignal.MHCalibrationChargeCam.LoGainLast:   899.5
     446MJCalibrateSignal.MHCalibrationChargeCam.LoGainFirst:   -98
     447MJCalibrateSignal.MHCalibrationChargeCam.LoGainLast:    902
    444448#MJCalibrateSignal.MHCalibrationChargeCam.TimeLowerLimit: 1.
    445449#MJCalibrateSignal.MHCalibrationChargeCam.TimeUpperLimit: 3.
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc

    r7095 r7189  
    180180// --------------------------------------------------------------------------
    181181//
    182 // Calculate the number of pixels with the given type-flags.
     182// Calculate the number of pixels without the given type-flags.
    183183//
    184184// The second argument aidx is the area index (see MGeomCam, MGeomPix)
     
    187187// Returns -1 if the geometry doesn't match.
    188188//
    189 Short_t MBadPixelsCam::GetNumUnsuitable(MBadPixelsPix::UnsuitableType_t type, const MGeomCam *geom, Int_t aidx) const
     189Short_t MBadPixelsCam::GetNumSuitable(MBadPixelsPix::UnsuitableType_t type, const MGeomCam *geom, Int_t aidx) const
    190190{
    191191    const UInt_t n = GetSize();
    192192
    193     if (aidx>=0 && geom->GetNumPixels()!=n)
     193    if (aidx>=0 && (!geom || geom->GetNumPixels()!=n))
    194194    {
    195195        *fLog << err << GetDescriptor() << "ERROR - Geometry (" << geom->ClassName() << ") size mismatch!" << endl;
     
    200200    for (UInt_t i=0; i<n; i++)
    201201    {
    202         if (aidx>=0 && (*geom)[i].GetAidx()!=aidx)
     202        if (aidx>=0 && geom && (*geom)[i].GetAidx()!=aidx)
     203            continue;
     204
     205        if (!(*this)[i].IsUnsuitable(type))
     206            rc++;
     207    }
     208    return rc;
     209}
     210
     211// --------------------------------------------------------------------------
     212//
     213// Calculate the number of pixels with the given type-flags.
     214//
     215// The second argument aidx is the area index (see MGeomCam, MGeomPix)
     216// The default (or any value less than 0) means: all
     217//
     218// Returns -1 if the geometry doesn't match.
     219//
     220Short_t MBadPixelsCam::GetNumUnsuitable(MBadPixelsPix::UnsuitableType_t type, const MGeomCam *geom, Int_t aidx) const
     221{
     222    const UInt_t n = GetSize();
     223
     224    if (aidx>=0 && geom && geom->GetNumPixels()!=n)
     225    {
     226        *fLog << err << GetDescriptor() << "ERROR - Geometry (" << geom->ClassName() << ") size mismatch!" << endl;
     227        return -1;
     228    }
     229
     230    Short_t rc = 0;
     231    for (UInt_t i=0; i<n; i++)
     232    {
     233        if (aidx>=0 && geom && (*geom)[i].GetAidx()!=aidx)
    203234            continue;
    204235
     
    334365void MBadPixelsCam::Print(Option_t *o) const
    335366{
    336 
    337367  *fLog << all << GetDescriptor() << ":" << endl;
    338368  *fLog << "Pixels without problems:" << endl;
     
    477507void MBadPixelsCam::PrintBadPixels( MBadPixelsPix::UncalibratedType_t typ, const char *text) const
    478508{
    479 
    480 
    481509  *fLog << "Pixels with " << text << ": " << endl;
    482510  UInt_t count = 0;
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.h

    r5463 r7189  
    4242    Short_t GetNumUnsuitable(MBadPixelsPix::UnsuitableType_t type, const MGeomCam *geom, Int_t aidx=-1) const;
    4343    Short_t GetNumUnsuitable(MBadPixelsPix::UnsuitableType_t type) const { return GetNumUnsuitable(type, 0); }
     44    Short_t GetNumSuitable(MBadPixelsPix::UnsuitableType_t type, const MGeomCam *geom, Int_t aidx=-1) const;
     45    Short_t GetNumSuitable(MBadPixelsPix::UnsuitableType_t type) const { return GetNumSuitable(type, 0); }
    4446    Short_t GetNumIsolated(MBadPixelsPix::UnsuitableType_t type, const MGeomCam &geom, Int_t aidx=-1) const;
    4547    Short_t GetNumIsolated(const MGeomCam &geom, Int_t aidx=-1) const { return GetNumIsolated(MBadPixelsPix::kUnsuitableRun, geom, aidx); }
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.cc

    r5052 r7189  
    4444
    4545#include <TOrdCollection.h>
    46 
    47 #include "MGeomCam.h"
     46#include <TGraph.h>
     47
     48#include "MGeomPix.h"
     49#include "MHCamera.h"
     50#include "MLogManip.h"
    4851
    4952ClassImp(MBadPixelsIntensityCam);
     
    268271}
    269272
     273
     274// -------------------------------------------------------------------
     275//
     276// Returns a TGraph with the number of uncalibrated type pixels per area index
     277// vs. the calibration camera.
     278//
     279TGraph *MBadPixelsIntensityCam::GetUncalibratedPerAreaVsTime(const MBadPixelsPix::UncalibratedType_t typ,
     280                                                             const Int_t aidx, const MGeomCam &geom)
     281{
     282 
     283  const Int_t size = GetSize();
     284 
     285  if (size == 0)
     286    return NULL;
     287 
     288  TArrayF uncal(size);
     289  TArrayF time(size);
     290 
     291  for (Int_t i=0;i<GetSize();i++)
     292    {
     293      //
     294      // Get the calibration cam from the intensity cam
     295      //
     296      MBadPixelsCam *cam = GetCam(i);
     297
     298      //
     299      // Get the calibration pix from the calibration cam
     300      //
     301      for (Int_t j=0; j<cam->GetSize(); j++)
     302        {
     303
     304          if (geom[j].GetAidx() != aidx && aidx > -1)
     305            continue;
     306
     307          const MBadPixelsPix &pix = (*cam)[j];
     308          //
     309          // Don't use bad pixels
     310          //
     311          if (pix.IsUncalibrated(typ))
     312            uncal[i]++;
     313        }
     314      time[i] = i;
     315    }
     316 
     317  TGraph *gr = new TGraph(size,time.GetArray(),uncal.GetArray());
     318 
     319  gr->SetTitle(Form("Uncalibrated Pixels Area %d",aidx));
     320  gr->GetXaxis()->SetTitle("Camera Nr.");
     321  gr->GetYaxis()->SetTitle("<N_{uncal}> [1]");     
     322  return gr;
     323}
     324
     325TGraph *MBadPixelsIntensityCam::GetUnsuitablePerAreaVsTime(const MBadPixelsPix::UnsuitableType_t typ, const Int_t aidx, const MGeomCam &geom)
     326{
     327  const Int_t size = GetSize();
     328 
     329  if (size == 0)
     330    return NULL;
     331 
     332  TArrayF unsuit(size);
     333  TArrayF time(size);
     334 
     335  for (Int_t i=0;i<GetSize();i++)
     336    {
     337      //
     338      // Get the calibration cam from the intensity cam
     339      //
     340      MBadPixelsCam *cam = GetCam(i);
     341
     342      //
     343      // Get the calibration pix from the calibration cam
     344      //
     345      for (Int_t j=0; j<cam->GetSize(); j++)
     346        {
     347          if (geom[j].GetAidx() != aidx && aidx > -1)
     348            continue;
     349
     350          const MBadPixelsPix &pix = (*cam)[j];
     351          //
     352          // Don't use bad pixels
     353          //
     354          if (pix.IsUnsuitable(typ))
     355            unsuit[i]++;
     356        }
     357      time[i] = i;
     358    }
     359 
     360  TGraph *gr = new TGraph(size,time.GetArray(),unsuit.GetArray());
     361 
     362  gr->SetTitle(Form("Unsuitable Pixels Area %d",aidx));
     363  gr->GetXaxis()->SetTitle("Camera Nr.");
     364  gr->GetYaxis()->SetTitle("<N_{unsuit}> [1]");     
     365  return gr;
     366}
     367
     368MHCamera *MBadPixelsIntensityCam::GetUnsuitableSpectrum(const MBadPixelsPix::UnsuitableType_t typ, const MGeomCam &geom)
     369{
     370  const Int_t size = GetSize();
     371 
     372  if (size == 0)
     373    return NULL;
     374 
     375  TString title;
     376  TString axist;
     377 
     378  switch (typ)
     379    {
     380    case MBadPixelsPix::kUnsuitableRun:
     381      title = "Unsuitable Pixels";
     382      break;
     383    case MBadPixelsPix::kUnreliableRun:
     384      title = "Unreliable Pixels";
     385      break;
     386    default:
     387      *fLog << warn << "Could not determine unsuitable type ... abort " << endl;
     388      return NULL;
     389    }
     390 
     391  MHCamera *camunsuit = new MHCamera(geom,"Unsuitables",title.Data());
     392
     393  for (Int_t i=0;i<GetSize();i++)
     394    {
     395      //
     396      // Get the calibration cam from the intensity cam
     397      //
     398      MBadPixelsCam *cam = GetCam(i);
     399
     400      //
     401      // Get the calibration pix from the calibration cam
     402      //
     403      for (Int_t j=0; j<cam->GetSize(); j++)
     404        {
     405          const MBadPixelsPix &pix = (*cam)[j];
     406          //
     407          // Don't use bad pixels
     408          //
     409          if (pix.IsUnsuitable(typ))
     410            {
     411              camunsuit->Fill(j,1);
     412              camunsuit->SetUsed(j);
     413            }
     414        }
     415    }
     416 
     417  return camunsuit;
     418}
     419
     420MHCamera *MBadPixelsIntensityCam::GetUncalibratedSpectrum(const MBadPixelsPix::UncalibratedType_t typ, const MGeomCam &geom)
     421{
     422
     423  const Int_t size = GetSize();
     424 
     425  if (size == 0)
     426    return NULL;
     427 
     428  TString title;
     429  TString axist;
     430 
     431  switch (typ)
     432    {
     433      case MBadPixelsPix::kPreviouslyExcluded:
     434        title = "PreviouslyExcluded";
     435        break;
     436      case MBadPixelsPix::kHiGainNotFitted:
     437        title = "HiGainNotFitted";
     438        break;
     439      case MBadPixelsPix::kLoGainNotFitted:
     440        title = "LoGainNotFitted";
     441        break;
     442      case MBadPixelsPix::kRelTimeNotFitted:
     443        title = "RelTimeNotFitted";
     444        break;
     445      case MBadPixelsPix::kHiGainOscillating:
     446        title = "HiGainOscillating";
     447        break;
     448      case MBadPixelsPix::kLoGainOscillating:
     449        title = "LoGainOscillating";
     450        break;
     451      case MBadPixelsPix::kRelTimeOscillating:
     452        title = "RelTimeOscillating";
     453        break;
     454      case MBadPixelsPix::kLoGainSaturation:
     455        title = "LoGainSaturation";
     456        break;
     457      case MBadPixelsPix::kChargeIsPedestal:
     458        title = "ChargeIsPedestal";
     459        break;
     460      case MBadPixelsPix::kChargeErrNotValid:
     461        title = "ChargeErrNotValid";
     462        break;
     463      case MBadPixelsPix::kChargeRelErrNotValid:
     464        title = "ChargeRelErrNotValid";
     465        break;
     466      case MBadPixelsPix::kChargeSigmaNotValid:
     467        title = "ChargeSigmaNotValid";
     468        break;
     469      case MBadPixelsPix::kMeanTimeInFirstBin:
     470        title = "MeanTimeInFirstBin";
     471        break;
     472      case MBadPixelsPix::kMeanTimeInLast2Bins:
     473        title = "MeanTimeInLast2Bins";
     474        break;
     475      case MBadPixelsPix::kDeviatingNumPhes:
     476        title = "DeviatingNumPhes";
     477        break;
     478      case MBadPixelsPix::kDeviatingNumPhots:
     479        title = "DeviatingNumPhots";
     480        break;
     481      case MBadPixelsPix::kDeviatingFFactor:
     482        title = "DeviatingFFactor";
     483        break;
     484      case MBadPixelsPix::kDeviatingTimeResolution:
     485        title = "DeviatingTimeResolution";
     486        break;
     487      case MBadPixelsPix::kConversionHiLoNotValid:
     488        title = "ConversionHiLoNotValid";
     489        break;
     490      case MBadPixelsPix::kHiGainOverFlow:
     491        title = "HiGainOverFlow";
     492        break;
     493      case MBadPixelsPix::kLoGainOverFlow:
     494        title = "LoGainOverFlow";
     495        break;
     496      case MBadPixelsPix::kHiLoNotFitted:
     497        title = "HiLoNotFitted";
     498        break;
     499      case MBadPixelsPix::kHiLoOscillating:
     500        title = "HiLoOscillating";
     501        break;
     502      case MBadPixelsPix::kDeadPedestalRms:
     503        title = "DeadPedestalRms";
     504        break;
     505      case MBadPixelsPix::kFluctuatingArrivalTimes:
     506        title = "FluctuatingArrivalTimes";
     507        break;
     508    default:
     509      *fLog << warn << "Could not determine uncalibrated type ... abort " << endl;
     510      return NULL;
     511    }
     512 
     513  MHCamera *camuncal = new MHCamera(geom,"Uncalibrated",title.Data());
     514
     515  for (Int_t i=0;i<GetSize();i++)
     516    {
     517      //
     518      // Get the calibration cam from the intensity cam
     519      //
     520      MBadPixelsCam *cam = GetCam(i);
     521
     522      //
     523      // Get the calibration pix from the calibration cam
     524      //
     525      for (Int_t j=0; j<cam->GetSize(); j++)
     526        {
     527          const MBadPixelsPix &pix = (*cam)[j];
     528          //
     529          // Don't use bad pixels
     530          //
     531          if (pix.IsUncalibrated(typ))
     532            {
     533              camuncal->Fill(j,1);
     534              camuncal->SetUsed(j);
     535            }
     536        }
     537    }
     538 
     539  return camuncal;
     540}
     541
     542
     543
     544void MBadPixelsIntensityCam::DrawUnsuitablePerAreaVsTime(const MBadPixelsPix::UnsuitableType_t typ, const Int_t aidx, const MGeomCam &geom)
     545{
     546  TGraph *gr = GetUnsuitablePerAreaVsTime(typ,aidx,geom);
     547  gr->SetBit(kCanDelete);
     548  gr->Draw("A*");
     549}
     550
     551void MBadPixelsIntensityCam::DrawUncalibratedPerAreaVsTime(const MBadPixelsPix::UncalibratedType_t typ, const Int_t aidx, const MGeomCam &geom)
     552{
     553  TGraph *gr = GetUncalibratedPerAreaVsTime(typ,aidx,geom);
     554  gr->SetBit(kCanDelete);
     555  gr->Draw("A*");
     556}
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.h

    r5052 r7189  
    1111#include "MBadPixelsCam.h"
    1212#endif
     13#ifndef MARS_MGeomCamMagic
     14#include "MGeomCamMagic.h"
     15#endif
    1316
    1417class TOrdCollection;
    15 class MGeomCam;
     18class TGraph;
     19class MHCamera;
    1620class MBadPixelsIntensityCam : public MParContainer, public MCamEvent
    1721{
     
    7478  void   DrawPixelContent( Int_t num) const;
    7579
     80  TGraph *GetUncalibratedPerAreaVsTime( const MBadPixelsPix::UncalibratedType_t typ,
     81                                        const Int_t aidx=-1, const MGeomCam &geom=MGeomCamMagic());
     82  TGraph *GetUnsuitablePerAreaVsTime( const MBadPixelsPix::UnsuitableType_t typ,
     83                                      const Int_t aidx=-1, const MGeomCam &geom=MGeomCamMagic());
     84
     85  MHCamera *GetUnsuitableSpectrum( const MBadPixelsPix::UnsuitableType_t typ, const MGeomCam &geom=MGeomCamMagic());
     86
     87  MHCamera *GetUncalibratedSpectrum( const MBadPixelsPix::UncalibratedType_t typ, const MGeomCam &geom=MGeomCamMagic());
     88
     89  void DrawUncalibratedPerAreaVsTime( const MBadPixelsPix::UncalibratedType_t typ,
     90                                        const Int_t aidx=-1, const MGeomCam &geom=MGeomCamMagic()); // *MENU*
     91  void DrawUnsuitablePerAreaVsTime( const MBadPixelsPix::UnsuitableType_t typ,
     92                                      const Int_t aidx=-1, const MGeomCam &geom=MGeomCamMagic()); // *MENU*
     93 
     94
     95
    7696  ClassDef(MBadPixelsIntensityCam, 1) // Base Container Intensity BadPixels Results
    7797};
  • trunk/MagicSoft/Mars/mbadpixels/Makefile

    r4957 r7189  
    2121INCLUDES = -I. -I../mbase -I../manalysis -I../mgeom -I../mgui \
    2222           -I../mmc -I../mpedestal -I../msignal -I../mpointing \
    23            -I../mhbase
     23           -I../mhbase -I../mhist
    2424# MBadPixelsCalc  (manalysis): MPedPhotCam, MSigmabar
    2525# MBadPixelsCalc  (mgeom):     MGeomCam
  • trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc

    r7053 r7189  
    3232//   MCalibrationIntensityChargeCam
    3333//   MCalibrationIntensityRelTimeCam
     34//   MCalibrationIntensityConstCam
    3435//   MBadPixelsIntensityCam
    3536//
     
    3738//   MCalibrationIntensityChargeCam
    3839//   MCalibrationIntensityRelTimeCam
    39 //   MBadPixelsIntensityCam
     40//   MBadPixelsIntensityCam
     41//
     42// Class version 2:
     43//  +  UInt_t  fNumPhesDump;         // Number of cams after which the number of phes gets averaged
     44//  +  Float_t fMeanPhes;
     45//  +  Float_t fMeanPhesRelVar;
     46//  +  Bool_t  fUpdateNumPhes;       // Update the number of photo-electrons only after fNumPhesDump number of Cams
     47//  +  TArrayF fPhes;
     48//  +  TArrayF fPhesVar;
    4049//
    4150//////////////////////////////////////////////////////////////////////////////
     
    5564#include "MCalibrationIntensityQECam.h"
    5665#include "MCalibrationIntensityRelTimeCam.h"
     66#include "MCalibrationIntensityConstCam.h"
    5767
    5868#include "MBadPixelsIntensityCam.h"
    5969
     70#include "MCalibrationChargePix.h"
    6071#include "MCalibrationChargeCalc.h"
    6172#include "MCalibrationRelTimeCalc.h"
     
    6778
    6879const UInt_t MCalibCalcFromPast::fgNumEventsDump = 500;
     80const UInt_t MCalibCalcFromPast::fgNumPhesDump   = 10;
    6981
    7082// --------------------------------------------------------------------------
     
    7486// Sets:
    7587// - fNumEventsDump to fgNumEventsDump
     88// - fNumPhesDump to fgNumPhesDump
    7689//
    7790MCalibCalcFromPast::MCalibCalcFromPast(const char *name, const char *title)
    7891    : fGeom(NULL), fParList(NULL), fRunHeader(NULL),
    79     fIntensCharge(NULL), fIntensBlind(NULL), fIntensQE(NULL),
    80     fIntensRelTime(NULL), fIntensBad(NULL), fChargeCalc(NULL),
    81     fRelTimeCalc(NULL), fCalibrate(NULL), fNumEvents(0), fNumCam(0),
    82     fUpdateWithFFactorMethod(kFALSE)
     92      fIntensCharge(NULL), fIntensBlind(NULL), fIntensRelTime(NULL), fIntensConst(NULL),
     93      fIntensBad(NULL),
     94      fChargeCalc(NULL), fRelTimeCalc(NULL), fCalibrate(NULL),
     95      fNumCam(0), fNumEvents(0), fUpdateWithFFactorMethod(kTRUE), fUpdateNumPhes(kTRUE)
    8396{
    8497
     
    87100
    88101  SetNumEventsDump();
     102  SetNumPhesDump  ();
    89103}
    90104
     
    150164    fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");
    151165    fIntensQE     = (MCalibrationIntensityQECam*)    pList->FindCreateObj("MCalibrationIntensityQECam");
     166    fIntensConst  = (MCalibrationIntensityConstCam*) pList->FindCreateObj("MCalibrationIntensityConstCam");
     167
     168    MCalibrationChargeCam *chargeinit = (MCalibrationChargeCam*)pList->FindObject("MCalibrationChargeCam");
     169    MCalibrationQECam     *qeinit     = (MCalibrationQECam*)    pList->FindObject("MCalibrationQECam");
     170
     171    if (chargeinit)
     172      fIntensCharge->SetCam(chargeinit,0);
     173    else
     174      *fLog << "Could not find initial MCalibrationChargeCam, cannot initialize intensity cam" << endl;
     175
     176    if (qeinit)
     177      fIntensQE->SetCam(qeinit,0);
     178    else
     179      *fLog << "Could not find initial MCalibrationQECam, cannot initialize intensity cam" << endl;
     180
     181    fIntensConst->GetCam()->Init(*fGeom);
    152182
    153183    if (!fChargeCalc)
     
    212242  fNumCam    = 0;
    213243  fNumEvents = 0;
     244  fNumPhes   = 0;
     245
     246  fChargeCalc->SetUseExternalNumPhes(kFALSE);
     247
     248  if (fUpdateNumPhes)
     249    {
     250      fPhes.Set(fNumPhesDump);
     251      fPhesVar.Set(fNumPhesDump);
     252    }
    214253
    215254  return kTRUE;
     
    231270 
    232271  fNumEvents = 0;
     272  ReInitialize();
     273
    233274  //
    234275  // Finalize Possible calibration histogram classes...
     
    246287  *fLog << inf << "Finalize calibration calculations..." << endl;
    247288  if (fChargeCalc)
    248     fChargeCalc->Finalize();
     289    {
     290      fChargeCalc->Finalize();
     291      if (fUpdateNumPhes)
     292        {
     293          MCalibrationChargePix &avpix =(MCalibrationChargePix&)fIntensCharge->GetCam()->GetAverageArea(0);
     294          fPhes   [fNumPhes] = avpix.GetPheFFactorMethod();
     295          fPhesVar[fNumPhes] = avpix.GetPheFFactorMethodVar();
     296
     297          fNumPhes++;
     298
     299          if (fNumPhes == fNumPhesDump)
     300            {
     301              fNumPhes = 0;
     302              if (!UpdateMeanPhes())
     303                {
     304                  *fLog << warn << "Could not update mean number of photo-electrons. "
     305                        << "Skip it until next update" << endl;
     306                  fChargeCalc->SetUseExternalNumPhes(kFALSE);
     307                }
     308              else
     309                {
     310                  *fLog << inf << "New averaged number photo-electrons: " << fMeanPhes << endl;
     311                  fChargeCalc->SetExternalNumPhes      ( fMeanPhes );
     312                  fChargeCalc->SetExternalNumPhesRelVar( fMeanPhesRelVar );
     313                  fChargeCalc->SetUseExternalNumPhes();
     314                }
     315            }
     316        }
     317    }
     318
    249319  if (fRelTimeCalc)
    250320    fRelTimeCalc->Finalize();
     321
    251322  if (fCalibrate)
    252       fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL :
    253                                           (MCalibrationChargeCam*)fIntensCharge->GetCam());
    254 
    255   ReInitialize();
     323    fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL
     324                                        : (MCalibrationChargeCam*)fIntensCharge->GetCam() );
     325
    256326  return kTRUE;
    257327}
     
    289359  fNumCam++;
    290360
    291   *fLog << inf << "MCalibCalcFromPast::ReInitialize #" << fNumCam << " ";
     361  *fLog << inf << "MCalibCalcFromPast::ReInitialize #" << fNumCam << ": ";
    292362
    293363  const Int_t runnumber = fRunHeader->GetRunNumber();
     
    331401}
    332402
     403
     404Bool_t MCalibCalcFromPast::UpdateMeanPhes()
     405{
     406    Float_t sumw = 0.;
     407    Float_t sum  = 0.;
     408
     409    for (Int_t i=0; i<fPhes.GetSize(); i++)
     410    {
     411        const Float_t weight = 1./fPhesVar[i];
     412        sum  += fPhes[i]*weight;
     413        sumw += weight;
     414    }
     415
     416    if (sumw < 0.000001)
     417        return kFALSE;
     418
     419    if (sum < 0.000001)
     420        return kFALSE;
     421
     422    fMeanPhes       = sum/sumw;
     423    fMeanPhesRelVar = sumw/sum/sum;
     424
     425    return kTRUE;
     426}
     427
    333428// --------------------------------------------------------------------------
    334429//
     
    336431//   MCalibCalcFromPast.UpdateWithFFactorMethod: Off, On
    337432//   MCalibCalcFromPast.NumEventsDump: 500
     433//   MCalibCalcFromPast.UpdateNumPhes: yes/no
     434//   MCalibCalcFromPast.NumPhesDump: 10
    338435//
    339436Int_t MCalibCalcFromPast::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     
    352449    }
    353450
     451    if (IsEnvDefined(env, prefix, "UpdateNumPhes", print))
     452    {
     453        TString s = GetEnvValue(env, prefix, "UpdateNumPhes", "");
     454        s.ToLower();
     455        if (s.BeginsWith("no"))
     456            SetUpdateNumPhes(kFALSE);
     457        if (s.BeginsWith("yes"))
     458            SetUpdateNumPhes(kTRUE);
     459        rc = kTRUE;
     460    }
     461
     462    if (IsEnvDefined(env, prefix, "NumPhesDump", print))
     463    {
     464        SetNumPhesDump(GetEnvValue(env, prefix, "NumPhesDump", (Int_t)fNumPhesDump));
     465        rc = kTRUE;
     466    }
     467
     468
     469
    354470    return rc;
    355471}
  • trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.h

    r7005 r7189  
    44#ifndef MARS_MTask
    55#include "MTask.h"
     6#endif
     7
     8#ifndef ROOT_TArrayF
     9#include <TArrayF.h>
    610#endif
    711
     
    1721class MCalibrationIntensityQECam;
    1822class MCalibrationIntensityRelTimeCam;
     23class MCalibrationIntensityConstCam;
    1924class MBadPixelsIntensityCam;
    2025
     
    2227{
    2328private:
    24 
    2529  static const UInt_t fgNumEventsDump;               //! Default for fNumEventsDump
     30  static const UInt_t fgNumPhesDump;                 //! Default for fNumPhesDump
    2631 
    2732  MGeomCam                        *fGeom;            //! Camera Geometry
     
    3237  MCalibrationIntensityQECam      *fIntensQE;        //! Intensity QE     Cam (to be created)
    3338  MCalibrationIntensityRelTimeCam *fIntensRelTime;   //! Intensity Rel. Time Cam (to be created)
     39  MCalibrationIntensityConstCam   *fIntensConst;     //! Intensity Rel. Time Cam (to be created)
    3440  MBadPixelsIntensityCam          *fIntensBad;       //! Intensity Bad Pixels Cam (to be created)
    3541 
     
    3844  MCalibrateData                  *fCalibrate;       //! Data Calibration Task
    3945                                                     
     46  UInt_t fNumCam;              //! Number of currently used Calibration Cam
    4047  UInt_t fNumEventsDump;       // Number of event after which the MCalibrationCams gets updated
    4148  UInt_t fNumEvents;           //! Event counter only for calibration events
    42   UInt_t fNumCam;              //! Number of currently used Calibration Cam
     49  UInt_t fNumPhesDump;         // Number of cams after which the number of phes gets averaged
     50  UInt_t fNumPhes;             //! Event counter for photo-electron updates
     51
     52  Float_t fMeanPhes;
     53  Float_t fMeanPhesRelVar;
    4354
    4455  Bool_t fUpdateWithFFactorMethod; // Update the interlaced calib events with the full F-Factor method
     56  Bool_t fUpdateNumPhes;           // Update the number of photo-electrons only after fNumPhesDump number of Cams
    4557
     58  TArrayF fPhes;
     59  TArrayF fPhesVar;
     60
     61  // MTask
    4662  Int_t  PreProcess(MParList *pList);
    4763  Int_t  Process();
    4864  Int_t  PostProcess(); 
    4965
     66  // MCalibCalcFromPast
    5067  Bool_t ReInitialize();
    5168  Bool_t Finalize(const char* name);
    5269
     70  Bool_t UpdateMeanPhes();
     71
     72  // MParContainer
    5373  Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
    5474
    5575public:
     76  MCalibCalcFromPast(const char *name=NULL, const char *title=NULL);
    5677
    57   MCalibCalcFromPast(const char *name=NULL, const char *title=NULL);
    58   ~MCalibCalcFromPast() {}
    59  
     78  // Getter
    6079  UInt_t GetNumEventsDump() const   {  return fNumEventsDump;   }
    61  
     80
     81  // Setter
    6282  void SetNumEventsDump( const UInt_t i=fgNumEventsDump )   { fNumEventsDump = i; }
     83  void SetNumPhesDump  ( const UInt_t i=fgNumPhesDump   )   { fNumPhesDump   = i; }
    6384 
    6485  void SetCalibrate    ( MCalibrateData          *c )  { fCalibrate   = c; }
    6586  void SetChargeCalc   ( MCalibrationChargeCalc  *c )  { fChargeCalc  = c; }
    6687  void SetRelTimeCalc  ( MCalibrationRelTimeCalc *c )  { fRelTimeCalc = c; }
     88  void SetUpdateNumPhes      ( const Bool_t b=kTRUE )  { fUpdateNumPhes           = b;  }
    6789
    6890  void SetUpdateWithFFactorMethod(const Bool_t b=kTRUE){ fUpdateWithFFactorMethod = b; }
    6991 
    70   ClassDef(MCalibCalcFromPast, 1) // Task to steer the processing of interlace calibration events
     92  ClassDef(MCalibCalcFromPast, 2) // Task to steer the processing of interlace calibration events
    7193};
    7294
  • trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc

    r7122 r7189  
    9292//
    9393// See also: MJCalibration, MJPedestal, MJExtractSignal, MJExtractCalibTest
    94 // 
     94//
    9595//////////////////////////////////////////////////////////////////////////////
    9696#include "MCalibrateData.h"
     
    112112#include "MPedestalPix.h"
    113113
     114#include "MCalibrationIntensityChargeCam.h"
    114115#include "MCalibrationChargeCam.h"
    115116#include "MCalibrationChargePix.h"
    116 
     117 
     118#include "MCalibrationIntensityQECam.h"
    117119#include "MCalibrationQECam.h"
    118120#include "MCalibrationQEPix.h"
    119 
     121 
     122#include "MCalibrationIntensityConstCam.h"
    120123#include "MCalibConstCam.h"
    121124#include "MCalibConstPix.h"
     
    152155//
    153156MCalibrateData::MCalibrateData(CalibrationMode_t calmode,const char *name, const char *title)
    154     : fGeomCam(NULL),   fBadPixels(NULL), fCalibrations(NULL),
    155       fQEs(NULL), fSignals(NULL), fCerPhotEvt(NULL), fCalibConstCam(NULL),
    156       fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.), fScaleFactor(1.)
     157    : fGeomCam(NULL),   fBadPixels(NULL), fCalibrations(NULL), fIntensCalib(NULL),
     158      fQEs(NULL), fIntensQE(NULL), fSignals(NULL), fCerPhotEvt(NULL), fCalibConstCam(NULL),
     159      fIntensConst(NULL), fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.),
     160      fScaleFactor(1.)
    157161{
    158162
     
    226230            return kFALSE;
    227231
    228         fCalibConstCam = (MCalibConstCam*)pList->FindCreateObj(AddSerialNumber("MCalibConstCam"));
    229         if (!fCalibConstCam)
    230             return kFALSE;
     232        fIntensConst = (MCalibrationIntensityConstCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityConstCam"));
     233        if (fIntensConst)
     234            *fLog << inf << "Found MCalibrationIntensityConstCam ... " << endl;
     235        else
     236        {
     237            fCalibConstCam = (MCalibConstCam*)pList->FindCreateObj(AddSerialNumber("MCalibConstCam"));
     238            if (!fCalibConstCam)
     239                return kFALSE;
     240        }
    231241    }
    232242
     
    235245    if (fCalibrationMode>kNone)
    236246    {
     247        fIntensCalib = (MCalibrationIntensityChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityChargeCam"));
     248        if (fIntensCalib)
     249          *fLog << inf << "Found MCalibrationIntensityChargeCam ... " << endl;
     250
    237251        fCalibrations = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
    238252        if (!fCalibrations)
     
    241255            return kFALSE;
    242256        }
     257
     258        fIntensQE = (MCalibrationIntensityQECam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityQECam"));
     259        if (fIntensQE)
     260          *fLog << inf << "Found MCalibrationIntensityQECam ... " << endl;
    243261
    244262        fQEs = (MCalibrationQECam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
     
    290308      {
    291309      case kPhe:
    292         fRenormFactor = MCalibrationQEPix::gkDefaultAverageQE;
    293         break;
     310          //
     311          // Average QE for C-photons, for pixels in the inner pixel region ("area 0"),
     312          // used later to convert from C-photons into "equivalent phes":
     313          //
     314          if (fQEs->GetAverageAreas() > 0)
     315          {
     316              MCalibrationQEPix& avqepix = (MCalibrationQEPix&)(fQEs->GetAverageArea(0));
     317              fRenormFactor = avqepix.GetAverageQE();
     318          }
     319          else // Average areas not yet initialized, use default value
     320              fRenormFactor = MCalibrationQEPix::gkDefaultAverageQE;
     321
     322          fRenormFactor = MCalibrationQEPix::gkDefaultAverageQE;
     323          break;
    294324      case kPhot:
    295         fRenormFactor = 1.;
    296         break;
     325          fRenormFactor = 1.;
     326          break;
    297327      }
    298328
     
    346376    }
    347377
    348     if(fCalibrationMode == kBlindPixel && !fQEs->IsBlindPixelMethodValid())
     378    const MCalibrationQECam *qecam = fIntensQE ? (MCalibrationQECam*)fIntensQE->GetCam() : fQEs;
     379    if(fCalibrationMode == kBlindPixel && !qecam->IsBlindPixelMethodValid())
    349380    {
    350381        *fLog << warn << "Blind pixel calibration method not valid, switching to F-factor method" << endl;
     
    352383    }
    353384
    354     if(fCalibrationMode == kPinDiode && !fQEs->IsPINDiodeMethodValid())
     385    if(fCalibrationMode == kPinDiode && !qecam->IsPINDiodeMethodValid())
    355386    {
    356387        *fLog << warn << "PIN diode calibration method not valid, switching to F-factor method" << endl;
     
    358389    }
    359390
    360     if(fCalibrationMode == kCombined && !fQEs->IsCombinedMethodValid())
     391    if(fCalibrationMode == kCombined && !qecam->IsCombinedMethodValid())
    361392    {
    362393        *fLog << warn << "Combined calibration method not valid, switching to F-factor method" << endl;
     
    419450
    420451    if (fCalibrationMode > kNone)
    421       {
    422        
    423         if (fCalibrations->GetSize() != npixels)
    424           {
     452    {
     453
     454        const MCalibrationCam *chargecam = fIntensCalib ? fIntensCalib->GetCam() : fCalibrations;
     455        if (chargecam->GetSize() != npixels)
     456        {
    425457            *fLog << "Size mismatch between MGeomCam and MCalibrationChargeCam... abort!" << endl;
    426458            return kFALSE;
    427           }
    428        
     459        }
     460
    429461        if (fBadPixels->GetSize() != npixels)
    430           {
     462        {
    431463            *fLog << "Size mismatch between MGeomCam and MBadPixelsCam... abort!" << endl;
    432464            return kFALSE;
    433           }
     465        }
    434466      }
    435467   
     
    466498    fHiLoConv.Reset();
    467499    fHiLoConvErr.Reset();
    468    
     500
     501    MCalibConstCam *constcam = fIntensConst ? fIntensConst->GetCam() : fCalibConstCam;
     502
     503    MCalibrationChargeCam *chargecam = NULL;
     504    MCalibrationQECam     *qecam     = NULL;
     505    if (updatecam)
     506    {
     507        chargecam = fCalibrations;
     508        qecam     = fQEs;
     509    }
     510    else
     511    {
     512        chargecam = fIntensCalib ? (MCalibrationChargeCam*)fIntensCalib->GetCam() : fCalibrations;
     513        qecam     = fIntensQE    ? (MCalibrationQECam*)    fIntensQE->GetCam()    : fQEs;
     514    }
     515
    469516    //
    470517    // For the moment, we use only a dummy zenith for the calibration:
     
    488535        Float_t calibUpdate   = 1.;
    489536
    490         MCalibConstPix &cpix  = (*fCalibConstCam)[pixidx];
     537        MCalibConstPix &cpix  = (*constcam)[pixidx];
    491538           
    492539        if(fCalibrationMode!=kNone)
     
    499546             }
    500547           
    501             MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*fCalibrations)[pixidx];
    502             MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCalibrations->GetAverageArea(0);
    503            
    504             hiloconv   = pix.GetConversionHiLo   ();
    505             hiloconverr= pix.GetConversionHiLoErr();
     548            const MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*chargecam)[pixidx];
     549            const MCalibrationChargePix &avpix = (MCalibrationChargePix&)chargecam->GetAverageArea(0);
     550
     551            hiloconv   = pix.GetConversionHiLo     ();
     552            hiloconverr= pix.GetConversionHiLoSigma();
    506553           
    507554            calibConv    = pix.GetMeanConvFADC2Phe();
     
    509556            calibFFactor = pix.GetMeanFFactorFADC2Phot();
    510557           
    511             MCalibrationQEPix &qe = (MCalibrationQEPix&) (*fQEs)[pixidx];
     558            const MCalibrationQEPix &qe = (MCalibrationQEPix&)(*qecam)[pixidx];
    512559
    513560            if (updatecam)
     
    613660        calibConv /= calibQE;
    614661
    615         if (calibConv != 0. && calibQE != 0.)
     662        if (calibConv > 0.00001 && calibQE > 0.00001)
    616663          {
    617664            calibConvVar  = calibConvVar/(calibConv*calibConv) + calibQEVar/(calibQE*calibQE);
     
    632679            calibConv    = -1.;
    633680            calibFFactor = -1.;
     681            *fLog << warn << "Conversion factor of Pixel " << pixidx << " out of range " << endl;
    634682          }
    635683        cpix.SetCalibConst(calibConv);
  • trunk/MagicSoft/Mars/mcalib/MCalibrateData.h

    r7122 r7189  
    1313class MBadPixelsCam;
    1414class MPedestalCam;
    15 class MCalibrationChargeCam;
    16 class MCalibrationQECam;
    17 class MExtractedSignalCam;
    18 
    1915class MPedPhotCam;
    2016class MSignalCam;
    2117class MCalibConstCam;
     18class MExtractedSignalCam;
     19
     20class MCalibrationChargeCam;
     21class MCalibrationQECam;
     22
     23class MCalibrationIntensityChargeCam;
     24class MCalibrationIntensityQECam;
     25class MCalibrationIntensityConstCam;
    2226
    2327class MCalibrateData : public MTask
     
    5862  Float_t  fCalibConvMaxLimit;           // Maximum limit for conv. factor
    5963   
    60   MGeomCam              *fGeomCam;       //! Camera geometry container
    61   MBadPixelsCam         *fBadPixels;     //! Bad Pixels information
    62   MCalibrationChargeCam *fCalibrations;  //! Calibration constants
    63   MCalibrationQECam     *fQEs;           //! Quantum efficiencies
    64   MExtractedSignalCam   *fSignals;       //! Integrated charge in FADCs counts
    65   MSignalCam            *fCerPhotEvt;    //! Cerenkov Photon Event used for calculation
    66   MCalibConstCam        *fCalibConstCam; //! Temporary calib consts storage
     64  MGeomCam                       *fGeomCam;       //! Camera geometry container
     65  MBadPixelsCam                  *fBadPixels;     //! Bad Pixels information
     66  MCalibrationChargeCam          *fCalibrations;  //! Calibration constants
     67  MCalibrationIntensityChargeCam *fIntensCalib;   //! Calibration constants from interlaced calib.
     68  MCalibrationQECam              *fQEs;           //! Quantum efficiencies
     69  MCalibrationIntensityQECam     *fIntensQE;      //! Quantum efficiencies  from interlaced calib.
     70  MExtractedSignalCam            *fSignals;       //! Integrated charge in FADCs counts
     71  MSignalCam                     *fCerPhotEvt;    //! Cerenkov Photon Event used for calculation
     72  MCalibConstCam                 *fCalibConstCam; //! Temporary calib consts storage
     73  MCalibrationIntensityConstCam  *fIntensConst;   //! Temporary calib consts storage
    6774 
    6875  CalibrationMode_t fCalibrationMode;    // Flag defining the calibration mode (CalibrationMode_t)
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r7126 r7189  
    184184//   + Float_t fPheErrUpperLimit; // Upper limit acceptance nr. phe's w.r.t. area idx mean (in sigmas)
    185185//
     186//
    186187//  ClassVersion 3:
    187188//   + Bool_t  fUseExtractorRes;  // Include extractor resolution in F-Factor method
     189//
     190//  ClassVersion 3:
     191//   +  Float_t fUnsuitablesLimit;                   // Limit for relative number of unsuitable pixels
     192//   +  Float_t fUnreliablesLimit;                   // Limit for relative number of unreliable pixels
     193//   +  Float_t fExternalNumPhes;                    // External mean number of photo-electrons set from outside
     194//   +  Float_t fExternalNumPhesRelVar;              // External rel. var. number of photo-electrons set from outside 
    188195//
    189196//////////////////////////////////////////////////////////////////////////////
     
    198205
    199206#include "MParList.h"
    200 
    201 #include "MStatusDisplay.h"
    202207
    203208#include "MCalibrationPattern.h"
     
    247252const Float_t MCalibrationChargeCalc::fgFFactorErrLimit        = 4.5;
    248253const Float_t MCalibrationChargeCalc::fgArrTimeRmsLimit        = 3.5;
     254const Float_t MCalibrationChargeCalc::fgUnsuitablesLimit       = 0.1;
     255const Float_t MCalibrationChargeCalc::fgUnreliablesLimit       = 0.3;
    249256const TString MCalibrationChargeCalc::fgNamePedestalCam = "MPedestalCam";
    250257
     
    263270//
    264271// Initializes:
    265 // - fArrTimeRmsLimit   to fgArrTimeRmsLimit
    266 // - fChargeLimit       to fgChargeLimit
    267 // - fChargeErrLimit    to fgChargeErrLimit   
    268 // - fChargeRelErrLimit to fgChargeRelErrLimit
    269 // - fFFactorErrLimit   to fgFFactorErrLimit
    270 // - fLambdaCheckLimit  to fgLambdaCheckLimit
    271 // - fLambdaErrLimit    to fgLambdaErrLimit
    272 // - fNamePedestalCam   to fgNamePedestalCam
    273 // - fPheErrLowerLimit  to fgPheErrLowerLimit
    274 // - fPheErrUpperLimit  to fgPheErrUpperLimit
    275 // - fPulserColor       to MCalibrationCam::kCT1
    276 // - fOutputPath        to "."
    277 // - fOutputFile        to "ChargeCalibStat.txt"
    278 // - flag debug         to kFALSE
     272// - fArrTimeRmsLimit     to fgArrTimeRmsLimit
     273// - fChargeLimit         to fgChargeLimit
     274// - fChargeErrLimit      to fgChargeErrLimit
     275// - fChargeRelErrLimit   to fgChargeRelErrLimit
     276// - fFFactorErrLimit     to fgFFactorErrLimit
     277// - fLambdaCheckLimit    to fgLambdaCheckLimit
     278// - fLambdaErrLimit      to fgLambdaErrLimit
     279// - fNamePedestalCam     to fgNamePedestalCam
     280// - fPheErrLowerLimit    to fgPheErrLowerLimit
     281// - fPheErrUpperLimit    to fgPheErrUpperLimit
     282// - fPulserColor         to MCalibrationCam::kCT1
     283// - fOutputPath          to "."
     284// - fOutputFile          to "ChargeCalibStat.txt"
     285// - flag debug           to kFALSE
     286// - IsUseExtractorRes    to kFALSE
     287// - IsUseExternalNumPhes to kFALSE
     288// - fExternalNumPhes     to 0.
     289// - fExternalNumPhesRelVar to 0.
    279290//
    280291// Sets all checks
     
    284295//
    285296MCalibrationChargeCalc::MCalibrationChargeCalc(const char *name, const char *title)
    286     : fUseExtractorRes(kFALSE),
    287     fGeom(NULL), fSignal(NULL), fCalibPattern(NULL), fExtractor(NULL)
     297    : fGeom(NULL), fSignal(NULL), fCalibPattern(NULL), fExtractor(NULL)
    288298{
    289299       
     
    309319  SetPheErrLowerLimit  ();
    310320  SetPheErrUpperLimit  ();
     321  SetUnsuitablesLimit  ();
     322  SetUnreliablesLimit  ();
     323  SetUseExtractorRes   ();
     324  SetUseUnreliables    ();
     325  SetUseExternalNumPhes(kFALSE);
     326 
     327  SetExternalNumPhes      ();
     328  SetExternalNumPhesRelVar();
    311329
    312330  SetCheckArrivalTimes     ();
     
    560578    }
    561579
     580  fResultFlags.Set(fGeom->GetNumAreas());
     581
    562582  return kTRUE;
    563583}
     
    777797    {
    778798
    779       const MPedestalPix     &ped = fPedestals->GetAverageArea(aidx);
     799      const MPedestalPix    &ped = fPedestals->GetAverageArea(aidx);
    780800      MCalibrationChargePix &pix = (MCalibrationChargePix&)chargecam->GetAverageArea(aidx);
     801      const MArrayI &arr         = fHCam->GetAverageAreaNum();
    781802
    782803      FinalizePedestals(ped,pix,aidx);
     804
     805      //
     806      // Correct for sqrt(number of valid pixels) in the pedestal RMS
     807      // (already done for calibration sigma in MHCalibrationCam::CalcAverageSigma()
     808      //
     809      pix.SetPedRMS(pix.GetPedRms()*TMath::Sqrt((Float_t)arr[aidx]),
     810                    pix.GetPedRmsErr()*TMath::Sqrt((Float_t)arr[aidx]));
     811      pix.SetSigma (pix.GetSigma()/pix.GetFFactorFADC2Phe());
     812
    783813      FinalizeCharges(pix, chargecam->GetAverageBadArea(aidx),"area id");
    784814      FinalizeArrivalTimes(pix, chargecam->GetAverageBadArea(aidx), "area id");
     
    847877  }
    848878
    849   //
    850   // Finalize calibration statistics
    851   //
    852   FinalizeUnsuitablePixels();
    853 
    854   chargecam->SetReadyToSave();
    855   qecam    ->SetReadyToSave();
    856   badcam   ->SetReadyToSave();
    857  
    858   if (blindcam)
    859     blindcam->SetReadyToSave();
    860   if (fPINDiode)
    861     fPINDiode->SetReadyToSave();
    862  
    863879  *fLog << inf << endl;
    864880  *fLog << GetDescriptor() << ": Fatal errors statistics:" << endl; 
     
    884900  PrintUncalibrated(MBadPixelsPix::kDeviatingNumPhes,
    885901                    "Deviating number of phes:                         ");
     902  PrintUncalibrated(MBadPixelsPix::kLoGainBlackout,
     903                    "Too many blackout events in low gain:             ");
    886904  PrintUncalibrated(MBadPixelsPix::kPreviouslyExcluded,
    887905                    "Previously excluded:                              ");
     
    906924      SetLogStream(oldlog);
    907925
    908   return kTRUE;
     926  chargecam->SetReadyToSave();
     927  qecam    ->SetReadyToSave();
     928  badcam   ->SetReadyToSave();
     929
     930  if (blindcam)
     931    blindcam->SetReadyToSave();
     932  if (fPINDiode)
     933    fPINDiode->SetReadyToSave();
     934
     935  //
     936  // Finalize calibration statistics
     937  //
     938  return FinalizeUnsuitablePixels();
    909939}
    910940
     
    10421072    }
    10431073
    1044   if (!fUseExtractorRes)
     1074  if (!IsUseExtractorRes())
    10451075    return kTRUE;
    10461076
     
    10591089    : resinphes/cal.GetMeanConvFADC2Phe();
    10601090
    1061   if (resinfadc > 1.5*cal.GetPedRms() )
    1062     {
    1063       *fLog << warn << " Extractor Resolution: " << resinfadc << " bigger than Pedestal RMS " << cal.GetPedRms() << endl;
    1064       resinfadc = cal.GetPedRms();
     1091  if (resinfadc > 3.0*cal.GetPedRms() )
     1092    {
     1093      *fLog << warn << " Extractor Resolution: " << resinfadc << " bigger than 3 Pedestal RMS "
     1094            << cal.GetPedRms() << endl;
     1095      resinfadc = 3.0*cal.GetPedRms();
    10651096    }
    10661097
     
    11521183          if (bad.IsUncalibrated( MBadPixelsPix::kChargeIsPedestal))
    11531184            bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun   );
    1154  
    1155           if (bad.IsUncalibrated( MBadPixelsPix::kChargeErrNotValid ))
    1156             bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
    1157 
    1158           if (bad.IsUncalibrated( MBadPixelsPix::kChargeRelErrNotValid ))
    1159             bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
    11601185        }
    11611186     
     
    12681293      if (bad.IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid))
    12691294        continue;
    1270      
     1295
     1296      if (!IsUseUnreliables())
     1297        if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
     1298          continue;
     1299
    12711300      const Float_t nphe  = pix.GetPheFFactorMethod();
    12721301      const Int_t   aidx  = (*fGeom)[i].GetAidx();
     
    13221351      if (ndf < 5)
    13231352        {
    1324           *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons "
    1325                 << "in the camera with area index: " << i << endl;
    1326           *fLog << warn << GetDescriptor() << ": Number of dof.: " << ndf << " is smaller than 5 " << endl;
    1327           *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
    1328           delete hist;
    1329           continue;
     1353            *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons " << endl;
     1354            *fLog << " in the camera with area index: " << i << endl;
     1355            *fLog << " Number of dof.: " << ndf << " is smaller than 5 " << endl;
     1356            *fLog << " Will use the simple mean and rms " << endl;
     1357            delete hist;
     1358            SetPheFitOK(i,kFALSE);
     1359            continue;
    13301360        }
    13311361     
     
    13341364      if (prob < 0.001)
    13351365        {
    1336           *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons "
    1337                 << "in the camera with area index: " << i << endl;
    1338           *fLog << warn << GetDescriptor() << ": Fit probability " << prob
    1339                 << " is smaller than 0.001 " << endl;
    1340           *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
    1341           delete hist;
    1342           continue;
     1366            *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons " << endl;
     1367            *fLog << " in the camera with area index: " << i << endl;
     1368            *fLog << " Fit probability " << prob << " is smaller than 0.001 " << endl;
     1369            *fLog << " Will use the simple mean and rms " << endl;
     1370            delete hist;
     1371            SetPheFitOK(i,kFALSE);
     1372            continue;
    13431373        }
    13441374     
    13451375      if (mean < 0.)
    13461376        {
    1347           *fLog << inf << GetDescriptor() << ": Fitted mean number of photo-electrons "
    1348                 << "with area idx " << i << ": " << mean << " is smaller than 0. " << endl;
    1349           *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;         
    1350           delete hist;
    1351           continue;
     1377            *fLog << inf << GetDescriptor() << ": Fitted mean number of photo-electrons " << endl;
     1378            *fLog << " with area idx " << i << ": " << mean << " is smaller than 0. " << endl;
     1379            *fLog << warn << " Will use the simple mean and rms " << endl;
     1380            SetPheFitOK(i,kFALSE);
     1381            delete hist;
     1382            continue;
    13521383        }
    13531384     
     
    13591390
    13601391      delete hist;
     1392
     1393      SetPheFitOK(i,kTRUE);
    13611394    }
    13621395
     
    13831416      if (bad.IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid))
    13841417        continue;
     1418
     1419      if (!IsUseUnreliables())
     1420        if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
     1421          continue;
    13851422
    13861423      const Float_t nvar  = pix.GetPheFFactorMethodVar();
     
    17301767  MCalibrationQEPix     &qepix = (MCalibrationQEPix&)    qecam->GetAverageArea(0);
    17311768
    1732   const Float_t avphotons   = avpix.GetPheFFactorMethod()       
     1769  if (IsDebug())
     1770    *fLog << dbginf << "External Phes: " << fExternalNumPhes
     1771          << " Internal Phes: " << avpix.GetPheFFactorMethod() << endl;
     1772
     1773  const Float_t avphotons   = ( IsUseExternalNumPhes()
     1774                                ? fExternalNumPhes
     1775                                : avpix.GetPheFFactorMethod() )
    17331776                           / qepix.GetDefaultQE(fPulserColor)
    17341777                           / qepix.GetPMTCollectionEff()
     
    17361779                           / qecam->GetPlexiglassQE();
    17371780
    1738   const Float_t avphotrelvar = avpix.GetPheFFactorMethodRelVar()
     1781  const Float_t avphotrelvar = ( IsUseExternalNumPhes()
     1782                                 ? fExternalNumPhesRelVar
     1783                                 : avpix.GetPheFFactorMethodRelVar() )
    17391784                            + qepix.GetDefaultQERelVar(fPulserColor) / fNumInnerFFactorMethodUsed
    17401785                            + qepix.GetPMTCollectionEffRelVar()
     
    18461891      if (ndf < 2)
    18471892        {
    1848           *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor "
    1849                 << "in the camera with area index: " << i << endl;
    1850           *fLog << "Number of dof.: " << ndf << " is smaller than 2 " << endl;
    1851           *fLog << "Will use the simple mean and rms." << endl;
     1893          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " << endl;
     1894          *fLog << " in the camera with area index: " << i << endl;
     1895          *fLog << " Number of dof.: " << ndf << " is smaller than 2 " << endl;
     1896          *fLog << " Will use the simple mean and rms." << endl;
    18521897          delete hist;
     1898          SetFFactorFitOK(i,kFALSE);
    18531899          continue;
    18541900        }
     
    18581904      if (prob < 0.001)
    18591905        {
    1860           *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor "
    1861                 << "in the camera with area index: " << i << endl;
    1862           *fLog << "Fit probability " << prob
    1863                 << " is smaller than 0.001 " << endl;
    1864           *fLog << "Will use the simple mean and rms." << endl;
     1906          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " << endl;
     1907          *fLog << " in the camera with area index: " << i << endl;
     1908          *fLog << " Fit probability " << prob << " is smaller than 0.001 " << endl;
     1909          *fLog << " Will use the simple mean and rms." << endl;
    18651910          delete hist;
    1866           continue;
     1911          SetFFactorFitOK(i,kFALSE);
     1912         continue;
    18671913        }
    18681914
    18691915      *fLog << inf << GetDescriptor() << ": Mean F-Factor "
    1870           << "with area index #" << i << ": "
    1871             << Form("%4.2f+-%4.2f",mean,sigma) << endl;
     1916          << "with area index #" << i << ": " << Form("%4.2f+-%4.2f",mean,sigma) << endl;
    18721917
    18731918      lowlim  [i] = 1.;
     
    18751920
    18761921      delete hist;
     1922
     1923      SetFFactorFitOK(i,kTRUE);
    18771924    }
    18781925 
     
    21342181// - store numbers of bad pixels of each type in fCam or fIntensCam
    21352182//
    2136 void MCalibrationChargeCalc::FinalizeUnsuitablePixels()
     2183Bool_t MCalibrationChargeCalc::FinalizeUnsuitablePixels()
    21372184{
    21382185 
     
    21432190  const Int_t nareas = fGeom->GetNumAreas();
    21442191
     2192  TArrayI suit(nareas);
     2193  TArrayI unsuit(nareas);
     2194  TArrayI unrel(nareas);
     2195
     2196  const MBadPixelsCam *badcam = fIntensBad ? (MBadPixelsCam*)fIntensBad->GetCam() : fBadPixels;
     2197  MCalibrationChargeCam *chargecam = fIntensCam ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam;
     2198
     2199  Int_t unsuitcnt=0;
     2200  Int_t unrelcnt =0;
     2201
     2202  // Count number of succesfully calibrated pixels
     2203  for (Int_t aidx=0; aidx<nareas; aidx++)
     2204  {
     2205      suit[aidx]   = badcam->GetNumSuitable(MBadPixelsPix::kUnsuitableRun,   fGeom, aidx);
     2206      unsuit[aidx] = badcam->GetNumUnsuitable(MBadPixelsPix::kUnsuitableRun, fGeom, aidx);
     2207      unrel[aidx]  = badcam->GetNumUnsuitable(MBadPixelsPix::kUnreliableRun, fGeom, aidx);
     2208
     2209      unsuitcnt   += unsuit[aidx];
     2210      unrelcnt    += unrel[aidx];
     2211
     2212      chargecam->SetNumUnsuitable(unsuit[aidx], aidx);
     2213      chargecam->SetNumUnreliable(unrel[aidx],  aidx);
     2214  }
     2215
    21452216  TArrayI counts(nareas);
    2146 
    2147   MBadPixelsCam         *badcam    = fIntensBad
    2148     ? (MBadPixelsCam*)fIntensBad->GetCam()  : fBadPixels;
    2149   MCalibrationChargeCam *chargecam = fIntensCam
    2150     ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
    2151 
    2152   for (Int_t i=0; i<badcam->GetSize(); i++)
    2153     {
    2154       MBadPixelsPix &bad = (*badcam)[i];
    2155       if (!bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
    2156         {
     2217  for (Int_t i=0; i<chargecam->GetSize(); i++)
     2218  {
     2219      MCalibrationPix &pix = (*chargecam)[i];
     2220      if (pix.IsHiGainSaturation())
     2221      {
    21572222          const Int_t aidx = (*fGeom)[i].GetAidx();
    21582223          counts[aidx]++;
    2159         }
    2160     }
     2224      }
     2225  }
    21612226
    21622227  if (fGeom->InheritsFrom("MGeomCamMagic"))
    2163     *fLog << " " << setw(7) << "Successfully calibrated Pixels: "
    2164           << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
    2165  
    2166   counts.Reset();
    2167 
    2168   for (Int_t i=0; i<badcam->GetSize(); i++)
    2169     {
    2170       MBadPixelsPix &bad =  (*badcam)[i];
    2171 
    2172       if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
    2173         {
    2174           const Int_t aidx = (*fGeom)[i].GetAidx();
    2175           counts[aidx]++;
    2176         }
    2177     }
    2178 
    2179   for (Int_t aidx=0; aidx<nareas; aidx++)
    2180     chargecam->SetNumUnsuitable(counts[aidx], aidx);
    2181 
    2182   if (fGeom->InheritsFrom("MGeomCamMagic"))
    2183     *fLog << " " << setw(7) << "Uncalibrated Pixels:            "
    2184           << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
    2185 
    2186   counts.Reset();
    2187 
    2188   for (Int_t i=0; i<badcam->GetSize(); i++)
    2189     {
    2190 
    2191       MBadPixelsPix &bad = (*badcam)[i];
    2192 
    2193       if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
    2194         {
    2195           const Int_t aidx = (*fGeom)[i].GetAidx();
    2196           counts[aidx]++;
    2197         }
    2198     }
    2199 
    2200   for (Int_t aidx=0; aidx<nareas; aidx++)
    2201     chargecam->SetNumUnreliable(counts[aidx], aidx);
    2202 
    2203   *fLog << " " << setw(7) << "Unreliable Pixels:              "
    2204         << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
    2205 
     2228  {
     2229      *fLog << " Successfully calibrated Pixels: Inner: "
     2230          << Form("%3i",suit[0])   << " Outer: " << Form("%3i",suit[1])   << endl;
     2231      *fLog << " Uncalibrated Pixels:            Inner: "
     2232          << Form("%3i",unsuit[0]) << " Outer: " << Form("%3i",unsuit[1]) << endl;
     2233      *fLog << " Unreliable Pixels:              Inner: "
     2234          << Form("%3i",unrel[0])  << " Outer: " << Form("%3i",unrel[1])  << endl;
     2235      *fLog << " High-gain saturated Pixels:     Inner: "
     2236          << Form("%3i",counts[0]) << " Outer: " << Form("%3i",counts[1]) << endl;
     2237      *fLog << endl;
     2238  }
     2239
     2240  return kTRUE;
     2241
     2242  if (unsuitcnt > fUnsuitablesLimit*fGeom->GetNumPixels())
     2243  {
     2244      *fLog << err << "Number of unsuitable pixels: " << 100.*unsuitcnt/fGeom->GetNumPixels()
     2245          << "% exceeds limit of " << fUnsuitablesLimit*100 << "%" <<  endl;
     2246      return kFALSE;
     2247  }
     2248
     2249  if (unrelcnt > fUnreliablesLimit*fGeom->GetNumPixels())
     2250  {
     2251      *fLog << err << "Relative number of unreliable pixels: " << 100.*unrelcnt/fGeom->GetNumPixels()
     2252          << "% exceeds limit of " << fUnreliablesLimit*100 << "%" << endl;
     2253      return kFALSE;
     2254  }
     2255  return kTRUE;
    22062256}
    22072257
     
    22322282    }
    22332283
    2234   *fLog << " " << setw(7) << text  
    2235         << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
     2284  *fLog << " " << setw(7) << text << "Inner: " << Form("%3i",countinner)
     2285      << " Outer: " << Form("%3i", countouter) << endl;
    22362286}
    22372287
     
    23612411      rc = kTRUE;
    23622412    }
    2363   if (IsEnvDefined(env, prefix, "UseExtractorRes", print))
    2364     {
    2365       SetUseExtractorRes(GetEnvValue(env, prefix, "UseExtractorRes", fUseExtractorRes));
     2413   if (IsEnvDefined(env, prefix, "UseExtractorRes", print))
     2414     {
     2415       SetUseExtractorRes(GetEnvValue(env, prefix, "UseExtractorRes", IsUseExtractorRes()));
    23662416      rc = kTRUE;
    23672417    }
     2418  if (IsEnvDefined(env, prefix, "UseUnreliables", print))
     2419    {
     2420      SetUseUnreliables(GetEnvValue(env, prefix, "UseUnreliables", IsUseUnreliables()));
     2421      rc = kTRUE;
     2422    }
     2423
     2424  if (IsEnvDefined(env, prefix, "UseExternalNumPhes", print))
     2425    {
     2426      SetUseExternalNumPhes(GetEnvValue(env, prefix, "UseExternalNumPhes", IsUseExternalNumPhes()));
     2427      rc = kTRUE;
     2428    }
     2429
     2430  if (IsEnvDefined(env, prefix, "UnsuitablesLimit", print))
     2431    {
     2432      SetUnsuitablesLimit(GetEnvValue(env, prefix, "UnsuitablesLimit", fUnsuitablesLimit));
     2433      rc = kTRUE;
     2434    }
     2435
     2436  if (IsEnvDefined(env, prefix, "UnreliablesLimit", print))
     2437    {
     2438       SetUnreliablesLimit(GetEnvValue(env, prefix, "UnreliablesLimit", fUnreliablesLimit));
     2439       rc = kTRUE;
     2440     }
     2441 
    23682442
    23692443  return rc;
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h

    r7099 r7189  
    5050  static const Float_t fgFFactorErrLimit;      //! Default for fFFactorErrLimit    (now set to: 4.5)
    5151  static const Float_t fgArrTimeRmsLimit;      //! Default for fArrTimeRmsLimit    (now set to: 3.5)
     52  static const Float_t fgUnsuitablesLimit;     //! Default for fUnsuitableLimit    (now set to: 0.1)
     53  static const Float_t fgUnreliablesLimit;     //! Default for fUnreliableLimit    (now set to: 0.3)
    5254 
    5355  static const TString fgNamePedestalCam;      //! "MPedestalCam"
    5456 
    5557  // Variables
     58  Float_t fArrTimeRmsLimit;                    // Limit acceptance RMS of absolute arrival times
    5659  Float_t fChargeLimit;                        // Limit acceptance mean charge  (in units of PedRMS)
    5760  Float_t fChargeErrLimit;                     // Limit acceptance charge error (in abs. numbers)
    5861  Float_t fChargeRelErrLimit;                  // Limit acceptance rel. error mean (in abs. numbers)
     62  Float_t fFFactorErrLimit;                    // Limit acceptance F-Factor w.r.t. area idx mean
    5963  Float_t fLambdaCheckLimit;                   // Limit rel. diff. lambda and lambdacheck in Blind Pixel
    6064  Float_t fLambdaErrLimit;                     // Limit acceptance lambda error in Blind Pixel
     
    6367  Float_t fPheErrLowerLimit;                   // Lower limit acceptance nr. phe's w.r.t. area idx mean (in sigmas)
    6468  Float_t fPheErrUpperLimit;                   // Upper limit acceptance nr. phe's w.r.t. area idx mean (in sigmas)
    65   Float_t fFFactorErrLimit;                    // Limit acceptance F-Factor w.r.t. area idx mean
    66   Float_t fArrTimeRmsLimit;                    // Limit acceptance RMS of absolute arrival times
    6769  Float_t fSqrtHiGainSamples;                  // Square root nr. High-Gain FADC slices used by extractor
    6870  Float_t fSqrtLoGainSamples;                  // Square root nr. Low -Gain FADC slices used by extractor
     71  Float_t fUnsuitablesLimit;                   // Limit for relative number of unsuitable pixels
     72  Float_t fUnreliablesLimit;                   // Limit for relative number of unreliable pixels
     73
     74  Float_t fExternalNumPhes;                    // External mean number of photo-electrons set from outside
     75  Float_t fExternalNumPhesRelVar;              // External rel. var. number of photo-electrons set from outside 
    6976
    7077  MCalibrationCam::PulserColor_t fPulserColor; // Calibration LEDs colour
     
    7380  Int_t   fNumInnerFFactorMethodUsed;          // Number of inner pixels used for F-Factor Method calibration
    7481
    75   Byte_t  fFlags;                              // Bit-field for the general flags
    76   TArrayC fResultFlags;                        // Bit-fields for the fitting results   (one field per area index)
    77   TArrayC fBlindPixelFlags;                    // Bit-fields for the blind pixel flags (one field per blind pixel)
    78   TArrayC fPINDiodeFlags;                      // Bit-fields for the PIN Diode flags   (one field per PIN Diode  )
    79  
    8082  TString fOutputPath;                         // Path to the output file
    8183  TString fOutputFile;                         // Name of the output file 
     
    8385
    8486  Int_t   fNumProcessed;                       // Number of processed events (for Intensity calibration)
    85   Bool_t  fUseExtractorRes;                    // Include extractor resolution in F-Factor method
    8687 
    8788  // Pointers
     
    115116
    116117  Byte_t fCheckFlags;                          // Bit-field to hold the possible check flags
    117  
     118
     119  enum  FitResult_t { kPheFitOK,
     120                      kFFactorFitOK,
     121                      kBlindPixelFitOK,
     122                      kBlindPixelPedFitOK,
     123                      kPINDiodeFitOK };        // Possible Fit Result flags
     124
     125  TArrayC fResultFlags;                        // Bit-fields for the fitting results   (one field per area index)
     126  TArrayC fBlindPixelFlags;                    // Bit-fields for the blind pixel flags (one field per blind pixel)
     127  TArrayC fPINDiodeFlags;                      // Bit-fields for the PIN Diode flags   (one field per PIN Diode  )
     128
    118129  enum  { kDebug,
    119           kPheFitOK, kFFactorFitOK, kBlindPixelFitOK, kBlindPixelPedFitOK, kPINDiodeFitOK };
     130          kUseExtractorRes,
     131          kUseUnreliables,
     132          kUseExternalNumPhes };               // Possible general flags
     133
     134  Byte_t fFlags;                               // Bit-field to hold the general flags
    120135
    121136  // functions
     137  void   FinalizeArrivalTimes    ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
     138  void   FinalizeBadPixels       ();
     139  Bool_t FinalizeBlindCam        (); 
     140  void   FinalizeBlindPixelQECam ();
     141  Bool_t FinalizeCharges         ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
     142  void   FinalizeCombinedQECam   ();
     143  void   FinalizeFFactorQECam    (); 
     144  Bool_t FinalizeFFactorMethod   ();
    122145  void   FinalizePedestals       ( const MPedestalPix    &ped, MCalibrationChargePix &cal, const Int_t aidx );
    123   void   FinalizeArrivalTimes    ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
    124   Bool_t FinalizeCharges         ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
    125146  Bool_t FinalizePINDiode        ();
    126   Bool_t FinalizeBlindCam        (); 
    127   Bool_t FinalizeFFactorMethod   ();
    128   void   FinalizeBadPixels       ();
    129   void   FinalizeFFactorQECam    (); 
    130   void   FinalizeBlindPixelQECam ();
    131147  void   FinalizePINDiodeQECam   ();
    132   void   FinalizeCombinedQECam   ();
    133   void   FinalizeUnsuitablePixels();
     148  Bool_t FinalizeUnsuitablePixels();
    134149
    135150  const char* GetOutputFile();
     
    143158  Bool_t IsCheckArrivalTimes     () const { return TESTBIT(fCheckFlags,kCheckArrivalTimes);      }
    144159
     160  Bool_t IsDebug                 () const { return TESTBIT(fFlags,kDebug);                       }
     161  Bool_t IsUseExtractorRes       () const { return TESTBIT(fFlags,kUseExtractorRes);             }
     162  Bool_t IsUseUnreliables        () const { return TESTBIT(fFlags,kUseUnreliables);              }
     163  Bool_t IsUseExternalNumPhes    () const { return TESTBIT(fFlags,kUseExternalNumPhes);          }
     164
    145165  void   PrintUncalibrated( MBadPixelsPix::UncalibratedType_t typ, const char *text) const;
    146166
    147167  // Global fit results
    148   void   SetPheFitOK          ( const Int_t aidx, const Bool_t b=kTRUE ) {
    149     b ? SETBIT(fResultFlags[aidx], kPheFitOK)
    150       : CLRBIT(fResultFlags[aidx], kPheFitOK);      }
    151   void   SetFFactorFitOK      ( const Int_t aidx, const Bool_t b=kTRUE ) {
    152     b ? SETBIT(fResultFlags[aidx], kFFactorFitOK)
    153       : CLRBIT(fResultFlags[aidx], kFFactorFitOK);  }
    154   void   SetBlindPixelFitOK   ( const Int_t  idx, const Bool_t b=kTRUE ) {
    155     b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelFitOK)
    156       : CLRBIT(fBlindPixelFlags[idx], kBlindPixelFitOK); }
    157   void   SetBlindPixelPedFitOK( const Int_t  idx, const Bool_t b=kTRUE ) {
    158     b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK)
    159       : CLRBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK); }
    160   void   SetPINDiodeFitOK     ( const Int_t  idx, const Bool_t b=kTRUE ) {
    161     b ? SETBIT(fPINDiodeFlags[idx], kPINDiodeFitOK)
    162       : CLRBIT(fPINDiodeFlags[idx], kPINDiodeFitOK); }
     168  void   SetPheFitOK          (const Int_t aidx, const Bool_t b=kTRUE) { b ? SETBIT(fResultFlags[aidx], kPheFitOK) : CLRBIT(fResultFlags[aidx], kPheFitOK);      }
     169  void   SetFFactorFitOK      (const Int_t aidx, const Bool_t b=kTRUE) { b ? SETBIT(fResultFlags[aidx], kFFactorFitOK) : CLRBIT(fResultFlags[aidx], kFFactorFitOK);  }
     170  void   SetBlindPixelFitOK   (const Int_t  idx, const Bool_t b=kTRUE) { b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelFitOK) : CLRBIT(fBlindPixelFlags[idx], kBlindPixelFitOK); }
     171  void   SetBlindPixelPedFitOK(const Int_t  idx, const Bool_t b=kTRUE) { b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK): CLRBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK); }
     172  void   SetPINDiodeFitOK     (const Int_t  idx, const Bool_t b=kTRUE) { b ? SETBIT(fPINDiodeFlags[idx], kPINDiodeFitOK): CLRBIT(fPINDiodeFlags[idx], kPINDiodeFitOK); }
    163173
    164174  Int_t  PreProcess (MParList *pList);
     
    169179
    170180public:
    171 
    172181  MCalibrationChargeCalc(const char *name=NULL, const char *title=NULL);
    173182
     
    176185  Int_t Finalize();
    177186
    178   Bool_t IsDebug() const   {  return TESTBIT(fFlags,kDebug); }
     187  void SetChargeLimit      (const Float_t f=fgChargeLimit      ) { fChargeLimit       = f; }
     188  void SetChargeErrLimit   (const Float_t f=fgChargeErrLimit   ) { fChargeErrLimit    = f; }
     189  void SetChargeRelErrLimit(const Float_t f=fgChargeRelErrLimit) { fChargeRelErrLimit = f; }
     190
     191  // Checks
     192  void SetCheckArrivalTimes(const Bool_t b=kTRUE)      { b ? SETBIT(fCheckFlags,kCheckArrivalTimes)      : CLRBIT(fCheckFlags,kCheckArrivalTimes); }
     193  void SetCheckDeadPixels(const Bool_t b=kTRUE)        { b ? SETBIT(fCheckFlags,kCheckDeadPixels)        : CLRBIT(fCheckFlags,kCheckDeadPixels); }
     194  void SetCheckDeviatingBehavior(const Bool_t b=kTRUE) { b ? SETBIT(fCheckFlags,kCheckDeviatingBehavior) : CLRBIT(fCheckFlags,kCheckDeviatingBehavior); }
     195  void SetCheckExtractionWindow(const Bool_t b=kTRUE)  { b ? SETBIT(fCheckFlags,kCheckExtractionWindow)  : CLRBIT(fCheckFlags,kCheckExtractionWindow); }
     196  void SetCheckHistOverflow(const Bool_t b=kTRUE)      { b ? SETBIT(fCheckFlags,kCheckHistOverflow)      : CLRBIT(fCheckFlags,kCheckHistOverflow); }
     197  void SetCheckOscillations(const Bool_t b=kTRUE)      { b ? SETBIT(fCheckFlags,kCheckOscillations)      : CLRBIT(fCheckFlags,kCheckOscillations); }
     198  void SetDebug(const Bool_t b=kTRUE)                  { b ? SETBIT(fFlags, kDebug)                      : CLRBIT(fFlags, kDebug); }
     199  void SetUseExtractorRes(const Bool_t b=kTRUE)        { b ? SETBIT(fFlags, kUseExtractorRes)            : CLRBIT(fFlags, kUseExtractorRes); }
     200  void SetUseUnreliables(const Bool_t b=kTRUE)         { b ? SETBIT(fFlags, kUseUnreliables)             : CLRBIT(fFlags, kUseUnreliables); }
     201  void SetUseExternalNumPhes(const Bool_t b=kTRUE)     { b ? SETBIT(fFlags, kUseExternalNumPhes)         : CLRBIT(fFlags, kUseExternalNumPhes); }
     202
     203  // pointers
     204  void SetPedestals(MPedestalCam *cam) { fPedestals=cam; }
     205  void SetExtractor(MExtractor   *ext) { fExtractor=ext; }
     206
     207  // limits
     208  void SetArrTimeRmsLimit (const Float_t f=fgArrTimeRmsLimit ) { fArrTimeRmsLimit   = f; }
     209  void SetFFactorErrLimit (const Float_t f=fgFFactorErrLimit ) { fFFactorErrLimit   = f; }
     210  void SetLambdaErrLimit  (const Float_t f=fgLambdaErrLimit  ) { fLambdaErrLimit    = f; }
     211  void SetLambdaCheckLimit(const Float_t f=fgLambdaCheckLimit) { fLambdaCheckLimit  = f; }
     212  void SetUnsuitablesLimit(const Float_t f=fgUnsuitablesLimit) { fUnsuitablesLimit  = f; }
     213  void SetUnreliablesLimit(const Float_t f=fgUnreliablesLimit) { fUnreliablesLimit  = f; }
     214
     215  // others
     216  void SetExternalNumPhes      ( const Float_t f=0.                       ) { fExternalNumPhes       = f; }
     217  void SetExternalNumPhesRelVar( const Float_t f=0.                       ) { fExternalNumPhesRelVar = f; } 
     218  void SetNamePedestalCam      ( const char *name=fgNamePedestalCam.Data()) { fNamePedestalCam    = name; }
     219  void SetOutputPath           ( const TString path="."                   );
     220  void SetOutputFile           ( const TString file="ChargeCalibStat.txt" );
     221  void SetPheErrLowerLimit     ( const Float_t f=fgPheErrLowerLimit       ) { fPheErrLowerLimit  = f;    }
     222  void SetPheErrUpperLimit     ( const Float_t f=fgPheErrUpperLimit       ) { fPheErrUpperLimit  = f;    }   
     223  void SetPulserColor          ( const MCalibrationCam::PulserColor_t col ) { fPulserColor       = col;  }
    179224 
    180   void SetChargeLimit       ( const Float_t f=fgChargeLimit            ) { fChargeLimit       = f;     }
    181   void SetChargeErrLimit    ( const Float_t f=fgChargeErrLimit         ) { fChargeErrLimit    = f;     }
    182   void SetChargeRelErrLimit ( const Float_t f=fgChargeRelErrLimit      ) { fChargeRelErrLimit = f;     }
    183 
    184   // Checks
    185   void SetCheckArrivalTimes( const Bool_t b=kTRUE ) {
    186     b ? SETBIT(fCheckFlags,kCheckArrivalTimes)
    187       : CLRBIT(fCheckFlags,kCheckArrivalTimes); }
    188   void SetCheckDeadPixels( const Bool_t b=kTRUE ) {
    189     b ? SETBIT(fCheckFlags,kCheckDeadPixels)
    190       : CLRBIT(fCheckFlags,kCheckDeadPixels); }
    191   void SetCheckDeviatingBehavior( const Bool_t b=kTRUE ) {
    192     b ? SETBIT(fCheckFlags,kCheckDeviatingBehavior)
    193       : CLRBIT(fCheckFlags,kCheckDeviatingBehavior); }
    194   void SetCheckExtractionWindow( const Bool_t b=kTRUE ) {
    195     b ? SETBIT(fCheckFlags,kCheckExtractionWindow)
    196       : CLRBIT(fCheckFlags,kCheckExtractionWindow); }
    197   void SetCheckHistOverflow( const Bool_t b=kTRUE ) {
    198     b ? SETBIT(fCheckFlags,kCheckHistOverflow)
    199       : CLRBIT(fCheckFlags,kCheckHistOverflow); }
    200   void SetCheckOscillations( const Bool_t b=kTRUE ) {
    201     b ? SETBIT(fCheckFlags,kCheckOscillations)
    202       : CLRBIT(fCheckFlags,kCheckOscillations); }
    203   void SetDebug            ( const Bool_t b=kTRUE ) {
    204     b ? SETBIT(fFlags, kDebug)
    205       : CLRBIT(fFlags, kDebug); }
    206 
    207   void SetExtractor(MExtractor   *ext) { fExtractor=ext; }
    208   void SetPedestals(MPedestalCam *cam) { fPedestals=cam; }
    209                                                                          
    210   void SetArrTimeRmsLimit   ( const Float_t f=fgArrTimeRmsLimit        ) { fArrTimeRmsLimit   = f;     }
    211   void SetFFactorErrLimit   ( const Float_t f=fgFFactorErrLimit        ) { fFFactorErrLimit   = f;     }
    212   void SetLambdaErrLimit    ( const Float_t f=fgLambdaErrLimit         ) { fLambdaErrLimit    = f;     }
    213   void SetLambdaCheckLimit  ( const Float_t f=fgLambdaCheckLimit       ) { fLambdaCheckLimit  = f;     }
    214   void SetNamePedestalCam   ( const char *name=fgNamePedestalCam.Data()) { fNamePedestalCam   = name;  }
    215   void SetOutputPath        ( TString path="."                   );
    216   void SetOutputFile        ( TString file="ChargeCalibStat.txt" );
    217   void SetPheErrLowerLimit  ( const Float_t f=fgPheErrLowerLimit       ) { fPheErrLowerLimit  = f;     }
    218   void SetPheErrUpperLimit  ( const Float_t f=fgPheErrUpperLimit       ) { fPheErrUpperLimit  = f;     }
    219   void SetPulserColor       ( const MCalibrationCam::PulserColor_t col ) { fPulserColor       = col;   }
    220   void SetUseExtractorRes(Bool_t b=kTRUE) { fUseExtractorRes = b; }
    221 
    222   ClassDef(MCalibrationChargeCalc, 3)   // Task calculating Calibration Containers and Quantum Efficiencies
     225  ClassDef(MCalibrationChargeCalc, 4)   // Task calculating Calibration Containers and Quantum Efficiencies
    223226};
    224227
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h

    r7188 r7189  
    188188  Bool_t CalcMeanFFactor(const Float_t nphotons, const Float_t nphotonsrelvar);
    189189 
    190   ClassDef(MCalibrationChargePix, 3)    // Container Charge Calibration Results Pixel
     190  ClassDef(MCalibrationChargePix, 4)    // Container Charge Calibration Results Pixel
    191191};
    192192
  • trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc

    r7005 r7189  
    4141//           MCalibrationChargeBlindPix, MCalibrationChargePINDiode
    4242//
     43// Inline Functions:
     44// -----------------
     45//
     46// GetSize(): Returns the current size of the TOrdCollection fCams
     47//  independently if the MCalibrationCam is filled with values or not.
     48//
     49// GetAverageAreas(): Returns the current size of the TOrdCollection
     50//  fAverageAreas of the current camera.
     51//
     52// GetAverageArea(UInt_t i): Get i-th High Gain pixel Area from the
     53//  current camera
     54//
     55// GetAverageArea(UInt_t i): Get i-th High Gain pixel Area from the
     56//  current camera
     57//
     58// GetAverageBadArea(UInt_t i): Get i-th High Gain pixel Area from the
     59//  current camera
     60//
     61// GetAverageBadArea(UInt_t i): Get i-th High Gain pixel Area from the
     62//  current camera
     63//
     64// GetAverageSectors(): Returns the current size of the TOrdCollection
     65//  fAverageSectors or the current camera
     66//
     67// GetAverageSector(UInt_t i): Get i-th High Gain Sector from the
     68//  current camera
     69//
     70// GetAverageSector(UInt_t i): Get i-th High Gain Sector from the current
     71//  camera
     72//
     73// GetAverageBadSector(UInt_t i): Get i-th High Gain Sector from the
     74//  current camera
     75//
     76// GetAverageBadSector(UInt_t i): Get i-th High Gain Sector from the
     77//  current camera
     78//
     79//
    4380// ClassVersion 2:
    4481//  + fHists
     82//
     83// ClassVersion 3:
     84//  - MArrayD fOffsets;           //! Arrays of Higain-vs-LoGain fit result Offsets
     85//  - MArrayD fSlopes;            //! Arrays of Higain-vs-LoGain fit result Slopes
    4586//
    4687/////////////////////////////////////////////////////////////////////////////
     
    127168
    128169    MParContainer::Copy(calib);
    129 
    130     calib.fOffsets = fOffsets;
    131     calib.fSlopes  = fSlopes;
    132170
    133171    const UInt_t n = GetSize();
     
    163201}
    164202
    165 // -----------------------------------------------------
    166 //
    167 // Not yet installed...
    168 //
    169 void MCalibrationIntensityCam::DrawHiLoFits()
    170 {
    171 
    172   /*
    173   if (!fOffsets)
    174     fOffsets = new TH1D("pp","Offsets of the HiGain LoGain Fit",100,-600.,400.);
    175   if (!fSlopes)
    176     fSlopes  = new TH1D("mm","Slopes of the HiGain LoGain Fit",100,-2.,2.);
    177   if (!fOffvsSlope)
    178     fOffvsSlope = new TH2D("aa","Slopes vs Offsets of the HiGain LoGain Fit",100,-600.,400.,100,-2.,2.);
    179  
    180   TIter Next(fPixels);
    181   MCalibrationPix *pix;
    182   MHCalibrationPixel *hist;
    183   while ((pix=(MCalibrationPix*)Next()))
    184     {
    185       hist = pix->GetHist();
    186       hist->FitHiGainvsLoGain();
    187       fOffsets->Fill(hist->GetOffset(),1.);
    188       fSlopes->Fill(hist->GetSlope(),1.);
    189       fOffvsSlope->Fill(hist->GetOffset(),hist->GetSlope(),1.);
    190     }
    191 
    192    TCanvas *c1 = new TCanvas();
    193 
    194    c1->Divide(1,3);
    195    c1->cd(1);
    196    fOffsets->Draw();
    197    gPad->Modified();
    198    gPad->Update();
    199 
    200    c1->cd(2);
    201   fSlopes->Draw();
    202   gPad->Modified();
    203   gPad->Update();
    204 
    205   c1->cd(3);
    206   fOffvsSlope->Draw("col1");
    207   gPad->Modified();
    208   gPad->Update();
    209   */
    210 }
    211 
    212203// -------------------------------------------------------------------
    213204//
     
    256247}
    257248
    258 
    259 // --------------------------------------------------------------------------
    260 //
    261 // Returns the current size of the TOrdCollection fCams
    262 // independently if the MCalibrationCam is filled with values or not.
    263 //
    264 const Int_t MCalibrationIntensityCam::GetSize() const
    265 {
    266   return fCams->GetSize();
    267 }
    268 
    269 // --------------------------------------------------------------------------
    270 //
    271 // Get i-th pixel from current camera
    272 //
    273 MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i)
    274 {
    275   return (*GetCam())[i];
    276 }
    277 
    278 // --------------------------------------------------------------------------
    279 //
    280 // Get i-th pixel from current camera
    281 //
    282 const MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i) const
    283 {
    284   return (*GetCam())[i];
    285 }
    286 
    287 
    288 // --------------------------------------------------------------------------
    289 //
    290 // Returns the current size of the TOrdCollection fAverageAreas of the current camera.
    291 //
    292 const Int_t MCalibrationIntensityCam::GetAverageAreas() const
    293 {
    294   return GetCam()->GetAverageAreas();
    295 }
    296 
    297 // --------------------------------------------------------------------------
    298 //
    299 // Get i-th High Gain pixel Area from the current camera
    300 //
    301 MCalibrationPix  &MCalibrationIntensityCam::GetAverageArea(UInt_t i)
    302 {
    303   return GetCam()->GetAverageArea(i);
    304 }
    305 
    306 // --------------------------------------------------------------------------
    307 //
    308 // Get i-th High Gain pixel Area from the current camera
    309 //
    310 const MCalibrationPix  &MCalibrationIntensityCam::GetAverageArea(UInt_t i) const
    311 {
    312   return GetCam()->GetAverageArea(i);
    313 }
    314 
    315 // --------------------------------------------------------------------------
    316 //
    317 // Get i-th High Gain pixel Area from the current camera
    318 //
    319 MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i)
    320 {
    321   return GetCam()->GetAverageBadArea(i);
    322 }
    323 
    324 // --------------------------------------------------------------------------
    325 //
    326 // Get i-th High Gain pixel Area from the current camera
    327 //
    328 const MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i) const
    329 {
    330   return GetCam()->GetAverageBadArea(i);
    331 }
    332 
    333 // --------------------------------------------------------------------------
    334 //
    335 // Returns the current size of the TOrdCollection fAverageSectors or the current camera
    336 //
    337 const Int_t MCalibrationIntensityCam::GetAverageSectors() const
    338 {
    339   return GetCam()->GetAverageSectors();
    340 }
    341 
    342 // --------------------------------------------------------------------------
    343 //
    344 // Get i-th High Gain Sector from the current camera
    345 //
    346 MCalibrationPix  &MCalibrationIntensityCam::GetAverageSector(UInt_t i)
    347 {
    348   return GetCam()->GetAverageSector(i);
    349 }
    350 
    351 // --------------------------------------------------------------------------
    352 //
    353 // Get i-th High Gain Sector from the current camera
    354 //
    355 const MCalibrationPix  &MCalibrationIntensityCam::GetAverageSector(UInt_t i) const
    356 {
    357   return GetCam()->GetAverageSector(i);
    358 }
    359 
    360 // --------------------------------------------------------------------------
    361 //
    362 // Get i-th High Gain Sector from the current camera
    363 //
    364 MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i)
    365 {
    366   return GetCam()->GetAverageBadSector(i);
    367 }
    368 
    369 // --------------------------------------------------------------------------
    370 //
    371 // Get i-th High Gain Sector from the current camera
    372 //
    373 const MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i) const
    374 {
    375   return GetCam()->GetAverageBadSector(i);
    376 }
    377 
    378 
    379 // --------------------------------------------------------------------------
    380 //
    381 // Get i-th camera
    382 //
    383 MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i)
    384 {
    385   return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i));
    386 }
    387 
    388 // --------------------------------------------------------------------------
    389 //
    390 // Get i-th camera
    391 //
    392 const MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i) const
    393 {
    394   return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i));
    395 }
    396 
    397 // --------------------------------------------------------------------------
    398 //
    399 // Get camera with name 'name'
    400 //
    401 MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name )
    402 {
    403   return static_cast<MCalibrationCam*>(fCams->FindObject(name));
    404 }
    405 
    406 // --------------------------------------------------------------------------
    407 //
    408 // Get camera with name 'name'
    409 //
    410 const MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name ) const
    411 {
    412   return static_cast<MCalibrationCam*>(fCams->FindObject(name));
    413 }
    414 
    415 // --------------------------------------------------------------------------
    416 //
    417 // Calls GetPixelContent for the current entry in fCams
    418 //
    419 Bool_t MCalibrationIntensityCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
    420 {
    421   return GetCam()->GetPixelContent(val,idx,cam,type);
    422 }
    423 
    424 // --------------------------------------------------------------------------
    425 //
    426 // Calls DrawPixelContent for the current entry in fCams
    427 //
    428 void MCalibrationIntensityCam::DrawPixelContent( Int_t num ) const
    429 {
    430   return GetCam()->DrawPixelContent(num);
    431 }
    432 
    433 Int_t MCalibrationIntensityCam::CountNumEntries(const MCalibrationCam::PulserColor_t col) const
     249// --------------------------------------------------------------------------
     250//
     251Int_t MCalibrationIntensityCam::CountNumEntries(const MCalibrationCam::PulserColor_t col) const
    434252{
    435253 
     
    451269// --------------------------------------------------------------------------
    452270//
     271// Get i-th pixel from current camera
     272//
     273MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i)
     274{
     275  return (*GetCam())[i];
     276}
     277
     278// --------------------------------------------------------------------------
     279//
     280// Get i-th pixel from current camera
     281//
     282const MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i) const
     283{
     284  return (*GetCam())[i];
     285}
     286
     287// --------------------------------------------------------------------------
     288//
     289// Get camera with name 'name'
     290//
     291MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name)
     292{
     293  return static_cast<MCalibrationCam*>(fCams->FindObject(name));
     294}
     295
     296// --------------------------------------------------------------------------
     297//
     298// Get camera with name 'name'
     299//
     300const MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name) const
     301{
     302  return static_cast<MCalibrationCam*>(fCams->FindObject(name));
     303}
     304
     305// --------------------------------------------------------------------------
     306//
    453307// Get i-th histogram class
    454308//
    455309MHCalibrationCam *MCalibrationIntensityCam::GetHist(Int_t i)
    456310{
    457     return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
    458 }
    459 
    460 // --------------------------------------------------------------------------
    461 //
    462 // Get i-th histogram class
    463 //
    464 const MHCalibrationCam *MCalibrationIntensityCam::GetHist(Int_t i) const
    465 {
    466     return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
    467 }
    468 
    469 // --------------------------------------------------------------------------
    470 //
    471 // Get histogram class with name 'name'
     311  return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
     312}
     313
     314// --------------------------------------------------------------------------
     315//
     316// Get i-th histogram class 
     317//
     318const MHCalibrationCam *MCalibrationIntensityCam::GetHist(Int_t i) const 
     319{
     320  return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
     321}
     322
     323// --------------------------------------------------------------------------
     324//
     325// Get histogram class with name 'name' 
    472326//
    473327MHCalibrationCam *MCalibrationIntensityCam::GetHist(const char *name )
     
    478332// --------------------------------------------------------------------------
    479333//
    480 // Get histogram class with name 'name'
    481 //
    482 const MHCalibrationCam *MCalibrationIntensityCam::GetHist(const char *name ) const
    483 {
    484     return static_cast<MHCalibrationCam*>(fHists->FindObject(name));
    485 }
     334// Get histogram class with name 'name'
     335//
     336const MHCalibrationCam *MCalibrationIntensityCam::GetHist(const char *name ) const
     337{
     338  return static_cast<MHCalibrationCam*>(fHists->FindObject(name));
     339}
     340
     341// --------------------------------------------------------------------------
     342//
     343// Calls DrawPixelContent for the current entry in fCams
     344//
     345void MCalibrationIntensityCam::DrawPixelContent( Int_t num ) const
     346{
     347  return GetCam()->DrawPixelContent(num);
     348}
  • trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.h

    r7005 r7189  
    1414#endif
    1515
    16 class TOrdCollection;
     16#ifndef ROOT_TOrdCollection
     17#include <TOrdCollection.h>
     18#endif
     19
    1720class MCalibrationPix;
    1821class MBadPixelsPix;
     
    2225class MCalibrationIntensityCam : public MParContainer, public MCamEvent
    2326{
    24 private:
    25   MArrayD fOffsets;        //! Arrays of Higain-vs-LoGain fit result Offsets
    26   MArrayD fSlopes;         //! Arrays of Higain-vs-LoGain fit result Slopes
    27 
    2827protected: 
    2928  TOrdCollection *fCams;   // Array of MCalibrationCams, one per pulse colour and intensity
     
    4544  Int_t CountNumEntries(const MCalibrationCam::PulserColor_t col) const; 
    4645
    47   // Draws
    48   void DrawHiLoFits();
    49   void DrawPixelContent( Int_t num) const;
    50  
    51   // Getters
    52   Bool_t GetPixelContent( Double_t &val, Int_t idx, const MGeomCam &cam,Int_t type=0) const;
    53   const Int_t GetSize() const;
     46  const Int_t GetSize() const  { return fCams->GetSize();  }
    5447
    55   const Int_t            GetAverageAreas     ()            const;       
    56         MCalibrationPix &GetAverageArea      ( UInt_t i );
    57   const MCalibrationPix &GetAverageArea      ( UInt_t i )  const;
    58         MBadPixelsPix   &GetAverageBadArea   ( UInt_t i );
    59   const MBadPixelsPix   &GetAverageBadArea   ( UInt_t i )  const;
    60   const Int_t            GetAverageSectors   ()            const;
    61         MCalibrationPix &GetAverageSector    ( UInt_t i );
    62   const MCalibrationPix &GetAverageSector    ( UInt_t i )  const;
    63         MBadPixelsPix   &GetAverageBadSector ( UInt_t i );
    64   const MBadPixelsPix   &GetAverageBadSector ( UInt_t i )  const;
     48  const Int_t            GetAverageAreas     ()            const   { return GetCam()->GetAverageAreas(); }
     49        MCalibrationPix &GetAverageArea      ( UInt_t i )          { return GetCam()->GetAverageArea(i);  }
     50  const MCalibrationPix &GetAverageArea      ( UInt_t i )  const   { return GetCam()->GetAverageArea(i);  }
     51        MBadPixelsPix   &GetAverageBadArea   ( UInt_t i )          { return GetCam()->GetAverageBadArea(i); } 
     52  const MBadPixelsPix   &GetAverageBadArea   ( UInt_t i )  const   { return GetCam()->GetAverageBadArea(i); }
     53  const Int_t            GetAverageSectors   ()            const   { return GetCam()->GetAverageSectors();  }
     54        MCalibrationPix &GetAverageSector    ( UInt_t i )          { return GetCam()->GetAverageSector(i);  }
     55  const MCalibrationPix &GetAverageSector    ( UInt_t i )  const   { return GetCam()->GetAverageSector(i);  }
     56        MBadPixelsPix   &GetAverageBadSector ( UInt_t i )          { return GetCam()->GetAverageBadSector(i); }
     57  const MBadPixelsPix   &GetAverageBadSector ( UInt_t i )  const   { return GetCam()->GetAverageBadSector(i); }
    6558
    66         MCalibrationCam *GetCam              ( Int_t i=-1);
    67   const MCalibrationCam *GetCam              ( Int_t i=-1) const;
     59        MCalibrationCam *GetCam              ( Int_t i=-1)       {
     60        return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i)); }
     61  const MCalibrationCam *GetCam              ( Int_t i=-1) const {
     62        return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i)); }
    6863
    6964        MCalibrationCam *GetCam              ( const char *name );
    7065  const MCalibrationCam *GetCam              ( const char *name ) const;
    7166
    72         MHCalibrationCam *GetHist            ( Int_t i=-1);
     67        MHCalibrationCam *GetHist            ( Int_t i=-1);     
    7368  const MHCalibrationCam *GetHist            ( Int_t i=-1) const;
    7469
    75         MHCalibrationCam *GetHist            ( const char *name );
     70        MHCalibrationCam *GetHist            ( const char *name );     
    7671  const MHCalibrationCam *GetHist            ( const char *name ) const;
    7772
     
    8782  void  Init   ( const MGeomCam &geom );
    8883 
    89   // Prints
     84   // Prints
    9085  void   Print(Option_t *o="")         const;
    9186
     
    9691  void  SetNumUnreliable      ( const UInt_t i,  const Int_t aidx  ) { GetCam()->SetNumUnreliable(i,aidx);       }
    9792  void  SetPulserColor        ( const MCalibrationCam::PulserColor_t col=MCalibrationCam::kCT1) {
    98                                                                 GetCam()->SetPulserColor(col);            }
     93                                                                       GetCam()->SetPulserColor(col);            }
     94  void  SetCam( MCalibrationCam *cam, const Int_t i)                 {  fCams->PutAt(cam,i);  }
     95 
     96  // MCamEvent
     97  Bool_t GetPixelContent( Double_t &val, Int_t idx, const MGeomCam &cam,Int_t type=0) const
     98        { return GetCam()->GetPixelContent(val,idx,cam,type);  }
     99  void DrawPixelContent( Int_t num) const;
    99100
    100   ClassDef(MCalibrationIntensityCam, 2) // Base Container Intensity Calibration Results
     101  ClassDef(MCalibrationIntensityCam, 3) // Base Container Intensity Calibration Results
    101102};
    102103
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationHiLoCam.cc

    r7095 r7189  
    8181/////////////////////////////////////////////////////////////////////////////
    8282#include "MHCalibrationHiLoCam.h"
    83 #include "MHCalibrationPix.h"
    84 
    85 #include "MLog.h"
    86 #include "MLogManip.h"
    87 
    88 #include "MParList.h"
    89 
    90 #include "MCalibrationHiLoCam.h"
    91 #include "MCalibrationCam.h"
    92 #include "MCalibrationPix.h"
    93 
    94 #include "MExtractedSignalCam.h"
    95 #include "MExtractedSignalPix.h"
    96 #include "MArrivalTimeCam.h"
    97 #include "MArrivalTimePix.h"
    98 
    99 #include "MGeomCam.h"
    100 #include "MGeomPix.h"
    101 
    102 #include "MBadPixelsIntensityCam.h"
    103 #include "MBadPixelsCam.h"
    104 #include "MBadPixelsPix.h"
    10583
    10684#include <TOrdCollection.h>
     
    11492#include <TLegend.h>
    11593#include <TGraph.h>
     94#include <TProfile.h>
     95
     96#include "MHCalibrationHiLoPix.h"
     97
     98#include "MLog.h"
     99#include "MLogManip.h"
     100
     101#include "MParList.h"
     102
     103#include "MCalibrationHiLoCam.h"
     104#include "MCalibrationHiLoPix.h"
     105#include "MCalibrationCam.h"
     106#include "MCalibrationIntensityCam.h"
     107#include "MCalibrationPix.h"
     108
     109#include "MExtractedSignalCam.h"
     110#include "MExtractedSignalPix.h"
     111#include "MArrivalTimeCam.h"
     112#include "MArrivalTimePix.h"
     113
     114#include "MGeomCam.h"
     115#include "MGeomPix.h"
     116
     117#include "MBadPixelsIntensityCam.h"
     118#include "MBadPixelsCam.h"
     119#include "MBadPixelsPix.h"
    116120
    117121ClassImp(MHCalibrationHiLoCam);
     
    123127const Axis_t  MHCalibrationHiLoCam::fgLast     = 29.9;
    124128const Float_t MHCalibrationHiLoCam::fgProbLimit = 0.;
     129const Int_t   MHCalibrationHiLoCam::fgHivsLoNbins = 90;
     130const Axis_t  MHCalibrationHiLoCam::fgHivsLoFirst = 95.;
     131const Axis_t  MHCalibrationHiLoCam::fgHivsLoLast  = 995.;
     132const Axis_t  MHCalibrationHiLoCam::fgLowerFitLimitProfile = 480.;
     133const Axis_t  MHCalibrationHiLoCam::fgUpperFitLimitProfile = 680.;
    125134const TString MHCalibrationHiLoCam::gsHistName  = "HiLo";
    126135const TString MHCalibrationHiLoCam::gsHistTitle = "HiGain vs. LoGain";
    127136const TString MHCalibrationHiLoCam::gsHistXTitle = "Amplification Ratio [1]";
    128137const TString MHCalibrationHiLoCam::gsHistYTitle = "Nr. events";
     138const TString MHCalibrationHiLoCam::gsHivsLoHistName   = "HivsLo";
     139const TString MHCalibrationHiLoCam::gsHivsLoHistTitle  = "High-gain vs. Low-gain Charge";
     140const TString MHCalibrationHiLoCam::gsHivsLoHistXTitle = "Q High-Gain [FADC counts]";
     141const TString MHCalibrationHiLoCam::gsHivsLoHistYTitle = "Q Low-Gain [FADC counts]";
    129142
    130143// --------------------------------------------------------------------------
     
    146159//
    147160MHCalibrationHiLoCam::MHCalibrationHiLoCam(const char *name, const char *title)
    148   : fArrTimes(NULL)
     161  : fArrTimes(NULL), fHivsLoResults("Results","Fit Results high-gain vs. low-gain",
     162                                    200,-10.,10.,200,0.,20.),
     163    fUsedLoGainSlices(0)
    149164{
    150165
     
    163178  SetHistYTitle(gsHistYTitle.Data());
    164179
     180  SetHivsLoNbins(fgHivsLoNbins);
     181  SetHivsLoFirst(fgHivsLoFirst);
     182  SetHivsLoLast (fgHivsLoLast );
     183
     184  SetLowerFitLimitProfile();
     185  SetUpperFitLimitProfile();
     186
     187  SetHivsLoHistName  (gsHivsLoHistName  .Data());
     188  SetHivsLoHistTitle (gsHivsLoHistTitle .Data());
     189  SetHivsLoHistXTitle(gsHivsLoHistXTitle.Data());
     190  SetHivsLoHistYTitle(gsHivsLoHistYTitle.Data());
     191
    165192  SetOscillations(kFALSE);
     193 
     194  fHivsLoResults.GetXaxis()->SetTitle("Offset per FADC slices [FADC cnts]");
     195  fHivsLoResults.GetYaxis()->SetTitle("Gains ratio [1]");
     196  fHivsLoResults.SetDirectory(0);
     197
    166198}
    167199
     
    254286  }
    255287
     288  fUsedLoGainSlices = signal->GetNumUsedLoGainFADCSlices();
     289
    256290  fArrTimes = (MArrivalTimeCam*)pList->FindObject("MArrivalTimeCam");
    257291  if (!fArrTimes)
     
    282316  return kTRUE;
    283317}
     318
     319// --------------------------------------------------------------------------
     320//
     321// Retrieve:
     322// - fRunHeader->GetNumSamplesHiGain();
     323//
     324// Initializes the High Gain Arrays:
     325//
     326// - For every entry in the expanded arrays:
     327//   * Initialize an MHCalibrationHiLoPix
     328//   * Set Binning from  fNbins, fFirst and fLast
     329//   * Set Binning of Abs Times histogram from  fAbsNbins, fAbsFirst and fAbsLast
     330//   * Set Histgram names and titles from fHistName and fHistTitle
     331//   * Set Abs Times Histgram names and titles from fAbsHistName and fAbsHistTitle
     332//   * Set X-axis and Y-axis titles from fHistXTitle and fHistYTitle
     333//   * Set X-axis and Y-axis titles of Abs Times Histogram from fAbsHistXTitle and fAbsHistYTitle
     334//   * Call InitHists
     335//
     336//
     337void MHCalibrationHiLoCam::InitHiGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
     338{
     339 
     340  TProfile *h;
     341
     342  if (fHiGainArray->GetSize()==0)
     343  {
     344      for (Int_t i=0; i<npixels; i++)
     345      {
     346        fHiGainArray->AddAt(new MHCalibrationHiLoPix(Form("%sHiGainPix%04d",fHistName.Data(),i),
     347                                                       Form("%s High Gain Pixel%04d",fHistTitle.Data(),i)),i);
     348
     349        MHCalibrationHiLoPix &pix = (MHCalibrationHiLoPix&)(*this)[i];
     350
     351        pix.SetNbins(fNbins);
     352        pix.SetFirst(fFirst);
     353        pix.SetLast (fLast);
     354
     355        pix.SetProbLimit(fProbLimit);
     356
     357        pix.SetHivsLoNbins(fHivsLoNbins);
     358        pix.SetHivsLoFirst(fHivsLoFirst);
     359        pix.SetHivsLoLast (fHivsLoLast);
     360
     361        InitHists(pix,(*fBadPixels)[i],i);
     362
     363        if (fCam)
     364          (*fCam)[i].SetPixId(i);
     365
     366        h = pix.GetHivsLo();
     367
     368        h->SetName (Form("H%sHiGainPix%04d",fHivsLoHistName.Data(),i));
     369        h->SetTitle(Form("%s High Gain Pixel %04d",fHivsLoHistTitle.Data(),i));
     370        h->SetXTitle(fHivsLoHistXTitle.Data());
     371        h->SetYTitle(fHivsLoHistYTitle.Data());
     372        h->SetDirectory(0);
     373      }
     374  }
     375
     376
     377  if (fAverageHiGainAreas->GetSize()==0)
     378  {
     379    for (Int_t j=0; j<nareas; j++)
     380      {
     381        fAverageHiGainAreas->AddAt(new MHCalibrationHiLoPix(Form("%sHiGainArea%d",fHistName.Data(),j),
     382                                                  Form("%s High Gain Area Idx %d",fHistTitle.Data(),j)),j);
     383       
     384        MHCalibrationHiLoPix &pix = (MHCalibrationHiLoPix&)GetAverageHiGainArea(j);
     385       
     386        pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
     387        pix.SetFirst(fFirst);
     388        pix.SetLast (fLast);
     389       
     390        pix.SetHivsLoNbins(fHivsLoNbins);
     391        pix.SetHivsLoFirst(fHivsLoFirst);
     392        pix.SetHivsLoLast (fHivsLoLast);
     393
     394        InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
     395
     396        if (fCam)
     397          fCam->GetAverageArea(j).SetPixId(j);
     398
     399        h =  pix.GetHivsLo();
     400       
     401        h->SetName (Form("H%sHiGainArea%d",fHivsLoHistName.Data(),j));
     402        h->SetTitle(Form("%s averaged on event-by-event basis High Gain Area Idx %d",
     403                         fHivsLoHistTitle.Data(), j));
     404        h->SetXTitle(fHivsLoHistXTitle.Data());
     405        h->SetYTitle(fHivsLoHistYTitle.Data());
     406        h->SetDirectory(0);
     407      }
     408  }
     409 
     410  if (fAverageHiGainSectors->GetSize()==0)
     411  {
     412      for (Int_t j=0; j<nsectors; j++)
     413        {
     414          fAverageHiGainSectors->AddAt(new MHCalibrationHiLoPix(Form("%sHiGainSector%02d",fHistName.Data(),j),
     415                                                      Form("%s High Gain Sector %02d",fHistTitle.Data(),j)),j);
     416
     417          MHCalibrationHiLoPix &pix = (MHCalibrationHiLoPix&)GetAverageHiGainSector(j);
     418
     419          pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
     420          pix.SetFirst(fFirst);
     421          pix.SetLast (fLast);
     422
     423          pix.SetHivsLoNbins(fHivsLoNbins);
     424          pix.SetHivsLoFirst(fHivsLoFirst);
     425          pix.SetHivsLoLast (fHivsLoLast);
     426         
     427          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
     428
     429          if (fCam)
     430            fCam->GetAverageSector(j).SetPixId(j);
     431
     432          h =  pix.GetHivsLo();
     433         
     434          h->SetName (Form("H%sHiGainSector%02d",fHivsLoHistName.Data(),j));
     435          h->SetTitle(Form("%s averaged on event-by-event basis High Gain Area Sector %02d",
     436                           fHivsLoHistTitle.Data(),j));
     437          h->SetXTitle(fHivsLoHistXTitle.Data());
     438          h->SetYTitle(fHivsLoHistYTitle.Data());
     439          h->SetDirectory(0);
     440      }
     441  }
     442}
     443
     444//--------------------------------------------------------------------------------------
     445//
     446// Return, if IsLoGain() is kFALSE
     447//
     448// Retrieve:
     449// - fRunHeader->GetNumSamplesHiGain();
     450//
     451// Initializes the Low Gain Arrays:
     452//
     453// - For every entry in the expanded arrays:
     454//   * Initialize an MHCalibrationHiLoPix
     455//   * Set Binning from  fNbins, fFirst and fLast
     456//   * Set Binning of HivsLo Times histogram from  fHivsLoNbins, fHivsLoFirst and fHivsLoLast
     457//   * Set Histgram names and titles from fHistName and fHistTitle
     458//   * Set HivsLo Times Histgram names and titles from fHivsLoHistName and fHivsLoHistTitle
     459//   * Set X-axis and Y-axis titles from fHistXTitle and fHistYTitle
     460//   * Set X-axis and Y-axis titles of HivsLo Times Histogram from fHivsLoHistXTitle and fHivsLoHistYTitle
     461//   * Call InitHists
     462//
     463void MHCalibrationHiLoCam::InitLoGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
     464{
     465  if (!IsLoGain())
     466    return;
     467
     468  TProfile *h;
     469
     470  if (fLoGainArray->GetSize()==0 )
     471    {
     472      for (Int_t i=0; i<npixels; i++)
     473        {
     474          fLoGainArray->AddAt(new MHCalibrationHiLoPix(Form("%sLoGainPix%04d",fHistName.Data(),i),
     475                                       Form("%s Low Gain Pixel %04d",fHistTitle.Data(),i)),i);
     476
     477          MHCalibrationHiLoPix &pix = (MHCalibrationHiLoPix&)(*this)(i);
     478
     479          pix.SetNbins(fNbins);
     480          pix.SetFirst(fFirst);
     481          pix.SetLast (fLast);
     482         
     483          pix.SetProbLimit(fProbLimit);
     484
     485          pix.SetHivsLoNbins(fHivsLoNbins);
     486          pix.SetHivsLoFirst(fHivsLoFirst);
     487          pix.SetHivsLoLast (fHivsLoLast );
     488         
     489          InitHists(pix,(*fBadPixels)[i],i);
     490
     491          h = pix.GetHivsLo();
     492         
     493          h->SetName (Form("H%sLoGainPix%04d",fHivsLoHistName.Data(),i));
     494          h->SetTitle(Form("%s Low Gain Pixel %04d",fHivsLoHistTitle.Data(),i));
     495          h->SetXTitle(fHivsLoHistXTitle.Data());
     496          h->SetYTitle(fHivsLoHistYTitle.Data());
     497          h->SetDirectory(0);
     498      }
     499  }
     500
     501  if (fAverageLoGainAreas->GetSize()==0)
     502    {
     503      for (Int_t j=0; j<nareas; j++)
     504        {
     505          fAverageLoGainAreas->AddAt(new MHCalibrationHiLoPix(Form("%sLoGainArea%d",fHistName.Data(),j),
     506                                       Form("%s Low Gain Area Idx %d",fHistTitle.Data(),j)),j);
     507       
     508          MHCalibrationHiLoPix &pix = (MHCalibrationHiLoPix&)GetAverageLoGainArea(j);
     509         
     510          pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
     511          pix.SetFirst(fFirst);
     512          pix.SetLast (fLast);
     513         
     514          pix.SetHivsLoNbins(fHivsLoNbins);
     515          pix.SetHivsLoFirst(fHivsLoFirst);
     516          pix.SetHivsLoLast (fHivsLoLast );
     517         
     518          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
     519
     520          h =  pix.GetHivsLo();
     521         
     522          h->SetName (Form("H%sLoGainArea%02d",fHivsLoHistName.Data(),j));
     523          h->SetTitle(Form("%s%s%02d",fHivsLoHistTitle.Data(),
     524                           " averaged on event-by-event basis Low Gain Area Idx ",j));
     525          h->SetXTitle(fHivsLoHistXTitle.Data());
     526          h->SetYTitle(fHivsLoHistYTitle.Data());
     527          h->SetDirectory(0);
     528        }
     529    }
     530 
     531
     532  if (fAverageLoGainSectors->GetSize()==0 && IsLoGain())
     533  {
     534    for (Int_t j=0; j<nsectors; j++)
     535      {
     536        fAverageLoGainSectors->AddAt(new MHCalibrationHiLoPix(Form("%sLoGainSector%02d",fHistName.Data(),j),
     537                                                        Form("%s Low Gain Sector %02d",fHistTitle.Data(),j)),j);
     538       
     539        MHCalibrationHiLoPix &pix = (MHCalibrationHiLoPix&)GetAverageLoGainSector(j);
     540       
     541        pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
     542        pix.SetFirst(fFirst);
     543        pix.SetLast (fLast);
     544       
     545        pix.SetHivsLoNbins(fHivsLoNbins);
     546        pix.SetHivsLoFirst(fHivsLoFirst);
     547        pix.SetHivsLoLast (fHivsLoLast);
     548       
     549        InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
     550
     551        h =  pix.GetHivsLo();
     552       
     553        h->SetName (Form("H%sLoGainSector%02d",fHivsLoHistName.Data(),j));
     554        h->SetTitle(Form("%s%s%02d",fHivsLoHistTitle.Data(),
     555                           " averaged on event-by-event basis Low Gain Area Sector ",j));
     556        h->SetXTitle(fHivsLoHistXTitle.Data());
     557        h->SetYTitle(fHivsLoHistYTitle.Data());
     558        h->SetDirectory(0);
     559      }
     560  }
     561}
     562
     563
    284564
    285565// -------------------------------------------------------------------------------
     
    341621
    342622      const Float_t sighi = pix.GetExtractedSignalHiGain();
     623
     624      //      *fLog << err << sighi << "  " << siglo << endl;
    343625      const Float_t ratio = sighi / siglo;
    344626     
    345       MHCalibrationPix &histhi = (*this)[i];
     627      MHCalibrationHiLoPix &histhi = (MHCalibrationHiLoPix&)(*this)[i];
    346628
    347629      histhi.FillHist(ratio);
     630      histhi.FillHivsLo(sighi,siglo);
     631
     632      if (IsAverageing())
     633        {
     634          MHCalibrationHiLoPix &histhi = (MHCalibrationHiLoPix&)GetAverageHiGainArea(aidx);
     635          histhi.FillHivsLo(sighi,siglo);
     636        }
     637
    348638      fSumareahi  [aidx]   += ratio;
    349639      fNumareahi  [aidx]   ++;
     
    371661  for (Int_t j=0; j<nareas; j++)
    372662    {
    373       MHCalibrationPix &histhi = GetAverageHiGainArea(j);
     663
     664      MHCalibrationHiLoPix &histhi = (MHCalibrationHiLoPix&)GetAverageHiGainArea(j);
     665     
    374666      if (IsOscillations())
    375667        histhi.FillHistAndArray(fNumareahi[j] == 0 ? 0. : fSumareahi[j]/fNumareahi[j]);
     
    390682    {
    391683      MHCalibrationPix &hist = GetAverageHiGainSector(j);
     684
    392685      if (IsOscillations())
    393686        hist.FillHistAndArray(fNumsectorhi[j] == 0 ? 0. : fSumsectorhi[j]/fNumsectorhi[j]);
     
    397690      if (IsLoGain())
    398691        {
     692
    399693          MHCalibrationPix &histlo = GetAverageLoGainSector(j);
     694
    400695          if (IsOscillations())
    401696            histlo.FillHistAndArray(fNumsectorlo[j] == 0 ? 0. : fSumsectorlo[j]/fNumsectorlo[j]);
     
    425720
    426721  const Int_t nareas   = fAverageHiGainAreas->GetSize();
    427   const Int_t nsectors = fAverageHiGainSectors->GetSize();
    428722
    429723  for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
    430724    {
    431725     
    432       MHCalibrationPix &hist = (*this)[i];
     726      MHCalibrationHiLoPix &hist = (MHCalibrationHiLoPix&)(*this)[i];
    433727
    434728      if (hist.IsExcluded())
     
    436730     
    437731      CheckOverflow(hist);
     732
     733      TProfile *h = hist.GetHivsLo();
     734      h->Fit("pol1","RQ","",fLowerFitLimitProfile,fUpperFitLimitProfile);
     735
     736      TF1 *fit = h->GetFunction("pol1");
     737
     738      const Float_t gainr  = fit->GetParameter(1) > 0.001
     739        ? 1./fit->GetParameter(1)
     740        : 0.;
     741      const Float_t offset = fit->GetParameter(0)/fUsedLoGainSlices;
     742
     743      fHivsLoResults.Fill(offset,gainr);
     744     
     745      MCalibrationHiLoPix &pix = (MCalibrationHiLoPix&)(*fCam)[i];
     746      pix.SetOffsetPerSlice(offset);
     747      pix.SetGainRatio     (gainr );
     748
    438749    }
    439750
     
    472783  {
    473784      for (Int_t j=0; j<nareas; j++)
    474           CheckOverflow(GetAverageLoGainArea(j));
    475 
    476       for (Int_t j=0; j<nsectors; j++)
    477           CheckOverflow(GetAverageLoGainSector(j));
     785        {
     786         
     787          MHCalibrationHiLoPix &hist = (MHCalibrationHiLoPix&)GetAverageHiGainArea(j);
     788          //
     789          // Check histogram overflow
     790          //
     791          CheckOverflow(hist);
     792         
     793          TProfile *h = hist.GetHivsLo();
     794          h->Fit("pol1","RQ","",fLowerFitLimitProfile,fUpperFitLimitProfile);
     795
     796          TF1 *fit = h->GetFunction("pol1");
     797         
     798          const Float_t gainr  = fit->GetParameter(1) > 0.001
     799            ? 1./fit->GetParameter(1)
     800            : 0.;
     801          const Float_t offset = fit->GetParameter(0)/fUsedLoGainSlices;
     802         
     803          MCalibrationHiLoPix &pix = (MCalibrationHiLoPix&)fCam->GetAverageArea(0);
     804          pix.SetOffsetPerSlice(offset);
     805          pix.SetGainRatio     (gainr );
     806
     807        }
     808     
     809      for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
     810        {
     811         
     812          MHCalibrationHiLoPix &hist = (MHCalibrationHiLoPix&)GetAverageHiGainSector(j);     
     813          //
     814          // Check histogram overflow
     815          //
     816          CheckOverflow(hist);
     817
     818          TProfile *h = hist.GetHivsLo();
     819          h->Fit("pol1","RQ","",fLowerFitLimitProfile,fUpperFitLimitProfile);
     820
     821          TF1 *fit = h->GetFunction("pol1");
     822         
     823          const Float_t gainr  = fit->GetParameter(1) > 0.001
     824            ? 1./fit->GetParameter(1)
     825            : 0.;
     826          const Float_t offset = fit->GetParameter(0)/fUsedLoGainSlices;
     827         
     828          MCalibrationHiLoPix &pix = (MCalibrationHiLoPix&)fCam->GetAverageSector(0);
     829          pix.SetOffsetPerSlice(offset);
     830          pix.SetGainRatio     (gainr );
     831
     832        }
    478833  }
    479834
     
    6801035}
    6811036
     1037Int_t MHCalibrationHiLoCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     1038{
     1039
     1040  Bool_t rc = kFALSE;
     1041
     1042  if (MHCalibrationCam::ReadEnv(env,prefix,print))
     1043    rc = kTRUE;
     1044   
     1045  if (IsEnvDefined(env, prefix, "LowerFitLimitProfile", print))
     1046    {
     1047      SetLowerFitLimitProfile(GetEnvValue(env, prefix, "LowerFitLimitProfile", fLowerFitLimitProfile));
     1048      rc = kTRUE;
     1049    }
     1050 
     1051  if (IsEnvDefined(env, prefix, "UpperFitLimitProfile", print))
     1052    {
     1053      SetUpperFitLimitProfile(GetEnvValue(env, prefix, "UpperFitLimitProfile", fUpperFitLimitProfile));
     1054      rc = kTRUE;
     1055    }
     1056 
     1057  if (IsEnvDefined(env, prefix, "HivsLoNbins", print))
     1058    {
     1059      SetHivsLoNbins(GetEnvValue(env, prefix, "HivsLoNbins", fHivsLoNbins));
     1060      rc = kTRUE;
     1061    }
     1062 
     1063  if (IsEnvDefined(env, prefix, "HivsLoFirst", print))
     1064    {
     1065      SetHivsLoFirst(GetEnvValue(env, prefix, "HivsLoFirst", fHivsLoFirst));
     1066      rc = kTRUE;
     1067    }
     1068 
     1069  if (IsEnvDefined(env, prefix, "HivsLoLast", print))
     1070    {
     1071      SetHivsLoLast(GetEnvValue(env, prefix, "HivsLoLast", fHivsLoLast));
     1072      rc = kTRUE;
     1073    }
     1074 
     1075  return rc;
     1076}
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationHiLoCam.h

    r7095 r7189  
    1414#endif
    1515
    16 class TH1F;
     16#ifndef ROOT_TH2F
     17#include <TH2F.h>
     18#endif
    1719
    1820class MGeomCam;
    1921class MArrivalTimeCam;
     22class MHCalibrationHiLoPix;
    2023
    2124class MHCalibrationHiLoCam : public MHCalibrationCam
    2225{
    2326private:
    24   static const Int_t   fgNbins;                      //! Default number of bins        (now set to: 900   )
    25   static const Axis_t  fgFirst;                      //! Default lower histogram limit (now set to: -13.5 )
    26   static const Axis_t  fgLast;                       //! Default upper histogram limit (now set to:  13.5 )
    27   static const Float_t fgProbLimit;                  //! The default for fProbLimit    (now set to: 0.0) 
    28  
    29   static const TString gsHistName;                   //! Default Histogram names
    30   static const TString gsHistTitle;                  //! Default Histogram titles
    31   static const TString gsHistXTitle;                 //! Default Histogram x-axis titles
    32   static const TString gsHistYTitle;                 //! Default Histogram y-axis titles
     27   static const Int_t   fgNbins;                //! Default number of bins        (now set to: 900   )
     28   static const Axis_t  fgFirst;                //! Default lower histogram limit (now set to: -13.5 )
     29   static const Axis_t  fgLast;                 //! Default upper histogram limit (now set to:  13.5 )
     30   static const Float_t fgProbLimit;            //! The default for fProbLimit    (now set to: 0.0)
    3331
    34   MArrayD fSumareahi  ;                               //
    35   MArrayD fSumsectorhi;                               //
    36   MArrayI fNumareahi  ;                               //
    37   MArrayI fNumsectorhi;                               //
    38   MArrayD fSumarealo  ;                               //
    39   MArrayD fSumsectorlo;                               //
    40   MArrayI fNumarealo  ;                               //
    41   MArrayI fNumsectorlo;                               //
     32   static const Int_t   fgHivsLoNbins;          //! Default number of bins        (now set to: 900   )
     33   static const Axis_t  fgHivsLoFirst;          //! Default lower histogram limit (now set to: -13.5 )
     34   static const Axis_t  fgHivsLoLast;           //! Default upper histogram limit (now set to:  13.5 )
    4235
    43   MArrivalTimeCam *fArrTimes;                         //! Pointer to arrival times
     36   static const Axis_t  fgLowerFitLimitProfile; //! Default for fLowerFitLimitProfile    (now set to: 480. )
     37   static const Axis_t  fgUpperFitLimitProfile; //! Default for fUpperFitLimitProfile    (now set to: 680. )
    4438
    45   Bool_t ReInitHists(MParList *pList);
    46   Bool_t FillHists(const MParContainer *par, const Stat_t w=1);
    47   Bool_t FinalizeHists();
    48   void   FinalizeBadPixels();
     39   static const TString gsHistName;          //! Default Histogram names
     40   static const TString gsHistTitle;         //! Default Histogram titles
     41   static const TString gsHistXTitle;        //! Default Histogram x-axis titles
     42   static const TString gsHistYTitle;        //! Default Histogram y-axis titles
    4943
    50   void   CheckOverflow( MHCalibrationPix &pix);
     44   static const TString gsHivsLoHistName;    //! Default  names hi vs. lo profile
     45   static const TString gsHivsLoHistTitle;   //! Default  titles hi vs. lo profile
     46   static const TString gsHivsLoHistXTitle;  //! Default  x-axis titles hi vs. lo profile
     47   static const TString gsHivsLoHistYTitle;  //! Default  y-axis titles hi vs. lo profile
     48
     49   TString fHivsLoHistName;                  //  names hi vs. lo profile
     50   TString fHivsLoHistTitle;                 //  titles hi vs. lo profile
     51   TString fHivsLoHistXTitle;                //  x-axis titles hi vs. lo profile
     52   TString fHivsLoHistYTitle;                //  y-axis titles hi vs. lo profile
     53
     54   Int_t   fHivsLoNbins;                     // Number of HivsLo bins
     55   Axis_t  fHivsLoFirst;                     // Lower histogram limit low gain
     56   Axis_t  fHivsLoLast;                      // Upper histogram limit low gain
     57
     58   Axis_t  fLowerFitLimitProfile;            // Lower limit for hi-vs. logain fit
     59   Axis_t  fUpperFitLimitProfile;            // Upper limit for hi-vs. logain fit
     60
     61   MArrayD fSumareahi  ;                     //
     62   MArrayD fSumsectorhi;                     //
     63   MArrayI fNumareahi  ;                     //
     64   MArrayI fNumsectorhi;                     //
     65   MArrayD fSumarealo  ;                     //
     66   MArrayD fSumsectorlo;                     //
     67   MArrayI fNumarealo  ;                     //
     68   MArrayI fNumsectorlo;                     //
     69
     70   MArrivalTimeCam *fArrTimes;               //! Pointer to arrival times
     71
     72   TH2F    fHivsLoResults;                   // Results from pol1-fit
     73
     74   Float_t fUsedLoGainSlices;                // Used low-gain FADC slices
     75   Bool_t ReInitHists(MParList *pList);
     76   Bool_t FillHists(const MParContainer *par, const Stat_t w=1);
     77   Bool_t FinalizeHists();
     78   void   FinalizeBadPixels();
     79
     80   void   InitHiGainArrays( const Int_t npix, const Int_t nareas, const Int_t nsectors );
     81   void   InitLoGainArrays( const Int_t npix, const Int_t nareas, const Int_t nsectors );
     82
     83   void   FinalizeHivsLo (MHCalibrationHiLoPix &hist);
     84
     85   void   CheckOverflow( MHCalibrationPix &pix);
     86
     87   Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
    5188 
    5289public:
     
    5592  // Clone
    5693  TObject *Clone(const char *name="") const;
     94
     95  TH2F &GetHivsLoResults() { return fHivsLoResults; }
     96
     97  void SetHivsLoHistName   ( const char *name )  { fHivsLoHistName   = name; }
     98  void SetHivsLoHistTitle  ( const char *name )  { fHivsLoHistTitle  = name; }
     99  void SetHivsLoHistXTitle ( const char *name )  { fHivsLoHistXTitle = name; }
     100  void SetHivsLoHistYTitle ( const char *name )  { fHivsLoHistYTitle = name; }
     101
     102  void SetHivsLoNbins      ( const Int_t  i=fgHivsLoNbins   ) { fHivsLoNbins   = i; }
     103  void SetHivsLoFirst      ( const Axis_t f=fgHivsLoFirst   ) { fHivsLoFirst   = f; }
     104  void SetHivsLoLast       ( const Axis_t f=fgHivsLoLast    ) { fHivsLoLast    = f; }
     105
     106  void SetLowerFitLimitProfile( const Axis_t f=fgLowerFitLimitProfile ) { fLowerFitLimitProfile = f; }
     107  void SetUpperFitLimitProfile( const Axis_t f=fgUpperFitLimitProfile ) { fUpperFitLimitProfile = f; }
    57108
    58109  // Draw
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.cc

    r7028 r7189  
    464464
    465465      if (npix > fNumPixelsRequired)
    466         GetAverageHiGainArea(j).FillHist(fSumhiarea[j]/npix);
     466        {
     467           if (IsOscillations())
     468                GetAverageHiGainArea(j).FillHistAndArray(fSumhiarea[j]/npix);
     469           else
     470                GetAverageHiGainArea(j).FillHist(fSumhiarea[j]/npix);
     471
     472        }
    467473    }
    468474
     
    473479
    474480      if (npix > 0)
    475         GetAverageHiGainSector(j).FillHist(fSumhisector [j]/npix);
     481        {
     482           if (IsOscillations())
     483                GetAverageHiGainSector(j).FillHistAndArray(fSumhisector [j]/npix);
     484           else
     485                GetAverageHiGainSector(j).FillHist(fSumhisector [j]/npix);
     486        }
    476487    }
    477488
     
    560571    {
    561572      *fLog << dbginf << GetDescriptor() << ": ID " << GetName()
     573            << " "<<pix.GetPixId()
    562574            << " Mean: "         << hist.GetMean    ()
    563575            << " MeanErr: "      << hist.GetMeanErr ()
  • trunk/MagicSoft/Mars/mhcalib/MHGausEvents.h

    r7188 r7189  
    169169  void  SimulateGausEvents(const Float_t mean, const Float_t sigma, const Int_t nevts=4096);     // *MENU*
    170170
    171   ClassDef(MHGausEvents, 3) // Base class for events with Gaussian distributed values
     171  ClassDef(MHGausEvents, 4) // Base class for events with Gaussian distributed values
    172172};
    173173
  • trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc

    r7127 r7189  
    7474#include "MCalibrationIntensityRelTimeCam.h"
    7575#include "MCalibrationIntensityQECam.h"
     76#include "MCalibrationIntensityConstCam.h"
    7677#include "MBadPixelsIntensityCam.h"
    7778
     
    268269    MCalibrationIntensityBlindCam       iblcam;
    269270    MCalibrationIntensityRelTimeCam     itmcam;
     271    MCalibrationIntensityConstCam       icncam;
    270272    MBadPixelsIntensityCam              ibdcam;
    271273
     
    299301        interlacedcont.Add(&itmcam);
    300302        interlacedcont.Add(&ibdcam);
     303        interlacedcont.Add(&icncam);
    301304        interlacedcont.Add(&hchacam);
    302305        if (IsUseBlindPixel())
     
    317320    calibcont.Add(&qecam);
    318321    calibcont.Add(&bndcam);
    319     calibcont.Add(&pind);
    320322    calibcont.Add(&tmcam);
     323    if (IsUseBlindPixel())
     324        calibcont.Add(&bndcam);
    321325
    322326    if (!ReadCalibration(calibcont, badpix, extractor2, extractor3, geom))
     
    362366    // This is necessary for the case in which it is not in the files
    363367    MBadPixelsCam badcam;
     368    icncam.SetBadPixels(&badpix);
    364369
    365370    // Setup Parlist
     
    524529
    525530    MCalibrationChargeCalc  chcalc;
     531    chcalc.SetExtractor(extractor3);
     532
    526533    MCalibrationRelTimeCalc recalc;
    527534    MCalibCalcFromPast      pacalc;
     
    570577    // MHCamEvent evt3(4, "PedPhot",    "Calibrated Pedestal;;P [phe]");
    571578    MHCamEvent evt4(  5, "PedRMS",     "Calibrated RMS from Extractor applied to ped.;;\\sigma_{p} [phe]");
    572     MHCamEvent evt5(  0, "Interp'd",   "Interpolated Signal per area scale A/A_{0};;S [phe]");
     579    MHCamEvent evt5(  0, "Interp'd",   "Interpolated Signal scaled with A/A_{0};;S [phe]");
    573580    MHCamEvent evt6(102, "Unsuitable", "Fraction of unsuitable events per Pixel;;[1]");
    574581    MHCamEvent evt7(  6, "Times",      "Calibrated Arrival Time;;T [fadc sl]");
     
    577584    evt6.SetThreshold();
    578585
    579     MFillH fill0(&evt0, "MPedestalFundamental",       "FillPedFLG");
    580     MFillH fill1(&evt1, "MPedestalFromExtractorRndm", "FillPedRmsFLG");
    581     MFillH fill2(&evt2, "MExtractedSignalCam",        "FillExtracted");
     586    MFillH fill0(&evt0, "MPedestalFundamental",          "FillPedFLG");
     587    MFillH fill1(&evt1, "MPedestalFromExtractorRndm",    "FillPedRmsFLG");
     588    MFillH fill2(&evt2, "MExtractedSignalCam",           "FillExtracted");
    582589    // MFillH fill3(&evt3, "MPedPhotFundamental",  "FillPedPhot");
    583     MFillH fill4(&evt4, "MPedPhotFromExtractorRndm",  "FillPedRMS");
    584     MFillH fill5(&evt5, "MSignalCam",                 "FillInterpolated");
    585     MFillH fill6(&evt6, "MBadPixelsCam",              "FillUnsuitable");
    586     MFillH fill7(&evt7, "MSignalCam",                 "FillTimes");
    587     MFillH fill8(&evt8, "MCalibConstCam",            "FillConv");
    588     MFillH fill9(&evt9, "MSignalCam",                 "FillPulse");
     590    MFillH fill4(&evt4, "MPedPhotFromExtractorRndm",     "FillPedRMS");
     591    MFillH fill5(&evt5, "MSignalCam",                    "FillInterpolated");
     592    MFillH fill6(&evt6, "MBadPixelsCam",                 "FillUnsuitable");
     593    MFillH fill7(&evt7, "MSignalCam",                    "FillTimes");
     594    MFillH fill8(&evt8, "MCalibrationIntensityConstCam", "FillConv");
     595    MFillH fill9(&evt9, "MSignalCam",                    "FillPulse");
    589596
    590597    MTaskEnv fillflorian("FinalFantasy");
  • trunk/MagicSoft/Mars/mjobs/MJCalibration.cc

    r7188 r7189  
    18381838    MCalibrationChargeCalc   calcalc;
    18391839    MCalibrationRelTimeCalc  timecalc;
     1840    calcalc.SetExtractor(fExtractor);
    18401841    calcalc.SetOutputFile("");
    18411842    timecalc.SetOutputFile("");
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.cc

    r7188 r7189  
    174174    }
    175175
    176     TObject *o = file.Get("ExtractSignal");
    177     if (o && !o->InheritsFrom(MExtractor::Class()))
    178     {
    179         *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
    180         return NULL;
    181     }
    182 
    183176    if (file.FindKey("MBadPixelsCam"))
    184177    {
     
    190183    }
    191184
     185    if (fExtractor)
     186        return fExtractor;
     187
     188    TObject *o=0;
     189    o = file.Get("ExtractSignal");
     190    if (o && !o->InheritsFrom(MExtractor::Class()))
     191    {
     192        *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
     193        return NULL;
     194    }
    192195    return o ? (MExtractor*)o->Clone("ExtractSignal") : NULL;
    193196}
Note: See TracChangeset for help on using the changeset viewer.