Editor 1 (proc)

Editor 2 (main)

Runtime error


   

Console


   

Run info


   

Debug

MC DRS Cal Run   Evt /---   Pix   CBPX =

Camera display

Min Max Min Max
Min Max Grid Marker Image Min Max

Histograms

Min Max Min Max
Min Max Min Max

Waveform

Xmin Xmax Ymin Ymax

Additional controls

Help

HELP

How does it work?

When you submit a javascript to the server, it will be executed on a sandbox on the server. Before the event is loaded from a file and made available within the sandbox. Generally, the sandbox can easily be enhanced, e.g. with algorithms available in php. This can be done on request. After execution, the result returned by the script is then displayed in the camera display.

Why Javascript?

Simply for security reasons. To avoid tranferring the event to the client's browser, the script must be executed on the server side. Also Python and PHP offer the possibility to execute scripts within a program, they do not have any security feature to avoid for exmple access to the local disk. The V8 Javascript engine however, is very limited in functionality and therefore ideally suited for a sandboxed and therefore safe excution on the server. Any other solution is welcome.

Javascript hints!

Please note that in Javascript only basic data typed (number, etc) are copied in an assignment. In all other cases, only a reference is copied. For example, the following code snippet does not return 2 as you might expect but 7!
var arr = [ 0, 1, 2, 3 ];
var cpy = arr;
cpy[2] = 7;
print(arr[2]);
To avoid that, the global namespace implements a clone function. For exmaple, the following code snippet will return the expected output:
var arr = [ 0, 1, 2, 3 ];
var cpy = $.clone(arr);
cpy[2] = 7;
print(arr[2]);

Javascript arrays

Note that javascript arrays have some very powerful member functions. For a description see for example here or search google for function like map or reduce.

The global object $

The environment provides a global object (namesapce) called $ with the following members:
$.file.numEventsNumber of events in the file
$.file.runStartMJD of run start minus 40587 (unix time in days)
$.file.runEndMJD of run end minus 40587 (unix time in days)
$.file.drsFileIf this is a DRS calibration file, the step id, otherwise -1
$.file.isMCTrue is this was requested as Monte Carlo file
$.file.isDRSTrue if DRS calibration constants were requested
$.file.isCalibratedTrue if a calibrated file was requested
$.eventThe event header information as obtained from the file
$.event.numRoiNumber of samples per pixel
$.event.numPixNumber of pixels
$.event.eventNumberEvent number
$.event.triggerNumberTrigger number
$.event.triggerTypeTrigger type
$.event.triggerDecoded trigger information
$.event.unixTime[2]Timestamp when the event arrived at the event builder (unix time in s and us)
$.event.timeDate object according to unixTime (ms precision)
$.data[numPix][numRoi]The event data
$.nroiShortcut to $.event.numRoi
$.npixShortcut to $.event.numPix
$.triggerShortcut to $.event.trigger
$.neighborsArray of 1440 arrays each containing the corresponding neighbors
$.mapArray of 1440 entries (software index) containing the hardware indices.
$.geomArray of 1440 entries. Each an array with two entries, x and y. The distance between two neighbors is 1.
$.dist(i,j)Calculated the distance of two pixels in degree.
$.convConversion factor to convert geom and dist to degree.

Stack traces

Please note that due to some interna, the line numbers in the stack trace shown in case of runtime errors are by one line too high.

Editor 1 (proc)

proc can return an array with numRoi entries or an array with up to four sub-arrays each of nRoi entries. They will be displayed in the graph. The chosel pixel is available as pixel. The most simple is to just return the selected pixel data unprocssed:
return $.data[pixel];

Editor 2 (main)

main should return extracted data per pixel. As proc it can return a single array or an array with up to four sub-arrays each with numPix entries. They are displayed in the camera displays. The function implemented as proc is accessible as proc(i) with i being available in proc as pixel. A very simple extractor could be to return just the sample at the trigger position
var rc = [];
for (var i=0; i<$.event.numPix; i++)
    rc[i] = $.data[i][60];
return rc;
or taking the data pre-procesed by the code of the proc-function:
var rc = [];
for (var i=0; i<$.event.numPix; i++)
    rc[i] = proc(i)[60];
