1 |
loizides |
1.1 |
#!/bin/bash
|
2 |
loizides |
1.7 |
# $Id: genrelval.sh,v 1.6 2008/11/21 20:12:26 loizides Exp $
|
3 |
loizides |
1.1 |
#
|
4 |
|
|
# genrelval.sh: Release validation script for generated particles
|
5 |
|
|
#
|
6 |
loizides |
1.7 |
# $Id: genrelval.sh,v 1.6 2008/11/21 20:12:26 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 |
loizides |
1.7 |
cat <<EOF
|
27 |
|
|
import FWCore.ParameterSet.Config as cms
|
28 |
loizides |
1.1 |
|
29 |
loizides |
1.7 |
process = cms.Process('HLT')
|
30 |
loizides |
1.1 |
|
31 |
loizides |
1.7 |
process.load('Configuration.StandardSequences.SimulationRandomNumberGeneratorSeeds_cff')
|
32 |
|
|
process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
|
33 |
loizides |
1.1 |
|
34 |
loizides |
1.7 |
|
35 |
|
|
process.maxEvents = cms.untracked.PSet(
|
36 |
|
|
input = cms.untracked.int32(25)
|
37 |
|
|
)
|
38 |
|
|
|
39 |
|
|
process.source = cms.Source("PythiaSource",
|
40 |
|
|
pythiaPylistVerbosity = cms.untracked.int32(1),
|
41 |
|
|
filterEfficiency = cms.untracked.double(1.0),
|
42 |
|
|
pythiaHepMCVerbosity = cms.untracked.bool(False),
|
43 |
|
|
comEnergy = cms.untracked.double(10000.0),
|
44 |
|
|
maxEventsToPrint = cms.untracked.int32(-1),
|
45 |
|
|
|
46 |
|
|
PythiaParameters = cms.PSet(
|
47 |
|
|
parameterSets = cms.vstring()
|
48 |
|
|
)
|
49 |
|
|
)
|
50 |
|
|
|
51 |
|
|
# load generator sequence (VtxSmeared is needed inside, missing dependence)
|
52 |
|
|
process.load('Configuration.StandardSequences.VtxSmearedBetafuncEarlyCollision_cff')
|
53 |
|
|
process.load('Configuration.StandardSequences.Generator_cff')
|
54 |
|
|
|
55 |
|
|
# include the MIT services and standard filler
|
56 |
|
|
process.ObjectService = cms.Service("ObjectService")
|
57 |
|
|
|
58 |
|
|
process.TreeService = cms.Service("TreeService",
|
59 |
|
|
fileNames = cms.untracked.vstring("mit-gen")
|
60 |
|
|
)
|
61 |
|
|
|
62 |
|
|
process.MitTreeFiller = cms.EDAnalyzer("FillMitTree",
|
63 |
|
|
fillers = cms.untracked.vstring('MetaInfos',
|
64 |
|
|
'MCParticles',
|
65 |
|
|
'MCEventInfo'),
|
66 |
|
|
|
67 |
|
|
MetaInfos = cms.untracked.PSet(
|
68 |
|
|
hltActive = cms.untracked.bool(False),
|
69 |
|
|
fillerType = cms.untracked.string('FillerMetaInfos')
|
70 |
|
|
),
|
71 |
|
|
|
72 |
|
|
MCParticles = cms.untracked.PSet(
|
73 |
|
|
simActive = cms.untracked.bool(False),
|
74 |
|
|
fillerType = cms.untracked.string('FillerMCParticles')
|
75 |
|
|
)
|
76 |
|
|
)
|
77 |
|
|
|
78 |
|
|
process.p0 = cms.Path( process.pgen * process.MitTreeFiller)
|
79 |
|
|
|
80 |
|
|
# also make Edm output for the events we generate
|
81 |
|
|
process.load('Configuration.EventContent.EventContent_cff')
|
82 |
|
|
|
83 |
|
|
process.FEVT = cms.OutputModule("PoolOutputModule",
|
84 |
|
|
process.FEVTSIMEventContent,
|
85 |
|
|
fileName = cms.untracked.string('edm-gen.root'),
|
86 |
|
|
)
|
87 |
|
|
|
88 |
|
|
process.end = cms.EndPath( process.FEVT )
|
89 |
|
|
EOF
|
90 |
loizides |
1.1 |
}
|
91 |
loizides |
1.7 |
|
92 |
loizides |
1.1 |
|
93 |
|
|
function write_macro {
|
94 |
|
|
echo '
|
95 |
|
|
//--------------------------------------------------------------------------------------------------
|
96 |
loizides |
1.2 |
void runGenRelVal(const char *files = "mit-gen_000.root")
|
97 |
loizides |
1.1 |
{
|
98 |
|
|
gROOT->Macro("$CMSSW_BASE/src/MitAna/macros/setRootEnv.C+");
|
99 |
loizides |
1.3 |
gSystem->Load("$CMSSW_BASE/lib/slc4_ia32_gcc345/libMitAnaValidation.so");
|
100 |
loizides |
1.1 |
|
101 |
|
|
using namespace mithep;
|
102 |
|
|
gDebugMask = Debug::kAnalysis;
|
103 |
loizides |
1.3 |
gDebugLevel = 0;
|
104 |
loizides |
1.1 |
|
105 |
|
|
// set up the modules
|
106 |
loizides |
1.2 |
GenRelValMod *mod = new GenRelValMod;
|
107 |
loizides |
1.6 |
mod->SetWrite(1);
|
108 |
|
|
mod->SetPrint(0);
|
109 |
loizides |
1.1 |
|
110 |
|
|
// set up analysis
|
111 |
|
|
Analysis *ana = new Analysis;
|
112 |
|
|
ana->SetSuperModule(mod);
|
113 |
loizides |
1.7 |
ana->SetUseHLT(0);
|
114 |
loizides |
1.1 |
ana->AddFile(files);
|
115 |
|
|
|
116 |
|
|
// run the analysis after successful initialisation
|
117 |
loizides |
1.2 |
ana->Run(0);
|
118 |
loizides |
1.1 |
}
|
119 |
|
|
'
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
##############################################################################################
|
123 |
|
|
##############################################################################################
|
124 |
|
|
#
|
125 |
|
|
# Generate sample and fill tree
|
126 |
|
|
mkdir -p $MY_BASE_DIR/prod
|
127 |
|
|
cd $MY_BASE_DIR/prod
|
128 |
loizides |
1.7 |
write_cfg > relval.py
|
129 |
|
|
cmsRun relval.py >pythia_raw.txt 2>/dev/null
|
130 |
loizides |
1.1 |
if (( $? )) ; then
|
131 |
|
|
echo "Problem generating sample:" >&2
|
132 |
|
|
echo '' >&2
|
133 |
|
|
cat pythia_raw.txt >&2
|
134 |
loizides |
1.3 |
echo "Output left in $MY_BASE_DIR" >&2
|
135 |
loizides |
1.1 |
exit 1
|
136 |
|
|
fi
|
137 |
|
|
|
138 |
|
|
# Parse pythia output into something easier to compare with tree.
|
139 |
|
|
# The following outputs: index, pdgcode, px, py, pz, E
|
140 |
|
|
# with a particular spacing similar to pylist.
|
141 |
|
|
PYFILE=$MY_BASE_DIR/prod/pythia_parsed.txt
|
142 |
|
|
cat pythia_raw.txt | \
|
143 |
|
|
perl -ne 'if ($_ =~ /^(\s{4}\d{1})\s.{18}(.{5})(.{5})(.{36})/ or
|
144 |
|
|
$_ =~ /^(\s{3}\d{2})\s.{18}(.{5})(.{5})(.{36})/ or
|
145 |
|
|
$_ =~ /^(\s{2}\d{3})\s.{18}(.{5})(.{5})(.{36})/ or
|
146 |
|
|
$_ =~ /^(\s{1}\d{4})\s.{18}(.{5})(.{5})(.{36})/)
|
147 |
|
|
{ print "$1$2$3$4\n" ; }' > $PYFILE
|
148 |
|
|
|
149 |
loizides |
1.2 |
|
150 |
|
|
# write+run the validation macro:
|
151 |
loizides |
1.1 |
cd $MY_BASE_DIR/prod
|
152 |
loizides |
1.2 |
|
153 |
loizides |
1.3 |
write_macro > ./runGenRelVal.C
|
154 |
loizides |
1.2 |
|
155 |
loizides |
1.3 |
rec=`root -l -n -q ./runGenRelVal.C 2>&1`
|
156 |
loizides |
1.1 |
if (( $? )) ; then
|
157 |
loizides |
1.3 |
echo "Problem executing runGenRelVal.C:" >&2
|
158 |
loizides |
1.1 |
echo '' >&2
|
159 |
|
|
echo $rec >&2
|
160 |
loizides |
1.3 |
echo "Output left in $MY_BASE_DIR" >&2
|
161 |
loizides |
1.1 |
exit 1
|
162 |
|
|
fi
|
163 |
|
|
|
164 |
|
|
# do the diff of pythia output and mit tree contents obtained from macro:
|
165 |
|
|
diff $PYFILE macro_output.txt > diff_report.txt
|
166 |
|
|
|
167 |
|
|
# check if things are ok
|
168 |
|
|
if (( $? )) ; then
|
169 |
loizides |
1.2 |
echo "Pythia output disagrees with GenParticles branch contents:" >&2
|
170 |
loizides |
1.1 |
cat diff_report.txt >&2
|
171 |
loizides |
1.3 |
echo "Output left in $MY_BASE_DIR" >&2
|
172 |
loizides |
1.1 |
exit 1
|
173 |
|
|
fi
|
174 |
|
|
|
175 |
|
|
# Cleanup
|
176 |
|
|
rm -rf $MY_BASE_DIR
|
177 |
|
|
exit 0
|