FairRoot/PandaRoot
countevents.C
Go to the documentation of this file.
1 #include <algorithm>
2 #include <map>
3 #include <utility>
4 #include <iostream>
5 
6 #include "TFile.h"
7 #include "TTree.h"
8 #include "TString.h"
9 #include "TROOT.h"
10 #include "TEventList.h"
11 #include "TDirectory.h"
12 
13 #define MAX 1000
14 #define BINS 100
15 #define NCAN 3
16 
17 typedef std::map<int, int> CountMap;
18 
20 
21 Int_t ev, run, mode, rec, nbranch;
22 
23 // ---------------------------------------------------------------
24 
25 int uid(int lev, int lrun, int lmode)
26 {
27  return lev+10000*lrun+(((lmode/100)%10)*20+lmode%10)*100000;
28 }
29 
30 // ---------------------------------------------------------------
31 
33 {
34  TFile *f=new TFile(fname,"READ");
35  TTree *t=(TTree*)f->Get(ntp);
36 
37  t->Draw(">>el",cut);
38  TEventList *el = (TEventList*)gDirectory->Get("el");
39 
40  t->SetBranchAddress("ev",&ev);
41  t->SetBranchAddress("run",&run);
42  t->SetBranchAddress("mode",&mode);
43  t->SetBranchAddress("recmode",&rec);
44 
45  t->SetBranchStatus("*",0);
46  t->SetBranchStatus("ev",1);
47  t->SetBranchStatus("run",1);
48  t->SetBranchStatus("mode",1);
49  t->SetBranchStatus("recmode",1);
50 
51  evcnt.clear();
52 
53  for (int i=0;i<el->GetN();++i)
54  {
55  t->GetEntry(el->GetEntry(i));
56  evcnt[uid(ev,run,mode)]+=1;
57  }
58  t->SetBranchStatus("*",1);
59 
60  printf("EVT = %d CAND = %d\n",evcnt.size(), el->GetN());
61  return 0;
62 }
Int_t run
Definition: countevents.C:21
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
int countevents(TString fname, TString ntp, TString cut)
Definition: countevents.C:32
Int_t i
Definition: run_full.C:25
Int_t mode
Definition: countevents.C:21
Int_t nbranch
Definition: countevents.C:21
int uid(int lev, int lrun, int lmode)
Definition: countevents.C:25
std::map< int, int > CountMap
Definition: countevents.C:17
double cut[MAX]
Definition: autocutx.C:36
Int_t rec
Definition: countevents.C:21
CountMap evcnt
Definition: countevents.C:19
Int_t ev
Definition: countevents.C:21
TFile * f
Definition: bump_analys.C:12
std::map< int, int > CountMap
Definition: autocutx.C:29
TTree * t
Definition: bump_analys.C:13