'config' is the detector configuraion file to be used by Epics
'chvscomptab' is the table in which 
           ch  comp  x y z
are given for scintillators. 
      ch: channel number in the array
    comp: component number in Epics
  x y, z: center of the Scintillator. (z is the top of the detector) in cm.

-------------------

********If you want to remake 'config' and 'chvscomptab', you have to do

1) Prepare 'array' file (basic array configuration file)
2) Issue  
       makeconfig array
        where 'array' is the  path to the 'array' mentioned in 1).
   This will create  'config' in this directory.
3) Issue 
       chvscomp array config  chvscomptab

   where the arguments are the paths to the files mentioned above.

-------------------

*****If 'array' changes largely, you may have to modify

     'BEGIN' part of the makesubd1.awk  must be handmade.

  (Enter the x,y values that devide the array into ~ 9x9 
        meshes; the lines must not cross the detectors )

     In makesubd1.awk and chvscomp,
     each column of 'array' is assumed to contain (5, 6 are not used)
           1 2 3 4  5  6   7
          ch x y z  .. .. ch2

     ch2 is assumed to be >=0 for a live detector
            else it is dead and not treated.


      In 'BEGIN' part of the makesubd1.awk,
      give the mesh (x,y) to make the smallest subdetectors
      which contain basic 'configunit' (see below for configunit).
      You must choose (x,y) so that it does not cross the detector areas.
      Each mesh would contain 0 to about 6 unit detectors.

     If 7-th  column is not to show the live detectors,
     the script must be modified; you have to find other
     column for such purpose. This change is also due to
     make 'chvscomp' script.

     There will be no part which must be modified by hand.


********Ingredients**********

1) array (other name and path are possible)

This is the basic array information in which we see 

ch  x y z  S flag  ch2 ....


where ch is the channel number
      x,y,z the coordinate of the unit detector (m)
      ch2 if it is not < 0, live ch is the live detector
  Only ch, x,y,z and ch2 are used to make config.


2) configunit (fixed name and path)

  This defines the basic unit of the detector as a subdector.
  All detectors in the array should have the same structure.

3) makeconfig, makesubd1.awk, makesubd2.awk, makesubd3.awk, makedet.awk

   These are a shell script and awk scripts to make config.
  Only makeconfig is used by the user; others are used implicitly by 
  makeconfig.   The command creates config1, config2, config3 and config.

  config[1-3] may be deleted. 

4) chvscomp

  This is a shell script to get ch vs component number correspondence.


===================

If you want to know how the subdetectors are deployed;
  1)  in Util
	make -f testCnf1.mk
	echo "../UserHook/TibetArray/config" | a.out > configout
  2) ./getsubd  configout > subd
  3)  awk -f subdconfig.awk  subd > subdforgnu
  4)  In gnuplot;  plot 'subdforgnu' w l

