Changeset 4235


Ignore:
Timestamp:
05/28/04 16:09:39 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r4227 r4235  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2004/05/28: Markus Gaug
     22
     23   * macros/calibration.C
     24     - make the macro compilable with possibility to run it in batch
     25       mode.
     26
     27   * msignal/MExtractor.cc
     28     - put an additional check in case that the number of FADC slices
     29       in the run header is smaller or equal to 0.
     30
    2031
    2132 2004/05/27: Javier Rico
  • trunk/MagicSoft/Mars/macros/calibration.C

    r4122 r4235  
    5555//
    5656/////////////////////////////////////////////////////////////////////////////
    57 static const TString outpath = "./";
     57#include "MJPedestal.h"
     58#include "MJCalibration.h"
     59#include "MJExtractCalibTest.h"
     60#include "TObject.h"
     61#include "TObjectTable.h"
     62#include "MExtractFixedWindowPeakSearch.h"
     63#include "MExtractSlidingWindow.h"
     64#include "MExtractFixedWindow.h"
     65#include "MExtractTimeHighestIntegral.h"
     66#include "MExtractTimeFastSpline.h"
     67#include "MRunIter.h"
     68#include "MStatusDisplay.h"
     69#include "TStyle.h"
     70#include "MCalibrationQECam.h"
     71#include "MHCalibrationTestCam.h"
     72#include "MHCalibrationTestPix.h"
     73#include "MBadPixelsCam.h"
     74#include "MArgs.h"
     75#include "MArray.h"
     76#include "MLog.h"
     77#include "MParContainer.h"
     78
     79using namespace std;
     80
     81static TString outpath = "./";
    5882static const TString inpath = "./";
    59 //static const TString inpath = "/home/rootdata/Calib/";
    60 //
    61 // Tell if you want to calibrate times:
    62 //
    63 static const  Bool_t useTimes = kTRUE;
    6483//
    6584// the default pedestal run for the calibration
    6685//
    67 static const Int_t   pedrun  = 26210;
     86static const Int_t   pedrun  = 26851;
    6887//
    6988// the default start calibration run
    7089//
    71 static const Int_t   calrun1 = 26209;
     90static const Int_t   calrun1 = 26849;
    7291//
    7392// the default last calibration run (if 0, only one run is taken, otherwise consecutive runs
    7493// between calrun1 and calrun2)
    7594//
    76 static const Int_t calrun2 = 0;
     95static  const Int_t calrun2 = 0;
    7796//
    7897// A switch to output debugging information about Objects use
    7998//
    80 static const Bool_t debug = kFALSE;
    81 //
    82 void calibration(const Int_t prun=pedrun, const Int_t crun1=calrun1, const Int_t crun2=calrun2)
     99static Bool_t debug = kFALSE;
     100//
     101// A switch to use the Blind Pixel
     102//
     103static Bool_t blindpix = kTRUE;
     104//
     105// A switch to use the PIN Diode
     106//
     107static Bool_t pindiode = kFALSE;
     108//
     109// Tell if you want to calibrate times:
     110//
     111static Bool_t useTimes = kFALSE;
     112//
     113// Tell if you want to use the display:
     114//
     115static Bool_t useDisplay = kTRUE;
     116//
     117Int_t calibration(const Int_t prun=pedrun,
     118                  const Int_t crun1=calrun1, const Int_t crun2=calrun2)
    83119{
    84120
    85 
    86   TObject::SetObjectStat(kTRUE);
     121  if (debug)
     122    TObject::SetObjectStat(kTRUE);
    87123
    88124  //
     
    91127  //  MExtractFixedWindowPeakSearch extractor;
    92128  //  MExtractSlidingWindow  extractor;   
    93    MExtractFixedWindow    extractor;   
     129  MExtractFixedWindow extractor;   
    94130
    95131  //
    96132  // Set Ranges or Windows
    97133  //
    98    extractor.SetRange(3,14,3,14);
     134  extractor.SetRange(0,15,3,14);
     135   // extractor.SetRange(5,9 ,5,9 );
    99136  //  extractor.SetWindows(8,8);
    100137
     
    107144  // Set Ranges or Windows
    108145  //
    109   timeext.SetRange(2,12,4,14);
     146  timeext.SetRange(1,14,3,14);
    110147
    111148  MRunIter pruns;
     
    119156    cruns.AddRuns(crun1,crun2,inpath);
    120157
    121   gStyle->SetOptStat(1);
     158  gStyle->SetOptStat(111111);
    122159  gStyle->SetOptFit();
    123160
    124   MStatusDisplay *display = new MStatusDisplay;
    125   display->SetUpdateTime(3000);
    126   display->Resize(850,700);
     161  MStatusDisplay *display = NULL;
     162
     163  if (useDisplay)
     164    {
     165      display = new MStatusDisplay;
     166      display->SetUpdateTime(3000);
     167      display->Resize(850,700);
     168    }
    127169 
    128170  /************************************/
     
    132174  MCalibrationQECam qecam;
    133175  MBadPixelsCam     badcam;
    134   MGeomCamMagic     geomcam;
    135   MGeomApply        geomapl;
    136176  //
    137177  // If you want to exclude pixels from the beginning, read
    138178  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
    139179  //
    140 //  badcam.AsciiRead("badpixels.dat");
     180  //  badcam.AsciiRead("badpixels.dat");
    141181
    142182  MJPedestal pedloop;
     
    144184  pedloop.SetInput(&pruns);
    145185  pedloop.SetOutputPath(outpath.Data());
    146   pedloop.SetDisplay(display);
     186  if (useDisplay)
     187    pedloop.SetDisplay(display);
    147188  pedloop.SetBadPixels(badcam);
    148189
    149190  if (!pedloop.Process())
    150     return;
     191    return 1;
    151192
    152193  /****************************************/
     
    174215  calloop.SetInput(&cruns);
    175216  calloop.SetOutputPath(outpath.Data());
    176   calloop.SetDisplay(display);
     217  if (useDisplay)
     218    calloop.SetDisplay(display);
     219  calloop.SetUseBlindPixel(blindpix);
     220  calloop.SetUsePINDiode(pindiode);
    177221  calloop.SetQECam(qecam);
    178222  calloop.SetBadPixels(pedloop.GetBadPixels());
    179223
    180   calloop.Process(pedloop.GetPedestalCam());
     224  if (!calloop.Process(pedloop.GetPedestalCam()))
     225    return 2;
     226
     227  //
     228  // The next lines are the use the Print() function and have
     229  // all the results as ascii-tables:
     230  //
     231  if (debug)
     232    {
     233      MCalibrationChargeCam &chargecam   = calloop.GetCalibrationCam();
     234      MCalibrationQECam     &nqecam      = calloop.GetQECam();
     235      MBadPixelsCam         &badbad      = calloop.GetBadPixels();
     236      chargecam.Print();
     237      nqecam.Print();
     238      badbad.Print();
     239    }
     240
     241  gLog << endl;
     242  gLog << "Mean number of photons from pulser Inner pixels (F-Factor Method): "
     243       << calloop.GetCalibrationCam().GetNumPhotonsFFactorMethod()
     244       << " +- " << calloop.GetCalibrationCam().GetNumPhotonsFFactorMethodErr() << endl;
     245  gLog << endl;
    181246
    182247  /********************************************************************/
     
    190255  testloop.SetInput(&cruns);
    191256  testloop.SetOutputPath(outpath);
    192   testloop.SetDisplay(display);
     257  if (useDisplay)
     258    testloop.SetDisplay(display);
    193259  testloop.SetBadPixels(calloop.GetBadPixels());
    194   testloop.ProcessD(pedloop.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam());
     260 
     261  if (!testloop.ProcessD(pedloop.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
     262    return 3;
     263
    195264  if (useTimes)
    196       testloop.ProcessT(pedloop.GetPedestalCam(),calloop.GetRelTimeCam());
    197 
    198   TObject::SetObjectStat(kFALSE);
    199   //
    200   // List of useful containers:
     265    if (!testloop.ProcessT(pedloop.GetPedestalCam(),calloop.GetRelTimeCam()))
     266      return 4;
     267
     268  gLog << endl;
     269  gLog << "Mean equiv. number of photons from cascades per mm^2 Inner pixels: "
     270       << testloop.GetTestCam().GetMeanMeanPhotPerArea(0)
     271       << " +- " << testloop.GetTestCam().GetRmsMeanPhotPerArea(0) << endl;
     272  gLog << "Sigma equiv. number of photons from cascades per mm^2 Inner pixels: "
     273       << testloop.GetTestCam().GetMeanSigmaPhotPerArea(0)
     274       << " +- " << testloop.GetTestCam().GetRmsSigmaPhotPerArea(0) << endl;
     275
     276  gLog << endl;
     277  gLog << "Mean equiv. number of photons from cascades per mm^2 Outer pixels: "
     278       << testloop.GetTestCam().GetMeanMeanPhotPerArea(1)
     279       << " +- " << testloop.GetTestCam().GetRmsMeanPhotPerArea(1) << endl;
     280  gLog << "Sigma equiv. number of photons from cascades per mm^2 Outer pixels: "
     281       << testloop.GetTestCam().GetMeanSigmaPhotPerArea(1)
     282       << " +- " << testloop.GetTestCam().GetRmsSigmaPhotPerArea(1) << endl;
     283  gLog << endl; 
     284
     285
     286  if (debug)
     287    TObject::SetObjectStat(kFALSE);
     288
     289  //
     290  // Debugging at the end:
    201291  //
    202292  if (debug)
     
    206296  // List of useful containers:
    207297  //
     298  MHCalibrationTestCam  &testcam     = testloop.GetTestCam();
     299  testcam[100].DrawClone("events");
     300
    208301/*
    209302  MPedestalCam          &pedcam      = pedloop.GetPedestalCam();
     
    214307  MHCalibrationTestTimeCam &testtime = testloop.GetTestTimeCam();
    215308*/
     309
     310  //
     311  // List of interesting plots:
     312  //
     313/*
     314  testcam.GetAverageHiGainArea(0).DrawClone();
     315  testcam.GetAverageLoGainArea(0).DrawClone();
     316  testcam.GetAverageHiGainArea(1).DrawClone();
     317  testcam.GetAverageLoGainArea(1).DrawClone();
     318
     319  testcam.GetAverageHiGainSector(1).DrawClone();
     320  testcam.GetAverageLoGainSector(1).DrawClone();
     321  testcam.GetAverageHiGainSector(2).DrawClone();
     322  testcam.GetAverageLoGainSector(2).DrawClone();
     323  testcam.GetAverageHiGainSector(3).DrawClone();
     324  testcam.GetAverageLoGainSector(3).DrawClone();
     325  testcam.GetAverageHiGainSector(4).DrawClone();
     326  testcam.GetAverageLoGainSector(4).DrawClone();
     327  testcam.GetAverageHiGainSector(5).DrawClone();
     328  testcam.GetAverageLoGainSector(5).DrawClone();
     329  testcam.GetAverageHiGainSector(6).DrawClone();
     330  testcam.GetAverageLoGainSector(6).DrawClone();
     331*/
     332  return 0;
     333
    216334}
    217335
    218 
     336static void Usage()
     337{
     338    gLog << endl;
     339    gLog << "Usage:" << endl;
     340    gLog << endl;
     341    gLog << "   calibration [ped.run nr.] [first cal.run nr.] [last cal.run nr.]" << endl ;
     342    gLog << endl;
     343    gLog << "   ped.run.nr:        Run number of the pedestal file." << endl;
     344    gLog << "   first cal.run nr.: Run number of the first calibration file." << endl;
     345    gLog << "   last  cal.run nr.: Run number of the last  calibration file." << endl;
     346    gLog << endl;
     347    gLog << "All calibration runs between (first cal.run nr.) and (last  cal.run nr.) will be used" << endl;
     348    gLog << "If last.cal.run.nr is 0 (default), only one calibration run is taken"                  << endl;
     349    gLog << endl;
     350    gLog << "Additional Options: " << endl;
     351    gLog << "     --inpath=#          Find the data in inpath"                      << endl;
     352    gLog << "     --outpath=#         Write the output containers to outpath"       << endl;
     353    gLog << "     --debug             Use the TObjectTable for debugging    "       << endl;
     354    gLog << "                             and write out the pixels as ascii tables" << endl;
     355    gLog << "     --useTimes          Calibrate the relative arrival times"         << endl;
     356    gLog << "     --skipBlindPix      Skip the blind pixel calibration"             << endl;
     357    gLog << "     --skipPINDiode      Skip the PIN Diode   calibration"             << endl;
     358}
     359
     360
     361int main(int argc, char **argv)
     362{
     363  //
     364  // Evaluate arguments
     365  //
     366  MArgs arg(argc, argv);
     367 
     368  if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
     369    {
     370      Usage();
     371      return -1;
     372    }
     373 
     374  debug    = arg.HasOnlyAndRemove("--debug")    || arg.HasOnlyAndRemove("-d");
     375  useTimes = arg.HasOnlyAndRemove("--useTimes") || arg.HasOnlyAndRemove("-t");
     376  blindpix = !(arg.HasOnlyAndRemove("--skipBlindPix"));
     377  pindiode = !(arg.HasOnlyAndRemove("--skipPINDiode"));
     378
     379  if (arg.HasOption("--inpath="))
     380    inpath = arg.GetStringAndRemove("--inpath=");
     381
     382  if (arg.HasOption("--outpath="))
     383    outpath = arg.GetStringAndRemove("--outpath=");
     384
     385  //
     386  // check for the right usage of the program
     387  //
     388  if (arg.GetNumArguments()>4)
     389    {
     390      Usage();
     391      return -1;
     392    }
     393
     394  //
     395  // Initialize Non-GUI (batch) mode
     396  //
     397  gROOT->SetBatch();
     398 
     399  //
     400  // Switch off the display
     401  //
     402  useDisplay = kFALSE;
     403
     404
     405  //
     406  // check for the arguments
     407  //
     408  Int_t pedr  = 0;
     409  Int_t calr1 = 0;
     410  Int_t calr2 = 0;
     411
     412  const Int_t nargs = arg.GetNumArguments();
     413
     414  if (nargs>=3)
     415    {
     416      pedr = arg.GetArgumentInt(0);
     417      calr1 = arg.GetArgumentInt(1);
     418      calr2 = arg.GetArgumentInt(2);
     419      return calibration(pedr,calr1,calr2);
     420    }
     421
     422  if (nargs>=2)
     423    {
     424      pedr = arg.GetArgumentInt(0);
     425      calr1 = arg.GetArgumentInt(1);
     426      return calibration(pedr,calr1);
     427    }
     428
     429  if (nargs>=1)
     430    {
     431      pedr = arg.GetArgumentInt(0);
     432      gLog << "PEDR: " << pedr << endl;
     433      return calibration(pedr);
     434    }
     435
     436  return calibration();
     437}
  • trunk/MagicSoft/Mars/msignal/MExtractor.cc

    r3962 r4235  
    181181  Int_t lastdesired   = (Int_t)(fLoGainLast);
    182182  Int_t lastavailable = (Int_t)fRunHeader->GetNumSamplesLoGain()-1;
     183
     184  if (lastavailable < 0)
     185    *fLog << warn << GetDescriptor()
     186          << ": WARNING: Number of available Low-Gain Slices is smaller than or equal zero!" << endl;
    183187 
    184188  if (lastdesired > lastavailable)
     
    197201  lastavailable = (Int_t)fRunHeader->GetNumSamplesHiGain()-1;
    198202 
     203  if (lastavailable < 0)
     204    {
     205      *fLog << err << GetDescriptor()
     206            << ": ERROR: Number of available High-Gain Slices is smaller than or equal zero!" << endl;
     207      return kFALSE;
     208    }
     209
    199210  if (lastdesired > lastavailable)
    200211    {
Note: See TracChangeset for help on using the changeset viewer.