Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
#!/usr/bin/perl

# A script to generate cfg files for the loading of the offline condDB

use warnings;
use strict;
$|++;

use File::Spec;

# Options
my $smSlot = 1;

# Connection and resource locations
my $connect = "oracle://cmsr/CMS_ECAL_H4_COND";
my $catalog = "relationalcatalog_oracle://cmsr/CMS_ECAL_H4_COND";
my $logfile = "/afs/cern.ch/cms/ECAL/testbeam/pedestal/2006/LOGFILE/cms_ecal_h4_cond.log";
my $cfgdir = "/afs/cern.ch/cms/ECAL/testbeam/pedestal/2006/config_files/write/cms_ecal_h4_cond";
$ENV{TNS_ADMIN} = "/afs/cern.ch/project/oracle/admin";

unless ($#ARGV == 3) {
  die "ERROR:  Use Args:  object inputfile tagsuffix since\n";
}

my ($object, $inputfile, $tagsuffix, $since) = @ARGV;

# "Fake mode" if since < 0
my $fake = $since < 0 ? 1 : 0;

# Rework the parameters
$cfgdir = File::Spec->rel2abs( $cfgdir );
$inputfile = File::Spec->rel2abs( $inputfile );
$logfile = File::Spec->rel2abs( $logfile );
my $record = $object.'Rcd';
my $tag = $object.'_'.$tagsuffix;
my $appendIOV = "false";
my $mode = "create";
if ($since != 0) { 
  $appendIOV = "true"; 
  $mode = "append";
}

# Get the number of the config file
opendir DIR, $cfgdir or die $!;
my @cfgfiles = sort(grep(/^\d{3}_.+\.cfg$/, readdir( DIR )));
my $cfgnum = @cfgfiles ? $#cfgfiles + 1 : 0;
my $cfgfile = sprintf("%03s_${object}_${mode}_${tagsuffix}.cfg", $cfgnum);
$cfgfile = File::Spec->catfile($cfgdir, $cfgfile) or die $!;
closedir DIR;

# Print our settings
print <<ENDPRINT;
=== Config Arguments ===
connect    $connect
catalog    $catalog
logfile    $logfile
object     $object
inputfile  $inputfile
tag        $tag
since      $since
appenIOV   $appendIOV
cfgfile    $cfgfile
ENDPRINT

# Make the config file
my $essource = '';
$essource =<<ENDCONFIG if $since != 0;
    es_source = PoolDBESSource
    {
        string connect = "$connect"
        untracked string catalog = "$catalog"
        untracked uint32 authenticationMethod = 1
        bool loadAll = true
        string timetype = "runnumber"
        VPSet toGet =
        {
            {
                string record = "$record"
                string tag = "$tag"
            }
        }
     }
ENDCONFIG

my $config =<<ENDCONFIG;
process TEST =
{
    source = EmptyIOVSource
    {
        string timetype = "runnumber"
	untracked uint32 firstRun = 1
        untracked uint32 lastRun  = 1
        uint32 interval = 1
    }

$essource

    service = PoolDBOutputService
    {
	string connect = "$connect"
	untracked string catalog = "$catalog"
	untracked uint32 authenticationMethod = 1
	string timetype = "runnumber"
	VPSet toPut =
	{
	    {
		untracked string containerName = "$object"
		untracked bool appendIOV = $appendIOV
		string tag ="$tag"
	    }
	}
    }
    
    module ecalModule = StoreEcalCondition
    {
        string logfile = "$logfile"
        untracked uint32 smSlot = $smSlot
	VPSet toPut =
	{
	    {
		untracked string conditionType = "$object"
		untracked string inputFile = "$inputfile"
		untracked uint32 since = $since
	    }
	}
    }

    path p =
    {
	ecalModule
    }

}
ENDCONFIG

# Write the config file
if ($fake) {
  print $config, "\n";
} else {
  open FILE, '>', $cfgfile or die $!;
  print FILE $config;
  close FILE;
}

# Execute cmsRun on the config file
print "=== Executing cmsRun ===\n";
system("cmsRun $cfgfile") unless $fake;

exit $?;