Changeset 6193 for trunk


Ignore:
Timestamp:
02/02/05 11:32:56 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/NEWS

    r6167 r6193  
    11                                                               -*-*- END -*-*-
    22 *** Version <cvs>
     3
     4   - Reference lines in the display can be read from conf. file
     5
     6   - Interlaced cal. events are now handled correctly by callisto.
     7
     8   - High-Gain vs. Low-Gain calibration constants can be calculated (but not
     9     yet applied) in callisto.
     10
     11   - class MJCalibTest can be called by callisto
     12
     13   - interpolated pointing positions are now in Tree "Events" after calibration
     14
     15   - callisto can now run with three data types: rawdata, rootdata, MC
    316
    417   - added two classes mreport/MReportStarguider.cc and
  • trunk/MagicSoft/Mars/mjobs/MJCalibTest.cc

    r6191 r6193  
    6666
    6767#include "MReadMarsFile.h"
     68#include "MRawFileRead.h"
    6869#include "MGeomApply.h"
     70#include "MGeomCam.h"
    6971#include "MExtractTimeAndChargeSlidingWindow.h"
    7072#include "MExtractor.h"
     
    239241
    240242
     243const char* MJCalibTest::GetInputFile() const
     244{
     245
     246  if (fSequence.IsValid())
     247    return Form("%s/calib%08d.root", (const char*)fPathOut, fSequence.GetSequence());
     248 
     249  if (!fRuns)
     250    return "";
     251 
     252  return Form("%s/%s-F1.root", (const char*)fPathOut, (const char*)fRuns->GetRunsAsFileName());
     253 
     254}
     255
     256
    241257const char* MJCalibTest::GetOutputFile() const
    242258{
     
    252268}
    253269
    254 
    255 Bool_t MJCalibTest::Process(MPedestalCam &pedcam,
    256                                    MCalibrationChargeCam &calcam, MCalibrationQECam &qecam,
    257                                    MCalibrationRelTimeCam &reltime,
    258                                    Byte_t filetype)
     270Bool_t MJCalibTest::ReadCalibration(TObjArray &l, MBadPixelsCam &cam, MExtractor* &ext1, MExtractor* &ext2, TString &geom) const
     271{
     272
     273  const TString fname = GetInputFile();
     274 
     275  *fLog << inf << "Reading from file: " << fname << endl;
     276
     277  TFile file(fname, "READ");
     278  if (!file.IsOpen())
     279    {
     280      *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl;
     281      return kFALSE;
     282    }
     283 
     284  TObject *o = file.Get("ExtractSignal");
     285  if (o && !o->InheritsFrom(MExtractor::Class()))
     286    {
     287      *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
     288      return kFALSE;
     289    }
     290  ext1 = o ? (MExtractor*)o->Clone() : NULL;
     291 
     292  o = file.Get("ExtractTime");
     293  if (o && !o->InheritsFrom(MExtractor::Class()))
     294    {
     295      *fLog << err << dbginf << "ERROR - ExtractTime read from " << fname << " doesn't inherit from MExtractor!" << endl;
     296      return kFALSE;
     297    }
     298  ext2 = o ? (MExtractor*)o->Clone() : NULL;
     299  if (!ext1 && !ext2)
     300    {
     301      *fLog << err << dbginf << "ERROR - Neither ExtractSignal nor ExrtractTime found in " << fname << "!" << endl;
     302      return kFALSE;
     303    }
     304 
     305  o = file.Get("MGeomCam");
     306  if (o && !o->InheritsFrom(MGeomCam::Class()))
     307    {
     308      *fLog << err << dbginf << "ERROR - MGeomCam read from " << fname << " doesn't inherit from MGeomCam!" << endl;
     309      return kFALSE;
     310    }
     311  geom = o ? o->ClassName() : "";
     312 
     313  TObjArray cont(l);
     314  cont.Add(&cam);
     315  return ReadContainer(cont);
     316}
     317
     318// --------------------------------------------------------------------------
     319//
     320// MJCalibration allows to setup several option by a resource file:
     321//   MJCalibrateSignal.RawData: yes,no
     322//
     323// For more details see the class description and the corresponding Getters
     324//
     325Bool_t MJCalibTest::CheckEnvLocal()
     326{
     327
     328  SetUseRootData();
     329 
     330  if (HasEnv("DataType"))
     331    {
     332      TString dat = GetEnv("DataType", "");
     333      if (dat.BeginsWith("raw", TString::kIgnoreCase))
     334        {
     335          fDataFlag = 0;
     336          SetUseRawData();
     337        }
     338      if (dat.BeginsWith("root", TString::kIgnoreCase))
     339        {
     340          fDataFlag = 0;
     341          SetUseRootData();
     342      }
     343      if (dat.BeginsWith("mc", TString::kIgnoreCase))
     344        {
     345          fDataFlag = 0;
     346          SetUseMC();
     347        }
     348    }
     349  return kTRUE;
     350}
     351
     352Bool_t MJCalibTest::Process(MPedestalCam &pedcam)
    259353{
    260354    // const TString fname = GetOutputFile();
    261355 
    262356//  if (gSystem->AccessPathName(fname, kFileExists))
    263     return ProcessFile(pedcam,calcam,qecam,reltime,filetype);
     357    return ProcessFile(pedcam);
    264358 
    265359    // return kTRUE;
    266360}
    267361
    268 Bool_t MJCalibTest::ProcessFile(MPedestalCam &pedcam,
    269                                        MCalibrationChargeCam &calcam, MCalibrationQECam &qecam,
    270                                        MCalibrationRelTimeCam &relcam,
    271                                        Byte_t filetype)
    272 {
    273   if (!fRuns)
    274     {
    275       *fLog << err << "No Runs choosen... abort." << endl;
    276       return kFALSE;
    277     }
    278   if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
    279     {
    280       *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
    281       return kFALSE;
    282     }
     362Bool_t MJCalibTest::ProcessFile(MPedestalCam &pedcam)
     363{
     364 
     365
     366  if (!fSequence.IsValid())
     367    {
     368      if (!fRuns)
     369        {
     370            *fLog << err << "ERROR - Sequence invalid and no runs chosen!" << endl;
     371            return kFALSE;
     372        }
     373     
     374      if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
     375        {
     376          *fLog << err << "Number of files found doesn't match number of runs... abort."
     377                << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
     378          return kFALSE;
     379        }
     380      *fLog << "Calibrate data from ";
     381      *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
     382      *fLog << endl;
     383    }
     384 
     385  CheckEnv();
    283386
    284387  *fLog << inf;
     
    287390  *fLog << endl;
    288391
    289   MBadPixelsCam badcam;
    290  
     392  MDirIter iter;
     393
     394  if (fSequence.IsValid())
     395    {
     396      const Int_t n0 = fSequence.SetupDatRuns(iter, fPathData, "D", IsUseRawData());
     397      const Int_t n1 = fSequence.GetNumDatRuns();
     398      if (n0==0)
     399        {
     400          *fLog << err << "ERROR - No input files of sequence found!" << endl;
     401          return kFALSE;
     402        }
     403      if (n0!=n1)
     404        {
     405          *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl;
     406          return kFALSE;
     407        }
     408    }
     409 
     410  MCalibrationChargeCam      calcam;
     411  MCalibrationQECam          qecam;
     412  MCalibrationRelTimeCam     tmcam;
     413  MBadPixelsCam              badpix;
     414 
     415  TObjArray calibcont;
     416  calibcont.Add(&calcam);
     417  calibcont.Add(&qecam);
     418  calibcont.Add(&tmcam);
     419   
     420  MExtractor *extractor1=0;
     421  MExtractor *extractor2=0;
     422  TString geom;
     423
     424  if (!ReadCalibration(calibcont, badpix, extractor1, extractor2, geom))
     425    return kFALSE;
     426 
     427  *fLog << all;
     428  if (extractor1)
     429    {
     430      *fLog << underline << "Signal Extractor found in calibration file" << endl;
     431      extractor1->Print();
     432      *fLog << endl;
     433    }
     434  else
     435    *fLog << inf << "No Signal Extractor: ExtractSignal in file." << endl;
     436 
     437  if (extractor2)
     438    {
     439      *fLog << underline << "Time Extractor found in calibration file" << endl;
     440      extractor2->Print();
     441      *fLog << endl;
     442    }
     443  else
     444    *fLog << inf << "No Time Extractor: ExtractTime in file." << endl;
     445 
     446  if (!geom.IsNull())
     447    *fLog << inf << "Camera geometry found in file: " << geom << endl;
     448  else
     449    *fLog << inf << "No Camera geometry found using default <MGeomCamMagic>" << endl;
     450
     451  if (fExtractor)
     452    extractor1 = fExtractor;
     453  if (fTimeExtractor)
     454    extractor2 = fTimeExtractor;
     455
    291456  // Setup Lists
    292457  MParList plist;
     
    294459  plist.AddToList(&fTestCam);
    295460  plist.AddToList(&fTestTimeCam);
    296   plist.AddToList(&badcam);
     461  plist.AddToList(&badpix);
    297462  plist.AddToList(&pedcam);
    298463  plist.AddToList(&calcam);
    299464  plist.AddToList(&qecam);
    300   plist.AddToList(&relcam);
     465  plist.AddToList(&tmcam);
    301466
    302467  MCerPhotEvt          cerphot;
     
    314479
    315480  // Setup Task-lists
     481  MRawFileRead rawread(NULL);
    316482  MReadMarsFile read("Events");
    317483  read.DisableAutoScheme();
    318   static_cast<MRead&>(read).AddFiles(*fRuns);
    319  
     484
     485  if (IsUseRawData())
     486    rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
     487  else
     488    static_cast<MRead&>(read).AddFiles(fSequence.IsValid() ? iter : *fRuns);
     489
    320490  // Check for interleaved events
    321491  MTriggerPatternDecode decode;
     
    325495
    326496  MGeomApply            apply; // Only necessary to craete geometry
    327   apply.SetGeometry(fGeometry); 
    328   MBadPixelsMerge       merge(&fBadPixels);
     497  if (!geom.IsNull())
     498    apply.SetGeometry(geom); 
     499  MBadPixelsMerge       merge(&badpix);
    329500
    330501  MExtractTimeAndChargeSlidingWindow extrsw;
     
    335506  MTaskEnv taskenv2("ExtractTime");
    336507
    337   if (fExtractor)
     508  if (extractor1)
    338509    {
    339       fExtractor->SetPedestals(&pedcam);
    340       taskenv1.SetDefault(fExtractor);
     510      extractor1->SetPedestals(&pedcam);
     511      taskenv1.SetDefault(extractor1);
    341512    }
    342513  if (fTimeExtractor)
     
    356527  MCalibrateData        photcalc;
    357528  MCalibrateRelTimes    caltimes;
    358   if (filetype==3) // MC file
     529  if (IsUseMC()) // MC file
    359530    {
    360531      photcalc.SetCalibrationMode(MCalibrateData::kFfactor);
     
    409580  tlist.AddToList(&conttp);
    410581  tlist.AddToList(&taskenv1);
    411   if (!fExtractor->InheritsFrom("MExtractTimeAndCharge"))
     582  if (!extractor1->InheritsFrom("MExtractTimeAndCharge"))
    412583    tlist.AddToList(&taskenv2);
    413584  tlist.AddToList(&contcos);
     
    448619}
    449620
    450 Bool_t MJCalibTest::ReadPedPhotCam()
    451 {
    452 
    453   const TString fname = GetOutputFile();
    454  
    455   if (gSystem->AccessPathName(fname, kFileExists))
    456     {
    457       *fLog << err << "Input file " << fname << " doesn't exist." << endl;
    458       return kFALSE;
    459     }
    460  
    461   *fLog << inf << "Reading from file: " << fname << endl;
    462  
    463   TFile file(fname, "READ");
    464   if (fPedPhotCam.Read()<=0)
    465     {
    466       *fLog << "Unable to read MPedPhotCam from " << fname << endl;
    467       return kFALSE;
    468     }
    469 
    470   if (file.FindKey("MBadPixelsCam"))
    471     {
    472       MBadPixelsCam bad;
    473       if (bad.Read()<=0)
    474         {
    475           *fLog << "Unable to read MBadPixelsCam from " << fname << endl;
    476           return kFALSE;
    477         }
    478       fBadPixels.Merge(bad);
    479     }
    480  
    481   if (fDisplay /*&& !fDisplay->GetCanvas("Pedestals")*/) // FIXME!
    482     fDisplay->Read();
    483  
    484   return kTRUE;
    485 }
    486 
    487621Bool_t MJCalibTest::WriteResult()
    488622{
  • trunk/MagicSoft/Mars/mjobs/MJCalibTest.h

    r6191 r6193  
    5252  TString fGeometry;
    5353 
    54   Bool_t ReadPedPhotCam();
    55  
     54  Bool_t CheckEnvLocal();
     55
    5656  void   DisplayResult(MParList &plist);
    5757  void   DisplayResultT(MParList &plist);
     
    5959  Bool_t WriteResult();
    6060 
    61   Bool_t ProcessFile(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam,
    62                      MCalibrationRelTimeCam &rel, Byte_t filetype);
     61  Bool_t ReadCalibration(TObjArray &o, MBadPixelsCam &bpix,
     62                         MExtractor* &ext1, MExtractor* &ext2, TString &geom) const;
     63
     64  Bool_t ProcessFile(MPedestalCam &pedcam);
    6365
    6466public:
     
    6769 
    6870  const char* GetOutputFile() const;
     71  const char* GetInputFile() const;
    6972 
    7073  MCalibrationTestCam      &GetTestCam()      { return fTestCam; }
     
    8285  void SetNormalDisplay()    { fDisplayType = kNormalDisplay;    }
    8386 
    84   Bool_t Process(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam,
    85                  MCalibrationRelTimeCam &relcam,Byte_t filetype=1);
     87  Bool_t Process(MPedestalCam &pedcam);
    8688 
    8789  ClassDef(MJCalibTest, 0) // Tool to calibrate and test the calibration run itself
Note: See TracChangeset for help on using the changeset viewer.