Difference: HowToCalculateLuminosity (1 vs. 2)

Revision 22010-09-07 - ThomasBird

 
META TOPICPARENT name="HowTos"

How to Calculate Luminosity

Creating the ntuple

You will need to make sure that the luminosity data is in the ntuple. To do this ckeck that there is a GetIntergratedLuminosity branch in your ntuple if there is move onto the next section, else continue.

You will need to add the following lines to the davinci python file which generates your ntuple.

DaVinci().Lumi = True
DaVinci().TupleFile = 'B2Dpi.root'

The Lumi option has recently (the end of July 2010 ish) been set to true by default. This cases problems since it overwrites where the ntuplesvc put your ntuple. So if you have a line like

NTupleSvc().Output =  [ "FILE1 DATAFILE='B2Dpi_post_st_pete_580-onwards-test.root' TYP='ROOT' OPT='NEW'"]

it now does nothing, so you can remove it and put the file name into the above TupleFile variable.

Analysing the ntuple

In your root macro you will need to add some stuff to open up the new branch of the ntuple and then loop over the values stored in it.

Changed:
<
<
The code I use is below, the final values of the luminosity and its error are stored in totLumi and totLumiErr, so you will need to print or save these.
>
>
Attached is a macro which just calculates the luminosity. Run it with root with root like so
 
Added:
>
>
root 'Lumi.C(false, "/opt/ppd/lhcb/tbird/CKM-approved/ntuple/B2Dpi_str09.root",-1)'

or for some speed with the g++root script defined over here HowToCompileRootMacros

g++root Lumi.C && time ./Lumi.C.exe | tee output.txt

The code I use in my main macro is below, the final values of the luminosity and its error are stored in totLumi and totLumiErr, so you will need to print or save these.

 
TChain *lumiChain = new TChain("GetIntegratedLuminosity/LumiTuple");
lumiChain->Add(filename);

Float_t         IntegratedLuminosity;
Float_t         IntegratedLuminosityErr;

TBranch        *b_IntegratedLuminosity;
TBranch        *b_IntegratedLuminosityErr;

lumiChain->SetBranchAddress("IntegratedLuminosity", &IntegratedLuminosity, &b_IntegratedLuminosity);
lumiChain->SetBranchAddress("IntegratedLuminosityErr", &IntegratedLuminosityErr, &b_IntegratedLuminosityErr);  

Long64_t lnentries = lumiChain->GetEntries();
Long64_t lnbytes = 0, lnb = 0;

Float_t totLumi = 0.0;
Float_t totLumiErr = 0.0;

for (Long64_t ljentry=0; ljentry<lnentries;ljentry++) {
    lnb = lumiChain->GetEntry(ljentry);
    lnbytes += lnb;

    totLumi += IntegratedLuminosity;
    totLumiErr += IntegratedLuminosityErr;
}
Changed:
<
<
-- ThomasBird - 2010-08-19
>
>

Lumi Macro

Added:
>
>
  • Lumi.C: Macro to calculate the intergrated luminosity in an ntuple

META FILEATTACHMENT attachment="Lumi.C" attr="" comment="Macro to calculate the intergrated luminosity in an ntuple" date="1283852490" name="Lumi.C" path="Lumi.C" size="49857" stream="Lumi.C" tmpFilename="/usr/tmp/CGItemp21636" user="ThomasBird" version="1"
 

Revision 12010-08-19 - ThomasBird

 
META TOPICPARENT name="HowTos"

How to Calculate Luminosity

Creating the ntuple

You will need to make sure that the luminosity data is in the ntuple. To do this ckeck that there is a GetIntergratedLuminosity branch in your ntuple if there is move onto the next section, else continue.

You will need to add the following lines to the davinci python file which generates your ntuple.

DaVinci().Lumi = True
DaVinci().TupleFile = 'B2Dpi.root'

The Lumi option has recently (the end of July 2010 ish) been set to true by default. This cases problems since it overwrites where the ntuplesvc put your ntuple. So if you have a line like

NTupleSvc().Output =  [ "FILE1 DATAFILE='B2Dpi_post_st_pete_580-onwards-test.root' TYP='ROOT' OPT='NEW'"]

it now does nothing, so you can remove it and put the file name into the above TupleFile variable.

Analysing the ntuple

In your root macro you will need to add some stuff to open up the new branch of the ntuple and then loop over the values stored in it.

The code I use is below, the final values of the luminosity and its error are stored in totLumi and totLumiErr, so you will need to print or save these.

TChain *lumiChain = new TChain("GetIntegratedLuminosity/LumiTuple");
lumiChain->Add(filename);

Float_t         IntegratedLuminosity;
Float_t         IntegratedLuminosityErr;

TBranch        *b_IntegratedLuminosity;
TBranch        *b_IntegratedLuminosityErr;

lumiChain->SetBranchAddress("IntegratedLuminosity", &IntegratedLuminosity, &b_IntegratedLuminosity);
lumiChain->SetBranchAddress("IntegratedLuminosityErr", &IntegratedLuminosityErr, &b_IntegratedLuminosityErr);  

Long64_t lnentries = lumiChain->GetEntries();
Long64_t lnbytes = 0, lnb = 0;

Float_t totLumi = 0.0;
Float_t totLumiErr = 0.0;

for (Long64_t ljentry=0; ljentry<lnentries;ljentry++) {
    lnb = lumiChain->GetEntry(ljentry);
    lnbytes += lnb;

    totLumi += IntegratedLuminosity;
    totLumiErr += IntegratedLuminosityErr;
}

-- ThomasBird - 2010-08-19

 
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