# ==========================================================================
#############################################################################
# ==========================================================================
#                              General
# ==========================================================================
#############################################################################
# ==========================================================================

# -------------------------------------------------------------------------
# Use this if you want to setup the logging stream for the jobs
# (overwrites command line options)
# -------------------------------------------------------------------------
#MLog.VerbosityLevel: 2
#MLog.DebugLevel:     1
#MLog.NoColors:       yes

# ==========================================================================
#############################################################################
# ==========================================================================
#                                   Ceres
# ==========================================================================
#############################################################################
# ==========================================================================

# -------------------------------------------------------------------------
# Use this if you want to write the MJStar output somewhere
# If you don't want it, it is written to the calibration output anyhow.
# -------------------------------------------------------------------------
#PathOut: .
#PathIn: .


# -------------------------------------------------------------------------
# Configure Eventloop
# -------------------------------------------------------------------------
#MaxEvents: 10000
#Overwrite: yes,no


# -------------------------------------------------------------------------
# Use this to setup binnings. For more details see: MBinning::ReadEnv
# -------------------------------------------------------------------------
# BinningEnergy.Raw:      100      1    100000  log
# BinningSize.Raw:        100      1  10000000  log
# BinningImpact.Raw:       50   -250       250
# BinningHeight.Raw:       50      0        12
# BinningAz.Raw:          360   -360       360
# BinningZd.Raw:           70      0        70
# BinningViewCone.Raw:    155      0        31
# BinningTrigPos.Raw:     150    -25       125
# BinningEvtWidth.Raw:    150      0        25
# BinningDist.Raw:        100      0       2.5
# BinningDistC.Raw:       100      0       2.5
# BinningThreshold.Raw:    35    0.9     90000  log
# BinningEnergyEst.Raw:   100    0.9     90000  log


# -------------------------------------------------------------------------
# Initialize random number generator (see MJob::InitRandomNumberGenerator)
# -------------------------------------------------------------------------
RandomNumberGenerator: TRandom3
#RandomNumberSeedValue: 0


# -------------------------------------------------------------------------
# Ceres general setup
# -------------------------------------------------------------------------

# Switch off the camera "electronics"
#Camera: Off

# Force the use of the "hardware" trigger for calibration data
#ForceTrigger: Yes


# -------------------------------------------------------------------------
# Some setup for the atmosphere. The default should be well suited.
# -------------------------------------------------------------------------
#MSimAtmosphere.FileAerosols: resmc/atmopshere-aerosols.txt
#MSimAtmosphere.FileOzone:    resmc/atmopshere-ozone.txt


# -------------------------------------------------------------------------
# Here you can control the poiting of the telescope. To switch on
# off-target observations set a value for the distance !=0 [deg].
# For details see MSimPointingPos
# -------------------------------------------------------------------------
#MSimPointingPos.OffTargetDistance: 0.4
#MSimPointingPos.OffTargetPhi: -1


# -------------------------------------------------------------------------
# Setup the reflector and camera geometry
# -------------------------------------------------------------------------
Reflector.Constructor: MReflector

# For the file definition see MReflector::ReadFile

#Reflector.FileName: resmc/magic-reflector.txt
#Reflector.FileName: resmc/magic-reflector-chessboard.txt
# Units mm: ~0.020°
#Reflector.SetSigmaPSF: 6.0
# Units mm: ~0.025°
#Reflector.SetSigmaPSF: 7.5

Reflector.FileName: resmc/dwarf-reflector.txt
# Units mm: ~0.02° 
#Reflector.SetSigmaPSF: 1.8
# Units mm: ~0.03°
Reflector.SetSigmaPSF: 2.6


# --- DWARF ---
# distance from mirror to camera [cm]
#focal_distance     489.73
# TRUE focal of the paraboloid (must correspond to that of the mirror positions defined below!)
#paraboloid_focal   488.87

# Hex cones maximum D=8mm
GeomCones.Constructor:  MGeomCamDwarf(209.5, 7.5, 4.8887);
MGeomCam.Constructor:   MGeomCamDwarf(209.5, 15,  4.8887);

MSimBundlePhotons.FileName: resmc/dwarf-apdmap.txt

# Set the APD type (1: 30x30 <default>, 2: 60x60)
#MSimAPD.Type: 1

# --- MAGIC ---
#MGeomCam.Constructor:   MGeomCamMagic(17.0)
#MSimAPD.NameGeomCam:


# -------------------------------------------------------------------------
# Setup the absorption, conversion efficiency and angular acceptance
# -------------------------------------------------------------------------
MirrorReflectivity.FileName:           resmc/dwarf-reflectivity.txt
PhotonDetectionEfficiency.FileName:    resmc/dwarf-pde-gapd.txt
ConesAngularAcceptance.FileName:       resmc/dwarf-cones.txt
ConesTransmission.FileName:            resmc/dwarf-cones-trans.txt


# -------------------------------------------------------------------------
# Setup what in MMCS would be called "additional spot size"
# -------------------------------------------------------------------------
#MSimPSF.Sigma: -1
#MSimReflector.DetectorMargin: 0


# -------------------------------------------------------------------------
# Setup the dark counts (FrequencyFixed) and the NSB noise per cm^2
# -------------------------------------------------------------------------
# Dark Counts per APD: ~4MHz
#MSimRandomPhotons.FrequencyFixed: 0.004
# Spectrum to use as NSB spectrum (see Benn et al. for example)
#MSimRandomPhotons.FileNameNSB: resmc/night-sky-la-palma.txt
# If an empty file name is given a constant is used instead:
#  NSB photon rate [ph/m^2/nm/sr/ns]
#MSimRandomPhotons.FrequencyNSB:   5.8

# FIXME: With a class describing the cones we could give NSB as
# per sr and cm^2


# -------------------------------------------------------------------------
# Setup the trigger
# -------------------------------------------------------------------------
# This line could be omitted but then the discriminator would be
# evaluated for all pixels not just for the pixels which are
# later "connected" in the trigger (used in the coincidence map)
# MSimTrigger.FileNameRouteAC:         resmc/magic-trigger-1NN.txt

# HEGRA like single pixel above threshold trigger
#MSimTrigger.DiscriminatorThreshold:  10.00
# Is this an option for a single pixel trigger?
#MSimTrigger.DigitalSignalLength:     -1
#MSimTrigger.CoincidenceTime:          3

# Magic like 2NN trigger (inner 396 pixel)
#MSimTrigger.FileNameCoincidenceMap:  resmc/magic-trigger-2NN.txt
#MSimTrigger.DiscriminatorThreshold:  7.00
#MSimTrigger.DigitalSignalLength:     8
#MSimTrigger.CoincidenceTime:         0.5

# Magic like 3NN trigger (inner 396 pixel)
#MSimTrigger.FileNameCoincidenceMap:  resmc/magic-trigger-3NN.txt
#MSimTrigger.DiscriminatorThreshold:  6.0
#MSimTrigger.DigitalSignalLength:     8
#MSimTrigger.CoincidenceTime:         0.5

# Magic like 4NN trigger (inner 396 pixel)
#MSimTrigger.FileNameCoincidenceMap:  resmc/magic-trigger-4NN.txt
#MSimTrigger.DiscriminatorThreshold:  5.0
#MSimTrigger.DigitalSignalLength:     8
#MSimTrigger.CoincidenceTime:         0.5

MSimTrigger.FileNameRouteAC:         resmc/magic-trigger-3NN.txt
MSimTrigger.DiscriminatorThreshold:  11000
MSimTrigger.DigitalSignalLength:     8
MSimTrigger.CoincidenceTime:         0.5

IntendedPulsePos.Val: 40

PulseShape.Function.Name: exp(-(x/2)^2/2)

# -------------------------------------------------------------------------
# Description how a pedestal/calibration signal is produced
# -------------------------------------------------------------------------

#MSimCalibrationSignal.NumEvents:  1000
#MSimCalibrationSignal.NumPhotons:    5
#MSimCalibrationSignal.TimeJitter:  1.0


# -------------------------------------------------------------------------
# Setup the FADC
# -------------------------------------------------------------------------

# Currently only 1GHz is supported
MRawRunHeader.SamplingFrequency: 1000
MRawRunHeader.NumSamples:         150
MRawRunHeader.NumBytesPerSample:    2
MRawRunHeader.FadcResolution:      12

#MSimReadout.fConversionFactor: 1

# The number of sampling points is almost irrelevant because they
# are equidistant, i.e. calculated and no search is necessary.
# Nevertheless, you must make sure that there are enough points
# to sample the function accuratly enough.
#MPulseShape.Function.Name:  3.51308*exp(-1.4105*(exp(-0.5*x)+0.310942*x)) + 4.33521e-3*exp(-1.4105*(exp(-0.5*x)+6.09265e-3*x))
#MPulseShape.Function.Npx:   250
#MPulseShape.Function.Xmin:   -5
#MPulseShape.Function.Xmax:   45

# Old values
# Baseline at 15 like in MAGIC
# 1.5 bit noise for a gain of 64
# This allows a maximum of 200phe/pix
MSimCamera.DefaultOffset: 960
MSimCamera.DefaultNoise:   96
MSimCamera.DefaultGain:   256

# New values
#MSimCamera.DefaultOffset: 1000
#MSimCamera.DefaultNoise:    30
#MSimCamera.DefaultGain:    190


# -------------------------------------------------------------------------
# Setup an image cleaning on the pure gamma signal (without noise)
# The default is to removed signals in isolated pixels. No time constraint
# is applied by default.
# -------------------------------------------------------------------------

#MImgCleanStd.CleanLevel1:   6.0
#MImgCleanStd.CleanLevel2:   6.0

# -------------------------------------------------------------------------
# This is a cut executed after the calculation of the image parameters
# -------------------------------------------------------------------------
#Cut.Inverted: Yes
#Cut.Condition: MHillas.fSize>10

#MSimTrigger.SimulateElectronics: Off
