Guide to the code developped in Edinburgh

If you want the code, please follow the following steps:

  • make sure you are setup to use the Edinburgh group CVS repository ( check for instructions here )
  • under your working directory do:
    • cvs co Analysis/Bs2Jpsiphi/ThreeAngles

A documentation page is found here ( but not guarantied to be the latest)

Overview of the code

There are several directories under the main tree. All of them (sort of) self-explanatory:

  • src: source code
  • exe: compiled binaries are put in this directory; there are also some examples for the input parameter files for generation and fitting
  • plots: classes and macros to analyse the output from each fit
  • doc: contains a configuration file to create documentation with doxygen
  • ganga: set of scripts (root and python) to be used with Ganga
  • lsf: set of scripts to submit jobs to the lsf batch system

This code does not make use of RooFit. It is a plain C/C++ code that uses ROOT framework for ntuples, plotting and fitting (using TMinuit). In addition, the numerical integrations are done using the MathMore library included in ROOT. The library depends on the GNU Scientific Library (or GSL). This is a very powerful collection of libraries. Usually you won't need to care if these are installed in your machine, but beware that at present the code strongly depends on these libraries.

Source code in more detail

The best documentation for the code is the code itself. Instructions on how to create a doxygen document are under the doc directory. A current version is at 3angle analysis doxygen (but might be out of date). Some explanations to where to start:

The code aims at two processes: the generation of the ToyMC data and the fitting.

For generation the relevant classes are: RandomDists and ConvolGenerator. The first one is the most basic one and generates in the ideal case (no resolution). The second class inherits from the first one but obviously re implements the needed functionality. The main method for generation is called RunExperiment.

For fitting, the files UMLlh_Fit{h,C} contain the TMinuit implementation which include different FCN functions. Each FCN is associated to the corresponding study (ideal, resolution, ideal+ext constraints ...).

The class MCToyData deals with the input and output of the event data ( ntuple containing all the variables).

PDFs

The collection of PDFs and other important function are in the following files:

  • PDFs.{h,C}
  • PDFsWRes.{h,C}
  • PDFsBkg.{h,C}
  • AngularTerms.h
  • Amplitudes.h
  • Acceptances.h
  • IntAmplitudes.h
  • IntAmplitudesWLimits.h

For resolution studies, a collection of C functions deals with the numerical integration: ResModels{h,C} ; GSLHelpers.{h,C}

Compiling and running

Make sure your system knows how to find ROOT. Enter the src directory and just type make. Compiled binaries are under the exe directory:

  • generate: produces toymc data with no resolution.
  • generateWC: produces toymc data with resolution (+acceptance +background)
  • Note on the naming convention: the name of the created root file is made up of the following segments: phis_study_ + your option + _ + run number + .root where 'your option' is an option of your choice and 'run number' is an integer identifying each file when using the multiple generation mode (will always be 0 if generating a single file. An offset can be used to change it).
  • fitdata: fit to toymc data (data is in the form of a root file with the naming convention followed in generation)
  • genResolution: generates a file with fixed or event-by-event propertime resolutions

All the executables have their own little help if no arguments are given.

There is no binary that executes the two main processes in one single executable. It can be easily implemented in a single script (as in fact in done when running on the GRID - have a look to the scripts under ../ganga/).

Warning, important For the resolution studies: you will need to generate a separate (ascii) file with the corresponding resolution per event. The default is to use fixed resolutions. Event-by-event resolutions are generated according to Luis' prescription. In both cases you will have to use the genResolution executable . In script mode, the function that generates the resolution is called evtbyevtResolution and it is implemented in file PDFsWRes.C. (this can be better implemented and I have added to the "improvements" section. The reason to use a separate file was to speed up the generation since this also uses an acceptance/rejection method).

Input parameter files

At the moment there are 3 input parameter files: 2 for generation and 1 for fitting. The parameters for fitting are sort of mismatched. This is not good (see the "possible improvements" section) . The following table shows the content of each file and some of the nominal values used:

Parameter For generation 1 For gereneration 2 For fitting
1 Gs 0.68 0.68   0.68
2 DG 0.10 0.10   0.10
3 Rt 0.20 0.20   0.20
4 R0 0.60 0.60   0.60
5 d1 0.0 0.0   0.0
6 d2 3.14 3.14   3.14
7 phis -0.04 -0.04   -0.04
8 Dms 17.77 17.77   17.77
9 wtag 0.30 0.30   0.30
10 fsig 1.0 1.0   ptres =0.03
11 Nkg tau 1.0 1.0   f1 =0.80
12 ptres - 0.03   mu1 =0.0022
13 f1 - 0.80   s1 =0.0584
14 mu1 - 0.0022   mu2 =-0.111
15 s1 - 0.0584   s2 =0.471
16 mu2 - -0.111   tag =1.0
17 s2 - 0.471   fsig =1.0
18 angres - 1.0   Bkg tau =1.0
19 accflag - 1.0(0.0)   bkgnorm =1.0
20 acck0 - 0.15   e_xt(dms) =0.007
21 Ns - 131000   e_xt(wtag) =0.0036
22 Nb - 15720   acck0 =0.15
23 Nobs - 146720   Ns = 131000
24 MB - 5.369   Nb = 15720
25 sigma MBs - 0.010   Nobs =146720
26 Bkg kappa - 1.000   MB = 5.369
27 - - -   sigma MBs =0.010
28 - - -   Bkg kappa = 1.000