return rc;
Note that the precise access to the result of proc might depend on what exactly is retruned by proc (an array, or an array with sub-arrays). Pixel which are not returned (undefind or null) are not displayed. This allows to show cleaned images as well or test image cleaning algorithms.

What is the data?

The data are all data files found in disks in La Palma (to be precise: on daq's disks). The data is raw-data but with the most recent DRS calibration (only the 1024-cell offset calibration) applied, while the application is done in intergers, i.e. the fractional part of the calibration constant is removed. (This is basically what is written in our FITS files as part of the lossless compression process). No spike or jump removal is applied.

The editor

Key bindings of the editor can be found at Codemirror. In addition the following binding are defined: Tab - Auto indent; F11 - Switch to fullscreen; Esc - In fullscreen mode to leave fullscreen; Ctrl-r - replace; Ctrl-y - Delete the line under the cursor; Ctrl-. (dot) - Fold code; Ctrl-Down (cursor down) - Autocomplete.

How to change the file?

Start typing the date in the filename field. The available files will be filtered as you type. To select a file you need to select it fom the pull down.

What is the meaning of the DRS and Cal checkboxes?

For some files, files which contain calibrated data are available. This means that the DRS calibration (offset (1024), gain and offset (roi)) has been applied. Enabling the checkbox will show this data instead of the raw data. Note that the precision is limited to 0.1mV. In some cases files were taken to deduce this calibration constants (DRS files). This is done in four steps: offset, gain, offset (1024), offset (roi). These steps are called 0, 1, 2 and 2 respectively. If the checkbox Drs is enabled, the corresponding calibration constants as stored in the .drs.fits file, are shown, which is BaselineMean [0], GainMean [1] and TriggerOffsetMean [2].

What is the meaning of the MC checkbox?

Currently, it is only to indicate whether the chosen file is a Monte Carlo file or not. At the moment, all available Monte Carlo file have a four-digit year starting with a 0.

Are there Monte Carlo files available?

Yes, there are. Monte Carlo files have the date 0000/00/00 and the praticle ID as run-number (1: gamma, 6: muon, 14: proton). To my understanding, the run-numbers 100, 101 and 102 refer to pedestals with closed shutter (100 and 101) and open shutter (102).

How to change the displayed pixel?

Enter the pixel number on the corresponding field or its hwardware address. As soon as you acknowledge your change (e.g. remove focus by clicking somewhere else) the pixel contents gets displayed.

How to Save/Load a script?

To load a file choose a file fro your local hard drive via the file selection dialog. To save the contents of the editor, press Save.

Submit

If you have changed the script and you want to run it on the current event press Submit. The Javascript will be executed for this event on the server.

Pixel value

To display the value returned for a pixel just click on the pixel. The value will be displayed in the Pixel field. This will also display the corresponding waveform in the graph.

Min/max values

Min and max values for the plot and the graph can be determined automatically or manully. To set the to a fixed value, enable the min and/or max field and enter the value of your choice. It will survive changing files, events or pixel.

What is the meaning of the image?

The image is a representation of the first and second moment of the distribution of the pixel values. The first moment is the center-of-gravity of the distirbution, the major and minor axis represent the standard deviation around the center-of-gravity (width and length). The line represents an estimate for the distance of the center-of-gravity to the origin of the primary particle (disp). Due to the lack of more information, it is a very simple estimate using disp=1.42*(1-width/length).

What are the additional controls

Get geometry: You will get a file with the pixel positions in arbitrary units. The three columns are the pixel index, and the x and y coordinate in degree.
Get camera data: You will get a file with the data from the currently displayed cameras. The columns are pixel index and value of the cameras 1, 2, 3 and 4.
Get waveforms: You will get a file with the data from the currently displayed waveforms. The columns are sample index and amplitude of the waveforms 1, 2, 3 and 4.

Why is loading the page so slow?

The total contents of the javascript libraries is about 1MB which all have to be treasferred to the browser. In addition the loading and processing of the event takes up to 1s so that the loading time of the page might be untypically slow. Once finished, the amaount of code to load can be decreased.

How to unzoom the plot?

Double click on the plot.