Ignore:
Timestamp:
11/30/04 20:43:15 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/macros/calibration.C

    r5411 r5532  
    5555//
    5656//////////////////////////////////////////////////////////////////////////////////////////
     57#include "getExtractor.C"
     58
    5759#include "MJPedestal.h"
    5860#include "MJCalibration.h"
    5961#include "MJExtractSignal.h"
    6062#include "MJExtractCalibTest.h"
    61 #include "MExtractFixedWindowPeakSearch.h"
    62 #include "MExtractSlidingWindow.h"
    63 #include "MExtractFixedWindow.h"
    64 #include "MExtractFixedWindowSpline.h"
    65 #include "MExtractAmplitudeSpline.h"
    66 #include "MExtractTimeHighestIntegral.h"
    67 #include "MExtractTimeFastSpline.h"
    68 #include "MExtractTimeAndChargeDigitalFilter.h"
    69 #include "MExtractTimeAndChargeSlidingWindow.h"
    70 #include "MExtractTimeAndChargeSpline.h"
    7163#include "MRunIter.h"
    7264#include "MStatusDisplay.h"
     
    7668#include "MArgs.h"
    7769#include "MArray.h"
    78 #include "MLog.h"
    7970#include "MParContainer.h"
    8071
     
    8273#include "TObject.h"
    8374#include "TObjectTable.h"
    84 #include "TSystem.h"
    85 
    86 #include <fstream>
     75#include "TCanvas.h"
     76#include "TPad.h"
     77#include "TH1.h"
     78#include "TPaveStats.h"
    8779
    8880using namespace std;
    8981
    9082static TString outpath = "./";
    91 static TString inpath  = "/home/rootdata/Calib/2004_07_06";
    92 static TString badfile = "";
    93 //static TString badfile = "badpixels_only0_559_560.dat";
    94 static TString weightfile = "msignal/calibration_weights_UV.dat";
    95 //static TString weightfile = "msignal/cosmics_weights.dat";
     83static TString inpath  = "/home/rootdata/Calib/2004_09_22";
     84//static TString badfile = "";
     85static TString badfile = "badpixels_only0_388_559.dat";
    9686//
    9787// the default pedestal run for the calibration
    9888//
    99 static const Int_t   pedrun  = 31756;
     89static const Int_t   pedrun  = 38995;
    10090//
    10191// the default start calibration run
    10292//
    103 static const Int_t   calrun1 = 31755;
     93static const Int_t   calrun1 = 38997;
    10494//
    10595// the default last calibration run (if 0, only one run is taken, otherwise consecutive runs
     
    120110static Bool_t pindiode = kTRUE;
    121111//
    122 // Tell if you want to calibrate times:
    123 //
    124 static Bool_t useTimes = kTRUE;
    125 //
    126 // Tell if you want to use a combined extractor:
    127 //
    128 static Bool_t useTimeAndCharge = kTRUE;
    129 //
    130112// Tell if you want to use the display:
    131113//
     
    140122static Bool_t useIntensity = kFALSE;
    141123//
    142 // Tell if you want to use MPedCalcFromLogain for the pedestal calculation
    143 //
    144 static Bool_t usedata      = kFALSE;
    145 //
    146124// Tell if you want to store and read the F0 and F1- files
    147125//
    148126static Bool_t usestorage   = kFALSE;
    149127//
    150 Int_t calibration(const Int_t prun=pedrun,
     128// Tell which extractor you want to use. The flags are counted according
     129// to the extractor-TDAS
     130//
     131static Int_t extractorflag = 1;
     132//
     133Int_t calibration(const UInt_t extflag=extractorflag, const Int_t prun=pedrun,
    151134                  const Int_t crun1=calrun1, const Int_t crun2=calrun2)
    152135{
    153136
     137  MExtractor *extractor = getExtractor(extflag);
     138
     139  if (!extractor)
     140    return 99;
     141
     142  extractor->SetName(Form("%s_Run_%05d",extractor->GetName(),prun));
     143  const Bool_t timeandcharge = extractor->InheritsFrom("MExtractTimeAndCharge");
     144
     145  gStyle->SetOptStat(1111);
     146  gStyle->SetOptFit();
     147  gStyle->SetTitleSize(0.35,"u");
     148  gStyle->SetTitleFontSize(0.9);
     149  gStyle->SetTitleH(0.12);
     150  gStyle->SetTitleW(0.95);
     151  gStyle->SetLineWidth(1);
     152
    154153  if (debug)
    155154    TObject::SetObjectStat(kTRUE);
    156 
    157   //
    158   // Choose the signal Extractor:
    159   //
    160   // PURE CHARGE EXTRACTORS:
    161   //  MExtractFixedWindowPeakSearch  extractor;
    162   //  MExtractSlidingWindow         extractor;   
    163   //  MExtractFixedWindow           extractor;
    164   //  MExtractFixedWindowSpline     extractor;
    165   //  MExtractAmplitudeSpline       extractor;
    166   //
    167   // PURE TIME EXTRACTORS:
    168   // ATTENTION: If an extractor deriving from MExtractTimeAndCharge is
    169   //            used, you may want to use the timing calculated directly
    170   //            from there. Use the flag: "useTimeAndCharge" in this case
    171   //
    172   //  MExtractTimeHighestIntegral timeext;
    173   MExtractTimeFastSpline timeext;
    174   //  MExtractTimeSpline timeext;
    175   //
    176   // COMBINED TIME AND CHARGE EXTRACTORS:
    177   // (You have to set the variable "useTimeAndCharge" in order to use the
    178   //  time calculated by this extractor!)
    179   MExtractTimeAndChargeDigitalFilter extractor;
    180   //  MExtractTimeAndChargeSpline   extractor;
    181   //  MExtractTimeAndChargeSlidingWindow extractor;
    182   //
    183   //  Set Ranges or Windows
    184   //
    185   //  extractor.SetRange(1,14,4,12);
    186   //  extractor.SetWindowSize(6,6);
    187   //  timeext.SetRange(1,14,4,12);
    188   //  timeext.SetWindowSize(6,6);
    189   //
    190   // Set additional information for some extractors
    191   //
    192   // Digital Filter:
    193   extractor.ReadWeightsFile(weightfile.Data());
    194   //  extractor.ReadWeightsFile("");
    195   // TimeAndChargeSpline:
    196   //  extractor.SetChargeType(MExtractTimeAndChargeSpline::kIntegral);
    197   //  extractor.SetTimeType(MExtractTimeAndChargeSpline::kHalfMaximum);
    198155
    199156  MRunIter pruns;
     
    207164    cruns.AddRuns(crun1,crun2,inpath);
    208165
    209   gStyle->SetOptStat(1111);
    210   gStyle->SetOptFit();
    211   gStyle->SetTitleSize(0.1,"u");
    212   gStyle->SetLineWidth(1);
    213 
    214166  MStatusDisplay *display = NULL;
    215167
     
    221173    }
    222174 
    223   /************************************/
    224   /* FIRST LOOP: PEDESTAL COMPUTATION */
    225   /************************************/
    226 
     175  /*****************************************/
     176  /* FIRST LOOP: PURE PEDESTAL COMPUTATION */
     177  /*****************************************/
    227178  //
    228179  // Hand over to the jobs a QE Cam with Cornings initialized
     
    241192    }
    242193
    243   MJPedestal pedloop;
    244   if (usedata)
    245    pedloop.SetUseData();
    246   pedloop.SetNoStorage(!usestorage);
    247   pedloop.SetEnvDebug(debug);
    248   pedloop.SetExtractor(&extractor);
    249   pedloop.SetInput(&pruns);
    250   pedloop.SetPathOut(outpath.Data());
     194  MJPedestal pedloop1;
     195  pedloop1.SetNoStorage(!usestorage);
     196  pedloop1.SetEnvDebug(debug);
     197  pedloop1.SetExtractor(extractor);
     198  pedloop1.SetInput(&pruns);
     199  pedloop1.SetPathOut(outpath.Data());
    251200  if (useDisplay)
    252201    {
    253       pedloop.SetDisplay(display);
    254       pedloop.SetDataCheckDisplay();
    255     }
    256   pedloop.SetBadPixels(badcam);
    257 
    258   if (!pedloop.Process())
     202      pedloop1.SetDisplay(display);
     203      pedloop1.SetDataCheckDisplay();
     204    }
     205  pedloop1.SetBadPixels(badcam);
     206 
     207  if (!pedloop1.Process())
    259208    return 1;
    260209
     
    263212  /****************************************/
    264213
     214  MJPedestal    pedloop2;
    265215  MJCalibration calloop;
     216
     217  if (timeandcharge)
     218    {
     219      /***********************************************************/
     220      /* NEEDE FOR SECOND LOOP: EXTRACTOR RESOLUTION COMPUTATION */
     221      /***********************************************************/
     222     
     223      pedloop2.SetUseData();
     224      pedloop2.SetNoStorage(!usestorage);
     225      pedloop2.SetEnvDebug(debug);
     226      pedloop2.SetExtractor(extractor);
     227      pedloop2.SetExtractorResolution();
     228      pedloop2.SetPedestals(pedloop1.GetPedestalCam()); 
     229      pedloop2.SetInput(&pruns);
     230      pedloop2.SetPathOut(outpath.Data());
     231      if (useDisplay)
     232        {
     233          pedloop2.SetDisplay(display);
     234          pedloop2.SetDataCheckDisplay();
     235        }
     236      pedloop2.SetBadPixels(badcam);
     237     
     238      if (!pedloop2.Process())
     239        return 1;
     240     
     241      extractor->SetNoiseCalculation(kFALSE);
     242      calloop.SetExtractorCam(pedloop2.GetPedestalCam());
     243    }
     244
     245  MPedestalCam &pedcam = pedloop1.GetPedestalCam();
    266246
    267247  if (debug)
     
    289269  // If you want to calibrate the times as well, choose:
    290270  //
    291   calloop.SetRelTimeCalibration(useTimes);
    292   calloop.SetExtractor(&extractor);
    293   calloop.SetTimeAndCharge(useTimeAndCharge);
    294   calloop.SetTimeExtractor(&timeext);
     271  calloop.SetExtractor(extractor);
    295272  calloop.SetInput(&cruns);
    296273  calloop.SetPathOut(outpath.Data());
     
    300277  calloop.SetUsePINDiode(pindiode);
    301278  calloop.SetQECam(qecam);
    302   calloop.SetBadPixels(pedloop.GetBadPixels());
    303 
    304   if (!calloop.Process(pedloop.GetPedestalCam()))
     279  calloop.SetBadPixels(pedloop1.GetBadPixels());
     280
     281  if (!calloop.Process(pedcam))
    305282    return 2;
    306283
     
    331308      testloop.SetDataCheckDisplay();
    332309
    333       testloop.SetExtractor(&extractor);
    334       testloop.SetTimeExtractor(&timeext);
     310      testloop.SetExtractor(extractor);
    335311      testloop.SetInput(&cruns);
    336312      testloop.SetPathOut(outpath);
     
    339315      testloop.SetBadPixels(calloop.GetBadPixels());
    340316     
    341       if (!testloop.ProcessD(pedloop.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
     317      if (!testloop.ProcessD(pedloop1.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
    342318        return 3;
    343319     
    344       if (useTimes)
    345         if (!testloop.ProcessT(pedloop.GetPedestalCam(),calloop.GetRelTimeCam()))
    346320      return 4;
    347321     
     
    354328  MJExtractSignal pedphotloop;
    355329
    356   pedphotloop.SetExtractor(&extractor);
    357   pedphotloop.SetTimeExtractor(&timeext);
     330  pedphotloop.SetExtractor(extractor);
    358331  pedphotloop.SetInput(&pruns);
    359332  pedphotloop.SetOutputPath(outpath);
     
    362335  pedphotloop.SetBadPixels(calloop.GetBadPixels());
    363336 
    364   if (!pedphotloop.ProcessP(pedloop.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
     337  if (!pedphotloop.ProcessP(pedloop1.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
    365338    return 5;
    366339
     
    375348
    376349  return 0;
    377 
    378350}
    379351
     
    393365    gLog << endl;
    394366    gLog << "Additional Options: " << endl;
     367    gLog << "     --extractor=#    Choose one of the following possible extractors (integer)" << endl;
     368    gLog << endl;
     369    gLog << "    Nr.    Extractor   Parameters " << endl;
     370    gLog << endl;   
     371    gLog << "       MExtractFixedWindow: " << endl;
     372    gLog << "           with the following parameters, if 'maxbin' defines the mean position" << endl;
     373    gLog << "           of the High-Gain FADC slice carrying the pulse maximum: " << endl;
     374    gLog << "     1:           SetRange('maxbin}}-1,'maxbin}}+2,'maxbin}}+0.5,'maxbin}}+3.5) " << endl;
     375    gLog << "     2:           SetRange('maxbin'-1,'maxbin'+2,'maxbin'-0.5,'maxbin'+4.5)" << endl;
     376    gLog << "     3:           SetRange('maxbin'-2,'maxbin'+3,'maxbin'-0.5,'maxbin'+4.5)" << endl;
     377    gLog << "     4:           SetRange('maxbin'-3,'maxbin'+4,'maxbin'-1.5,'maxbin'+5.5)" << endl;
     378    gLog << "     5:           SetRange('maxbin'-5,'maxbin'+8,'maxbin'-1.5,'maxbin'+7.5)" << endl;
     379    gLog << "       MExtractFixedWindowSpline: " << endl;
     380    gLog << "     6:           SetRange('maxbin'-1,'maxbin'+2,'maxbin'+0.5,'maxbin'+3.5)" << endl;
     381    gLog << "     7:           SetRange('maxbin'-1,'maxbin'+2,'maxbin'-0.5,'maxbin'+4.5)" << endl;
     382    gLog << "     8:           SetRange('maxbin'-2,'maxbin'+3,'maxbin'-0.5,'maxbin'+4.5)" << endl;
     383    gLog << "     9:           SetRange('maxbin'-3,'maxbin'+4,'maxbin'-1.5,'maxbin'+5.5)" << endl;
     384    gLog << "     10:          SetRange('maxbin'-5,'maxbin'+8,'maxbin'-1.5,'maxbin'+7.5)" << endl;
     385    gLog << "       MExtractFixedWindowPeakSearch: " << endl;
     386    gLog << "                  SetRange(0,18,2,14) and the following parameters:" << endl;
     387    gLog << "     11:          SetWindows(2,2,2)" << endl;
     388    gLog << "     12:          SetWindows(4,4,2)" << endl;
     389    gLog << "     13:          SetWindows(6,6,4)" << endl;
     390    gLog << "     14:          SetWindows(4,6,4)" << endl;
     391    gLog << "     15:          SetWindows(8,8,4)" << endl;
     392    gLog << "     16:          SetWindows(14,10,4)" << endl;
     393    gLog << "      MExtractTimeAndChargeSlidingWindow:" << endl;
     394    gLog << "                  SetRange(0,18,2,14) and the following parameters:" << endl;
     395    gLog << "     17:          SetWindowSize(2,2)" << endl;
     396    gLog << "     18:          SetWindowSize(4,4)" << endl;
     397    gLog << "     19:          SetWindowSize(6,6)" << endl;
     398    gLog << "     20:          SetWindowSize(4,6)" << endl;
     399    gLog << "     21:          SetWindowSize(8,8)" << endl;
     400    gLog << "     22:          SetWindowSize(14,10)" << endl;
     401    gLog << "      MExtractTimeAndChargeSpline: " << endl;
     402    gLog << "                  SetChargeType(MExtractTimeAndChargeSpline::kIntegral) and:" << endl;
     403    gLog << "                  SetRange(0,18,2,14) and the following parameters:" << endl;
     404    gLog << "     23:          SetRiseTime(1.5); SetFallTime(4.5)" << endl;
     405    gLog << "     24:          SetRiseTime(0.5); SetFallTime(2.5)" << endl;
     406    gLog << "     25:          SetRiseTime(0.5); SetFallTime(1.5)" << endl;
     407    gLog << "     26:          SetRiseTime(0.5); SetFallTime(0.5)" << endl;
     408    gLog << "     27:          SetChargeType(MExtractTimeAndChargeSpline::kAmplitude" << endl;
     409    gLog << "                  SetRange(0,10,4,11)" << endl;
     410    gLog << "      MExtractTimeAndChargeDigitalFilter" << endl;
     411    gLog << "                  SetRange(0,18,2,14) and the following parameters:" << endl;
     412    gLog << "     28:          SetNameWeightsFile('msignal/cosmics_weights.dat')" << endl;
     413    gLog << "     29:          SetNameWeightsFile('msignal/cosmics_weights4.dat')" << endl;
     414    gLog << "     30:          SetNameWeightsFile('msignal/cosmics_weights_logain6.dat')" << endl;
     415    gLog << "     31:          SetNameWeightsFile('msignal/cosmics_weights_logain4.dat')" << endl;
     416    gLog << "     32:          SetNameWeightsFile('msignal/calibration_weights_UV.dat')" << endl;
     417    gLog << "     33:          SetNameWeightsFile('msignal/calibration_weights_UV4.dat')" << endl;
     418    gLog << "     34:          SetNameWeightsFile('msignal/calibration_weights_UV_logain6.dat')" << endl;
     419    gLog << "     35:          SetNameWeightsFile('msignal/calibration_weights_UV_logain4.dat')" << endl;
     420    gLog << "     36:  Real Fit: (not yet implemented)" << endl;
     421    gLog << endl;
    395422    gLog << "     --inpath=#          Find the data in inpath"                      << endl;
    396423    gLog << "     --outpath=#         Write the output containers to outpath"       << endl;
     
    398425    gLog << "     --debug             Use the TObjectTable for debugging    "       << endl;
    399426    gLog << "                             and write out the pixels as ascii tables" << endl;
    400     gLog << "     --useTimes          Calibrate the relative arrival times"         << endl;
    401427    gLog << "     --useTest           Use the class MJExtractCalibTest to test the calibration on itself" << endl;
    402428    gLog << "     --skipBlindPix      Skip the blind pixel calibration"             << endl;
     
    419445 
    420446  debug    = arg.HasOnlyAndRemove("--debug")    || arg.HasOnlyAndRemove("-d");
    421   useTimes = arg.HasOnlyAndRemove("--useTimes") || arg.HasOnlyAndRemove("-t");
    422447  useTest  = arg.HasOnlyAndRemove("--useTest")  || arg.HasOnlyAndRemove("-e");
    423448  blindpix = !(arg.HasOnlyAndRemove("--skipBlindPix"));
    424449  pindiode = !(arg.HasOnlyAndRemove("--skipPINDiode"));
     450
     451  if (arg.HasOption("--extractor="))
     452    extractorflag = arg.GetIntAndRemove("--extractor=");
    425453
    426454  if (arg.HasOption("--inpath="))
     
    455483  // Switch off the display
    456484  //
    457   useDisplay = kFALSE;
    458 
    459 
     485  useDisplay = kTRUE;
    460486  //
    461487  // check for the arguments
     
    479505      pedr = arg.GetArgumentInt(0);
    480506      calr1 = arg.GetArgumentInt(1);
    481       return calibration(pedr,calr1);
     507      gLog << "PEDR: " << pedr << " CALR1: " << calr1 << " CALR2 " << calr2 << endl;
     508      gLog << "inpath: " << inpath << endl;
     509      gLog << "extractor: " << extractorflag << endl;
     510      return calibration();
    482511    }
    483512
     
    485514    {
    486515      pedr = arg.GetArgumentInt(0);
    487       gLog << "PEDR: " << pedr << endl;
    488       return calibration(pedr);
    489     }
    490 
    491   return calibration();
     516      return calibration(pedr,calr1,calr2);
     517    }
     518
     519  return calibration(pedr,calr1,calr2);
    492520}
     521
Note: See TracChangeset for help on using the changeset viewer.