Changeset 7194


Ignore:
Timestamp:
07/15/05 13:25:57 (19 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r7193 r7194  
    2020
    2121                                                 -*-*- END OF LINE -*-*-
     22 2005/07/16 Thomas Bretz
     23
     24   * macros/dohtml.C:
     25     - some updates to the macro section
     26
     27   * mcalib/MCalibrationCam.h:
     28     - added new member function GetPulserColorStr to convert
     29       pulser color into string
     30
     31   * mcalib/MCalibrationPattern.h:
     32     - added new member function GetPulserColorStr to return
     33       pulser color a string
     34
     35   * mcalib/MCalibrationPatternDecode.cc:
     36     - fixed a typo in a comment
     37
     38   * mhflux/MHThetaSq.cc:
     39     - set default number of bins to 75
     40
     41   * msignal/MExtractTimeAndChargeDigitalFilter.[h,cc]:
     42     - updated support for automatic weights. All cases should now
     43       be handled as accurate as possible.
     44
     45   * msignal/MC_calibration_weights_UV46.dat,
     46     msignal/MC_cosmics_weights46.dat:
     47     - new files
     48
     49
     50
    2251 2005/07/14 Thomas Bretz
    2352
  • trunk/MagicSoft/Mars/NEWS

    r7193 r7194  
    4848       - fgLoGainBlackoutLimit: 3.5
    4949       - fgLoGainPickupLimit: 3.5
     50
     51   - callisto: The handling of automatic weights for the digital filter
     52     has been improved. There are now new calibration weights special
     53     for Monte Carlo calibrations.
    5054
    5155   - callisto: use a new criterium to exclude bad pixels: If the high-gain
  • trunk/MagicSoft/Mars/macros/dohtml.C

    r5694 r7194  
    101101    html.SetSourceDir("macros");
    102102    html.Convert("merpp.C",         "MARS - Merging and Preprocessing");
    103     html.Convert("readraw.C",       "MARS - How To Read A Raw");
     103    html.Convert("tutorials/readraw.C",       "MARS - How To Read A Raw");
    104104    html.Convert("rootlogon.C",     "MARS - rootlogon.C");
    105     html.Convert("readCT1.C",       "MARS - Read and display CT1 Events");
     105    //html.Convert("readCT1.C",       "MARS - Read and display CT1 Events");
    106106    html.Convert("readMagic.C",     "MARS - Read and display Magic Events");
    107     html.Convert("CT1Hillas.C",     "MARS - Calculate CT1 Hillas");
     107    //html.Convert("CT1Hillas.C",     "MARS - Calculate CT1 Hillas");
    108108    html.Convert("MagicHillas.C",   "MARS - Calculate Magic Hillas");
    109     html.Convert("collarea.C",      "MARS - Calculate Collection Area from a MC root file");
     109//?    html.Convert("collarea.C",      "MARS - Calculate Collection Area from a MC root file");
    110110    html.Convert("threshold.C",     "MARS - Calculate Energy Threshold from a MC root file");
    111111    html.Convert("trigrate.C",      "MARS - Calculate Trigger Rate from a MC root file");
    112112    html.Convert("star.C",          "MARS - (St)andard (A)nalysis and (R)econstruction");
    113     html.Convert("starplot.C",      "MARS - Plot parameters from file created with star.C");
     113    html.Convert("tutorials/starplot.C",      "MARS - Plot parameters from file created with star.C");
     114    html.Convert("tutorials/readrfl.C",      "MARS - Example of reading reflector output with Mars");
    114115    html.Convert("comprob.C",       "MARS - Calculation of composite probabilities for G/H-Seperation");
    115116    html.Convert("multidimdist.C",  "MARS - Calculation of multidimensional distances for G/H-Seperation");
    116117    html.Convert("multidimdist2.C", "MARS - Calculation of multidimensional distances for G/H-Seperation");
    117     html.Convert("estimate.C",      "MARS - Shows results from the energy estimation");
    118     html.Convert("estfit.C",        "MARS - Fits the coefficients of the energy estimator MEnergyEstParam");
    119     html.Convert("plot.C",          "MARS - Plots 1D mars histogram");
    120     html.Convert("plot2.C",         "MARS - Plots a 2D mars histogram");
    121     html.Convert("starplot.C",      "MARS - Plots data from a STAR-file into a mars histogram");
    122     html.Convert("testenv.C",       "MARS - Example to use TEnv and Mars Eventloops");
     118//    html.Convert("estimate.C",      "MARS - Shows results from the energy estimation");
     119//    html.Convert("estfit.C",        "MARS - Fits the coefficients of the energy estimator MEnergyEstParam");
     120    html.Convert("tutorials/plot.C",          "MARS - Plots 1D mars histogram");
     121    html.Convert("tutorials/plot2.C",         "MARS - Plots a 2D mars histogram");
     122    html.Convert("tutorials/testenv.C",       "MARS - Example to use TEnv and Mars Eventloops");
    123123    html.Convert("triglvl2.C",      "MARS - Example to use MMcTriggerLvl2 class, using filters and creating histograms");
    124     html.Convert("status.C",        "MARS - Example to use the online display");
    125     html.Convert("calibration.C",   "MARS - Example to use the calibration");
    126     html.Convert("pedvsevent.C",    "MARS - Example to use MPedCalcPedRun");
    127     html.Convert("pedphotcalc.C",   "MARS - Example to use MPedPhotCalc");
    128     html.Convert("sectorvstime.C",  "MARS - Example how to plot mean value of a camera sector versus time");
    129     html.Convert("calibration.C",   "MARS - Example how to use the calibrationa camera ");
    130     html.Convert("bootcampstandardanalysis.C", "MARS - Example of the status of the standard analysis at the bootcamp");
     124    //html.Convert("status.C",        "MARS - Example to use the online display");
     125    //html.Convert("calibration.C",   "MARS - Example to use the calibration");
     126    html.Convert("tutorials/pedvsevent.C",    "MARS - Example to use MPedCalcPedRun");
     127    //html.Convert("pedphotcalc.C",   "MARS - Example to use MPedPhotCalc");
     128    html.Convert("tutorials/derotatedc.C",  "MARS - Example of plotting derotated dc currents");
     129    html.Convert("tutorials/evtrate.C",  "MARS - Example how to plot the event rate");
     130    html.Convert("tutorials/pixvsevent.C",  "MARS - Example how to plot pixel value versus event number/time");
     131    html.Convert("tutorials/sectorvstime.C",  "MARS - Example how to plot mean value of a camera sector versus time");
     132    html.Convert("tutorials/pedestalvstime.C",  "MARS - Example how to plot pedestal/rms versus time");
     133    html.Convert("tutorials/pixfirerate.C",  "MARS - Example how to plot the firerate of a pixel (times above threshold)");
     134    html.Convert("tutorials/pixsatrate.C",  "MARS - Example how to plot the saturation rate of a pixel");
     135    //html.Convert("calibration.C",   "MARS - Example how to use the calibrationa camera ");
     136    //html.Convert("bootcampstandardanalysis.C", "MARS - Example of the status of the standard analysis at the bootcamp");
    131137    html.Convert("readIPR.C",       "MARS - Example to read and display the IPRs from a (merpped) report file");
    132     html.Convert("extendcam.C",     "MARS - Example of using MGeomCamExtend and MHexagonalFTCalc");
    133     html.Convert("hft.C",           "MARS - Example of using MHexagonalFTCalc");
     138    html.Convert("tutorials/extendcam.C",     "MARS - Example of using MGeomCamExtend and MHexagonalFTCalc");
     139    html.Convert("tutorials/hft.C",           "MARS - Example of using MHexagonalFTCalc");
    134140}
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCam.h

    r6963 r7194  
    9494  const MCalibrationPix &operator[]             ( UInt_t i )           const;
    9595
     96  static TString GetPulserColorStr(PulserColor_t col) {
     97      TString str;
     98      switch (col)
     99      {
     100      case kCT1:   str += "CT1";      break;
     101      case kGREEN: str += "Green";    break;
     102      case kBLUE:  str += "Blue";     break;
     103      case kUV:    str += "UV";       break;
     104      case kNONE:  str += "None";     break;
     105      default:     str += "Unknown";  break;
     106      }
     107      str += " (";
     108      str += (int)col;
     109      str += ")";
     110      return str;
     111  }
     112
    96113  // Inits
    97114  void  Init                   ( const MGeomCam &geom         );
  • trunk/MagicSoft/Mars/mcalib/MCalibrationPattern.h

    r6013 r7194  
    5454
    5555    const MCalibrationCam::PulserColor_t GetPulserColor() const { return fPulserColor; }
     56    TString GetPulserColorStr() const { return MCalibrationCam::GetPulserColorStr(fPulserColor); }
    5657
    5758    void SetPulserColor   ( const MCalibrationCam::PulserColor_t col) { fPulserColor = col; }
  • trunk/MagicSoft/Mars/mcalib/MCalibrationPatternDecode.cc

    r6056 r7194  
    9999Int_t MCalibrationPatternDecode::Process()
    100100{
    101     // No setting necessary because MCalibrationPattern::reset() has
     101    // No setting necessary because MCalibrationPattern::Reset() has
    102102    // been called just before
    103103    if (fRunHeader->GetFormatVersion()<5)
  • trunk/MagicSoft/Mars/mhflux/MHThetaSq.cc

    r7178 r7194  
    6262//
    6363MHThetaSq::MHThetaSq(const char *name, const char *title)
    64     : MHAlpha(name, title), fThetaSq(0), fNumBinsSignal(3), fNumBinsTotal(45)
     64    : MHAlpha(name, title), fThetaSq(0), fNumBinsSignal(3), fNumBinsTotal(75)
    6565{
    6666    //
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc

    r7134 r7194  
    7070#include "MRawRunHeader.h"
    7171#include "MCalibrationPattern.h"
     72#include "MExtractedSignalCam.h"
    7273
    7374#include "MPedestalPix.h"
     
    142143  if (fWindowSizeHiGain > availhirange)
    143144  {
    144       // Please simplify this!
    145       *fLog << warn << GetDescriptor()
    146             << Form("%s%2i%s%2i%s%2i%s",": Hi Gain window size: ",fWindowSizeHiGain,
    147                     " is bigger than available range: [",(int)fHiGainFirst,",",(int)fHiGainLast,"]") << endl;
     145      *fLog << warn << GetDescriptor() << ": Hi Gain window size: " << Form("%2i",fWindowSizeHiGain);
     146      *fLog << " is bigger than available range: [" << Form("%2i", (int)fHiGainFirst);
     147      *fLog << "," << Form("%21", (int)fHiGainLast) << "]" << endl;
     148
    148149      fHiGainLast = fHiGainFirst + fWindowSizeHiGain;
    149       *fLog << warn << GetDescriptor()
    150             << ": Will set the upper range to: " << (int)fHiGainLast << endl;
     150
     151      *fLog << warn << GetDescriptor() << ": Will set the upper range to: " << (int)fHiGainLast << endl;
    151152    }
    152153 
     
    163164      if (fWindowSizeLoGain > availlorange)
    164165        {
    165       // Please simplify this!
    166           *fLog << warn << GetDescriptor()
    167                 << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",fWindowSizeLoGain,
    168                         " is bigger than available range: [",(int)fLoGainFirst,",",(int)fLoGainLast,"]") << endl;
    169           fLoGainLast = fLoGainFirst + fWindowSizeLoGain;
    170           *fLog << warn << GetDescriptor()
    171             << ": Will set the upper range to: " << (int)fLoGainLast << endl;
     166            *fLog << warn << GetDescriptor() << ": Lo Gain window size: " << Form("%2i",fWindowSizeLoGain);
     167            *fLog << " is bigger than available range: [" << Form("%2i", (int)fLoGainFirst);
     168            *fLog << "," << Form("%21", (int)fLoGainLast) << "]" << endl;
     169
     170            fLoGainLast = fLoGainFirst + fWindowSizeLoGain;
     171
     172            *fLog << warn << GetDescriptor() << ": Will set the upper range to: " << (int)fLoGainLast << endl;
    172173        }
    173174     
     
    205206// --------------------------------------------------------------------------
    206207//
    207 // InitArrays
    208 //
    209 // Gets called in the ReInit() and initialized the arrays
    210 //
    211 Bool_t MExtractTimeAndChargeDigitalFilter::InitArrays()
    212 {
    213     if (!fRunHeader)
     208// The weights are determined using GetAutimaticWeights().
     209//
     210// kFALSE is returned if it returned an error.
     211// kTRUE  is returned if no new weights were set.
     212//
     213// If new weights are set
     214//  fTimeShiftHiGain
     215//  fTimeShiftLoGain
     216//  fNumHiGainSamples
     217//  fNumLoGainSamples
     218//  fSqrtHiGainSamples
     219//  fSqrtLoGainSamples
     220// and
     221//  fSignals->SetUsedFADCSlices(...)
     222// is updated accordingly.
     223//
     224Bool_t MExtractTimeAndChargeDigitalFilter::GetWeights()
     225{
     226    switch (GetAutomaticWeights())
     227    {
     228    case kERROR: // An error occured
    214229        return kFALSE;
    215 
    216     const Int_t rangehi = (Int_t)(fHiGainLast - fHiGainFirst + 1 + fHiLoLast);
    217     const Int_t rangelo = (Int_t)(fLoGainLast - fLoGainFirst + 1);
    218 
    219     fHiGainSignal.Set(rangehi);
    220     fLoGainSignal.Set(rangelo);
    221 
    222     // Try to get automatic weights
    223     if (!ReadAutomaticWeightsFile())
    224         return kFALSE;
    225 
    226     // If still no weights set try conservative way
    227     if (fNameWeightsFileSet.IsNull())
    228         if (!ReadWeightsFile(fNameWeightsFile))
    229             return kFALSE;
    230 
    231     fTimeShiftHiGain = (Float_t)fHiGainFirst + 0.5 + 1./fBinningResolutionHiGain;
     230    case kFALSE: // No new weights set
     231        return kTRUE;
     232    }
     233
     234    // New weights set
     235    fTimeShiftHiGain = 0.5 + 1./fBinningResolutionHiGain + fHiGainFirst;
    232236    fTimeShiftLoGain = 0.5 + 1./fBinningResolutionLoGain;
     237
    233238    //
    234239    // We need here the effective number of samples which is about 2.5 in the case of a window
     
    240245    fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
    241246
     247    // From MExtractTimeAndCharge::ReInit
     248    if (fSignals)
     249        fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
     250                                    fLoGainFirst, fLoGainLast, fNumLoGainSamples);
    242251    return kTRUE;
     252}
     253
     254// --------------------------------------------------------------------------
     255//
     256// InitArrays
     257//
     258// Gets called in the ReInit() and initialized the arrays
     259//
     260Bool_t MExtractTimeAndChargeDigitalFilter::InitArrays()
     261{
     262    if (!fRunHeader)
     263        return kFALSE;
     264
     265    const Int_t rangehi = (Int_t)(fHiGainLast - fHiGainFirst + 1 + fHiLoLast);
     266    const Int_t rangelo = (Int_t)(fLoGainLast - fLoGainFirst + 1);
     267
     268    fHiGainSignal.Set(rangehi);
     269    fLoGainSignal.Set(rangelo);
     270
     271    return GetWeights();
     272}
     273
     274// --------------------------------------------------------------------------
     275//
     276// Check if reading a new weights file is necessary because the calibration
     277// pattern has changed. (Cannot be done in ReInit, because at this time
     278// the calibration pattern is not available.
     279// Then process the event.
     280//
     281Int_t MExtractTimeAndChargeDigitalFilter::Process()
     282{
     283    // Change Weights if the calibration patter changes
     284    if (!GetWeights())
     285        return kERROR;
     286
     287    // Process event
     288    return MExtractTimeAndCharge::Process();
    243289}
    244290
     
    643689//----------------------------------------------------------------------------
    644690//
     691// If automatic weights are requested, no default weights (name.IsNull())
     692// are requested, fRunHeader is available and fRunHeader->IsMonteCarloRun()
     693// is true prepend "MC_" in from of the name.
     694//
     695// return poth+name;
     696//
     697TString MExtractTimeAndChargeDigitalFilter::CompileWeightFileName(TString path, const TString &name) const
     698{
     699    if (fAutomaticWeights && !name.IsNull() && fRunHeader && fRunHeader->IsMonteCarloRun())
     700        path += "MC_";
     701
     702    path += name;
     703
     704    return path;
     705}
     706
     707//----------------------------------------------------------------------------
     708//
    645709// Read a pre-defined weights file into the class.
    646710// This is mandatory for the extraction
     
    648712// If filenname is empty, then all weights will be set to 1.
    649713//
    650 Bool_t MExtractTimeAndChargeDigitalFilter::ReadWeightsFile(TString filename)
    651 {
    652  
    653     // This is a fix for TEnv files edited with windows editors
    654     filename.ReplaceAll("\015", "");
    655 
    656     fAmpWeightsHiGain .Set(fBinningResolutionHiGain*fWindowSizeHiGain);
    657     fAmpWeightsLoGain .Set(fBinningResolutionLoGain*fWindowSizeLoGain);
    658     fTimeWeightsHiGain.Set(fBinningResolutionHiGain*fWindowSizeHiGain);
    659     fTimeWeightsLoGain.Set(fBinningResolutionLoGain*fWindowSizeLoGain);
    660 
    661     if (fNameWeightsFile.IsNull() || fNameWeightsFile=="-")
    662     {
     714// Returns:
     715//  kTRUE:  new weights set
     716//  kFALSE: no  weights set
     717//  kERROR: error
     718//
     719Int_t MExtractTimeAndChargeDigitalFilter::ReadWeightsFile(TString filename, TString path)
     720{
     721    if (filename.IsNull())
     722    {
     723        fAmpWeightsHiGain .Set(fBinningResolutionHiGain*fWindowSizeHiGain);
     724        fAmpWeightsLoGain .Set(fBinningResolutionLoGain*fWindowSizeLoGain);
     725        fTimeWeightsHiGain.Set(fBinningResolutionHiGain*fWindowSizeHiGain);
     726        fTimeWeightsLoGain.Set(fBinningResolutionLoGain*fWindowSizeLoGain);
     727
    663728        fAmpWeightsHiGain.Reset(1);
    664729        fTimeWeightsHiGain.Reset(1);
    665730        fAmpWeightsLoGain.Reset(1);
    666731        fTimeWeightsLoGain.Reset(1);
    667         fNameWeightsFileSet = "-";
    668732        return kTRUE;
    669733    }
    670734
     735    // Add "MC_" in front of the filename if necessary
     736    filename = CompileWeightFileName(path, filename);
     737
    671738    //filename = MJob::ExpandPath(filename);
    672739
    673740    if (fNameWeightsFileSet==filename)
    674         return kTRUE;
     741        return kFALSE; // No file read
    675742
    676743    ifstream fin(filename.Data());
     
    679746        *fLog << err << GetDescriptor() << ": ERROR - Cannot open file " << filename << ": ";
    680747        *fLog << strerror(errno) << endl;
    681         return kFALSE;
    682     }
    683 
    684     *fLog << all << "DigitalFilter: Reading weights in " << filename << "..." << flush;
     748        return kERROR;
     749    }
     750
     751    *fLog << all << GetDescriptor() << ": Reading weights in " << filename << "..." << flush;
    685752
    686753    Int_t len = 0;
     
    705772            {
    706773                *fLog << err << "ERROR - 'High Gain Weights' found twice in line #" << line << "." << endl;
    707                 return kFALSE;
     774                return kERROR;
    708775            }
    709776
     
    712779                *fLog << err << "ERROR - Wrong number of arguments in line #" << line << ":" << endl;
    713780                *fLog << str << endl;
    714                 return kFALSE;
     781                return kERROR;
    715782            }
    716783
     
    727794            {
    728795                *fLog << err << "ERROR - 'Lo Gain Weights' found twice in line #" << line << "." << endl;
    729                 return kFALSE;
     796                return kERROR;
    730797            }
    731798
     
    734801                *fLog << err << "ERROR - Wrong number of arguments in line #" << line << ":" << endl;
    735802                *fLog << str << endl;
    736                 return kFALSE;
     803                return kERROR;
    737804            }
    738805
     
    758825            *fLog << err << "ERROR - Wrong number of arguments in line #" << line << ":" << endl;
    759826            *fLog << str << endl;
    760             return kFALSE;
     827            return kERROR;
    761828        }
    762829
     
    770837    if (cnt != len)
    771838    {
    772         *fLog << err << "Size mismatch in weights file " << filename << endl;
    773         return kFALSE;
     839        *fLog << err << "ERROR - Size mismatch in weights file " << filename << endl;
     840        return kERROR;
    774841    }
    775842
    776843    if (!hi)
    777844    {
    778         *fLog << err << "No correct header found in weights file " << filename << endl;
    779         return kFALSE;
     845        *fLog << err << "ERROR - No correct header found in weights file " << filename << endl;
     846        return kERROR;
    780847    }
    781848
     
    824891//----------------------------------------------------------------------------
    825892//
    826 // If automatic weight disabled or run type is pedestal no action is taken
    827 // and kTRUE is returned.
    828 //
    829 // Otherwise:
    830 //  - If runtype is kRTData and filename starts with "MC_weights" "MC" is
    831 //    replaced by "cosmics"
    832 //  - If runtype is kRTMonteCarlo and filename starts with "cosmics_weights"
    833 //    "cosmics" is replaced by "MC"
    834 //  - If name filename begins with "calibration_weights_" for blue and green
    835 //    "UV" is replaced by "blue"
    836 //  - If name filename begins with "calibration_weights_" for UV and CT1
    837 //    "blue" is replaced by "UV"
    838 //
    839 // The replacements are done in this order. If no match is found no
    840 // replacement is done. Afterwards ReadWeightsFile for the resulting
    841 // path-/filename is called.
    842 //
    843 Bool_t MExtractTimeAndChargeDigitalFilter::ReadAutomaticWeightsFile()
    844 {
    845     if (!fAutomaticWeights || fRunHeader->GetRunType()==MRawRunHeader::kRTPedestal)
    846         return kTRUE;
    847 
    848     if (fNameWeightsFile.IsNull())
    849     {
    850         *fLog << err << "ERROR - Cannot get automatic weights without default filename." << endl;
    851         return kFALSE;
    852     }
    853 
    854     *fLog << dbg << endl;
    855     *fLog << underline << GetDescriptor() << endl;
    856     *fLog << " Trying to get automatic weight for " << fNameWeightsFile << endl;
    857 
     893// The default (+ prepending possible "MC_") is read for:
     894//
     895//   - RunType: Pedestal (independant of fAutomaticWeights)
     896//   - fAutomaticWeights disabled
     897//
     898//  if fAutomaticWeights enabled:
     899//   - fNameWeightsFile.IsNull()
     900//   - !fCalibPattern
     901//   - fCalibPattern->GetPulserColor()==MCalibrationCam::kNONE
     902//
     903// If automatic weights are enabled, the case above didn't take place and
     904// fNameWeightsFile starts with "calibration_weights_"
     905//   - the color (blue, UV) is replaced by the appropriate one
     906//     taken from the calibration pattern
     907//
     908// In most cases a debug output is printed. Further output about the color
     909// determination can be switched on with debug level > 5;
     910//
     911// Returns:
     912//  kFALSE: No new weights set
     913//  kTRUE:  New weights set
     914//  kERROR: Error
     915//
     916Int_t MExtractTimeAndChargeDigitalFilter::GetAutomaticWeights()
     917{
    858918    const Ssiz_t pos = fNameWeightsFile.Last('/')+1;
    859919    const Ssiz_t len = fNameWeightsFile.Length();
    860920
     921    // Split file name in path and name
    861922    TString path = fNameWeightsFile(0, pos>=0?pos:len);
    862923    TString name = fNameWeightsFile(pos>=0?pos:0, len);
    863924
    864     if (name.BeginsWith("cosmics_weights") && fRunHeader->GetRunType()==MRawRunHeader::kRTMonteCarlo)
    865     {
    866         name.Remove(0, 7);
    867         name.Prepend("MC");
    868         *fLog << "Run type: Monte Carlo data" << endl;
    869     }
    870     if (name.BeginsWith("MC_weights") && fRunHeader->GetRunType()==MRawRunHeader::kRTData)
    871     {
    872         name.Remove(0, 2);
    873         name.Prepend("cosmics");
    874         *fLog << "Run type: Cosmics data" << endl;
     925    // Remove trailing "MC_" for automatic weights
     926    if (fAutomaticWeights && name.BeginsWith("MC_"))
     927        name.Remove(0, 3);
     928
     929    // In case of a pedetsal run no calibration pattern can be available
     930    // the default weights are always used.
     931    if (fRunHeader->GetRunType()==MRawRunHeader::kRTPedestal)
     932    {
     933        *fLog << dbg << "Pedestal file... using default weights: " << fNameWeightsFile << endl;
     934        return ReadWeightsFile(name, path);
     935    }
     936
     937    // If automatic weights are switched off use default weights
     938    if (!fAutomaticWeights)
     939    {
     940        *fLog << dbg << "Automatic weights switched off... using default weights: " << fNameWeightsFile << endl;
     941        return ReadWeightsFile(name, path);
     942    }
     943
     944    // If automatic weights are switched on but no filename is given raise error
     945    if (fNameWeightsFile.IsNull())
     946    {
     947        *fLog << err << "ERROR - Cannot get automatic weights without default filename." << endl;
     948        return kERROR;
     949    }
     950
     951    // If this is no pedestal run, automatic weights are requested and a
     952    // filename for the weights file is given pedestal-extraction from
     953    // cosmics data is assumed.
     954    if (!fCalibPattern)
     955    {
     956        *fLog << dbg << "No decoded calibration pattern available... using default weights: " << fNameWeightsFile << endl;
     957        return ReadWeightsFile(name, path);
     958    }
     959
     960    const Bool_t debug = gLog.GetDebugLevel()>5;
     961
     962    // If no calibration pattern is available do not change the
     963    // current weighs or current weights file name.
     964    if (fCalibPattern->GetPulserColor()==MCalibrationCam::kNONE)
     965    {
     966        // If we are extracting data and the calibration pattern is kNONE
     967        // we assume that it is a data file without interleaved events
     968        // and calibration pattern information available.
     969        if ((fRunHeader->GetRunType()!=MRawRunHeader::kRTData && !fRunHeader->IsMonteCarloRun()) || debug)
     970            *fLog << dbg << "No calibration color set so far... guessing default: " << fNameWeightsFile << endl;
     971
     972        return ReadWeightsFile(name, path);
     973    }
     974
     975    if (debug)
     976    {
     977        *fLog << dbg << endl;
     978        *fLog << underline << GetDescriptor() << endl;
     979        *fLog << " Trying to get automatic weight for " << fNameWeightsFile << endl;
     980        *fLog << " Run type: ";
    875981    }
    876982
    877983    if (name.BeginsWith("calibration_weights_") && fCalibPattern)
    878984    {
    879         *fLog << " Run type: Calibration with color " << (int)fCalibPattern->GetPulserColor() << ", setting ";
     985        if (debug)
     986            *fLog << " Calibration with color " << fCalibPattern->GetPulserColorStr() << ", setting ";
    880987        switch (fCalibPattern->GetPulserColor())
    881988        {
    882989        case MCalibrationCam::kBLUE:  // 2
    883990        case MCalibrationCam::kGREEN: // 1
    884             *fLog << "blue/green" << endl;
     991            if (debug)
     992                *fLog << "blue/green, ";
    885993            name.ReplaceAll("UV", "blue");
    886994            break;
     
    888996        case MCalibrationCam::kUV:    // 3
    889997        case MCalibrationCam::kCT1:   // 0
    890             *fLog << "UV/CT1" << endl;
     998            if (debug)
     999                *fLog << "UV/CT1, ";
    8911000            name.ReplaceAll("blue", "UV");
    8921001            break;
    8931002        case MCalibrationCam::kNONE:
    894             *fLog << "None" << endl;
    8951003            break;
    896         default: // kNONE=4
    897             *fLog << "???" << endl;
    898         }
    899     }
    900 
    901     path += name;
    902 
    903     return ReadWeightsFile(path);
     1004        default: // kNone + etc
     1005            *fLog << err << "ERROR - Cannot get automatic weights for " << fCalibPattern->GetPulserColorStr() << endl;
     1006            return kERROR;
     1007        }
     1008    }
     1009
     1010    return ReadWeightsFile(name, path);
    9041011}
    9051012
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.h

    r7099 r7194  
    6969  // MExtractTimeAndChargeDigitalFilter
    7070  void    CalcBinningResArrays();
    71   Bool_t  ReadAutomaticWeightsFile();
     71  Int_t   GetAutomaticWeights();
     72  Bool_t  GetWeights();
     73  Int_t   ReadWeightsFile(TString filename, TString path="");
     74  TString CompileWeightFileName(TString path, const TString &name) const;
    7275
    7376  // MExtractTimeAndCharge
     
    7679  // MTask
    7780  Int_t PreProcess(MParList *pList);
     81  Int_t Process();
    7882
    7983protected:
     
    8589  ~MExtractTimeAndChargeDigitalFilter() { }
    8690
    87   Bool_t ReadWeightsFile(TString filename);
    88  
    8991  Bool_t WriteWeightsFile(TString filename,
    9092                          TH1F *shapehi, TH2F *autocorrhi,
     
    9294
    9395
    94   void SetNameWeightsFile(TString s="") { fNameWeightsFile = s; fNameWeightsFileSet=""; }
     96  void SetNameWeightsFile(TString s="") { s.ReplaceAll("\015", ""); // This is a fix for TEnv files edited with windows editors
     97      fNameWeightsFile = s; fNameWeightsFileSet=""; }
    9598  void EnableAutomaticWeights(Bool_t b=kTRUE) { fAutomaticWeights = b; }
    9699
Note: See TracChangeset for help on using the changeset viewer.