Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:19

0001 #!/usr/bin/env perl
0002 
0003 # This scrits must be used ./runNtpMakerCAF.pl RunNumber
0004 # It looks for streamer files from run with name $GLOBAL following
0005 # the CMS conventions for the path name.
0006 #Jobs are submitted on the CAF.
0007 
0008  
0009 #------Configure here ---------------------------------------
0010 #$GLOBAL="GlobalCruzet4";
0011 #$GLOBAL="GlobalRAFF";
0012 $GLOBAL="Commissioning08";
0013 $pathToFiles="Calo/RAW/v1";
0014 #$eventSource="\"NewEventStreamFileReader\"";
0015 $eventSource="\"PoolSource\"";
0016 $nfiles= 100;  #number of files processed per job
0017 $numJobs = -1; #number of jobs you want to submit (use -1 if all)
0018 $nEvents = -1; #number of events you want to run in each job (use -1 if all)
0019 $lumiMin = -1; #select based on lumi number, if all put -1
0020 $lumiMax = 9999; #select based on lumi number, if all put a high number 
0021 #-------------------------------------------------------------
0022 
0023 
0024 if(! $ARGV[0] ) {print "Usage: ./runNtpMaker.pl RunNumber\n"; exit;}
0025 
0026 $RUN = $ARGV[0]; 
0027 
0028 $A = substr($RUN,0,2);
0029 $ZERO = "0";
0030 $A = $ZERO.$A;
0031 $B = substr($RUN,2);
0032 
0033 ##look in castor and get list of files
0034 system("nsls /castor/cern.ch/cms/store/data/$GLOBAL/$pathToFiles/000/$A/$B/ > files.txt");
0035 $count = `wc -l < files.txt`;
0036 die "wc failed: $?" if $?;
0037 chomp($count);
0038 print "-----------------------------\n";
0039 print "Total number of file: $count\n";
0040 print "-----------------------------\n";
0041 
0042 #read file list
0043 open(MYFILE, "<files.txt");
0044 $line=0;
0045 $myn=0;
0046 $job=1; # so that nothing is processed if no lumi section is found
0047 @names = ();
0048 while(<MYFILE>)
0049 {
0050 $name = $_;
0051 chomp($name);
0052 
0053 #check lumi section assuming std output naming convention
0054 $indx = index($name, '.');
0055 $indx = index($name, '.',$indx+1);
0056 $lumi = substr($name,$indx+1,4);
0057 $lumi = $lumi+0; #needed to convert string to number
0058 
0059 if($lumi > $lumiMin && $lumi < $lumiMax) {
0060 #print "lumi is $lumi\n"; 
0061 push(@names, $name); #accumulate the files for i_th-job.
0062 #print "$name";
0063 $line++;
0064 $job = $line%$nfiles; 
0065 
0066   if(eof(MYFILE)) 
0067   {
0068     $job=0; #so that if there are not enough files wrt $nfiles
0069   }         #it uses those.
0070 }
0071 #end lumo part
0072 
0073 if($job==0){
0074 
0075 $total=@names;
0076 $myn=$line/$nfiles;
0077 
0078 if(eof(MYFILE) || int($myn)==0) {$myn=0;}
0079 
0080 #create i_th configuration file 
0081 open CFGFILE, "> l1prompt_$RUN\_$myn\_cfg.py";
0082 
0083 print CFGFILE "import FWCore.ParameterSet.Config as cms\n";
0084 print CFGFILE "\n";
0085 print CFGFILE "process = cms.Process(\"L1Prompt\")\n";
0086 print CFGFILE "\n";
0087 print CFGFILE "process.load(\"L1TriggerConfig.L1GeometryProducers.l1CaloGeometry_cfi\")\n"; 
0088 print CFGFILE "process.load(\"L1TriggerConfig.L1GeometryProducers.l1CaloGeomRecordSource_cff\")\n"; 
0089 print CFGFILE "process.load(\"L1TriggerOffline.L1Analyzer.dttfUnpack_cff\")\n"; 
0090 print CFGFILE "process.load(\"L1TriggerOffline.L1Analyzer.gtUnpack_cff\")\n"; 
0091 print CFGFILE "process.load(\"L1TriggerOffline.L1Analyzer.gctUnpack_cff\")\n"; 
0092 print CFGFILE "process.load(\"L1TriggerOffline.L1Analyzer.L1PromptAnalysis_cfi\")\n";
0093 print CFGFILE "process.l1PromptAnalysis.OutputFile = '$RUN\_$myn.root'\n";
0094 print CFGFILE "\n";
0095 print CFGFILE "process.source = cms.Source($eventSource,\n";
0096 print CFGFILE "fileNames = cms.untracked.vstring(\n";
0097 $ii=0;
0098 foreach $ll (@names)
0099 {
0100 $ii++;
0101 #print "$ll";
0102 if($ii != $total){
0103 print CFGFILE "\'/store/data/$GLOBAL/$pathToFiles/000/$A/$B/$ll\',\n";
0104 } else
0105 {
0106 print CFGFILE "\'/store/data/$GLOBAL/$pathToFiles/000/$A/$B/$ll\'\n";
0107 }
0108 }
0109 @names=();
0110 print CFGFILE ")\n";
0111 print CFGFILE ")\n";
0112 print CFGFILE "\n";
0113 print CFGFILE "process.maxEvents = cms.untracked.PSet(\n";
0114 print CFGFILE "    input = cms.untracked.int32($nEvents)\n";
0115 print CFGFILE ")\n";
0116 print CFGFILE "\n";
0117 print CFGFILE "process.p = cms.Path(process.l1GtUnpack+process.l1GctHwDigis+process.l1GtEvmUnpack+process.l1dttfunpack+process.l1PromptAnalysis)\n";
0118 print CFGFILE "\n";
0119 
0120 print "bsub -J $RUN\_$myn -q cmscaf submit.ch l1prompt_$RUN\_$myn\_cfg.py $RUN\_$myn\n";
0121 system("bsub -J $RUN\_$myn -q cmscaf submit.ch l1prompt_$RUN\_$myn\_cfg.py $RUN\_$myn\n");
0122 
0123 
0124 if($myn==$numJobs) {exit;}
0125 
0126 }
0127 }
0128 print "End submission...\n";
0129