Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:56

0001 #!/usr/bin/perl
0002 
0003 # A script to generate cfg files for the loading of the offline condDB
0004 
0005 use warnings;
0006 use strict;
0007 $|++;
0008 
0009 use File::Spec;
0010 
0011 # Options
0012 my $smSlot = 1;
0013 
0014 # Connection and resource locations
0015 my $connect = "oracle://cmsr/CMS_ECAL_H4_COND";
0016 my $catalog = "relationalcatalog_oracle://cmsr/CMS_ECAL_H4_COND";
0017 my $logfile = "/afs/cern.ch/cms/ECAL/testbeam/pedestal/2006/LOGFILE/cms_ecal_h4_cond.log";
0018 my $cfgdir = "/afs/cern.ch/cms/ECAL/testbeam/pedestal/2006/config_files/write/cms_ecal_h4_cond";
0019 $ENV{TNS_ADMIN} = "/afs/cern.ch/project/oracle/admin";
0020 
0021 unless ($#ARGV == 3) {
0022   die "ERROR:  Use Args:  object inputfile tagsuffix since\n";
0023 }
0024 
0025 my ($object, $inputfile, $tagsuffix, $since) = @ARGV;
0026 
0027 # "Fake mode" if since < 0
0028 my $fake = $since < 0 ? 1 : 0;
0029 
0030 # Rework the parameters
0031 $cfgdir = File::Spec->rel2abs( $cfgdir );
0032 $inputfile = File::Spec->rel2abs( $inputfile );
0033 $logfile = File::Spec->rel2abs( $logfile );
0034 my $record = $object.'Rcd';
0035 my $tag = $object.'_'.$tagsuffix;
0036 my $appendIOV = "false";
0037 my $mode = "create";
0038 if ($since != 0) { 
0039   $appendIOV = "true"; 
0040   $mode = "append";
0041 }
0042 
0043 # Get the number of the config file
0044 opendir DIR, $cfgdir or die $!;
0045 my @cfgfiles = sort(grep(/^\d{3}_.+\.cfg$/, readdir( DIR )));
0046 my $cfgnum = @cfgfiles ? $#cfgfiles + 1 : 0;
0047 my $cfgfile = sprintf("%03s_${object}_${mode}_${tagsuffix}.cfg", $cfgnum);
0048 $cfgfile = File::Spec->catfile($cfgdir, $cfgfile) or die $!;
0049 closedir DIR;
0050 
0051 # Print our settings
0052 print <<ENDPRINT;
0053 === Config Arguments ===
0054 connect    $connect
0055 catalog    $catalog
0056 logfile    $logfile
0057 object     $object
0058 inputfile  $inputfile
0059 tag        $tag
0060 since      $since
0061 appenIOV   $appendIOV
0062 cfgfile    $cfgfile
0063 ENDPRINT
0064 
0065 # Make the config file
0066 my $essource = '';
0067 $essource =<<ENDCONFIG if $since != 0;
0068     es_source = PoolDBESSource
0069     {
0070         string connect = "$connect"
0071         untracked string catalog = "$catalog"
0072         untracked uint32 authenticationMethod = 1
0073         bool loadAll = true
0074         string timetype = "runnumber"
0075         VPSet toGet =
0076         {
0077             {
0078                 string record = "$record"
0079                 string tag = "$tag"
0080             }
0081         }
0082      }
0083 ENDCONFIG
0084 
0085 my $config =<<ENDCONFIG;
0086 process TEST =
0087 {
0088     source = EmptyIOVSource
0089     {
0090         string timetype = "runnumber"
0091     untracked uint32 firstRun = 1
0092         untracked uint32 lastRun  = 1
0093         uint32 interval = 1
0094     }
0095 
0096 $essource
0097 
0098     service = PoolDBOutputService
0099     {
0100     string connect = "$connect"
0101     untracked string catalog = "$catalog"
0102     untracked uint32 authenticationMethod = 1
0103     string timetype = "runnumber"
0104     VPSet toPut =
0105     {
0106         {
0107         untracked string containerName = "$object"
0108         untracked bool appendIOV = $appendIOV
0109         string tag ="$tag"
0110         }
0111     }
0112     }
0113     
0114     module ecalModule = StoreEcalCondition
0115     {
0116         string logfile = "$logfile"
0117         untracked uint32 smSlot = $smSlot
0118     VPSet toPut =
0119     {
0120         {
0121         untracked string conditionType = "$object"
0122         untracked string inputFile = "$inputfile"
0123         untracked uint32 since = $since
0124         }
0125     }
0126     }
0127 
0128     path p =
0129     {
0130     ecalModule
0131     }
0132 
0133 }
0134 ENDCONFIG
0135 
0136 # Write the config file
0137 if ($fake) {
0138   print $config, "\n";
0139 } else {
0140   open FILE, '>', $cfgfile or die $!;
0141   print FILE $config;
0142   close FILE;
0143 }
0144 
0145 # Execute cmsRun on the config file
0146 print "=== Executing cmsRun ===\n";
0147 system("cmsRun $cfgfile") unless $fake;
0148 
0149 exit $?;