FairRoot/PandaRoot
Functions
ana_dsdsj2.C File Reference

Go to the source code of this file.

Functions

int ana_dsdsj2 (TString fname="dsds_10k.evt.root", int num=0)
 

Function Documentation

int ana_dsdsj2 ( TString  fname = "dsds_10k.evt.root",
int  num = 0 
)

Definition at line 1 of file ana_dsdsj2.C.

References basiclibs(), c1, ctime, Double_t, f, fMcCands, idx, num, printf(), rtime, t, and timer.

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",900,600);
13  c1->Divide(3,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  // **** for every event, a TCLonesArray with the candidates is stored in pndsim
21  //
22  TClonesArray *fChrgCands=new TClonesArray("TCandidate");
23  TClonesArray *fNeutCands=new TClonesArray("TCandidate");
24  TClonesArray *fMcCands=new TClonesArray("TCandidate");
25 
26  t->SetBranchAddress("PndChargedCandidates",&fChrgCands);
27  t->SetBranchAddress("PndNeutralCandidates",&fNeutCands);
28  t->SetBranchAddress("PndMcTracks",&fMcCands);
29 
30  TCandidate *tc;
31 
32  // **** create and setup some histos for QA plots
33  //
34  TH1F *phimass = new TH1F("phimass","phi cands",100,0.95,1.1);
35  TH1F *pi0mass = new TH1F("pi0mass","pi0 cands",100,0.135-0.03,0.135+0.03);
36  TH1F *dsmass = new TH1F("dsmass","Ds cands",100,1.968-0.03,1.968+0.03);
37  TH1F *ds0mass = new TH1F("ds0mass","Ds0 cands",100,2.317-0.05,2.317+0.05);
38  TH1F *ppmass = new TH1F("ppmass","pbarp cands",100,4.306-0.1,4.306+0.1);
39 
40  TH1F *nmult=new TH1F("nmult","# neutrals",15,0,15);
41 
42  TH1F *pdiff=new TH1F("pdiff","momentum difference",100,-0.05,0.05);
43 
44  phimass->SetMinimum(0);
45  pi0mass->SetMinimum(0);
46  dsmass->SetMinimum(0);
47  ds0mass->SetMinimum(0);
48  ppmass->SetMinimum(0);
49 
50  if (num==0) num= t->GetEntriesFast();
51  cout <<"\n####### Processing "<<num <<" events...\n"<<endl;
52 
53  // **** create all the particle lists we'll need for rebuilding the decay tree
54  //
55  TCandList mcCands;
56 
57  TCandList allCands,neutralCands,chargedCands, plusCands,minusCands;
58 
59  TCandList kpCands,kmCands,piCands;
60 
61  TCandList phiCands,pi0Cands,dsCands,ds0Cands,ppCands;
62 
63  // **** create and configure the selectors/filters we'd like to use later
64  //
65  TPidChargedSelector *chargedSel = new TPidChargedSelector;
66  TPidNeutralSelector *neutralSel = new TPidNeutralSelector;
67  TPidPlusSelector *plusSel = new TPidPlusSelector;
68  TPidMinusSelector *minusSel = new TPidMinusSelector;
69 
70  // **** mass selectors for the resonances/composites
71  //
72  TPidMassSelector *phiMSel = new TPidMassSelector("phiSelector" , 1.0195 , 0.01);
73  TPidMassSelector *pi0MSel = new TPidMassSelector("pi0Selector" , 0.135 , 0.005);
74  TPidMassSelector *dsMSel = new TPidMassSelector("dsSelector" , 1.9685 , 0.01);
75 
76  TPidSimpleKaonSelector *kSel = new TPidSimpleKaonSelector();
77  kSel->SetCriterion("loose");
78  TPidSimplePionSelector *piSel = new TPidSimplePionSelector();
79  piSel->SetCriterion("veryLoose");
80 
81  int i1,i2;
82 
83  // **** loop over all _events_
84  //
85  for (Int_t j=0; j< num;j++)
86  {
87  if ((j%100)==0) cout <<"evt "<<j<<endl;
88 
89  t->GetEntry(j);
90  TFactory::Instance()->Reset();
91 
92  mcCands.Cleanup();
93  chargedCands.Cleanup();
94  neutralCands.Cleanup();
95 
96  // **** loop over all Candidates and add them to the list allCands
97  //
98 
99  for (i1=0; i1<fChrgCands->GetEntriesFast(); i1++){
100  tc = (TCandidate *)fChrgCands->At(i1);
101  chargedCands.Add(*tc);
102  }
103 
104  for (i1=0; i1<fNeutCands->GetEntriesFast(); i1++){
105  tc = (TCandidate *)fNeutCands->At(i1);
106  neutralCands.Add(*tc);
107  }
108 
109  for (i1=0; i1<fMcCands->GetEntriesFast(); i1++){
110  tc = (TCandidate *)fMcCands->At(i1);
111  mcCands.Add(*tc);
112  }
113 
114 
115  // **** select all the basic list
116  //
117 
118  //cout <<"c:"<<chargedCands.GetLength()<<" n:"<<neutralCands.GetLength()<<endl;
119 
120  nmult->Fill(neutralCands.GetLength());
121 
122  plusCands.Select(chargedCands ,plusSel);
123  minusCands.Select(chargedCands ,minusSel);
124 
125  // **** pid selection
126  //
127  kpCands.Select(plusCands ,kSel);
128  kmCands.Select(minusCands ,kSel);
129  piCands.Select(chargedCands ,piSel);
130 
131  // **** now start combining all composits; inbetween plot masses
132  // before using the mass selectors
133  //
134  phiCands.Combine(kpCands,kmCands);
135 
136  TCandListIterator iterPhi(phiCands);
137  while (tc=iterPhi.Next()) phimass->Fill(tc->M());
138  phiCands.Select(phiMSel);
139 
140  dsCands.Combine(phiCands,piCands);
141 
142  TCandListIterator iterDs(dsCands);
143  while (tc=iterDs.Next()) dsmass->Fill(tc->M());
144  dsCands.Select(dsMSel);
145 
146  pi0Cands.Combine(neutralCands,neutralCands);
147 
148  TCandListIterator iterPi0(pi0Cands);
149  while (tc=iterPi0.Next()) pi0mass->Fill(tc->M());
150  pi0Cands.Select(pi0MSel);
151 
152  ds0Cands.Combine(dsCands,pi0Cands);
153 
154  TCandListIterator iterDs0(ds0Cands);
155  while (tc=iterDs0.Next()) ds0mass->Fill(tc->M());
156 
157  ppCands.Combine(ds0Cands,dsCands);
158  //cout << ds0Cands.GetLength()<<" "<<dsCands.GetLength()<<" "<<ppCands.GetLength()<<endl;
159  ppCands.Select(neutralSel);
160 
161  // **** since we didn't care about the D_s charge, combinations might appear in two
162  // different ways; RemoveClones removes double candidates based on the same final states
163  ppCands.RemoveClones();
164 
165  TCandListIterator iterPp(ppCands);
166 
167  while (tc=iterPp.Next())
168  {
169  ppmass->Fill(tc->M());
170  //printTree(tc);
171  }
172 
173  TCandListIterator iterChrg(chargedCands);
174  while(tc=iterChrg.Next())
175  {
176  int idx=tc->GetMcIdx();
177  if (idx!=-1) pdiff->Fill(tc->P()-mcCands[idx]->P());
178  }
179 
180 
181  }
182 
183  // **** plot all that stuff
184  //
185  c1->cd(1);
186  phimass->Draw();
187  c1->cd(2);
188  pi0mass->Draw();
189  c1->cd(3);
190  dsmass->Draw();
191  c1->cd(4);
192  ds0mass->Draw();
193  c1->cd(5);
194  ppmass->Draw();
195  c1->cd(6);
196  pdiff->Draw();
197 
198  timer.Stop();
199  Double_t rtime = timer.RealTime();
200  Double_t ctime = timer.CpuTime();
201 
202  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
203 
204  return 0;
205 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
basiclibs()
int num[96]
Definition: ranlxd.cxx:381
TClonesArray * fMcCands
Definition: poormantracks.C:26
int idx[MAX]
Definition: autocutx.C:38
Double_t
TStopwatch timer
Definition: hit_dirc.C:51
TFile * f
Definition: bump_analys.C:12
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