RunninglibNEST: Difference between revisions

From LZ Computing
Jump to navigation Jump to search
(Created page with "==Running libNEST== If you would like to produce S1 or S2 data from energy depositions you can run libNEST. This will walk through how to do this in python in the context of L...")
 
No edit summary
 
Line 8: Line 8:
The following lines need to be run before starting libNEST. They can be added to your ~/.bashrc file in order to be run automatically when you ssh.
The following lines need to be run before starting libNEST. They can be added to your ~/.bashrc file in order to be run automatically when you ssh.
<nowiki>
<nowiki>
source /cvmfs/lz.opensciencegrid.org/fastNEST/release-#.#.#/libNEST/thislibNEST.sh
source /cvmfs/lz.opensciencegrid.org/fastNEST/release-3.0.2/libNEST/thislibNEST.sh


export PYTHONPATH=${PYTHONPATH}:/cvmfs/lz.opensciencegrid.org/fastNEST/release-#.#.#/libNEST </nowiki>
export PYTHONPATH=${PYTHONPATH}:/cvmfs/lz.opensciencegrid.org/fastNEST/release-3.0.2/libNEST </nowiki>
The first line sets up libNEST to be run on your system and the second allows python to import the libNEST module (it would not be necessary if using root instead of python).
The first line sets up libNEST to be run on your system and the second allows python to import the libNEST module (it would not be necessary if using root instead of python). Note that the 3.0.2 release is required to run with python as the installation does not automatically include the python library.


====Simple S1 and S2 calculation in python====
====Simple S1 and S2 calculation in python====

<nowiki>
import libNEST ## When I was testing I just ran this line a few times

### First setup the NEST parameters
'''
// LXe forward field region
//following parameters depend on the cathodeVoltage!
//currently assuming cathodeVoltage = 50 kV - sjh, Dec. 7, 2015
'''
cathode_voltage = 50. # kV
electricField_lxe = 290. # V/cm
drift_velocity = 1.78 # mm/us
density_lxe = 2.88 # g/cm3

##inputs: particle type (ER==1, NR==0), energy (keV), electric field (V/cm), xenon density (g/cm^3), drift time (us)
nestLZ=libNEST.NEST(1,1,electricField_lxe,density_lxe,-1)
detectorLZ=libNEST.Detector()
detectorLZ.LZSettings()
detectorLZ.cathodeVoltage=cathode_voltage
nestLZ.SetDetectorParameters(detectorLZ)


## Now we can set the parameters of the individual event
En=70 # keV
z_pos=50 # cm
nestLZ.SetEnergy(En)
nestLZ.SetElectricField( electricField_lxe )
nestLZ.SetDriftLocation( (1456.-z_pos*10.)/drift_velocity ) #in us.
## Note the units on the drift velocity so the z position must be converted to mm (BaccRootConverter uses cm)
nestLZ.DetectorResponse()
nestLZ.DetectorResponse()
S1=nestLZ.GetS1c() #S1c accounts for the corrections of S1 collection as function of position in the detector
S2=nestLZ.GetS2c()

print S1,S2 # If successful this will print out values corresponding to S1 and S2

</nowiki>

Latest revision as of 20:13, 21 June 2017

Running libNEST

If you would like to produce S1 or S2 data from energy depositions you can run libNEST. This will walk through how to do this in python in the context of LZ.

Before running libNEST read through the tutorial found here: fastNEST Tutorial also browse the git-lab: https://lz-git.ua.edu/sim/fastNEST

libNEST startup procedure

The following lines need to be run before starting libNEST. They can be added to your ~/.bashrc file in order to be run automatically when you ssh.

source /cvmfs/lz.opensciencegrid.org/fastNEST/release-3.0.2/libNEST/thislibNEST.sh

export PYTHONPATH=${PYTHONPATH}:/cvmfs/lz.opensciencegrid.org/fastNEST/release-3.0.2/libNEST 

The first line sets up libNEST to be run on your system and the second allows python to import the libNEST module (it would not be necessary if using root instead of python). Note that the 3.0.2 release is required to run with python as the installation does not automatically include the python library.

Simple S1 and S2 calculation in python

import libNEST ## When I was testing I just ran this line a few times 

### First setup the NEST parameters
'''
  // LXe forward field region
  //following parameters depend on the cathodeVoltage!
  //currently assuming cathodeVoltage = 50 kV - sjh, Dec. 7, 2015
'''
cathode_voltage = 50. # kV
electricField_lxe = 290. # V/cm
drift_velocity = 1.78 # mm/us
density_lxe = 2.88 # g/cm3

##inputs: particle type (ER==1, NR==0), energy (keV), electric field (V/cm), xenon density (g/cm^3), drift time (us)
nestLZ=libNEST.NEST(1,1,electricField_lxe,density_lxe,-1)
detectorLZ=libNEST.Detector()
detectorLZ.LZSettings()
detectorLZ.cathodeVoltage=cathode_voltage
nestLZ.SetDetectorParameters(detectorLZ)


## Now we can set the parameters of the individual event 
En=70  # keV
z_pos=50 # cm
nestLZ.SetEnergy(En)
nestLZ.SetElectricField( electricField_lxe )
nestLZ.SetDriftLocation( (1456.-z_pos*10.)/drift_velocity ) #in us. 
## Note the units on the drift velocity so the z position must be converted to mm (BaccRootConverter uses cm)
nestLZ.DetectorResponse()
nestLZ.DetectorResponse()
S1=nestLZ.GetS1c() #S1c accounts for the corrections of S1 collection as function of position in the detector
S2=nestLZ.GetS2c()

print S1,S2 # If successful this will print out values corresponding to S1 and S2