Kalanand's December 2012 Log

   November 2012   
December 2012
SuMoTuWeThFrSa
      1
2345678
9101112131415
16171819202122
23242526272829
3031     
   January 2013   

December 13th

aMC@NLO web page

http://amcatnlo.web.cern.ch/amcatnlo/

December 19th

Changing lepton species in an LHE file

We generated a large sample of WW (&rightarrow lνjj + 2 tag-jets) scattering events using Phantom event generator, but turns out that the generated lepton was always a muon. However, we need all three species of leptons. Phil Dudero wrote a perl script that will replace 2/3 of the events with one of the other lepton pairs. Here goes the script:
#!/usr/bin/perl

$count=0;
$ifilename="_phamom_gen1.dat";
print "$ifilename\n";
open(OUTP,">$ifilename") || die "problem opening $ifilename";
while(<>){
    $line=$_;
    if (/^ [ -]13/) {
        $count++;
        if ($count % 3 == 1) {
            $line =~ s/13/11/;
        } elsif ($count % 3 == 0) {
            $line =~ s/13/15/;
        }
    }
    if (/^ [ -]14/) {
        if ($count % 3 == 1) {
            $line =~ s/14/12/;
        } elsif ($count % 3 == 0) {
            $line =~ s/14/16/;
        }
    }
    print OUTP $line;

    if (/^\<\/LesHouchesEvents\>/) {
        if ($count % 20000==0) {
            $ifile=int($count/20000) + 1;
            $ifilename="_phamom_gen" . "$ifile" . ".dat";
            close(OUTP);
            if ($count < 500000) {
                print "$ifilename\n";
                open(OUTP,">$ifilename")  || die "problem opening $ifilename";
            }
        }
    }
}
The way you use it is you cat *all* 25 phamom.dat files at once through a pipe to this perl script. It rotates through the lepton flavors and writes 25 files of 20k events apiece just like the input files.

So save the text above to file "inclusive.pl", then
chmod +x inclusive.pl
and
cat phamom*.dat | ./inclusive.pl
Afterward you should have 25 files named "_phanom_gen1.dat", "_phamom_gen2.dat", etc.

Note that this procedure may scramble the events with respect to the filenames, depending on how your input files are named, since the correct lexical ordering for numbers 1 to 25 is 1,10,11,12,13,14,15,16,17,18,19,2,20,21,22,23,24,25,3,4,5,6,7,8,9, but the script writes 1,2,3,4,5,6,7,8,9,10, etc.

Altogether this will give you 166666 events of tau, and 166667 events each of mu and electron.

December 20th

Some CMSDAS/JTerm links

Home - Jets - short exercise
SWGuideCMSDataAnalysisSchoolJetAnalysis < CMS < TWiki
SWGuideCMSDataAnalysisSchoolJetResonances < CMS < TWiki
SWGuideCMSDataAnalysisSchoolJetAnalysis < CMS < TWiki
SWGuideCMSDataAnalysisSchool2012JetsLongExerciseDijetMassSpectrumInAssociationWithW < CMS < TWiki
CX - Files
WorkBookExercisesCMSDataAnalysisSchool < CMS < TWiki

Go to November's log


Last modified: Thu Dec 20 15:34:56 CST 2012