character*length name character*LEN title integer*4 ierr integer*4 ilen, rlen parameter (ilen=LEN) parameter (rlen=LEN) integer*4 ival integer*4 iarray(ilen) real*4 rval real*4 rarray(rlen) character*LEN string ierr=regeventint(name,ival,title) ! I*4 event variable ierr=regeventreal(name,rval,title) ! R*4 event ierr=regeventdouble(name,rval,title) ! R*8 event ierr=regparmint(name,ival,title) ! I*4 parameter ierr=regparmreal(name,rval,title) ! R*4 parameter ierr=regparmdouble(name,rval,title) ! R*8 parameter ierr=regtestint(name,ival,title) ! I*4 test result ierr=regtestreal(name,rval,title) ! R*4 test result ierr=regtestdouble(name,rval,title) ! R*8 test result ierr=regeventintarray(name,iarray,ilen,title) ! I*4 event array ierr=regeventrealarray(name,rarray,rlen,title) ! R*4 event array ierr=regeventdoublearray(name,rarray,rlen,title) ! R*8 event array ierr=regparmintarray(name,iarray,ilen,title) ! I*4 parameter array ierr=regparmrealarray(name,rarray,rlen,title) ! R*4 parameter array ierr=regparmdoublearray(name,rarray,rlen,title) ! R*8 parameter array ierr=regtestmintarray(name,iarray,ilen,title) ! I*4 test result array ierr=regtestrealarray(name,rarray,rlen,title) ! R*4 test result array ierr=regtestdoublearray(name,rarray,rlen,title) ! R*8 test result array ierr=regparmstring(name,string,title) ! Character string
The title argument is an arbitrary string that may be used to label a variable. It may be omitted by using a zero instead of a string. The above functions return an error code, zero for success, and not zero for failure. No specific meanings have been assigned yet for the failure error codes.
The memory locations of the variables that are registered must be static. In Fortran this can be guaranteed by placing all variables that are registered in common blocks. (Or by listing the variables in SAVE statements.)
A test result variable does need not to be registered unless one wants access to the test result from within the source code. An example would be where one wants to condition analysis (peformed after executing a test block) on the result of one of the tests.
If a test result is to be a real value, then the variable or array must be registered before the tests are booked.
character *(*) filename character *(*) histname integer*4 id integer*4 ierr ierr=thload(filename) ierr=thbook() ierr=thwhalias(filename) id = thgetid(histname)
The thload
routine loads all of the blocks of parameters, tests and
histograms contained in a single file. This file may have any number of
blocks of separate types. Several calls to thload
may be made to
load definitions contained in several files. The loading does not
actually set parameter values or book tests or histograms, but merely
makes a copy of the files in memory. A single call to thbook will then
book all of the blocks that have been loaded and not yet booked. After
booking, the routine thwhalias
may be used to write a file of
PAW[]
alias commands that the user may load into PAW so that histograms can be
refered to by name rather than by id number.
All CTP calls return an integer*4
error code. Zero is returned for
successful execute. No specific failure codes are defined except that a
failure will be indicated by a non-zero return code.
The following calls are available for test evaluation and for incrementing test result scalers:
character *(*) blockname integer*4 ierr ierr=thtstexe() ! Execute all tests ierr=thtstexeb(blockname) ! Execute a single block of tests ierr=thtstins() ! Increment all test scalers ierr=thtstinsb(blockname) ! Increment scalers for on block
The calls without arguments will cause all the blocks (in alphabetical
order) to be processed. For the routines that end with b
, only a
single block is executed.
The test scalers must be cleared initially before any calls to increment the scalers are made or before a new run is analyzed. As with test execution and scaler incrementing, all test scalers or just those associated with a specific test block may be cleared.
character *(*) blockname integer*4 ierr ierr=thtstcls() ! Clear all test scalers ierr=thtstclsb(blockname) ! Clear test scalers for ! a single block of tests
Test test results may be cleared before tests are executed with the following routines.
character *(*) blockname integer*4 ierr ierr=thtstclr() ! Clear all test flags ierr=thtstclrb(blockname) ! Clear test flags a single block
Clearing the test results is not required as the execution of each test will result in a definite value. However, there can be situations where clearing the test results is important. Two of the situations are:
In writing the tests that go into CTP test blocks, a given test result name
should generally only be used in one block. In particular particular care
must be taken if arrays are used for test results. If mutually
exclusive array elements (of a given array) are used in more than one test
block, the use of test scalers and the clearing of test flags can have
undesired results. This is because, the ins
, cls
, and
clr
routines will operate on an entire array even if only one
element of that array is used as a test result in a given block. Since
the indices of arrays can be variable as well as fixed, CTP has no easy
way of determining which elements of these arrays to operate on (increment
or clear.)
character *(*) blockname integer*4 ierr ierr=thhstexe() ierr=thhstexeb(blockname)
The CTP histogram filling calls should be called after tests have been executed.
CTP has no routines for saving histograms to a file. This should be accomplished with
character *(*) blockname integer*4 ierr ierr=thgethit() ierr=thgethitb(blockname)
Calls to execute gethit blocks should generally be performed before test execution and histogram filling calls.
character *(*) blockname integer*4 ierr ierr=threp(blockname,filename) ierr=threpa(blockname,filename)
The threp
will copy the text contained in the specified block into
the specified output file, replacing strings insides of braces ({}) with
the expressions contained within them. The routine threpa
is
identical except that the report is appended to the specified file, rather
than overwriting it.
ctp.input
.
subroutine regallvars() implicit none include 'parcommon.inc' include 'testcommon.inc' include 'eventcommon.inc' integer*4 regparmint, regparmreal integer*4 ierr c c Register the parameters used in the ``constants block'' c ierr = regparmreal('proton',proton,'Mass of the proton') ierr = regparmreal('neutron',neutron,'Mass of the neutron') ierr = regparmreal('pion',pion,'Mass of the charged pion') ierr = regparmreal('pizero',pizero,'Mass of the neutral pion') ierr = regparmrealarray('offsets',offsets,8,'An array of offsets') ierr = regparmreal('thmin',thmin,'Low end of theta cut') ierr = regparmreal('thmax',thmax,'High end of theta cut') ierr = regparmreal('phimin',phimin,'Low end of phi cut') ierr = regparmreal('phimax',phimax,'High end of phi cut') ierr = regparmstring('hbook_filename',hbook_filename, 'HBOOK Filename') ierr = regparmstring('report_filename',report_filename, 'Report Generator Filename') c c Register some test result variables. Only the array clean is c registered as CTP will automatically register test result variables c as the test block is booked. If you want to easily access c ierr = regtestintarray('clean',clean,6,'Array of test results') c c Register variables that are recalculated each event which contain c quantities that may be histogrammed. c ierr = regeventreal('mass',mass,'Calculated mass') ierr = regeventreal('fptheta',fptheta,'Theta angle at focal plane') c return end
c c parcommon.inc - Common block for registered parameters c real*4 proton, neutron, pion, pizero real*4 offsets(8) real*4 thmin, thmax, phimin, phimax character*80 hbook_filename,report_filename c common /parms/ proton, neutron, pion, pizero & ,offsets, thmin, thmax, phimin, phimax common /strings/ hbook_filename,report_filename c c testcommon.inc - Common block for test results c integer*4 clean(6) c common /tests/ clean c c eventcommon.inc - Common for event variables c real*4 mass, fptheta c common /event/ mass,fptheta
subroutine initialize() implicit none integer*4 hmemor(20000) common /pawc/ hmemor integer*4 ierr call regallvars call hlimit(20000) ierr = thload('ctp.input') ierr = thbook() ierr = thwalias('paw.aliases') ierr = thtstcls() ! Clear all test scalers return end
subroutine analyze_event implicit none include 'parcommon.inc' include 'testcommon.inc' include 'eventcommon.inc' integer*4 ierr c OTHER DECLARATIONS c GET THE EVENT c DO EVENT ANALYSIS ierr = thtstexeb('hms') ! Exec tests ierr = thtstinsb('hms') ! Incr scalers ierr = thhstexeb('hms') ! Fill histograms return end
subroutine end_analysis implicit none include 'parcommon.inc' include 'testcommon.inc' include 'eventcommon.inc' integer*4 ierr hbook calls to save file threpout call.