Ignore:
Timestamp:
09/13/04 13:14:17 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.cc

    r4960 r4974  
    4242//
    4343// The following flag can be set:
    44 // - SetDebug() for debug output.
    45 // - SetLoGain() for the case that low-gain slices are available, but
    46 //               MRawRunHeader::GetNumLoGainSlices() gives still 0.
     44// - SetAverageging() for calculating the event-by-event averages.
     45// - SetDebug()       for debug output.
     46// - SetLoGain()      for the case that low-gain slices are available, but
     47//                        MRawRunHeader::GetNumLoGainSlices() gives still 0.
    4748//
    4849// The flag fLoGain steers if low-gain signal is treated at all or not.
     
    99100// - fPulserFrequency to fgPulserFrequency
    100101//
     102// - SetAveregeing  (kTRUE);
     103// - SetDebug       (kFALSE);
     104// - SetLoGain      (kTRUE);
     105//-  SetOscillations(kTRUE);
     106//-  SetSizeCheck   (kTRUE);
     107//
    101108MHCalibrationCam::MHCalibrationCam(const char *name, const char *title)
    102109    :  fHistName(gsHistName),fHistTitle(gsHistTitle),
     
    126133    SetPulserFrequency();
    127134
     135    SetAverageing  (kTRUE);
    128136    SetDebug       (kFALSE);
    129137    SetLoGain      (kTRUE);
    130138    SetOscillations(kTRUE);
     139    SetSizeCheck   (kTRUE);
    131140}
    132141
     
    172181  if (fHiGainArray)
    173182    { fHiGainArray->ForEach(MHCalibrationPix,Reset)();  }
    174   if (fAverageHiGainAreas)
    175     { fAverageHiGainAreas->ForEach(MHCalibrationPix,Reset)();  }
    176   if (fAverageHiGainSectors)
    177     { fAverageHiGainSectors->ForEach(MHCalibrationPix,Reset)();  }
    178 
     183  if (IsAverageing())
     184    {
     185      if (fAverageHiGainAreas)
     186        { fAverageHiGainAreas->ForEach(MHCalibrationPix,Reset)();  }
     187      if (fAverageHiGainSectors)
     188        { fAverageHiGainSectors->ForEach(MHCalibrationPix,Reset)();  }
     189    }
     190 
    179191  if (!IsLoGain())
    180192    return;
     
    182194  if (fLoGainArray)
    183195    { fLoGainArray->ForEach(MHCalibrationPix,Reset)();  }
    184   if (fAverageLoGainAreas)
    185     { fAverageLoGainAreas->ForEach(MHCalibrationPix,Reset)();  }
    186   if (fAverageLoGainSectors)
    187     { fAverageLoGainSectors->ForEach(MHCalibrationPix,Reset)();  }
    188  
     196  if (IsAverageing())
     197    {
     198      if (fAverageLoGainAreas)
     199        { fAverageLoGainAreas->ForEach(MHCalibrationPix,Reset)();  }
     200      if (fAverageLoGainSectors)
     201        { fAverageLoGainSectors->ForEach(MHCalibrationPix,Reset)();  }
     202    }
    189203}
    190204
     
    329343{
    330344
     345  //
     346  // FIXME, this might be done faster and more elegant, by direct copy.
     347  //
     348  MHCalibrationCam *cam = new MHCalibrationCam();
     349
     350  cam->fRunNumbers             = fRunNumbers;
     351  cam->fPulserFrequency        = fPulserFrequency;
     352  cam->fFlags                  = fFlags;
     353
     354  if (!IsAverageing())
     355    return cam;
     356
    331357  //  const Int_t nhi   = fHiGainArray->GetEntries();
    332358  //  const Int_t nlo   = fLoGainArray->GetEntries();
     
    334360  //  const Int_t nsehi = fAverageHiGainSectors->GetEntries();
    335361 
    336   //
    337   // FIXME, this might be done faster and more elegant, by direct copy.
    338   //
    339   MHCalibrationCam *cam = new MHCalibrationCam();
    340 
    341362  //  cam->fHiGainArray->Expand(nhi);
    342363  //  cam->fLoGainArray->Expand(nlo);
     
    387408  cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;   
    388409  cam->fAverageSectorNum       = fAverageSectorNum;     
    389   cam->fRunNumbers             = fRunNumbers;
    390 
    391   cam->fPulserFrequency        = fPulserFrequency;
    392410
    393411  return cam;
     
    424442  }
    425443
     444  /* not needed -> Class is never used twice
    426445  fHiGainArray->Delete();
    427446  fLoGainArray->Delete();
     
    432451  fAverageHiGainSectors->Delete();
    433452  fAverageLoGainSectors->Delete();
     453  */
    434454
    435455  return SetupHists(pList);
     
    491511    }
    492512
    493   //
    494   // The function TArrayF::Set() already sets all entries to 0.
    495   //
    496   fAverageAreaNum.        Set(nareas);
    497   fAverageAreaSat.        Set(nareas);           
    498   fAverageAreaSigma.      Set(nareas);     
    499   fAverageAreaSigmaVar.   Set(nareas);   
    500   fAverageAreaRelSigma.   Set(nareas);   
    501   fAverageAreaRelSigmaVar.Set(nareas);
    502   fAverageSectorNum.      Set(nsectors);
    503   fRunNumbers.            Set(fRunNumbers.GetSize()+1);
    504 
    505   for (Int_t aidx=0; aidx<nareas; aidx++)
    506       fAverageAreaNum[aidx] = 0;
    507 
    508   for (Int_t sector=0; sector<nsectors; sector++)
    509       fAverageSectorNum[sector] = 0;
    510 
    511   for (Int_t i=0; i<npixels; i++)
    512     {
    513 
    514       if ((*fBadPixels)[i].IsBad())
    515         continue;
    516 
    517       fAverageAreaNum  [(*fGeom)[i].GetAidx()  ]++;
    518       fAverageSectorNum[(*fGeom)[i].GetSector()]++;
     513  if (IsAverageing())
     514    {
     515      //
     516      // The function TArrayF::Set() already sets all entries to 0.
     517      //
     518      fAverageAreaNum.        Set(nareas);
     519      fAverageAreaSat.        Set(nareas);           
     520      fAverageAreaSigma.      Set(nareas);     
     521      fAverageAreaSigmaVar.   Set(nareas);   
     522      fAverageAreaRelSigma.   Set(nareas);   
     523      fAverageAreaRelSigmaVar.Set(nareas);
     524      fAverageSectorNum.      Set(nsectors);
     525      fRunNumbers.            Set(fRunNumbers.GetSize()+1);
     526     
     527      for (Int_t aidx=0; aidx<nareas; aidx++)
     528        fAverageAreaNum[aidx] = 0;
     529     
     530      for (Int_t sector=0; sector<nsectors; sector++)
     531        fAverageSectorNum[sector] = 0;
     532 
     533      for (Int_t i=0; i<npixels; i++)
     534        {
     535          if ((*fBadPixels)[i].IsBad())
     536            continue;
     537         
     538          fAverageAreaNum  [(*fGeom)[i].GetAidx()  ]++;
     539          fAverageSectorNum[(*fGeom)[i].GetSector()]++;
     540        }
    519541    }
    520542
     
    544566        h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
    545567      }
     568 
     569  if (!IsAverageing())
     570    return kTRUE;
    546571 
    547572  for (Int_t j=0; j<nareas; j++)
     
    616641  }
    617642
     643  if (!IsAverageing())
     644    return;
     645
    618646  if (fAverageHiGainAreas->GetEntries()==0)
    619647  {
     
    725753  }
    726754
     755  if (!IsAverageing())
     756    return;
     757
    727758  if (fAverageLoGainAreas->GetEntries()==0)
    728759  {
     
    801832{
    802833
     834  if (!IsSizeCheck())
     835    return FillHists(par,w);
     836
    803837  const Int_t npixels  = fGeom->GetNumPixels();
    804838  const Int_t nareas   = fGeom->GetNumAreas();
     
    814848    }
    815849 
    816   if (fAverageHiGainAreas->GetEntries() != nareas)
    817     {
    818       *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
    819       return kFALSE;
    820     }
    821 
    822   if (fAverageHiGainSectors->GetEntries() != nsectors)
    823     {
    824       *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
    825       return kFALSE;
    826     }
    827 
    828850  if (IsLoGain())
    829851    {
     
    833855          return kFALSE;
    834856        }
     857    }
     858 
     859  if (!IsAverageing())
     860    return FillHists(par,w);
     861
     862  if (fAverageHiGainAreas->GetEntries() != nareas)
     863    {
     864      *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
     865      return kFALSE;
     866    }
     867 
     868  if (fAverageHiGainSectors->GetEntries() != nsectors)
     869    {
     870      *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
     871      return kFALSE;
     872    }
     873 
     874  if (IsLoGain())
     875    {
    835876     
    836877      if (fAverageLoGainAreas->GetEntries() != nareas)
     
    928969    }
    929970
     971  if (!IsAverageing())
     972    return;
     973 
    930974  for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
    931975    {
     
    9811025    }
    9821026
     1027  if (!IsAverageing())
     1028    return;
     1029 
    9831030  for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
    9841031    {
     
    10121059
    10131060  if (!fCam)
     1061    return;
     1062 
     1063  if (!IsAverageing())
    10141064    return;
    10151065 
     
    11971247
    11981248
    1199 // --------------------------------------------------------------------------
    1200 //
    1201 // Dummy, needed by MCamEvent
    1202 //
    1203 Bool_t MHCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
    1204 {
    1205   return kTRUE;
    1206 }
    1207 
    1208 // --------------------------------------------------------------------------
    1209 //
    1210 // What MHCamera needs in order to draw an individual pixel in the camera
    1211 //
    1212 void MHCalibrationCam::DrawPixelContent(Int_t idx) const
    1213 {
    1214 }
    1215 
    12161249// -----------------------------------------------------------------------------
    12171250//
     
    12241257void MHCalibrationCam::Draw(const Option_t *opt)
    12251258{
     1259
     1260  if (!IsAverageing())
     1261    return;
    12261262
    12271263  const Int_t nareas = fAverageHiGainAreas->GetEntries();
     
    13161352      rc = kTRUE;
    13171353    }
     1354  if (IsEnvDefined(env, prefix, "SizeCheck", print))
     1355    {
     1356      SetSizeCheck(GetEnvValue(env, prefix, "SizeCheck", IsSizeCheck()));
     1357      rc = kTRUE;
     1358    }
     1359  if (IsEnvDefined(env, prefix, "Averageing", print))
     1360    {
     1361      SetAverageing(GetEnvValue(env, prefix, "Averageing", IsAverageing()));
     1362      rc = kTRUE;
     1363    }
    13181364 
    13191365  if (IsEnvDefined(env, prefix, "Nbins", print))
Note: See TracChangeset for help on using the changeset viewer.