1 |
loizides |
1.1 |
#!/bin/bash
|
2 |
loizides |
1.6 |
# $Id: genrelval.sh,v 1.5 2008/07/31 12:06:02 loizides Exp $
|
3 |
loizides |
1.1 |
#
|
4 |
|
|
# genrelval.sh: Release validation script for generated particles
|
5 |
|
|
#
|
6 |
loizides |
1.6 |
# $Id: genrelval.sh,v 1.5 2008/07/31 12:06:02 loizides Exp $
|
7 |
loizides |
1.1 |
#_____________________________________________________________________________________________
|
8 |
|
|
#
|
9 |
|
|
# Variables to configure:
|
10 |
|
|
#
|
11 |
|
|
|
12 |
|
|
# Assume there is already a CMSSW environment
|
13 |
|
|
# and that our code is compiled.
|
14 |
|
|
|
15 |
|
|
# Set the directory where the generated sample and logfiles
|
16 |
|
|
# will be placed.
|
17 |
|
|
export MY_BASE_DIR=/tmp/relval.`date +%s`
|
18 |
|
|
|
19 |
|
|
#
|
20 |
|
|
# end variables to configure.
|
21 |
|
|
#_____________________________________________________________________________________________
|
22 |
|
|
##############################################################################################
|
23 |
|
|
##############################################################################################
|
24 |
loizides |
1.2 |
|
25 |
loizides |
1.1 |
function write_cfg {
|
26 |
|
|
echo '
|
27 |
|
|
process Gen =
|
28 |
|
|
{
|
29 |
|
|
# request 2 events for validation purpose
|
30 |
loizides |
1.3 |
untracked PSet maxEvents = { untracked int32 input = 5 }
|
31 |
loizides |
1.1 |
|
32 |
|
|
include "FWCore/MessageService/data/MessageLogger.cfi"
|
33 |
|
|
include "Configuration/StandardSequences/data/SimulationRandomNumberGeneratorSeeds.cff"
|
34 |
|
|
include "SimGeneral/HepPDTESSource/data/pythiapdt.cfi"
|
35 |
|
|
|
36 |
|
|
# verbose parameter set for pythia
|
37 |
|
|
source = PythiaSource
|
38 |
|
|
{
|
39 |
|
|
untracked int32 pythiaPylistVerbosity = 1
|
40 |
|
|
untracked bool pythiaHepMCVerbosity = false
|
41 |
loizides |
1.3 |
untracked int32 maxEventsToPrint = 5
|
42 |
loizides |
1.1 |
untracked double filterEfficiency = 1.
|
43 |
|
|
|
44 |
|
|
PSet PythiaParameters = {
|
45 |
|
|
vstring parameterSets = {
|
46 |
|
|
}
|
47 |
|
|
}
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
# load generator sequence (VtxSmeared is needed inside, missing dependence)
|
51 |
|
|
include "Configuration/StandardSequences/data/VtxSmearedBetafuncEarlyCollision.cff"
|
52 |
|
|
include "Configuration/StandardSequences/data/Generator.cff"
|
53 |
|
|
|
54 |
loizides |
1.5 |
# define the object service
|
55 |
|
|
service = ObjectService { }
|
56 |
|
|
|
57 |
loizides |
1.1 |
# define the tree service
|
58 |
|
|
service = TreeService {
|
59 |
|
|
untracked vstring fileNames = { "mit-gen" }
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
# customize the MIT filler
|
63 |
|
|
module MitTreeFiller = FillMitTree {
|
64 |
|
|
untracked bool defactive = false
|
65 |
loizides |
1.4 |
untracked PSet MCParticles = {
|
66 |
|
|
untracked bool active = true
|
67 |
|
|
untracked bool simActive = false
|
68 |
|
|
}
|
69 |
loizides |
1.1 |
}
|
70 |
|
|
|
71 |
|
|
# standard path of action of the module
|
72 |
|
|
path p0 = { pgen, MitTreeFiller }
|
73 |
|
|
|
74 |
|
|
# also make Edm output for the events we generate
|
75 |
|
|
include "Configuration/EventContent/data/EventContent.cff"
|
76 |
|
|
module FEVT = PoolOutputModule
|
77 |
|
|
{
|
78 |
|
|
using FEVTSIMEventContent
|
79 |
|
|
untracked string fileName = "edm-gen.root"
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
# output path for the Edm file
|
83 |
|
|
endpath outpath = { FEVT }
|
84 |
|
|
|
85 |
|
|
# schedule the various path
|
86 |
|
|
schedule = { p0, outpath }
|
87 |
|
|
}
|
88 |
|
|
'
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
function write_macro {
|
92 |
|
|
echo '
|
93 |
|
|
//--------------------------------------------------------------------------------------------------
|
94 |
loizides |
1.2 |
void runGenRelVal(const char *files = "mit-gen_000.root")
|
95 |
loizides |
1.1 |
{
|
96 |
|
|
gROOT->Macro("$CMSSW_BASE/src/MitAna/macros/setRootEnv.C+");
|
97 |
loizides |
1.3 |
gSystem->Load("$CMSSW_BASE/lib/slc4_ia32_gcc345/libMitAnaValidation.so");
|
98 |
loizides |
1.1 |
|
99 |
|
|
using namespace mithep;
|
100 |
|
|
gDebugMask = Debug::kAnalysis;
|
101 |
loizides |
1.3 |
gDebugLevel = 0;
|
102 |
loizides |
1.1 |
|
103 |
|
|
// set up the modules
|
104 |
loizides |
1.2 |
GenRelValMod *mod = new GenRelValMod;
|
105 |
loizides |
1.6 |
mod->SetWrite(1);
|
106 |
|
|
mod->SetPrint(0);
|
107 |
loizides |
1.1 |
|
108 |
|
|
// set up analysis
|
109 |
|
|
Analysis *ana = new Analysis;
|
110 |
|
|
ana->SetSuperModule(mod);
|
111 |
|
|
ana->AddFile(files);
|
112 |
|
|
|
113 |
|
|
// run the analysis after successful initialisation
|
114 |
loizides |
1.2 |
ana->Run(0);
|
115 |
loizides |
1.1 |
}
|
116 |
|
|
'
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
##############################################################################################
|
120 |
|
|
##############################################################################################
|
121 |
|
|
#
|
122 |
|
|
# Generate sample and fill tree
|
123 |
|
|
mkdir -p $MY_BASE_DIR/prod
|
124 |
|
|
cd $MY_BASE_DIR/prod
|
125 |
|
|
write_cfg > relval.cfg
|
126 |
|
|
cmsRun relval.cfg >pythia_raw.txt 2>/dev/null
|
127 |
|
|
if (( $? )) ; then
|
128 |
|
|
echo "Problem generating sample:" >&2
|
129 |
|
|
echo '' >&2
|
130 |
|
|
cat pythia_raw.txt >&2
|
131 |
loizides |
1.3 |
echo "Output left in $MY_BASE_DIR" >&2
|
132 |
loizides |
1.1 |
exit 1
|
133 |
|
|
fi
|
134 |
|
|
|
135 |
|
|
# Parse pythia output into something easier to compare with tree.
|
136 |
|
|
# The following outputs: index, pdgcode, px, py, pz, E
|
137 |
|
|
# with a particular spacing similar to pylist.
|
138 |
|
|
PYFILE=$MY_BASE_DIR/prod/pythia_parsed.txt
|
139 |
|
|
cat pythia_raw.txt | \
|
140 |
|
|
perl -ne 'if ($_ =~ /^(\s{4}\d{1})\s.{18}(.{5})(.{5})(.{36})/ or
|
141 |
|
|
$_ =~ /^(\s{3}\d{2})\s.{18}(.{5})(.{5})(.{36})/ or
|
142 |
|
|
$_ =~ /^(\s{2}\d{3})\s.{18}(.{5})(.{5})(.{36})/ or
|
143 |
|
|
$_ =~ /^(\s{1}\d{4})\s.{18}(.{5})(.{5})(.{36})/)
|
144 |
|
|
{ print "$1$2$3$4\n" ; }' > $PYFILE
|
145 |
|
|
|
146 |
loizides |
1.2 |
|
147 |
|
|
# write+run the validation macro:
|
148 |
loizides |
1.1 |
cd $MY_BASE_DIR/prod
|
149 |
loizides |
1.2 |
|
150 |
loizides |
1.3 |
write_macro > ./runGenRelVal.C
|
151 |
loizides |
1.2 |
|
152 |
loizides |
1.3 |
rec=`root -l -n -q ./runGenRelVal.C 2>&1`
|
153 |
loizides |
1.1 |
if (( $? )) ; then
|
154 |
loizides |
1.3 |
echo "Problem executing runGenRelVal.C:" >&2
|
155 |
loizides |
1.1 |
echo '' >&2
|
156 |
|
|
echo $rec >&2
|
157 |
loizides |
1.3 |
echo "Output left in $MY_BASE_DIR" >&2
|
158 |
loizides |
1.1 |
exit 1
|
159 |
|
|
fi
|
160 |
|
|
|
161 |
|
|
# do the diff of pythia output and mit tree contents obtained from macro:
|
162 |
|
|
diff $PYFILE macro_output.txt > diff_report.txt
|
163 |
|
|
|
164 |
|
|
# check if things are ok
|
165 |
|
|
if (( $? )) ; then
|
166 |
loizides |
1.2 |
echo "Pythia output disagrees with GenParticles branch contents:" >&2
|
167 |
loizides |
1.1 |
cat diff_report.txt >&2
|
168 |
loizides |
1.3 |
echo "Output left in $MY_BASE_DIR" >&2
|
169 |
loizides |
1.1 |
exit 1
|
170 |
|
|
fi
|
171 |
|
|
|
172 |
|
|
# Cleanup
|
173 |
|
|
rm -rf $MY_BASE_DIR
|
174 |
|
|
exit 0
|