FairRoot/PandaRoot
ana_d0d0b_micro.C
Go to the documentation of this file.
1 int ana_d0d0b_micro(TString fname="dsds_10k.evt.root",int num=0)
2 {
3  TStopwatch timer;
4  timer.Start();
5 
6  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
7  basiclibs();
8 
9  // **** the library is needed in order to use the TCandidate and TCandList etc
10  gSystem->Load("libRho");
11 
12  TCanvas *c1=new TCanvas("c1","c1",600,600);
13  c1->Divide(2,2);
14 
15  // **** access the datastructure holding the particle lists
16  //
17  //TFile* f = new TFile(fname.Data());
18  //TTree *t=f->Get("pndsim") ;
19 
20  TChain *t=new TChain("pndsim");
21  t->Add(fname);
22  //t->Add("dsdsj20k_4291.evt.fast.root");
23 
24  // **** for every event, a TCLonesArray with the candidates is stored in pndsim
25  //
26  TClonesArray *fMcCands=new TClonesArray("TCandidate");
27  TClonesArray *fMicro=new TClonesArray("PndPidCandidate");
28 
29  t->SetBranchAddress("PndMcTracks",&fMcCands);
30  t->SetBranchAddress("PndPidCandidates",&fMicro);
31 
32  TCandidate *tc;
33 
34  // **** create and setup some histos for QA plots
35  //
36  TH1F *d0mass = new TH1F("d0mass","Ds cands",100,1.864-0.05,1.864+0.05);
37  TH1F *ppmass = new TH1F("ppmass","pbarp cands",100,4.4,4.6);
38 
39  //TH1F *d0d0b=new TH2F("d0d0b","",100,1.864-0.05,1.864+0.05,100,1.864-0.05,1.864+0.05);
40 
41  TH1F *nmult=new TH1F("nmult","# neutrals",15,0,15);
42 
43  if (num==0) num= t->GetEntries();
44  cout <<"\n####### Processing "<<num <<" events...\n"<<endl;
45 
46  // **** create all the particle lists we'll need for rebuilding the decay tree
47  //
48  TCandList mc;
49 
50  TCandList neut,chrg, plus,minus;
51 
52  TCandList kp,km,pip,pim;
53 
54  TCandList d0,d0b,pp,pipi;
55 
56  // **** create and configure the selectors/filters we'd like to use later
57  //
58  TPidChargedSelector *chargedSel = new TPidChargedSelector;
59  TPidNeutralSelector *neutralSel = new TPidNeutralSelector;
60  TPidPlusSelector *plusSel = new TPidPlusSelector;
61  TPidMinusSelector *minusSel = new TPidMinusSelector;
62 
63  // **** mass selectors for the resonances/composites
64  //
65  TPidMassSelector *d0MSel = new TPidMassSelector("d0Selector" , 1.864 , 0.03);
66 
67  TPidSimpleKaonSelector *kSel = new TPidSimpleKaonSelector();
68  kSel->SetCriterion("veryLoose");
69  TPidSimplePionSelector *piSel = new TPidSimplePionSelector();
70  piSel->SetCriterion("veryLoose");
71 
72  int i1,i2;
73 
74  // **** loop over all _events_
75  //
76  for (Int_t j=0; j< num;j++)
77  {
78  if ((j%100)==0) cout <<"evt "<<j<<endl;
79 
80  t->GetEntry(j);
81  TFactory::Instance()->Reset();
82 
83  mc.Cleanup();
84  chrg.Cleanup();
85  neut.Cleanup();
86 
87  // **** loop over all Candidates and add them to the list allCands
88  //
89 
90  for (i1=0; i1<fMicro->GetEntriesFast(); i1++){
91  //PndPidCandidate *mic = (PndPidCandidate *)fMicro->At(i1);
92  TCandidate tc2(*((PndPidCandidate*)fMicro->At(i1)),i1);
93  if (abs(tc2.Charge())>0.01)chrg.Add(tc2);
94  else neut.Add(tc2);
95  }
96 
97 
98  for (i1=0; i1<fMcCands->GetEntriesFast(); i1++){
99  tc = (TCandidate *)fMcCands->At(i1);
100  mc.Add(*tc);
101  }
102 
103  // **** select all the basic list
104 
105  nmult->Fill(neut.GetLength());
106 
107  plus.Select(chrg ,plusSel);
108  minus.Select(chrg ,minusSel);
109 
110  // **** pid selection
111  //
112  kp.Select(plus ,kSel);
113  km.Select(minus ,kSel);
114  pip.Select(plus ,piSel);
115  pim.Select(minus ,piSel);
116 
117  // **** now start combining all composits; inbetween plot masses
118  // before using the mass selectors
119  //
120  d0.Combine(km,pip);
121  d0b.Combine(kp,pim);
122 
123  for (i2=0;i2<d0.GetLength();i2++) d0mass->Fill(d0[i2].M());
124  for (i2=0;i2<d0b.GetLength();i2++) d0mass->Fill(d0b[i2].M());
125 
126  d0.Select(d0MSel);
127  d0b.Select(d0MSel);
128 
129  pp.Combine(d0,d0b,pip,pim);
130 
131  for (i2=0;i2<pp.GetLength();i2++) ppmass->Fill(pp[i2].M());
132 
133  }
134 
135  // **** plot all that stuff
136  //
137  c1->cd(1);
138  d0mass->Draw();
139  c1->cd(2);
140  ppmass->Draw();
141  c1->cd(3);
142  nmult->Draw();
143 
144  timer.Stop();
145  Double_t rtime = timer.RealTime();
146  Double_t ctime = timer.CpuTime();
147 
148  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
149  return 0;
150 }
151 
152 /*void printTree(TCandidate *tc, int level=0)
153 {
154  int i=0;
155  int nd=tc->NDaughters();
156  if (nd==0) return;
157  cout <<tc->Uid()<<"("<<level<<") -> ";
158  for (i=0;i<nd;i++) cout<<tc->Daughter(i)->Uid()<<" ";
159  cout <<endl;
160  for (i=0;i<nd;i++) printTree(tc->Daughter(i),level+1);
161  if (level==0) cout <<endl;
162 }
163 */
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
basiclibs()
int num[96]
Definition: ranlxd.cxx:381
int ana_d0d0b_micro(TString fname="dsds_10k.evt.root", int num=0)
TClonesArray * fMcCands
Definition: poormantracks.C:26
Double_t d0
Definition: checkhelixhit.C:59
Double_t
TStopwatch timer
Definition: hit_dirc.C:51
c1
Definition: plot_dirc.C:35
Double_t ctime
Definition: hit_dirc.C:114
TTree * t
Definition: bump_analys.C:13
Double_t rtime
Definition: hit_dirc.C:113