1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #define htree_cxx
- #include "htree.h"
- #include <TH2.h>
- #include <TStyle.h>
- #include <TCanvas.h>
- #include <math.h>
- #include <cstdio>
- void htree::Loop()
- {
- // In a ROOT session, you can do:
- // Root > .L htree.C
- // Root > htree t
- // Root > t.GetEntry(12); // Fill t data members with entry number 12
- // Root > t.Show(); // Show values of entry 12
- // Root > t.Show(16); // Read and show values of entry 16
- // Root > t.Loop(); // Loop on all entries
- //
- // This is the loop skeleton where:
- // jentry is the global entry number in the chain
- // ientry is the entry number in the current Tree
- // Note that the argument to GetEntry must be:
- // jentry for TChain::GetEntry
- // ientry for TTree::GetEntry and TBranch::GetEntry
- //
- // To read only selected branches, Insert statements like:
- // METHOD1:
- // fChain->SetBranchStatus("*",0); // disable all branches
- // fChain->SetBranchStatus("branchname",1); // activate branchname
- // METHOD2: replace line
- // fChain->GetEntry(jentry); //read all branches
- //by b_branchname->GetEntry(ientry); //read only this branch
- if (fChain == 0) return;
- TH1F *dtof[2]; // east, west
- dtof[0] = new TH1F("tof_east", "TOF resolution uncorrected EAST;#Delta t, ns;dN/dt", 300,-3,3);
- dtof[1] = new TH1F("tof_west", "TOF resolution uncorrected WEST;#Delta t, ns;dN/dt", 300,-3,3);
- TH2F *dtof_slat[2]; // east, west per slat
- dtof_slat[0] = new TH2F("tofslat_east", "TOF resolution uncorrected EAST;slat number;#Delta t, ns;dN/dt", 1000,0,999, 300,-3,3);
- dtof_slat[1] = new TH2F("tofslat_west", "TOF resolution uncorrected WEST;slat number;#Delta t, ns;dN/dt", 1000,0,999, 300,-3,3);
- float t_exp, beta, pt, dt; // expected time
- Long64_t nentries = fChain->GetEntriesFast();
- // activate only required branches
- fChain->SetBranchStatus("*",0);
- fChain->SetBranchStatus("nh",1);
- fChain->SetBranchStatus("tofdz",1);
- fChain->SetBranchStatus("tofdphi",1);
- fChain->SetBranchStatus("p",1);
- fChain->SetBranchStatus("pltof",1);
- fChain->SetBranchStatus("dcarm",1);
- fChain->SetBranchStatus("ttof",1);
- fChain->SetBranchStatus("slat",1);
- fChain->SetBranchStatus("the0",1);
- for (Long64_t jentry=0; jentry<nentries;jentry++)
- {
- // skip entry if read failed
- if (fChain->GetEntry(jentry) == -1)
- break;
-
- // loop through all tracks
- for (int i=0; i<nh; i++)
- {
- if (fabs(tofdz[i])>1.0 || fabs(tofdphi[i])>1.0 ||
- dcarm[i]<0 || dcarm[i]>1)
- continue;
- pt = p[i] * sin(the0[i]);
- if (pt < 1.1 || pt > 1.9)
- continue;
- beta = p[i] / sqrt(0.0194795 + p[i]*p[i]);
- t_exp = pltof[i] / (29.9792458 * beta);
-
- dt = ttof[i] - t_exp;
- dtof[dcarm[i]] -> Fill(dt);
- dtof_slat[dcarm[i]] -> Fill(slat[i], dt);
- }
- }
- output->Write();
- puts("Processing finished.");
- }
|