Index: examples/Validation.cpp
===================================================================
--- examples/Validation.cpp	(revision 23389ff3a092403c3a099c8af2cc8f45338abbed)
+++ examples/Validation.cpp	(revision fa068d31eb4e23117ac06ecbb0fa0219743e0663)
@@ -551,5 +551,5 @@
 
   TF1 *f2 = new TF1("f2", "gaus", f1->GetParameter(1) - 2*f1->GetParameter(2), f1->GetParameter(1) + 2*f1->GetParameter(2));
-  hist->Fit("f2","RQ");  
+  hist->Fit("f2","RQ");
 
   Double_t sig = f2->GetParameter(2);
@@ -914,6 +914,9 @@
   DrawAxis(mg_elFwd, leg_elFwd, 0.2);
 
-  C_el1->Print("delphes_validation.pdf(","pdf");
-  C_el2->Print("delphes_validation.pdf","pdf");
+  TString pdfOutput(outputFile);
+  pdfOutput.ReplaceAll(".root", ".pdf");
+
+  C_el1->Print(pdfOutput+"(","pdf");
+  C_el2->Print(pdfOutput,"pdf");
 
   gDirectory->cd(0);
@@ -1015,6 +1018,6 @@
   DrawAxis(mg_muFwd, leg_muFwd, 0.3, 1);
 
-  C_mu1->Print("delphes_validation.pdf","pdf");
-  C_mu->Print("delphes_validation.pdf","pdf");
+  C_mu1->Print(pdfOutput,"pdf");
+  C_mu->Print(pdfOutput,"pdf");
 
   gDirectory->cd(0);
@@ -1116,6 +1119,6 @@
   DrawAxis(mg_phFwd, leg_phFwd, 0.1);
 
-  C_ph1->Print("delphes_validation.pdf","pdf");
-  C_ph->Print("delphes_validation.pdf","pdf");
+  C_ph1->Print(pdfOutput,"pdf");
+  C_ph->Print(pdfOutput,"pdf");
 
   gDirectory->cd(0);
@@ -1267,8 +1270,8 @@
   mg_met->GetYaxis()->SetTitle("#sigma(ME_{x}) [GeV]");
 
-  C_jet->Print("delphes_validation.pdf","pdf");
-  C_btag1->Print("delphes_validation.pdf","pdf");
-  C_tautag1->Print("delphes_validation.pdf","pdf");
-  C_met->Print("delphes_validation.pdf)","pdf");
+  C_jet->Print(pdfOutput,"pdf");
+  C_btag1->Print(pdfOutput,"pdf");
+  C_tautag1->Print(pdfOutput,"pdf");
+  C_met->Print(pdfOutput+")","pdf");
 
   TFile *fout = new TFile(outputFile,"recreate");
Index: examples/validation.sh
===================================================================
--- examples/validation.sh	(revision 23389ff3a092403c3a099c8af2cc8f45338abbed)
+++ examples/validation.sh	(revision fa068d31eb4e23117ac06ecbb0fa0219743e0663)
@@ -1,3 +1,41 @@
+##############################################################################################
+#
+# This code produces at set of validation plots for a given detector card. 
+#
+# In order to run this you need to compile Delphes with Pythia8 first, see: 
+# 
+# https://cp3.irmp.ucl.ac.be/projects/delphes/wiki/WorkBook/Pythia8
+#
+# After you (re-)compiled Delphes with Pythia8 you are ready to go, execute from Delphes main dir:
+#
+# ./examples/validation.sh [detector_card] [number_of_events] 
+# 
+#  e.g.
+# 
+# ./examples/validation.sh delphes_card_CMS.tcl 100000
+#
+# Note that the more events you specify, the more accurate the controls plots will be ...
+#
+############################################################################################
+
 #! /bin/sh
+
+EXPECTED_ARGS=2
+E_BADARGS=65
+
+if [ $# -ne $EXPECTED_ARGS ]
+then
+  echo "Usage: ./examples/validation.sh [detector_card] [number_of_events]"
+  echo "for instance: ./examples/validation.sh delphes_card_CMS.tcl 10000"
+  exit $E_BADARGS
+fi
+
+card=$1
+nEvents=$2
+validationCard=cards/validation_$card
+output=validation_${card%.*}.root
+
+sed 's/delphes_card_CMS.tcl/'$card'/g' cards/validation_card.tcl  > $validationCard
+
 function runParticleGun {
   name=$1
@@ -5,5 +43,6 @@
   cmnd="examples/Pythia8/configParticleGun_$name.cmnd"
   sed '/Main:spareMode1/s/=[[:space:]]*[0-9]*/= '$pid'/' examples/Pythia8/configParticleGun.cmnd > $cmnd
-  ./DelphesPythia8 cards/validation_card.tcl $cmnd delphes_ParticleGun_$name.root
+  sed '/Main:numberOfEvents/s/=[[:space:]]*[0-9]*/= '$nEvents'/' examples/Pythia8/configParticleGun.cmnd  > $cmnd 
+  ./DelphesPythia8 $validationCard $cmnd delphes_ParticleGun_$name.root
 }
 
@@ -15,3 +54,3 @@
 runParticleGun taujet 15
 
-./Validation delphes_ParticleGun_electron.root delphes_ParticleGun_muon.root delphes_ParticleGun_photon.root delphes_ParticleGun_jet.root delphes_ParticleGun_bjet.root delphes_ParticleGun_taujet.root delphes_validation.root
+./Validation delphes_ParticleGun_electron.root delphes_ParticleGun_muon.root delphes_ParticleGun_photon.root delphes_ParticleGun_jet.root delphes_ParticleGun_bjet.root delphes_ParticleGun_taujet.root $output
