1 | #!/bin/bash
|
---|
2 | ################################################################################
|
---|
3 | #
|
---|
4 | # This code produces a set of validation plots for a given detector card.
|
---|
5 | #
|
---|
6 | # In order to run this you need to compile Delphes with Pythia8 first, see:
|
---|
7 | #
|
---|
8 | # https://cp3.irmp.ucl.ac.be/projects/delphes/wiki/WorkBook/Pythia8
|
---|
9 | #
|
---|
10 | # After you (re-)compiled Delphes with Pythia8 you are ready to go, execute from Delphes main dir:
|
---|
11 | #
|
---|
12 | # ./validation/validation.sh [detector_card] [number_of_events]
|
---|
13 | #
|
---|
14 | # e.g.
|
---|
15 | #
|
---|
16 | # ./validation/validation.sh cards/delphes_card_CMS.tcl 100000
|
---|
17 | #
|
---|
18 | # Note that the more events you specify, the more accurate the controls plots will be ...
|
---|
19 | # This said, 500k events should be ok for most cases.
|
---|
20 | #
|
---|
21 | ################################################################################
|
---|
22 |
|
---|
23 | EXPECTED_ARGS=2
|
---|
24 | E_BADARGS=65
|
---|
25 |
|
---|
26 | if [ $# -ne $EXPECTED_ARGS ]
|
---|
27 | then
|
---|
28 | echo "Usage: ./validation/validation.sh [detector_card] [number_of_events]"
|
---|
29 | echo "for instance: ./validation/validation.sh cards/delphes_card_CMS.tcl 10000"
|
---|
30 | exit $E_BADARGS
|
---|
31 | fi
|
---|
32 |
|
---|
33 | cardbase=$(basename $1)
|
---|
34 | carddir=$(dirname $1)
|
---|
35 | nEvents=$2
|
---|
36 | output=validation_${cardbase%.*}.root
|
---|
37 | mainoutputdir=report_${cardbase%.*}
|
---|
38 | outputrootdir=report_${cardbase%.*}/root
|
---|
39 | cardlabel=${cardbase%.*}
|
---|
40 | version=x.y.z
|
---|
41 | outpdf=$mainoutputdir/${output%.*}.pdf
|
---|
42 | cardsdir=validation/cards
|
---|
43 | samplesdir=validation/samples
|
---|
44 | validationcard=$carddir/validation_$cardbase
|
---|
45 |
|
---|
46 | mkdir -p $cardsdir
|
---|
47 | mkdir -p $samplesdir
|
---|
48 | mkdir -p $outputrootdir
|
---|
49 | mkdir -p $mainoutputdir/www/fig
|
---|
50 |
|
---|
51 | sed "s/delphes_card_CMS.tcl/$cardbase/g" cards/validation_card.tcl > $validationcard
|
---|
52 | sed -i "1i set MaxEvents $nEvents" $validationcard
|
---|
53 |
|
---|
54 | function runParticleGun {
|
---|
55 | name=$1
|
---|
56 | pid=$2
|
---|
57 | cmnd=$cardsdir/configParticleGun_$name.cmnd
|
---|
58 | outputroot=particleGun_${name}_${cardlabel}.root
|
---|
59 | sed "/Main:spareMode1/s|=[[:space:]]*[0-9]*|= $pid|; /Main:numberOfEvents/s|=[[:space:]]*[0-9]*|= $nEvents|" examples/Pythia8/configParticleGun.cmnd > $cmnd
|
---|
60 | ./DelphesPythia8 $validationcard $cmnd $outputrootdir/$outputroot
|
---|
61 |
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | function runJetsGun {
|
---|
66 | name=$1
|
---|
67 | pid=$2
|
---|
68 | lhe=$samplesdir/events_$name.lhe
|
---|
69 | cmnd=$cardsdir/configLHE_$name.cmnd
|
---|
70 | inputroot=$samplesdir/$name.root
|
---|
71 | outputroot=particleGun_${name}_${cardlabel}.root
|
---|
72 |
|
---|
73 | if [ ! -f $inputroot ]
|
---|
74 | then
|
---|
75 | python validation/flatGunLHEventProducer.py --pdg $pid --guntype pt --pmin 1 --pmax 50000 --etamin -6 --etamax 6 --nevts $nEvents --seed 1 --output $lhe --log --ecm 100000
|
---|
76 | gunzip $lhe.gz
|
---|
77 | sed "/Beams:LHEF/s|=[[:space:]].*|= $lhe|; /Main:numberOfEvents/s/=[[:space:]]*[0-9]*/= $nEvents/" examples/Pythia8/configLHE.cmnd > $cmnd
|
---|
78 |
|
---|
79 | ./DelphesPythia8 cards/gen_card.tcl $cmnd $inputroot
|
---|
80 | fi
|
---|
81 |
|
---|
82 | ./DelphesROOT $validationcard $outputrootdir/$outputroot $inputroot
|
---|
83 | }
|
---|
84 |
|
---|
85 |
|
---|
86 | runParticleGun pion 211 &
|
---|
87 | runParticleGun electron 11 &
|
---|
88 | runParticleGun muon 13 &
|
---|
89 | runParticleGun photon 22 &
|
---|
90 | runParticleGun neutron 2112 &
|
---|
91 | runParticleGun taujet 15 &
|
---|
92 | runJetsGun jet 1 &
|
---|
93 | runJetsGun bjet 5 &
|
---|
94 | runJetsGun cjet 4 &
|
---|
95 |
|
---|
96 | wait
|
---|
97 | echo all particle guns complete ...
|
---|
98 |
|
---|
99 | ./DelphesValidation $outputrootdir/particleGun_pion_$cardlabel.root $outputrootdir/particleGun_electron_$cardlabel.root $outputrootdir/particleGun_muon_$cardlabel.root $outputrootdir/particleGun_photon_$cardlabel.root $outputrootdir/particleGun_neutron_$cardlabel.root $outputrootdir/particleGun_jet_$cardlabel.root $outputrootdir/particleGun_bjet_$cardlabel.root $outputrootdir/particleGun_cjet_$cardlabel.root $outputrootdir/particleGun_taujet_$cardlabel.root $mainoutputdir/$output $version
|
---|
100 |
|
---|
101 |
|
---|
102 | # produce calo grid plots
|
---|
103 | ./CaloGrid $1 ECal
|
---|
104 | ./CaloGrid $1 HCal
|
---|
105 | gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=tmp/tmp1.pdf $outpdf ECal.pdf
|
---|
106 | gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$outpdf tmp/tmp1.pdf HCal.pdf
|
---|
107 | mv ECal.pdf $mainoutputdir/www/fig/img_ecal.pdf
|
---|
108 | mv ECal.png $mainoutputdir/www/fig/img_ecal.png
|
---|
109 | mv HCal.pdf $mainoutputdir/www/fig/img_hcal.pdf
|
---|
110 | mv HCal.png $mainoutputdir/www/fig/img_hcal.png
|
---|
111 |
|
---|