From b1eb9ae6872faf9d0673bbdd608198496a2efa9c Mon Sep 17 00:00:00 2001 From: Rene Brun <Rene.Brun@cern.ch> Date: Thu, 17 Aug 2000 16:31:12 +0000 Subject: [PATCH] Add a new tutorial h1anal.C. This tutorial illustrates the use of code automatically generated by TTree::MakeSelector. The file h1anal.C has plenty of comments explaining the principle and the various ways to run this class. The data sets used by this tutorial have been copied to the Root Web site. For the location and use, see the fiel h1anal.C git-svn-id: http://root.cern.ch/svn/root/trunk@490 27541ba8-7e3a-0410-8455-c3a389f83636 --- tutorials/h1anal.C | 272 ++++++++++++++++++ tutorials/h1anal.h | 673 ++++++++++++++++++++++++++++++++++++++++++++ tutorials/h1chain.C | 7 + 3 files changed, 952 insertions(+) create mode 100644 tutorials/h1anal.C create mode 100644 tutorials/h1anal.h create mode 100644 tutorials/h1chain.C diff --git a/tutorials/h1anal.C b/tutorials/h1anal.C new file mode 100644 index 00000000000..b6f87b506d4 --- /dev/null +++ b/tutorials/h1anal.C @@ -0,0 +1,272 @@ +// Example of analysis class for the H1 data. +// ========================================= +// +// This file uses 4 large data sets from the H1 collaboration at DESY Hamburg. +// One can access these data sets (277 MBytes) from the standard Root web site +// at: ftp://root.cern.ch/root/h1anal/ +// The Physics plots below generated by this example cannot be produced when +// using smaller data sets. +// +// There are several ways to analyze data stored in a Root Tree +// -Using TTree::Draw: This is very convenient and efficient for small tasks. +// A TTree::Draw call produces one histogram at the time. The histogram +// is automatically generated. The selection expression may be specified +// in the command line. +// +// -Using the TTreeViewer: This is a graphical interface to TTree::Draw +// with the same functionality. +// +// -Using the code generated by TTree::MakeClass: In this case, the user +// creates an instance of the analysis class. He has the control over +// the event loop and he can generate an unlimited number of histograms. +// +// -Using the code generated by TTree::MakeSelector. Like for the code +// generated by TTree::MakeClass, the user can do complex analysis. +// However, he cannot control the event loop. The event loop is controlled +// by TTree::Process called by the user. This solution is illustrated +// by the current code. The advantage of this method is that it can be run +// in a parallel environment using PROOF (the Parallel Root Facility). +// +// A chain of 4 files (originally converted from PAW ntuples) is used +// to illustrate the various ways to loop on Root data sets. +// Each data set contains a Root Tree named "h42" +// The class definition in h1anal.h has been generated automatically +// by the Root utility TTree::MakeSelector using one of the files with the +// following statement: +// h42->MakeSelector("h1anal"); +// This produces two files: h1anal.h and h1anal.C (skeleton of this file) +// The h1anal class is derived from the Root class TSelector. +// +// The following members functions are called by the TTree::Process functions. +// Begin: called everytime a loop on the tree starts. +// a convenient place to create your histograms. +// Notify(): This function is called at the first entry of a new Tree +// in a chain. +// ProcessCut: called at the beginning of each entry to return a flag +// true if the entry must be analyzed. +// ProcessFill: called in the entry loop for all entries accepted +// by Select. +// Terminate: called at the end of a loop on a TTree. +// a convenient place to draw/fit your histograms. +// +// To use this file, try the following session +// +// Root > gROOT->Time(); //will show RT & CPU time per command +// +//==> A- create a TChain with the 4 H1 data files +// The chain can be created by executed the short macro h1chain.C below: +// { +// TChain chain("h42"); +// chain.Add("$H1/dstarmb.root"); // 21330730 bytes 21920 events +// chain.Add("$H1/dstarp1a.root"); // 71464503 bytes 73243 events +// chain.Add("$H1/dstarp1b.root"); // 83827959 bytes 85597 events +// chain.Add("$H1/dstarp2.root"); // 100675234 bytes 103053 events +// //where $H1 is a system symbol pointing to the H1 data directory. +// } +// +// Root > .x h1chain.C +// +//==> B- loop on all events +// Root > chain.Process("h1anal.C") +// +//==> C- same as B, but in addition fill the event list with selected entries. +// The event list is saved to a file "elist.root" by the Terminate function. +// To see the list of selected events, you can do elist->Print("all"). +// The selection function has selected 7525 events out of the 283813 events +// in the chain of files. (2.65 per cent) +// Root > chain.Process("h1anal.C","fillList") +// +//==> D- Process only entries in the event list +// The event list is read from the file in elist.root generated by step C +// Root > chain.Process("h1anal.C","useList") +// +//==> E- the above steps have been executed via the interpreter. +// You can repeat the steps B, C and D using the script compiler +// by replacing "h1anal.C" by "h1anal.C+" or "h1anal.C++" +// +// in a new session with ,eg: +// +//==> F- Create the chain as in A, then execute +// Root > chain.Process("h1anal.C+","useList") +// +// The commands executed with the 4 different methods B,C,D and E +// produce two canvases shown below: +// begin_html <a href="gif/h1anal_dstar.gif" >the Dstar plot</a> end_html +// begin_html <a href="gif/h1anal_tau.gif" >the Tau D0 plot</a> end_html + +#include "h1anal.h" +#include "TH2.h" +#include "TF1.h" +#include "TStyle.h" +#include "TCanvas.h" +#include "TLine.h" +#include "TEventList.h" + +const Double_t dxbin = (0.17-0.13)/40; // Bin-width +const Double_t sigma = 0.0012; +TEventList *elist = 0; +Bool_t useList, fillList; +TH1F *hdmd; +TH2F *h2; + +//_____________________________________________________________________ +Double_t fdm5(Double_t *xx, Double_t *par) +{ + Double_t x = xx[0]; + if (x <= 0.13957) return 0; + Double_t xp3 = (x-par[3])*(x-par[3]); + Double_t res = dxbin*(par[0]*TMath::Power(x-0.13957, par[1]) + + par[2] / 2.5066/par[4]*TMath::Exp(-xp3/2/par[4]/par[4])); + return res; +} + +//_____________________________________________________________________ +Double_t fdm2(Double_t *xx, Double_t *par) +{ + Double_t x = xx[0]; + if (x <= 0.13957) return 0; + Double_t xp3 = (x-0.1454)*(x-0.1454); + Double_t res = dxbin*(par[0]*TMath::Power(x-0.13957, 0.25) + + par[1] / 2.5066/sigma*TMath::Exp(-xp3/2/sigma/sigma)); + return res; +} + +//_____________________________________________________________________ +void h1anal::Begin(TTree *tree) +{ +// function called before starting the event loop +// -it performs some cleanup +// -it creates histograms +// -it sets some initialisation for the event list + + //initialize the Tree branch addresses + Init(tree); + + //print the option specified in the Process function. + TString option = GetOption(); + printf("Starting h1anal with process option: %s\n",option.Data()); + + //some cleanup in case this function had already been executed + //delete any previously generated histograms or functions + gDirectory->Delete("hdmd"); + gDirectory->Delete("h2*"); + delete gROOT->GetFunction("f5"); + delete gROOT->GetFunction("f2"); + + //create histograms + hdmd = new TH1F("hdmd","dm_d",40,0.13,0.17); + h2 = new TH2F("h2","ptD0 vs dm_d",30,0.135,0.165,30,-3,6); + + //process cases with event list + fillList = kFALSE; + useList = kFALSE; + fChain->SetEventList(0); + delete gDirectory->GetList()->FindObject("elist"); + // case when one creates/fills the event list + if (option.Contains("fillList")) { + fillList = kTRUE; + elist = new TEventList("elist","selection from Cut",5000); + } + // case when one uses the event list generated in a previous call + if (option.Contains("useList")) { + useList = kTRUE; + TFile f("elist.root"); + elist = (TEventList*)f.Get("elist"); + if (elist) elist->SetDirectory(0); //otherwise the file destructor will delete elist + fChain->SetEventList(elist); + } +} + +//_____________________________________________________________________ +Bool_t h1anal::ProcessCut(Int_t entry) +{ +// Selection function to select D* and D0. + + //in case one event list is given in input, the selection has already been done. + if (useList) return kTRUE; + + // Read only the necessary branches to select entries. + // return as soon as a bad entry is detected + b_md0_d->GetEntry(entry); if (TMath::Abs(md0_d-1.8646) >= 0.04) return kFALSE; + b_ptds_d->GetEntry(entry); if (ptds_d <= 2.5) return kFALSE; + b_etads_d->GetEntry(entry); if (TMath::Abs(etads_d) >= 1.5) return kFALSE; + b_ik->GetEntry(entry); ik--; //original ik used f77 convention starting at 1 + b_ipi->GetEntry(entry); ipi--; + b_ntracks->GetEntry(entry); + b_nhitrp->GetEntry(entry); + if (nhitrp[ik]*nhitrp[ipi] <= 1) return kFALSE; + b_rend->GetEntry(entry); + b_rstart->GetEntry(entry); + if (rend[ik] -rstart[ik] <= 22) return kFALSE; + if (rend[ipi]-rstart[ipi] <= 22) return kFALSE; + b_nlhk->GetEntry(entry); if (nlhk[ik] <= 0.1) return kFALSE; + b_nlhpi->GetEntry(entry); if (nlhpi[ipi] <= 0.1) return kFALSE; + b_ipis->GetEntry(entry); ipis--; if (nlhpi[ipis] <= 0.1) return kFALSE; + b_njets->GetEntry(entry); if (njets < 1) return kFALSE; + + // if option fillList, fill the event list + if (fillList) elist->Enter(fChain->GetChainEntryNumber(entry)); + return kTRUE; +} + + +//_____________________________________________________________________ +void h1anal::ProcessFill(Int_t entry) +{ +// function called for selected entries only + + // read branches not processed in ProcessCut + b_dm_d->GetEntry(entry); //read branch holding dm_d + b_rpd0_t->GetEntry(entry); //read branch holding rpd0_t + b_ptd0_d->GetEntry(entry); //read branch holding ptd0_d + + //fill some histograms + hdmd->Fill(dm_d); + h2->Fill(dm_d,rpd0_t/0.029979*1.8646/ptd0_d); +} + +//_____________________________________________________________________ +void h1anal::Terminate() +{ +// function called at the end of the event loop + + //create the canvas for the h1anal fit + gStyle->SetOptFit(); + TCanvas *c1 = new TCanvas("c1","h1anal analysis",10,10,800,600); + c1->SetBottomMargin(0.15); + hdmd->GetXaxis()->SetTitle("m_{K#pi#pi} - m_{K#pi}[GeV/c^{2}]"); + hdmd->GetXaxis()->SetTitleOffset(1.4); + + //fit histogram hdmd with function f5 using the loglikelihood option + TF1 *f5 = new TF1("f5",fdm5,0.139,0.17,5); + f5->SetParameters(1000000, .25, 2000, .1454, .001); + hdmd->Fit("f5","lr"); + + //create the canvas for tau d0 + gStyle->SetOptFit(0); + gStyle->SetOptStat(1100); + TCanvas *c2 = new TCanvas("c2","tauD0",100,100,800,600); + c2->SetGrid(); + c2->SetBottomMargin(0.15); + + // Project slices of 2-d histogram h2 along X , then fit each slice + // with function f2 and make a histogram for each fit parameter + // Note that the generated histograms are added to the list of objects + // in the current directory. + TF1 *f2 = new TF1("f2",fdm2,0.139,0.17,2); + f2->SetParameters(10000, 10); + h2->FitSlicesX(f2,0,0,1,"qln"); + TH1D *h2_1 = (TH1D*)gDirectory->Get("h2_1"); + h2_1->GetXaxis()->SetTitle("#tau[ps]"); + h2_1->SetMarkerStyle(21); + h2_1->Draw(); + c2->Update(); + TLine *line = new TLine(0,0,0,c2->GetUymax()); + line->Draw(); + + //save the event list to a Root file if one was produced + if (fillList) { + TFile efile("elist.root","recreate"); + elist->Write(); + } +} diff --git a/tutorials/h1anal.h b/tutorials/h1anal.h new file mode 100644 index 00000000000..bba95dba107 --- /dev/null +++ b/tutorials/h1anal.h @@ -0,0 +1,673 @@ +////////////////////////////////////////////////////////// +// This class has been automatically generated +// (Wed Apr 19 21:47:55 2000 by ROOT version 2.24/02) +// from TTree h42/ +// found on file: Memory Directory +////////////////////////////////////////////////////////// + + +#ifndef h1anal_h +#define h1anal_h + +#include <TChain.h> +#include <TFile.h> +#include <TSelector.h> + +class h1anal : public TSelector { + public : + TTree *fChain; //pointer to the analyzed TTree or TChain + //Declaration of leaves types + Int_t nrun; + Int_t nevent; + Int_t nentry; + UInt_t trelem[192]; + UInt_t subtr[128]; + UInt_t rawtr[128]; + UInt_t L4subtr[128]; + UInt_t L5class[32]; + Float_t E33; + Float_t de33; + Float_t x33; + Float_t dx33; + Float_t y33; + Float_t dy33; + Float_t E44; + Float_t de44; + Float_t x44; + Float_t dx44; + Float_t y44; + Float_t dy44; + Float_t Ept; + Float_t dept; + Float_t xpt; + Float_t dxpt; + Float_t ypt; + Float_t dypt; + Float_t pelec[4]; + Int_t flagelec; + Float_t xeelec; + Float_t yeelec; + Float_t Q2eelec; + Int_t nelec; + Float_t Eelec[20]; + Float_t thetelec[20]; + Float_t phielec[20]; + Float_t xelec[20]; + Float_t Q2elec[20]; + Float_t xsigma[20]; + Float_t Q2sigma[20]; + Float_t sumc[4]; + Float_t sumetc; + Float_t yjbc; + Float_t Q2jbc; + Float_t sumct[4]; + Float_t sumetct; + Float_t yjbct; + Float_t Q2jbct; + Float_t Ebeamel; + Float_t Ebeampr; + Float_t pvtx_d[3]; + Float_t cpvtx_d[6]; + Float_t pvtx_t[3]; + Float_t cpvtx_t[6]; + Int_t ntrkxy_t; + Float_t prbxy_t; + Int_t ntrkz_t; + Float_t prbz_t; + Int_t nds; + Int_t rankds; + Int_t qds; + Float_t pds_d[4]; + Float_t ptds_d; + Float_t etads_d; + Float_t dm_d; + Float_t ddm_d; + Float_t pds_t[4]; + Float_t dm_t; + Float_t ddm_t; + Int_t ik; + Int_t ipi; + Int_t ipis; + Float_t pd0_d[4]; + Float_t ptd0_d; + Float_t etad0_d; + Float_t md0_d; + Float_t dmd0_d; + Float_t pd0_t[4]; + Float_t md0_t; + Float_t dmd0_t; + Float_t pk_r[4]; + Float_t ppi_r[4]; + Float_t pd0_r[4]; + Float_t md0_r; + Float_t Vtxd0_r[3]; + Float_t cvtxd0_r[6]; + Float_t dxy_r; + Float_t dz_r; + Float_t psi_r; + Float_t rd0_d; + Float_t drd0_d; + Float_t rpd0_d; + Float_t drpd0_d; + Float_t rd0_t; + Float_t drd0_t; + Float_t rpd0_t; + Float_t drpd0_t; + Float_t rd0_dt; + Float_t drd0_dt; + Float_t prbr_dt; + Float_t prbz_dt; + Float_t rd0_tt; + Float_t drd0_tt; + Float_t prbr_tt; + Float_t prbz_tt; + Int_t ijetd0; + Float_t ptr3d0_j; + Float_t ptr2d0_j; + Float_t ptr3d0_3; + Float_t ptr2d0_3; + Float_t ptr2d0_2; + Float_t Mimpds_r; + Float_t Mimpbk_r; + Int_t ntracks; + Float_t pt[200]; + Float_t kappa[200]; + Float_t phi[200]; + Float_t theta[200]; + Float_t dca[200]; + Float_t z0[200]; + Float_t covar[200][15]; + Int_t nhitrp[200]; + Float_t prbrp[200]; + Int_t nhitz[200]; + Float_t prbz[200]; + Float_t rstart[200]; + Float_t rend[200]; + Float_t lhk[200]; + Float_t lhpi[200]; + Float_t nlhk[200]; + Float_t nlhpi[200]; + Float_t dca_d[200]; + Float_t ddca_d[200]; + Float_t dca_t[200]; + Float_t ddca_t[200]; + Int_t muqual[200]; + Int_t imu; + Int_t imufe; + Int_t njets; + Float_t E_j[20]; + Float_t pt_j[20]; + Float_t theta_j[20]; + Float_t eta_j[20]; + Float_t phi_j[20]; + Float_t m_j[20]; + Float_t thrust; + Float_t pthrust[4]; + Float_t thrust2; + Float_t pthrust2[4]; + Float_t spher; + Float_t aplan; + Float_t plan; + Float_t nnout[1]; + +//List of branches + TBranch *b_nrun; + TBranch *b_nevent; + TBranch *b_nentry; + TBranch *b_trelem; + TBranch *b_subtr; + TBranch *b_rawtr; + TBranch *b_L4subtr; + TBranch *b_L5class; + TBranch *b_E33; + TBranch *b_de33; + TBranch *b_x33; + TBranch *b_dx33; + TBranch *b_y33; + TBranch *b_dy33; + TBranch *b_E44; + TBranch *b_de44; + TBranch *b_x44; + TBranch *b_dx44; + TBranch *b_y44; + TBranch *b_dy44; + TBranch *b_Ept; + TBranch *b_dept; + TBranch *b_xpt; + TBranch *b_dxpt; + TBranch *b_ypt; + TBranch *b_dypt; + TBranch *b_pelec; + TBranch *b_flagelec; + TBranch *b_xeelec; + TBranch *b_yeelec; + TBranch *b_Q2eelec; + TBranch *b_nelec; + TBranch *b_Eelec; + TBranch *b_thetelec; + TBranch *b_phielec; + TBranch *b_xelec; + TBranch *b_Q2elec; + TBranch *b_xsigma; + TBranch *b_Q2sigma; + TBranch *b_sumc; + TBranch *b_sumetc; + TBranch *b_yjbc; + TBranch *b_Q2jbc; + TBranch *b_sumct; + TBranch *b_sumetct; + TBranch *b_yjbct; + TBranch *b_Q2jbct; + TBranch *b_Ebeamel; + TBranch *b_Ebeampr; + TBranch *b_pvtx_d; + TBranch *b_cpvtx_d; + TBranch *b_pvtx_t; + TBranch *b_cpvtx_t; + TBranch *b_ntrkxy_t; + TBranch *b_prbxy_t; + TBranch *b_ntrkz_t; + TBranch *b_prbz_t; + TBranch *b_nds; + TBranch *b_rankds; + TBranch *b_qds; + TBranch *b_pds_d; + TBranch *b_ptds_d; + TBranch *b_etads_d; + TBranch *b_dm_d; + TBranch *b_ddm_d; + TBranch *b_pds_t; + TBranch *b_dm_t; + TBranch *b_ddm_t; + TBranch *b_ik; + TBranch *b_ipi; + TBranch *b_ipis; + TBranch *b_pd0_d; + TBranch *b_ptd0_d; + TBranch *b_etad0_d; + TBranch *b_md0_d; + TBranch *b_dmd0_d; + TBranch *b_pd0_t; + TBranch *b_md0_t; + TBranch *b_dmd0_t; + TBranch *b_pk_r; + TBranch *b_ppi_r; + TBranch *b_pd0_r; + TBranch *b_md0_r; + TBranch *b_Vtxd0_r; + TBranch *b_cvtxd0_r; + TBranch *b_dxy_r; + TBranch *b_dz_r; + TBranch *b_psi_r; + TBranch *b_rd0_d; + TBranch *b_drd0_d; + TBranch *b_rpd0_d; + TBranch *b_drpd0_d; + TBranch *b_rd0_t; + TBranch *b_drd0_t; + TBranch *b_rpd0_t; + TBranch *b_drpd0_t; + TBranch *b_rd0_dt; + TBranch *b_drd0_dt; + TBranch *b_prbr_dt; + TBranch *b_prbz_dt; + TBranch *b_rd0_tt; + TBranch *b_drd0_tt; + TBranch *b_prbr_tt; + TBranch *b_prbz_tt; + TBranch *b_ijetd0; + TBranch *b_ptr3d0_j; + TBranch *b_ptr2d0_j; + TBranch *b_ptr3d0_3; + TBranch *b_ptr2d0_3; + TBranch *b_ptr2d0_2; + TBranch *b_Mimpds_r; + TBranch *b_Mimpbk_r; + TBranch *b_ntracks; + TBranch *b_pt; + TBranch *b_kappa; + TBranch *b_phi; + TBranch *b_theta; + TBranch *b_dca; + TBranch *b_z0; + TBranch *b_covar; + TBranch *b_nhitrp; + TBranch *b_prbrp; + TBranch *b_nhitz; + TBranch *b_prbz; + TBranch *b_rstart; + TBranch *b_rend; + TBranch *b_lhk; + TBranch *b_lhpi; + TBranch *b_nlhk; + TBranch *b_nlhpi; + TBranch *b_dca_d; + TBranch *b_ddca_d; + TBranch *b_dca_t; + TBranch *b_ddca_t; + TBranch *b_muqual; + TBranch *b_imu; + TBranch *b_imufe; + TBranch *b_njets; + TBranch *b_E_j; + TBranch *b_pt_j; + TBranch *b_theta_j; + TBranch *b_eta_j; + TBranch *b_phi_j; + TBranch *b_m_j; + TBranch *b_thrust; + TBranch *b_pthrust; + TBranch *b_thrust2; + TBranch *b_pthrust2; + TBranch *b_spher; + TBranch *b_aplan; + TBranch *b_plan; + TBranch *b_nnout; + + h1anal(TTree *tree=0); + ~h1anal(); + void Begin(TTree *tree); + void Init(TTree *tree); + Bool_t Notify(); + Bool_t ProcessCut(Int_t entry); + void ProcessFill(Int_t entry); + void Terminate(); +}; + +#endif + + +//_____________________________________________________________________ +h1anal::h1anal(TTree *tree) +{ +// Build the chain of Root files +// +} + +//_____________________________________________________________________ +h1anal::~h1anal() +{ +} + +//_____________________________________________________________________ +void h1anal::Init(TTree *tree) +{ +// Set branch addresses + if (tree == 0) return; + fChain = tree; + + fChain->SetBranchAddress("nrun",&nrun); + fChain->SetBranchAddress("nevent",&nevent); + fChain->SetBranchAddress("nentry",&nentry); + fChain->SetBranchAddress("trelem",trelem); + fChain->SetBranchAddress("subtr",subtr); + fChain->SetBranchAddress("rawtr",rawtr); + fChain->SetBranchAddress("L4subtr",L4subtr); + fChain->SetBranchAddress("L5class",L5class); + fChain->SetBranchAddress("E33",&E33); + fChain->SetBranchAddress("de33",&de33); + fChain->SetBranchAddress("x33",&x33); + fChain->SetBranchAddress("dx33",&dx33); + fChain->SetBranchAddress("y33",&y33); + fChain->SetBranchAddress("dy33",&dy33); + fChain->SetBranchAddress("E44",&E44); + fChain->SetBranchAddress("de44",&de44); + fChain->SetBranchAddress("x44",&x44); + fChain->SetBranchAddress("dx44",&dx44); + fChain->SetBranchAddress("y44",&y44); + fChain->SetBranchAddress("dy44",&dy44); + fChain->SetBranchAddress("Ept",&Ept); + fChain->SetBranchAddress("dept",&dept); + fChain->SetBranchAddress("xpt",&xpt); + fChain->SetBranchAddress("dxpt",&dxpt); + fChain->SetBranchAddress("ypt",&ypt); + fChain->SetBranchAddress("dypt",&dypt); + fChain->SetBranchAddress("pelec",pelec); + fChain->SetBranchAddress("flagelec",&flagelec); + fChain->SetBranchAddress("xeelec",&xeelec); + fChain->SetBranchAddress("yeelec",&yeelec); + fChain->SetBranchAddress("Q2eelec",&Q2eelec); + fChain->SetBranchAddress("nelec",&nelec); + fChain->SetBranchAddress("Eelec",Eelec); + fChain->SetBranchAddress("thetelec",thetelec); + fChain->SetBranchAddress("phielec",phielec); + fChain->SetBranchAddress("xelec",xelec); + fChain->SetBranchAddress("Q2elec",Q2elec); + fChain->SetBranchAddress("xsigma",xsigma); + fChain->SetBranchAddress("Q2sigma",Q2sigma); + fChain->SetBranchAddress("sumc",sumc); + fChain->SetBranchAddress("sumetc",&sumetc); + fChain->SetBranchAddress("yjbc",&yjbc); + fChain->SetBranchAddress("Q2jbc",&Q2jbc); + fChain->SetBranchAddress("sumct",sumct); + fChain->SetBranchAddress("sumetct",&sumetct); + fChain->SetBranchAddress("yjbct",&yjbct); + fChain->SetBranchAddress("Q2jbct",&Q2jbct); + fChain->SetBranchAddress("Ebeamel",&Ebeamel); + fChain->SetBranchAddress("Ebeampr",&Ebeampr); + fChain->SetBranchAddress("pvtx_d",pvtx_d); + fChain->SetBranchAddress("cpvtx_d",cpvtx_d); + fChain->SetBranchAddress("pvtx_t",pvtx_t); + fChain->SetBranchAddress("cpvtx_t",cpvtx_t); + fChain->SetBranchAddress("ntrkxy_t",&ntrkxy_t); + fChain->SetBranchAddress("prbxy_t",&prbxy_t); + fChain->SetBranchAddress("ntrkz_t",&ntrkz_t); + fChain->SetBranchAddress("prbz_t",&prbz_t); + fChain->SetBranchAddress("nds",&nds); + fChain->SetBranchAddress("rankds",&rankds); + fChain->SetBranchAddress("qds",&qds); + fChain->SetBranchAddress("pds_d",pds_d); + fChain->SetBranchAddress("ptds_d",&ptds_d); + fChain->SetBranchAddress("etads_d",&etads_d); + fChain->SetBranchAddress("dm_d",&dm_d); + fChain->SetBranchAddress("ddm_d",&ddm_d); + fChain->SetBranchAddress("pds_t",pds_t); + fChain->SetBranchAddress("dm_t",&dm_t); + fChain->SetBranchAddress("ddm_t",&ddm_t); + fChain->SetBranchAddress("ik",&ik); + fChain->SetBranchAddress("ipi",&ipi); + fChain->SetBranchAddress("ipis",&ipis); + fChain->SetBranchAddress("pd0_d",pd0_d); + fChain->SetBranchAddress("ptd0_d",&ptd0_d); + fChain->SetBranchAddress("etad0_d",&etad0_d); + fChain->SetBranchAddress("md0_d",&md0_d); + fChain->SetBranchAddress("dmd0_d",&dmd0_d); + fChain->SetBranchAddress("pd0_t",pd0_t); + fChain->SetBranchAddress("md0_t",&md0_t); + fChain->SetBranchAddress("dmd0_t",&dmd0_t); + fChain->SetBranchAddress("pk_r",pk_r); + fChain->SetBranchAddress("ppi_r",ppi_r); + fChain->SetBranchAddress("pd0_r",pd0_r); + fChain->SetBranchAddress("md0_r",&md0_r); + fChain->SetBranchAddress("Vtxd0_r",Vtxd0_r); + fChain->SetBranchAddress("cvtxd0_r",cvtxd0_r); + fChain->SetBranchAddress("dxy_r",&dxy_r); + fChain->SetBranchAddress("dz_r",&dz_r); + fChain->SetBranchAddress("psi_r",&psi_r); + fChain->SetBranchAddress("rd0_d",&rd0_d); + fChain->SetBranchAddress("drd0_d",&drd0_d); + fChain->SetBranchAddress("rpd0_d",&rpd0_d); + fChain->SetBranchAddress("drpd0_d",&drpd0_d); + fChain->SetBranchAddress("rd0_t",&rd0_t); + fChain->SetBranchAddress("drd0_t",&drd0_t); + fChain->SetBranchAddress("rpd0_t",&rpd0_t); + fChain->SetBranchAddress("drpd0_t",&drpd0_t); + fChain->SetBranchAddress("rd0_dt",&rd0_dt); + fChain->SetBranchAddress("drd0_dt",&drd0_dt); + fChain->SetBranchAddress("prbr_dt",&prbr_dt); + fChain->SetBranchAddress("prbz_dt",&prbz_dt); + fChain->SetBranchAddress("rd0_tt",&rd0_tt); + fChain->SetBranchAddress("drd0_tt",&drd0_tt); + fChain->SetBranchAddress("prbr_tt",&prbr_tt); + fChain->SetBranchAddress("prbz_tt",&prbz_tt); + fChain->SetBranchAddress("ijetd0",&ijetd0); + fChain->SetBranchAddress("ptr3d0_j",&ptr3d0_j); + fChain->SetBranchAddress("ptr2d0_j",&ptr2d0_j); + fChain->SetBranchAddress("ptr3d0_3",&ptr3d0_3); + fChain->SetBranchAddress("ptr2d0_3",&ptr2d0_3); + fChain->SetBranchAddress("ptr2d0_2",&ptr2d0_2); + fChain->SetBranchAddress("Mimpds_r",&Mimpds_r); + fChain->SetBranchAddress("Mimpbk_r",&Mimpbk_r); + fChain->SetBranchAddress("ntracks",&ntracks); + fChain->SetBranchAddress("pt",pt); + fChain->SetBranchAddress("kappa",kappa); + fChain->SetBranchAddress("phi",phi); + fChain->SetBranchAddress("theta",theta); + fChain->SetBranchAddress("dca",dca); + fChain->SetBranchAddress("z0",z0); + fChain->SetBranchAddress("covar",covar); + fChain->SetBranchAddress("nhitrp",nhitrp); + fChain->SetBranchAddress("prbrp",prbrp); + fChain->SetBranchAddress("nhitz",nhitz); + fChain->SetBranchAddress("prbz",prbz); + fChain->SetBranchAddress("rstart",rstart); + fChain->SetBranchAddress("rend",rend); + fChain->SetBranchAddress("lhk",lhk); + fChain->SetBranchAddress("lhpi",lhpi); + fChain->SetBranchAddress("nlhk",nlhk); + fChain->SetBranchAddress("nlhpi",nlhpi); + fChain->SetBranchAddress("dca_d",dca_d); + fChain->SetBranchAddress("ddca_d",ddca_d); + fChain->SetBranchAddress("dca_t",dca_t); + fChain->SetBranchAddress("ddca_t",ddca_t); + fChain->SetBranchAddress("muqual",muqual); + fChain->SetBranchAddress("imu",&imu); + fChain->SetBranchAddress("imufe",&imufe); + fChain->SetBranchAddress("njets",&njets); + fChain->SetBranchAddress("E_j",E_j); + fChain->SetBranchAddress("pt_j",pt_j); + fChain->SetBranchAddress("theta_j",theta_j); + fChain->SetBranchAddress("eta_j",eta_j); + fChain->SetBranchAddress("phi_j",phi_j); + fChain->SetBranchAddress("m_j",m_j); + fChain->SetBranchAddress("thrust",&thrust); + fChain->SetBranchAddress("pthrust",pthrust); + fChain->SetBranchAddress("thrust2",&thrust2); + fChain->SetBranchAddress("pthrust2",pthrust2); + fChain->SetBranchAddress("spher",&spher); + fChain->SetBranchAddress("aplan",&aplan); + fChain->SetBranchAddress("plan",&plan); + fChain->SetBranchAddress("nnout",&nnout); +} + +//_____________________________________________________________________ +Bool_t h1anal::Notify() +{ +// called when loading a new file +// get branch pointers + + printf("Processing file: %s\n",fChain->GetCurrentFile()->GetName()); + b_nrun = fChain->GetBranch("nrun"); + b_nevent = fChain->GetBranch("nevent"); + b_nentry = fChain->GetBranch("nentry"); + b_trelem = fChain->GetBranch("trelem"); + b_subtr = fChain->GetBranch("subtr"); + b_rawtr = fChain->GetBranch("rawtr"); + b_L4subtr = fChain->GetBranch("L4subtr"); + b_L5class = fChain->GetBranch("L5class"); + b_E33 = fChain->GetBranch("E33"); + b_de33 = fChain->GetBranch("de33"); + b_x33 = fChain->GetBranch("x33"); + b_dx33 = fChain->GetBranch("dx33"); + b_y33 = fChain->GetBranch("y33"); + b_dy33 = fChain->GetBranch("dy33"); + b_E44 = fChain->GetBranch("E44"); + b_de44 = fChain->GetBranch("de44"); + b_x44 = fChain->GetBranch("x44"); + b_dx44 = fChain->GetBranch("dx44"); + b_y44 = fChain->GetBranch("y44"); + b_dy44 = fChain->GetBranch("dy44"); + b_Ept = fChain->GetBranch("Ept"); + b_dept = fChain->GetBranch("dept"); + b_xpt = fChain->GetBranch("xpt"); + b_dxpt = fChain->GetBranch("dxpt"); + b_ypt = fChain->GetBranch("ypt"); + b_dypt = fChain->GetBranch("dypt"); + b_pelec = fChain->GetBranch("pelec"); + b_flagelec = fChain->GetBranch("flagelec"); + b_xeelec = fChain->GetBranch("xeelec"); + b_yeelec = fChain->GetBranch("yeelec"); + b_Q2eelec = fChain->GetBranch("Q2eelec"); + b_nelec = fChain->GetBranch("nelec"); + b_Eelec = fChain->GetBranch("Eelec"); + b_thetelec = fChain->GetBranch("thetelec"); + b_phielec = fChain->GetBranch("phielec"); + b_xelec = fChain->GetBranch("xelec"); + b_Q2elec = fChain->GetBranch("Q2elec"); + b_xsigma = fChain->GetBranch("xsigma"); + b_Q2sigma = fChain->GetBranch("Q2sigma"); + b_sumc = fChain->GetBranch("sumc"); + b_sumetc = fChain->GetBranch("sumetc"); + b_yjbc = fChain->GetBranch("yjbc"); + b_Q2jbc = fChain->GetBranch("Q2jbc"); + b_sumct = fChain->GetBranch("sumct"); + b_sumetct = fChain->GetBranch("sumetct"); + b_yjbct = fChain->GetBranch("yjbct"); + b_Q2jbct = fChain->GetBranch("Q2jbct"); + b_Ebeamel = fChain->GetBranch("Ebeamel"); + b_Ebeampr = fChain->GetBranch("Ebeampr"); + b_pvtx_d = fChain->GetBranch("pvtx_d"); + b_cpvtx_d = fChain->GetBranch("cpvtx_d"); + b_pvtx_t = fChain->GetBranch("pvtx_t"); + b_cpvtx_t = fChain->GetBranch("cpvtx_t"); + b_ntrkxy_t = fChain->GetBranch("ntrkxy_t"); + b_prbxy_t = fChain->GetBranch("prbxy_t"); + b_ntrkz_t = fChain->GetBranch("ntrkz_t"); + b_prbz_t = fChain->GetBranch("prbz_t"); + b_nds = fChain->GetBranch("nds"); + b_rankds = fChain->GetBranch("rankds"); + b_qds = fChain->GetBranch("qds"); + b_pds_d = fChain->GetBranch("pds_d"); + b_ptds_d = fChain->GetBranch("ptds_d"); + b_etads_d = fChain->GetBranch("etads_d"); + b_dm_d = fChain->GetBranch("dm_d"); + b_ddm_d = fChain->GetBranch("ddm_d"); + b_pds_t = fChain->GetBranch("pds_t"); + b_dm_t = fChain->GetBranch("dm_t"); + b_ddm_t = fChain->GetBranch("ddm_t"); + b_ik = fChain->GetBranch("ik"); + b_ipi = fChain->GetBranch("ipi"); + b_ipis = fChain->GetBranch("ipis"); + b_pd0_d = fChain->GetBranch("pd0_d"); + b_ptd0_d = fChain->GetBranch("ptd0_d"); + b_etad0_d = fChain->GetBranch("etad0_d"); + b_md0_d = fChain->GetBranch("md0_d"); + b_dmd0_d = fChain->GetBranch("dmd0_d"); + b_pd0_t = fChain->GetBranch("pd0_t"); + b_md0_t = fChain->GetBranch("md0_t"); + b_dmd0_t = fChain->GetBranch("dmd0_t"); + b_pk_r = fChain->GetBranch("pk_r"); + b_ppi_r = fChain->GetBranch("ppi_r"); + b_pd0_r = fChain->GetBranch("pd0_r"); + b_md0_r = fChain->GetBranch("md0_r"); + b_Vtxd0_r = fChain->GetBranch("Vtxd0_r"); + b_cvtxd0_r = fChain->GetBranch("cvtxd0_r"); + b_dxy_r = fChain->GetBranch("dxy_r"); + b_dz_r = fChain->GetBranch("dz_r"); + b_psi_r = fChain->GetBranch("psi_r"); + b_rd0_d = fChain->GetBranch("rd0_d"); + b_drd0_d = fChain->GetBranch("drd0_d"); + b_rpd0_d = fChain->GetBranch("rpd0_d"); + b_drpd0_d = fChain->GetBranch("drpd0_d"); + b_rd0_t = fChain->GetBranch("rd0_t"); + b_drd0_t = fChain->GetBranch("drd0_t"); + b_rpd0_t = fChain->GetBranch("rpd0_t"); + b_drpd0_t = fChain->GetBranch("drpd0_t"); + b_rd0_dt = fChain->GetBranch("rd0_dt"); + b_drd0_dt = fChain->GetBranch("drd0_dt"); + b_prbr_dt = fChain->GetBranch("prbr_dt"); + b_prbz_dt = fChain->GetBranch("prbz_dt"); + b_rd0_tt = fChain->GetBranch("rd0_tt"); + b_drd0_tt = fChain->GetBranch("drd0_tt"); + b_prbr_tt = fChain->GetBranch("prbr_tt"); + b_prbz_tt = fChain->GetBranch("prbz_tt"); + b_ijetd0 = fChain->GetBranch("ijetd0"); + b_ptr3d0_j = fChain->GetBranch("ptr3d0_j"); + b_ptr2d0_j = fChain->GetBranch("ptr2d0_j"); + b_ptr3d0_3 = fChain->GetBranch("ptr3d0_3"); + b_ptr2d0_3 = fChain->GetBranch("ptr2d0_3"); + b_ptr2d0_2 = fChain->GetBranch("ptr2d0_2"); + b_Mimpds_r = fChain->GetBranch("Mimpds_r"); + b_Mimpbk_r = fChain->GetBranch("Mimpbk_r"); + b_ntracks = fChain->GetBranch("ntracks"); + b_pt = fChain->GetBranch("pt"); + b_kappa = fChain->GetBranch("kappa"); + b_phi = fChain->GetBranch("phi"); + b_theta = fChain->GetBranch("theta"); + b_dca = fChain->GetBranch("dca"); + b_z0 = fChain->GetBranch("z0"); + b_covar = fChain->GetBranch("covar"); + b_nhitrp = fChain->GetBranch("nhitrp"); + b_prbrp = fChain->GetBranch("prbrp"); + b_nhitz = fChain->GetBranch("nhitz"); + b_prbz = fChain->GetBranch("prbz"); + b_rstart = fChain->GetBranch("rstart"); + b_rend = fChain->GetBranch("rend"); + b_lhk = fChain->GetBranch("lhk"); + b_lhpi = fChain->GetBranch("lhpi"); + b_nlhk = fChain->GetBranch("nlhk"); + b_nlhpi = fChain->GetBranch("nlhpi"); + b_dca_d = fChain->GetBranch("dca_d"); + b_ddca_d = fChain->GetBranch("ddca_d"); + b_dca_t = fChain->GetBranch("dca_t"); + b_ddca_t = fChain->GetBranch("ddca_t"); + b_muqual = fChain->GetBranch("muqual"); + b_imu = fChain->GetBranch("imu"); + b_imufe = fChain->GetBranch("imufe"); + b_njets = fChain->GetBranch("njets"); + b_E_j = fChain->GetBranch("E_j"); + b_pt_j = fChain->GetBranch("pt_j"); + b_theta_j = fChain->GetBranch("theta_j"); + b_eta_j = fChain->GetBranch("eta_j"); + b_phi_j = fChain->GetBranch("phi_j"); + b_m_j = fChain->GetBranch("m_j"); + b_thrust = fChain->GetBranch("thrust"); + b_pthrust = fChain->GetBranch("pthrust"); + b_thrust2 = fChain->GetBranch("thrust2"); + b_pthrust2 = fChain->GetBranch("pthrust2"); + b_spher = fChain->GetBranch("spher"); + b_aplan = fChain->GetBranch("aplan"); + b_plan = fChain->GetBranch("plan"); + b_nnout = fChain->GetBranch("nnout"); + return kTRUE; +} diff --git a/tutorials/h1chain.C b/tutorials/h1chain.C new file mode 100644 index 00000000000..243157c5a4c --- /dev/null +++ b/tutorials/h1chain.C @@ -0,0 +1,7 @@ +{ + TChain chain("h42"); + chain.Add("$H1/dstarmb.root"); + chain.Add("$H1/dstarp1a.root"); + chain.Add("$H1/dstarp1b.root"); + chain.Add("$H1/dstarp2.root"); +} -- GitLab