Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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