Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:12

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, "> BadStrips.cff" or die "Can't write to BadStrips.cff";
0006 print OUT <<_EOF;
0007 replace prod.BadComponentList = {
0008 _EOF
0009 
0010 sub block($$) { 
0011     my ($first, $length) = @_;
0012     return ($first .. ($first + $length - 1));
0013 }
0014 
0015 my $first = 1;
0016 my $tot = 0; my $bads = 0;
0017 while(<ALL>) {
0018     my ($detid, $napv, $foo, $bar) = split(/\s+/, $_);
0019     my $strips = 128 * $napv;
0020     my @badStrips = ();
0021 
0022     # --- insert logic here ------    
0023 
0024     my $prob   = 0.20; #10% of the modules will have at least one bad strip
0025     my $pmult  = 0.30; #30% chanche of having another bad block after the first one
0026     #if (($napv <= 6) && ($detid =~ /^3/)) {  
0027         my $ptr = int(rand($strips/$prob));
0028         while ($ptr < $strips) {
0029             my $len = (rand() < 0.2 ? 1 : int(rand(8)+1));
0030             push @badStrips, block($ptr,$len); 
0031             $ptr += $len; last unless $ptr < $strips;
0032             $ptr += int(rand(($strips-$ptr)/$pmult)); 
0033         }
0034     #}
0035 
0036     # --- end logic --------------
0037 
0038     if (@badStrips) {
0039         my $record = sprintf("{ uint32 BadModule = %d vuint32 BadChannelList = {%s} }",
0040                                 $detid, join(',', @badStrips));
0041         print OUT ($first ? "\t " : "\t,"), $record, "\n";
0042         $first = 0;
0043         $bads++;
0044     }
0045     $tot++;
0046 }
0047 
0048 print OUT "}\n";
0049 close OUT;
0050 print "Summary: $bads modules with bad Strips over $tot total modules.\n";