ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/Validation/test/genrelval.sh
Revision: 1.5
Committed: Thu Jul 31 12:06:02 2008 UTC (16 years, 9 months ago) by loizides
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_006, Mit_005, Mit_004, MITHEP_2_0_x
Changes since 1.4: +5 -6 lines
Log Message:
Added ObjectService.

File Contents

# User Rev Content
1 loizides 1.1 #!/bin/bash
2 loizides 1.5 # $Id: genrelval.sh,v 1.4 2008/07/25 12:41:41 loizides Exp $
3 loizides 1.1 #
4     # genrelval.sh: Release validation script for generated particles
5     #
6 loizides 1.5 # $Id: genrelval.sh,v 1.4 2008/07/25 12:41:41 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.1
106     // set up analysis
107     Analysis *ana = new Analysis;
108     ana->SetSuperModule(mod);
109     ana->AddFile(files);
110    
111     // run the analysis after successful initialisation
112 loizides 1.2 ana->Run(0);
113 loizides 1.1 }
114     '
115     }
116    
117     ##############################################################################################
118     ##############################################################################################
119     #
120     # Generate sample and fill tree
121     mkdir -p $MY_BASE_DIR/prod
122     cd $MY_BASE_DIR/prod
123     write_cfg > relval.cfg
124     cmsRun relval.cfg >pythia_raw.txt 2>/dev/null
125     if (( $? )) ; then
126     echo "Problem generating sample:" >&2
127     echo '' >&2
128     cat pythia_raw.txt >&2
129 loizides 1.3 echo "Output left in $MY_BASE_DIR" >&2
130 loizides 1.1 exit 1
131     fi
132    
133     # Parse pythia output into something easier to compare with tree.
134     # The following outputs: index, pdgcode, px, py, pz, E
135     # with a particular spacing similar to pylist.
136     PYFILE=$MY_BASE_DIR/prod/pythia_parsed.txt
137     cat pythia_raw.txt | \
138     perl -ne 'if ($_ =~ /^(\s{4}\d{1})\s.{18}(.{5})(.{5})(.{36})/ or
139     $_ =~ /^(\s{3}\d{2})\s.{18}(.{5})(.{5})(.{36})/ or
140     $_ =~ /^(\s{2}\d{3})\s.{18}(.{5})(.{5})(.{36})/ or
141     $_ =~ /^(\s{1}\d{4})\s.{18}(.{5})(.{5})(.{36})/)
142     { print "$1$2$3$4\n" ; }' > $PYFILE
143    
144 loizides 1.2
145     # write+run the validation macro:
146 loizides 1.1 cd $MY_BASE_DIR/prod
147 loizides 1.2
148 loizides 1.3 write_macro > ./runGenRelVal.C
149 loizides 1.2
150 loizides 1.3 rec=`root -l -n -q ./runGenRelVal.C 2>&1`
151 loizides 1.1 if (( $? )) ; then
152 loizides 1.3 echo "Problem executing runGenRelVal.C:" >&2
153 loizides 1.1 echo '' >&2
154     echo $rec >&2
155 loizides 1.3 echo "Output left in $MY_BASE_DIR" >&2
156 loizides 1.1 exit 1
157     fi
158    
159     # do the diff of pythia output and mit tree contents obtained from macro:
160     diff $PYFILE macro_output.txt > diff_report.txt
161    
162     # check if things are ok
163     if (( $? )) ; then
164 loizides 1.2 echo "Pythia output disagrees with GenParticles branch contents:" >&2
165 loizides 1.1 cat diff_report.txt >&2
166 loizides 1.3 echo "Output left in $MY_BASE_DIR" >&2
167 loizides 1.1 exit 1
168     fi
169    
170     # Cleanup
171     rm -rf $MY_BASE_DIR
172     exit 0