#! /usr/bin/perl
#
# Usage: ./plot_sm.pl dirname [all] [plottype]
#    OR  ./plot_sm.pl dirname layer stack
#
# Auto plot tool.

sub usage{
    printf("\n");
    printf("plot tool for noise in supermodule.\n");
    printf("\n");
    printf("Usage: ./plot_sm.pl dirname [all] [plottype]  ->  Plot data in files in \"dirname\". All ROCs.\n");
    printf("                                                  [plottype] argument is optional\n");
    printf("                                                  [plottype]=0 (default): Noise,    ROB granularity.\n");
    printf("                                                  [plottype]=1          : Noise,    MCM granularity.\n");
    printf("                                                  [plottype]=2          : Noise,    ADC granularity.\n");
    printf("                                                  [plottype]=3          : Baseline, ADC granularity.\n");
    printf("                                                  [plottype]=4          : Noise,    Pad granularity.\n");
    printf("       ./o32_plot.pl dirname [layer] [stack]  ->  Plot data in files in \"dirname\". Single ROC.\n");
    printf("\n");
}

if( ($#ARGV == 0) ) {
    $Dir   = $ARGV[0];
    $Nevts = 1;
    system("root \'plot_sm.C\(\"$Dir\", $Nevts, \"All\", 99, 99 \)\'");
} elsif( ($#ARGV == 1) && ($ARGV[1]=="all") ) {
    $Dir  = $ARGV[0];
    $Nevts = 1;
    system("root \'plot_sm.C\(\"$Dir\", $Nevts, \"All\", 99, 99 \)\'");
} elsif( ($#ARGV == 2) && ($ARGV[1]=="all") ) {
    $Dir     = $ARGV[0];
    $Nevts    = 1;
    $plottype = $ARGV[2];
    system("root \'plot_sm.C\(\"$Dir\", $Nevts, \"All\", 99, 99, \" \",$plottype \)\'");
} elsif( $#ARGV == 2 ) {
    $Dir    = $ARGV[0];
    $layer   = $ARGV[1];
    $stack   = $ARGV[2];
    $Nevts = 1;
    system("root \'plot_sm.C\(\"$Dir\", $Nevts, \"L$layerS$stack\", $layer, $stack \)\'");
} else {
    usage;
}

# EOF
