FairRoot/PandaRoot
Functions | Variables
simu_tag.C File Reference
#include <map>
#include <vector>
#include <iostream>
#include "TFile.h"
#include "TSystemFile.h"
#include "TSystemDirectory.h"
#include "TList.h"
#include "TString.h"
#include "TTree.h"
#include "TEventList.h"

Go to the source code of this file.

Functions

void init_cuts (TString energy)
 
void init_modes ()
 
void get_tuples (TString beg="")
 
int get_N0 (TString fname, TString bgcut)
 
int cnt_events (TTree *t, TString cut, bool globcnt=false)
 
int simu_tag (TString energy="24")
 

Variables

std::vector< TStringlfiles
 
std::vector< TStringntps
 
std::map< TString, TStringcuts
 
std::map< TString, TStringmodes
 
std::map< int, int > evcnt
 

Function Documentation

int cnt_events ( TTree *  t,
TString  cut,
bool  globcnt = false 
)

Definition at line 126 of file simu_tag.C.

References ev, and evcnt.

127 {
128  Float_t ev;
129  t->Draw(">>el",cut);
130 
131  TEventList *el=(TEventList*)gDirectory->Get("el");
132 
133  t->SetBranchStatus("*",0);
134  t->SetBranchStatus("ev",1);
135  t->SetBranchAddress("ev",&ev);
136 
137  std::map<int, int> sigcnt;
138  for (int j=0;j<el->GetN();++j)
139  {
140  t->GetEntry(el->GetEntry(j));
141  sigcnt[(int)ev]+=1;
142  if (globcnt) evcnt[(int)ev]+=1;
143  }
144  t->SetBranchStatus("*",1);
145  return sigcnt.size();
146 }
int ev
double cut[MAX]
Definition: autocutx.C:36
TTree * t
Definition: bump_analys.C:13
CountMap evcnt
Definition: autocutx.C:31
int get_N0 ( TString  fname,
TString  bgcut 
)

Definition at line 115 of file simu_tag.C.

References f, and n.

Referenced by simu_tag().

116 {
117  TFile *f=new TFile(fname,"READ");
118  TTree *n = (TTree*) f->Get("ntp");
119 
120  int N0 = n->GetEntries(bgcut);
121  f->Close();
122  delete f;
123  return N0;
124 }
int n
TFile * f
Definition: bump_analys.C:12
void get_tuples ( TString  beg = "")

Definition at line 88 of file simu_tag.C.

References cuts, file, files, lfiles, next, ntps, and TString.

Referenced by simu_tag().

89 {
90  TSystemDirectory dir(".",".");
91  TList *files = dir.GetListOfFiles();
92  if (files)
93  {
94  TSystemFile *file;
95  TString fname;
96  TIter next(files);
97  while ((file=(TSystemFile*)next()))
98  {
99  fname = file->GetName();
100  if (!file->IsDirectory() && fname.BeginsWith(beg) && fname.EndsWith(".root")) {
101  TString nname=TString( fname(4,fname.Length()-9));
102  cout<< "Found " << fname.Data() <<endl;
103  if (nname!="ntp")
104  {
105  if (cuts.count(nname)!=0){
106  ntps.push_back(nname);
107  lfiles.push_back(fname);
108  }
109  }
110  }
111  }
112  }
113 }
TFile * file
TString cuts[MAX]
Definition: autocutx.C:35
std::map< int, TString > files
Definition: simubg.C:28
std::vector< TString > ntps
Definition: simu_tag.C:16
std::vector< TString > lfiles
Definition: simu_tag.C:15
static int next[96]
Definition: ranlxd.cxx:374
void init_cuts ( TString  energy)

Definition at line 23 of file simu_tag.C.

References cuts.

Referenced by simu_tag().

