README of FACT svntools/rootmacros

	on the ISDC cluster, I used /opt/root5.18.x86_64/bin/root for testing.

fbsl.C		ROOT Macro computing the baseline for each pixel
	the function is declared as:
	int fbsl( 
  	const char *datafilename    = "path-to-datafile.fits.gz",
	  const char *drsfilename = "path-to-calibfile.drs.fits.gz",
	  const char *TextOutFileName = "./appendfile.txt",
	  const char *RootOutFileName = "./datafile.root",
	  int firstevent      = 0,
	  int nevents       = -1, 
	  int firstpixel    = 0,
	  int npixel        = -1,
	  bool produceGraphic = false
	)

	the baseline and its rms is calculated for each pixel based on the data,
	given in the datafile.
	the results are appended to a textfile
	and the histograms ,which were used for caluculation, as well as some
overviews are stored in a root file.
	the 4 ints: firstevent, nevents, firstpixel, npixel can be used to calculate
only for a subset
	the last bool can be set to true, which will open 2 Canvases with overview
histograms.

	for automatic production of baseline analysis one can call this macro like
this:
e.g.
	root -l -q fbsl.C++'("/data00/fact-construction/raw/2011/10/26/20111026_036.fits.gz", "/data00/fact-construction/raw/2011/10/26/20111026_031.drs.fits.gz", "./fbsl.txt", "./20111026_036.root")'

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

fpeak_cfd.C		ROOT macro creating an amplitude spektrum for each pixel

int fpeak(
  char *datafilename    = "data/20111016_013.fits.gz",
  const char *drsfilename = "../../20111016_011.drs.fits.gz",
  const char *OutRootFileName = "../analysis/fpeak_cdf.Coutput.root",
  int firstevent      = 0,
  int nevents       = -1,
  int firstpixel      = 0,
  int npixel        = -1,
  bool spikeDebug = false,
  int avg1    = 14,
  int avg2    = 8,
  int verbosityLevel = 1, // different verbosity levels can be implemented here
  bool ProduceGraphic = true
 )

the peaks are search, using the constant fraction discriminator, implemented
as a FIR filter, which outputs a waveform, which rising edge zero crossings
show the position of a peak.

the two integers 'avg1' and 'avg2' are still present for debugging... 
two sliding average filters are beeing used, and these are the HALFwidths of
these filters.

The amplitude spektra are produced as a TH2F with the pixels on its x-Axis.
For further analysy the ROOT macro gainfit.C may be used...


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

gainfit.C ROOT macro for analysing the amplitude spektra of fpeak_cfd.C

this is far from beeing any good, but have a look yourself.

call it like this:
gainfit("rootfilename.root", "textoutfilename.txt" , false);

its short ... so I'd rather not explain it here.
I guess one can try for many other fit functions, and play with Parameter
bounds, but I had no time yet.
Thomas Krähenbühl once send me a mail containing a lot of ideas, and I guess
in gainanalysis.C there is a lot more ... 
these scripts should maybe be joined soon ...somehow.
D.Neise 20111104


