Ignore:
Timestamp:
08/29/13 18:17:12 (11 years ago)
Author:
dneise
Message:
edited both scripts, so we can use them on phido for processing of simulated data
Location:
branches/Mars_MC/fact/analysis/mc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/Mars_MC/fact/analysis/mc/callisto.C

    r17055 r17056  
    1 int callisto(const char *seqfile="seq/2012/01/23/20120123_023.seq", const char *outpath = "output", bool use_delays=true)
     1
     2#include <sstream>
     3#include <iostream>
     4
     5#include "TH1F.h"
     6#include "TFile.h"
     7#include "TStyle.h"
     8#include "TGraph.h"
     9#include "TLine.h"
     10
     11#include "MDrsCalibration.h"
     12#include "MLogManip.h"
     13#include "MExtralgoSpline.h"
     14#include "MSequence.h"
     15#include "MStatusArray.h"
     16#include "MHCamera.h"
     17#include "MJob.h"
     18#include "MWriteRootFile.h"
     19#include "MHCamera.h"
     20#include "MBadPixelsCam.h"
     21#include "MBadPixelsPix.h"
     22#include "MDirIter.h"
     23#include "MTaskList.h"
     24#include "MFDataPhrase.h"
     25#include "MArrayF.h"
     26#include "MBadPixelsTreat.h"
     27#include "MCalibrateDrsTimes.h"
     28#include "MHSectorVsTime.h"
     29#include "MHCamEvent.h"
     30#include "MExtractTimeAndChargeSpline.h"
     31#include "MFillH.h"
     32#include "MDrsCalibApply.h"
     33#include "MGeomApply.h"
     34#include "MContinue.h"
     35#include "MRawFitsRead.h"
     36#include "MEvtLoop.h"
     37#include "MParList.h"
     38#include "MStatusDisplay.h"
     39#include "MDrsCalibrationTime.h"
     40#include "MH3.h"
     41#include "MGeomCamFACT.h"
     42#include "MCalibrateFact.h"
     43#include "MParameters.h"
     44#include "MWriteAsciiFile.h"
     45
     46/* Maybe you wanna use this macro like this:
     47 *
     48 * 0.) ---- call root ----
     49 *  root -b
     50 *
     51 * 1.) ---- compile the stuff ----
     52 *  .L fact/analysis/callisto_buildable_no_sequence_file.C++
     53 *  <read a lot of warnings>
     54 *
     55 * 2.) ---- you can call it then ----
     56 *      Therefore you need to specify all the paths ... see below.
     57 *   
     58 * When you wanna call the stuff directly from the bash make sure to
     59 * escape the bracets and quotes correctly.
     60 *
     61 * your can do:
     62 *  root -b -q callisto_buildable_no_sequence_file.C++'("path1","path2",...)'
     63 * or:
     64 *  root -b -q callisto_buildable_no_sequence_file.C++(\"path1\",\"$HOME\",...)
     65 * using bash enviroment variables like $HOME is not possible in the upper variant.
     66 */
     67
     68using namespace std;
     69
     70int callisto_for_monte_carlo_simulated_data(
     71            const char *drs_calib_300_path="/fhgfs/groups/app/fact/mc_test/testingdrsfile/test300samples.drs.fits",
     72            const char *pedestal_file_path="/fhgfs/groups/app/fact/mc_test/ceresfitstest/mcFilesForTests/mcNsbPedestal/00000001.001_P_MonteCarlo000_Events.fits",
     73            const char *data_file_path="/fhgfs/groups/app/fact/mc_test/ceresfitstest/mcFilesForTests/mcProton/00000003.387_D_MonteCarlo010_Events.fits",
     74           
     75            const char *root_file_output_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/callisto.root",
     76            const char *status_display_output_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/callisto_status_display.root",
     77            const char *status_display_title = "callisto_status_display")
    278{
     79   
    380    // ======================================================
    481
     
    1087
    1188    // map file to use (get that from La Palma!)
    12     const char *map = usemap ? "/home/fact/FACT++/FACTmap111030.txt" : NULL;
     89    const char *map = usemap ? "/fhgfs/groups/app/fact/resources/monte_carlo_FACTmap.txt" : NULL;
    1390
    1491    Bool_t maximum = kTRUE;
    1592
    1693    const char *lp_template    = maximum ?
    17         "template-lp-extractor-maximum.root" :
    18         "template-lp-extractor-leading-edge.root";
    19 
    20     const char *pulse_template = "template-pulse.root";
     94        "/cm/shared/apps/fact/Mars_svn_LP/template-lp-extractor-maximum.root" :
     95        "/cm/shared/apps/fact/Mars_svn_LP/template-lp-extractor-leading-edge.root";
     96
     97    const char *pulse_template = "/cm/shared/apps/fact/Mars_svn_LP/template-pulse.root";
    2198
    2299    // ------------------------------------------------------
     
    47124    // Extraction type: Extract integral and half leading edge
    48125
    49     const int type = maximum ? (MExtralgoSpline::kIntegralRel) : (MExtralgoSpline::kIntegralFixed);
     126    const MExtralgoSpline::ExtractionType_t type = maximum ? (MExtralgoSpline::kIntegralRel) : (MExtralgoSpline::kIntegralFixed);
    50127    //const int type = MExtralgoSpline::kIntegralFixed;
    51128
     
    54131
    55132    Long_t max  =    0;  // All
    56     Long_t max0 =  max;  // Time marker
    57     Long_t max1 =  max;  // Light pulser
    58     //Long_t max2 = 3000;  // Calibration ratio
    59133    Long_t max3 =  max;  // Pedestal Rndm
    60134    Long_t max4 =  max;  // Pedestal Ext
    61     Long_t max5 =  max;  // Data
    62135
    63136    // ======================================================
     
    65138    if (map && gSystem->AccessPathName(map, kFileExists))
    66139    {
    67         gLog << "ERROR - Cannot access mapping file '" << map << "'" << endl;
     140        gLog << err << "ERROR - Cannot access mapping file '" << map << "'" << endl;
    68141        return 1;
    69142    }
    70143
    71     // The sequence file which defines the files for the analysis
    72     MSequence seq(seqfile);
    73     if (!seq.IsValid())
    74     {
    75         gLog << "ERROR - Sequence '" << seqfile << "' invalid!" << endl;
    76         return 2;
     144    TString datfile = TString(data_file_path);
     145    TString drsfile = TString(drs_calib_300_path);
     146    TString pedfile = TString(pedestal_file_path);
     147
     148    gLog.Separator("Callisto");
     149    gLog << all;   
     150    gLog << "Data File        : " << datfile << "\n";
     151    gLog << "DRS calib     300: " << drsfile << '\n';
     152
     153    MDrsCalibration drscalib300;
     154    if (!drscalib300.ReadFits(drsfile.Data())) {
     155        gLog << err << "ERROR - Cannot access drscallib300 file '" << drsfile << "'" << endl;
     156        return 5;
    77157    }
    78 
    79     // --------------------------------------------------------------------------------
    80 
    81     gLog.Separator("Callisto");
    82     gLog << "Calibrate data of sequence '" << seq.GetFileName() << "'" << endl;
    83     gLog << endl;
     158    gLog << all;
     159    gLog << "Pedestal     file: " << pedfile << '\n';
     160
     161    gLog << "root_file_output_path: " << root_file_output_path << endl;
     162    gLog << "status_display_output_path: " << status_display_output_path << endl;
     163    gLog << "status_display_title: " << status_display_title << endl;
    84164
    85165    // ------------------------------------------------------
    86 
    87     ostringstream drsname;
    88     drsname << gSystem->DirName(seqfile) << "/";
    89     drsname << seq.GetNight().GetNightAsInt() << "_";
    90     drsname << Form("%03d", seq.GetDrsSequence()) << ".drs.seq";
    91 
    92     MSequence drs(drsname.str().c_str());
    93     if (!drs.IsValid())
    94     {
    95         gLog << "ERROR - DRS sequence invalid!" << endl;
    96         return 3;
    97     }
    98 
    99     gLog << "DRS sequence file: " << drsname.str() << '\n' << endl;
    100 
    101     TString drsfile = seq.GetFileName(0, MSequence::kRawDrs);
    102     if (drsfile.IsNull())
    103     {
    104         cout << "No DRS file available in sequence." << endl;
    105         return 4;
    106     }
    107 
    108     TString timfile = drs.GetFileName(0, MSequence::kFitsDat);
    109     TString drs1024 = drs.GetFileName(0, MSequence::kFitsDrs);
    110     TString pedfile = seq.GetFileName(0, MSequence::kFitsPed);
    111     TString calfile = seq.GetFileName(0, MSequence::kFitsCal);
    112 
    113     gLog << "DRS calib     300: " << drsfile << '\n';
    114     gLog << "DRS calib    1024: " << drs1024 << "\n\n";
    115 
    116     MDrsCalibration drscalib300;
    117     if (!drscalib300.ReadFits(drsfile.Data()))
    118         return 5;
    119 
    120     MDrsCalibration drscalib1024;
    121     if (!drscalib1024.ReadFits(drs1024.Data()))
    122         return 6;
    123 
    124     gLog << "Time calibration : " << timfile << '\n';
    125     gLog << "Pedestal     file: " << pedfile << '\n';
    126     gLog << "Light Pulser file: " << calfile << '\n' << endl;
    127 
    128     // ------------------------------------------------------
    129 
    130     MDirIter iter;
    131     if (seq.GetRuns(iter, MSequence::kFitsDat)<=0)
    132     {
    133         gLog << "ERROR - Sequence valid but without files." << endl;
    134         return 7;
    135     }
    136     iter.Print();
    137 
    138     // ======================================================
    139 
    140166    MStatusArray arrt, arrp;
    141167
     
    143169    if (arrt.Read()<=0)
    144170    {
    145         cout << "ERROR - Reading LP template from " << lp_template << endl;
     171        gLog << err << "ERROR - Reading LP template from " << lp_template << endl;
    146172        return 100;
    147173    }
     
    150176    if (!lpref)
    151177    {
    152         cout << "ERROR - LP Template not found in " << lp_template << endl;
     178        gLog << err << "ERROR - LP Template not found in " << lp_template << endl;
    153179        return 101;
    154180    }
     
    158184    if (!gain)
    159185    {
    160         cout << "ERROR - Gain not found in " << lp_template << endl;
     186        gLog << err << "ERROR - Gain not found in " << lp_template << endl;
    161187        return 101;
    162188    }
     
    166192    if (arrp.Read()<=0)
    167193    {
    168         cout << "ERROR - Reading Pulse template from " << pulse_template << endl;
     194        gLog << err << "ERROR - Reading Pulse template from " << pulse_template << endl;
    169195        return 102;
    170196    }
     
    173199    if (!hpulse)
    174200    {
    175         cout << "ERROR - Pulse Template not found in " << pulse_template << endl;
     201        gLog << err << "ERROR - Pulse Template not found in " << pulse_template << endl;
    176202        return 103;
    177203    }
    178204    hpulse->SetDirectory(0);
    179 
    180205    // ======================================================
    181206
     
    184209    MBadPixelsCam badpixels;
    185210    badpixels.InitSize(1440);
     211    /*
    186212    badpixels[ 424].SetUnsuitable(MBadPixelsPix::kUnsuitable);
    187213    badpixels[ 583].SetUnsuitable(MBadPixelsPix::kUnsuitable);
     
    190216    badpixels[1208].SetUnsuitable(MBadPixelsPix::kUnsuitable);
    191217    badpixels[1399].SetUnsuitable(MBadPixelsPix::kUnsuitable);
    192 
     218    */
    193219    //  Twin pixel
    194220    //     113
     
    211237    hrate.DefineLabelY(0x400, "Ped");
    212238    // hrate.DefaultLabelY("ERROR");
    213 
    214     Bool_t isinteg =
    215         (type&MExtralgoSpline::kIntegral)    ||
    216         (type&MExtralgoSpline::kFixedWidth)  ||
    217         (type&MExtralgoSpline::kDynWidth)
    218         ? kTRUE : kFALSE;
    219 
    220239    gStyle->SetOptFit(kTRUE);
    221240
    222     // ======================================================
    223 
    224     gLog << endl;
    225     gLog.Separator("Processing DRS timing calibration run");
    226 
    227     MTaskList tlist0;
    228 
    229     MParList plist0;
    230     plist0.AddToList(&tlist0);
    231     plist0.AddToList(&drscalib1024);
    232     plist0.AddToList(&badpixels);
    233     plist0.AddToList(&timecam);
    234 
    235     MEvtLoop loop0("DetermineTimeCal");
    236     loop0.SetDisplay(d);
    237     loop0.SetParList(&plist0);
    238 
    239     // ------------------ Setup the tasks ---------------
    240 
    241     MRawFitsRead read0(timfile);
    242 
    243     MContinue cont0("MRawEvtHeader.GetTriggerID!=33792", "SelectTim");
    244 
    245     MGeomApply apply0;
    246 
    247     MDrsCalibApply drsapply0;
    248 
    249     MFillH fill0("MHDrsCalibrationTime");
    250     fill0.SetNameTab("DeltaT");
    251 
    252     tlist0.AddToList(&read0);
    253     tlist0.AddToList(&apply0);
    254     tlist0.AddToList(&drsapply0);
    255     tlist0.AddToList(&cont0);
    256     tlist0.AddToList(&fill0);
    257 
    258     if (!loop0.Eventloop(max0))
    259         return 8;
    260 
    261     if (!loop0.GetDisplay())
    262         return 9;
    263 
    264     /*
    265      MHDrsCalibrationT *t = (MHDrsCalibrationT*)plist4.FindObject("MHDrsCalibrationT");
    266      t->SetDisplay(d);
    267      t->PlotAll();
    268      */
    269 
    270     // ======================================================
    271 
    272     gLog << endl;
    273     gLog.Separator("Processing external light pulser run");
    274 
    275     MTaskList tlist1;
    276 
    277     MParList plist1;
    278     plist1.AddToList(&tlist1);
    279     plist1.AddToList(&drscalib300);
    280     plist1.AddToList(&badpixels);
    281     plist1.AddToList(&timecam);
    282 
    283     MEvtLoop loop1("DetermineCalConst");
    284     loop1.SetDisplay(d);
    285     loop1.SetParList(&plist1);
    286 
    287     // ------------------ Setup the tasks ---------------
    288 
    289     MRawFitsRead read1;
    290     read1.LoadMap(map);
    291     read1.AddFile(calfile);
    292 
    293     MContinue cont1("(MRawEvtHeader.GetTriggerID&0xff00)!=0x100", "SelectCal");
    294 
    295     MGeomApply apply1;
    296 
    297     MDrsCalibApply drsapply1;
    298 
    299     /*
    300     MPedestalCam  fPedestalCamOut1a;
    301     MPedestalCam  fPedestalCamOut1b;
    302     MPedestalCam  fPedestalCamOut1c;
    303 
    304     MPedCalcPedRun pedcalc1a;
    305     MPedCalcPedRun pedcalc1b;
    306     MPedCalcPedRun pedcalc1c;
    307     pedcalc1a.SetPedestalsOut(&fPedestalCamOut1a);
    308     pedcalc1b.SetPedestalsOut(&fPedestalCamOut1b);
    309     pedcalc1c.SetPedestalsOut(&fPedestalCamOut1c);
    310 
    311     MExtractTimeAndChargeSpline extractor1ab;
    312     extractor1a.SetRange(first_slice, last_slice);
    313     extractor1a.SetRiseTimeHiGain(rise_time);
    314     extractor1a.SetFallTimeHiGain(fall_time);
    315     extractor1a.SetChargeType(type);
    316     extractor1a.SetSaturationLimit(600000);
    317     extractor1a.SetNoiseCalculation(kFALSE);
    318 
    319     pedcalc1a.SetRandomCalculation(kTRUE);
    320     pedcalc1b.SetRandomCalculation(kFALSE);
    321     pedcalc1a.SetExtractor(&extractor1a);
    322     pedcalc1b.SetExtractor($extractor1a);
    323     pedcalc1c.SetRangeFromExtractor(&extractor1a);
    324     */
    325 
    326     // ---
    327 
    328     MExtractTimeAndChargeSpline extractor1b("ExtractPulse");
    329     extractor1b.SetRange(first_slice, last_slice);
    330     extractor1b.SetRiseTimeHiGain(rise_time_cal);
    331     extractor1b.SetFallTimeHiGain(fall_time_cal);
    332     extractor1b.SetHeightTm(heighttm);
    333     extractor1b.SetChargeType(type);
    334     extractor1b.SetSaturationLimit(600000);
    335     extractor1b.SetNoiseCalculation(kFALSE);
    336 
    337     MExtractTimeAndChargeSpline extractor1c("ExtractAmplitude");
    338     extractor1c.SetRange(first_slice, last_slice);
    339     extractor1c.SetChargeType(MExtralgoSpline::kAmplitude);
    340     extractor1c.SetSaturationLimit(600000);
    341     extractor1c.SetNoiseCalculation(kFALSE);
    342     extractor1c.SetNameSignalCam("Amplitude");
    343     extractor1c.SetNameTimeCam("AmplitudePos");
    344 
    345     // ---
    346 
    347     MHCamEvent evt1a(5, "CalRatio", "Ratio per slice between integrated signal and amplitude;; r [1/n]");
    348     evt1a.SetNameSub("Amplitude", kTRUE);
    349     MFillH fill1a(&evt1a, "MExtractedSignalCam", "FillRatio");
    350     fill1a.SetDrawOption("gaus");
    351 
    352     MParameterD ratio1a;
    353     ratio1a.SetVal(1./(fall_time_cal+rise_time_cal));
    354     fill1a.SetWeight(&ratio1a);
    355 
    356     // ---
    357 
    358     MHCamEvent evt1f(0, "ExtCalSig", "Extracted calibration signal;;S [mV·sl]");
    359     MHCamEvent evt1g(4, "ExtCalTm",  "Extracted arrival times;;T [sl]");
    360     MHCamEvent evt1h(6, "CalCalTm",  "Calibrated arrival times;;T [sl]");
    361 
    362     MHSectorVsTime hist1rmsb("ExtSigVsTm");
    363     MHSectorVsTime hist1tmb("CalTmVsTm");
    364     hist1rmsb.SetTitle("Extracted calibration vs event number;;S [mV·sl]");
    365     hist1rmsb.SetType(0);
    366     hist1tmb.SetTitle("Extracted arrival time vs event number;;T [sl]");
    367     //hist1tmb.SetType(4);
    368     hist1tmb.SetType(6);
    369 
    370     MFillH fill1f(&evt1f, "MExtractedSignalCam", "FillExtSig");
    371     MFillH fill1g(&evt1g, "MArrivalTimeCam",     "FillExtTm");
    372     MFillH fill1h(&evt1h, "MSignalCam",          "FillCalTm");
    373     MFillH fill1r(&hist1rmsb, "MExtractedSignalCam", "FillExtSigVsTm");
    374     //MFillH fill1j(&hist1tmb,  "MArrivalTimeCam",     "FillExtTmVsTm");
    375     MFillH fill1j(&hist1tmb,  "MSignalCam",     "FillCalTmVsTm");
    376 
    377     fill1f.SetDrawOption("gaus");
    378     fill1h.SetDrawOption("gaus");
    379 
    380     // ---
    381 
    382     MCalibrateDrsTimes calctm1a("CalibrateCalEvents");
    383     calctm1a.SetNameUncalibrated("UncalibratedTimes");
    384 
    385     MBadPixelsTreat treat1;
    386     treat1.SetProcessPedestalRun(kFALSE);
    387     treat1.SetProcessPedestalEvt(kFALSE);
    388 
    389     // ---
    390 
    391     MHCamEvent evt1c(6, "ExtCalTmShift", "Relative extracted arrival time of calibration pulse (w.r.t. event-median);;\\Delta T [ns]");
    392     MHCamEvent evt1d(6, "CalCalTmShift", "Relative calibrated arrival time of calibration pulse (w.r.t. event-median);;\\Delta T [ns]");
    393 
    394     evt1c.SetMedianShift();
    395     evt1d.SetMedianShift();
    396 
    397     MFillH fill1c(&evt1c, "UncalibratedTimes", "FillExtCalTm");
    398     MFillH fill1d(&evt1d, "MSignalCam",        "FillCalCalTm");
    399     fill1d.SetDrawOption("gaus");
    400 
    401     // ------------------ Setup eventloop and run analysis ---------------
    402 
    403     tlist1.AddToList(&read1);
    404     tlist1.AddToList(&apply1);
    405     tlist1.AddToList(&drsapply1);
    406     tlist1.AddToList(&cont1);
    407     tlist1.AddToList(&extractor1b);
    408     if (isinteg)
    409     {
    410         tlist1.AddToList(&extractor1c);
    411         tlist1.AddToList(&fill1a);
    412     }
    413     tlist1.AddToList(&calctm1a);
    414     tlist1.AddToList(&treat1);
    415     tlist1.AddToList(&fill1f);
    416     tlist1.AddToList(&fill1g);
    417     tlist1.AddToList(&fill1h);
    418     tlist1.AddToList(&fill1r);
    419     tlist1.AddToList(&fill1j);
    420     tlist1.AddToList(&fill1c);
    421     tlist1.AddToList(&fill1d);
    422 
    423     if (!loop1.Eventloop(max1))
    424         return 10;
    425 
    426     if (!loop1.GetDisplay())
    427         return 11;
    428 
    429     if (use_delays)
    430         timecam.SetDelays(*evt1h.GetHist());
    431241
    432242    // ========================= Result ==================================
    433243
    434     Double_t avgS = evt1f.GetHist()->GetMean();
    435     Double_t medS = evt1f.GetHist()->GetMedian();
    436     Double_t rmsS = evt1f.GetHist()->GetRMS();
    437     Double_t maxS = evt1f.GetHist()->GetMaximum();
     244    //~ Double_t avgS = evt1f.GetHist()->GetMean();
     245    //~ Double_t medS = evt1f.GetHist()->GetMedian();
     246    //~ Double_t rmsS = evt1f.GetHist()->GetRMS();
     247    //~ Double_t maxS = evt1f.GetHist()->GetMaximum();
    438248
    439249    MArrayF der1(hpulse->GetNbinsX());
     
    454264    MArrayD calib(1440);
    455265    for (int i=0; i<1440; i++)
    456     {
    457         Double_t g = gain->GetBinContent(i+1)>0.5 ? gain->GetBinContent(i+1) : 1;
    458         if (evt1f.GetHist()->GetBinContent(i+1)>0 && !badpixels[i].IsUnsuitable())
    459             calib[i] = lpref->GetBinContent(i+1) / evt1f.GetHist()->GetBinContent(i+1) / g;
    460     }
     266        calib[i] =1.;
    461267
    462268    gROOT->SetSelectedPad(0);
     
    472278    Double_t w = hpulse->GetBinWidth(1);
    473279    Double_t T = w*(spline.GetTime()+0.5)       +ax->GetXmin();
    474     Double_t H = w*(hpulse->GetMaximumBin()+0.5)+ax->GetXmin();
     280    //~ Double_t H = w*(hpulse->GetMaximumBin()+0.5)+ax->GetXmin();
    475281
    476282    TLine line;
     
    704510    MRawFitsRead read5;
    705511    read5.LoadMap(map);
    706     read5.AddFiles(iter);
     512    read5.AddFile(datfile);
    707513
    708514    MFillH fill5a(&hrate);
     
    777583    //calctm4tm.SetFilter(&filtercal);
    778584
    779     MHCamEvent evt5m(6, "ExtTm",      "Extracted arrival times of calibration pulse;;\\Delta T [ns]");
    780     MHCamEvent evt5n(6, "CalTm",      "Calibrated arrival times of calibration pulse;;\\Delta T [ns]");
    781     MHCamEvent evt5q(6, "ExtTmShift", "Relative extracted arrival times of calibration pulse (w.r.t. event-median);;\\Delta T [ns]");
    782     MHCamEvent evt5r(6, "CalTmShift", "Relative calibrated arrival times of calibration pulse (w.r.t. event-median);;\\Delta T [ns]");
    783     MHCamEvent evt5s(6, "ExtTM",      "Extracted absolute time marker position;;T [sl]");
    784     MHCamEvent evt5t(6, "CalTM",      "Calibrated absolute time marker position;;T [ns]");
    785     MHCamEvent evt5u(6, "ExtTMshift", "Relative extracted time marker position (w.r.t. event-median);;\\Delta T [ns]");
    786     MHCamEvent evt5v(6, "CalTMshift", "Relative calibrated time marker position (w.r.t. event-median);;\\Delta T [ns]");
    787     MHCamEvent evt5w(6, "ExtDiff",    "Difference between extracted arrival time of time marker and calibration pulse;;\\Delta T [ns]");
    788     MHCamEvent evt5x(6, "CalDiff",    "Difference between calibrated arrival time of time marker and calibration pulse;;\\Delta T [ns]");
    789 
    790     evt5w.SetNameSub("UncalibratedTimes");
    791     evt5x.SetNameSub("MSignalCam");
    792 
    793     evt5q.SetMedianShift();
    794     evt5r.SetMedianShift();
    795     evt5u.SetMedianShift();
    796     evt5v.SetMedianShift();
    797     //evt4w.SetMedianShift();
    798     //evt4x.SetMedianShift();
    799 
    800     MFillH fill5m(&evt5m, "UncalibratedTimes", "FillExtTm");
    801     MFillH fill5n(&evt5n, "MSignalCam",        "FillCalTm");
    802     MFillH fill5q(&evt5q, "UncalibratedTimes", "FillExtTmShift");
    803     MFillH fill5r(&evt5r, "MSignalCam"       , "FillCalTmShift");
    804     MFillH fill5s(&evt5s, "UncalTimeMarker",   "FillExtTM");
    805     MFillH fill5t(&evt5t, "TimeMarker",        "FillCalTM");
    806     MFillH fill5u(&evt5u, "UncalTimeMarker",   "FillExtTMshift");
    807     MFillH fill5v(&evt5v, "TimeMarker",        "FillCalTMshift");
    808     MFillH fill5w(&evt5w, "UncalTimeMarker",   "FillExtDiff");
    809     MFillH fill5x(&evt5x, "TimeMarker",        "FillCalDiff");
    810 
    811     fill5m.SetDrawOption("gaus");
    812     fill5n.SetDrawOption("gaus");
    813     fill5q.SetDrawOption("gaus");
    814     fill5r.SetDrawOption("gaus");
    815     //fill5s.SetDrawOption("gaus");
    816     //fill5t.SetDrawOption("gaus");
    817     //fill5u.SetDrawOption("gaus");
    818     //fill5v.SetDrawOption("gaus");
    819     //fill5w.SetDrawOption("gaus");
    820     //fill5x.SetDrawOption("gaus");
    821 
    822 
    823585    MBadPixelsTreat treat5;
    824586    treat5.SetProcessPedestalRun(kFALSE);
    825587    treat5.SetProcessPedestalEvt(kFALSE);
    826 
    827     MHSectorVsTime hist5cal("CalVsTm");
    828     MHSectorVsTime hist5ped("PedVsTm");
    829     hist5cal.SetTitle("Median calibrated calibration signal vs event number;;Signal [~phe]");
    830     hist5ped.SetTitle("Median calibrated pedestal signal vs event number;;Signal [~phe]");
    831     hist5cal.SetType(0);
    832     hist5ped.SetType(0);
    833     hist5cal.SetMinimum(0);
    834     hist5ped.SetMinimum(0);
    835     hist5cal.SetUseMedian();
    836     hist5ped.SetUseMedian();
    837     hist5cal.SetNameTime("MTime");
    838     hist5ped.SetNameTime("MTime");
    839 
    840     MFillH fill5cal(&hist5cal, "MSignalCam", "FillCalVsTm");
    841     MFillH fill5ped(&hist5ped, "MSignalCam", "FillPedVsTm");
    842     fill5cal.SetFilter(&filtercal);
    843     fill5ped.SetFilter(&filterped);
    844588
    845589    MHCamEvent evt5b(0, "ExtSig",   "Extracted signal;;S [mV·sl]");
     
    868612    //contsw.SetInverted();
    869613
    870     const TString fname(Form("s/([0-9]+_[0-9]+)[.]fits([.]gz)?$/%s\\/$1_C.root/",
    871                              MJob::Esc(outpath).Data()));
    872 
    873614    // The second rule is for the case reading raw-files!
    874     MWriteRootFile write5(2, fname, "RECREATE", "Calibrated Data");
     615   
     616    MWriteRootFile write5(root_file_output_path, "RECREATE", "Calibrated Data", 2);
    875617    write5.AddContainer("MRawRunHeader", "RunHeaders");
    876618    write5.AddContainer("MGeomCam",      "RunHeaders");
     
    879621    write5.AddContainer("MRawEvtHeader", "Events");
    880622    //write.AddContainer("MTriggerPattern", "Events");
    881 
     623   
     624   
    882625    // ------------------ Setup histograms and fill tasks ----------------
    883626
     
    888631    tlist5tm.AddToList(&extractor5tm);
    889632    tlist5tm.AddToList(&calctm5tm);
    890     tlist5tm.AddToList(&fill5m);
    891     tlist5tm.AddToList(&fill5n);
    892     tlist5tm.AddToList(&fill5q);
    893     tlist5tm.AddToList(&fill5r);
    894     //tlist5tm.AddToList(&fill5s);
    895     //tlist5tm.AddToList(&fill5t);
    896     tlist5tm.AddToList(&fill5u);
    897     tlist5tm.AddToList(&fill5v);
    898     tlist5tm.AddToList(&fill5w);
    899     tlist5tm.AddToList(&fill5x);
    900633    tlist5tm.SetFilter(&filtercal);
    901634
     
    922655    tlist5.AddToList(&conv5);
    923656    tlist5.AddToList(&treat5);
    924     tlist5.AddToList(&fill5ped);
    925     tlist5.AddToList(&fill5cal);
    926657    tlist5.AddToList(&tlist5dat);
    927658    tlist5.AddToList(&write5);
     
    933664        return 19;
    934665
    935     TString title = "--  Calibrated signal #";
    936     title += seq.GetSequence();
    937     title += " (";
    938     title += drsfile;
    939     title += ")  --";
    940     d->SetTitle(title, kFALSE);
    941 
    942     TString path;
    943     path += Form("%s/20%6d_%03d-calibration.root", outpath,
    944                  seq.GetSequence()/1000, seq.GetSequence()%1000);
    945 
    946     d->SaveAs(path);
     666    d->SetTitle(status_display_title, kFALSE);
     667    d->SaveAs(status_display_output_path);
    947668
    948669    return 0;
  • branches/Mars_MC/fact/analysis/mc/star.C

    r17055 r17056  
    1 int star(const char *seqfile="sequences/20111205_013.seq", Double_t lvl1=7.8, Double_t lvl2=3.9, const char *inpath = "output", const char *outpath = "output")
     1#include <sstream>
     2#include <iostream>
     3
     4#include "TH1F.h"
     5#include "TFile.h"
     6#include "TStyle.h"
     7#include "TGraph.h"
     8#include "TLine.h"
     9
     10#include "MDrsCalibration.h"
     11#include "MLogManip.h"
     12#include "MExtralgoSpline.h"
     13#include "MSequence.h"
     14#include "MStatusArray.h"
     15#include "MHCamera.h"
     16#include "MJob.h"
     17#include "MWriteRootFile.h"
     18#include "MHCamera.h"
     19#include "MBadPixelsCam.h"
     20#include "MBadPixelsPix.h"
     21#include "MDirIter.h"
     22#include "MTaskList.h"
     23#include "MFDataPhrase.h"
     24#include "MArrayF.h"
     25#include "MBadPixelsTreat.h"
     26#include "MCalibrateDrsTimes.h"
     27#include "MHSectorVsTime.h"
     28#include "MHCamEvent.h"
     29#include "MExtractTimeAndChargeSpline.h"
     30#include "MFillH.h"
     31#include "MDrsCalibApply.h"
     32#include "MGeomApply.h"
     33#include "MContinue.h"
     34#include "MRawFitsRead.h"
     35#include "MEvtLoop.h"
     36#include "MParList.h"
     37#include "MStatusDisplay.h"
     38#include "MDrsCalibrationTime.h"
     39#include "MH3.h"
     40#include "MGeomCamFACT.h"
     41#include "MCalibrateFact.h"
     42#include "MParameters.h"
     43#include "MWriteAsciiFile.h"
     44
     45#include "MMuonSetup.h"
     46#include "MReadMarsFile.h"
     47#include "MHillasCalc.h"
     48#include "MHn.h"
     49#include "MMuonSearchParCalc.h"
     50#include "MMuonCalibParCalc.h"
     51#include "MBinning.h"
     52#include "MImgCleanStd.h"
     53
     54
     55using namespace std;
     56
     57int star_for_monte_carlo_simulated_data(
     58    const char *mars_data_file_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/callisto.root",
     59    const char *root_output_file_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/star.root",
     60    const char *status_display_output_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/star_status_display.root",
     61    const char *status_display_title = "star_status_display_title",
     62    const char *hillas_txt_file_path = "/fhgfs/groups/app/callisto_star_test/star_hillas.txt",
     63    Double_t lvl1=4.0,
     64    Double_t lvl2=2.5,
     65    Double_t deltat = 17.5)
    266{
    3     double deltat = 17.5;
     67    //Double_t lvl1=7.8,
     68    //Double_t lvl2=3.9,
    469    //    lvl1 = 2.5;
    570    //    lvl2 = 0.5;
    6 
    7     // The sequence file which defines the files for the analysis
    8     MSequence seq(seqfile);
    9     if (!seq.IsValid())
    10     {
    11         gLog << "ERROR - Sequence invalid!" << endl;
    12         return 1;
    13     }
    14 
    1571    // ------------------------------------------------------
    1672
    1773    gLog.Separator("Star");
    18     gLog << "Calculate image parameters of sequence ";
    19     gLog << seq.GetFileName() << endl;
     74    gLog << all << "Calculate image parameters of sequence ";
    2075    gLog << endl;
     76    gLog << "mars_data_file_path: " << mars_data_file_path << endl;
     77    gLog << "root_output_file_path: " << root_output_file_path << endl;
     78    gLog << "status_display_output_path: " << status_display_output_path << endl;
     79    gLog << "status_display_title: " << status_display_title << endl;
     80    gLog << endl;
     81    gLog << "lvl1: " << lvl1 <<endl;
     82    gLog << "lvl2: " << lvl2 <<endl;
     83   
     84   
     85    gLog << endl;
    2186
    2287    // ------------------------------------------------------
    23 
    24     gLog << "Inpath:   " << inpath << endl;
    25     gLog << "Outpath:  " << outpath << endl;
    26 
    27     const TString rule(Form("s/([0-9]+_[0-9]+)_C[.]root?$/%s\\/$1_I.root/",
    28                             MJob::Esc(outpath).Data()));
    29     gLog << "Rule:     " << rule << endl;
    30 
    31     MDirIter iter;
    32     if (seq.GetRuns(iter, MSequence::kFactCal, inpath)<=0)
    33     {
    34         gLog << "ERROR - Sequence valid but without files." << endl;
    35         return 2;
    36     }
    37 
    38     iter.Print();
    3988
    4089    gLog.Separator();
     
    4594    MBinning bins3(  67, -0.005, 0.665, "BinningTheta", "asin");
    4695    MBinning bins4(  25,      0,   2.5, "BinningDist");
    47 
    4896    MBinning binsM1(100,      0,     5, "BinningMuonRadius");
    4997    MBinning binsM2( 60,      0,   0.3, "BinningMuonDeviation");
     
    54102    MBinning binsM7( 30,      5,  5000, "BinningMuonSize", "log");
    55103    MBinning binsM8(100,      0,     5, "BinningMuonRelTimeSigma");
    56 
    57104    MBinning binsM9(100,      0,     5, "BinningRadius");
    58105
     
    104151    MReadMarsFile read("Events");
    105152    read.DisableAutoScheme();
    106     read.AddFiles(iter);
     153    read.AddFile(mars_data_file_path);
    107154
    108155    MContinue cont("MRawEvtHeader.GetTriggerID!=4", "SelectData");
     
    228275    // ---------------------------------------------------------------
    229276
    230     MWriteRootFile write(2, rule, "RECREATE", "Image parameters"); // EffectiveOnTime
     277    MWriteAsciiFile write_ascii_hillas(hillas_txt_file_path, "MHillas");
     278    write_ascii_hillas.AddColumns("MHillasExt");
     279    write_ascii_hillas.AddColumns("MHillasSrc");
     280
     281
     282    MWriteRootFile write(root_output_file_path, "RECREATE", "Image parameters", 2);
    231283    write.AddContainer("MTime",           "Events");
    232284    write.AddContainer("MHillas",         "Events");
     
    238290    write.AddContainer("MRawRunHeader",   "RunHeaders");
    239291    write.AddContainer("MGeomCam",        "RunHeaders");
    240 
    241292    MFDataPhrase fmuonhn("MMuonCalibPar.fRelTimeSigma>=0",
    242293                         "MuonHistCut");
     
    274325    //tlist.AddToList(&writem);
    275326    tlist.AddToList(&write);
     327    tlist.AddToList(&write_ascii_hillas);
    276328
    277329    if (!loop.Eventloop())
     
    281333        return 4;
    282334
    283     TString title = "--  Image parameters #";
    284     title += seq.GetSequence();
    285     title += "  --";
    286     d->SetTitle(title, kFALSE);
    287 
    288     TString path;
    289     path += Form("%s/20%06d_%03d-images.root", outpath,
    290                  seq.GetSequence()/1000, seq.GetSequence()%1000);
    291 
    292     d->SaveAs(path);
     335    d->SetTitle(status_display_title, kFALSE);
     336    d->SaveAs(status_display_output_path);
    293337
    294338    return 0;
Note: See TracChangeset for help on using the changeset viewer.