24 {
25  if (energy=="24")
26  {
27  cuts["nphi"] = "phipt>0.239374&&phid1pidpi<0.0114195&&npidkl>1.99";
28  cuts["nlam"] = "fw1>0.2&&pla>0.15&&fw4>0.2&&prapmax<2.5";
29  }
30  else if (energy=="38")
31  {
32  cuts["nphi"] = "phipcm>1.02899&&phipt>0.699287&&phid0pidk>0.40629";
33  cuts["nlam"] = "thr>0.908013&&lampt>0.803121&&prapmax<3";
34  cuts["njpsi"] = "jpsipcm<0.7";
35  cuts["nd01"] = "d0pcm<0.386277&&d0d0pidk>0.661042";
36  //cuts["nd02"] = "d0d0pidk>0.9&&d0pcm<0.292463";
37  //cuts["nd02"] = "d0d0pidk>0.8&&d0pcm<0.402238";
38  cuts["ndpm1"] = "dpmpcm<0.292203&&dpmd0pidk>0.630705";
39  //cuts["ndpm2"] = "dpmd0pidk>0.792914&&dpmpcm<0.3";
40  //cuts["ndpm3"] = "dpmpcm<0.381059&&prapmax<3";
41  //cuts["ndpm4"] = "dpmpcm<0.4&&prapmax<3";
42  }
43  else if (energy=="45")
44  {
45  cuts["nphi"] = "phipcm>1.376&&fw2>0.631154&&npidkl>1";
46  cuts["nlam"] = "fw2>0.603771&&lampt>0.881976&&fw2>0.8";
47  cuts["njpsi"] = "npt10>1&&jpsid0pidpi<0.2&&jpsid1pidpi<0.2";
48  cuts["nd01"] = "npt10>0&&d0d0pidk>0.453262&&prapmax<3";
49  //cuts["nd02"] = "d0d0pidk>0.9&&d0pcm<0.292463";
50  //cuts["nd02"] = "d0d0pidk>0.8&&d0pcm<0.402238";
51  cuts["ndpm1"] = "dpmd0pidk>0.5&&dpmpt>1&&prapmax<3&&dpmd0p>1.2";
52  //cuts["ndpm2"] = "dpmd0pidk>0.792914&&dpmpcm<0.3";
53  //cuts["ndpm3"] = "dpmpcm<0.381059&&prapmax<3";
54  //cuts["ndpm4"] = "dpmpcm<0.4&&prapmax<3";
55  cuts["nds1"] = "npidkl>1&&dsd1pidk>0.5&&dsd0pidk>0.5&&dsd1p>1.6";
56  }
57  else if (energy=="50")
58  {
59  cuts["nphi"] = "phipcm>1.75195&&fw2>0.654609&&phid1pidk>0.292159";
60  cuts["nlam"] = "fw2>0.8&&lampcm>2.15559&&lampt>1";
61  cuts["njpsi"] = "jpsipcm<1.73971&&jpsid1pidpi<0.2";
62  cuts["nd01"] = "d0d0pidk>0.394868&&prapmax<2.88343";
63  cuts["ndpm1"] = "dpmd0pidk>0.4&&dpmpt>0.7&&prapmax<3";
64  cuts["nds1"] = "npidkl>1&&dsd1pidk>0.642251&&dsd1p>1&&dsd0pidk>0.5";
65  cuts["nlamc"] = "abs(lamcpcm-1)<0.1&&lamcd1pidk>0.5&&lamcd0pidp>0.5";
66  cuts["netac1"]= "etacd1pidk>0.389332&&etacd0pidk>0.4";
67  }
68  else if (energy=="55")
69  {
70  }
71 }
TString cuts[MAX]
Definition: autocutx.C:35
Double_t energy
Definition: plot_dirc.C:15
void init_modes ( )

Definition at line 73 of file simu_tag.C.

References modes.

74 {
75  modes["nphi"] = "00";
76  modes["nlam"] = "31";
77  modes["njpsi"] = "21";
78  modes["nd01"] = "18"; modes["nd02"] = "182"; modes["nd03"] = "183";
79  modes["ndpm1"] = "14"; modes["ndpm2"] = "142"; modes["ndpm3"] = "143"; modes["ndpm4"] = "144";
80  modes["nds1"] = "17"; modes["nds2"] = "172";
81  modes["nlamc"] = "34";
82  modes["netac1"] = "70"; modes["netac2"] = "71"; modes["netac3"] = "72"; modes["netac4"] = "73";
83  modes["nchic01"] = "80";modes["nchic02"] = "81";
84 
85  modes["DPM"] = "50";
86 }
int modes[]
Definition: evaltrig.C:36
int simu_tag ( TString  energy = "24")

