Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:36

0001 use strict;
0002 use warnings;
0003 open ALL, $ENV{'CMSSW_RELEASE_BASE'}."/src/CalibTracker/SiStripCommon/data/SiStripDetInfo.dat" or die "Can't find SiStripDetInfo.dat";
0004 
0005 open OUT, "> BadAPVs.cff" or die "Can't write to BadAPVs.cff";
0006 print OUT <<_EOF;
0007 replace prod.BadComponentList = {
0008 _EOF
0009 
0010 my $first = 1;
0011 my $tot = 0; my $bads = 0;
0012 while(<ALL>) {
0013     my ($detid, $napv, $foo, $bar) = split(/\s+/, $_);
0014     my @badAPVs = ();
0015 
0016     # --- insert logic here ------    
0017 
0018     if (($napv <= 6) && ($detid =~ /^3/)) {  
0019         foreach my $apv (0 .. ($napv-1)) { 
0020            if (rand() < 0.2) { 
0021               push @badAPVs, $apv; 
0022            }
0023         }
0024     }
0025 
0026     # --- end logic --------------
0027 
0028     if (@badAPVs) {
0029         my $record = sprintf("{ uint32 BadModule = %d vuint32 BadApvList = {%s} }",
0030                                 $detid, join(',', @badAPVs));
0031         print OUT ($first ? "\t " : "\t,"), $record, "\n";
0032         $first = 0;
0033         $bads++;
0034     }
0035     $tot++;
0036 }
0037 
0038 print OUT "}\n";
0039 close OUT;
0040 print "Summary: $bads modules with bad APVs over $tot total modules.\n";