next up previous contents
Next: Calibration on Cosmic Ray Up: For ESPACE Programmer Previous: ESPACE Internal Variables

ESPACE Program Modules

  In this section programs and fragments of programs, concerning to shower detector software are described. Here, for shortness, the designation shwr(ish) is used instead of spdet.trigger.sh(ish), where ish=1 for Preshower and ish=2 for Shower. (See structures /onespectrodet/, /trig_package/, /shower/ in espace_type.h file.)



logical function shcal_coef_io (io,fname) (file read_show_coef.f) -- Program for the shower detector channels Pedestals, its Sigma-s and Calibration coefficients Input/Output from/to the given disk file into/from the corresponding structure. When data input has been required, then program tries to read the coefficients from the given file. If the given file doesn't exist, then program builtin data into the structure is set. These builtin coefficients have been calculated using the data of run 1690.

Input:
io -- Option indicating Input or Output action:
=0 -- Input data into the structure from the given file;
=1 -- Output data from the structure into the given file.
fname -- File name from/to which data must be inputed/outputed.
shwr(ish).geom.nblock -- Number of the detector modules.

Output:
shcal_coef_io -- Indicates the operation result:
=.true. -- The data have been read/written from/to the given disk file;
=.false. -- Open or Write error on the given file.

Input/Output:
shwr(ish).cof(i).offset.adc -- Mean value of the i-th channel pedestal -- Output, if io=0, and Input, if io=1, to/from structure /shower/.
shwr(ish).cor(i).offset_sigma.adc -- Value of the i-th channel pedestal sigma -- Output, if io=0, and Input, if io=1, to/from structure /shower/.
shwr(ish).cor(i).amplitude.adc -- Value of the i-th channel calibration constant -- Output, if io=0, and Input, if io=1, to/from structure /shower/.

Is Called From: read_show_coef, shcal_dofit.

Note: Program assumes, that fname is a name of the current directory file. In order to prevent a repetition of the same calibration coefficients computation by the various users, one can create a common usage directory and save there all created coefficients files. In this case into the inner character variable path can be set this directory path name.



subroutine read_show_coef (file read_show_coef.f) -- Read from the disk file and set into the corresponding data structure the shower detector channels Pedestals, its Sigma-s and Calibration coefficients. Firstly program tries to read coefficients from the shower_calib_rXXXX.dat file (where XXXX is a run number). If this file doesn't exist, then program tries to read the shower_calib.dat file. If this file doesn't exist too, then program builtin data is set into the structure.

Input:
run_number -- Number of currently processing run (see run_info.h).

Output:
shwr(ish).cor(i).offset.adc -- Mean value of the i-th channel pedestal.
shwr(ish).cor(i).offset_sigma.adc -- Value of the i-th channel pedestal sigma.
shwr(ish).cor(i).amplitude.adc -- Value of the i-th channel calibration constant.

Used Subroutine: shcal_coef_io.

Is Called From: read_show_e.

Note 1: Program assumes, that shower_calib_rXXXX.dat and shower_calib.dat are the current directory files (see also the Note to the shcal_coef_io program).
Note 2: XXXX -- is a 4 digital run number.



subroutine read_show_peds (file read_show_peds.f) -- Read from the disk file shower_peds.dat and set into the corresponding data structure the mean pedestal values and Sigma-s of the shower detector channels. If file of pedestals doesn't exist, then no changes in the data structure is made.

Input:
shwr(ish).geom.nblock -- Number of the detector modules.

Output:
shwr(ish).cor(i).offset.adc -- Mean value of the i-th channel pedestal.
shwr(ish).cor(i).offset_sigma.adc -- Value of the i-th channel pedestal sigma.

Is Called From: shcal_dofit.

Note: Program assumes, that shower_peds.dat is the current directory file. Pedestals file can be saved into the common usage directory together with the calibration coefficients files (see also the Note to the shcal_coef_io program).



logical function read_show_e (raw,wdctr,spdet) (file read_show_e.f) -- Extract shower detector data from the raw data read out, correct it and set into the corresponding structure /shower/. For every block, data correction is made by formula Aicor=(Airaw-Pi) ×Ci , where: i -- block number, Airaw -- raw ADC value from the block, Pi -- pedestal value, Ci -- calibration constant, Aicor -- corrected ADC value. (So, the i -th block data correction means determination of energy deposition in the block.) For this, the calibration constants reading program read_show_coef is called only once for each new run during the first entrance into the read_show_e.

