FairRoot/PandaRoot
Macros | Functions | Variables
cutqa.C File Reference
#include "TFile.h"
#include "TTree.h"
#include "TString.h"
#include "TH1F.h"
#include "TCanvas.h"
#include "TROOT.h"
#include "TEventList.h"
#include "TDirectory.h"
#include <iostream>
#include <map>

Go to the source code of this file.

Macros

#define MAX   200
 
#define BINS   500
 
#define NCAN   3
 

Functions

int countEvents (TTree *t, TString ccut)
 
int cutqa (TString pre, TString ntp, TString var, TString cut="", int n0sig=0, int n0bkg=0)
 

Variables

std::map< int, int > evcnt
 

Macro Definition Documentation

#define BINS   500

Definition at line 14 of file cutqa.C.

#define MAX   200

Definition at line 13 of file cutqa.C.

#define NCAN   3

Definition at line 15 of file cutqa.C.

Function Documentation

int countEvents ( TTree *  t,
TString  ccut 
)

Definition at line 19 of file cutqa.C.

References ev, evcnt, and i.

Referenced by cutqa().

20 {
21  t->SetEventList(0);
22  t->SetBranchStatus("*",1);
23  t->Draw(">>el",ccut);
24  t->SetBranchStatus("*",0);
25  t->SetBranchStatus("evt",1);
26 
27  TEventList *el=(TEventList*)gDirectory->Get("el");
28 
29  Float_t ev;
30  t->SetBranchAddress("evt",&ev);
31 
32  evcnt.clear();
33 
34  for (int i=0;i<el->GetN();++i)
35  {
36  t->GetEntry(el->GetEntry(i));
37  evcnt[ev]+=1;
38  }
39  t->SetBranchStatus("*",1);
40 
41  return evcnt.size();
42 }
Int_t i
Definition: run_full.C:25
int ev
std::map< int, int > evcnt
Definition: cutqa.C:17
TTree * t
Definition: bump_analys.C:13
int cutqa ( TString  pre,
TString  ntp,
TString  var,
TString  cut = "",
int  n0sig = 0,
int  n0bkg = 0 
)

Definition at line 45 of file cutqa.C.

References countEvents(), cut, ev, f, h, i, mode, nsig, t, and TString.

46 {
47  TString bgcode="900";
48  TFile *f=new TFile("M"+pre+"_"+ntp+".root","READ");
49  TTree *t=(TTree*)f->Get(ntp);
50 
51  int bkgmode = pre.Atoi()*100+50;
52 
53  Float_t ev, mode;
54  t->SetBranchAddress("evt",&ev);
55  t->SetBranchAddress("mode",&mode);
56 
57  if (cut=="") cut="1";
58 
59  bool twod = var.Contains(":");
60 
61  int i,j,k;
62 
63  int nsig, nbkg;
64 
65  TString sigcut="tag&&mode!="+bgcode+"&&mct";
66  t->Draw(var+">>h(150)",sigcut);
67  TH1F *h=(TH1F*)gDirectory->Get("h");
68  nsig=h->GetEntries();
69  sigcut+="&&"+cut;
70 
71  TString bkgcut="tag&&mode=="+bgcode;
72  t->Draw(var+">>h(150)",bkgcut);
73  h=(TH1F*)gDirectory->Get("h");
74  nbkg=h->GetEntries();
75  bkgcut+="&&"+cut;
76 
77  t->Draw(var+">>hs(150)",sigcut);
78  TH1F *hs=(TH1F*)gDirectory->Get("hs");
79  hs->SetLineColor(2);
80  t->Draw(var+">>hb(150)",bkgcut,"same");
81  TH1F *hb= (TH1F*)gDirectory->Get("hb");
82 
83 /* hs->Scale(1./hs->GetEntries());
84  hb->Scale(1./hb->GetEntries());*/
85 
86  if (twod)
87  {
88  hs->SetMarkerColor(2);
89  hb->Draw();hs->Draw("same");
90  }
91  else
92  if (hs->GetMaximum()>hb->GetMaximum())
93  {
94  hs->Draw();hb->Draw("same");
95  }
96  else
97  {
98  hb->Draw();hs->Draw("same");
99  }
100 
101  int nev_sig=0, nev_bkg=0, ncnd_sig=0, ncnd_bkg=0;
102 
103 /* TEventList el("el","");
104 
105  // bkg count
106  t->Draw(">>el","tag&&mode!="+pre+"50&&"+cut);
107  t->SetEventList(&el);*/
108 // t->SetBranchStatus("*",0);
109 // t->SetBranchStatus("ev",1);
110 // t->SetBranchStatus("tag",1);
111 // t->SetBranchStatus("mode",1);
112 
113 /* Float_t currev=-1;
114 
115  for (j=0;j<el.GetN();++j)
116  {
117  t->GetEntry(el.GetEntry(j));
118  if (currev!=ev)
119  {
120  nev_sig++;
121  currev=ev;
122  }
123  }*/
124  cout <<"CAND: N_sig = "<<hs->GetEntries();
125 /* t->SetEventList(0);
126  t->Draw(">>el","tag&&mode=="+pre+"50&&"+cut);
127  t->SetEventList(&el);
128  currev=-1;
129 
130  for (j=0;j<el.GetN();++j)
131  {
132  t->GetEntry(el.GetEntry(j));
133  if (currev!=ev)
134  {
135  nev_bkg++;
136  currev=ev;
137  }
138  }*/
139  cout <<" N_bkg = "<<hb->GetEntries()<<endl;;
140  cout <<"CAND: eff_sig = "<< hs->GetEntries()/nsig<<" eff_bkg = "<<hb->GetEntries()/nbkg<<endl;
141 
142 /* t->SetBranchStatus("*",1);*/
143  t->SetEventList(0);
144 
145  nev_sig = countEvents(t, "tag&&mode!="+bgcode+"&&"+cut);
146  nev_bkg = countEvents(t, "tag&&mode=="+bgcode+"&&"+cut);
147 
148  cout <<"EVTS: N_sig = "<< nev_sig<<" N_bkg = "<<nev_bkg<<endl;
149  if (n0sig>0 && n0bkg>0)
150  cout <<"EVTS: eff_sig = "<< nev_sig*0.001/n0sig<<" eff_bkg = "<<nev_bkg*0.001/n0bkg<<endl;
151 
152  return 0;
153 }
Int_t i
Definition: run_full.C:25
int ev
double cut[MAX]
Definition: autocutx.C:36
Int_t mode
Definition: autocutx.C:47
TFile * f
Definition: bump_analys.C:12
int nsig
Definition: toy_core.C:46
int countEvents(TTree *t, TString ccut)
Definition: cutqa.C:19
TTree * t
Definition: bump_analys.C:13

Variable Documentation

std::map<int, int> evcnt

Definition at line 17 of file cutqa.C.

Referenced by countEvents().