FairRoot/PandaRoot
toy_core.C
Go to the documentation of this file.
1 #include "EventShape.h"
2 #include "SimpleNtp.C"
3 //#include "SimpleCand.C"
4 #include <iostream>
5 #include <vector>
6 #include <map>
7 
8 #include "TFile.h"
9 #include "TTree.h"
10 #include "TRandom3.h"
11 #include "TDatabasePDG.h"
12 #include "TParticlePDG.h"
13 #include "TCanvas.h"
14 #include "TH1F.h"
15 #include "TH2F.h"
16 #include "TLegend.h"
17 #include "TParticle.h"
18 #include "TClonesArray.h"
19 #include "TF1.h"
20 #include "TStyle.h"
21 #include "TNtuple.h"
22 #include "TLatex.h"
23 #include "TGaxis.h"
24 
25 using std::cout;
26 using std::endl;
27 
28 TRandom3 fRand;
29 TLorentzVector fIni;
30 
31 // *** some program parameters
32 const int fMAX = 100; // *** max tracks per event
33 int nbins = 300; // *** bins of mass histograms
34 double low = 0.0; // *** lower edge of histo
35 double high = 6.0; // *** higher edge of histo (will be modified acc. to resonance mass)
36 
37 // *** some contants for neutrals
38 const double fNeutEff = 0.95; // *** efficiency for neutrals
39 const double fdE = 0.05; // *** neutral energy resolution
40 const double fNdtht = 0.003; // *** neutrals tht resolution
41 const double fNdphi = 0.003; // *** neutrals phi resolution
42 
43 // number of sigmas selection for pi0, KS
44 int nsigpiks = 5;
45 // number of sigmas selection for channels
46 int nsig = 8;
47 
48 // *** constants for particles
49 int fPi0Pdg = 111; // *** PDG code for pi0
50 double fPi0Mass = 0.13497; // *** center of mass cut window
51 double fPi0win = 0;
52 double fPi0sig = 0.0055;
53 
54 int fKsPdg = 310; // *** PDG code for pi0
55 double fKsMass = 0.497614; // *** center of mass cut window
56 double fKswin = 0.025;
57 double fKssig = 0.012;
58 
59 int fDPdg = 411; // *** PDG code to match D
60 double fDMass = 1.8693; // *** center of mass cut window
61 double fDsig = 0.045; // *** sigma of peak
62 double fDwin =0.25;
63 
64 int fD0Pdg = 421; // *** PDG code to match D0
65 double fD0Mass = 1.8645; // *** center of mass cut window
66 double fD0sig = 0.055; // *** sigma of peak
67 double fD0win =0.25;
68 
69 int fJpsiPdg = 443; // *** PDG code to match J/psi
70 double fJMass = 3.09687; // *** center of mass cut window
71 double fJsig = 0.11; // *** sigma of peak
72 double fJwin =0.7;
73 
74 int feePdg = 88880; // *** PDG code to match pbarpSystem
75 double feeMass = 0; // *** center of mass cut window, here = sqrt(s)
76 double feesigconst = 0.0024; // *** const of linear width function
77 double feesigslope = 0.036; // *** slope of linear width function
78 double feewin = 0.; // *** to be determined by function
79 
80 int fLamPdg = 3122; // *** PDG code to match Lam
81 double fLamMass = 1.115684; // *** center of mass cut window
82 double fLamsig = 0.0042; // *** sigma of peak
83 double fLamwin =0.1;
84 
85 int fDsPdg = 431; // *** PDG code to match Ds
86 double fDsMass = 1.9686; // *** center of mass cut window
87 double fDssig = 0.04; // *** sigma of peak
88 double fDswin =0.2;
89 
90 int fPhiPdg = 333; // *** PDG code to match Phi
91 double fPhiMass = 1.0195; // *** center of mass cut window
92 double fPhisig = 0.0065; // *** sigma of peak
93 double fPhiwin =0.2;
94 
95 int fEtacPdg = 441; // *** PDG code to match etac
96 double fEtacMass = 2.9798; // *** center of mass cut window
97 double fEtacsig = 0.08; // *** sigma of peak
98 double fEtacwin =0.15;
99 
100 int fLamcPdg = 4122; // *** PDG code to match Lambda_c
101 double fLamcMass = 2.2849; // *** center of mass cut window
102 double fLamcsig = 0.035; // *** sigma of peak
103 double fLamcwin =0.2;
104 
105 // *** pid probability table; will be modified according to purity parameter value
106 // *** true pid: e mu pi K p classified as [%]
107 double pidtab [25] = { 80, 5, 5, 5, 5, // e
108  5, 80, 5, 5, 5, // mu
109  5, 5, 80, 5, 5, // pi
110  5, 5, 5, 80, 5, // K
111  5, 5, 5, 5, 80 }; // p
112 
113 // *** table determined by Donghee 11/2012 for P>0.1
114 double pidreal [25] = { 95, 6, 10, 7, 10, // e
115  5, 86, 27, 6, 7, // mu
116  9, 29, 85, 18, 16, // pi
117  9, 21, 40, 67, 24, // K
118  12, 12, 20, 16, 90 }; // p
119 
120 // *** global stable particle masses used in pid selection; set in init()
121 double mE, mMu, mPi, mK, mP, mPi0;
122 
123 TF1 *f_res=0;
125 
126 // *** this map contains mapping from PDG code to indices 0...4 (for pidtab)
127 // *** 11 -> 0, 13 -> 1, 211 -> 2, 321 -> 3, 2212 -> 4
128 std::map<int,int> pdgidx;
129 
130 TDatabasePDG *pdg_db;
131 
132 typedef std::vector<SimpleCand> CandList;
133 
134 // *** all global particle lists we need to do combinatorics
136 
137 // *** the global pid lists
139 
140 // *** setup style
141 void setStyle()
142 {
143  gStyle->SetPadTopMargin(0.13);
144  gStyle->SetPadBottomMargin(0.18);
145  gStyle->SetPadLeftMargin(0.2);
146  gStyle->SetPadRightMargin(0.015);
147 
148  gStyle->SetLabelSize(0.075,"X");
149  gStyle->SetLabelSize(0.07,"Y");
150 
151  gStyle->SetStatY(0.87);
152  gStyle->SetStatX(0.985);
153  gStyle->SetStatW(0.4);
154  gStyle->SetStatH(0.12);
155  gStyle->SetOptStat("e"); // only entries
156 
157  gStyle->SetTitleH(0.1);
158  gStyle->SetTitleX(0.08);
159  gStyle->SetTitleOffset(1.1,"x");
160  gStyle->SetTitleXSize(0.075);
161 }
162 
163 // *** boost full list with -boost and store in boostlist
164 void boostList(CandList &list, CandList &boostlist, TVector3 boost)
165 {
166  int N=list.size();
167  boostlist.clear();
168 
169  for (unsigned int i=0;i<N;i++)
170  {
171  SimpleCand c=list[i];
172  TLorentzVector lv(c.P4());
173  lv.Boost(-boost);
174  c.SetP4(lv);
175  boostlist.push_back(c);
176  }
177 }
178 
179 // *** check PDG code is final state particle
180 bool isFinalState(int n)
181 {
182  n=abs(n);
183  return (n==11 || n==13 || n==211 || n==321 || n==2212 || n==22);
184 }
185 
186 // *** online momentum resoltion based on talk of Yutie Lang, PANDA CM 12/2011, TRK oder DAQ session
187 // *** values (pt[GeV/c], dp/p[%]): (1.0, 3.8) (2.0, 5.5) (5.0, 12.2)
188 // *** see init routine for function parameters
189 double dponline(TLorentzVector &v)
190 {
191  return f_res->Eval(v.Pt())/100.;
192 }
193 
194 // *** computes the pid table for given efficiency and purity
195 void makePidTable(double pideff, double misid)
196 {
197  cout<< "Using PID table:"<<endl;
198 
199  if (pideff<0 && misid<0)
200  {
201  for (int i=0;i<5;++i)
202  {
203  for (int j=0;j<5;++j)
204  {
205  //pidtab[j+5*i] = pidreal[j+5*i];
206  printf("%4.0f",pidtab[j+5*i]);
207  //cout << pidtab[i+5*j]<<" ";
208  }
209  cout<< endl;
210  }
211  return;
212  }
213 
214  if (pideff<0) pideff=0;
215  if (pideff>100) pideff=100;
216  if (misid>100) misid=100;
217 
218  // *** neff is the efficiency for particles of wrong type
219  //double neff = pideff*(100-pidpur)/(4*pidpur);
220  //if (neff>100) neff=100;
221 
222  for (int i=0;i<5;++i)
223  {
224  for (int j=0;j<5;++j)
225  {
226  if (i==j) pidtab[i+5*j] = pideff;
227  else pidtab[i+5*j] = misid;
228  cout << pidtab[i+5*j]<<" ";
229  }
230  cout<< endl;
231  }
232 }
233 
234 // *** initialization of some globals
235 void init(double pideff, double misid)
236 {
237  // *** setting the mapping of PDG code to tab index
238  pdgidx.clear();
239  pdgidx[11]=0;
240  pdgidx[13]=1;
241  pdgidx[211]=2;
242  pdgidx[321]=3;
243  pdgidx[2212]=4;
244 
245  pdg_db=TDatabasePDG::Instance();
246 
247  // *** create pid table
248  makePidTable(pideff, misid);
249 
250  // *** gets particle masses from pdg database and set them globally
251  mE = pdg_db->GetParticle(11)->Mass();
252  mMu = pdg_db->GetParticle(13)->Mass();
253  mPi = pdg_db->GetParticle(211)->Mass();
254  mK = pdg_db->GetParticle(321)->Mass();
255  mP = pdg_db->GetParticle(2212)->Mass();
256 
257  mPi0= pdg_db->GetParticle(111)->Mass();
258 
259  // *** resolution fcn based on Yutie Lang results; see routine dponline above
260  f_res=new TF1("f_res","pol2(0)");
261  f_res->SetParameters(2.367,1.3,0.133);
262  f_res->SetRange(0,10);
263 }
264 
265 // *** prints single candidate of type SimpleCand
267 {
268  cout <<c.Id()<<" pid:"<<c.Pid()<<" ("<<c.P4().X()<<","<<c.P4().Y()<<","<<c.P4().Z()<<";"<<c.P4().T()<<") ";
269  cout <<c.Charge()<<" "<<c.P4().M();
270  cout <<" moth:"<<c.MotherIdx()<<" nsib:"<<c.NSiblings()<<" nfs:"<<c.NFS();
271  cout <<" mcpid:"<<c.McPid()<<" mct:"<<c.Mct()<<endl;
272 }
273 
274 // *** prints list of candidates
275 void printList(CandList &l, TString tit="")
276 {
277  if (tit!="") cout << tit<<endl;
278  for (unsigned int j=0;j<l.size();++j) printCand(l[j]);
279  cout <<endl;
280 }
281 
282 // *** prints all global lists
284 {
285  printList(mclist, "MC List");
286  printList(recolist, "Reco List");
287 
288  printList(eplus, "e+ List");
289  printList(eminus, "e- List");
290 
291  printList(muplus, "mu+ List");
292  printList(muminus, "mu- List");
293 
294  printList(piplus, "pi+ List");
295  printList(piminus, "pi- List");
296 
297  printList(kplus, "k+ List");
298  printList(kminus, "k- List");
299 
300  printList(pplus, "p+ List");
301  printList(pminus, "p- List");
302 
303  printList(gam, "gamma List");
304 }
305 
306 // *** counts how many combinations (=composite particles in l) fullfill the mass criterion
307 int massCrit(CandList &l, double m, double w)
308 {
309  int cnt = 0;
310  for (unsigned int i=0;i<l.size();++i)
311  {
312  double mass=l[i].P4().M();
313  if (mass>m-w && mass<m+w) cnt++;
314  }
315 
316  return cnt;
317 }
318 
319 // *** is there one mass combination in the window?
320 bool eventAccepted(CandList &l, double m =0, double w=0)
321 {
322  bool accepted = false;
323  unsigned int i=0;
324 
325  while (!accepted && i<l.size())
326  //for (unsigned int i=0;i<l.size();++i)
327  {
328  double mass = l[i++].P4().M();
329  if (mass>m-w && mass<m+w) accepted =true;
330  }
331 
332  return accepted;
333 }
334 
335 
336 // *** fill the mass histos
337 int fillHisto(CandList &l, TH1 *hall, TH1* hbg=0, double m =0, double w=0, TH1* hallsel=0, TH1* hbgsel=0, TH1* hsig=0, TH1* hmm=0, TH2* hmvsmm=0)
338 {
339  int cnt =0;
340  for (unsigned int i=0;i<l.size();++i)
341  {
342  double mass = l[i].P4().M();
343  double miss = (fIni-l[i].P4()).M();
344  hall->Fill(mass);
345 
346  //missing mass
347  if (hmm) hmm->Fill(miss);
348  if (hmvsmm) hmvsmm->Fill(mass, miss);
349 
350  bool mct = l[i].Mct();
351  if (hbg && !mct) hbg->Fill(mass);
352  if (hsig && mct) hsig->Fill(mass);
353  if (mass>m-w && mass<m+w)
354  {
355  cnt++;
356  if (hallsel) hallsel->Fill(mass);
357  if (hbgsel && !mct) hbgsel->Fill(mass);
358  }
359  }
360  return cnt;
361 }
362 
363 int combine(CandList &l1, CandList &l2, CandList &out, int matchPdg=0)
364 {
365  out.clear();
366 
367  bool sameList = (&l1 == &l2);
368 
369  for (unsigned int i=0;i<l1.size();++i)
370  {
371  for (unsigned int j=0;j<l2.size();++j)
372  {
373  if (sameList && j<=i) continue;
374  if (l1[i].Marker() & l2[j].Marker()) continue; // *** overlap
375  //if (l1[i].EvtId()!=l2[j].EvtId()) continue; // *** tracks from different events
376  SimpleCand c;
377  c.SetP4(l1[i].P4()+l2[j].P4());
378  c.SetCharge(l1[i].Charge()+l2[j].Charge());
379  c.SetNFS(l1[i].NFS()+l2[j].NFS());
380  c.SetMarker(l1[i].Marker() | l2[j].Marker());
381  c.AddDau(&(l1[i]));c.AddDau(&(l2[j]));
382  c.SetPdg(matchPdg);
383 
384  int m1 = l1[i].MotherIdx();
385  int m2 = l2[j].MotherIdx();
386  int ev1 = l1[i].EvtId();
387  int ev2 = l2[j].EvtId();
388 
389  if ( ev1==ev2 && // *** particles are from same event
390  m1>=0 && m1 == m2 && // *** there is a common mother of all particles
391  (l1[i].McPid()||l1[i].Mct()) && // *** all particles match (FS: PID, Comp:mct)
392  (l2[j].McPid()||l2[j].Mct()) && // *** "
393  2==mclist[m1].NDau() && // *** mother has as many daughters as we combine particles
394  matchPdg == mclist[m1].Pid() ) // *** mother has correct PDG
395  {
396  c.SetId(m1);
397  c.SetMcPid();
398  c.SetMct();
399  c.SetMotherIdx(mclist[m1].MotherIdx());
400  c.SetEvtId(ev1);
401  }
402 
403  out.push_back(c);
404  }
405  }
406  return out.size();
407 }
408 
409 int combine(CandList &l1, CandList &l2, CandList &l3, CandList &out, int matchPdg=0)
410 {
411  out.clear();
412 
413  bool same12 = (&l1 == &l2);
414  bool same13 = (&l1 == &l3);
415  bool same23 = (&l2 == &l3);
416 
417  for (unsigned int i1=0;i1<l1.size();++i1)
418  {
419  for (unsigned int i2=0;i2<l2.size();++i2)
420  {
421  if (same12 && i2<i1) continue;
422  if (l1[i1].Marker() & l2[i2].Marker()) continue;
423 
424  for (unsigned int i3=0;i3<l3.size();++i3)
425  {
426  if ((same13 && i3<i1) || (same23 && i3<i2)) continue;
427 
428  if ( l1[i1].Marker() & l3[i3].Marker() ) continue;
429  if ( l2[i2].Marker() & l3[i3].Marker() ) continue;
430 
431  //if (l1[i1].EvtId()!=l2[i2].EvtId() ||
432  // l1[i1].EvtId()!=l3[i3].EvtId() ||
433  // l2[i2].EvtId()!=l3[i3].EvtId() ) continue; // *** tracks from different events
434 
435  SimpleCand c;
436  c.SetP4( l1[i1].P4() + l2[i2].P4() + l3[i3].P4());
437  c.SetCharge( l1[i1].Charge() + l2[i2].Charge() + l3[i3].Charge() );
438  c.SetNFS( l1[i1].NFS() + l2[i2].NFS() + l3[i3].NFS());
439  c.SetMarker( l1[i1].Marker() | l2[i2].Marker() | l3[i3].Marker() );
440  c.AddDau(&(l1[i1]));c.AddDau(&(l2[i2]));c.AddDau(&(l3[i3]));
441  c.SetPdg(matchPdg);
442 
443  int m1 = l1[i1].MotherIdx();
444  int m2 = l2[i2].MotherIdx();
445  int m3 = l3[i3].MotherIdx();
446 
447  int ev1 = l1[i1].EvtId();
448  int ev2 = l2[i2].EvtId();
449  int ev3 = l3[i3].EvtId();
450 
451  if ( ev1==ev2 && ev2==ev3 && // *** particles are from same event
452  m1>=0 && m1 == m2 && m2 == m3 && // *** there is a common mother of all particles
453  (l1[i1].McPid()||l1[i1].Mct()) && // *** all particles match (FS: PID, Comp:mct)
454  (l2[i2].McPid()||l2[i2].Mct()) && // *** "
455  (l3[i3].McPid()||l3[i3].Mct()) && // *** "
456  3==mclist[m1].NDau() && // *** mother has as many daughters as we combine particles
457  matchPdg == mclist[m1].Pid() ) // *** mother has correct PDG
458  {
459  c.SetId(m1);
460  c.SetMcPid();
461  c.SetMct();
462  c.SetMotherIdx(mclist[m1].MotherIdx());
463  c.SetEvtId(ev1);
464  }
465 
466  out.push_back(c);
467  }
468  }
469  }
470 
471  return out.size();
472 }
473 
474 int combine(CandList &l1, CandList &l2, CandList &l3, CandList &l4, CandList &out, int matchPdg=0)
475 {
476  out.clear();
477 
478  bool same12 = (&l1 == &l2);
479  bool same13 = (&l1 == &l3);
480  bool same14 = (&l1 == &l4);
481 
482  bool same23 = (&l2 == &l3);
483  bool same24 = (&l2 == &l4);
484 
485  bool same34 = (&l3 == &l4);
486 
487  for (unsigned int i1=0;i1<l1.size();++i1)
488  {
489  for (unsigned int i2=0;i2<l2.size();++i2)
490  {
491  if (same12 && i2<i1) continue;
492  if (l1[i1].Marker() & l2[i2].Marker()) continue;
493 
494  for (unsigned int i3=0;i3<l3.size();++i3)
495  {
496  if ((same13 && i3<i1) || (same23 && i3<i2)) continue;
497 
498  if ( l1[i1].Marker() & l3[i3].Marker() ) continue;
499  if ( l2[i2].Marker() & l3[i3].Marker() ) continue;
500 
501  for (unsigned int i4=0;i4<l4.size();++i4)
502  {
503  if ((same14 && i4<i1) || (same24 && i4<i2) || (same34 && i4<i3)) continue;
504 
505  if ( l1[i1].Marker() & l4[i4].Marker() ) continue;
506  if ( l2[i2].Marker() & l4[i4].Marker() ) continue;
507  if ( l3[i3].Marker() & l4[i4].Marker() ) continue;
508 
509  //if (l1[i1].EvtId()!=l2[i2].EvtId() ||
510  // l1[i1].EvtId()!=l3[i3].EvtId() ||
511  // l2[i2].EvtId()!=l3[i3].EvtId() ) continue; // *** tracks from different events
512 
513  SimpleCand c;
514  c.SetP4( l1[i1].P4() + l2[i2].P4() + l3[i3].P4() + l4[i4].P4() );
515  c.SetCharge( l1[i1].Charge() + l2[i2].Charge() + l3[i3].Charge() + l4[i4].Charge() );
516  c.SetNFS( l1[i1].NFS() + l2[i2].NFS() + l3[i3].NFS() + l4[i4].NFS() );
517  c.SetMarker( l1[i1].Marker() | l2[i2].Marker() | l3[i3].Marker() | l4[i4].Marker() );
518  c.AddDau(&(l1[i1]));c.AddDau(&(l2[i2]));c.AddDau(&(l3[i3]));c.AddDau(&(l4[i4]));
519  c.SetPdg(matchPdg);
520 
521  int m1 = l1[i1].MotherIdx();
522  int m2 = l2[i2].MotherIdx();
523  int m3 = l3[i3].MotherIdx();
524  int m4 = l4[i4].MotherIdx();
525 
526  int ev1 = l1[i1].EvtId();
527  int ev2 = l2[i2].EvtId();
528  int ev3 = l3[i3].EvtId();
529  int ev4 = l4[i4].EvtId();
530 
531  if ( ev1==ev2 && ev2==ev3 && ev3==ev4 && // *** particles are from same event
532  m1>=0 && m1 == m2 && m2 == m3 && m3 == m4 && // *** there is a common mother of all particles
533  (l1[i1].McPid()||l1[i1].Mct()) && // *** all particles match (FS: PID, Comp:mct)
534  (l2[i2].McPid()||l2[i2].Mct()) && // *** "
535  (l3[i3].McPid()||l3[i3].Mct()) && // *** "
536  (l4[i4].McPid()||l4[i4].Mct()) && // *** "
537  4==mclist[m1].NDau() && // *** mother has as many daughters as we combine particles
538  matchPdg == mclist[m1].Pid() ) // *** mother has correct PDG
539  {
540  c.SetId(m1);
541  c.SetMcPid();
542  c.SetMct();
543  c.SetMotherIdx(mclist[m1].MotherIdx());
544  c.SetEvtId(ev1);
545  }
546 
547  out.push_back(c);
548  }
549  }
550  }
551  }
552 
553  return out.size();
554 }
555 
556 
557 void smearMom(SimpleCand &c, double dpr=0.05, double dtht=0.000, double dphi=0.000)
558 {
559  TLorentzVector p4=c.P4();
560 
561  // *** use resolution function
562  if (dpr<0) dpr = dponline(p4);
563 
564  double p = p4.P();
565  double m = p4.M();
566 
567  double dp = p*dpr;
568  double newp = -1;
569 
570  if (dp==0) newp=p;
571  while (newp<0) newp = p4.P() + fRand.Gaus(0.0,dp);
572 
573  p4.SetVectM( p4.Vect().Unit()*newp, m );
574 
575  double newtht = p4.Theta();
576  if (dtht!=0) newtht += fRand.Gaus(0.,dtht);
577  p4.SetTheta(newtht);
578 
579  double newphi = p4.Phi();
580  if (dphi!=0) newphi += fRand.Gaus(0.,dphi);
581  p4.SetPhi(newphi);
582 
583  c.SetP4(p4);
584 
585 }
586 
587 bool isDetected(double eff=0.90)
588 {
589  // very simple efficiency cut; might be dependent on candidate itself later
590  if (fRand.Rndm()<eff) return true;
591  return false;
592 }
593 
594 void makeRecoCands(CandList &mc, CandList &reco, double eff=0.90, double dp=0.05, double dtht=0.001, double dphi=0.001)
595 {
596  reco.clear();
597 
598  unsigned int marker = 1;
599 
600  for (unsigned int i=0;i<mc.size();i++)
601  {
602  SimpleCand c=mc[i];
603  int pid = abs(c.Pid());
604  if (!isFinalState(pid)) continue;
605 
606  if (pid!=22 && isDetected(eff)) // *** charged track
607  {
608  smearMom(c,dp,dtht,dphi);
609  // set pion mass as default
610  c.SetMass(0.13957);
611  c.SetMarker(marker);
612  c.SetPdg(211*c.Charge());
613  marker *=2;
614  reco.push_back(c);
615  }
616  else if (pid==22 && isDetected(fNeutEff)) // *** neutral
617  {
618  smearMom(c,fdE, fNdtht, fNdphi);
619  c.SetMarker(marker);
620  c.SetPdg(22);
621  marker *=2;
622  reco.push_back(c);
623  }
624  }
625 }
626 
627 // **** A simple mass selector
628 void selectMass(CandList &in, CandList &out, double mmean=0, double mw=0)
629 {
630  out.clear();
631 
632  for (unsigned int i=0;i<in.size();++i)
633  if (fabs(in[i].P4().M()-mmean)<mw) out.push_back(in[i]);
634 
635 }
636 
637 // *** perform pid selection according to the pidtable
638 void select(CandList &in, CandList &out, int chrg=0, int pdg=0, double mass=0.139)
639 {
640  out.clear();
641 
642  TParticlePDG *part = pdg_db->GetParticle(pdg);
643 
644  //pdg *= pdg<20 ? -chrg : chrg;
645 
646  if (part) mass = part->Mass();
647  if (mass<0) mass = 0.139;
648 
649  for (unsigned int i=0;i<in.size();++i)
650  {
651  SimpleCand c=in[i];
652 
653  // select a specific charge in any case
654  if (c.Charge()==chrg)
655  {
656  c.SetMass(mass);
657  if (c.Pid()==pdg) c.SetMcPid();
658  c.SetPdg(pdg);
659  if (pdg==0 || pdg==22) out.push_back(c); // do we want select a pdg code? 0=only charge
660  else
661  {
662  // invalid pdg code?
663  if (pdgidx.find(abs(pdg))==pdgidx.end()) continue;
664 
665  int selidx = pdgidx[abs(pdg)];
666  int partidx = pdgidx[abs(c.Pid())];
667  double prob = pidtab[5*selidx + partidx]/100.;
668  //cout <<pdg <<" "<<c.Pid()<<" : "<<selidx<<" "<<partidx<<" P:"<<prob<<endl;
669 
670  if (fRand.Rndm()<prob) out.push_back(c);
671  }
672  }
673  }
674 }
675 
677 {
678  // *** prepare globally defined PID lists
679  select(l, eplus, 1, -11, mE);
680  select(l, eminus, -1, 11, mE);
681 
682  select(l, muplus, 1, -13, mMu);
683  select(l, muminus, -1, 13, mMu);
684 
685  select(l, piplus, 1, 211, mPi);
686  select(l, piminus, -1, -211, mPi);
687 
688  select(l, kplus, 1, 321, mK);
689  select(l, kminus, -1, -321, mK);
690 
691  select(l, pplus, 1, 2212, mP);
692  select(l, pminus, -1, -2212, mP);
693 
694  select(l, gam, 0, 22, 0);
695 }
696 
697 void makeIni4Vector(TLorentzVector &l, double s)
698 {
699  double X = (s*s-2*mP*mP)/(2*mP);
700  double p = sqrt(X*X - mP*mP);
701  l.SetXYZM(0,0,p,s);
702 }
703 
704 void configHisto(TH1* h)
705 {
706  h->SetFillStyle(3001);
707  h->SetFillColor(602);
708  h->SetLineStyle(3);
709  h->SetLineColor(602);
710 /* TGaxis *ax = (TGaxis*)h->GetYaxis();
711  ax->SetMaxDigits(2);*/
712 }
713 
715 {
716  TLorentzVector l = c.P4();
717  TVector3 boost = fIni.BoostVector();
718  TLorentzVector lb = l;
719  lb.Boost(-boost);
720 
721  n->Column(pre+"px", l.Px());
722  n->Column(pre+"py", l.Py());
723  n->Column(pre+"pz", l.Pz());
724  n->Column(pre+"p", l.P());
725  n->Column(pre+"e", l.E());
726  n->Column(pre+"m", l.M());
727  n->Column(pre+"pdg", c.Pdg());
728  n->Column(pre+"tpdg", c.Pid());
729  n->Column(pre+"ch", c.Charge());
730 
731  n->Column(pre+"pt", l.Pt());
732  n->Column(pre+"tht", l.Theta());
733  n->Column(pre+"phi", l.Phi());
734  n->Column(pre+"pcm", lb.P());
735 
736  n->Column(pre+"mct", c.Mct()||c.McPid() );
737 }
738 
739 // int getDau( int idx, SimpleCand &c)
740 // {
741 // int num=0;
742 // int curridx=-1;
743 // unsigned int marker = c.Marker();
744 //
745 // while (curridx<idx)
746 // {
747 // while (!(marker&1) && num<32) {num++;marker>>=1;}
748 // curridx++;
749 // }
750 // return num;
751 // }
752 //
753 // int countDau(SimpleCand &c)
754 // {
755 // int num=0;
756 // unsigned int marker = c.Marker();
757 // while (marker) {marker &= (marker-1); num++;}
758 //
759 // return num;
760 // }
761 //
762 // int getDauIdx(SimpleCand &c, int* dauidx)
763 // {
764 // int num=0;
765 // int idx=0;
766 // unsigned int marker = c.Marker();
767 //
768 // while (marker)
769 // {
770 // if (marker & 1)
771 // {
772 // dauidx[num]=idx;
773 // num++;
774 // }
775 // marker >>= 1;
776 // idx++;
777 // }
778 // return num;
779 // }
780 
781 void writeTuple(TString pre, CandList &l, EventShape &evsh, SimpleNtp *n, double mass, double win)
782 {
783  int dauidx[32];
784  for (int i=0;i<l.size();++i)
785  {
786  qaCand(pre,l[i], n);
787  float tag = 0;
788  float mct = l[i].Mct();
789 
790  if (fabs(l[i].P4().M()-mass)<win) tag=1.0;
791 
792  n->Column("tag",tag);
793  n->Column("mct",mct);
794 
795  //int nDau = getDauIdx(l[i], dauidx);
796 
797  //cout <<"c("<<l[i].Marker()<<") "<<i<<" made from ";
798  for (int j=0;j<l[i].NDau();++j)
799  {
800  //cout <<dauidx[j]<<" ";
801  //SimpleCand d = recolist[dauidx[j]];
802  SimpleCand d=*(l[i].Dau(j));
803  qaCand(TString::Format("%sd%d",pre.Data(),j),d, n);
804  }
805  //cout <<endl;
806 
807  n->Column("evt", evtno);
808  n->Column("mode", globmode);
809 
810  // store eventshape
811  n->Column("npart", evsh.NParticles());
812  n->Column("nneut", evsh.NNeutral());
813  n->Column("nchrg", evsh.NCharged());
814  n->Column("sumpc", evsh.ChrgPSumCms());
815  n->Column("sumpt", evsh.PtSumLab());
816  n->Column("sumptc", evsh.ChrgPtSumLab());
817  n->Column("pmaxl" ,evsh.PmaxLab());
818  n->Column("pmax", evsh.PmaxCms());
819  n->Column("pmin", evsh.PminCms());
820  n->Column("ptmax",evsh.Ptmax());
821  n->Column("thr", evsh.Thrust());
822  n->Column("pla", evsh.Planarity());
823  n->Column("apl", evsh.Aplanarity());
824  n->Column("sph", evsh.Sphericity());
825  n->Column("cir", evsh.Circularity());
826  n->Column("ne", ne);
827  n->Column("nmu", nmu);
828  n->Column("npi", npi);
829  n->Column("nk", nk);
830  n->Column("npr", npr);
831  n->Column("fw1", evsh.FoxWolfMomR(1));
832  n->Column("fw2", evsh.FoxWolfMomR(2));
833  n->Column("fw3", evsh.FoxWolfMomR(3));
834  n->Column("fw4", evsh.FoxWolfMomR(4));
835  n->Column("fw5", evsh.FoxWolfMomR(5));
836 
837  n->DumpData();
838  }
839 }
840 
841 int toy_core(TString fsig, int nev=2, double sqrts=3.77, bool simcut=true, bool evcut=false, double dp=0.05,
842  double trkeff=95., double pideff=95., double misid =5., double P_mix=0.00, bool writentp=false, int mode =9999)
843 {
844  setStyle();
845 
846  globmode= mode;
847 
848  fRand.SetSeed(314);
849 
850  init(pideff, misid);
851 
852  int i,j,k;
853 
854  makeIni4Vector(fIni, sqrts);
855 
856  fIni.Print();
857 
860 
861  fPhiwin = nsig*fPhisig;
862  fDwin = nsig*fDsig;
863  fD0win = nsig*fD0sig;
864  fDswin = nsig*fDssig;
865  fJwin = nsig*fJsig;
867  feewin = nsig*(feesigconst+sqrts*feesigslope);
869  fLamwin = nsig*fLamsig;
870 
871  //gStyle->SetOptStat(1111);
872 
873  // *** open file and get tree
874  TFile *f=new TFile(fsig,"READ");
875  if (f->IsZombie())
876  {
877  cout <<"File not found:"<<fsig<<endl;
878  return;
879  }
880 
881  bool dpm=fsig.Contains("DPM"); // *** DPM events
882  TString treename = dpm ? "data" : "ntp"; // *** set treename
883  TTree *t=(TTree*)f->Get(treename);
884 
885  if (t==0)
886  {
887  cout <<"Tree '"<<treename<<"' not found in '"<<fsig<<"'."<<endl;
888  return;
889  }
890 
891  // *** how many events ?
892  int Nevt = t->GetEntriesFast();
893  if (nev==0) nev = Nevt;
894 
895  double mmean=0, mwsig=0, mwoff=0;
896  int matchPDG=0;
897 
898  // *** choose histogram scale according to resonance
899  high = mmean+2;
900 
901  TCanvas *c1=new TCanvas("c1","c1",10,10,600,300);
902  c1->Divide(2,1);
903  TCanvas *c2=new TCanvas("c2","c2",20,20,1800,800);
904  c2->Divide(5,2,0.005,0.01);
905 
906 /* TCanvas *c3=new TCanvas("c3","c3",1010,10,600,600);
907  c3->Divide(2,2);*/
908 
909 // TCanvas *c4=new TCanvas("c4","c4",1220,20,500,500);
910 
911  double min=0, max=6.0, min2=0.5;
912 
913  // *** create some histograms
914  TH1F *h_mom= new TH1F("h_mom","Momenta",200,0,5);
915  TH1F *h_momc= new TH1F("h_momc","Momenta charged",200,0,5);
916  TH1F *h_momn= new TH1F("h_momn","Momenta neutral",200,0,5);
917  TH1F *h_mult= new TH1F("h_mult","Multiplicity",50,-0.5,49.5);
918  TH1F *h_multrec= new TH1F("h_multrec","Multiplicity reco",50,-0.5,49.5);
919  TH1F *h_multc= new TH1F("h_multc","Multiplicity charged",30,-0.5,29.5);
920  TH1F *h_multn= new TH1F("h_multn","Multiplicity neutral",50,-0.5,49.5);
921  TH1F *h_fw1= new TH1F("h_fw1","Fox Wolfram R1",300,-1.1,1.1);
922  TH1F *h_pmax= new TH1F("h_pmax","pmax cms",300,0,5);
923 
924  TH1F *h_mult_k = new TH1F("h_mult_k","Multiplicity Kaons",10,-0.5,9.5);
925  TH1F *h_mult_lep = new TH1F("h_mult_lep","Multiplicity Leptons",10,-0.5,9.5);
926  TH1F *h_sum_klep = new TH1F("h_sum_lep","Sum Kaons + Leptons",15,-0.5,14.5);
927  TH2F *h_mult_klep=new TH2F("h_mult_klep","#Kaons vs. #Leptons",10,-0.5,9.5, 10, -0.5, 9.5);
928  h_mult_klep->SetYTitle("#Leptons");
929  h_mult_klep->SetXTitle("#Kaons");
930 
931  // ****** pi0
932  TH1F *h_pi0=new TH1F("h_pi0","#pi^{0} #rightarrow #gamma#gamma",200,min,0.4);
933  TH1F *h_pi0sel=new TH1F("h_pi0sel","Pi0",200,min,0.4);
934  TH1F *h_pi0sig=new TH1F("h_pi0sig","Pi0",200,min,0.4);
935  h_pi0sig->SetLineColor(2);
936  configHisto(h_pi0sel);
937 
938  // ****** Ks
939  TH1F *h_ks=new TH1F("h_ks","K_{S}^{0} #rightarrow #pi^{+}#pi^{-}",200,0.2,0.8);
940  TH1F *h_kssel=new TH1F("h_kssel","Pi0",200,0.2,0.8);
941  TH1F *h_kssig=new TH1F("h_kssig","Pi0",200,0.2,0.8);
942  h_kssig->SetLineColor(2);
943  configHisto(h_kssel);
944 
945  // ****** Jpsi -> ee
946  TH1F *h_jpsi=new TH1F("h_jpsi","J/#psi #rightarrow e^{+}e^{-}",nbins,min,max);
947  TH1F *h_jpsisel=new TH1F("h_jpsisel","J/psi",nbins,min,max);
948  TH1F *h_jpsisig=new TH1F("h_jpsisig","J/psi",nbins,min,max);
949  h_jpsisig->SetLineColor(2);
950  configHisto(h_jpsisel);
951 
952  // ****** Jpsi -> mu mu
953  TH1F *h_jpsi2=new TH1F("h_jpsi2","J/#psi #rightarrow #mu^{+}#mu^{-}",nbins,min,max);
954  TH1F *h_jpsi2sel=new TH1F("h_jpsi2sel","J/psi",nbins,min,max);
955  TH1F *h_jpsi2sig=new TH1F("h_jpsi2sig","J/psi",nbins,min,max);
956  h_jpsi2sig->SetLineColor(2);
957  configHisto(h_jpsi2sel);
958 
959  // ****** eta_c -> Ks K pi
960  TH1F *h_etac=new TH1F("h_etac","#eta_{c} #rightarrow K_{S} K^{+} #pi^{-}",nbins,min,max);
961  TH1F *h_etacsel=new TH1F("h_etacsel","etac",nbins,min,max);
962  TH1F *h_etacsig=new TH1F("h_etacsig","etac",nbins,min,max);
963  h_etacsig->SetLineColor(2);
964  configHisto(h_etacsel);
965 
966  // ****** D0 -> K- pi+
967  TH1F *h_d0=new TH1F("h_d0","D^{0} #rightarrow K^{-}#pi^{+}",nbins,min,max);
968  TH1F *h_d0sel=new TH1F("h_d0sel","D0",nbins,min,max);
969  TH1F *h_d0sig=new TH1F("h_d0sig","D0",nbins,min,max);
970  h_d0sig->SetLineColor(2);
971  configHisto(h_d0sel);
972 
973  // ****** D+ -> K- pi+ pi+
974  TH1F *h_dpm=new TH1F("h_dpm","D^{+} #rightarrow K^{-}#pi^{+}#pi^{+}",nbins,min,max);
975  TH1F *h_dpmsel=new TH1F("h_dpmsel","D#pm",nbins,min,max);
976  TH1F *h_dpmsig=new TH1F("h_dpmsig","D#pm",nbins,min,max);
977  h_dpmsig->SetLineColor(2);
978  configHisto(h_dpmsel);
979 
980  // ****** Ds+ -> K+ K- pi+
981  TH1F *h_ds=new TH1F("h_ds","D_{s}^{+} #rightarrow K^{+}K^{-}#pi^{+}",nbins,min,max);
982  TH1F *h_dssel=new TH1F("h_dssel","Ds",nbins,min,max);
983  TH1F *h_dssig=new TH1F("h_dssig","Ds",nbins,min,max);
984  h_dssig->SetLineColor(2);
985  configHisto(h_dssel);
986 
987  // ****** phi -> K+ K-
988  TH1F *h_phi=new TH1F("h_phi","#phi #rightarrow K^{+}K^{-}",nbins,min2,max/2);
989  TH1F *h_phisel=new TH1F("h_phisel","Phi",nbins,min2,max/2);
990  TH1F *h_phisig=new TH1F("h_phisig","Phi",nbins,min2,max/2);
991  h_phisig->SetLineColor(2);
992  configHisto(h_phisel);
993 
994  // ****** Lambda_c -> p K- pi+
995  TH1F *h_lamc=new TH1F("h_lamc","#Lambda_{c} #rightarrow pK^{-}#pi^{+}",nbins,min,max);
996  TH1F *h_lamcsel=new TH1F("h_lamcsel","Lam_c",nbins,min,max);
997  TH1F *h_lamcsig=new TH1F("h_lamcsig","Lam_c",nbins,min,max);
998  h_lamcsig->SetLineColor(2);
999  configHisto(h_lamcsel);
1000 
1001  // ****** Lambda -> p pi-
1002  TH1F *h_lam=new TH1F("h_lam","#Lambda #rightarrow p#pi^{-}",nbins,min2,max/2);
1003  TH1F *h_lamsel=new TH1F("h_lamsel","Lam",nbins,min2,max/2);
1004  TH1F *h_lamsig=new TH1F("h_lamsig","Lam",nbins,min2,max/2);
1005  h_lamsig->SetLineColor(2);
1006  configHisto(h_lamsel);
1007 
1008  // ****** pp -> e+ e-
1009  TH1F *h_ee=new TH1F("h_ee","p#bar{p} #rightarrow e^{+}e^{-}",nbins,min,max*1.2);
1010  TH1F *h_eesel=new TH1F("h_eesel","ee",nbins,min,max*1.2);
1011  TH1F *h_eesig=new TH1F("h_eesig","ee",nbins,min,max*1.2);
1012  h_eesig->SetLineColor(2);
1013  configHisto(h_eesel);
1014 
1015 
1016  h_jpsi->SetXTitle("m(e^{+}e^{-}) [GeV/c^{2}]");
1017  h_jpsi2->SetXTitle("m(#mu^{+}#mu^{-}) [GeV/c^{2}]");
1018  h_etac->SetXTitle("m(K_{S} K^{+}#pi^{-}) [GeV/c^{2}]");
1019 
1020  h_d0->SetXTitle("m(K^{-}#pi^{+}) [GeV/c^{2}]");
1021 
1022  h_dpm->SetXTitle("m(K^{-}#pi^{+}#pi^{+}) [GeV/c^{2}]");
1023 
1024  h_ds->SetXTitle("m(K^{+}K^{-}#pi^{+}) [GeV/c^{2}]");
1025 
1026  h_phi->SetXTitle("m(K^{+}K^{-}) [GeV/c^{2}]");
1027  h_lamc->SetXTitle("m(pK^{-}#pi^{+}) [GeV/c^{2}]");
1028  h_lam->SetXTitle("m(p#pi^{-}) [GeV/c^{2}]");
1029  h_ee->SetXTitle("m(e^{+}e^{-}) [GeV/c^{2}]");
1030 
1031  // *** prepare the tree to loop through
1032 
1033  Int_t nTrk,Id[fMAX],DF[fMAX],DL[fMAX];
1034  Double_t px[fMAX],py[fMAX],pz[fMAX],E[fMAX],m[fMAX];
1035  TClonesArray* DpmPart=0;
1036 
1037  if (dpm)
1038  {
1039  DpmPart=new TClonesArray("TParticle",100);
1040  t->SetBranchAddress("Npart",&nTrk);
1041  t->SetBranchAddress("Particles", &DpmPart);
1042  }
1043  else
1044  {
1045  t->SetBranchAddress("nTrk",&nTrk);
1046  t->SetBranchAddress("Id",Id);
1047  t->SetBranchAddress("DF",DF);
1048  t->SetBranchAddress("DL",DL);
1049  t->SetBranchAddress("px",px);
1050  t->SetBranchAddress("py",py);
1051  t->SetBranchAddress("pz",pz);
1052  t->SetBranchAddress("E",E);
1053  t->SetBranchAddress("m",m);
1054  }
1055 
1056  TFile *fn=0;
1057 
1058  TString filename(fsig(fsig.Index("/")+1,fsig.Length())+"_ntp.root");
1059 
1060  if (writentp) fn=new TFile(filename, "RECREATE");
1061 
1062  SimpleNtp *nphi = new SimpleNtp("nphi","phi -> K+K-");
1063  SimpleNtp *nd0 = new SimpleNtp("nd0","D0 -> K+ pi+");
1064  SimpleNtp *ndpm = new SimpleNtp("ndpm","D+ -> K- pi+ pi+");
1065  SimpleNtp *nds = new SimpleNtp("nds","Ds -> K+ K- pi+");
1066  SimpleNtp *njpsi1 = new SimpleNtp("njpsi1","J/psi -> e+ e-");
1067  SimpleNtp *njpsi2 = new SimpleNtp("njpsi2","J/psi -> mu+ mu-");
1068  SimpleNtp *netac = new SimpleNtp("netac","eta_c -> KS (pi+pi-) K- pi+");
1069  SimpleNtp *nee = new SimpleNtp("nee","ppbar -> e+ e-");
1070  SimpleNtp *nlam = new SimpleNtp("nlam","Lambda -> p pi-");
1071  SimpleNtp *nlamc = new SimpleNtp("nlamc","Lambda_c -> p K- pi+");
1072 
1073  int combCnt=0; // how many combinatione are within our mass criterion
1074  int evCnt=0; // how many _events_ (not combinations!) are within our mass criterion
1075  int evMultCut=0;
1076 
1077  // *** the event loop
1078 
1079  int mixevts=1;
1080  int currmix=0;
1081 
1082  int cntInLam=0;
1083 
1084  // how many events are tagged by individual algo?
1085  bool channelselect[10];
1086  double channelcount[10];
1087  TString channelname[10]={"Phi(KK)","pp->ee" ,"Lam(ppi)","etac(KS K pi)","J/psi(ee)","J/psi(mumu)","D+-(K2pi)","D0(Kpi)","Ds(KKpi)","Lamc(pKpi)"};
1088 
1089  for (i=0;i<10;++i) channelcount[i]=0.;
1090 
1091  if (fRand.Rndm()<P_mix) mixevts=2;
1092 
1093  for (i=0;i<nev;++i)
1094  {
1095  evtno = i;
1096  t->GetEntry(i);
1097 
1098  if (i%5000==0) cout <<"ev "<<i<<endl;
1099 
1100  // *** read in from file the mc candidate
1101  if (0==currmix)
1102  {
1103  mclist.clear(); // *** contains all MC cands (also non-final-states)
1104  mcFSlist.clear(); // *** contains only final state MC cands
1105  }
1106 
1107  bool good = true;
1108 
1109  if (dpm)
1110  {
1111  int npi = 0;
1112  int nstab = 0;
1113 
1114  for (j=0;j<nTrk;++j)
1115  {
1116  TParticle *pt=(TParticle*)DpmPart->At(j);
1117  Id[j] = pt->GetPdgCode();
1118  int pdg = abs(Id[j]);
1119  px[j] = pt->Px();
1120  py[j] = pt->Py();
1121  pz[j] = pt->Pz();
1122  E[j] = pt->Energy();
1123  m[j] = pt->GetMass();
1124  DF[j] = 0;
1125  DL[j] = -1;
1126  if (pdg==211) npi++;
1127  if (isFinalState(pdg)) nstab++;
1128  }
1129  //if (npi!=4 || nstab!=npi ) good = false;
1130  }
1131 
1132  if (!good) continue;
1133 
1134  for (j=0;j<nTrk;++j)
1135  {
1136  int chrg = 0;
1137  int pdg = abs(Id[j]);
1138  TParticlePDG *p=pdg_db->GetParticle(Id[j]);
1139  if (p) chrg = p->Charge();
1140  if (abs(chrg)>1) chrg/=3;
1141 
1142  SimpleCand c(px[j], py[j], pz[j], E[j], Id[j], j, chrg);
1143  c.SetDau(DF[j], DL[j]);
1144 
1145  for (k=0;k<j;++k) if (j>=DF[k] && j<=DL[k])
1146  {
1147  c.SetMotherIdx(k);
1148  c.SetNSiblings(DL[k]-DF[k]+1);
1149  }
1150 
1151  c.SetEvtId(i);
1152 
1153  mclist.push_back(c);
1154 
1155  // final state particle?
1156  if (isFinalState(pdg)) mcFSlist.push_back(c);
1157  }
1158 
1159  if (++currmix<mixevts) continue;
1160 
1161  currmix=0;
1162 
1163  h_mult->Fill(mcFSlist.size());
1164 
1165  // *** if mass cut is negative (= number of sigmas), compute absolute window size
1166  //if (mwin<0) mwidth=-mwin*(dp*mwsig+mwoff);
1167 
1168  // *** prepare the toy reco: smear momentum and apply track efficiency (both flat at the moment)
1169  makeRecoCands(mcFSlist, recolist, trkeff/100., dp );
1170 
1171  // *** the boost of the system
1172  TVector3 boost = fIni.BoostVector();
1173  boostList(recolist, recocmslist, boost);
1174 
1175  // *** Make Event Selection
1176  EventShape evsh(recolist, fIni);
1177 /* if (evcut)
1178  {
1179  if (evshape.ChrgPtSumLab()<1.5) continue;
1180  }*/
1181 
1182  h_multrec->Fill(recolist.size());
1183  //cout <<mcFSlist.size()<<" "<<recolist.size()<<endl;
1184 
1185  // *** prepare all pid list according to the pidtable probabilities
1187 
1188  npi = piplus.size()+piminus.size();
1189  nk = kplus.size()+kminus.size();
1190  npr = pplus.size()+pminus.size();
1191  ne = eplus.size()+eminus.size();
1192  nmu = muplus.size()+muminus.size();
1193  nlep = ne+nmu;
1194 
1195 /* int nk10 = 0; // # kaons with p>1.0
1196  for (j=0;j<kplus.size();++j) if (kplus[j].P4().P()>1.0) nk10++;
1197  for (j=0;j<kminus.size();++j) if (kminus[j].P4().P()>1.0) nk10++;
1198 
1199  int npr10 = 0; // # protons with p>1.0
1200  for (j=0;j<pplus.size();++j) if (pplus[j].P4().P()>1.0) npr10++;
1201  for (j=0;j<pminus.size();++j) if (pminus[j].P4().P()>1.0) npr10++;*/
1202 
1203  h_mult_k->Fill(nk);
1204  h_mult_lep->Fill(nlep);
1205  h_mult_klep->Fill(nk, nlep);
1206  h_sum_klep->Fill(nk + nlep);
1207 
1208 
1209  // *** the lists we need for combinatorics
1210  CandList comb1, comb2, comb3;
1211 
1212  CandList LPhi, LPi0, LKs; // phi -> KK , pi0 -> gg (mass cut), KS -> pi+ pi- (mass cut)
1213  CandList LJpsiE, LJpsiMu; // J/psi -> ee/mu mu
1214  CandList LEtac, LEtac2; // etac
1215  CandList LDp, LDm, LDp2, LDm2, LDp3, LDm3, LDp4, LDm4; // D+- -> K2pi, K2pipi0, KS pi pi0, KS pi pi pi
1216  CandList LDsp, LDsm, LDsp2, LDsm2; // Ds -> KKpi, KKpipi0
1217  CandList LD0, LD02, LD0b, LD02b, LD03, LD03b; // D0 -> Kpi, Kpipi0, K3pi
1218  CandList LLamcp, LLamcm; // Lc -> pKpi
1219  CandList LLam, LLamb; // Lam -> ppi
1220  CandList Lee; // Lam -> ppi
1221 
1222  int ncomb1=0, ncomb2=0;
1223  bool selected=false;
1224 
1225  for (j=0;j<13;++j) channelselect[j]=false;
1226 
1227  // Apply cut on kaon/lepton multiplicity
1228 /* if ( multcut>0 && (N_K+N_lep<multcut) )
1229  {
1230  mixevts=1;
1231  if (fRand.Rndm()<P_mix) mixevts=2;
1232  continue;
1233  }*/
1234 
1235  evMultCut++;
1236 
1237  bool accepted = false;
1238 
1239  //
1240  // ********* pi0 / KS
1241  //
1242  // *** do combinatorics (pi0 -> gg)
1243  combine(gam, gam, comb1, fPi0Pdg);
1244  fillHisto(comb1, h_pi0, 0, fPi0Mass, fPi0win, h_pi0sel, 0, h_pi0sig );
1245  selectMass(comb1, LPi0, fPi0Mass, fPi0win);
1246 
1247  // *** do combinatorics (pi0 -> gg)
1248  combine(piplus, piminus, comb1, fKsPdg);
1249  fillHisto(comb1, h_ks, 0, fKsMass, fKswin, h_kssel, 0, h_kssig );
1250  selectMass(comb1, LKs, fKsMass, fKswin);
1251 
1252 
1253  // **** cache some eventshape vars
1254  int npart = evsh.NParticles();
1255  int nchrg = evsh.NCharged();
1256  int nneut = evsh.NNeutral();
1257  int npi0 = LPi0.size(); // #pi0 candidates
1258  int nks0 = LKs.size(); // #KS0 candidates
1259  int npi005 = 0.0;
1260  int npi010 = 0.0;
1261  int nks005 = 0.0;
1262  int nks010 = 0.0;
1263  int np05 = evsh.MultPminCms(0.5);
1264  int np10 = evsh.MultPminCms(1.0);
1265 
1266  double pmaxl = evsh.PmaxLab();
1267  double pmax = evsh.PmaxCms();
1268  double pmin = evsh.PminCms();
1269  double ptmax = evsh.Ptmax();
1270 
1271  double sumpc = evsh.ChrgPSumCms();
1272  double sumpc05 = evsh.SumChrgPminCms(0.5);
1273  double sumpt = evsh.PtSumLab();
1274  double sumptc = evsh.ChrgPtSumLab();
1275  double sumptl = sumpt;
1276  double sumen = evsh.NeutESumCms();
1277 
1278  double fw1 = evsh.FoxWolfMomR(1);
1279  double fw2 = evsh.FoxWolfMomR(2);
1280  double fw3 = evsh.FoxWolfMomR(3);
1281  double fw4 = evsh.FoxWolfMomR(4);
1282  double fw5 = evsh.FoxWolfMomR(5);
1283 
1284  // count pi0 with threshold
1285  for (j=0; j<LPi0.size(); ++j)
1286  {
1287  if (LPi0[j].P4().P()>0.5) npi005++;
1288  if (LPi0[j].P4().P()>1.0) npi010++;
1289  }
1290  // count KS with threshold
1291  for (j=0; j<LKs.size(); ++j)
1292  {
1293  if (LKs[j].P4().P()>0.5) nks005++;
1294  if (LKs[j].P4().P()>1.0) nks010++;
1295  }
1296 
1297  h_fw1->Fill(fw2);
1298  h_pmax->Fill(pmax);
1299 
1300 
1301  // **** find out, whether event was accepted
1302 
1303  // ********* PHI -> K+ K-
1304  if ( !evcut
1305  || (sqrts==2.4 && nk>1 && npart<7 && pmax<0.648 )
1306  || (sqrts==3.77 && nk>1 && fw2>0.5456 )
1307  || (sqrts==4.28 && nk>1 && 1 )
1308  || (sqrts==5.0 && nk>1 && 1 )
1309  || (sqrts==5.5 && nk>1 && 1 )
1310  )
1311  {
1312  // *** do combinatorics (phi -> K K)
1313  combine (kplus, kminus, LPhi, fPhiPdg);
1314 
1315  accepted |= eventAccepted(LPhi,fPhiMass, fPhiwin);
1316 
1317  writeTuple("phi",LPhi,evsh, nphi,fPhiMass, fPhiwin);
1318  }
1319 
1320 
1321  // ********* LAMBDA -> p pi-
1322  if ( !evcut
1323  || (sqrts==2.4 && npart>3 && npr>0 && npi>0 && fw1>0.132 && fw4>0.2024 )
1324  || (sqrts==3.77 && npart>3 && pmax>1.056 && fw1>0.0 && fw2>0.6248 && fw5>0.22 )
1325  || (sqrts==4.28 && npart>3 && 1 )
1326  || (sqrts==5.0 && npart>3 && 1 )
1327  || (sqrts==5.5 && npart>3 && 1 )
1328  )
1329  {
1330  // *** do combinatorics (Lam -> p pi)
1331  combine (pplus, piminus, LLam, fLamPdg);
1332  combine (pminus, piplus, LLamb, -fLamPdg);
1333 
1334  accepted |= eventAccepted(LLam, fLamMass, fLamwin);
1335  accepted |= eventAccepted(LLamb, fLamMass, fLamwin);
1336 
1337  writeTuple("lam",LLam,evsh, nlam, fLamMass, fLamwin);
1338  writeTuple("lam",LLamb,evsh, nlam, fLamMass, fLamwin);
1339  }
1340 
1341  // ********* pp -> e+ e-
1342  if ( !evcut
1343  )
1344  {
1345  // *** do combinatorics (e+ e-)
1346  combine(eminus, eplus, Lee, 88880);
1347 
1348  accepted |= eventAccepted(Lee, fIni.M(), feewin);
1349 
1350  writeTuple("ee",Lee,evsh, nee, fIni.M(), feewin);
1351  }
1352 
1353  // ********* ETAC
1354  if ( !evcut
1355 /* || (sqrts==3.77 && np10>1 && npi<4 && pmin<0.3 && sumpc>3.296 )
1356  || (sqrts==4.28 && 1 )
1357  || (sqrts==5.0 && 1 )
1358  || (sqrts==5.5 && 1 )*/
1359  )
1360  {
1361  // *** do combinatorics (ETAC)
1362  combine(LKs, kplus, piminus, LEtac, fEtacPdg);
1363  combine(LKs, kminus, piplus, LEtac2, fEtacPdg);
1364 
1365  accepted |= eventAccepted(LEtac, fEtacMass, fEtacwin);
1366  accepted |= eventAccepted(LEtac2, fEtacMass, fEtacwin);
1367 
1368  writeTuple("etac",LEtac,evsh, netac, fEtacMass, fEtacwin);
1369  writeTuple("etac",LEtac2,evsh, netac, fEtacMass, fEtacwin);
1370  }
1371 
1372  // ********* JPSI -> e+e-
1373  if ( !evcut
1374  || (sqrts==3.77 && np10>1 && npi<4 && pmin<0.3 && sumpc>3.296 )
1375  || (sqrts==4.28 && 1 )
1376  || (sqrts==5.0 && 1 )
1377  || (sqrts==5.5 && 1 )
1378  )
1379  {
1380  // *** do combinatorics (J/psi -> ee)
1381  combine(eminus, eplus, LJpsiE, fJpsiPdg);
1382 
1383  accepted |= eventAccepted(LJpsiE, fJMass, fJwin);
1384 
1385  writeTuple("jpsi1",LJpsiE,evsh, njpsi1, fJMass, fJwin);
1386  }
1387 
1388  // ********* JPSI -> mu+mu-
1389  if ( !evcut
1390  || (sqrts==3.77 && np10>1 && npi<4 && pmin<0.3 && sumpc>3.296 )
1391  || (sqrts==4.28 && 1 )
1392  || (sqrts==5.0 && 1 )
1393  || (sqrts==5.5 && 1 )
1394  )
1395  {
1396  // *** do combinatorics (J/psi -> mu mu)
1397  combine(muminus, muplus, LJpsiMu, fJpsiPdg);
1398 
1399  accepted |= eventAccepted(LJpsiMu, fJMass, fJwin);
1400 
1401  writeTuple("jpsi2",LJpsiMu,evsh, njpsi2, fJMass, fJwin);
1402  }
1403 
1404 
1405  // ********* D+ -> K- pi+ pi+
1406  if ( !evcut
1407  || (sqrts==3.77 && nk>0 && npart<12 && pmax<0.936 && sumpc>1.76 )
1408  || (sqrts==4.28 && nk>0 && 1 )
1409  || (sqrts==5.0 && nk>0 && 1 )
1410  || (sqrts==5.5 && nk>0 && 1 )
1411  )
1412  {
1413  // *** do combinatorics (D+- -> K pi pi)
1414  combine (piplus, piplus, kminus, LDp, fDPdg);
1415  combine (piminus, piminus, kplus, LDm, -fDPdg);
1416 
1417  accepted |= eventAccepted(LDp,fDMass, fDwin);
1418  accepted |= eventAccepted(LDm,fDMass, fDwin);
1419 
1420  writeTuple("d",LDp,evsh, ndpm,fDMass, fDwin);
1421  writeTuple("d",LDm,evsh, ndpm,fDMass, fDwin);
1422  }
1423 
1424 
1425  // ********* D0 -> K- pi+
1426  if ( !evcut
1427  || (sqrts==3.77 && nk>0 && sumpc05>3.18 && pmax>0.768 && pmax<1.056 && fw3<0.1848 )
1428  || (sqrts==4.28 && nk>0 && 1 )
1429  || (sqrts==5.0 && nk>0 && 1 )
1430  || (sqrts==5.5 && nk>0 && 1 )
1431  )
1432  {
1433  // *** do combinatorics (D0 -> K pi)
1434  combine (kplus, piminus, LD0, -fD0Pdg);
1435  combine (kminus, piplus, LD0b, fD0Pdg);
1436 
1437  accepted |= eventAccepted(LD0, fD0Mass, fD0win);
1438  accepted |= eventAccepted(LD0b, fD0Mass, fD0win);
1439 
1440  writeTuple("d0",LD0,evsh, nd0, fD0Mass, fD0win);
1441  writeTuple("d0",LD0b,evsh, nd0, fD0Mass, fD0win);
1442  }
1443 
1444 
1445  // ********* DS -> K+ K- pi+
1446  if ( !evcut
1447  || (sqrts==4.28 && nk>1 && 1 )
1448  || (sqrts==5.0 && nk>1 && 1 )
1449  || (sqrts==5.5 && nk>1 && 1 )
1450  )
1451  {
1452  // *** do combinatorics (Ds+- -> K K pi)
1453  combine (kplus, kminus, piplus, LDsp, fDsPdg);
1454  combine (kplus, kminus, piminus, LDsm, -fDsPdg);
1455 
1456  accepted |= eventAccepted(LDsp, fDsMass, fDswin);
1457  accepted |= eventAccepted(LDsm, fDsMass, fDswin);
1458 
1459  writeTuple("ds",LDsp,evsh, nds, fDsMass, fDswin);
1460  writeTuple("ds",LDsm,evsh, nds, fDsMass, fDswin);
1461  }
1462 
1463 
1464  // ********* LAMBDA_C -> p K- pi+
1465  if ( !evcut
1466  || (sqrts==5.0 && 1 )
1467  || (sqrts==5.5 && 1 )
1468  )
1469  {
1470  // *** do combinatorics (Lamc)
1471  combine (pplus, kminus, piplus, LLamcp, fLamcPdg);
1472  combine (pminus, kplus, piminus, LLamcm, -fLamcPdg);
1473 
1474  accepted |= eventAccepted(LLamcp, fLamcMass, fLamcwin);
1475  accepted |= eventAccepted(LLamcm, fLamcMass, fLamcwin);
1476 
1477  writeTuple("lamc",LLamcp,evsh, nlamc, fLamcMass, fLamcwin);
1478  writeTuple("lamc",LLamcm,evsh, nlamc, fLamcMass, fLamcwin);
1479  }
1480 
1481 
1482  // ********* NOW do counting and drawing, ONLY for events which are accepted by any selector
1483  // {"Phi(KK)", "ee", "Lam(ppi)", "etac", "J/psi(ee)","J/psi(mumu)","D+-(K2pi)", "D0(Kpi)","Ds(KKpi)","Lamc(pKpi)"};
1484  // 0 1 2 3 4 5 6 7 8 9
1485  if (!simcut || accepted)
1486  {
1487  // **** Phi
1488  if (sqrts>2.2)
1489  {
1490  ncomb1 = fillHisto(LPhi, h_phi, 0, fPhiMass, fPhiwin, h_phisel, 0, h_phisig );
1491  combCnt += ncomb1;
1492  if (ncomb1>0) {selected=true; channelselect[0]=true;}
1493  }
1494 
1495  // **** ee
1496  if (sqrts>2.2)
1497  {
1498  ncomb1 = fillHisto(Lee, h_ee, 0, fIni.M(), feewin, h_eesel, 0, h_eesig );
1499  combCnt += ncomb1;
1500  if (ncomb1>0) {selected=true; channelselect[1]=true;}
1501  }
1502 
1503  // **** Lam
1504  if (sqrts>2.2)
1505  {
1506  ncomb1 = fillHisto(LLam, h_lam, 0, fLamMass, fLamwin, h_lamsel, 0, h_lamsig );
1507  ncomb2 = fillHisto(LLamb, h_lam, 0, fLamMass, fLamwin, h_lamsel, 0, h_lamsig );
1508  combCnt += ncomb1 + ncomb2;
1509  if (ncomb1>0 || ncomb2>0) {selected=true; channelselect[2]=true;}
1510  }
1511 
1512  // **** etac
1513  if (sqrts>3.1)
1514  {
1515  ncomb1 = fillHisto(LEtac, h_etac, 0, fEtacMass, fEtacwin, h_etacsel, 0, h_etacsig );
1516  ncomb2 = fillHisto(LEtac2, h_etac, 0, fEtacMass, fEtacwin, h_etacsel, 0, h_etacsig );
1517  combCnt += ncomb1 + ncomb2;
1518  if (ncomb1>0 || ncomb2>0 ) {selected=true; channelselect[3]=true;}
1519  }
1520 
1521  // **** J/psi ee
1522  if (sqrts>3.1)
1523  {
1524  ncomb1 = fillHisto(LJpsiE, h_jpsi, 0, fJMass, fJwin, h_jpsisel, 0, h_jpsisig );
1525  combCnt += ncomb1;
1526  if (ncomb1>0 ) {selected=true; channelselect[4]=true;}
1527  }
1528 
1529  // **** J/psi mumu
1530  if (sqrts>3.1)
1531  {
1532  ncomb1 = fillHisto(LJpsiMu, h_jpsi2, 0, fJMass, fJwin, h_jpsi2sel, 0, h_jpsi2sig );
1533  combCnt += ncomb1 ;
1534  if (ncomb1>0 ) {selected=true; channelselect[5]=true;}
1535  }
1536 
1537  // **** Dp
1538  if (sqrts>3.75)
1539  {
1540  ncomb1 = fillHisto(LDp, h_dpm, 0, fDMass, fDwin, h_dpmsel, 0, h_dpmsig );
1541  ncomb2 = fillHisto(LDm, h_dpm, 0, fDMass, fDwin, h_dpmsel, 0, h_dpmsig );
1542  combCnt += ncomb1 +ncomb2;
1543  if (ncomb1>0 || ncomb2>0) {selected=true; channelselect[6]=true;}
1544  }
1545 
1546  // **** D0
1547  if (sqrts>3.75)
1548  {
1549  ncomb1 = fillHisto(LD0, h_d0, 0, fD0Mass, fD0win, h_d0sel, 0, h_d0sig );
1550  ncomb2 = fillHisto(LD0b, h_d0, 0, fD0Mass, fD0win, h_d0sel, 0, h_d0sig );
1551  combCnt += ncomb1 +ncomb2;
1552  if (ncomb1>0 || ncomb2>0) {selected=true; channelselect[7]=true;}
1553  }
1554 
1555  // **** Ds
1556  if (sqrts>4.)
1557  {
1558  ncomb1 = fillHisto(LDsp, h_ds, 0, fDsMass, fDswin, h_dssel, 0, h_dssig );
1559  ncomb2 = fillHisto(LDsm, h_ds, 0, fDsMass, fDswin, h_dssel, 0, h_dssig );
1560  combCnt += ncomb1 +ncomb2;
1561  if (ncomb1>0 || ncomb2>0) {selected=true; channelselect[8]=true;}
1562  }
1563 
1564  // **** Lamc
1565  if (sqrts>4.57)
1566  {
1567  ncomb1 = fillHisto(LLamcp, h_lamc, 0, fLamcMass, fLamcwin, h_lamcsel, 0, h_lamcsig );
1568  ncomb2 = fillHisto(LLamcm, h_lamc, 0, fLamcMass, fLamcwin, h_lamcsel, 0, h_lamcsig );
1569  combCnt += ncomb1 + ncomb2;
1570  if (ncomb1>0 || ncomb2>0) {selected=true; channelselect[9]=true;}
1571  }
1572  }
1573  // ****************
1574 
1575  if (selected) evCnt+=mixevts; // *** if any combination is in window count event
1576 
1577  for (j=0;j<10;++j) if (channelselect[j]) channelcount[j]+=mixevts;
1578 
1579  //hmix->Fill(mixevts);
1580  // new round of mixing
1581  mixevts=1;
1582  if (fRand.Rndm()<P_mix) mixevts=2;
1583 
1584  //if (i<3) printAllLists();
1585  }
1586  //cout <<"cntInLam "<<cntInLam<<endl;
1587  cout<< "#Combinations:"<<combCnt<<" #Events:"<<evCnt<<" ";
1588  cout <<"Efficiency (ev):"<<(double)evCnt/(double)nev<<endl;
1589  cout <<"Mult Cut Eff (ev):"<<(double)evMultCut/(double)nev<<endl;
1590 
1591  for (i=0;i<10;++i)
1592  {
1593  channelcount[i]/=nev;
1594  cout <<channelname[i]<<":"<<channelcount[i]<<endl;
1595  }
1596  cout <<endl;
1597 
1598  TLatex latex;
1599  latex.SetTextSize(0.08);
1600  char tmp[200];
1601  double offset = 0.1;
1602  double pos=3.3, pos2=1.85;
1603  double hfac = 0.75;
1604  // *** plot all stuff and write out info
1605  c1->cd(1); h_pi0->Draw(); h_pi0sel->Draw("same"); h_pi0sig->Draw("same");
1606  c1->cd(2); h_ks->Draw(); h_kssel->Draw("same"); h_kssig->Draw("same");
1607 
1608  c2->cd(1); h_phi->Draw(); h_phisel->Draw("same"); h_phisig->Draw("same");
1609  sprintf(tmp,"#epsilon = %4.1f%%",channelcount[0]*100.);
1610  latex.DrawLatex(pos2,h_phi->GetMaximum()*hfac+offset,tmp);
1611 
1612  c2->cd(2); h_ee->Draw(); h_eesel->Draw("same"); h_eesig->Draw("same");
1613  sprintf(tmp,"#epsilon = %4.1f%%",channelcount[1]*100.);
1614  latex.DrawLatex(pos*1.2,h_ee->GetMaximum()*hfac+offset,tmp);
1615 
1616  c2->cd(3); h_lam->Draw(); h_lamsel->Draw("same"); h_lamsig->Draw("same");
1617  sprintf(tmp,"#epsilon = %4.1f%%",channelcount[2]*100.);
1618  latex.DrawLatex(pos2,h_lam->GetMaximum()*hfac+offset,tmp);
1619 
1620  c2->cd(4); h_etac->Draw(); h_etacsel->Draw("same"); h_etacsig->Draw("same");
1621  sprintf(tmp,"#epsilon = %4.1f%%",channelcount[3]*100.);
1622  latex.DrawLatex(pos,h_etac->GetMaximum()*hfac+offset,tmp);
1623 
1624  c2->cd(5); h_jpsi->Draw(); h_jpsisel->Draw("same"); h_jpsisig->Draw("same");
1625  sprintf(tmp,"#epsilon = %4.1f%%",channelcount[4]*100.);
1626  latex.DrawLatex(pos,h_jpsi->GetMaximum()*hfac+offset,tmp);
1627 
1628  c2->cd(6); h_jpsi2->Draw(); h_jpsi2sel->Draw("same"); h_jpsi2sig->Draw("same");
1629  sprintf(tmp,"#epsilon = %4.1f%%",channelcount[5]*100.);
1630  latex.DrawLatex(pos,h_jpsi2->GetMaximum()*hfac+offset,tmp);
1631 
1632  c2->cd(7); h_dpm->Draw(); h_dpmsel->Draw("same"); h_dpmsig->Draw("same");
1633  sprintf(tmp,"#epsilon = %4.1f%%",channelcount[6]*100.);
1634  latex.DrawLatex(pos,h_dpm->GetMaximum()*hfac+offset,tmp);
1635 
1636  c2->cd(8); h_d0->Draw(); h_d0sel->Draw("same"); h_d0sig->Draw("same");
1637  sprintf(tmp,"#epsilon = %4.1f%%",channelcount[7]*100.);
1638  latex.DrawLatex(pos,h_d0->GetMaximum()*hfac+offset,tmp);
1639 
1640  c2->cd(9); h_ds->Draw(); h_dssel->Draw("same"); h_dssig->Draw("same");
1641  sprintf(tmp,"#epsilon = %4.1f%%",channelcount[8]*100.);
1642  latex.DrawLatex(pos,h_ds->GetMaximum()*hfac+offset,tmp);
1643 
1644  c2->cd(10); h_lamc->Draw(); h_lamcsel->Draw("same"); h_lamcsig->Draw("same");
1645  sprintf(tmp,"#epsilon = %4.1f%%",channelcount[9]*100.);
1646  latex.DrawLatex(pos,h_lamc->GetMaximum()*hfac+offset,tmp);
1647 
1648  // total efficiency in first plot (phi)
1649  c2->cd(5);
1650  double posy = h_jpsi->GetMaximum()*1.12;
1651  if (posy=0) posy=1.12;
1652  sprintf(tmp,"(#epsilon_{t} = %4.1f%%)",double(evCnt)/double(nev)*100.);
1653  latex.SetTextColor(kMagenta+2);
1654  latex.DrawLatex(3.0,h_jpsi->GetMaximum()*1.12,tmp);
1655 
1656 
1657  //sprintf(tmp,"#epsilon = %4.1f%%",channelcount[6]*100.);
1658  //latex.DrawLatex(2.5,h_pi0->GetMaximum()*0.95,tmp);
1659 
1660 /* c2->cd();
1661  TPad *peff=new TPad("peff","peff",0.45,0.47,0.55,0.53);
1662  peff->Draw();
1663  peff->cd();
1664  sprintf(tmp,"#epsilon_{tot} = %4.1f%%",double(evCnt)/double(nev)*100.);
1665  latex.SetTextSize(0.5);
1666  latex.SetTextColor(2);
1667  latex.DrawLatex(0.1,0.3,tmp);
1668  */
1669  c2->cd();
1670 
1671  h_mult_klep->Scale(1.0/nev);
1672 
1673  TString plotname(fsig(fsig.Index("/")+1,fsig.Length()-5));
1674 
1675  c2->SaveAs("fig/"+plotname+"_core.gif");
1676  c2->SaveAs("fig/"+plotname+"_core.pdf");
1677 
1678  if (writentp)
1679  {
1680  fn->Write();
1681  fn->Close();
1682  }
1683 
1684  return 0;
1685 }
double fDwin
int fLamPdg
const double fNdtht
CandList pminus
TVector3 pos
void select(CandList &in, CandList &out, int chrg=0, int pdg=0, double mass=0.139)
int fPhiPdg
void SetPdg(int pdg)
Definition: SimpleCand.C:25
int globmode
Definition: toy_core.C:124
void setStyle()
Definition: crosstag.C:39
CandList mclist
Double_t p
Definition: anasim.C:58
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
void printList(CandList &l, TString tit="")
double fKswin
int NNeutral() const
Definition: EventShape.h:17
double mK
void SetP4(TLorentzVector lv)
Definition: SimpleCand.C:20
void SetEvtId(int ev)
Definition: SimpleCand.C:35
int fJpsiPdg
int feePdg
Definition: toy_core.C:74
TObjArray * d
const double fNeutEff
double mP
void makePidSelection(CandList &l)
Int_t i
Definition: run_full.C:25
__m128 m
Definition: P4_F32vec4.h:28
TString plotname[10]
Definition: full_core_ntp.C:44
int low
Definition: anaMvdDigi.C:51
int NCharged() const
Definition: EventShape.h:16
void configHisto(TH1 *h)
Definition: full_core_ntp.C:76
double fPi0win
TRandom3 fRand
Definition: full_core_ntp.C:28
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
double fDsMass
int nk
Definition: toy_core.C:124
int npr
Definition: toy_core.C:124
Int_t tag
Definition: crosstag.C:23
TDatabasePDG * pdg_db
int NParticles() const
Definition: EventShape.h:15
TLorentzVector s
Definition: Pnd2DStar.C:50
int n
int Pdg() const
Definition: SimpleCand.C:41
int pid()
const int fMAX
Definition: full_core_ntp.C:32
CandList kminus
double Aplanarity()
Definition: EventShape.h:299
double mE
int evtno
Definition: toy_core.C:124
double fKssig
Definition: toy_core.C:57
c2
Definition: plot_dirc.C:39
CandList recocmslist
CandList piplus
double fJsig
double fLamcsig
int NFS() const
Definition: SimpleCand.C:47
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
void makePidTable(double pideff, double misid)
bool Mct() const
Definition: SimpleCand.C:48
TVector3 offset(2, 0, 0)
double fLamwin
int fEtacPdg
void makeRecoCands(CandList &mc, CandList &reco, double eff=0.90, double dp=0.05, double dtht=0.001, double dphi=0.001)
void SetMcPid(bool mct=true)
Definition: SimpleCand.C:30
int combine(CandList &l1, CandList &l2, CandList &out, int matchPdg=0)
CandList eplus
int fillHisto(CandList &l, TH1 *hall, TH1 *hbg=0, double m=0, double w=0, TH1 *hallsel=0, TH1 *hbgsel=0, TH1 *hsig=0, TH1 *hmm=0, TH2 *hmvsmm=0)
int Pid() const
Definition: SimpleCand.C:40
std::vector< SimpleCand > CandList
Definition: SimpleCand.C:76
double fDswin
__m128 v
Definition: P4_F32vec4.h:4
void writeTuple(TString pre, CandList &l, EventShape &evsh, SimpleNtp *n, double mass, double win)
Definition: toy_core.C:781
std::map< int, int > pdgidx
int fDPdg
double PmaxLab() const
Definition: EventShape.h:20
double dponline(TLorentzVector &v)
double fDMass
void SetMarker(unsigned int i)
Definition: SimpleCand.C:33
int fLamcPdg
double PtSumLab() const
Definition: EventShape.h:29
static int init
Definition: ranlxd.cxx:374
void SetCharge(int ch)
Definition: SimpleCand.C:27
double fKsMass
void SetMct(bool mct=true)
Definition: SimpleCand.C:29
TString pt(TString pts, TString exts="px py pz")
Definition: invexp.C:133
int NSiblings() const
Definition: SimpleCand.C:46
CandList muplus
bool isFinalState(int n)
Int_t mode
Definition: autocutx.C:47
const double fdE
int massCrit(CandList &l, double m, double w)
void qaCand(TString pre, SimpleCand &c, SimpleNtp *n)
Definition: toy_core.C:714
TString m2(TString pts, TString exts="e px py pz")
Definition: invexp.C:117
int ne
Definition: toy_core.C:124
int nsigpiks
Definition: toy_core.C:44
double pidreal[25]
void SetMass(double mass)
Definition: SimpleCand.C:22
double fPi0sig
Definition: toy_core.C:52
Double_t
double fLamsig
double feewin
Definition: toy_core.C:78
double pidtab[25]
void SetNSiblings(int n)
Definition: SimpleCand.C:31
int Id() const
Definition: SimpleCand.C:42
double NeutESumCms() const
Definition: EventShape.h:38
void SetId(int id)
Definition: SimpleCand.C:26
double fLamcMass
double fPhiwin
double fLamcwin
double fPhisig
double PminCms() const
Definition: EventShape.h:23
double fEtacMass
TFile * f
Definition: bump_analys.C:12
double fPhiMass
double mPi0
CandList pplus
int nbins
Definition: full_core_ntp.C:33
double Sphericity()
Definition: EventShape.h:281
double fDsig
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:25
double Circularity()
Definition: EventShape.h:308
int MultPminCms(double pmin)
Definition: EventShape.h:493
double Planarity()
Definition: EventShape.h:290
TLorentzVector P4() const
Definition: SimpleCand.C:39
CandList recolist
double fEtacsig
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
bool eventAccepted(CandList &l, double m=0, double w=0)
TFile * out
Definition: reco_muo.C:20
void smearMom(SimpleCand &c, double dpr=0.05, double dtht=0.000, double dphi=0.000)
c1
Definition: plot_dirc.C:35
CandList gam
int fD0Pdg
double fEtacwin
void boostList(CandList &list, CandList &boostlist, TVector3 boost)
int nlep
Definition: toy_core.C:124
double ChrgPSumCms() const
Definition: EventShape.h:40
double X
Definition: anaLmdDigi.C:68
double Thrust()
Definition: EventShape.h:324
int fPi0Pdg
double feesigconst
Definition: toy_core.C:76
int nsig
Definition: toy_core.C:46
double FoxWolfMomR(int order)
Definition: EventShape.h:462
int reco()
void AddDau(SimpleCand *c)
Definition: SimpleCand.C:37
double PmaxCms() const
Definition: EventShape.h:21
double fPi0Mass
CandList piminus
Int_t cnt
Definition: hist-t7.C:106
CandList mcFSlist
double high
Definition: full_core_ntp.C:35
double fJMass
double fLamMass
void printCand(TLorentzVector l, TVector3 p)
TF1 * f_res
TLorentzVector fIni
Definition: full_core_ntp.C:29
TTree * t
Definition: bump_analys.C:13
void selectMass(CandList &in, CandList &out, double mmean=0, double mw=0)
int toy_core(TString fsig, int nev=2, double sqrts=3.77, bool simcut=true, bool evcut=false, double dp=0.05, double trkeff=95., double pideff=95., double misid=5., double P_mix=0.00, bool writentp=false, int mode=9999)
Definition: toy_core.C:841
int fDsPdg
double mPi
double SumChrgPminCms(double pmin)
Definition: EventShape.h:814
void printAllLists()
CandList muminus
int fKsPdg
double fD0sig
const double fNdphi
double mMu
void SetMotherIdx(int idx)
Definition: SimpleCand.C:28
bool isDetected(double eff=0.90)
double fDssig
void SetNFS(int n)
Definition: SimpleCand.C:32
double ChrgPtSumLab() const
Definition: EventShape.h:32
double feesigslope
Definition: toy_core.C:77
double feeMass
Definition: toy_core.C:75
double fD0Mass
PndMCTrack * mct
Definition: hist-t7.C:147
void SetDau(int n, int m=0)
Definition: SimpleCand.C:34
CandList kplus
double fJwin
double fD0win
int MotherIdx() const
Definition: SimpleCand.C:45
void Column(TString name, Float_t value)
Definition: SimpleNtp.C:33
int nmu
Definition: toy_core.C:124
int Charge() const
Definition: SimpleCand.C:44
double pz[39]
Definition: pipisigmas.h:14
void DumpData()
Definition: SimpleNtp.C:23
bool McPid() const
Definition: SimpleCand.C:49
void makeIni4Vector(TLorentzVector &l, double s)
double Ptmax() const
Definition: EventShape.h:24
CandList eminus
int npi
Definition: toy_core.C:124
const string filename