Input:
raw -- Is a record of structure /raw_total/ (see raw_type.h).
wdctr -- Is a record of structure /word_counters/ (see raw_type.h).
spdet -- Is a record of structure /onespectrodet/ (see espace_type.h).
run_number -- Number of currently processing run (see run_info.h).
rawdata_input -- Flag, which shows either raw data input is done (if .true.), or not (if .false.). (See communications.h).
raw.shower1(100).block - Array of Preshower fired blocks numbers (raw_type.h).
raw.shower1(100).data -- Array of amplitudes values from ADC in Preshower fired blocks (see raw_type.h).
raw.shower2(100).block -- Array of Shower fired blocks numbers (see raw_type.h).
raw.shower2(100).data -- Array of amplitudes values from ADC in Shower fired blocks (see raw_type.h).
raw.shower1 -- Preshower read out word counter (see raw_type.h).
raw.shower2 -- Shower read out word counter (see raw_type.h).
spdet.index -- Index to the spectrometer records ( =1 for the electron arm records).
spdet.hitbit(64) -- Array of detectors hitbits.
shwr(ish).hitbit -- Hitbit assigned to the shower detector.
shwr(ish).geom.nblock -- Number of the detector modules.
shwr(ish).adc_range -- Range of ADC amplitudes values.
shwr(ish).cor(i).offset.adc -- Mean value of the i-th channel pedestal.
shwr(ish).cor(i).offset_sigma.adc -- Value of the i-th channel pedestal sigma.
shwr(ish).cor(i).amplitude.adc -- Value of the i-th channel calibration constant.

Output:
read_show_e -- Is always .true. when this function is called.
shwr(ish).nhits.adc -- Number of hits read out.
shwr(ish).nblock.adc -- Number of blocks that fired.
shwr(ish).block(i).fired.adc -- Flag, which shows either the block number i was fired (if .true.), or not (if .false.).
shwr(ish).block(i).nrhit.adc -- Number of hits on the i-th fired block.
shwr(ish).block(i).val(1).adc -- Raw ADC value from the i-th fired block.
shwr(ish).block(i).cor_val(1).adc -- Corrected ADC value (i.e. energy deposition) in the i-th fired block.
shwr(ish).blocks(i).adc -- Number of the i-th fired block.
shwr(ish).blocknr(i).adc -- Pointer to block number for the i-th hit.
shwr(ish).hitnr(i).adc -- Pointer to hit number in a block for the i-th hit.

Used Subroutines: read_show_coef, which_show_block.

Is Called From: interpret_event_coin.



integer function which_show_block (ispectro,ish,tdc_info,ihit) (file which_show_block.f) -- Define the shower detector block number for the given hit.

Input:
ispectro -- Index to the spectrometer arm ( =1 for the electron arm).
ish -- Index to the Preshower (if =1) or the Shower (if =2) detector.
tdc_info -- Flag, which shows either TDC (if .true.), or ADC (if .false.) hit information is considered.
ihit -- The hit number, for which the block number definition is required.
shwr(ish).geom.nblock -- Number of the detector modules.
shwr(ish).block(i).nrhit.adc -- Number of hits on the i-th fired block.
shwr(ish).blocks(i).adc -- Number of the i-th fired block.

Output:
which_show_block -- Defined block number for the given hit.

Is Called From: read_show_e.



subroutine tot_shower (sptr,spdet) (file tot_shower.f) -- Program for showers clusters reconstruction in Preshower and Shower. This program determines number of blocks, energy deposition and coordinates of center for every cluster defined in the shower detectors. Also, analyzes geometrical position of the ``golden track'' point on the detector plane and Preshower and Shower clusters centers in order to determine the ``main'' cluster and to set it parameters and identifier.

Input:
sptr -- Is a record of structure /onespectrotr/ (see espace_type.h).
spdet -- Is a record of structure /onespectrodet/ (see espace_type.h).
sptr.particle.fp_h.x, ....fp_h.y, ....fp_h.z -- Particle X, Y and Z coordinates in the detector hut coordinate system (in meters).
spdet.hitbit(64) -- Array of detectors hitbits.
shwr(ish).hitbit -- Hitbit assigned to the shower detector.
shwr(ish).geom.p.x, ....p.y, ....p.z -- X, Y and Z coordinates giving the detector position (in meters).
shwr(ish).geom.block(96).p.x, ....p.y, ....p.z -- X, Y and Z coordinates of the detector blocks in detector local coordinate system (in meters).
shwr(ish).nhits.adc -- Number of hits read out.
shwr(ish).blocks(96).adc -- Array of fired blocks numbers.
shwr(ish).block(96).cor_val(2).adc -- Energies in fired blocks.

Output:
shwr(ish).iden -- Identifier of the ``main'' cluster:
=k >0 or =0 -- The (k+1)-th cluster corresponds to the ``golden track'';
=-1 -- Shower and Preshower clusters are coincident, but are not coincident with the ``golden track'';
<-1 -- In other cases.
shwr(ish).ecl, shwr(ish).xcl, shwr(ish).ycl -- Energy deposition (in MeV), X and Y coordinates (in meters) of the ``main'' cluster.
shwr(ish).x, shwr(ish).y -- X and Y coordinates (in meters) of the ``golden track'' in the detector local coordinate system.
shwr(ish).ncluster -- Number of clusters determined.
shwr(ish).clust(i).mult -- Number of blocks in the i-th cluster.
shwr(ish).clust(i).x, shwr(ish).clust(i).y, shwr(ish).clust(i).energy -- X, Y coordinates in the detector coordinate system (in meters) and energy deposition (in MeV) of the i-th cluster.
shwr(ish).clust(i).cell(j).cell_num, shwr(ish).clust(i).cell(j).cell_val -- Block number and energy deposition in the j-th block of the i-th cluster.

