Changeset 5848 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
01/14/05 19:14:03 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r5845 r5848  
    4242       the whole camera including a fit to the values.
    4343
     44   * mpedestal/MPedCalcPedRun.[h,cc]
     45     - undo some changes introduced by TB on 2/12/04 which had made the
     46       use of interlaced pedestal events impossible again.
     47     - Use now the new class MTriggerPattern directly to recognize an
     48       interlaced pedestal event.     
    4449
    4550
  • trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc

    r5832 r5848  
    139139#include "MExtractTimeAndCharge.h"
    140140
     141#include "MTriggerPattern.h"
     142
    141143ClassImp(MPedCalcPedRun);
    142144
     
    145147const UShort_t MPedCalcPedRun::fgExtractWinFirst       = 0;
    146148const UShort_t MPedCalcPedRun::fgExtractWinSize        = 6;
    147 const UInt_t   MPedCalcPedRun::gkFirstRunWithFinalBits = 45589;
    148 
     149const UInt_t   MPedCalcPedRun::gkFirstRunWithFinalBits = 45605;
    149150// --------------------------------------------------------------------------
    150151//
     
    162163//
    163164MPedCalcPedRun::MPedCalcPedRun(const char *name, const char *title)
    164     : fOverlap(0)
    165 {
    166     fName  = name  ? name  : "MPedCalcPedRun";
    167     fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";
    168 
    169     SetExtractWindow(fgExtractWinFirst, fgExtractWinSize);
     165    : fOverlap(0), fIsFirstPedRun(kFALSE), fUsedEvents(0), fTrigPattern(NULL)
     166{
     167  fName  = name  ? name  : "MPedCalcPedRun";
     168  fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";
     169 
     170  SetExtractWindow(fgExtractWinFirst, fgExtractWinSize);
     171 
     172  //  SetNumEventsDump(1001);
     173  //  SetNumAreasDump(1001);
     174  //  SetNumSectorsDump(1001);
    170175}
    171176
     
    179184void MPedCalcPedRun::CheckExtractionWindow()
    180185{
    181     const UShort_t lastavailable = fRunHeader->GetNumSamplesHiGain()-1;
    182 
    183     if (fExtractWinLast <= lastavailable)
    184         return;
    185 
    186     const UShort_t diff = fExtractWinLast - lastavailable;
    187 
    188     *fLog << warn << endl;
    189     *fLog << "Selected ExtractWindow [" << fExtractWinFirst << "," << fExtractWinLast;
    190     *fLog << "] ranges out of range [0," << lastavailable << "]." << endl;
    191     *fLog << "Using " << diff << " samples from the 'Lo-Gain' slices for the pedestal extraction" << endl;
    192 
    193     fExtractWinLast -= diff;
    194     fOverlap         = diff;
     186  const UShort_t lastavailable = fRunHeader->GetNumSamplesHiGain()-1;
     187 
     188  if (fExtractWinLast <= lastavailable)
     189    return;
     190 
     191  const UShort_t diff = fExtractWinLast - lastavailable;
     192 
     193  *fLog << warn << endl;
     194  *fLog << "Selected ExtractWindow [" << fExtractWinFirst << "," << fExtractWinLast;
     195  *fLog << "] ranges out of range [0," << lastavailable << "]." << endl;
     196  *fLog << "Using " << diff << " samples from the 'Lo-Gain' slices for the pedestal extraction" << endl;
     197 
     198  fExtractWinLast -= diff;
     199  fOverlap         = diff;
     200}
     201
     202void MPedCalcPedRun::Reset()
     203{
     204
     205  MExtractPedestal::ResetArrays();
     206  fUsedEvents    = 0;
    195207}
    196208
     
    201213Int_t MPedCalcPedRun::PreProcess(MParList *pList)
    202214{
    203     fUsedEvents = 0;
    204     fIsFirstPedRun = kTRUE;
    205     return MExtractPedestal::PreProcess(pList);
     215
     216  fUsedEvents    = 0;
     217  fIsFirstPedRun = kTRUE;
     218  fIsNotPedRun   = kFALSE;
     219 
     220  fTrigPattern = (MTriggerPattern*)pList->FindObject("MTriggerPattern");
     221  if (!fTrigPattern)
     222    *fLog << warn << GetDescriptor()
     223          << ": MTriggerPattern not found... Cannot use interlaced pedestal events." << endl;
     224
     225  return MExtractPedestal::PreProcess(pList);
    206226}
    207227
     
    209229//
    210230// The run type is checked for "kRTPedestal"
    211 // and the variable fSkip is set in that case
     231// and the variable fIsNotPedRun is set in that case
    212232//
    213233Bool_t MPedCalcPedRun::ReInit(MParList *pList)
    214234{
    215     if (!MExtractPedestal::ReInit(pList))
    216         return kFALSE;
    217 
    218     CheckExtractionWindow();
    219 
    220     // If this is the first ped run, the next run (call to ReInit)
    221     // is not the first anymore
    222     if (fRunHeader->GetRunType()==MRawRunHeader::kRTPedestal)
     235
     236  if (!MExtractPedestal::ReInit(pList))
     237    return kFALSE;
     238
     239  CheckExtractionWindow();
     240
     241  //
     242  // If this is the first ped run, the next run (call to ReInit)
     243  // is not the first anymore
     244  //
     245  if (fRunHeader->GetRunType()==MRawRunHeader::kRTPedestal)
    223246    {
    224         fIsFirstPedRun = kFALSE;
    225         return kTRUE;
     247      fIsFirstPedRun = kFALSE;
     248      fIsNotPedRun   = kFALSE;
     249      return kTRUE;
    226250    }
    227 
    228     // If this is the first call to ReInit (before reading the first file)
    229     // nothing should be done
    230     if (fIsFirstPedRun)
    231         return kTRUE;
    232 
    233     // In any other case some kind of finaliazation must be done
    234     *fLog << inf << "Finalizing pedestal calculations..." << flush;
    235 
    236     if (!Finalize())
    237         return kFALSE;
    238 
    239     Reset();
    240 
     251 
     252  fIsNotPedRun = kTRUE;
     253  //
     254  // If this is the first call to ReInit (before reading the first file)
     255  // nothing should be done. It occurs for the case that the first treated
     256  // file is not of pedestal type.
     257  //
     258  if (fIsFirstPedRun)
    241259    return kTRUE;
     260 
     261  //
     262  // In the other case, produce the MPedestalCam to be use the subsequent (non-pedestal) events
     263  //
     264  *fLog << inf << "Finalizing pedestal calculations..." << flush;
     265 
     266  if (!Finalize())
     267    return kFALSE;
     268 
     269  Reset();
     270
     271  return kTRUE;
    242272}
    243273
     
    253283Int_t MPedCalcPedRun::Calc()
    254284{
    255     if (!IsPedBitSet())
    256     {
    257         *fLog << err << GetDescriptor() << " - ERROR: IsPedBitSet() returned kFALSE... abort." << endl;
    258         return kERROR;
    259     }
    260 
    261     if (fRunHeader->GetRunType() != MRawRunHeader::kRTPedestal)
    262         return kTRUE;
    263 
     285
     286  if (fIsNotPedRun && !IsPedBitSet())
     287    return kTRUE;
     288 
     289  //  if (fUsedEvents == fNumEventsDump)
     290  //    {
     291  //      *fLog << endl;
     292  //      *fLog << inf << GetDescriptor() << " : Finalize pedestal calculations..." << flush;
     293  //      Finalize();
     294  //      Reset();
     295  //    }
     296 
    264297  fUsedEvents++;
    265298
     
    277310     
    278311      if (fExtractor)
    279           CalcExtractor(pixel, sum, (*fPedestalsIn)[idx]);
     312        CalcExtractor(pixel, sum, (*fPedestalsIn)[idx]);
    280313      else
    281           CalcSums(pixel, sum, ab0, ab1);
     314        CalcSums(pixel, sum, ab0, ab1);
    282315
    283316      fSumx[idx]           += sum;
     
    370403}
    371404
     405
    372406// --------------------------------------------------------------------------
    373407//
     
    376410Int_t MPedCalcPedRun::Finalize()
    377411{
    378     if (fUsedEvents == 0)
    379         return kTRUE;
    380 
    381     MRawEvtPixelIter pixel(fRawEvt);
    382     while (pixel.Next())
    383         CalcPixResults(fUsedEvents, pixel.GetPixelId());
    384 
    385     //
    386     // Loop over the (two) area indices to get the averaged pedestal per aidx
    387     //
    388     for (UInt_t aidx=0; aidx<fAreaValid.GetSize(); aidx++)
    389         if (fAreaValid[aidx]>0)
    390             CalcAreaResults(fUsedEvents, fAreaValid[aidx], aidx);
    391 
    392     //
    393     // Loop over the (six) sector indices to get the averaged pedestal per sector
    394     //
    395     for (UInt_t sector=0; sector<fSectorValid.GetSize(); sector++)
    396         if (fSectorValid[sector]>0)
    397             CalcSectorResults(fUsedEvents, fSectorValid[sector], sector);
    398 
    399     fPedestalsOut->SetTotalEntries(fUsedEvents*fExtractWinSize);
    400     fPedestalsOut->SetReadyToSave();
    401 
     412
     413  if (fUsedEvents == 0)
    402414    return kTRUE;
     415 
     416  MRawEvtPixelIter pixel(fRawEvt);
     417  while (pixel.Next())
     418    CalcPixResults(fUsedEvents, pixel.GetPixelId());
     419 
     420  //
     421  // Loop over the (two) area indices to get the averaged pedestal per aidx
     422  //
     423  for (UInt_t aidx=0; aidx<fAreaValid.GetSize(); aidx++)
     424    if (fAreaValid[aidx]>0)
     425      CalcAreaResults(fUsedEvents, fAreaValid[aidx], aidx);
     426 
     427  //
     428  // Loop over the (six) sector indices to get the averaged pedestal per sector
     429  //
     430  for (UInt_t sector=0; sector<fSectorValid.GetSize(); sector++)
     431    if (fSectorValid[sector]>0)
     432      CalcSectorResults(fUsedEvents, fSectorValid[sector], sector);
     433 
     434  fPedestalsOut->SetTotalEntries(fUsedEvents*fExtractWinSize);
     435  fPedestalsOut->SetReadyToSave();
     436 
     437  return kTRUE;
    403438}
    404439
    405440Int_t MPedCalcPedRun::PostProcess()
    406441{
    407     if (!Finalize())
    408         return kFALSE;
    409 
    410     return MExtractPedestal::PostProcess();
     442  if (!Finalize())
     443    return kFALSE;
     444 
     445  return MExtractPedestal::PostProcess();
    411446}
    412447
     
    416451// The last but one bit is used for the "pedestal-bit".
    417452//
    418 // This bit is set since run gkFinalizationTriggerBit
     453// This bit is set since run gkFirstRunWithFinalBits
    419454//
    420455Bool_t MPedCalcPedRun::IsPedBitSet()
    421456{
    422     if (fRunHeader->GetRunNumber() == 38996)
    423         return kTRUE;
    424 
    425     if (fRunHeader->GetRunNumber() < gkFirstRunWithFinalBits)
    426         return kTRUE;
    427 
    428     return (fEvtHeader->GetTriggerID() & BIT(3)) ? kTRUE : kFALSE;
     457
     458  if (!fTrigPattern)
     459    return kTRUE;
     460
     461  if (fRunHeader->GetRunNumber() < gkFirstRunWithFinalBits)
     462    return kTRUE;
     463 
     464  return (fTrigPattern->GetPrescaled() & MTriggerPattern::kPedestal) ? kTRUE : kFALSE;
    429465}
    430466
    431467void MPedCalcPedRun::Print(Option_t *o) const
    432468{
     469
    433470    MExtractPedestal::Print(o);
    434471
  • trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.h

    r5715 r5848  
    66#endif
    77
     8class MTriggerPattern;
    89class MRawEvtPixelIter;
    910class MPedestalPix;
     
    1920
    2021    Bool_t  fIsFirstPedRun;    //! Flag to tell if the first run out of many is used
     22    Bool_t  fIsNotPedRun;      //! Flag to tell if the current run is a pedestal run
    2123    ULong_t fUsedEvents;       // Number of used (not skipped) events
     24
     25    MTriggerPattern *fTrigPattern;  //! Trigger pattern decoded
    2226
    2327    Bool_t IsPedBitSet();
     
    3640
    3741    void Print(Option_t *o="") const;
     42    void Reset();
     43   
    3844    Int_t Finalize();
    3945
Note: See TracChangeset for help on using the changeset viewer.