Rev 277 | Rev 329 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 277 | Rev 319 | ||
---|---|---|---|
Line 6... | Line 6... | ||
6 | #include <TFile.h> |
6 | #include <TFile.h> |
7 | #include <TTree.h> |
7 | #include <TTree.h> |
8 | #include <TBranch.h> |
8 | #include <TBranch.h> |
9 | #include <TBufferJSON.h> |
9 | #include <TBufferJSON.h> |
10 | #include <TMath.h> |
10 | #include <TMath.h> |
11 | - | ||
- | 11 | #include <vector> |
|
12 | #include "BParticle.h" |
12 | #include "BParticle.h" |
13 | #include "BEvent.h" |
13 | #include "BEvent.h" |
14 | 14 | ||
15 | class Hdr{ |
15 | class Hdr{ |
16 | public: |
16 | public: |
17 | int id; |
17 | int id; |
18 | int len; |
18 | int len; |
19 | int progress; |
19 | int progress; |
20 | }; |
20 | }; |
21 | 21 | ||
- | 22 | std::vector<int> histogram(int n, ...){ |
|
- | 23 | std::vector<int> result; |
|
- | 24 | int val = 0; |
|
- | 25 | va_list ap; |
|
- | 26 | int i; |
|
- | 27 | ||
- | 28 | va_start(ap, n); |
|
- | 29 | for(i = 0; i < n; i++) { |
|
- | 30 | result.push_back( va_arg(ap, int) ); |
|
- | 31 | } |
|
- | 32 | va_end(ap); |
|
- | 33 | return result; |
|
- | 34 | } |
|
22 | 35 | ||
23 | class Blab2 { |
36 | class Blab2 { |
24 | public: |
37 | public: |
25 | const char *names[11]={"photon", "electron", "pion", "muon", "kaon", "proton", "J/Psi", "D", "D*", "B", "Phi"}; |
38 | const char *names[11]={"photon", "electron", "pion", "muon", "kaon", "proton", "J/Psi", "D", "D*", "B", "Phi"}; |
26 | 39 | ||
Line 37... | Line 50... | ||
37 | void Init(); |
50 | void Init(); |
38 | void event(); |
51 | void event(); |
39 | void Process(); |
52 | void Process(); |
40 | void h1d(const char *varname, const char *name, int nbins, double min, double max, int id ); |
53 | void h1d(const char *varname, const char *name, int nbins, double min, double max, int id ); |
41 | int selector(int pin, int charge, SIMPLEPID particlename, int hid, int pout ); |
54 | int selector(int pin, int charge, SIMPLEPID particlename, int hid, int pout ); |
- | 55 | int selector(int pin, int charge, SIMPLEPID particlename, std::vector<int> hid, int pout ); |
|
42 | int combiner(int id0 ,int id1 , int same, SIMPLEPID particlename, double min, double max, int hid, int id ); |
56 | int combiner(int id0 ,int id1 , int same, SIMPLEPID particlename, double min, double max, int hid, int id ); |
- | 57 | int combiner(int id0 ,int id1 , int same, SIMPLEPID particlename, double min, double max, std::vector<int>hid, int id ); |
|
43 | int fix_mass(int id); |
58 | int fix_mass(int id); |
44 | int Fill(int hid, BParticle *p); |
59 | int Fill(std::vector<int> hid, BParticle *p); |
45 | void plist(int i); |
60 | void plist(int i); |
46 | 61 | ||
47 | 62 | ||
48 | ClassDef ( Blab2, 1 ) |
63 | ClassDef ( Blab2, 1 ) |
49 | }; |
64 | }; |
Line 57... | Line 72... | ||
57 | 72 | ||
58 | 73 | ||
59 | void Blab2::h1d(const char *varname, const char *name, int nbins, double min, double max, int id ){ |
74 | void Blab2::h1d(const char *varname, const char *name, int nbins, double min, double max, int id ){ |
60 | TString svar(varname); |
75 | TString svar(varname); |
61 | TString axis[]={"mass (GeV/c2)", |
76 | TString axis[]={"mass (GeV/c2)", |
62 | "momentum (GeV/c)", |
77 | "momentum (GeV/c)", |
63 | "energy (GeV)","charge", |
78 | "energy (GeV)","charge", |
64 | "identity", |
79 | "identity", |
65 | "momentum (GeV/c)", |
80 | "momentum (GeV/c)", |
66 | "momentum (GeV/c)", |
81 | "momentum (GeV/c)", |
67 | "momentum (GeV/c)", |
82 | "momentum (GeV/c)", |
Line 79... | Line 94... | ||
79 | if (svar.Contains("GetZMomentum")) fHtype[id]=7; |
94 | if (svar.Contains("GetZMomentum")) fHtype[id]=7; |
80 | if (svar.Contains("GetTransverseMomentum")) fHtype[id]=8; |
95 | if (svar.Contains("GetTransverseMomentum")) fHtype[id]=8; |
81 | if (svar.Contains("GetTheta")) fHtype[id]=9; |
96 | if (svar.Contains("GetTheta")) fHtype[id]=9; |
82 | if (svar.Contains("GetCosTheta")) fHtype[id]=10; |
97 | if (svar.Contains("GetCosTheta")) fHtype[id]=10; |
83 | 98 | ||
84 | fH |
99 | //fH[id]= new TH1F(TString::Format("h%d",id), TString::Format("%s;%s;N",name,axis[fHtype[id]].Data()), nbins, min, max); |
85 | - | ||
86 | if (fHtype[id]==4) { |
100 | if (fHtype[id]==4) { |
87 | fH[id]= new TH1F(TString::Format("h%d",id), TString::Format("%s;%s;N",name,axis[fHtype[id]].Data()), 11, 0, 11); |
101 | fH[id]= new TH1F(TString::Format("h%d",id), TString::Format("%s;%s;N",name,axis[fHtype[id]].Data()), 11, 0, 11); |
88 | for (int i=0;i<11;i++) fH[id]->GetXaxis()->SetBinLabel(i+1,names[i]); |
102 | for (int i=0;i<11;i++) fH[id]->GetXaxis()->SetBinLabel(i+1,names[i]); |
89 | } else { |
103 | } else { |
90 | fH[id]= new TH1F(TString::Format("h%d",id), TString::Format("%s;%s;N",name,axis[fHtype[id]].Data()), nbins, min, max); |
104 | fH[id]= new TH1F(TString::Format("h%d",id), TString::Format("%s;%s;N",name,axis[fHtype[id]].Data()), nbins, min, max); |
91 | } |
105 | } |
92 | 106 | ||
93 | 107 | ||
94 | } |
108 | } |
95 | 109 | ||
- | 110 | ||
- | 111 | ||
96 | int Blab2::Fill(int |
112 | int Blab2::Fill(std::vector<int> id, BParticle *p){ |
- | 113 | for (int i=0; i< id.size(); i++){ |
|
- | 114 | int hid = id[i]; |
|
97 | if (hid>=0 && fH[hid]) { |
115 | if (hid>=0 && fH[hid]) { |
98 | double val; |
116 | double val; |
99 | switch (fHtype[hid]){ |
117 | switch (fHtype[hid]){ |
100 | case 0 : val = p->GetMass(); break; |
118 | case 0 : val = p->GetMass(); break; |
101 | case 1 : val = p->GetMomentum(); break; |
119 | case 1 : val = p->GetMomentum(); break; |
Line 110... | Line 128... | ||
110 | case 10: val = (p->GetMomentum()!=0) ? p->pz()/p->GetMomentum() : 0; break; |
128 | case 10: val = (p->GetMomentum()!=0) ? p->pz()/p->GetMomentum() : 0; break; |
111 | default: val = 0 ; break; |
129 | default: val = 0 ; break; |
112 | } |
130 | } |
113 | fH[hid]->Fill(val); |
131 | fH[hid]->Fill(val); |
114 | } |
132 | } |
- | 133 | ||
- | 134 | } |
|
115 | 135 | ||
116 | return 0; |
136 | return 0; |
- | 137 | } |
|
- | 138 | int Blab2::combiner(int _p0, int _p1,int same, SIMPLEPID pid, double min, double max, int hid, int _p2 ){ |
|
- | 139 | std::vector<int> a; |
|
- | 140 | return combiner(_p0,_p1,same,pid,min,max,a,_p2); |
|
117 | } |
141 | } |
118 | 142 | ||
119 | int Blab2::combiner(int _p0, int _p1,int same, SIMPLEPID pid, double min, double max, int hid, int _p2 ){ |
143 | int Blab2::combiner(int _p0, int _p1,int same, SIMPLEPID pid, double min, double max, std::vector<int> hid, int _p2 ){ |
120 | // Loop over all the particles in both lists. |
144 | // Loop over all the particles in both lists. |
121 | if (_p0 < 0 ) _p0 =0; |
145 | if (_p0 < 0 ) _p0 =0; |
122 | if (_p1 < 0 ) _p1 =0; |
146 | if (_p1 < 0 ) _p1 =0; |
123 | 147 | ||
124 | 148 | ||
Line 145... | Line 169... | ||
145 | } |
169 | } |
146 | return _p2; |
170 | return _p2; |
147 | } |
171 | } |
148 | 172 | ||
149 | 173 | ||
150 | int Blab2::selector(int pin, int charge, SIMPLEPID type , int hid, int pout ){ |
174 | int Blab2::selector(int pin, int charge, SIMPLEPID type , int hid, int pout ){ |
- | 175 | std::vector<int> a; |
|
- | 176 | return selector(pin,charge,type,a,pout); |
|
- | 177 | } |
|
- | 178 | int Blab2::selector(int pin, int charge, SIMPLEPID type , std::vector<int> hid, int pout ){ |
|
151 | if (pin < 0 ) pin =0; |
179 | if (pin < 0 ) pin =0; |
152 | 180 | ||
153 | fList[pout]->Clear(); |
181 | fList[pout]->Clear(); |
154 | int nprt=0; |
182 | int nprt=0; |
155 | 183 |