From 450d1be56f401d2b0ec6b21be3a25db96c1065bd Mon Sep 17 00:00:00 2001 From: cbravo135 Date: Mon, 31 Jul 2017 14:55:31 +0200 Subject: [PATCH] Updated mcTree analysis macro --- include/mcTree.h | 55 ++++++++++++++++++++++++++++++++++++++++-------- macros/mcTree.C | 32 ---------------------------- 2 files changed, 46 insertions(+), 41 deletions(-) diff --git a/include/mcTree.h b/include/mcTree.h index cdc44d0..80e4864 100644 --- a/include/mcTree.h +++ b/include/mcTree.h @@ -1,8 +1,8 @@ ////////////////////////////////////////////////////////// // This class has been automatically generated on -// Tue Feb 2 13:23:01 2016 by ROOT version 6.06/00 +// Mon Jul 31 14:53:13 2017 by ROOT version 6.06/01 // from TTree mcTree/mcTree -// found on file: mcTree.root +// found on file: test/testRun.root ////////////////////////////////////////////////////////// #ifndef mcTree_h @@ -10,10 +10,10 @@ #include #include -#include #include // Header file for the classes stored in the TTree if any. +#include "vector" class mcTree { public : @@ -23,12 +23,34 @@ public : // Fixed size dimensions of array or collections stored in the TTree if any. // Declaration of leaf types - vector *daughters; + vector *daughtersPt; + vector *daughtersEta; + vector *daughtersPhi; + vector *daughtersE; + vector *daughtersID; Double_t weight; + Double_t pz; + Double_t x1; + Double_t x2; + Int_t iq1; + Int_t iq2; + Double_t Q2; + Double_t momM; // List of branches - TBranch *b_daughters; //! + TBranch *b_daughtersPt; //! + TBranch *b_daughtersEta; //! + TBranch *b_daughtersPhi; //! + TBranch *b_daughtersE; //! + TBranch *b_daughtersID; //! TBranch *b_weight; //! + TBranch *b_pz; //! + TBranch *b_x1; //! + TBranch *b_x2; //! + TBranch *b_iq1; //! + TBranch *b_iq2; //! + TBranch *b_Q2; //! + TBranch *b_momM; //! mcTree(TTree *tree=0); virtual ~mcTree(); @@ -49,9 +71,9 @@ mcTree::mcTree(TTree *tree) : fChain(0) // if parameter tree is not specified (or zero), connect the file // used to generate this class and read the Tree. if (tree == 0) { - TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("mcTree.root"); + TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("test/testRun.root"); if (!f || !f->IsOpen()) { - f = new TFile("mcTree.root"); + f = new TFile("test/testRun.root"); } f->GetObject("mcTree",tree); @@ -95,15 +117,30 @@ void mcTree::Init(TTree *tree) // (once per file to be processed). // Set object pointer - daughters = 0; + daughtersPt = 0; + daughtersEta = 0; + daughtersPhi = 0; + daughtersE = 0; + daughtersID = 0; // Set branch addresses and branch pointers if (!tree) return; fChain = tree; fCurrent = -1; fChain->SetMakeClass(1); - fChain->SetBranchAddress("daughters", &daughters, &b_daughters); + fChain->SetBranchAddress("daughtersPt", &daughtersPt, &b_daughtersPt); + fChain->SetBranchAddress("daughtersEta", &daughtersEta, &b_daughtersEta); + fChain->SetBranchAddress("daughtersPhi", &daughtersPhi, &b_daughtersPhi); + fChain->SetBranchAddress("daughtersE", &daughtersE, &b_daughtersE); + fChain->SetBranchAddress("daughtersID", &daughtersID, &b_daughtersID); fChain->SetBranchAddress("weight", &weight, &b_weight); + fChain->SetBranchAddress("pz", &pz, &b_pz); + fChain->SetBranchAddress("x1", &x1, &b_x1); + fChain->SetBranchAddress("x2", &x2, &b_x2); + fChain->SetBranchAddress("iq1", &iq1, &b_iq1); + fChain->SetBranchAddress("iq2", &iq2, &b_iq2); + fChain->SetBranchAddress("Q2", &Q2, &b_Q2); + fChain->SetBranchAddress("momM", &momM, &b_momM); Notify(); } diff --git a/macros/mcTree.C b/macros/mcTree.C index ef02909..da9c57e 100644 --- a/macros/mcTree.C +++ b/macros/mcTree.C @@ -1,14 +1,8 @@ #define mcTree_cxx #include "mcTree.h" #include -#include #include #include -#include - -#include - -using namespace std; void mcTree::Loop() { @@ -39,37 +33,11 @@ void mcTree::Loop() Long64_t nentries = fChain->GetEntriesFast(); - TFile *myF = new TFile("dalitz.root","RECREATE"); - - TH2D *dalitz = new TH2D("dalitz","dalitz",910,0.0,9100.0,910,0.0,9100.0); - Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; - - double m12 = 0.0; - double m13 = 0.0; - - TLorentzVector p1 = daughters->at(0); - TLorentzVector p2 = daughters->at(1); - TLorentzVector p3 = daughters->at(2); - - TLorentzVector p12 = p1 + p2; - TLorentzVector p13 = p1 + p3; - - m12 = p12.M(); - m13 = p13.M(); - - if(jentry%1000 == 0) cout << "m12: " << m12 << " m13: " << m13 << endl; - - dalitz->Fill(m12,m13); - } - - dalitz->Write(); - myF->Write(); - myF->Close(); }