Used Subroutine: det_vertex.

Is Called From: spectrometer_reconstruct.



subroutine shcal_events (sptr,spdet) (file shcal.f) -- Select events for shower detector channels calibration and write these (calibration) events into the disk file. The calibration events are selected such, that the charged particle is electron with the biggest probability (see sec.1.2).

Input:
sptr -- Is a record of structure /onespectrotr/ (see espace_type.h).
spdet -- Is a record of structure /onespectrodet/ (see espace_type.h).
shcal_flagfit -- Flag, which shows either the shower detector calibration required, (if .true.), or not (if .false.) in the Espace/File/scan command.
sptr.ok -- Flag, which shows either data reconstruction in all of spectrometer detectors packages was successful, (if .true.), or not (if .false.).
shwr(ish).ncluster -- Number of clusters determined in the shower detector.
shwr(ish).iden -- Identifier used for the ``main'' cluster selection.
spdet.vdc.ntrack -- Number of tracks reconstructed in the VDC system.
spdet.trigger.sc(isc).npad -- Number of paddles that fired on the isc-th Scintillator (isc= 1 or 2).
spdet.trigger.gas.analog_adcsum -- Sum of amplitudes of Gas Cherenkov signals.
sptr.particle.pmom_kin -- Particle momentum corrected for kinematic broadening.
shwr(ish).clust(1).mult -- Number of blocks in the cluster.
shwr(ish).clust(1).cell(j).cell_num -- Blocks numbers in the cluster.
shwr(ish).block(i).val(1).adc -- Raw ADC value from the i-th fired block of the cluster.

Output:
shcal_events.dat_tmp -- The temporary text file, into which the following data of each of selected calibration events are written: momentum of particle, number of blocks in the Preshower cluster, amplitude values in each of these blocks, number of blocks in the Shower cluster, amplitude values in each of these blocks. This file is used by the calibration constants fitting program shcal_dofit later.

Is Called From: process_data.



subroutine shcal_dofit (file shcal.f) -- Calculate the calibration constants using the data of the calibration events selected before by program shcal_events. Constants calculation is proceeded by the following.

Firstly, program reads the calibration events and defines the number of hits in each of shower detector blocks. For blocks, hits number in which is less than a number minblev, the value of calibration constant is taken from the structure /shower/ and is fixed, i.e. is not recalculated by the following fitting procedure. (Initial values of all constants into the structure /shower/ is set before, during the data scanning by program read_show_coef.)

Secondly, program reads into the structure /shower/ the mean pedestal values and Sigma-s of the shower detector channels by program read_show_peds calling. Repeated setting of pedestals into the structure is done with the purpose to have the most appropriate (on the time) pedestal values for new calibration. It must provide a user by copying the corresponding file into the corresponding directory (see program read_show_peds).

Then, the calibration constant values are fitted by minimization of functional (2) (see sec.1.2).

If minimization is completed successfully, then the fitted values of calibration constants are set in the structure /shower/ and are saved into the disk file by calling program read_show_io. Otherwise, the old calibration constants values is restored in the structure /shower/ by calling program read_show_coef.

New calibration constants values (including pedestals and its sigma-s values) are saved into both shower_calib_rXXXX.dat (where XXXX is the run number of data file) and shower_calib.dat files. The purpose of creation of two similar calibration constants files is: 1) keep the own constants file for every calibrated run file in order to use it during a future processing without repeated calibration; 2) keep a constants file for cases, when processed run file has not been calibrated previously, and one can use the latest calculated constants (see program read_show_coef).

Finally, the temporary file shcal_events.dat_tmp is removed and flag of the calibration requirement shcal_flagfit is reseted.

Input:
run_number -- Number of currently processing run (see run_info.h).
shwr(ish).cor(i).amplitude.adc -- Initial values of the shower detector channels calibration constants, which was set by program read_show_coef before.
shwr(ish).cor(i).offset.adc -- Values of the shower detector channels pedestals, by which the new calibration constants are calculated.

Output:
shower_calib.dat and shower_calib_rXXXX.dat (where XXXX is the run number of data file) -- Two similar files, containing the calculated calibration constants.

Used Subroutine: read_show_peds, shcal_coef_io, read_show_coef.

Is Called From: scan_file program, when a File/scan command with option ``s'' has been given.


next up previous contents
Next: Calibration on Cosmic Ray Up: For ESPACE Programmer Previous: ESPACE Internal Variables
Armen Ketikyan
5/16/1998