Changeset 5942 for trunk


Ignore:
Timestamp:
01/22/05 15:54:06 (20 years ago)
Author:
mazin
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r5941 r5942  
    3838     - replace title of that times-averageing Tab from "RelTimes" by
    3939       "Times".
     40
     41   * macros/calibration.C
     42     - update to changes in MJExtractCalibTest
    4043
    4144 2005/01/21 Markus Gaug
  • trunk/MagicSoft/Mars/macros/calibration.C

    r5862 r5942  
    8686//static TString inpath  = "/home/rootdata/Calib/2004_07_06";
    8787//static TString inpath  = "/home/rootdata/Calib/2004_09_22";
    88 static TString inpath  = "/home/rootdata/Calib/2004_12_18";
     88static TString inpath  = "/.magic/magicserv01/MAGIC/rootdata/2004_12_18";
    8989static TString badfile;
    9090//static TString badfile = "badpixels_only0_388_559.dat";
     
    122122// A switch to use the PIN Diode
    123123//
    124 static Bool_t pindiode = kTRUE;
     124static Bool_t pindiode = kFALSE;
    125125//
    126126// Tell if you want to use the display:
     
    341341      testloop.SetBadPixels(calloop.GetBadPixels());
    342342     
    343       if (!testloop.ProcessD(pedloop1.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
     343      if (!testloop.Process(pedloop1.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam(),
     344                            calloop.GetRelTimeCam()))
    344345        return 3;
    345346     
  • trunk/MagicSoft/Mars/mjobs/MJExtractCalibTest.cc

    r5810 r5942  
    4545#include "MParList.h"
    4646#include "MTaskList.h"
     47#include "MTaskEnv.h"
    4748#include "MEvtLoop.h"
    4849
     
    5253#include "MBadPixelsCam.h"
    5354#include "MBadPixelsTreat.h"
     55#include "MBadPixelsCalc.h"
     56#include "MBadPixelsMerge.h"
    5457#include "MCerPhotEvt.h"
    5558#include "MArrivalTime.h"
     
    6467#include "MReadMarsFile.h"
    6568#include "MGeomApply.h"
    66 #include "MExtractSlidingWindow.h"
     69#include "MExtractTimeAndChargeSlidingWindow.h"
    6770#include "MExtractor.h"
    6871#include "MExtractTime.h"
     
    7376#include "MCalibrateData.h"
    7477#include "MCalibrateRelTimes.h"
    75 #include "MPedPhotCalc.h"
     78
     79#include "MTriggerPattern.h"
     80#include "MTriggerPatternDecode.h"
     81#include "MFTriggerPattern.h"
    7682
    7783#include "MStatusDisplay.h"
     
    8995MJExtractCalibTest::MJExtractCalibTest(const char *name, const char *title)
    9096    : fUseCosmicsFilter(kTRUE), fRuns(NULL), fExtractor(NULL), fTimeExtractor(NULL),
    91       fDisplayType(kNormalDisplay)
     97      fDisplayType(kNormalDisplay), fGeometry("MGeomCamMagic")
    9298{
    9399    fName  = name  ? name  : "MJExtractCalibTest";
     
    247253
    248254
    249 Bool_t MJExtractCalibTest::ProcessD(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam)
     255Bool_t MJExtractCalibTest::Process(MPedestalCam &pedcam,
     256                                   MCalibrationChargeCam &calcam, MCalibrationQECam &qecam,
     257                                   MCalibrationRelTimeCam &reltime,
     258                                   Byte_t filetype)
    250259{
    251260    // const TString fname = GetOutputFile();
    252261 
    253262//  if (gSystem->AccessPathName(fname, kFileExists))
    254     return ProcessFileD(pedcam,calcam,qecam);
     263    return ProcessFile(pedcam,calcam,qecam,reltime,filetype);
    255264 
    256265    // return kTRUE;
    257266}
    258267
    259 Bool_t MJExtractCalibTest::ProcessFileD(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam)
     268Bool_t MJExtractCalibTest::ProcessFile(MPedestalCam &pedcam,
     269                                       MCalibrationChargeCam &calcam, MCalibrationQECam &qecam,
     270                                       MCalibrationRelTimeCam &relcam,
     271                                       Byte_t filetype)
    260272{
    261273  if (!fRuns)
     
    269281      return kFALSE;
    270282    }
    271  
     283
    272284  *fLog << inf;
    273285  fLog->Separator(GetDescriptor());
    274286  *fLog << "Calculate MExtractedSignalCam from Runs " << fRuns->GetRunsAsString() << endl;
    275287  *fLog << endl;
    276  
     288
     289  MBadPixelsCam badcam;
     290 
     291  // Setup Lists
     292  MParList plist;
     293  plist.AddToList(this); // take care of fDisplay!
     294  plist.AddToList(&fTestCam);
     295  plist.AddToList(&fTestTimeCam);
     296  plist.AddToList(&badcam);
     297  plist.AddToList(&pedcam);
     298  plist.AddToList(&calcam);
     299  plist.AddToList(&qecam);
     300  plist.AddToList(&relcam);
     301
    277302  MCerPhotEvt          cerphot;
    278303  MPedPhotCam          pedphot;
    279304  MHCalibrationTestCam testcam;
    280305
    281   // Setup Lists
    282   MParList plist;
    283   plist.AddToList(&pedcam);
    284   plist.AddToList(&calcam);
    285   plist.AddToList(&qecam);
    286306  plist.AddToList(&cerphot);
    287307  plist.AddToList(&pedphot);
    288308  plist.AddToList(&testcam);
    289   plist.AddToList(&fTestCam);
    290   plist.AddToList(&fBadPixels);
    291 
     309
     310  pedcam.SetName("MPedestalFundamental");
     311 
    292312  MTaskList tlist;
    293313  plist.AddToList(&tlist);
     
    298318  static_cast<MRead&>(read).AddFiles(*fRuns);
    299319 
     320  // Check for interleaved events
     321  MTriggerPatternDecode decode;
     322  MFTriggerPattern      fcalib;
     323  fcalib.DenyCalibration();
     324  MContinue conttp(&fcalib, "ContTrigPattern");
     325
    300326  MGeomApply            apply; // Only necessary to craete geometry
    301   MExtractSlidingWindow extract2;
     327  apply.SetGeometry(fGeometry); 
     328  MBadPixelsMerge       merge(&fBadPixels);
     329
     330  MExtractTimeAndChargeSlidingWindow extrsw;
     331  MExtractTimeFastSpline             extime;
     332  extime.SetPedestals(&pedcam);
     333
     334  MTaskEnv taskenv1("ExtractSignal");
     335  MTaskEnv taskenv2("ExtractTime");
     336
     337  if (fExtractor)
     338    {
     339      fExtractor->SetPedestals(&pedcam);
     340      taskenv1.SetDefault(fExtractor);
     341    }
     342  if (fTimeExtractor)
     343    {
     344      fTimeExtractor->SetPedestals(&pedcam);
     345      taskenv2.SetDefault(fTimeExtractor);
     346    }
     347  else
     348    {
     349      extrsw.SetPedestals(&pedcam);
     350      extrsw.SetWindowSize(8,8);
     351      taskenv2.SetDefault(&extrsw);
     352      *fLog << warn << GetDescriptor()
     353            << ": No extractor has been chosen, take default MExtractTimeAndChargeSlidingWindow " << endl;
     354    }
     355
    302356  MCalibrateData        photcalc;
    303   photcalc.SetCalibrationMode(MCalibrateData::kFfactor);
    304   MPedPhotCalc          pedphotcalc; 
     357  MCalibrateRelTimes    caltimes;
     358  if (filetype==3) // MC file
     359    {
     360      photcalc.SetCalibrationMode(MCalibrateData::kFfactor);
     361      photcalc.SetPedestalFlag(MCalibrateData::kRun);
     362      photcalc.AddPedestal("MPedestalCam", "MPedPhotFundamental");
     363    }
     364  else
     365    {
     366      photcalc.SetCalibrationMode(MCalibrateData::kFfactor);
     367      photcalc.AddPedestal("Fundamental");
     368      photcalc.SetPedestalFlag(MCalibrateData::kEvent);
     369      photcalc.SetSignalType(MCalibrateData::kPhot);
     370    }
     371
     372  MBadPixelsCalc        badcalc;
    305373  MBadPixelsTreat       badtreat;
    306   badtreat.SetUseInterpolation();
     374  badtreat.SetProcessTimes(kFALSE);
     375
     376  badcalc.SetNamePedPhotCam("MPedPhotFundamental");
     377  //badtreat.SetUseInterpolation();
     378  badtreat.AddNamePedPhotCam("MPedPhotFundamental");
     379
    307380  MCalibrationTestCalc  testcalc;
    308381
     
    313386    }
    314387 
    315   MHCamEvent evt("ExtSignal");
    316   evt.SetType(0);
    317   MFillH fill(&evt, "MExtractedSignalCam");
     388  MHCamEvent evt0(0,"Signal", "Un-Calibrated Signal;;S [FADC cnts]" );
     389  MHCamEvent evt1(3,"CalSig", "Calibrated and Interpolated Signal;;S [\\gamma]");
     390  MHCamEvent evt2(0,"Times" , "Arrival Time;;T [slice]");
     391
     392  MFillH fill0(&evt0, "MExtractedSignalCam", "FillUncalibrated");
     393  MFillH fill1(&evt1, "MCerPhotEvt", "FillCalibrated");
     394  MFillH fill2(&evt2, "MArrivalTime","FillTimes");
    318395 
    319396  MFillH fillcam("MHCalibrationTestCam", "MCerPhotEvt");
    320397  fillcam.SetNameTab("Test");
     398  MFillH filltme("MHCalibrationTestTimeCam", "MArrivalTime");
     399  filltme.SetNameTab("TestTime");
    321400
    322401  MFCosmics cosmics;
    323   MContinue cont(&cosmics);
     402  cosmics.SetNamePedestalCam("MPedestalFundamental");
     403  MContinue contcos(&cosmics,"ContCosmics");
    324404 
    325405  tlist.AddToList(&read);
     406  tlist.AddToList(&decode);
    326407  tlist.AddToList(&apply);
    327 
    328   if (fExtractor)
    329     tlist.AddToList(fExtractor);
    330   else
    331   {
    332       *fLog << warn << GetDescriptor()
    333             << ": No extractor has been chosen, take default MExtractSlidingWindow " << endl;
    334       tlist.AddToList(&extract2);
    335   }
    336 
    337 
    338   if (fUseCosmicsFilter)
    339     tlist.AddToList(&cont);
    340 
    341   tlist.AddToList(&fill);
     408  tlist.AddToList(&merge);
     409  tlist.AddToList(&conttp);
     410  tlist.AddToList(&taskenv1);
     411  if (!fExtractor->InheritsFrom("MExtractTimeAndCharge"))
     412    tlist.AddToList(&taskenv2);
     413  tlist.AddToList(&contcos);
     414  tlist.AddToList(&fill0);
    342415  tlist.AddToList(&photcalc);
    343   tlist.AddToList(&pedphotcalc);
     416  tlist.AddToList(&caltimes);
     417  tlist.AddToList(&badcalc);
    344418  tlist.AddToList(&badtreat);
     419  tlist.AddToList(&fill1);
     420  tlist.AddToList(&fill2);
    345421  tlist.AddToList(&fillcam);
     422  tlist.AddToList(&filltme);
    346423  tlist.AddToList(&testcalc);
    347424 
     
    363440  DisplayResult(plist);
    364441
    365   if (!WriteResultD())
     442  if (!WriteResult())
    366443    return kFALSE;
    367444
     
    370447  return kTRUE;
    371448}
    372 
    373 Bool_t MJExtractCalibTest::ProcessT(MPedestalCam &pedcam, MCalibrationRelTimeCam &relcam)
    374 {
    375 
    376 //  const TString fname = GetOutputFile();
    377  
    378 //  if (gSystem->AccessPathName(fname, kFileExists))
    379     return ProcessFileT(pedcam,relcam);
    380  
    381 //  return kTRUE;
    382 }
    383 
    384 Bool_t MJExtractCalibTest::ProcessFileT(MPedestalCam &pedcam, MCalibrationRelTimeCam &relcam)
    385 {
    386 
    387   if (!fRuns)
    388     {
    389       *fLog << err << "No Runs choosen... abort." << endl;
    390       return kFALSE;
    391     }
    392   if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
    393     {
    394       *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
    395       return kFALSE;
    396     }
    397  
    398   *fLog << inf;
    399   fLog->Separator(GetDescriptor());
    400   *fLog << "Calculate MExtractedSignalCam from Runs " << fRuns->GetRunsAsString() << endl;
    401   *fLog << endl;
    402  
    403   MArrivalTime     arrtime;
    404 
    405   // Setup Lists
    406   MParList plist;
    407   plist.AddToList(&pedcam);
    408   plist.AddToList(&relcam);
    409   plist.AddToList(&arrtime);
    410   plist.AddToList(&fTestTimeCam);
    411   plist.AddToList(&fBadPixels);
    412  
    413   MTaskList tlist;
    414   plist.AddToList(&tlist);
    415 
    416   // Setup Task-lists
    417   MReadMarsFile read("Events");
    418   read.DisableAutoScheme();
    419   static_cast<MRead&>(read).AddFiles(*fRuns);
    420  
    421   MGeomApply             apply; // Only necessary to craete geometry
    422   MExtractTimeFastSpline extract;
    423   MExtractSlidingWindow  extcharge; // Only for the cosmics filter
    424   MCalibrateRelTimes     timecalc;
    425   MFCosmics              cosmics;
    426   MContinue              cont(&cosmics);
    427 
    428   MHCamEvent evt("ExtTimes");
    429   evt.SetType(0);
    430   MFillH fill(&evt, "MArrivalTimeCam");
    431  
    432   MFillH fillcam("MHCalibrationTestTimeCam", "MArrivalTime");
    433   fillcam.SetNameTab("TestTime");
    434 
    435   tlist.AddToList(&read);
    436   tlist.AddToList(&apply);
    437 
    438   if (fTimeExtractor)
    439     tlist.AddToList(fTimeExtractor);
    440   else
    441   {
    442       *fLog << warn << GetDescriptor()
    443             << ": No extractor has been chosen, take default MExtractTimeFastSpline " << endl;
    444       tlist.AddToList(&extract);
    445   }
    446 
    447   tlist.AddToList(&extcharge);
    448   tlist.AddToList(&cont);
    449   tlist.AddToList(&fill);
    450   tlist.AddToList(&timecalc);
    451   tlist.AddToList(&fillcam);
    452  
    453   // Create and setup the eventloop
    454   MEvtLoop evtloop(fName);
    455   evtloop.SetParList(&plist);
    456   evtloop.SetDisplay(fDisplay);
    457   evtloop.SetLogStream(fLog);
    458  
    459   // Execute first analysis
    460   if (!evtloop.Eventloop())
    461     {
    462       *fLog << err << GetDescriptor() << ": Failed." << endl;
    463       return kFALSE;
    464     }
    465  
    466   tlist.PrintStatistics();
    467  
    468   DisplayResultT(plist);
    469 
    470   if (!WriteResultT())
    471     return kFALSE;
    472 
    473   *fLog << inf << GetDescriptor() << ": Done." << endl;
    474  
    475   return kTRUE;
    476 }
    477 
    478449
    479450Bool_t MJExtractCalibTest::ReadPedPhotCam()
     
    514485}
    515486
    516 Bool_t MJExtractCalibTest::WriteResultD()
     487Bool_t MJExtractCalibTest::WriteResult()
    517488{
    518489   
     
    544515    }
    545516
     517    if (fTestTimeCam.Write()<=0)
     518    {
     519        *fLog << err << "Unable to write MCalibrationTestCam to " << oname << endl;
     520        return kFALSE;
     521    }
     522
    546523    return kTRUE;
    547524
    548525}
    549526
    550 Bool_t MJExtractCalibTest::WriteResultT()
    551 {
    552    
    553     if (fPathOut.IsNull())
    554         return kTRUE;
    555    
    556     const TString oname(GetOutputFile());
    557 
    558     *fLog << inf << "Writing to file: " << oname << endl;
    559    
    560     TFile file(oname, "UPDATE");
    561    
    562     if (fDisplay && fDisplay->Write()<=0)
    563     {
    564         *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
    565         return kFALSE;
    566     }
    567 
    568     if (fTestTimeCam.Write()<=0)
    569     {
    570         *fLog << err << "Unable to write MHCalibrationTestTimeCam to " << oname << endl;
    571         return kFALSE;
    572     }
    573 
    574     return kTRUE;
    575 
    576 }
    577527
    578528
Note: See TracChangeset for help on using the changeset viewer.