Notes:

  • generation 1 = no resolution; generation 2 = with resolution(++)
  • as you can see parameters for generation and fitting don't necessary match in their order
  • fsig (fraction of signal not B/S): if it is 1.0 then no background model is used
  • tbkg: (parameter in exponential background model)
  • f1, mu1, s1 (mu2, s2) are the parameter values for a double Gaussian model (as suggested in Gerhard's 2003 note)
  • angres: angular resolution (not in use)
  • accflag, acck0: if accflag >= 1 then the acceptance model is ON and acck0 is the one parameter it takes
  • For fitting: tag,bkgnorm are parameters needed during the execution and therefore their input values are meaningless
  • e_xt(dms) and e_xt(wtag): are the input values for the external constraints on the errors of Dms and wtag

Examples:

Examples of use

To generate data in the ideal case:

cd src/
make clean
make
...
cd ../exe
./generate inputParameter.txt myTest 131000
...
RandomDists (no convolution)> RunExperiment starts now.
RunExperiment> 10000
RunExperiment> event=0 0.694228 2.44652 1.47137 0.855783        0
produceData> Data was successfully generated.

To generate data with resolution:

./generateWC inputParameterWRes.txt myTest2 131000
...
ConvolGenerator> resolution parameters:
p:0     0.03
p:1     0.8
p:2     0.0022
p:3     0.0584
p:4     -0.1114
p:5     0.471
p:6     0.2
SelectSignalType> calculating normalisation factors...
opening files:
// phis_resolutions.dat: event by event resolutions. Total data: 131000
ConvolGenerator> RunExperiment starts now. 
...(will take longer)...
RunExperiment> event=0 0.013621 1.36653 0.793704        -3.03615        0
produceData> Data was successfully generated.

To fit to data:

Scripts

There are several scripts that you can use for Ganga and LSF job submission.

To do list

  • Clean up the src directory: contains a lot more than needed. Some of the code is for testing and plotting and can be removed from there
  • Add a class for the toy MC event data and incorporate this into the fitting routines
  • A doxygen documentation page
  • The first fit results did not included the "edm" value. In consequence I added a backward compatibility feature that needs to be removed from the fitdata function (and also in the plots/!FitResults class)
  • See the next section for more TODO...

Improvements to the code

The code is always in evolution and good ideas occur at any time. I'll list here some suggestions and improvements that could be made to the current version of the full angular analysis code.

  • Better way of dealing with the event-by-event resolution
  • Break into smaller blocks all of the common bits in the PDFs: there are lots of terms which could be coded once example: sin(phis)sin(dms t)exp(-Gst)
  • With the previous point in mind, one could also code the analytic expressions for the time integrals, and therefore remove the numerical integration
  • The input parameter files are not unified (there are three different files: 1 for generation without resolution; 1 for generation with resolution incorporated; 1 for fitting)
  • The input parameter files could also contain more information (external errors, parameter names) ... a Parameter class could be added for example
  • Changing basis: by default, the pdf works out the angles in the Transversity basis but if you want to change it to the Helicity you will need to do it in the code (file PDFs.C). This is quite easy to do but needs then recompilation. Bear in mind the normalization factor w.r.t. to the angles changes as well: n(transversity) = 0.5 n(helicity).
  • Different FCN functions could be better implemented (?)
  • External constraints are hard coded -> make it more general
  • As usual, some better naming of files, classes and methods is always a good idea
  • Use of Minuit2 (?)
  • any other ideas ...

EvtGen validation

This code has been tested against EvtGen, the official event generator in Gauss. Distributions of the three angles and propertime were compared with same input data. For example, here is the plot of the theta_tr (red: toy mc ; black: evtgen ):

  • Angle comparison (theta_tr):
    angComp_cos_theta.png

-- AndresOsorio - 21 Jul 2007

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng angComp_cos_theta.png r1 manage 10.6 K 2007-08-13 - 20:45 AndresOsorio Angle comparison (theta_tr)
Texttxt inputParameters.txt r1 manage 0.1 K 2007-08-03 - 17:15 AndresOsorio Example of input parameter with no-resolution
Texttxt inputParametersWRes.txt r1 manage 0.1 K 2007-08-03 - 17:14 AndresOsorio Example of input parameter with resolution
Texttxt inputParametersWResAcc.txt r2 r1 manage 0.1 K 2007-08-03 - 17:21 AndresOsorio Example of input parameter with resolution and acceptance
Texttxt inputParametersWResBkgAcc.txt r2 r1 manage 0.1 K 2007-08-03 - 17:21 AndresOsorio Example of input parameter with resolution, background and acceptance
Edit | Attach | Watch | Print version | History: r17 < r16 < r15 < r14 < r13 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r17 - 2007-12-05 - AndresOsorio
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback