Browse Source

Add tof_resolution lection.

Andrew Savchenko 7 years ago
parent
commit
b4e44fe09f
5 changed files with 464 additions and 0 deletions
  1. 0 0
      .gitignore
  2. 0 0
      LICENSE
  3. 5 0
      tor_resolution/do_htree.C
  4. 88 0
      tor_resolution/htree.C
  5. 371 0
      tor_resolution/htree.h

+ 0 - 0
.gitignore


+ 0 - 0
LICENSE


+ 5 - 0
tor_resolution/do_htree.C

@@ -0,0 +1,5 @@
+do_htree() {
+    gSystem->Load("htree_C.so");
+    htree t("312471_0.root");
+    t.Loop();
+}

+ 88 - 0
tor_resolution/htree.C

@@ -0,0 +1,88 @@
+#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.");
+}

+ 371 - 0
tor_resolution/htree.h

@@ -0,0 +1,371 @@
+//////////////////////////////////////////////////////////
+// This class has been automatically generated on
+// Fri Mar 27 23:50:31 2015 by ROOT version 5.34/28
+// from TTree htree/Hadron EMC + TOF tree
+// found on file: 312471_0.root
+//////////////////////////////////////////////////////////
+
+#ifndef htree_h
+#define htree_h
+
+#include <TROOT.h>
+#include <TTree.h>
+#include <TFile.h>
+#include <TString.h>
+#include "error.h"
+#include "errno.h"
+
+// Header file for the classes stored in the TTree if any.
+
+// Fixed size dimensions of array or collections stored in the TTree if any.
+
+class htree {
+public :
+   TTree          *fChain;   //!pointer to the analyzed TTree or TChain
+   Int_t           fCurrent; //!current Tree number in a TChain
+   TFile          *output; 
+
+   // Declaration of leaf types
+   Int_t           run;
+   Float_t         bbcz;
+   Float_t         cent;
+   Float_t         BbcT;
+   Float_t         QX10;
+   Float_t         QX11;
+   Float_t         QX12;
+   Float_t         QX13;
+   Float_t         QX14;
+   Float_t         QX15;
+   Float_t         QX16;
+   Float_t         QX17;
+   Float_t         QX18;
+   Float_t         QY10;
+   Float_t         QY11;
+   Float_t         QY12;
+   Float_t         QY13;
+   Float_t         QY14;
+   Float_t         QY15;
+   Float_t         QY16;
+   Float_t         QY17;
+   Float_t         QY18;
+   Float_t         bbcQY10;
+   Float_t         bbcQY11;
+   Float_t         bbcQY12;
+   Float_t         bbcQX10;
+   Float_t         bbcQX11;
+   Float_t         bbcQX12;
+   Float_t         mpcQY10;
+   Float_t         mpcQY11;
+   Float_t         mpcQY12;
+   Float_t         mpcQX10;
+   Float_t         mpcQX11;
+   Float_t         mpcQX12;
+   Int_t           nh;
+   Float_t         p[42];   //[nh]
+   Short_t         charge[42];   //[nh]
+   Float_t         phi0[42];   //[nh]
+   Float_t         the0[42];   //[nh]
+   Short_t         dcarm[42];   //[nh]
+   Float_t         pc3dz[42];   //[nh]
+   Float_t         pc3dphi[42];   //[nh]
+   Float_t         alpha[42];   //[nh]
+   Float_t         phi[42];   //[nh]
+   Float_t         zed[42];   //[nh]
+   Short_t         n0[42];   //[nh]
+   Float_t         tofdz[42];   //[nh]
+   Float_t         tofdphi[42];   //[nh]
+   Float_t         pc2dz[42];   //[nh]
+   Float_t         pc2dphi[42];   //[nh]
+   Float_t         emcdz[42];   //[nh]
+   Float_t         emcdphi[42];   //[nh]
+   Short_t         sect[42];   //[nh]
+   Short_t         ysect[42];   //[nh]
+   Short_t         zsect[42];   //[nh]
+   Float_t         plemc[42];   //[nh]
+   Float_t         ecent[42];   //[nh]
+   Float_t         emcrawtdc[42];   //[nh]
+   Float_t         emcrawadc[42];   //[nh]
+   Float_t         ecore[42];   //[nh]
+   Float_t         ttof[42];   //[nh]
+   Float_t         pltof[42];   //[nh]
+   Float_t         etof[42];   //[nh]
+   Int_t           slat[42];   //[nh]
+   Int_t           rh;
+   Float_t         phir[47];   //[rh]
+   Float_t         time[47];   //[rh]
+   Float_t         qr0[47];   //[rh]
+   Float_t         etar[47];   //[rh]
+   Short_t         armr[47];   //[rh]
+   Short_t         ring[47];   //[rh]
+   Int_t           chid[47];   //[rh]
+
+   // List of branches
+   TBranch        *b_run;   //!
+   TBranch        *b_bbcz;   //!
+   TBranch        *b_cent;   //!
+   TBranch        *b_BbcT;   //!
+   TBranch        *b_QX10;   //!
+   TBranch        *b_QX11;   //!
+   TBranch        *b_QX12;   //!
+   TBranch        *b_QX13;   //!
+   TBranch        *b_QX14;   //!
+   TBranch        *b_QX15;   //!
+   TBranch        *b_QX16;   //!
+   TBranch        *b_QX17;   //!
+   TBranch        *b_QX18;   //!
+   TBranch        *b_QY10;   //!
+   TBranch        *b_QY11;   //!
+   TBranch        *b_QY12;   //!
+   TBranch        *b_QY13;   //!
+   TBranch        *b_QY14;   //!
+   TBranch        *b_QY15;   //!
+   TBranch        *b_QY16;   //!
+   TBranch        *b_QY17;   //!
+   TBranch        *b_QY18;   //!
+   TBranch        *b_bbcQY10;   //!
+   TBranch        *b_bbcQY11;   //!
+   TBranch        *b_bbcQY12;   //!
+   TBranch        *b_bbcQX10;   //!
+   TBranch        *b_bbcQX11;   //!
+   TBranch        *b_bbcQX12;   //!
+   TBranch        *b_mpcQY10;   //!
+   TBranch        *b_mpcQY11;   //!
+   TBranch        *b_mpcQY12;   //!
+   TBranch        *b_mpcQX10;   //!
+   TBranch        *b_mpcQX11;   //!
+   TBranch        *b_mpcQX12;   //!
+   TBranch        *b_nh;   //!
+   TBranch        *b_p;   //!
+   TBranch        *b_charge;   //!
+   TBranch        *b_phi0;   //!
+   TBranch        *b_the0;   //!
+   TBranch        *b_dcarm;   //!
+   TBranch        *b_pc3dz;   //!
+   TBranch        *b_pc3dphi;   //!
+   TBranch        *b_alpha;   //!
+   TBranch        *b_phi;   //!
+   TBranch        *b_zed;   //!
+   TBranch        *b_n0;   //!
+   TBranch        *b_tofdz;   //!
+   TBranch        *b_tofdphi;   //!
+   TBranch        *b_pc2dz;   //!
+   TBranch        *b_pc2dphi;   //!
+   TBranch        *b_emcdz;   //!
+   TBranch        *b_emcdphi;   //!
+   TBranch        *b_sect;   //!
+   TBranch        *b_ysect;   //!
+   TBranch        *b_zsect;   //!
+   TBranch        *b_plemc;   //!
+   TBranch        *b_ecent;   //!
+   TBranch        *b_emcrawtdc;   //!
+   TBranch        *b_emcrawadc;   //!
+   TBranch        *b_ecore;   //!
+   TBranch        *b_ttof;   //!
+   TBranch        *b_pltof;   //!
+   TBranch        *b_etof;   //!
+   TBranch        *b_slat;   //!
+   TBranch        *b_rh;   //!
+   TBranch        *b_phir;   //!
+   TBranch        *b_time;   //!
+   TBranch        *b_qr0;   //!
+   TBranch        *b_etar;   //!
+   TBranch        *b_armr;   //!
+   TBranch        *b_ring;   //!
+   TBranch        *b_chid;   //!
+
+   htree(TTree *tree=0);
+   htree(const char *name, TTree *tree=0);
+   virtual ~htree();
+   virtual Int_t    Cut(Long64_t entry);
+   virtual Int_t    GetEntry(Long64_t entry);
+   virtual Long64_t LoadTree(Long64_t entry);
+   virtual void     Init(TTree *tree);
+   virtual void     Loop();
+   virtual Bool_t   Notify();
+   virtual void     Show(Long64_t entry = -1);
+};
+
+#endif
+
+#ifdef htree_cxx
+htree::htree(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("312471_0.root");
+      if (!f || !f->IsOpen()) {
+         f = new TFile("312471_0.root");
+      }
+      f->GetObject("htree",tree);
+
+   }
+   Init(tree);
+}
+
+htree::htree(const char *name, 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(name);
+      if (!f || !f->IsOpen()) {
+         f = new TFile(name);
+         if (f->IsZombie())
+              error(EIO, errno, "failed to open input file %s for writing", name);
+      }
+      f->GetObject("htree",tree);
+   }
+   Init(tree);
+
+   // prepare output
+   TString str = "res-";
+   str += name;
+   output = new TFile(str.Data(),"recreate");
+   if (output->IsZombie())
+        error(EIO, errno, "failed to open output file %s for writing", str.Data());
+}
+
+htree::~htree()
+{
+   if (!fChain) return;
+   delete fChain->GetCurrentFile();
+   output->Close();
+}
+
+Int_t htree::GetEntry(Long64_t entry)
+{
+// Read contents of entry.
+   if (!fChain) return 0;
+   return fChain->GetEntry(entry);
+}
+Long64_t htree::LoadTree(Long64_t entry)
+{
+// Set the environment to read one entry
+   if (!fChain) return -5;
+   Long64_t centry = fChain->LoadTree(entry);
+   if (centry < 0) return centry;
+   if (fChain->GetTreeNumber() != fCurrent) {
+      fCurrent = fChain->GetTreeNumber();
+      Notify();
+   }
+   return centry;
+}
+
+void htree::Init(TTree *tree)
+{
+   // The Init() function is called when the selector needs to initialize
+   // a new tree or chain. Typically here the branch addresses and branch
+   // pointers of the tree will be set.
+   // It is normally not necessary to make changes to the generated
+   // code, but the routine can be extended by the user if needed.
+   // Init() will be called many times when running on PROOF
+   // (once per file to be processed).
+
+   // Set branch addresses and branch pointers
+   if (!tree) return;
+   fChain = tree;
+   fCurrent = -1;
+   fChain->SetMakeClass(1);
+
+   fChain->SetBranchAddress("run", &run, &b_run);
+   fChain->SetBranchAddress("bbcz", &bbcz, &b_bbcz);
+   fChain->SetBranchAddress("cent", &cent, &b_cent);
+   fChain->SetBranchAddress("BbcT", &BbcT, &b_BbcT);
+   fChain->SetBranchAddress("QX10", &QX10, &b_QX10);
+   fChain->SetBranchAddress("QX11", &QX11, &b_QX11);
+   fChain->SetBranchAddress("QX12", &QX12, &b_QX12);
+   fChain->SetBranchAddress("QX13", &QX13, &b_QX13);
+   fChain->SetBranchAddress("QX14", &QX14, &b_QX14);
+   fChain->SetBranchAddress("QX15", &QX15, &b_QX15);
+   fChain->SetBranchAddress("QX16", &QX16, &b_QX16);
+   fChain->SetBranchAddress("QX17", &QX17, &b_QX17);
+   fChain->SetBranchAddress("QX18", &QX18, &b_QX18);
+   fChain->SetBranchAddress("QY10", &QY10, &b_QY10);
+   fChain->SetBranchAddress("QY11", &QY11, &b_QY11);
+   fChain->SetBranchAddress("QY12", &QY12, &b_QY12);
+   fChain->SetBranchAddress("QY13", &QY13, &b_QY13);
+   fChain->SetBranchAddress("QY14", &QY14, &b_QY14);
+   fChain->SetBranchAddress("QY15", &QY15, &b_QY15);
+   fChain->SetBranchAddress("QY16", &QY16, &b_QY16);
+   fChain->SetBranchAddress("QY17", &QY17, &b_QY17);
+   fChain->SetBranchAddress("QY18", &QY18, &b_QY18);
+   fChain->SetBranchAddress("bbcQY10", &bbcQY10, &b_bbcQY10);
+   fChain->SetBranchAddress("bbcQY11", &bbcQY11, &b_bbcQY11);
+   fChain->SetBranchAddress("bbcQY12", &bbcQY12, &b_bbcQY12);
+   fChain->SetBranchAddress("bbcQX10", &bbcQX10, &b_bbcQX10);
+   fChain->SetBranchAddress("bbcQX11", &bbcQX11, &b_bbcQX11);
+   fChain->SetBranchAddress("bbcQX12", &bbcQX12, &b_bbcQX12);
+   fChain->SetBranchAddress("mpcQY10", &mpcQY10, &b_mpcQY10);
+   fChain->SetBranchAddress("mpcQY11", &mpcQY11, &b_mpcQY11);
+   fChain->SetBranchAddress("mpcQY12", &mpcQY12, &b_mpcQY12);
+   fChain->SetBranchAddress("mpcQX10", &mpcQX10, &b_mpcQX10);
+   fChain->SetBranchAddress("mpcQX11", &mpcQX11, &b_mpcQX11);
+   fChain->SetBranchAddress("mpcQX12", &mpcQX12, &b_mpcQX12);
+   fChain->SetBranchAddress("nh", &nh, &b_nh);
+   fChain->SetBranchAddress("p", p, &b_p);
+   fChain->SetBranchAddress("charge", charge, &b_charge);
+   fChain->SetBranchAddress("phi0", phi0, &b_phi0);
+   fChain->SetBranchAddress("the0", the0, &b_the0);
+   fChain->SetBranchAddress("dcarm", dcarm, &b_dcarm);
+   fChain->SetBranchAddress("pc3dz", pc3dz, &b_pc3dz);
+   fChain->SetBranchAddress("pc3dphi", pc3dphi, &b_pc3dphi);
+   fChain->SetBranchAddress("alpha", alpha, &b_alpha);
+   fChain->SetBranchAddress("phi", phi, &b_phi);
+   fChain->SetBranchAddress("zed", zed, &b_zed);
+   fChain->SetBranchAddress("n0", n0, &b_n0);
+   fChain->SetBranchAddress("tofdz", tofdz, &b_tofdz);
+   fChain->SetBranchAddress("tofdphi", tofdphi, &b_tofdphi);
+   fChain->SetBranchAddress("pc2dz", pc2dz, &b_pc2dz);
+   fChain->SetBranchAddress("pc2dphi", pc2dphi, &b_pc2dphi);
+   fChain->SetBranchAddress("emcdz", emcdz, &b_emcdz);
+   fChain->SetBranchAddress("emcdphi", emcdphi, &b_emcdphi);
+   fChain->SetBranchAddress("sect", sect, &b_sect);
+   fChain->SetBranchAddress("ysect", ysect, &b_ysect);
+   fChain->SetBranchAddress("zsect", zsect, &b_zsect);
+   fChain->SetBranchAddress("plemc", plemc, &b_plemc);
+   fChain->SetBranchAddress("ecent", ecent, &b_ecent);
+   fChain->SetBranchAddress("emcrawtdc", emcrawtdc, &b_emcrawtdc);
+   fChain->SetBranchAddress("emcrawadc", emcrawadc, &b_emcrawadc);
+   fChain->SetBranchAddress("ecore", ecore, &b_ecore);
+   fChain->SetBranchAddress("ttof", ttof, &b_ttof);
+   fChain->SetBranchAddress("pltof", pltof, &b_pltof);
+   fChain->SetBranchAddress("etof", etof, &b_etof);
+   fChain->SetBranchAddress("slat", slat, &b_slat);
+   fChain->SetBranchAddress("rh", &rh, &b_rh);
+   fChain->SetBranchAddress("phir", phir, &b_phir);
+   fChain->SetBranchAddress("time", time, &b_time);
+   fChain->SetBranchAddress("qr0", qr0, &b_qr0);
+   fChain->SetBranchAddress("etar", etar, &b_etar);
+   fChain->SetBranchAddress("armr", armr, &b_armr);
+   fChain->SetBranchAddress("ring", ring, &b_ring);
+   fChain->SetBranchAddress("chid", chid, &b_chid);
+   Notify();
+}
+
+Bool_t htree::Notify()
+{
+   // The Notify() function is called when a new file is opened. This
+   // can be either for a new TTree in a TChain or when when a new TTree
+   // is started when using PROOF. It is normally not necessary to make changes
+   // to the generated code, but the routine can be extended by the
+   // user if needed. The return value is currently not used.
+
+   return kTRUE;
+}
+
+void htree::Show(Long64_t entry)
+{
+// Print contents of entry.
+// If entry is not specified, print current entry
+   if (!fChain) return;
+   fChain->Show(entry);
+}
+Int_t htree::Cut(Long64_t entry)
+{
+// This function may be called from Loop.
+// returns  1 if entry is accepted.
+// returns -1 otherwise.
+   return 1;
+}
+#endif // #ifdef htree_cxx