Ignore:
Timestamp:
04/26/14 15:35:48 (10 years ago)
Author:
tbretz
Message:
Improved the calling convention. There is really no need to give so many arguments. Pipe some Monte Carlo values through. I wonder what special MC macros are for which omit all the Monte Carlo data in their output.
Location:
trunk/Mars/fact/analysis/mc
Files:
2 edited

Legend:

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

    r17641 r17699  
    1 using namespace std;
    2 
    31#include <sstream>
    42#include <iostream>
     3
     4#include "MLog.h"
     5#include "MLogManip.h"
    56
    67#include "TH1F.h"
     
    1011#include "TLine.h"
    1112
     13#include "../mcore/DrsCalib.h"
    1214#include "MDrsCalibration.h"
    13 //#include "MLogManip.h"
    1415#include "MExtralgoSpline.h"
    1516#include "MSequence.h"
     
    4546#include "MWriteAsciiFile.h"
    4647
     48using namespace std;
     49
    4750/* Maybe you wanna use this macro like this:
    4851 *
     
    6770 */
    6871
    69 //using namespace std;
    70 
    71 int callisto(
    72             const char *drs_calib_300_path="/fhgfs/groups/app/fact/mc_test/testingdrsfile/test300samples.drs.fits",
    73             const char *pedestal_file_path="/fhgfs/groups/app/fact/mc_test/ceresfitstest/mcFilesForTests/mcNsbPedestal/00000001.001_P_MonteCarlo000_Events.fits",
    74             const char *data_file_path="/fhgfs/groups/app/fact/mc_test/ceresfitstest/mcFilesForTests/mcProton/00000003.387_D_MonteCarlo010_Events.fits",
    75            
    76             const char *root_file_output_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/callisto.root",
    77             const char *status_display_output_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/callisto_status_display.root",
    78             const char *status_display_title = "callisto_status_display")
     72int callisto(const TString drsfile="test300samples.drs.fits",
     73             const TString pedfile="00000001.001_P_MonteCarlo000_Events.fits",
     74             const TString datfile="00000003.387_D_MonteCarlo010_Events.fits",
     75             TString outfile = "",
     76             TString displayfile = "", TString displaytitle = "")
    7977{
    80    
     78
     79    // ======================================================
     80
     81    if (displaytitle.IsNull())
     82        displaytitle = gSystem->BaseName(datfile);
     83
     84    FileStat_t fstat;
     85    int rc = gSystem->GetPathInfo(outfile, fstat);
     86    bool isdir = !rc || R_ISDIR(fstat.fMode);
     87
     88    const char *buf = gSystem->ConcatFileName(outfile, "callisto.root");
     89    outfile = buf;
     90    delete [] buf;
     91
     92    if (displayfile.IsNull())
     93    {
     94        displayfile = outfile;
     95        displayfile.Insert(displayfile.Last('.'), "-display");
     96    }
     97    else
     98    {
     99        if (isdir && gSystem->DirName(displayfile)==TString("."))
     100        {
     101            buf = gSystem->ConcatFileName(outfile, displayfile);
     102            displayfile = buf;
     103            delete [] buf;
     104        }
     105    }
     106
    81107    // ======================================================
    82108
     
    88114
    89115    // map file to use (get that from La Palma!)
    90     const char *map = usemap ? "/fhgfs/groups/app/fact/resources/monte_carlo_FACTmap.txt" : NULL;
     116    const char *map = usemap ? "TestForThomas/FACT/FACTmap111030.txt" : NULL;
    91117
    92118    Bool_t maximum = kTRUE;
     
    96122    //    "/cm/shared/apps/fact/Mars_svn_LP/template-lp-extractor-leading-edge.root";
    97123
    98     const char *lp_template    = "/cm/shared/apps/fact/Mars_Trunk/template-lp.root";
    99 
    100     //const char *pulse_template = "/cm/shared/apps/fact/Mars_svn_LP/template-pulse.root";
    101 
    102     const char *pulse_template = "/cm/shared/apps/fact/Mars_Trunk/template-pulse.root";
     124    const char *pulse_template = "TestForThomas/FACT/template-pulse.root";
    103125
    104126    // ------------------------------------------------------
     
    147169    }
    148170
    149     TString datfile = TString(data_file_path);
    150     TString drsfile = TString(drs_calib_300_path);
    151     TString pedfile = TString(pedestal_file_path);
    152 
    153171    gLog.Separator("Callisto");
    154     gLog << all;   
    155     gLog << "Data File        : " << datfile << "\n";
    156     gLog << "DRS calib     300: " << drsfile << '\n';
     172    gLog << all;
     173    gLog << "Data File:     " << datfile << '\n';
     174    gLog << "DRS calib 300: " << drsfile << endl;;
    157175
    158176    MDrsCalibration drscalib300;
     
    162180    }
    163181    gLog << all;
    164     gLog << "Pedestal     file: " << pedfile << '\n';
    165 
    166     gLog << "root_file_output_path: " << root_file_output_path << endl;
    167     gLog << "status_display_output_path: " << status_display_output_path << endl;
    168     gLog << "status_display_title: " << status_display_title << endl;
     182    gLog << "Pedestal file: " << pedfile << '\n';
     183    gLog << "Output file:   " << outfile << '\n';
     184    gLog << "Display file:  " << displayfile << '\n';
     185    gLog << "Display title: " << displaytitle << endl;
    169186
    170187    // ------------------------------------------------------
    171188    MStatusArray arrt, arrp;
    172189
    173     TFile ft(lp_template);
    174     if (arrt.Read()<=0)
    175     {
    176         gLog << err << "ERROR - Reading LP template from " << lp_template << endl;
    177         return 100;
    178     }
    179 
    180     MHCamera *lpref = (MHCamera*)arrt.FindObjectInCanvas("ExtCalSig;avg", "MHCamera", "Cam");
    181     if (!lpref)
    182     {
    183         gLog << err << "ERROR - LP Template not found in " << lp_template << endl;
    184         return 101;
    185     }
    186     lpref->SetDirectory(0);
     190    // TFile ft(lp_template);
     191    // if (arrt.Read()<=0)
     192    // {
     193    //     gLog << err << "ERROR - Reading LP template from " << lp_template << endl;
     194    //     return 100;
     195    // }
     196
     197    // MHCamera *lpref = (MHCamera*)arrt.FindObjectInCanvas("ExtCalSig;avg", "MHCamera", "Cam");
     198    // if (!lpref)
     199    // {
     200    //     gLog << err << "ERROR - LP Template not found in " << lp_template << endl;
     201    //     return 101;
     202    // }
     203    // lpref->SetDirectory(0);
    187204
    188205    // MHCamera *gain = (MHCamera*)arrt.FindObjectInCanvas("gain", "MHCamera", "Gain");
     
    619636    // The second rule is for the case reading raw-files!
    620637   
    621     MWriteRootFile write5(root_file_output_path, "RECREATE", "Calibrated Data", 2);
    622     write5.AddContainer("MRawRunHeader", "RunHeaders");
    623     write5.AddContainer("MGeomCam",      "RunHeaders");
    624     write5.AddContainer("MSignalCam",    "Events");
    625     write5.AddContainer("MTime",         "Events");
    626     write5.AddContainer("MRawEvtHeader", "Events");
     638    MWriteRootFile write5(outfile, "RECREATE", "Calibrated Data", 2);
     639    write5.AddContainer("MRawRunHeader",       "RunHeaders");
     640    write5.AddContainer("MGeomCam",            "RunHeaders");
     641    write5.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
     642    write5.AddContainer("MCorsikaRunHeader",   "RunHeaders", kFALSE);
     643    write5.AddContainer("MMcRunHeader",        "RunHeaders", kFALSE);
     644
     645    // Common events
     646    write5.AddContainer("MCorsikaEvtHeader",   "Events", kFALSE);
     647    write5.AddContainer("MMcEvt",              "Events", kFALSE);
     648    write5.AddContainer("IncidentAngle",       "Events", kFALSE);
     649    write5.AddContainer("MPointingPos",        "Events", kFALSE);
     650    write5.AddContainer("MSignalCam",          "Events");
     651    write5.AddContainer("MTime",               "Events");
     652    write5.AddContainer("MRawEvtHeader",       "Events");
    627653    //write.AddContainer("MTriggerPattern", "Events");
    628    
    629654   
    630655    // ------------------ Setup histograms and fill tasks ----------------
     
    669694        return 19;
    670695
    671     d->SetTitle(status_display_title, kFALSE);
    672     d->SaveAs(status_display_output_path);
     696    d->SetTitle(displaytitle, kFALSE);
     697    d->SaveAs(displayfile);
    673698
    674699    return 0;
  • trunk/Mars/fact/analysis/mc/star.C

    r17641 r17699  
    11#include <sstream>
    22#include <iostream>
     3
     4#include "MLog.h"
     5#include "MLogManip.h"
    36
    47#include "TH1F.h"
     
    811#include "TLine.h"
    912
     13#include "../mcore/DrsCalib.h"
    1014#include "MDrsCalibration.h"
    1115//#include "MLogManip.h"
     
    5357#include "MImgCleanStd.h"
    5458
    55 
    5659using namespace std;
    5760
    58 int star(
    59     const char *mars_data_file_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/callisto.root",
    60     const char *root_output_file_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/star.root",
    61     const char *status_display_output_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/star_status_display.root",
    62     const char *status_display_title = "star_status_display_title",
    63     const char *hillas_txt_file_path = "/fhgfs/groups/app/callisto_star_test/star_hillas.txt",
    64     Double_t lvl1=4.0,
    65     Double_t lvl2=2.5,
    66     Double_t deltat = 17.5)
     61int star(const TString callistofile, TString outfile,
     62         TString displayfile, TString displaytitle,
     63         const TString txtfile,
     64         Double_t lvl1=4.0, Double_t lvl2=2.5, Double_t deltat = 17.5);
     65
     66
     67int star(const TString infile = "callisto.root", TString outfile = "",
     68         Double_t lvl1=4.0,  Double_t lvl2=2.5, Double_t deltat = 17.5)
    6769{
     70    return star(infile, outfile, "", "", "", lvl1, lvl2, deltat);
     71}
     72
     73int star(const TString callistofile, TString outfile,
     74         TString displayfile,  TString displaytitle,
     75         const TString txtfile,
     76         Double_t lvl1, Double_t lvl2, Double_t deltat)
     77{
     78
    6879    //Double_t lvl1=7.8,
    6980    //Double_t lvl2=3.9,
     
    7283    // ------------------------------------------------------
    7384
     85    if (displaytitle.IsNull())
     86        displaytitle = gSystem->BaseName(callistofile);
     87
     88    FileStat_t fstat;
     89    int rc = gSystem->GetPathInfo(outfile, fstat);
     90    bool isdir = !rc || R_ISDIR(fstat.fMode);
     91
     92    char *buf = gSystem->ConcatFileName(outfile, "star.root");
     93    outfile = buf;
     94    delete [] buf;
     95
     96    if (displayfile.IsNull())
     97    {
     98        displayfile = outfile;
     99        displayfile.Insert(displayfile.Last('.'), "-display");
     100    }
     101    else
     102    {
     103        if (isdir && gSystem->DirName(displayfile)==TString("."))
     104        {
     105            buf = gSystem->ConcatFileName(outfile, displayfile);
     106            displayfile = buf;
     107            delete [] buf;
     108        }
     109    }
     110
     111    // ------------------------------------------------------
     112
    74113    gLog.Separator("Star");
    75114    gLog << all << "Calculate image parameters of sequence ";
    76115    gLog << endl;
    77     gLog << "mars_data_file_path: " << mars_data_file_path << endl;
    78     gLog << "root_output_file_path: " << root_output_file_path << endl;
    79     gLog << "status_display_output_path: " << status_display_output_path << endl;
    80     gLog << "status_display_title: " << status_display_title << endl;
     116    gLog << "Callisto file: " << callistofile << endl;
     117    gLog << "Output file:   " << outfile << endl;
     118    gLog << "Display file:  " << displayfile << endl;
     119    gLog << "Display title: " << displaytitle << endl;
    81120    gLog << endl;
    82     gLog << "lvl1: " << lvl1 <<endl;
    83     gLog << "lvl2: " << lvl2 <<endl;
     121    gLog << "lvl1: "   << lvl1 <<endl;
     122    gLog << "lvl2: "   << lvl2 <<endl;
     123    gLog << "deltat: " << deltat <<endl;
    84124   
    85125   
     
    152192    MReadMarsFile read("Events");
    153193    read.DisableAutoScheme();
    154     read.AddFile(mars_data_file_path);
     194    read.AddFile(callistofile);
    155195
    156196    MContinue cont("MRawEvtHeader.GetTriggerID!=4", "SelectData");
     
    276316    // ---------------------------------------------------------------
    277317
    278     MWriteAsciiFile write_ascii_hillas(hillas_txt_file_path, "MHillas");
    279     write_ascii_hillas.AddColumns("MHillasExt");
    280     write_ascii_hillas.AddColumns("MHillasSrc");
    281 
    282 
    283     MWriteRootFile write(root_output_file_path, "RECREATE", "Image parameters", 2);
    284     write.AddContainer("MTime",           "Events");
    285     write.AddContainer("MHillas",         "Events");
    286     write.AddContainer("MHillasExt",      "Events");
    287     write.AddContainer("MHillasSrc",      "Events");
    288     write.AddContainer("MImagePar",       "Events");
    289     write.AddContainer("MNewImagePar",    "Events");
    290     write.AddContainer("MRawEvtHeader",   "Events");
    291     write.AddContainer("ThetaSquared",   "Events");
    292     write.AddContainer("Disp",           "Events");
    293     write.AddContainer("MRawRunHeader",   "RunHeaders");
    294     write.AddContainer("MGeomCam",        "RunHeaders");
     318    MWriteAsciiFile writeascii(txtfile, "MHillas");
     319    writeascii.AddColumns("MHillasExt");
     320    writeascii.AddColumns("MHillasSrc");
     321
     322
     323    MWriteRootFile write(outfile, "RECREATE", "Image parameters", 2);
     324    write.AddContainer("MTime",               "Events");
     325    write.AddContainer("MHillas",             "Events");
     326    write.AddContainer("MHillasExt",          "Events");
     327    write.AddContainer("MHillasSrc",          "Events");
     328    write.AddContainer("MImagePar",           "Events");
     329    write.AddContainer("MNewImagePar",        "Events");
     330    write.AddContainer("MRawEvtHeader",       "Events");
     331    write.AddContainer("ThetaSquared",        "Events");
     332    write.AddContainer("Disp",                "Events");
     333    write.AddContainer("MCorsikaEvtHeader",   "Events", kFALSE);
     334    write.AddContainer("MMcEvt",              "Events", kFALSE);
     335    write.AddContainer("IncidentAngle",       "Events", kFALSE);
     336    write.AddContainer("MPointingPos",        "Events", kFALSE);
     337
     338    write.AddContainer("MRawRunHeader",       "RunHeaders");
     339    write.AddContainer("MGeomCam",            "RunHeaders");
     340    write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
     341    write.AddContainer("MCorsikaRunHeader",   "RunHeaders", kFALSE);
     342    write.AddContainer("MMcRunHeader",        "RunHeaders", kFALSE);
     343
    295344    MFDataPhrase fmuonhn("MMuonCalibPar.fRelTimeSigma>=0",
    296345                         "MuonHistCut");
     
    351400    //tlist.AddToList(&writem);
    352401    tlist.AddToList(&write);
    353     tlist.AddToList(&write_ascii_hillas);
     402    if (!txtfile.IsNull())
     403        tlist.AddToList(&writeascii);
    354404
    355405    if (!loop.Eventloop())
     
    359409        return 4;
    360410
    361     d->SetTitle(status_display_title, kFALSE);
    362     d->SaveAs(status_display_output_path);
     411    d->SetTitle(displaytitle, kFALSE);
     412    d->SaveAs(displayfile);
    363413
    364414    return 0;
    365415}
     416
Note: See TracChangeset for help on using the changeset viewer.