Definition at line 148 of file simu_tag.C.

References cnt_events(), cuts, energy, evcnt, f, get_N0(), get_tuples(), i, init_cuts(), init_modes(), lfiles, modes, nsig, ntps, t, and TString.

149 {
150  init_cuts(energy);
151  init_modes();
152 
153  TString bgcut = "mode=="+energy+modes["DPM"];
154 
155  TString pref = "M"+energy+"_";
156  get_tuples(pref);
157 
158  cout <<"\nn-tuples and cuts used: "<<endl;
159  for (uint i=0;i<ntps.size();++i) cout << lfiles[i]<<", "<<ntps[i]<<" : " <<cuts[ntps[i]]<<" && tag && "<<bgcut<<endl;
160  cout <<endl;
161 
162  int N0 = get_N0(pref+"ntp.root",bgcut);
163 
164  cout <<"Total Bkg N0 = "<<N0<<endl;
165 
166  int sum = 0;
167 
168  for (uint i=0;i<ntps.size();++i)
169  {
170  TString sigcut = "mode=="+energy+modes[ntps[i]];
171 
172  int sigN0 = get_N0(pref+"ntp.root",sigcut);
173 
174  TFile *f=new TFile(lfiles[i],"READ");
175  TTree *t= (TTree*)f->Get(ntps[i]);
176 
177  TString bcut=cuts[ntps[i]]+" && tag && "+bgcut;
178  TString scut=cuts[ntps[i]]+" && tag && "+sigcut;
179 
180  int nbg = cnt_events(t, bcut, true);
181  int nsig = cnt_events(t, scut);
182 
183  double eff_bg = (double)nbg/N0;
184  double eff_sg = (double)nsig/sigN0;
185 
186  TString ccut = cuts[ntps[i]];
187  ccut.ReplaceAll("&&"," && ");
188 
189  TString sout = TString::Format("%8s : BG = %5d/%6d = %7.5f SIG = %5d/%6d = %7.5f cut : %s\n",
190  ntps[i].Data(), nbg, N0, eff_bg, nsig, sigN0, eff_sg, ccut.Data());
191 
192  cout <<sout.Data();
193  sum+=nbg;
194 
195  f->Close();
196  delete f;
197  }
198 
199  double eff = evcnt.size()/(double)N0;
200  cout <<"\n\nN0_BG = "<<N0<<" SUM = "<<sum<<" SIMU TAG = "<<evcnt.size()<<" -> EFF = "<<eff<<" SUPR-FAC = "<<1./eff<<endl;
201 
202 /* for ( std::map< int, int, std::less< int > >::const_iterator iter = evcnt.begin();
203  iter != evcnt.end(); ++iter )
204  if (iter->second>1) cout << iter->first << '\t' << iter->second << '\n';*/
205 
206  return 0;
207 }
int modes[]
Definition: evaltrig.C:36
int get_N0(TString fname, TString bgcut)
Definition: simu_tag.C:115
Int_t i
Definition: run_full.C:25
void init_cuts(TString energy)
Definition: simu_tag.C:23
TString cuts[MAX]
Definition: autocutx.C:35
std::vector< TString > ntps
Definition: simu_tag.C:16
TFile * f
Definition: bump_analys.C:12
int cnt_events(TChain *t, TString cut, bool globcnt=false)
std::vector< TString > lfiles
Definition: simu_tag.C:15
int nsig
Definition: toy_core.C:46
void get_tuples(TString beg="")
Definition: simu_tag.C:88
TTree * t
Definition: bump_analys.C:13
CountMap evcnt
Definition: autocutx.C:31
void init_modes()
Definition: full_core_ntp.C:86
Double_t energy
Definition: plot_dirc.C:15

Variable Documentation

Definition at line 17 of file simu_tag.C.

std::map<int, int> evcnt

Definition at line 20 of file simu_tag.C.

std::vector<TString> lfiles

Definition at line 15 of file simu_tag.C.

Referenced by get_tuples(), and simu_tag().

Definition at line 18 of file simu_tag.C.

std::vector<TString> ntps

Definition at line 16 of file simu_tag.C.

Referenced by get_tuples(), and simu_tag().