Ignore:
Timestamp:
05/24/12 02:06:03 (12 years ago)
Author:
Jens Buss
Message:
 
additonal conditions when which method will be called
add int main that can get the function parameters from a rc file
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/rootmacros/PulseTemplates/FPulseOverlay.C

    r13779 r13852  
    7070//#include "pixel.C"
    7171
     72#include "configfile.h"
     73
    7274
    7375//----------------------------------------------------------------------------
     
    193195//----------------------------------------------------------------------------
    194196int FPulseOverlay(
    195         TString     datafilename        = "raw/2012/03/09/20120309_018.fits.gz",
    196         TString     drsfilename         = "raw/2012/03/09/20120309_012.drs.fits.gz",
    197         TString     OutRootFileName     = "analysis/FPulseTemplate/20120309_018/Overlay/20120309_018.root",
    198         bool            ProduceGraphic      = false,
    199         bool            spikeDebug          = false,
    200         bool            debugPixel          = false,
    201         bool            testmode            = false,
    202         bool            saveResults         = true,
    203         int             verbosityLevel      = 1,        // different verbosity levels can be implemented here
     197        TString         inputPath           = "raw/2012/03/09/",
     198        TString         datafilename        = "20120309_018.fits.gz",
     199        TString         drsfilename         = "20120309_012.drs.fits.gz",
     200        TString         OutputPath          = "analysis/FPulseTemplate/20120309_018/Overlay/",
     201        TString         OutRootFileName     = "20120309_018.root",
    204202        int             firstevent          = 1,        // Hast to be between 1 and infinity NOT 0!!!!
    205203        int             nevents             = -1,
     
    208206        int             pixelSetSize       = 150,
    209207        int             maxPulseOrder       = 5,
     208        int             verbosityLevel      = 1,        // different verbosity levels can be implemented here
     209        TString         histoOptions        = "SRM",
    210210        int             AmplWindowWidth     = 16,       //Width of Window for selection of pulses to histograms
    211         TString         histoOptions        = "SRM",
    212211        float           GainMean            = 9,
    213212        float           BSLMean             = -1,        //4 Histogramms will be drawn, decide how far pulsehights differ from eachother
     
    216215        int             OverlayWindowLeft   = 70,
    217216        int             OverlayWindowRight  = 230,
     217        bool            ProduceGraphic      = false,
     218        bool            spikeDebug          = false,
     219        bool            debugPixel          = false,
     220        bool            stats               = false,
     221        bool            saveResults         = true,
     222        bool            testmode            = false,
    218223        int             refresh_rate        = 500      //refresh rate for canvases
    219224        )
     
    223228//      Save-Root-File Settings
    224229//----------------------------------------------------------------------------
    225     datafilename        = SetHostsPaths(false,   datafilename );
    226     drsfilename         = SetHostsPaths(false,   drsfilename );
    227     OutRootFileName     = SetHostsPaths(true,  OutRootFileName );
     230
     231    inputPath       = SetHostsPaths(false, inputPath );
     232    OutputPath      = SetHostsPaths(true, OutputPath );
     233    datafilename.Prepend(inputPath);
     234    drsfilename.Prepend(inputPath);
     235    OutRootFileName.Prepend(OutputPath);
     236//    drsfilename         = SetHostsPaths(false,   drsfilename );
     237//    OutRootFileName     = SetHostsPaths(true,  OutRootFileName );
     238    cout <<  endl;
     239    cout << "drs filename:\t" << drsfilename << endl;
     240    cout << "data filename:\t" << datafilename << endl;
     241    cout << "out filename:\t" << OutRootFileName << endl;
     242
    228243
    229244    if (saveResults)
     
    403418// Main Cycle
    404419//-----------------------------------------------------------------------------
    405 
     420    if ( pixelSetSize == -1 )
     421    {
     422        pixelSetSize = firstpixel +npixel;
     423    }
    406424//----------------------------------------------------------------------------
    407425// Initialize Pixel
     
    422440    {
    423441        lastPixelOfSet = firstPixelOfSet + pixelSetSize-1;
     442        if (lastPixelOfSet > firstpixel + npixel)
     443        {
     444            lastPixelOfSet = firstpixel + npixel;
     445        }
    424446        if (lastPixelOfSet > 1439)
    425447        {
     
    484506                                maxPulseOrder,
    485507                                verbosityLevel,
    486                                 false,
     508                                stats,
    487509                                histoOptions,
    488                                 NULL,
    489510                                gPixelOverlayXaxisLeft,
    490511                                gPixelOverlayXaxisRight,
     
    12181239
    12191240
    1220 int main()
     1241int main(int argc,char *argv[])
    12211242{
    12221243
    1223 FPulseOverlay();
    1224 return 0;
     1244    TString     test;
     1245    TString     rcFileName;
     1246    TString     processType             = "overlay";
     1247    bool        rcFileNameCmdSet        = false;
     1248    int         verbLevel               = 0; // different verbosity levels can be implemented here
     1249    bool        verbLevelCmdSet         = false;
     1250    bool        save                    = false;
     1251    bool        produceGraphic          = false;
     1252
     1253    // decode arguments
     1254    if(argc < 2)
     1255    {
     1256        printf("no arguements given, using standard arguments\n");
     1257    }
     1258
     1259    // set conditions for functions arguments
     1260    for (int i=1;i<argc;i++)
     1261    {
     1262        test = argv[i];
     1263
     1264        if (test.Contains("--config_file") || test.Contains("-c"))
     1265        {
     1266            cout << "RC-File: \"" << argv[i + 1] << "\"" << endl;
     1267            rcFileName = argv[i + 1];
     1268            rcFileNameCmdSet = true;
     1269            continue;
     1270        }
     1271
     1272        if (test.Contains("--verbosity") || test.Contains("-v"))
     1273        {
     1274            cout << "Verbosity Level: \"" << argv[i + 1] << "\"" << endl;
     1275            verbLevel = atoi(argv[i + 1]);
     1276            continue;
     1277        }
     1278
     1279        if (test.Contains("--save") || test.Contains("-s"))
     1280        {
     1281            cout << "will save results" << endl;
     1282            save = true;
     1283            continue;
     1284        }
     1285
     1286        if (test.Contains("--graphics") || test.Contains("-g"))
     1287        {
     1288            cout << "will produce graphics" << endl;
     1289            produceGraphic = true;
     1290            continue;
     1291        }
     1292    }
     1293
     1294    // reading rc-File:
     1295    configfile rcfile( rcFileName, processType );
     1296
     1297    if (save)
     1298    {
     1299        rcfile.mSave = save;
     1300    }
     1301
     1302    if (verbLevelCmdSet)
     1303    {
     1304        rcfile.mVerbLevel = verbLevel;
     1305    }
     1306
     1307    if (produceGraphic)
     1308    {
     1309        rcfile.mProduceGraphic = produceGraphic;
     1310    }
     1311
     1312    FPulseOverlay(
     1313                rcfile.mInputPath,
     1314                rcfile.mDataFileName,
     1315                rcfile.mDrsFileName,
     1316                rcfile.mOutputPath,
     1317                rcfile.mOutputFile,
     1318                rcfile.mFirstEvent,
     1319                rcfile.mNumEvents,
     1320                rcfile.mFirstPixel,
     1321                rcfile.mNumPixel,
     1322                rcfile.mPixelSetSize,
     1323                rcfile.mMaxOrder,
     1324                rcfile.mVerbLevel,
     1325                rcfile.mHistoOptions,
     1326                rcfile.mAmplWindowWidth,
     1327                rcfile.mGainMean,
     1328                rcfile.mBSLMean,
     1329                rcfile.mAvg1,
     1330                rcfile.mAvg2,
     1331                rcfile.mOverlayWindowLeft,
     1332                rcfile.mOverlayWindowRight,
     1333                rcfile.mProduceGraphic,
     1334                rcfile.mSpikeDebug,
     1335                rcfile.mDbgPixel,
     1336                rcfile.mPrintStats,
     1337                rcfile.mSave,
     1338                rcfile.mTestMode,
     1339                rcfile.mRefreshRate
     1340                );
     1341    return 0;
    12251342
    12261343}
Note: See TracChangeset for help on using the changeset viewer.