Skip to content

Commit

Permalink
Updated mcTree analysis macro
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravo135 committed Jul 31, 2017
1 parent 98517d5 commit 450d1be
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 41 deletions.
55 changes: 46 additions & 9 deletions include/mcTree.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
//////////////////////////////////////////////////////////
// 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
#define mcTree_h

#include <TROOT.h>
#include <TChain.h>
#include <TLorentzVector.h>
#include <TFile.h>

// Header file for the classes stored in the TTree if any.
#include "vector"

class mcTree {
public :
Expand All @@ -23,12 +23,34 @@ public :
// Fixed size dimensions of array or collections stored in the TTree if any.

// Declaration of leaf types
vector<TLorentzVector> *daughters;
vector<double> *daughtersPt;
vector<double> *daughtersEta;
vector<double> *daughtersPhi;
vector<double> *daughtersE;
vector<double> *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();
Expand All @@ -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);

Expand Down Expand Up @@ -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();
}

Expand Down
32 changes: 0 additions & 32 deletions macros/mcTree.C
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#define mcTree_cxx
#include "mcTree.h"
#include <TH2.h>
#include <TFile.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TLorentzVector.h>

#include <iostream>

using namespace std;

void mcTree::Loop()
{
Expand Down Expand Up @@ -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; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(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();
}

0 comments on commit 450d1be

Please sign in to comment.