README of FACT svntools/rootmacros ++++++++++++++++++++++++++++++++++ ROOT version on ISDC fact cluster: /opt/root5.18.x86_64/bin/root for testing. ROOT macros: ============ fana2.C view the DRS data of a pixel, before and after various filter algorithms fbsl.C compute the baseline for all pixels, save the values in a txt file and the histograms in a ROOT file fpeak_cdf.C extract the single photon spectra gainfit.C analyses the amplitude spektra of fpeak_cfd.C flightpulser.C ROOT macro for plotting the amplitudes of the external lightpulser tpeak.C ROOT macros to produce overlays of data around a found peak in a given window. GetDrsOffset.C ROOT macro calculating the DRS Offset calibration constants Calling root in batch mode (helpful for automatization): ======================================================== 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")' see run.py for an example on how to run for instance fbsl.C on a list of data + calibration files Detailed Description of macros ============================== fana2.C ROOT macro for viewing pipeline data function declaration: int fana2( char *datafilename = "../raw/20110916_025.fits", // input file fits or fits.gz const char *drsfilename = "../raw/20110916_024.drs.fits", // DRS calibration file drs.fits or drs.fits.gz int pixelnr = 0, // which pixel in range(1440) int firstevent = 0, // first event to display int nevents = -1 ) // number of events to display description: the raw data are read and the drs calibration is applied spikes (DRS feature) are removed (replaced by the average of the neighboring channels a sliding average filter is applied, default length: 16 slices a constant fraction disciminator filter is applied online display: canvas 1: DRS Waveform 1) raw DRS pipeline 2) estimator for spike detection DRS pipeline 3) correct raw data (spikes removed) canvas 2: filtered DRS Waveform 1) sliding average FIR filter response 2) 1) + constant fraction discriminator FIR filter respones 3) 2) + sliding average FIR filter respone ( not used just left for historical reasons ) remarks: region of interest of the data file and the drs calibration file must agree ------------------------------------------------------------------------------------ fbsl.C ROOT Macro computing the baseline for each pixel function declaration: 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 ) description: estimatin of the baseline (following T. Ph. Kraehenbuehl: histogram the concents of all slices and all events individually for each pixel the value with the maximum bin content corresponds to the baseline create summary histograms with the estimated baselines create summary histograms with the rms values of the single pixel histo's output: text file with the estimated baseline values root file containing summary histograms for baseline estimates and rms individual histogram of each single pixel remarks: the rms is not the rms of the baseline, but the rms of the complete pixel histograms the 4 ints: firstevent, nevents, firstpixel, npixel can be used to perform the calculatation on a subset if produceGraphic == true, two Canvases with overview histograms are opened ----------------------------------------------------------------------------------------------- fpeak_cfd.C ROOT macro creating an amplitude spektrum for each pixel function declaration: 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 ) description: 1) using the constant fraction discriminator FIR filtered data peaks of single photons are searched 2) a negative slope zero crossings indicates the position of a peak 3) additional cuts confirm the single photon peak and verify irs separation from other peask in order to avoid overlaps of several pulses 4) the amplitudes of the identified peaks are histogrammed in a 2d histo ( amplitude vs pixel ) outputs: root file containing the 2d histogram of the amplitudes vs pixel remark: the two integers 'avg1' and 'avg2' are still present for debugging... two sliding average filters are used, and these are the HALFwidths of these filters. ----------------------------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------------------------- flightpulser.C ROOT macro for plotting the amplitudes of the external lightpulser call it e.g. like this root flightpulser.C+'("data/20111029_017.fits.gz","data/20111029_013.drs.fits.gz","../analysis/20111029_017-013_fpeak_cfd.root", 0, 100, 0,-1)' to look at the amplitudes of all camera pixel for 100 events. you get a color coded TH2F so you can look at the amplitude distribution yourself. this macro is based on fpeak_cdf.C pretty much. I basically use the same steps, but in the end I just fill the absolute maximum into the TH2F. The macro is pretty slow (about 1.5 min for 100 full camera events) so I switched off the sliding averages... but it didn't help much... I am still not sure how to improve the speed of these macros..... ----------------------------------------------------------------------------------------------- tpeak.C ROOT macros to produce overlays of data around a found peak in a given window. int tpeak( 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 OverlayWindowLeft = 50, int OverlayWindowRight = 150, int verbosityLevel = 1, // different verbosity levels can be implemented here bool ProduceGraphic = true ) call it like this, if you want to overlay a certain number of peaks for a single channel tpeak("data/20111029_017.fits.gz","data/20111029_013.drs.fits.gz","test.root",0,1000,333,1,true,0,0,50,150,1,true) set the first bool 'spikeDebug' to false in order to overlay quicker ... every 50th event the canvas is updated. depending on what kind of peaks you like to detect the sliding average filters should be set to e.g. 14,8 for singles in a quiet G-APD pedestal run or 0,0 if you want to see just every thing that might be a signal... the window size 50,150 means .. 50 slices to the left of the maximum and 150 to the right. there is a bit of cleaning included in the file, maybe you want to switch it off, then just search for the calls of these methods... removeMaximaBelow( *zXings, 3.0); removeRegionWithMaxOnEdge( *zXings, 2); removeRegionOnFallingEdge( *zXings, 100); and comment them out or play with the settings. they are defined in zerosearch.C, which is maybe a bad choice... --------------------------------------------------------------------------------------- GetDrsOffset.C ROOT macro calculating the DRS Offset calibration constants -- TESTING -- In case you have taken a file, which is good for calibrating the DRS Offset, then you can calculate the offset using this macro. It just calculates the mean value and the RMS for all DRS bins of all pixels in the file, for the number of events you like. The output is two TH2Fs, which contain all requested data on the one hand and on the other hand are good for having an overview. call it like this: GetDrsOffset("path/20111111_001.fits.gz") GetDrsOffset("path/20111111_001.fits.gz", "foo/output.root") saves the output to a root file GetDrsOffset("path/20111111_001.fits.gz", "", "bar/test.bin") saves the output to a binary file. GetDrsOffset("path/20111111_001.fits.gz", "foo/out.root", "bar/test.bin", false, -1) produces all output, but does not open a ROOT Canvas. -1 : means process all events in the given file.