Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:16

0001 #!/bin/bash
0002 
0003 # This is going to be a script that performs a test suit over the 
0004 # AlpgenInterface package. Still in development.
0005 # Any questions, please contact Thiago Tomei (IFT-UNESP / SPRACE). 
0006 
0007 # Modify these defaults to suit your environment.
0008 ARCHITECTURE=$SCRAM_ARCH
0009 ALPGEN_PATH=$CMS_PATH/sw/$ARCHITECTURE/external/alpgen/213-cms
0010 ALPGEN_BIN_PATH=$ALPGEN_PATH/bin
0011 
0012 # Hi!
0013 echo "++++++++++++++++++++"
0014 echo "+ ALPGEN INTERFACE +"
0015 echo "++++++++++++++++++++"
0016 echo "" 
0017 echo "Starting basic sanity checks for Alpgen in CMSSW" 
0018 echo ""
0019 # See the available executables.
0020 echo "The Alpgen executables should be found in $ALPGEN_BIN_PATH"
0021 echo "Available executables in $ALPGEN_BIN_PATH:"
0022 ls $ALPGEN_BIN_PATH
0023 echo ""
0024 
0025 # Create an empty input file.
0026 if ls input.skel &> /dev/null
0027   then \rm input.skel
0028 fi
0029 touch input.skel
0030 
0031 # Some functions that we define for later use
0032 
0033 # A function to create the input file using a here document.
0034 create_input_file ()
0035 {
0036 # First, setup derived parameters.
0037 INPUTFILENAME=$LABEL.input
0038 STDOUTFILENAME=$LABEL.stdout
0039 if [[ "$ICKKW" -eq 1 ]]
0040 then 
0041   MATCHINGPYTHON=True
0042 else
0043   MATCHINGPYTHON=False
0044 fi
0045 ETCLUS=$(bc <<CalculationLimitString
0046 scale = 4
0047 var1=$ETMIN+5.0
0048 var2=1.2*$ETMIN
0049 if(var1 > var2) var1
0050 if(var1 <= var2) var2
0051 CalculationLimitString
0052 )
0053 
0054 # Now, write the file proper.
0055 cat > input.skel <<EOF
0056 $IMODE         ! imode
0057 $LABEL       ! label for files
0058 0         ! start with: 0=new grid, 1=previous warmup grid, 2=previous generation grid
0059 10000 2   ! Nevents/iteration,  N(warm-up iterations)
0060 100000    ! Nevents generated after warm-up
0061 *** The above 5 lines provide mandatory inputs for all processes
0062 *** (Comment lines are introduced by the three asteriscs)
0063 *** The lines below modify existing defaults for the hard process under study
0064 *** For a complete list of accessible parameters and their values,
0065 *** input 'print 1' (to display on the screen) or 'print 2' to write to file
0066 ih2 $IH2                ! nature of collisions: pp (1) or ppbar (-1)
0067 ebeam $ENERGY           ! beam energy in GeV
0068 ickkw $ICKKW              ! matching on (1) or off (0)
0069 etajmax 5            ! full rap range for jets
0070 njets   $NJETS            ! total number of jets
0071 ptjmin  $ETMIN         ! ptmin for jets
0072 drjmin  $DRMIN          ! minimum separation for jets
0073 EOF
0074 mv input.skel $INPUTFILENAME
0075 }
0076 
0077 # Function to run a test.
0078 run_test()
0079 {
0080 # Create the ALPGEN input file (default: W+1j at the Tevatron).
0081 IMODE=1
0082 create_input_file
0083 # Run it.
0084 echo "Testing: $ALPGEN_BIN_PATH/$ALPGEN_EXECUTABLE < $INPUTFILENAME (imode 1)..."
0085 $ALPGEN_BIN_PATH/$ALPGEN_EXECUTABLE < $INPUTFILENAME > $STDOUTFILENAME
0086 
0087 # Also for imode = 2.
0088 IMODE=2
0089 create_input_file
0090 echo "Testing: $ALPGEN_BIN_PATH/$ALPGEN_EXECUTABLE < $INPUTFILENAME (imode 2)..."
0091 echo "++++++++++" >> $STDOUTFILENAME
0092 $ALPGEN_BIN_PATH/$ALPGEN_EXECUTABLE < $INPUTFILENAME >> $STDOUTFILENAME
0093 
0094 # Create the cmsRun cfg.py file.
0095 cat test_TEMPLATE_cfg.py | sed "s/FILENAME/$LABEL/" | sed "s/MATCHING/$MATCHINGPYTHON/" \
0096 | sed "s/EXCLUSIVE/$EXCLUSIVE/" | sed "s/ETMIN/$ETCLUS/" | sed "s/DRMIN/$DRMIN/" > test_cfg.py
0097 # Run it.
0098 echo "Testing: cmsRun test_cfg.py (running both AlpgenSource and AlpgenProducer)..."
0099 cmsRun test_cfg.py > cmsRun.stdout 2> cmsRun.stderr
0100 }
0101 
0102 # Function to display the test results.
0103 display_test_results()
0104 {
0105 # The input file.
0106 echo -e "\nINPUT FILE: $INPUTFILENAME"
0107 cat $INPUTFILENAME
0108 # Beam content.
0109 if [[ "$IH2" -eq 1 ]]
0110 then BEAMCONTENT="proton proton" 
0111 elif [[ "$IH2" -eq -1  ]]
0112 then BEAMCONTENT="proton antiproton"
0113 else BEAMCONTENT="unkwown"
0114 fi
0115 echo -e "\nBeam content given as input: $BEAMCONTENT"
0116 echo "Beam content seem by CMSSW: "
0117 grep "PYTHIA will be initialized" cmsRun.stdout
0118 # Beam energy.
0119 echo -e "\nBeam energy given as input: $ENERGY GeV"
0120 echo -n "Beam energy seem by CMSSW: "
0121 grep energies cmsRun.stdout | awk '{print $3,$4}'
0122 # Jet parameters for matching.
0123 echo -e "\nJet parameters for matching"
0124 echo "Given as input: EXCLUSIVE = $EXCLUSIVE"
0125 echo "                ETCLUS = $ETCLUS"
0126 echo "                DRMIN = $DRMIN"
0127 echo "Seen by CMSSW:"
0128 grep IEXC cmsRun.stdout
0129 grep ETACLUS cmsRun.stdout
0130 echo "===================="
0131 echo
0132 }
0133 
0134 # Parameters for the ALPGEN input file.
0135 # Also, the exclusive / inclusive option.
0136 # Must be either True or False
0137 ALPGEN_EXECUTABLE=wjetgen
0138 LABEL=w1j
0139 IH2=-1
0140 ENERGY=980.0
0141 ICKKW=1
0142 NJETS=1
0143 ETMIN=20.0
0144 DRMIN=0.7
0145 EXCLUSIVE=True
0146 # Run test and display test results
0147 run_test
0148 display_test_results
0149 
0150 # Now you just change the values and run new tests.
0151 # Test Z+jets
0152 ALPGEN_EXECUTABLE=zjetgen
0153 LABEL=z0j
0154 IH2=1
0155 ENERGY=7000.0
0156 ICKKW=0
0157 NJETS=0
0158 ETMIN=20.0
0159 DRMIN=0.7
0160 EXCLUSIVE=False
0161 run_test
0162 display_test_results
0163 
0164 # Test bbbar+jets
0165 ALPGEN_EXECUTABLE=2Qgen
0166 LABEL=bbbar1j
0167 IH2=1
0168 ENERGY=5000.0
0169 ICKKW=1
0170 NJETS=1
0171 ETMIN=40.0
0172 DRMIN=0.7
0173 EXCLUSIVE=True
0174 run_test
0175 display_test_results