Vetra ROOT Scripts

ROOT ( http://root.cern.ch/ ) is a CERN data analysis framework, based around C++. It has a lot of built-in functions specifically designed to deal with particle physics experiments. The "NTuple" and histogram output files produced by Vetra use the ROOT data format.

Below are a series of scripts which may be useful for data analysis after running Vetra. Please feel free to add any scripts you've written.

Scripts for improving output NTuple files

As described in the step-by-step guide, it's useful to do some additional processing on the output NTuple files before looking at the data. Additionally, we may want to join NTuple files together, for example to combine data sets taken under different timing conditions in order to determine when the output signal is highest.

VetraSortSource_window.cpp

As mentioned elsewhere, if we take n samples every time a trigger occurs, each set of n samples won’t necessarily end up in the output file in the correct order. So, the script above is needed to do re-ordering. The output of the script is a new NTuple file with the updated trees, which will take the same name as the input file, but with the prefix “Sort_” added.

The script sorts the n timebins taken during MIP tests into the correct order, and tags each sample with the time it occurred. The script also adds a BadStrip flag to the data. Within the script, there is an array where you can list the bad strips on the detector, and any hit on these strips will have BadStrip=1, making it easy to exclude these from analysis. Note that the set of bad strips is currently set up to deal with a particular 3D strip detector – it should be changed to match whatever detector you’re using!

The syntax you use to run the script is below. The first argument is the root file containing the NTuple data, in inverted commas. The second argument WindowDelay is a number, and should be set to match the delay applied to the 5ns trigger acceptance window. (The second argument is just used to calculate the time at which each sample was taken.)

sort("NTupleFileName.root",!WindowDelay)

e.g. sort("NTuple_3Ddetector_5samples_20nsdelay",20)

VetraSortSource_single.cpp

With single samples, we don’t actually need to reorder, but we still need to add the BadStrip flag and the SampleTime variable (which is simply given as an argument).

Syntax: (char rootFile[], int SampleTime)

CombineFiles.cpp

This script can be used to combine the LCMS and Cluster monitor NTuples from several different files. The script is called with combine() after it has been loaded; the names of the files to be combined has to be set within the script file.

When using the TELL1, we can take samples at 25ns intervals, and we can control the timing of the first sample relative to the trigger. So, we can do one test with sampling at 0ns, 25ns, 50ns, 75ns and 100ns, a second test where we sample at 5ns, 30ns, 55ns, 80ns and 105ns... etc. When we have all 5 data files, we can use this script to combine them in order to find out where the peak of the pulse occurs.

Data analysis script

This single script, SourceAnalysis.cpp, contains a variety of different data processing functions, most of which are listed below. The unlisted ones are essentially clones of other functions, that have been modified to deal with specific situations (such as analysis from a test beam).

The first part of the script is a function describing a Landau convolved with a Gaussian, taken from http://root.cern.ch/root/html/examples/langaus.C.html. This is then used by functions such as makeLandau() etc.

loadFile(char rootFile[])

Simply allows you to load a file, in preparation for later steps. Most of the functions defined in the script don’t take arguments; instead, you use loadFile to select the file you want to use, and then modify the script to fine-tune the processing

makeLandau()

Before using this, use loadFile to load an NTuple file. Takes the “ClusterHit” tree from the current file, plots the spectrum, and fits with a Landau convoluted with a Gaussian. It returns the graph and the fit parameters. You need to alter the script to choose the cuts you want to make on the data. For example, BadStrip==0 means we only take data from strips that aren’t bad, and we could also select a specific SampleTime.

makeLandauReverse() / makeLandauNeg()

These are versions of makeLandau which deal with negative-going signals, either by inverting the original data before making the fit, or keeping the data as it is and using a negative version of the fitting function.

lcmsnoise(), pednoise(), bothnoise()

After loading a histogram file, these functions will calculate the noise sigma on each strip after the LCMS stage, after the pedestal stage, or both (superimposing.the result on a single graph).

pulsehistSource()

Load an NTuple file first. This function makes a histogram showing ADC values from the LCMS stage vs time, giving the shape of the peak.

pulseshapeSource()

Like the above, except it finds the mean value in each timebin, to give a profile of the pulse shape.

A couple of histogram and n-tuple root data files are attached below as examples. The histogram combines data from all the events during a run, so you can see the general behaviour such as noise, but can't select specific events. The n-tuple contains event-by-event information, and so cuts can be made.

Hist_PlanarRetest_newset_MIP_single_120V_FIRFilter.root

NTuple_PlanarRetest_newset_MIP_single_120V_FIRFilter.root

Improved pulse-shape-finding process

In order to find the full pulse shape, including undershoot etc., we effectively need a 2-step process:

  1. Look at the time bin where we expect the peak of the pulse to occur, and pick out the strips that have seen a hit.
  2. Go to the other time bins (corresponding to the rising and falling edges of the pulse, and the undershoot) and grab the data from the strips that were hit.

However, LHCb software is designed to deal with a series of independent events, which can be processed in parallel. So, Vetra isn't able to leap back and forwards between samples taken at different times. As a result, finding the full pulse shape becomes a more convoluted process.

PROCEDURE

When running in 5-sample mode, make MIP measurements with the trigger acceptance window set to 0, 5, 10, 15, 20ns.

In Vetra, decode the each file twice, using different output file names. The first time, go into the TELL1Checkers.opts option file, and set the option VeloLCMSMoni.WriteAll=1;

This will generate an extremely large output file, containing all the strip data, regardless of whether a hit occurs or not.

The second time, set this WriteAll option back to 0. This will mean we only write out data from strips that have been hit, as normal.

For each pair of output files, use the script PulseTreesSource.cpp. It takes as its arguments the two file names and the particular window delay setting as shown below.

sortPulse(char eventFile[],char hitFile[],int WindowDelay)

This script produces an output file containing the data from all 5 time bins for each hit.

Finally, this will produce a total of 5 output files, which must be joined together using this CombineFilesLCMSonly.cpp script. This is much like the CombineFiles.cpp script above, except it only looks at the LCMS monitor.

The pulseshapeSource() and pulsehistSource() functions in the SourceAnalysis.cpp script file can then be useful to plot the signal vs time.

-- DavidPennicard - 31 Jul 2008

Topic attachments
I Attachment History Action Size Date Who Comment
C source code filecpp CombineFiles.cpp r1 manage 3.6 K 2008-07-31 - 11:57 DavidPennicard  
C source code filecpp CombineFilesLCMSonly.cpp r1 manage 2.7 K 2008-07-31 - 11:57 DavidPennicard  
Unknown file formatroot Hist_PlanarRetest_newset_MIP_single_120V_FIRFilter.root r1 manage 483.7 K 2008-10-09 - 10:58 DavidPennicard  
Unknown file formatroot NTuple_PlanarRetest_newset_MIP_single_120V_FIRFilter.root r1 manage 2061.7 K 2008-10-09 - 10:57 DavidPennicard  
C source code filecpp PulseTreesSource.cpp r1 manage 13.3 K 2008-07-31 - 11:59 DavidPennicard  
C source code filecpp SourceAnalysis.cpp r1 manage 24.0 K 2008-07-31 - 11:57 DavidPennicard  
C source code filecpp VetraSortSource_single.cpp r1 manage 10.6 K 2008-07-31 - 11:57 DavidPennicard  
C source code filecpp VetraSortSource_window.cpp r1 manage 13.7 K 2008-07-31 - 11:56 DavidPennicard  
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2009-01-09 - DavidPennicard
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback