Changeset 18579 for trunk/Mars/fact


Ignore:
Timestamp:
09/06/16 10:25:30 (8 years ago)
Author:
tbretz
Message:
A copy of mc/callisto.C, removed the pedestal processing, adapted the mapping, removed the timecam from the tasklist to avoid processing the drs time calibration --> all this should go to callisto.C one day where MC files should be processed with the same code than data.
File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Mars/fact/analysis/mc/callisto_data.C

    r18554 r18579  
    7575 */
    7676
    77 int callisto(const TString drsfile="test300samples2.drs.fits.gz",
    78              const TString pedfile="00000001.001_P_MonteCarlo000_Events.fits",
    79              const TString datfile="00000003.387_D_MonteCarlo010_Events.fits",
    80              TString outpath = "",
    81              TString displayfile = "", TString displaytitle = "")
     77int callisto_data(const TString drsfile="test300samples2.drs.fits.gz",
     78                  const TString datfile="00000003.387_D_MonteCarlo010_Events.fits",
     79                  TString outpath = "",
     80                  TString displayfile = "", TString displaytitle = "")
    8281{
    8382
     
    118117    // false: Display pixels in hardware/linear indices,
    119118    //        but the order is the camera display is distorted
    120     bool usemap = true;
     119    bool usemap = false;
    121120
    122121    // map file to use (get that from La Palma!)
    123     const char *pmap = usemap ? "/home/isdc/toscanos/FACT/Mars_svn/resources/FACTmap111030.txt" : NULL;
     122    const char *pmap = usemap ? "FACTmap111030.txt" : NULL;
    124123
    125124    // ------------------------------------------------------
     
    160159
    161160    //double scale = 0.1;
    162     double scale = 0.1024;
     161    double scale = 0.1024; // 0.00389429
    163162
    164163    // ======================================================
     
    181180    }
    182181    gLog << all;
    183     gLog << "Pedestal file: " << pedfile << '\n';
    184182    gLog << "Output file:   " << outfile << '\n';
    185183    gLog << "Display file:  " << displayfile << '\n';
     
    187185
    188186    // ------------------------------------------------------
    189 /*
    190     MStatusArray arrt, arrp;
    191 
    192     TFile ft(lp_template);
    193     if (arrt.Read()<=0)
    194     {
    195         gLog << err << "ERROR - Reading LP template from " << lp_template << endl;
    196         return 100;
    197     }
    198 
    199     MHCamera *lpref = (MHCamera*)arrt.FindObjectInCanvas("ExtCalSig;avg", "MHCamera", "Cam");
    200     if (!lpref)
    201     {
    202         gLog << err << "ERROR - LP Template not found in " << lp_template << endl;
    203         return 101;
    204     }
    205     lpref->SetDirectory(0);
    206 
    207     MHCamera *gain = (MHCamera*)arrt.FindObjectInCanvas("gain", "MHCamera", "Gain");
    208     if (!gain)
    209     {
    210         gLog << err << "ERROR - Gain not found in " << lp_template << endl;
    211         return 101;
    212     }
    213     gain->SetDirectory(0);
    214 
    215     TFile fp(pulse_template);
    216     if (arrp.Read()<=0)
    217     {
    218         gLog << err << "ERROR - Reading Pulse template from " << pulse_template << endl;
    219         return 102;
    220     }
    221 
    222     TH1F *hpulse = (TH1F*)arrp.FindObjectInCanvas("hPixelEdgeMean0_0", "TH1F", "cgpPixelPulses0");
    223     if (!hpulse)
    224     {
    225         gLog << err << "ERROR - Pulse Template not found in " << pulse_template << endl;
    226         return 103;
    227     }
    228     hpulse->SetDirectory(0);
    229     */
    230     // ======================================================
    231 
    232     MDrsCalibrationTime timecam;
     187
     188    // ======================================================
    233189
    234190    // Plot the trigger pattern rates vs. run-number
     
    246202
    247203    // ========================= Result ==================================
    248 /*
    249     //~ Double_t avgS = evt1f.GetHist()->GetMean();
    250     //~ Double_t medS = evt1f.GetHist()->GetMedian();
    251     //~ Double_t rmsS = evt1f.GetHist()->GetRMS();
    252     //~ Double_t maxS = evt1f.GetHist()->GetMaximum();
    253 
    254     MArrayF der1(hpulse->GetNbinsX());
    255     MArrayF der2(hpulse->GetNbinsX());
    256 
    257     MExtralgoSpline spline(hpulse->GetArray()+1, hpulse->GetNbinsX(),
    258                            der1.GetArray(), der2.GetArray());
    259     spline.SetRiseFallTime(rise_time_dat, fall_time_dat);
    260     spline.SetExtractionType(type);
    261     spline.SetHeightTm(heighttm);
    262 
    263     spline.Extract(hpulse->GetMaximumBin()-1);
    264 
    265     // The pulser signal is most probably around 400mV/9.5mV
    266     // IntegraFixed 2/48 corresponds to roughly 215mV*50slices
    267     Double_t scale = 1./spline.GetSignal();
    268 
    269     MArrayD calib(1440);
    270     for (int i=0; i<1440; i++)
    271         calib[i] =1.;
    272 
    273     gROOT->SetSelectedPad(0);
    274     d->AddTab("PulseTemp");
    275     gPad->SetGrid();
    276     hpulse->SetNameTitle("Pulse", "Single p.e. pulse template");
    277     hpulse->SetDirectory(0);
    278     hpulse->SetLineColor(kBlack);
    279     hpulse->DrawCopy();
    280 
    281     TAxis *ax = hpulse->GetXaxis();
    282 
    283     Double_t w = hpulse->GetBinWidth(1);
    284     Double_t T = w*(spline.GetTime()+0.5)       +ax->GetXmin();
    285     //~ Double_t H = w*(hpulse->GetMaximumBin()+0.5)+ax->GetXmin();
    286 
    287     TLine line;
    288     line.SetLineColor(kRed);
    289     line.DrawLine(T-rise_time_dat*w, spline.GetHeight(),
    290                   T+fall_time_dat*w, spline.GetHeight());
    291     line.DrawLine(T, spline.GetHeight()/4, T, 3*spline.GetHeight()/4);
    292     line.DrawLine(T-rise_time_dat*w, 0,
    293                   T-rise_time_dat*w, spline.GetHeight());
    294     line.DrawLine(T+fall_time_dat*w, 0,
    295                   T+fall_time_dat*w, spline.GetHeight());
    296 
    297     TGraph gg;
    298     for (int ix=1; ix<=hpulse->GetNbinsX(); ix++)
    299         for (int i=0; i<10; i++)
    300         {
    301             Double_t x = hpulse->GetBinLowEdge(ix)+i*hpulse->GetBinWidth(ix)/10.;
    302             gg.SetPoint(gg.GetN(), x+w/2, spline.EvalAt(ix-1+i/10.));
    303         }
    304 
    305     gg.SetLineColor(kBlue);
    306     gg.SetMarkerColor(kBlue);
    307     gg.SetMarkerStyle(kFullDotMedium);
    308     gg.DrawClone("L");
    309 
    310     gROOT->SetSelectedPad(0);
    311     d->AddTab("CalConst");
    312     MGeomCamFACT fact;
    313     MHCamera hcalco(fact);
    314     hcalco.SetName("CalConst");
    315     hcalco.SetTitle(Form("Relative calibration constant [%.0f/pe]", 1./scale));
    316     hcalco.SetCamContent(calib);
    317     hcalco.SetAllUsed();
    318     //hcalco.Scale(scale);
    319     hcalco.DrawCopy();
    320 */
    321     // ======================================================
    322204
    323205    gLog << endl;
    324     gLog.Separator("Extracting random pedestal");
    325 
    326     MTaskList tlist3;
    327 
    328     MParList plist3;
    329     plist3.AddToList(&tlist3);
    330     plist3.AddToList(&drscalib300);
    331     plist3.AddToList(&badpixels);
    332     plist3.AddToList(&timecam);
    333 
    334     MEvtLoop loop3("DetermineRndmPed");
    335     loop3.SetDisplay(d);
    336     loop3.SetParList(&plist3);
    337 
    338     // ------------------ Setup the tasks ---------------
    339 
    340     MRawFitsRead read3;
    341     read3.LoadMap(pmap);
    342     read3.AddFile(pedfile);
    343 
    344     MFillH fill3a(&hrate);
    345 
    346     MContinue cont3("(MRawEvtHeader.GetTriggerID&0xff00)!=0x400", "SelectPed");
    347 
    348     MGeomApply apply3;
    349 
    350     MDrsCalibApply drsapply3;
    351 
    352     MFilterData filterdata5;
    353 
    354     //---
    355 
    356     MExtractFACT extractor3;
    357     extractor3.SetRange(first_slice, last_slice);
    358     extractor3.SetNoiseCalculation(kTRUE);
    359 
    360     MCalibrateFact conv3;
    361     conv3.SetScale(scale);
    362     //conv3.SetCalibConst(calib);
    363 
    364     MBadPixelsTreat treat3;
    365     treat3.SetProcessPedestalRun(kFALSE);
    366     treat3.SetProcessPedestalEvt(kFALSE);
    367     treat3.SetProcessTimes(kFALSE);
    368 
    369     MHCamEvent evt3b(0, "PedRdm","Interpolated random pedestal;;Signal [~phe]");
    370     //evt2b.SetErrorSpread(kFALSE);
    371 
    372     MFillH fill3b(&evt3b, "MSignalCam", "FillPedRdm");
    373     fill3b.SetDrawOption("gaus");
    374 
    375     // ------------------ Setup eventloop and run analysis ---------------
    376 
    377     tlist3.AddToList(&read3);
    378     tlist3.AddToList(&apply3);
    379     tlist3.AddToList(&drsapply3);
    380     tlist3.AddToList(&cont3);
    381     tlist3.AddToList(&filterdata3);
    382     tlist3.AddToList(&extractor3);
    383 //    tlist3.AddToList(&fill3a);
    384     tlist3.AddToList(&conv3);
    385     tlist3.AddToList(&treat3);
    386     tlist3.AddToList(&fill3b);
    387 
    388     if (!loop3.Eventloop(max3))
    389         return 14;
    390 
    391     if (!loop3.GetDisplay())
    392         return 15;
    393 
    394     // ======================================================
    395 
    396     gLog << endl;
    397     gLog.Separator("Extracting pedestal");
    398 
    399     MTaskList tlist4;
    400 
    401     MParList plist4;
    402     plist4.AddToList(&tlist4);
    403     plist4.AddToList(&drscalib300);
    404     plist4.AddToList(&badpixels);
    405     plist4.AddToList(&timecam);
    406 
    407     MEvtLoop loop4("DetermineExtractedPed");
    408     loop4.SetDisplay(d);
    409     loop4.SetParList(&plist4);
    410 
    411     // ------------------ Setup the tasks ---------------
    412 
    413     MRawFitsRead read4;
    414     read4.LoadMap(pmap);
    415     read4.AddFile(pedfile);
    416 
    417     MContinue cont4("(MRawEvtHeader.GetTriggerID&0xff00)!=0x400", "SelectPed");
    418 
    419     MGeomApply apply4;
    420 
    421     MDrsCalibApply drsapply4;
    422 
    423     MFilterData filterdata4;
    424 
    425     MExtractFACT extractor4;
    426     extractor4.SetRange(first_slice, last_slice);
    427     extractor4.SetNoiseCalculation(kFALSE);
    428 
    429     MCalibrateFact conv4;
    430     conv4.SetScale(scale);
    431     //conv4.SetCalibConst(calib);
    432 
    433     MBadPixelsTreat treat4;
    434     treat4.SetProcessPedestalRun(kFALSE);
    435     treat4.SetProcessPedestalEvt(kFALSE);
    436 
    437     MHCamEvent evt4b(0, "PedExt","Interpolated extracted pedestal;;Signal [~phe]");
    438     //evt4b.SetErrorSpread(kFALSE);
    439 
    440     MFillH fill4b(&evt4b, "MSignalCam", "FillPedExt");
    441     fill4b.SetDrawOption("gaus");
    442 
    443     // ------------------ Setup eventloop and run analysis ---------------
    444 
    445     tlist4.AddToList(&read4);
    446     tlist4.AddToList(&apply4);
    447     tlist4.AddToList(&drsapply4);
    448     tlist4.AddToList(&cont4);
    449     tlist4.AddToList(&filterdata4);
    450     tlist4.AddToList(&extractor4);
    451     tlist4.AddToList(&conv4);
    452     tlist4.AddToList(&treat4);
    453     tlist4.AddToList(&fill4b);
    454 
    455     if (!loop4.Eventloop(max4))
    456         return 15;
    457 
    458     if (!loop4.GetDisplay())
    459         return 16;
    460 
    461     // ===================================================================
    462 
    463     gLog << endl;
    464     gLog.Separator("Extracting and calibration data");
     206    gLog.Separator("Extracting and calibrating data");
    465207
    466208    MTaskList tlist5;
     
    470212    plist5.AddToList(&drscalib300);
    471213    plist5.AddToList(&badpixels);
    472     plist5.AddToList(&timecam);
    473214
    474215    MEvtLoop loop5("CalibratingData");
     
    480221    MRawFitsRead read5a;
    481222    MReadMarsFile read5b("Events");
    482     read5a.LoadMap(pmap);
     223    if (pmap)
     224        read5a.LoadMap(pmap);
    483225    read5a.AddFile(datfile);
    484226    read5b.DisableAutoScheme();
Note: See TracChangeset for help on using the changeset viewer.