|
||||
Warning, file /estarlight/utils/AnalyzeTree.cxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // This macro reads the starlight.root file produced by convertStarlightAsciiToTree.C, 0002 // which contains TLorentzVectors for the parents and a TClonesArray of TLorentzVectors 0003 // for the daughters. 0004 // 0005 // It creates histograms of the p_T and rapidity of the daughters, as well as the p_T, 0006 // rapidity and mass of the parent. While the parents may have been created as the 0007 // vector sum of any number of daughter particles, this macro currently produces 0008 // histograms for only the first two daughter particles. The daughter histograms are 0009 // called D1Pt, D2Pt, D1Rapidity, and D1Rapidity. Parent histograms are 0010 // named ParentPt, ParentRapidity, and ParentMass. The histograms are stored in 0011 // starlight_histos.root. 0012 // 0013 // To use this macro, you must first run convertStarlightAsciiToTree.C to produce the 0014 // starlight.root file. If needed, modify the file AnalyzeTree.h to call your input file 0015 // (as downloaded, it calls starlight.root). Then open root and type .x anaTree.C . 0016 0017 #define AnalyzeTree_cxx 0018 #include "AnalyzeTree.h" 0019 #include <TH2.h> 0020 #include <TStyle.h> 0021 #include <TCanvas.h> 0022 #include <TLorentzVector.h> 0023 #include <iostream> 0024 0025 void AnalyzeTree::Loop() 0026 { 0027 // In a ROOT session, you can do: 0028 // Root > .L MyClass.C 0029 // Root > MyClass t 0030 // Root > t.GetEntry(12); // Fill t data members with entry number 12 0031 // Root > t.Show(); // Show values of entry 12 0032 // Root > t.Show(16); // Read and show values of entry 16 0033 // Root > t.Loop(); // Loop on all entries 0034 // 0035 0036 // This is the loop skeleton where: 0037 // jentry is the global entry number in the chain 0038 // ientry is the entry number in the current Tree 0039 // Note that the argument to GetEntry must be: 0040 // jentry for TChain::GetEntry 0041 // ientry for TTree::GetEntry and TBranch::GetEntry 0042 // 0043 // To read only selected branches, Insert statements like: 0044 // METHOD1: 0045 // fChain->SetBranchStatus("*",0); // disable all branches 0046 // fChain->SetBranchStatus("branchname",1); // activate branchname 0047 // METHOD2: replace line 0048 // fChain->GetEntry(jentry); //read all branches 0049 //by b_branchname->GetEntry(ientry); //read only this branch 0050 if (fChain == 0) return; 0051 0052 // define histos 0053 TH1D* D1Prapidity = new TH1D("D1Prapidity","Prapidity of Daughter 1",200, -10, 10); 0054 TH1D* D1Pt = new TH1D("D1Pt","Transverse Momentum of Daughter 1",100, 0, 2.); 0055 TH1D* D2Prapidity = new TH1D("D2Prapidity","Prapidity of Daughter 2",200, -10, 10); 0056 TH1D* D2Pt = new TH1D("D2Pt","Transverse Momentum of Daughter 2",100, 0, 2.); 0057 TH1D* ParentRapidity = new TH1D("ParentRapidity","Rapidity of Parent",200, -10, 10); 0058 TH1D* ParentPt = new TH1D("ParentPt","Transverse Momentum of Parent",100, 0, 2.); 0059 TH1D* ParentMass = new TH1D("ParentMass","Invariant Mass of Parent",100, 0, 5.); 0060 0061 // Fill histograms 0062 Long64_t nentries = fChain->GetEntriesFast(); 0063 0064 Long64_t nbytes = 0, nb = 0; 0065 for (Long64_t jentry=0; jentry<nentries;jentry++) { 0066 Long64_t ientry = LoadTree(jentry); 0067 if (ientry < 0) break; 0068 nb = fChain->GetEntry(jentry); nbytes += nb; 0069 // if desired, acceptance or analysis cuts can be applied here, before filling histograms 0070 // if (Cut(ientry) < 0) continue; 0071 D1Prapidity->Fill( p1prap_ ); 0072 D2Prapidity->Fill( p2prap_ ); 0073 D1Pt->Fill( p1pt_ ); 0074 D2Pt->Fill( p2pt_ ); 0075 ParentRapidity->Fill( fsrap_ ); 0076 ParentPt->Fill( fspt_ ); 0077 ParentMass->Fill( fsmass_ ); 0078 }// jentry 0079 0080 0081 // write out the histos 0082 TFile *histofile = new TFile("starlight_histos.root","recreate"); 0083 // f->cd; 0084 0085 D1Prapidity->Write(); 0086 D2Prapidity->Write(); 0087 D1Pt->Write(); 0088 D2Pt->Write(); 0089 ParentRapidity->Write(); 0090 ParentPt->Write(); 0091 ParentMass->Write(); 0092 0093 histofile->Save(); 0094 histofile->Close(); 0095 0096 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |