Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:09

0001 #!/usr/bin/env perl
0002 
0003 #located in offline/framework/frog/
0004 
0005 use DBI;
0006 use strict;
0007 use Getopt::Long;
0008 use Data::Dumper;
0009 use List::Util qw(shuffle);
0010 
0011 sub commonfiletypes;
0012 sub fill_nocombine_files;
0013 sub print_single_types;
0014 sub print_runs;
0015 
0016 my $dbh = DBI->connect("dbi:ODBC:FileCatalog_read") || die $DBI::error;
0017 $dbh->{LongReadLen}=2000; # full file paths need to fit in here
0018 
0019 my $getdsttypes = $dbh->prepare("select distinct(dsttype) from datasets where dsttype not like '%\_pi\_%' ESCAPE '\' and dsttype <> 'beam' and dsttype <> 'cosmic' and dataset = 'mdc2'");
0020 $getdsttypes->execute();
0021 
0022 my %dsttype = ();
0023 while(my @res = $getdsttypes->fetchrow_array())
0024 {
0025     my $listfile = sprintf("%s.list",lc $res[0]);
0026     $dsttype{$res[0]} = $listfile;
0027     if (-f $listfile)
0028     {
0029     unlink $listfile;
0030     }
0031 }
0032 my %exclude_these = (
0033     "DST_JOBA" => "Test PanDa",
0034     "DST_MDC2_GLOBAL" => "Test PanDa",
0035     "DST_PASS1_CLUSTERS" => "Test PanDa",
0036     "DST_RECO_CLUSTER" => "Test PanDa"
0037     );
0038 
0039 my %proddesc = (
0040 #    "1" => "hijing (0-12fm) pileup 0-12fm DELETED",
0041 #    "2" => "hijing (0-4.88fm) pileup 0-12fm DELETED",
0042     "3" => "pythia8 pp MB",
0043     "4" => "hijing (0-20fm) pileup 0-20fm",
0044 #    "5" => "hijing (0-12fm) pileup 0-20fm DELETED",
0045     "6" => "hijing (0-4.88fm) pileup 0-20fm",
0046     "7" => "HF pythia8 Charm",
0047     "8" => "HF pythia8 Bottom",
0048     "9" => "HF pythia8 Charm D0",
0049     "10" => "HF pythia8 Bottom D0",
0050     "11" => "JS pythia8 Jet ptmin = 30GeV",
0051     "12" => "JS pythia8 Jet ptmin = 10GeV",
0052     "13" => "JS pythia8 Photon Jet",
0053     "14" => "Single Particles",
0054     "15" => "Special Productions",
0055     "16" => "HF pythia8 D0 Jets",
0056     "17" => "HF pythia8 D0 pi-k Jets ptmin = 5GeV ",
0057     "18" => "HF pythia8 D0 pi-k Jets ptmin = 12GeV",
0058     "19" => "JS pythia8 Jet ptmin = 40GeV",
0059     "20" => "hijing pAu (0-10fm) pileup 0-10fm",
0060     "21" => "JS pythia8 Jet ptmin = 20GeV",
0061     "22" => "cosmic field on",
0062     "23" => "cosmic field off",
0063     "24" => "AMPT",
0064     "25" => "EPOS",
0065     "26" => "JS pythia8 Detroit",
0066     "27" => "JS pythia8 Photonjet ptmin = 5GeV",
0067     "28" => "JS pythia8 Photonjet ptmin = 10GeV",
0068     "29" => "JS pythia8 Photonjet ptmin = 20GeV",
0069     "30" => "Herwig MB",
0070     "31" => "Herwig Jet ptmin = 10 GeV",
0071     "32" => "Herwig Jet ptmin = 30 GeV",
0072     "33" => "JS pythia8 Jet ptmin = 15GeV",
0073     "34" => "JS pythia8 Jet ptmin = 50GeV"
0074     );
0075 
0076 my %pileupdesc = (
0077     "1" => "50kHz for Au+Au, 3MHz for p+p (default)",
0078     "2" => "25kHz for Au+Au",
0079     "3" => "10kHz for Au+Au",
0080     "4" => "1MHz for pp 100us streaming",
0081     "5" => "2MHz for pp 20us streaming",
0082     ">5" => "pileup rate in kHz"
0083     );
0084 
0085 my $nEvents;
0086 my $start_segment;
0087 my $last_segment;
0088 my $randomize;
0089 my $prodtype;
0090 my $runnumber;
0091 my $verbose;
0092 my $nopileup;
0093 my $nobkgpileup;
0094 my $embed;
0095 my $pileup = 1;
0096 my $particle;
0097 my $pmin;
0098 my $pmax;
0099 my $production;
0100 my $momentum;
0101 # that should teach me a lesson to not give a flag an optional string value
0102 # just using embed:s leads to the next ARGV to be used as argument, even if it
0103 # is the next option. Sadly getopt swallows the - so parsing this becomes
0104 # quickly a nightmare, The only solution I see is to read the ARGV's - check for
0105 # the argument in question with a string compare (=~/em/) and then have a look
0106 # at the next argument (if it exists) and check if is is another option (=~/-/)
0107 # and if so use "auau" as default for $embed and push the modified option
0108 # into the new command line ARGV. It defaults to auau if -emb is set but
0109 # neither pau nor auau is given
0110 my @newargs = ();
0111 my $iarg = 0;
0112 foreach my $argument (@ARGV)
0113 {
0114     if (substr($argument,1,2) eq "em")
0115     {
0116     my $firstchar = substr($ARGV[$iarg+1],0,1);
0117     if (! exists $ARGV[$iarg+1] || substr($ARGV[$iarg+1],0,1) eq "-")
0118     {
0119         push(@newargs, $argument);
0120         push(@newargs,"auau");
0121     }
0122     else
0123     {
0124         push(@newargs, $argument);
0125         if ($ARGV[$iarg+1] ne "pau" && $ARGV[$iarg+1] ne "auau" && $ARGV[$iarg+1] ne "central")
0126         {
0127         push(@newargs,"auau");
0128         }
0129     }
0130     }
0131     else
0132     {
0133     push(@newargs,$argument);
0134     }
0135     $iarg++;
0136 }
0137 @ARGV=@newargs;
0138 GetOptions('embed:s' => \$embed, 'l:i' => \$last_segment, 'momentum:s' => \$momentum, 'n:i' => \$nEvents, "nobkgpileup" => \$nobkgpileup, "nopileup" => \$nopileup, "particle:s" => \$particle, 'pileup:i' => \$pileup, "pmin:i" => \$pmin, "pmax:i"=>\$pmax, "production:s"=>\$production, 'rand' => \$randomize, 'run:i' => \$runnumber, 's:i' => \$start_segment, 'type:i' =>\$prodtype, "verbose" =>\$verbose);
0139 my $filenamestring;
0140 my %filetypes = ();
0141 my %notlike = ();
0142 
0143 my $AuAu_pileupstring;
0144 my $pp_pileupstring;
0145 my $pAu_pileupstring;
0146 my $pileupstring;
0147 
0148 if (! defined $runnumber && $#newargs >= 0)
0149 {
0150     print "\nyou need to give a runnumber with -run <runnumber>\n";
0151     print_runs();
0152     exit(1);
0153 }
0154 if (defined $embed && defined $nopileup)
0155 {
0156     print "--embed and --nopileup flags do not work together, it does not make sense\n";
0157     exit(1);
0158 }
0159 if (!defined $embed && defined $nobkgpileup)
0160 {
0161     print "--nobkgpileup flag only valid for embedding (use also --embed)\n";
0162     exit(1);
0163 }
0164 my $pAu_bkgpileup = sprintf("_bkg_0_20fm");
0165 my $AuAu_bkgpileup = sprintf("_bkg_0_10fm");
0166 if ($pileup == 1)
0167 {
0168     $AuAu_pileupstring = sprintf("_50kHz%s",$AuAu_bkgpileup);
0169     $pp_pileupstring = sprintf("_3MHz");
0170     $pAu_pileupstring = sprintf("_500kHz%s",$pAu_bkgpileup);
0171 }
0172 elsif ($pileup == 2)
0173 {
0174     $AuAu_pileupstring = sprintf("_25kHz%s",$AuAu_bkgpileup);
0175 }
0176 elsif ($pileup == 3)
0177 {
0178     $AuAu_pileupstring = sprintf("_10kHz%s",$AuAu_bkgpileup);
0179 }
0180 elsif ($pileup == 4)
0181 {
0182     $pp_pileupstring = sprintf("_1MHz");
0183 }
0184 elsif ($pileup == 5)
0185 {
0186     $pp_pileupstring = sprintf("_2MHz");
0187 }
0188 else
0189 {
0190     $pp_pileupstring = sprintf("_%dkHz",$pileup);
0191     $AuAu_pileupstring = sprintf("_%dkHz%s",$AuAu_bkgpileup);
0192 }
0193 if (defined $nobkgpileup)
0194 {
0195     $pp_pileupstring = sprintf("");
0196     $AuAu_pileupstring = sprintf("");
0197 }
0198 
0199 my $embedok = 0;
0200 
0201 if (defined $prodtype)
0202 {
0203     if ($prodtype == 1)
0204     {
0205         die "This dataset has been deleted\n";
0206     &commonfiletypes();
0207     }
0208     elsif ($prodtype == 2)
0209     {
0210         die "Dataset $prodtype has been deleted\n";
0211     &commonfiletypes();
0212     }
0213     elsif ($prodtype == 3)
0214     {
0215     $filenamestring = "pythia8_pp_mb";
0216     if (! defined $nopileup)
0217     {
0218         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0219     }
0220         $pileupstring = $pp_pileupstring;
0221     &commonfiletypes();
0222     }
0223     elsif ($prodtype == 4)
0224     {
0225     if (defined $nopileup)
0226     {
0227         $filenamestring = sprintf("sHijing_0_20fm");
0228     }
0229     else
0230     {
0231         $filenamestring = sprintf("sHijing_0_20fm%s",$AuAu_pileupstring);
0232     }
0233         $notlike{$filenamestring} = ["pythia8" ,"single", "special"];
0234         $pileupstring = $AuAu_pileupstring;
0235     &commonfiletypes();
0236     }
0237     elsif ($prodtype == 5)
0238     {
0239     $filenamestring = sprintf("sHijing_0_12fm%s",$AuAu_pileupstring);
0240         die "Dataset $prodtype has been deleted\n";
0241     &commonfiletypes();
0242     }
0243     elsif ($prodtype == 6)
0244     {
0245     if (defined $nopileup)
0246     {
0247         $filenamestring = sprintf("sHijing_0_488fm");
0248     }
0249     else
0250     {
0251       $filenamestring = sprintf("sHijing_0_488fm%s",$AuAu_pileupstring);
0252     }
0253         $notlike{$filenamestring} = ["pythia8" ,"single", "special"];
0254         $pileupstring = $AuAu_pileupstring;
0255     &commonfiletypes();
0256     }
0257     elsif ($prodtype == 7)
0258     {
0259     $filenamestring = "pythia8_Charm";
0260     if (! defined $nopileup)
0261     {
0262         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0263     }
0264         $pileupstring = $pp_pileupstring;
0265     &commonfiletypes();
0266     }
0267     elsif ($prodtype == 8)
0268     {
0269     $filenamestring = "pythia8_Bottom";
0270     if (! defined $nopileup)
0271     {
0272         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0273     }
0274         $pileupstring = $pp_pileupstring;
0275     &commonfiletypes();
0276     }
0277     elsif ($prodtype == 9)
0278     {
0279     $filenamestring = "pythia8_CharmD0";
0280     if (! defined $nopileup)
0281     {
0282         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0283     }
0284         $pileupstring = $pp_pileupstring;
0285     &commonfiletypes();
0286     }
0287     elsif ($prodtype == 10)
0288     {
0289     $filenamestring = "pythia8_BottomD0";
0290     if (! defined $nopileup)
0291     {
0292         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0293     }
0294         $pileupstring = $pp_pileupstring;
0295     &commonfiletypes();
0296     }
0297     elsif ($prodtype == 11)
0298     {
0299         $embedok = 1;
0300     $filenamestring = "pythia8_Jet30";
0301     if (! defined $nopileup)
0302     {
0303         if (defined $embed)
0304         {
0305         if ($embed eq "pau")
0306         {
0307             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0308         }
0309         elsif ($embed eq "central")
0310         {
0311             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0312         }
0313         else
0314         {
0315             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0316         }
0317         }
0318         else
0319         {
0320         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0321         }
0322     }
0323         $pileupstring = $pp_pileupstring;
0324     &commonfiletypes();
0325     }
0326     elsif ($prodtype == 12)
0327     {
0328         $embedok = 1;
0329     $filenamestring = "pythia8_Jet10";
0330     if (! defined $nopileup)
0331     {
0332         if (defined $embed)
0333         {
0334         if ($embed eq "pau")
0335         {
0336             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0337         }
0338         elsif ($embed eq "central")
0339         {
0340             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0341         }
0342         else
0343         {
0344             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0345         }
0346         }
0347         else
0348         {
0349         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0350         }
0351     }
0352         $pileupstring = $pp_pileupstring;
0353     &commonfiletypes();
0354     }
0355     elsif ($prodtype == 13)
0356     {
0357         $embedok = 1;
0358     $filenamestring = "pythia8_PhotonJet";
0359     if (! defined $nopileup)
0360     {
0361         if (defined $embed)
0362         {
0363         if ($embed eq "pau")
0364         {
0365             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0366         }
0367         elsif ($embed eq "central")
0368         {
0369             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0370         }
0371         else
0372         {
0373             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0374         }
0375         }
0376         else
0377         {
0378         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0379         }
0380     }
0381         $pileupstring = $pp_pileupstring;
0382     &commonfiletypes();
0383     }
0384     elsif ($prodtype == 14)
0385     {
0386         $embedok = 1;
0387         $nopileup = 1;
0388         my $bad = 0;
0389     $filenamestring = "single";
0390     if (!defined $particle)
0391     {
0392         print "-particle: G4 particle name needs to be set for single particle sims\n";
0393         $bad = 1;
0394     }
0395     if ($bad > 0)
0396     {
0397             print "\nExisting single particle sims, use:\n";
0398             print_single_types();
0399         exit(1);
0400     }
0401     if (defined $pmin && defined $pmax)
0402     {
0403         if (defined $momentum)
0404         {
0405         $filenamestring = sprintf("%s_%s_%s_%d_%dMeV",$filenamestring, $particle, $momentum, $pmin, $pmax);
0406         }
0407         else
0408         {
0409         $filenamestring = sprintf("%s_%s_%d_%dMeV",$filenamestring, $particle, $pmin, $pmax);
0410         }
0411 
0412         if (defined $embed)
0413         {
0414         if ($embed eq "pau")
0415         {
0416             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0417         }
0418         else
0419         {
0420             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0421         }
0422         }
0423     }
0424     else
0425     {
0426         if (defined $embed)
0427         {
0428         if ($embed eq "pau")
0429         {
0430             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0431         }
0432         else
0433         {
0434             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0435         }
0436         }
0437         else
0438         {
0439         $filenamestring = sprintf("%s_%s",$filenamestring, $particle, $pmin, $pmax);
0440         }
0441     }
0442     &commonfiletypes();
0443     }
0444     elsif ($prodtype == 15)
0445     {
0446         $nopileup = 1;
0447         my $bad = 0;
0448     $filenamestring = "special";
0449     if (! defined $production)
0450     {
0451         $bad = 1;
0452     }
0453     if ($bad > 0)
0454     {
0455             print "\nExisting special sims, use:\n";
0456             print_special_types();
0457         exit(1);
0458     }
0459     $filenamestring = sprintf("%s_%s",$filenamestring, $production);
0460     &commonfiletypes();
0461     }
0462     elsif ($prodtype == 16)
0463     {
0464     $filenamestring = "pythia8_JetD0";
0465     if (! defined $nopileup)
0466     {
0467         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0468     }
0469         $pileupstring = $pp_pileupstring;
0470     &commonfiletypes();
0471     }
0472     elsif ($prodtype == 17)
0473     {
0474     $filenamestring = "pythia8_CharmD0piKJet5";
0475     if (! defined $nopileup)
0476     {
0477         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0478     }
0479         $pileupstring = $pp_pileupstring;
0480     &commonfiletypes();
0481     }
0482     elsif ($prodtype == 18)
0483     {
0484     $filenamestring = "pythia8_CharmD0piKJet12";
0485     if (! defined $nopileup)
0486     {
0487         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0488     }
0489         $pileupstring = $pp_pileupstring;
0490     &commonfiletypes();
0491     }
0492     elsif ($prodtype == 19)
0493     {
0494         $embedok = 1;
0495     $filenamestring = "pythia8_Jet40";
0496     if (! defined $nopileup)
0497     {
0498         if (defined $embed)
0499         {
0500         if ($embed eq "pau")
0501         {
0502             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0503         }
0504         elsif ($embed eq "central")
0505         {
0506             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0507         }
0508         else
0509         {
0510             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0511         }
0512         }
0513         else
0514         {
0515         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0516         }
0517     }
0518         $pileupstring = $pp_pileupstring;
0519     &commonfiletypes();
0520     }
0521     elsif ($prodtype == 20)
0522     {
0523     if (defined $nopileup)
0524     {
0525         $filenamestring = sprintf("sHijing_pAu_0_10fm");
0526     }
0527     else
0528     {
0529         $filenamestring = sprintf("sHijing_pAu_0_10fm%s",$pAu_pileupstring);
0530     }
0531         $notlike{$filenamestring} = ["pythia8" ,"single", "special"];
0532         $pileupstring = $pAu_pileupstring;
0533     &commonfiletypes();
0534     }
0535     elsif ($prodtype == 21)
0536     {
0537         $embedok = 1;
0538     $filenamestring = "pythia8_Jet20";
0539     if (! defined $nopileup)
0540     {
0541         if (defined $embed)
0542         {
0543         if ($embed eq "pau")
0544         {
0545             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0546         }
0547         elsif ($embed eq "central")
0548         {
0549             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0550         }
0551         else
0552         {
0553             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0554         }
0555         }
0556         else
0557         {
0558         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0559         }
0560     }
0561         $pileupstring = $pp_pileupstring;
0562     &commonfiletypes();
0563     }
0564     elsif ($prodtype == 22)
0565     {
0566     $filenamestring = "cosmic_magnet_on";
0567         $filenamestring = sprintf("%s",$filenamestring);
0568     $nopileup = 1; # it is no pileup only - no need to require it
0569     &commonfiletypes();
0570     }
0571     elsif ($prodtype == 23)
0572     {
0573     $filenamestring = "cosmic_magnet_off";
0574         $filenamestring = sprintf("%s",$filenamestring);
0575     $nopileup = 1; # it is no pileup only - no need to require it
0576     &commonfiletypes();
0577     }
0578     elsif ($prodtype == 24)
0579     {
0580     if (defined $nopileup)
0581     {
0582         $filenamestring = sprintf("ampt_0_20fm");
0583     }
0584     else
0585     {
0586         $filenamestring = sprintf("ampt_0_20fm%s",$AuAu_pileupstring);
0587     }
0588         $notlike{$filenamestring} = ["pythia8" ,"single", "special"];
0589         $pileupstring = $AuAu_pileupstring;
0590     &commonfiletypes();
0591     }
0592     elsif ($prodtype == 25)
0593     {
0594     if (defined $nopileup)
0595     {
0596         $filenamestring = sprintf("epos_0_153fm");
0597     }
0598     else
0599     {
0600         $filenamestring = sprintf("epos_0_153fm_%s_bkg_0_153fm",$AuAu_pileupstring);
0601     }
0602         $notlike{$filenamestring} = ["pythia8" ,"single", "special"];
0603         $pileupstring = $pAu_pileupstring;
0604     &commonfiletypes();
0605     }
0606     elsif ($prodtype == 26)
0607     {
0608         $embedok = 1;
0609     $filenamestring = "pythia8_Detroit";
0610     if (! defined $nopileup)
0611     {
0612         if (defined $embed)
0613         {
0614         if ($embed eq "pau")
0615         {
0616             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0617         }
0618         elsif ($embed eq "central")
0619         {
0620             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0621         }
0622         else
0623         {
0624             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0625         }
0626         }
0627         else
0628         {
0629         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0630         }
0631     }
0632         $pileupstring = $pp_pileupstring;
0633     &commonfiletypes();
0634     }
0635     elsif ($prodtype == 27)
0636     {
0637         $embedok = 1;
0638     $filenamestring = "pythia8_PhotonJet5";
0639     if (! defined $nopileup)
0640     {
0641         if (defined $embed)
0642         {
0643         if ($embed eq "pau")
0644         {
0645             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0646         }
0647         elsif ($embed eq "central")
0648         {
0649             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0650         }
0651         else
0652         {
0653             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0654         }
0655         }
0656         else
0657         {
0658         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0659         }
0660     }
0661         $pileupstring = $pp_pileupstring;
0662     &commonfiletypes();
0663     }
0664     elsif ($prodtype == 28)
0665     {
0666         $embedok = 1;
0667     $filenamestring = "pythia8_PhotonJet10";
0668     if (! defined $nopileup)
0669     {
0670         if (defined $embed)
0671         {
0672         if ($embed eq "pau")
0673         {
0674             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0675         }
0676         elsif ($embed eq "central")
0677         {
0678             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0679         }
0680         else
0681         {
0682             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0683         }
0684         }
0685         else
0686         {
0687         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0688         }
0689     }
0690         $pileupstring = $pp_pileupstring;
0691     &commonfiletypes();
0692     }
0693     elsif ($prodtype == 29)
0694     {
0695         $embedok = 1;
0696     $filenamestring = "pythia8_PhotonJet20";
0697     if (! defined $nopileup)
0698     {
0699         if (defined $embed)
0700         {
0701         if ($embed eq "pau")
0702         {
0703             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0704         }
0705         elsif ($embed eq "central")
0706         {
0707             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0708         }
0709         else
0710         {
0711             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0712         }
0713         }
0714         else
0715         {
0716         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0717         }
0718     }
0719         $pileupstring = $pp_pileupstring;
0720     &commonfiletypes();
0721     }
0722     elsif ($prodtype == 30)
0723     {
0724         $embedok = 1;
0725     $filenamestring = "Herwig_MB";
0726     if (! defined $nopileup)
0727     {
0728         if (defined $embed)
0729         {
0730         if ($embed eq "pau")
0731         {
0732             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0733         }
0734         elsif ($embed eq "central")
0735         {
0736             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0737         }
0738         else
0739         {
0740             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0741         }
0742         }
0743         else
0744         {
0745         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0746         }
0747     }
0748         $pileupstring = $pp_pileupstring;
0749     &commonfiletypes();
0750     }
0751     elsif ($prodtype == 31)
0752     {
0753         $embedok = 1;
0754     $filenamestring = "Herwig_Jet10";
0755     if (! defined $nopileup)
0756     {
0757         if (defined $embed)
0758         {
0759         if ($embed eq "pau")
0760         {
0761             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0762         }
0763         elsif ($embed eq "central")
0764         {
0765             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0766         }
0767         else
0768         {
0769             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0770         }
0771         }
0772         else
0773         {
0774         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0775         }
0776     }
0777         $pileupstring = $pp_pileupstring;
0778     &commonfiletypes();
0779     }
0780     elsif ($prodtype == 32)
0781     {
0782         $embedok = 1;
0783     $filenamestring = "Herwig_Jet30";
0784     if (! defined $nopileup)
0785     {
0786         if (defined $embed)
0787         {
0788         if ($embed eq "pau")
0789         {
0790             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0791         }
0792         elsif ($embed eq "central")
0793         {
0794             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0795         }
0796         else
0797         {
0798             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0799         }
0800         }
0801         else
0802         {
0803         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0804         }
0805     }
0806         $pileupstring = $pp_pileupstring;
0807     &commonfiletypes();
0808     }
0809     elsif ($prodtype == 33)
0810     {
0811         $embedok = 1;
0812     $filenamestring = "pythia8_Jet15";
0813     if (! defined $nopileup)
0814     {
0815         if (defined $embed)
0816         {
0817         if ($embed eq "pau")
0818         {
0819             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0820         }
0821         elsif ($embed eq "central")
0822         {
0823             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0824         }
0825         else
0826         {
0827             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0828         }
0829         }
0830         else
0831         {
0832         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0833         }
0834     }
0835         $pileupstring = $pp_pileupstring;
0836     &commonfiletypes();
0837     }
0838     elsif ($prodtype == 34)
0839     {
0840         $embedok = 1;
0841     $filenamestring = "pythia8_Jet50";
0842     if (! defined $nopileup)
0843     {
0844         if (defined $embed)
0845         {
0846         if ($embed eq "pau")
0847         {
0848             $filenamestring = sprintf("%s_sHijing_pAu_0_10fm%s",$filenamestring, $pAu_pileupstring);
0849         }
0850         elsif ($embed eq "central")
0851         {
0852             $filenamestring = sprintf("%s_sHijing_0_488fm%s",$filenamestring, $AuAu_pileupstring);
0853         }
0854         else
0855         {
0856             $filenamestring = sprintf("%s_sHijing_0_20fm%s",$filenamestring, $AuAu_pileupstring);
0857         }
0858         }
0859         else
0860         {
0861         $filenamestring = sprintf("%s%s",$filenamestring,$pp_pileupstring);
0862         }
0863     }
0864         $pileupstring = $pp_pileupstring;
0865     &commonfiletypes();
0866     }
0867 
0868     else
0869     {
0870     print "no production type $prodtype\n";
0871     exit(1);
0872     }
0873     &fill_other_types();
0874 }
0875 
0876 if (defined $embed && ! $embedok)
0877 {
0878     print "Embedding not implemented for type $prodtype\n";
0879     exit(1);
0880 }
0881 
0882 my $filenamestring_with_runnumber = sprintf("%s\-%010d-",$filenamestring,$runnumber);
0883 if ($#ARGV < 0)
0884 {
0885     if (! defined $prodtype)
0886     {
0887     print "usage: CreateFileLists.pl -type <production type> <filetypes>\n";
0888     print "parameters:\n";
0889     print "-embed : pp embedded into MB AuAu hijing (only for pp types)\n";
0890     print "  -embed pau : embedded into pAu (only for pp types)\n";
0891     print "  -embed central : embedded into central AuAu\n";
0892     print "-l     : last segment\n";
0893     print "-n     : <number of events>\n";
0894     print "-nopileup : without pileup\n";
0895     print "-rand  : randomize segments used\n";
0896     print "-run   : runnumber (mandatory, no default anymore)\n";
0897     print "-s     : starting segment (remember first segment is 0)\n";
0898     print "\n-type  : production type\n";
0899     foreach my $pd (sort { $a <=> $b } keys %proddesc)
0900     {
0901         print "    $pd : $proddesc{$pd}\n";
0902     }
0903     print "\n-pileup : pileup rate selection (default = $pileup)\n";
0904     foreach my $pd (sort { $a <=> $b } keys %pileupdesc)
0905     {
0906         print "    $pd : $pileupdesc{$pd}\n";
0907     }
0908     print "\n-nobkgpileup : no pileup of background event (use with -embed)\n";
0909         print "\n Single particle mandatory options:\n";
0910         print "-particle : G4 particle name\n";
0911         print "-mom : (optional) p or pt\n";
0912         print "-pmin : minimum momentum (in MeV/c)\n";
0913         print "-pmax : maximum momentum (in MeV/c)\n";
0914 
0915         print "\n Special production mandatory options:\n";
0916         print "-production : production name\n";
0917 
0918     print "\navailable file types (choose at least one, --> means: written to):\n";
0919     foreach my $tp (sort keys %dsttype)
0920     {
0921         if (! exists $exclude_these{$tp})
0922         {
0923         print "$tp  --> $dsttype{$tp}\n";
0924         }
0925     }
0926     }
0927     else
0928     {
0929     print "\navailable file types for -type $prodtype: $proddesc{$prodtype}:\n";
0930     foreach my $tp (sort keys %filetypes)
0931     {
0932         print "\t$tp : $filetypes{$tp}\n";
0933     }
0934     }
0935 
0936     exit(0);
0937 }
0938 
0939 if (defined $randomize && ! defined $nEvents)
0940 {
0941     print "randomizing segments only if number of events is selected\n";
0942     exit(0);
0943 }
0944 
0945 if (! defined $prodtype )
0946 {
0947     print "need to give production type\n";
0948     print "-type : production type\n";
0949     foreach my $pd (sort keys %proddesc)
0950     {
0951     print "    $pd : $proddesc{$pd}\n";
0952     }
0953     exit(0);
0954 }
0955 if (! exists $proddesc{$prodtype})
0956 {
0957     print  "invalid production type $prodtype, valid values\n";
0958     print "-type : production type\n";
0959     foreach my $pd (sort keys %proddesc)
0960     {
0961     print "    $pd : $proddesc{$pd}\n";
0962     }
0963     exit(0);
0964 }
0965 
0966 #check dst types
0967 my %req_types = ();
0968 
0969 # hash of {dsttype} containing hash of segment,filename
0970 my %allfilehash = ();
0971 
0972 my %allevthash = ();
0973 
0974 my %nocombine = ();
0975 &fill_nocombine_files;
0976 
0977 while($#ARGV >= 0)
0978 {
0979     if (! exists $dsttype{$ARGV[0]})
0980     {
0981     print "dst type $ARGV[0] does not exist\n";
0982     print "\navailable types:\n";
0983     foreach my $tp (sort keys %dsttype)
0984     {
0985         print "$tp\n";
0986     }
0987     exit(1);
0988     }
0989     if (exists $req_types{$ARGV[0]})
0990     {
0991     print "please no duplicate file types ($ARGV[0])\n";
0992     exit(1);
0993     }
0994 
0995     if (exists $nocombine{$ARGV[0]})
0996     {
0997     if ($#ARGV >= 1 || keys %req_types > 0)
0998     {
0999         print "File type $ARGV[0] cannot be combined with other files\n";
1000         exit(1);
1001     }
1002     }
1003     $req_types{$ARGV[0]} = 1;
1004     $allfilehash{$ARGV[0]} = ();
1005     $allevthash{$ARGV[0]} = ();
1006     shift (@ARGV);
1007 
1008 }
1009 print "This Can Take a While (10 minutes depending on the amount of events and the number of file types you want)\n";
1010 my $conds = sprintf("dsttype = ? and filename like \'\%%%s\%\'",$filenamestring_with_runnumber);
1011 
1012 if (exists $notlike{$filenamestring})
1013 {
1014     my $ref = $notlike{$filenamestring};
1015     foreach my $item  (@$ref)
1016     {
1017     $conds = sprintf("%s and filename not like  \'\%%%s\%\'",$conds,$item);
1018     }
1019 }
1020 if (defined $start_segment)
1021 {
1022     $conds = sprintf("%s and segment >= %d",$conds,$start_segment);
1023 }
1024 if (defined $last_segment)
1025 {
1026     if (defined $start_segment)
1027     {
1028     if ($last_segment < $start_segment)
1029     {
1030         print "last segment: (-l $last_segment) smaller than start segment: (-s $start_segment), I will try but you will not get anything\n";
1031     }
1032     }
1033     $conds = sprintf("%s and segment <= %d",$conds,$last_segment);
1034 }
1035 my $getfilesql = sprintf("select filename,segment,events from datasets where %s order by segment",$conds);
1036 #my $getfilesql = sprintf("select filename,segment,events from datasets where %s ",$conds);
1037 
1038 my %getfiles = ();
1039 foreach  my $tp (keys %req_types)
1040 {
1041     if ($tp eq "G4Hits" || $tp eq "G4HitsOld")
1042     {
1043     if (defined $embed)
1044     {
1045         print "Selecting G4Hits with -embed is not supported (and does not make sense)\n";
1046         exit(1);
1047     }
1048     my $newfilenamestring;
1049     if (defined $nopileup) # for no pileup we have the string already (G4Hits are nopileup)
1050     {
1051         my @sp1 = split(/-/,$filenamestring_with_runnumber);
1052         $newfilenamestring = $filenamestring_with_runnumber;
1053     }
1054     else
1055     {
1056         my $splitstring = sprintf("_%s",$pileupstring);
1057             my @sp2 = split(/$splitstring/,$filenamestring_with_runnumber);
1058         $newfilenamestring = sprintf("%s-%010d-",$sp2[0],$runnumber);
1059     }
1060     my $newgetfilesql = $getfilesql;
1061     $newgetfilesql =~ s/$filenamestring_with_runnumber/$newfilenamestring/;
1062     $getfiles{"G4Hits"} = $dbh->prepare($newgetfilesql);
1063     $getfiles{"G4HitsOld"} = $dbh->prepare($newgetfilesql);
1064     if (defined $verbose)
1065     {
1066         print "sql (newgetfilesql): $newgetfilesql\n";
1067     }
1068     }
1069     else
1070     {
1071     $getfiles{$tp} = $dbh->prepare($getfilesql);
1072     if (defined $verbose)
1073     {
1074         print "sql (getfilesql): $getfilesql\n";
1075     }
1076     }
1077 }
1078 #die;
1079 # here we fill the big hash with all segments/files for all requested filetypes
1080 if (defined $verbose)
1081 {
1082     print "fetching files from DB done, hashing all of them\n";
1083 }
1084 foreach my $tp (sort keys %req_types)
1085 {
1086     my %dsthash = ();
1087     my %evthash = ();
1088     $getfiles{$tp}->execute($tp);
1089     if ($getfiles{$tp}->rows == 0)
1090     {
1091     print "no files for type $tp\n";
1092     exit(0);
1093     }
1094     while (my @res = $getfiles{$tp}->fetchrow_array())
1095     {
1096     my $hashkey = sprintf("%05d",$res[1]);
1097     $dsthash{$hashkey} = $res[0];
1098     $evthash{$res[0]} = $res[2];
1099     }
1100     $allfilehash{$tp} = \%dsthash;
1101     $allevthash{$tp} = \%evthash;
1102 }
1103 
1104 my $entries = 200000000; # given that we have 200k files max, this value is always higher
1105 my $lowtype;
1106 # here we find the dst type with the smallest number of entries (segments)
1107 # so we do not loop too much when finding matches for the other types
1108 if (defined $verbose)
1109 {
1110     print "hashing done, finding hash with lowest number of entries\n";
1111 }
1112 foreach my $tp (sort { $a <=> $b } keys %allfilehash)
1113 {
1114     if ($entries > keys %{$allfilehash{$tp}})
1115     {
1116     $entries = keys %{$allfilehash{$tp}};
1117     $lowtype = $tp;
1118     }
1119 }
1120 # here $lowtype is the dst type with the smallest number of segments
1121 #print "lowest entries: $entries, type: $lowtype\n";
1122 #print Dumper(%allevthash);
1123 if (defined $verbose)
1124 {
1125     print "matching hashes\n";
1126 }
1127 
1128 my @segarray = ();
1129 foreach my $seg (sort { $a <=> $b } keys %{$allfilehash{$lowtype}})
1130 {
1131     foreach my $tp (sort { $a <=> $b } keys %allfilehash)
1132     {
1133     if ($tp eq $lowtype)
1134     {
1135         next;
1136     }
1137     if (! exists  $allfilehash{$tp}{$seg})
1138     {
1139         last;
1140     }
1141     }
1142     push(@segarray,$seg);
1143 }
1144 # in segarray we have the common segments of all files now
1145 
1146 # remove segments from array when number of events is reached
1147 # randomize segments when -r is set
1148 if (defined $nEvents)
1149 {
1150     if (defined $randomize)
1151     {
1152     @segarray = shuffle(@segarray);
1153     }
1154     my @tmparray = ();
1155     foreach my $seg (@segarray)
1156     {
1157     push(@tmparray,$seg);
1158     $nEvents -= $allevthash{$lowtype}{$allfilehash{$lowtype}{$seg}};
1159     if ($nEvents <= 0)
1160     {
1161         last;
1162     }
1163     }
1164     @segarray = @tmparray;
1165 }
1166 # sort list of segments and write to output file
1167 my $nSelectedEvents = 0;
1168 my %filesorted = ();
1169 foreach my $seg (@segarray)
1170 #foreach my $seg (sort { $a <=> $b } @segarray)
1171 {
1172     $nSelectedEvents += $allevthash{$lowtype}{$allfilehash{$lowtype}{$seg}};
1173 #   print "segment $seg is good\n";
1174 #    foreach my $tp (sort keys %allfilehash)
1175     foreach my $tp (keys %allfilehash)
1176     {
1177 #       print "using $allfilehash{$tp}{$seg}\n";
1178 #   my $printcmd = sprintf("echo %s >> %s",$allfilehash{$tp}{$seg},$dsttype{$tp});
1179     $filesorted{$dsttype{$tp}}{$allfilehash{$tp}{$seg}} = 1;
1180 #   print "$printcmd\n";
1181 #   system($printcmd);
1182     }
1183 
1184 }
1185 foreach my $listfile (keys %filesorted)
1186 {
1187     open(F3,">$listfile");
1188     foreach my $fil (sort keys %{$filesorted{$listfile}})
1189     {
1190     print F3 "$fil\n";
1191     }
1192     close(F3);
1193 }
1194 print "wrote the following list files containing >= $nSelectedEvents events:\n";
1195 foreach my $tp (sort { $a <=> $b } keys %allfilehash)
1196 {
1197     print "$dsttype{$tp}\n";
1198 }
1199 
1200 
1201 $getdsttypes->finish();
1202 foreach my $tp (keys %getfiles)
1203 {
1204     $getfiles{$tp}->finish();
1205 }
1206 $dbh->disconnect;
1207 
1208 sub commonfiletypes
1209 {
1210 # for no pileup pass(X) --> pass(X-1)
1211 # pass1
1212     $filetypes{"G4Hits"} = "G4 Hits";
1213 #    $filetypes{"G4HitsOld"} = "Old G4 Hits";
1214 # pass2
1215     $filetypes{"DST_BBC_G4HIT"} = "Pileup BBC (now MBD), EPD G4Hits";
1216     $filetypes{"DST_CALO_G4HIT"} = "Pileup Calorimeter G4Hits";
1217     $filetypes{"DST_TRKR_G4HIT"} = "Pileup Tracking Detector G4 Hits";
1218     $filetypes{"DST_TRUTH_G4HIT"} = "temporary Pileup Truth info, use DST_TRUTH";
1219 # pass3 mbdepd
1220     $filetypes{"DST_MBD_EPD"} = "Reconstructed Mbd, Epd";
1221 # pass3 calo
1222     $filetypes{"DST_CALO_CLUSTER"} = "Reconstructed Calorimeter Towers and Clusters";
1223 #pass3 trk
1224     $filetypes{"DST_TRKR_HIT"} = "TPC and Silicon Hits";
1225     $filetypes{"DST_TRUTH"} = "Truth Info (updated with Clusters)";
1226 #pass4 truth jets
1227     $filetypes{"DST_TRUTH_JET"} = "Truth Jets";
1228 #pass4 tracks
1229     $filetypes{"DST_TRKR_CLUSTER"} = "pass0 output: tpc clusters";
1230     $filetypes{"DST_TRACKSEEDS"} = "passA output: track seeds";
1231     $filetypes{"DST_TRACKS"} = "passC output: Reconstructed Tracks";
1232 #pass5 tracks/clusters
1233     $filetypes{"DST_GLOBAL"} = "Global Info (MBD, sEPD, Vertex)";
1234     $filetypes{"DST_TRUTH_RECO"} = "digested track truth info";
1235 }
1236 
1237 
1238 # here are filetypes which are ntuples or cannot be combined
1239 # with other files for any other reason
1240 sub fill_nocombine_files
1241 {
1242     $nocombine{"JET_EVAL_DST_HF_CHARM"} = 1;
1243     $nocombine{"JET_EVAL_DST_HF_BOTTOM"} = 1;
1244     $nocombine{"QA_DST_HF_CHARM"} = 1;
1245     $nocombine{"QA_DST_HF_BOTTOM"} = 1;
1246 }
1247 
1248 sub fill_other_types
1249 {
1250     my $sqlstring = sprintf("select distinct(dsttype) from datasets where filename like '%%%s%%'",$filenamestring);
1251     my $getalltypes = $dbh->prepare($sqlstring);
1252     $getalltypes->execute();
1253     while (my @res = $getalltypes->fetchrow_array())
1254     {
1255     if (! exists $filetypes{$res[0]})
1256     {
1257         $filetypes{$res[0]} = "No Description";
1258     }
1259     }
1260     $getalltypes->finish();
1261 }
1262 
1263 sub print_single_types
1264 {
1265     my $sqlstring = sprintf("select filename from datasets where runnumber = %d and filename like '%%_single_%%' and segment=0",$runnumber);
1266     my $getallfiles = $dbh->prepare($sqlstring);
1267     $getallfiles->execute();
1268     my $runsplit = sprintf("MeV-%010d",$runnumber);
1269     my $runsplit_embed = sprintf("_sHijing_0_20fm");
1270     my $runsplit_runnumber = sprintf("-%010d",$runnumber);
1271     my %types = ();
1272     my %dsts = ();
1273     while (my @res = $getallfiles->fetchrow_array())
1274     {
1275     my @sp1 = split(/_single_/,$res[0]);
1276         my @sp2;
1277         my $typeflag = "";
1278     if ($sp1[1] =~ /MeV/)
1279     {
1280         @sp2 = split(/$runsplit/,$sp1[1]);
1281     }
1282     if ($sp1[1] =~ /$runsplit_embed/)
1283     {
1284         @sp2 = split(/$runsplit_embed/,$sp1[1]);
1285             $typeflag = "-embed ";
1286     }
1287     else
1288     {
1289         @sp2 = split(/$runsplit_runnumber/,$sp1[1]);
1290     }
1291     $types{$sp2[0]} = $typeflag;
1292         $dsts{$sp1[0]} = 1;
1293     }
1294     $getallfiles->finish();
1295     foreach my $name (sort keys %types)
1296     {
1297     if ($name =~ /(\S+)\_(\d+)\_(\d+).*/ )
1298     {
1299         my $part = $1;
1300             my $mom;
1301             my $minp = $2;
1302             my $maxp = $3;
1303         if ($part =~ /(\S+)_(\S+)/)
1304         {
1305         $part = $1;
1306         $mom = $2;
1307         }
1308         if (defined $mom)
1309         {
1310         print "CreateFileList.pl -type 14 $types{$name} -run $runnumber -particle $part -mom $mom -pmin $minp -pmax $maxp\n";
1311         }
1312         else
1313             {
1314                 print "CreateFileList.pl -type 14 $types{$name} -run $runnumber -particle $part -pmin $minp -pmax $maxp\n";
1315             }
1316     }
1317         else
1318         {
1319             print "CreateFileList.pl -type 14 $types{$name} -run $runnumber -particle $name\n";
1320 
1321         }
1322     }
1323     print "\nDST types:\n";
1324     foreach my $name (sort keys %dsts)
1325     {
1326     print "$name\n";
1327     }
1328 }
1329 
1330 sub print_special_types
1331 {
1332     my $sqlstring = sprintf("select filename from datasets where runnumber = %d and filename like '%%_special_%%'",$runnumber);
1333     my $getallfiles = $dbh->prepare($sqlstring);
1334     $getallfiles->execute();
1335     my $runsplit = sprintf("-%010d",$runnumber);
1336     my %types = ();
1337     my %dsts = ();
1338     while (my @res = $getallfiles->fetchrow_array())
1339     {
1340     my @sp1 = split(/_special_/,$res[0]);
1341     my @sp2 = split(/$runsplit/,$sp1[1]);
1342     $types{$sp2[0]} = 1;
1343         $dsts{$sp1[0]} = 1;
1344     }
1345     $getallfiles->finish();
1346     foreach my $name (sort keys %types)
1347     {
1348         print "CreateFileList.pl -type 15 -production $name\n";
1349     }
1350     print "\nDST types:\n";
1351     foreach my $name (sort keys %dsts)
1352     {
1353         print "$name\n";
1354     }
1355 }
1356 
1357 sub print_runs
1358 {
1359     my $getrunnumbers = $dbh->prepare("select distinct(runnumber) from datasets where dataset = 'mdc2' order by runnumber");
1360     $getrunnumbers->execute();
1361     print "Available Runs (check our wiki for more details for each runnumber):\n";
1362     while(my @res = $getrunnumbers->fetchrow_array())
1363     {
1364     print "$res[0]\n";
1365     }
1366     print "NB: Not all DSTs are available for all runs\n";
1367     $getrunnumbers->finish();
1368 }