ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/Validation/test/genrelval.sh
Revision: 1.3
Committed: Sun Jul 13 08:39:59 2008 UTC (16 years, 9 months ago) by loizides
Content type: application/x-sh
Branch: MAIN
Changes since 1.2: +12 -13 lines
Log Message:
fixes plus more prinout.

File Contents

# User Rev Content
1 loizides 1.1 #!/bin/bash
2 loizides 1.3 # $Id: genrelval.sh,v 1.2 2008/07/10 16:23:12 loizides Exp $
3 loizides 1.1 #
4     # genrelval.sh: Release validation script for generated particles
5     #
6 loizides 1.3 # $Id: genrelval.sh,v 1.2 2008/07/10 16:23:12 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     # define the tree service
55     service = TreeService {
56     untracked vstring fileNames = { "mit-gen" }
57     }
58    
59     # customize the MIT filler
60     module MitTreeFiller = FillMitTree {
61     untracked bool defactive = false
62     untracked PSet GenParts = {
63     untracked bool active = true
64     untracked string mitName = "GenParticles"
65     untracked string edmName = "source"
66     }
67     }
68    
69     # standard path of action of the module
70     path p0 = { pgen, MitTreeFiller }
71    
72     # also make Edm output for the events we generate
73     include "Configuration/EventContent/data/EventContent.cff"
74     module FEVT = PoolOutputModule
75     {
76     using FEVTSIMEventContent
77     untracked string fileName = "edm-gen.root"
78     }
79    
80     # output path for the Edm file
81     endpath outpath = { FEVT }
82    
83     # schedule the various path
84     schedule = { p0, outpath }
85     }
86     '
87     }
88    
89     function write_macro {
90     echo '
91     //--------------------------------------------------------------------------------------------------
92 loizides 1.2 void runGenRelVal(const char *files = "mit-gen_000.root")
93 loizides 1.1 {
94     gROOT->Macro("$CMSSW_BASE/src/MitAna/macros/setRootEnv.C+");
95 loizides 1.3 gSystem->Load("$CMSSW_BASE/lib/slc4_ia32_gcc345/libMitAnaValidation.so");
96 loizides 1.1
97     using namespace mithep;
98     gDebugMask = Debug::kAnalysis;
99 loizides 1.3 gDebugLevel = 0;
100 loizides 1.1
101     // set up the modules
102 loizides 1.2 GenRelValMod *mod = new GenRelValMod;
103 loizides 1.1
104     // set up analysis
105     Analysis *ana = new Analysis;
106     ana->SetSuperModule(mod);
107     ana->AddFile(files);
108    
109     // run the analysis after successful initialisation
110 loizides 1.2 ana->Run(0);
111 loizides 1.1 }
112     '
113     }
114    
115     ##############################################################################################
116     ##############################################################################################
117     #
118     # Generate sample and fill tree
119     mkdir -p $MY_BASE_DIR/prod
120     cd $MY_BASE_DIR/prod
121     write_cfg > relval.cfg
122     cmsRun relval.cfg >pythia_raw.txt 2>/dev/null
123     if (( $? )) ; then
124     echo "Problem generating sample:" >&2
125     echo '' >&2
126     cat pythia_raw.txt >&2
127 loizides 1.3 echo "Output left in $MY_BASE_DIR" >&2
128 loizides 1.1 exit 1
129     fi
130    
131     # Parse pythia output into something easier to compare with tree.
132     # The following outputs: index, pdgcode, px, py, pz, E
133     # with a particular spacing similar to pylist.
134     PYFILE=$MY_BASE_DIR/prod/pythia_parsed.txt
135     cat pythia_raw.txt | \
136     perl -ne 'if ($_ =~ /^(\s{4}\d{1})\s.{18}(.{5})(.{5})(.{36})/ or
137     $_ =~ /^(\s{3}\d{2})\s.{18}(.{5})(.{5})(.{36})/ or
138     $_ =~ /^(\s{2}\d{3})\s.{18}(.{5})(.{5})(.{36})/ or
139     $_ =~ /^(\s{1}\d{4})\s.{18}(.{5})(.{5})(.{36})/)
140     { print "$1$2$3$4\n" ; }' > $PYFILE
141    
142 loizides 1.2
143     # write+run the validation macro:
144 loizides 1.1 cd $MY_BASE_DIR/prod
145 loizides 1.2
146 loizides 1.3 write_macro > ./runGenRelVal.C
147 loizides 1.2
148 loizides 1.3 rec=`root -l -n -q ./runGenRelVal.C 2>&1`
149 loizides 1.1 if (( $? )) ; then
150 loizides 1.3 echo "Problem executing runGenRelVal.C:" >&2
151 loizides 1.1 echo '' >&2
152     echo $rec >&2
153 loizides 1.3 echo "Output left in $MY_BASE_DIR" >&2
154 loizides 1.1 exit 1
155     fi
156    
157     # do the diff of pythia output and mit tree contents obtained from macro:
158     diff $PYFILE macro_output.txt > diff_report.txt
159    
160     # check if things are ok
161     if (( $? )) ; then
162 loizides 1.2 echo "Pythia output disagrees with GenParticles branch contents:" >&2
163 loizides 1.1 cat diff_report.txt >&2
164 loizides 1.3 echo "Output left in $MY_BASE_DIR" >&2
165 loizides 1.1 exit 1
166     fi
167    
168     # Cleanup
169     rm -rf $MY_BASE_DIR
170     exit 0