process PROD  = {

   service = MessageLogger
   {
      untracked vstring destinations = {"cerr", "cout"}
      PSet cerr                      = { string threshold = "WARNING" }
      PSet cout                      = { string threshold = "INFO"    }

      untracked vstring fwkJobReports = {"FrameworkJobReport.xml"}
      vstring categories = { "FwkJob" }
      PSet FrameworkJobReport.xml = {
                                PSet default = { int32 limit = 0 }
                                PSet FwkJob = { int32 limit = 10000000 }
                                    }

   }

   service = RandomNumberGeneratorService
   {
      untracked uint32 sourceSeed = 135799753
      PSet moduleSeeds =
      {
         untracked uint32 VtxSmeared = 123456789
      }
   }

        
    # NOTE : if one wants to run with the SiStripDigitizer,
    #        then mag.field in the OscarProducer should be
    #        turned ON; otherwise it gets (re)created by the
    #        SiStripDigitizer, which seems to corrupt at all 
    #        the edm::Event record
     

    # Step 1 : Event Generation

    # flat random E-gun, single muon
    # 
    # if you want another particle type, replace the PartID
    # (standard STDHEP numbering scheme)
    #
    # to run it along with CMS detector simulation
    # (OscarProducer) make sure to select QGSP physics
    # list, instead DummyPhysics ("Dummy" has only EM 
    # process and wont know to model interactions of
    # hadrons with matter)
    #
   source = FlatRandomEGunSource
   {
      untracked int32 maxEvents = 100
      PSet PGunParameters =
      {
         # you can request more than 1 particle
         #vint32  PartID = {211,11}
         #vint32 PartID = { 13 } 
         vint32 PartID = { 11 } 
         double MinEta = -1.5
         double MaxEta = 1.5
         double MinPhi = -3.14159265358979323846 # must be in radians
         double MaxPhi =  3.14159265358979323846
         double MinE  = 9.99
         double MaxE  = 10.01
      }
      untracked int32 Verbosity = 0 # set to 1 (or greater)  for printouts
   }
 
   # event vertex smearing - applies only once (internal check)
   # Note : all internal generatoes will always do (0,0,0) vertex
   #

   module VtxSmeared = VertexGenerator 
   {
      string type = "IOMC/EventVertexGenerators/GaussianEventVertexGenerator"
      double MeanX = 0.
      double MeanY = 0.
      double MeanZ = 0.
      double SigmaX = 0.015
      double SigmaY = 0.015
      double SigmaZ = 53.0  // in mm (as in COBRA/OSCAR)
   }

   #Geometry
   #
   include "Geometry/CMSCommonData/data/cmsSimIdealGeometryXML.cfi"

   es_module = TrackerGeometricDetESModule {}
   #Magnetic Field
   #
   include "MagneticField/Engine/data/volumeBasedMagneticField.cfi"
		
   # Step 2 : CMS Detector Simulation

   # CMS Det.Simulation module (OscarProducer)
   #
   module SimG4Object = OscarProducer 
   { 
      bool NonBeamEvent = false
      untracked int32 RunNumber = 1001
      untracked int32 G4EventManagerVerbosity = 0
      untracked int32 G4StackManagerVerbosity = 0
      untracked int32 G4TrackingManagerVerbosity = 0
      bool UseMagneticField = true
      # bool UseMagneticField = false
      bool OverrideUserStackingAction = true
      bool StoreRndmSeeds = false
      bool RestoreRndmSeeds = false
      string PhysicsTablesDirectory = "PhysicsTables"
      bool StorePhysicsTables = false
      bool RestorePhysicsTables = false
      #VPSet Watchers = {
      #	{ string type = "SimTracer"
      #	  bool verbose = true }
      #}
      PSet MagneticField =
      {
         double delta = 1.
      }
      PSet Physics =
      {
         # NOTE : if you want EM Physics only,
	 #        please select "SimG4Core/Physics/DummyPhysics" for type
	 #        and turn ON DummyEMPhysics
	 #
	 string type = "SimG4Core/Physics/QGSP"
	 bool DummyEMPhysics = false
         bool CutsPerRegion = true
         double DefaultCutValue = 1000.  # cuts in cm, i.e. 10m
         untracked int32 Verbosity = 0   # 1 will print cuts as they get set fdrom DD
			                 # 2 will do as 1 + will dump Geant4 table of cuts			
      }
      PSet Generator = 
      {
         bool ApplyPtCuts = true
	 bool ApplyEtaCuts = true
	 bool ApplyPhiCuts = false
	 double MinPhiCut = 0.   # in degrees,
	 double MaxPhiCut = 360. # internally converted to radians, (-pi,pi) range accounted for
	 double MinEtaCut = -5.5
	 double MaxEtaCut = 5.5
	 double MinPtCut = 40.
	 double MaxPtCut = 999999.
	 untracked int32 Verbosity = 0
      }

      PSet RunAction = { string StopFile = "StopRun" }
      PSet EventAction =
      {
         bool CollapsePrimaryVertices = false
	 string StopFile = "StopRun"
	 untracked bool debug = false
      }
      PSet TrackingAction = 
      { 
         untracked bool DetailedTiming = false 
      }
     PSet UtilityActions =
      {
               string type = "SimG4Core/UtilityAction/TrackingVerboseAction"
               untracked bool  DEBUG = false
               untracked bool  CheckForHighEtPhotons = false
               untracked int32 EventMin = 0
               untracked int32 EventMax = 0
               untracked int32 EventStep = 1
               untracked int32 TrackMin = 0
               untracked int32 TrackMax = 0
               untracked int32 TrackStep = 1
               untracked int32 VerboseLevel = 0 
      }
      PSet SteppingAction =
      {
         bool   KillBeamPipe = true
	 double CriticalEnergyForVacuum = 2.0
	 double CriticalDensity = 1.e-25
	 untracked int32  Verbosity = 0
      }
      PSet TrackerSD =
      {
	 bool    ZeroEnergyLoss = false
	 bool	 NeverAccumulate = false
	 bool	 PrintHits = false
	 double  ElectronicSigmaInNanoSeconds = 12.06         
	 double  EnergyThresholdForPersistencyInGeV = 0.5
	 double  EnergyThresholdForHistoryInGeV = 0.05
      }
      PSet MuonSD =
      {
         double  EnergyThresholdForPersistency = 1.0
         bool    AllMuonsPersistent = false
         bool    PrintHits = false
      }

      PSet CaloSD = {
         double EminTrack = 1.0
         int32  CheckHits = 25
         bool   UseMap = true
         #int32  Verbosity = 1
         int32 Verbosity = 0
         bool   DetailedTiming = false
      }
      PSet ECalSD = {
         bool   UseBirkLaw = false
         double BirkC1 = 0.013
         double BirkC2 = 9.6e-6
         #int32  Verbosity = 11
         int32 Verbosity = 0
      }
      PSet HCalSD = {
         bool   UseBirkLaw = false
         double BirkC1 = 0.013
         double BirkC2 = 9.6e-6
         #int32  Verbosity = 111
         int32 Verbosity = 0
         bool   UseShowerLibrary = true
         bool   TestNumberingScheme = false
      }
      PSet CaloTrkProcessing = {
         #int32  Verbosity = 1
         int32 Verbosity = 0
         bool   TestBeam  = false
         double EminTrack = 0.01
      }                     
      PSet HFShower =    {
         #int32  Verbosity = 11
         int32 Verbosity = 0
         double ProbMax   = 0.7268
         double CFibre    = 0.50
      }
      PSet HFShowerLibrary = {
         FileInPath FileName = "SimG4CMS/Calo/data/hfshowerlibrary_lhep.root"
         string TreeEMID  = "h3"
         string TreeHadID = "h8"
      }
      PSet HFCherenkov = {
         #int32  Verbosity       = 1
	 int32 Verbosity = 0
         double RefIndex        = 1.459
         double Lambda1         = 280.0
         double Lambda2         = 700.0
         double Aperture        = 0.33
         double ApertureTrapped = 0.22
         double Gain            = 0.33
         bool   CheckSurvive    = false
      }
   }  # end of OscarProducer's PSet's/block



  module mix = MixingModule {
         int32 bunchspace = 25
   }

  es_module = EcalPreshowerGeometryEP {}
  es_module = EcalBarrelGeometryEP {}
  es_module = EcalEndcapGeometryEP {}
  es_module = HcalHardcodeGeometryEP {}
  es_module = CaloTowerHardcodeGeometryEP {}
  es_module = CaloGeometryBuilder {}

  include "SimCalorimetry/EcalSimProducers/data/ecaldigi.cfi"

 ###################################################################
 # Get hardcoded conditions the same used for standard digitization
  es_source = EcalTrivialConditionRetriever {
       #untracked double adcToGeVEBConstant = 0.0286
      untracked double adcToGeVEBConstant = 0.0636
  }
 ###################################################################


 #######################################################################################	
 # EB+EE uncalibrated RecHit producer 
 # Weight method (CMS standard requires tuned weights) 	
 include "RecoLocalCalo/EcalRecProducers/data/EcalWeightUncalibratedRecHitProducer.cfi"	
 # Analytic fit (much slower does not require weights) 	
 # include "RecoLocalCalo/EcalRecProducers/data/EcalAnalFitUncalibratedRecHitProducer.cfi"	
 #######################################################################################

 #######################################################################################
 # EB+EE RecHit producer (from uncalibrated RecHit)
 include "RecoLocalCalo/EcalRecProducers/data/EcalRecHitProducer.cfi"	
 #######################################################################################

 #######################################################################################
 # ES RecHit producer (from Digis)
 include "RecoLocalCalo/EcalRecProducers/data/ESRecHitProducer.cfi"	
 #######################################################################################

 sequence detSim = { VtxSmeared, SimG4Object }
 sequence ecalDigi = { mix, ecaldigi }
 sequence ecalRecHit = { ecaluncalibrechit , ecalrechit, esrechit }

  path p1 = { detSim, ecalDigi, ecalRecHit }

   module o1 = PoolOutputModule 
   { 
      untracked string fileName = "electron10GeV_detsim_ecalRecHits.root" 

      untracked vstring outputCommands = 
      {
        "keep *",
	"drop *_ecaldigi_*_*"
      }
   }
   endpath outpath = { o1 }
}