FairRoot/PandaRoot
Functions
ana_Lambda_fit2.C File Reference

Go to the source code of this file.

Functions

void propagate (TLorentzVector &l, TVector3 &p, float charge, TH2F *hpro=0)
 
int ana_Lambda_fit2 (TString fname="Lambda.full_2000ev.root", int num=0)
 

Function Documentation

int ana_Lambda_fit2 ( TString  fname = "Lambda.full_2000ev.root",
int  num = 0 
)

Definition at line 66 of file ana_Lambda_fit2.C.

References basiclibs(), c1, ctime, d, Double_t, f, num, p, printf(), propagate(), rtime, t, and timer.

67 {
68  TStopwatch timer;
69  timer.Start();
70 
71  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
72  basiclibs();
73 
74  // **** the library is needed in order to use the TCandidate and TCandList etc
75  gSystem->Load("libRho");
76 
77  TCanvas *c1=new TCanvas("c1","c1",800,800);
78  c1->Divide(2,2);
79 
80  // **** access the datastructure holding the particle lists
81  //
82  TFile* f = new TFile(fname.Data());
83  TTree *t=f->Get("pndsim") ;
84 
85  // **** for every event, a TCLonesArray with the candidates is stored in pndsim
86  //
87  TClonesArray *fChrgCands=new TClonesArray("TCandidate");
88  //TClonesArray *fNeutCands=new TClonesArray("TCandidate");
89  //TClonesArray *fMcCands=new TClonesArray("TCandidate");
90 
91  t->SetBranchAddress("PndChargedCandidates",&fChrgCands);
92  //t->SetBranchAddress("PndNeutralCandidates",&fNeutCands);
93  //t->SetBranchAddress("PndMcTracks",&fMcCands);
94 
95  TCandidate *tc;
96 
97  // **** create and setup some histos for QA plots
98  //
99  TH1F *ppimass = new TH1F("ppimass","p pi cands",100,1.05,1.2);
100  TH1F *ppi2mass = new TH1F("ppi2mass","p pi cands",100,1.05,1.2);
101  ppi2mass->SetFillColor(2);
102  ppi2mass->SetLineColor(2);
103  ppi2mass->SetLineWidth(1);
104 
105  TH2F *hvtx=new TH2F("hvtx","vertex positions (x,y)",100,-10,10,100,-10,10);
106  TH2F *hvtx2=new TH2F("hvtx2","vertex positions (x,z)",100,-10,10,100,-10,10);
107 
108  TH1F *hdist=new TH1F("hdist","vtx distance to (0,0,0)",100,0,15);
109 
110  ppimass->SetMinimum(0);
111 
112  if (num==0) num= t->GetEntriesFast();
113  cout <<"\n####### Processing "<<num <<" events...\n"<<endl;
114 
115  // **** create all the particle lists we'll need for rebuilding the decay tree
116  //
117  TCandList mcCands;
118 
119  TCandList allCands,chargedCands, minusCands, plusCands, pplusCands, pminusCands, piplusCands, piminusCands;
120 
121  TCandList ppiCands;
122 
123  // **** create and configure the selectors/filters we'd like to use later
124  //
125  TPidChargedSelector *chargedSel = new TPidChargedSelector;
126  TPidNeutralSelector *neutralSel = new TPidNeutralSelector;
127 
128  TPidPlusSelector *plusSel = new TPidPlusSelector;
129  TPidMinusSelector *minusSel = new TPidMinusSelector;
130 
131  // **** mass selectors for the resonances/composites
132  //
133  TPidSimplePionSelector *piSel = new TPidSimplePionSelector();
134  piSel->SetCriterion("veryLoose");
135  TPidSimpleProtonSelector *pSel = new TPidSimpleProtonSelector();
136  pSel->SetCriterion("veryLoose");
137 
138  int i1,i2;
139 
140  // **** loop over all _events_
141  //
142  for (Int_t j=0; j< num;j++)
143  {
144  TFactory::Instance()->Reset();
145 
146  chargedCands.Cleanup();
147  ppiCands.Cleanup();
148 
149  t->GetEntry(j);
150 
151 
152  if ((j%100)==0)
153  {
154  cout <<"evt "<<j<<endl;
155  c1->cd(1);
156  if (ppi2mass->GetMaximum()<ppimass->GetMaximum()) ppi2mass->SetMaximum(ppimass->GetMaximum()*1.05);
157 
158  ppi2mass->Draw();
159  ppimass->Draw("same");
160 
161  c1->cd(2);
162  hdist->Draw();
163  c1->cd(3);
164  hvtx->Draw("");
165  c1->cd(4);
166  hvtx2->Draw("");
167  c1->Update();
168  }
169 
170 
171  // **** loop over all Candidates and add them to the list allCands
172  //
173 
174  for (i1=0; i1<fChrgCands->GetEntriesFast(); i1++){
175  tc = (TCandidate *)fChrgCands->At(i1);
176 
177  //TMatrixD cov=tc->Cov7();
178  //cov.Print();
179 
180  TLorentzVector l=tc->P4();
181  TVector3 p=tc->Pos();
182 
183  propagate(l,p,tc->GetCharge());
184  tc->SetP4(l);
185  tc->SetPos(p);
186 
187  //TMatrixD cov=tc->Cov7();
188  //cov.Print();
189 
190  chargedCands.Add(*tc);
191 
192  //TMatrixD cov2=chargedCands[chargedCands.GetLength()-1].Cov7();
193  //cov2.Print();
194 
195  }
196 
197  plusCands.Select(chargedCands, plusSel);
198  minusCands.Select(chargedCands, minusSel);
199 
200  pplusCands.Select(plusCands,pSel);
201  pminusCands.Select(minusCands,pSel);
202 
203  piplusCands.Select(plusCands,piSel);
204  piminusCands.Select(minusCands,piSel);
205 
206  cout <<endl<<"---------------------"<<endl;
207  cout <<"chrg:"<<chargedCands.GetLength()<<" ";
208  cout <<"plus:"<<plusCands.GetLength()<<" ";
209  cout <<"minus:"<<minusCands.GetLength()<<" ";
210  cout <<"p+:"<<pplusCands.GetLength()<<" ";
211  cout <<"p-:"<<pminusCands.GetLength()<<" ";
212  cout <<"pi+:"<<piplusCands.GetLength()<<" ";
213  cout <<"pi-:"<<piminusCands.GetLength()<<endl;
214 
215  // **** select all the basic list
216  //
217 
218  //cout <<"c:"<<chargedCands.GetLength()<<" n:"<<neutralCands.GetLength()<<endl;
219 
220 
221  ppiCands.Combine(piminusCands,pplusCands);
222  //ppiCands.Combine(pplusCands,piminusCands);
223 
224  TCandListIterator iterP(ppiCands);
225  while (tc=iterP.Next())
226  {
227  ppimass->Fill(tc->Mass());
228  PndVtxFitter vtxf(*tc);
229  vtxf.Fit();
230  TCandidate *fitted=vtxf.FittedCand(*tc);
231  cout <<"unfitted="<<(*tc)<<endl;
232  if (fitted)
233  {
234  double d=fitted->Pos().Mag();
235  //if (d==0) continue;
236  cout <<"fitted = "<<(*fitted)<<endl;
237  ppi2mass->Fill(fitted->Mass());
238  hvtx->Fill(fitted->Pos().X(),fitted->Pos().Y());
239  hvtx2->Fill(fitted->Pos().X(),fitted->Pos().Z());
240  hdist->Fill(fitted->Pos().Mag());
241  }
242 
243  }
244  /*
245  int ii,jj;
246 
247  int npi=piminusCands.GetLength();
248  int np=pplusCands.GetLength();
249 
250 
251  for (ii=0;ii<npi;ii++)
252  {
253  for (jj=0;jj<np;jj++)
254  {
255  TCandidate pim=piminusCands[ii];
256  TCandidate pp=pplusCands[jj];
257 
258  if( pp.Overlaps(pim)) continue;
259 
260  //TMatrixD pcov=pp.Cov7();
261  //TMatrixD picov=pim.Cov7();
262 
263  TCandidate *compo=pim.Combine(pp);
264  ppimass->Fill(compo->Mass());
265  PndVtxFitter vtxf(*compo);
266  vtxf.Fit();
267  TCandidate *fitted=vtxf.FittedCand(*compo);
268  cout <<"unfitted="<<(*compo)<<endl;
269  if (fitted)
270  {
271  double d=fitted->Pos().Mag();
272  if (d==0) continue;
273  cout <<"fitted = "<<(*fitted)<<endl;
274  ppi2mass->Fill(fitted->Mass());
275  hvtx->Fill(fitted->Pos().X(),fitted->Pos().Y());
276  hvtx2->Fill(fitted->Pos().X(),fitted->Pos().Z());
277  hdist->Fill(fitted->Pos().Mag());
278  }
279 
280  // cout <<"Proton:" <<pp<<endl;
281  //pcov.Print();
282  //cout <<"Pion:"<<pim<<endl;
283  //picov.Print();
284 
285  //delete compo;
286  }
287  }
288  */
289  }
290  // **** plot all that stuff
291  //
292  c1->cd(1);
293  if (ppi2mass->GetMaximum()<ppimass->GetMaximum()) ppi2mass->SetMaximum(ppimass->GetMaximum()*1.05);
294 
295  ppi2mass->Draw();
296  ppimass->Draw("same");
297 
298  c1->cd(2);
299  hdist->Draw();
300  c1->cd(3);
301  hvtx->Draw("");
302  c1->cd(4);
303  hvtx2->Draw("");
304  c1->Update();
305 
306  timer.Stop();
307  Double_t rtime = timer.RealTime();
308  Double_t ctime = timer.CpuTime();
309 
310  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
311 
312  return 0;
313 }
Double_t p
Definition: anasim.C:58
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
void propagate(TLorentzVector &l, TVector3 &p, float charge, TH2F *hpro=0)
TObjArray * d
basiclibs()
int num[96]
Definition: ranlxd.cxx:381
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
void propagate ( TLorentzVector &  l,
TVector3 &  p,
float  charge,
TH2F *  hpro = 0 
)

Definition at line 1 of file ana_Lambda_fit2.C.

References a, cos(), dz, i, lambda(), pt(), pz, sin(), sqrt(), x, x0, y, y0, z, and z0.

2 {
3  double x0=p.X()/100;
4  double y0=p.Y()/100;
5  double z0=p.Z()/100;
6 
7  double px0=l.Px();
8  double py0=l.Py();
9  double pz0=l.Pz();
10 
11  double B=2;
12 
13  double pt=sqrt(px0*px0+py0*py0);
14  double lambda=pz0/pt;
15  double s_t=z0/lambda;
16  double a=-0.2998*B*charge/3;
17  double rho=a/pt;
18 
19  //cout <<hpro<<endl;
20 
21  if (hpro)
22  {
23  int steps=100;
24  double dz=z0/steps;
25  for (int i=0;i<steps;i++)
26  {
27  if (i==90) i=99;
28  double s_tt=(i+1)*dz/lambda;
29  double cosrst=cos(rho*s_tt);
30  double sinrst=sin(rho*s_tt);
31 
32  double px = px0*cosrst + py0*sinrst;
33  double py = py0*cosrst - px0*sinrst;
34  //double pz = pz0;
35 
36  double xt=x0 - px/a*sinrst + py/a*(1-cosrst);
37  double yt=y0 - py/a*sinrst - px/a*(1-cosrst);
38  //double z=z0 - lambda*s_tt;
39 
40  hpro->Fill(xt,yt);
41  }
42  }
43 
44  //cout <<"lam="<<atan(1/lambda)/3.1416*180<<" "<<rho<<" "<<s_t<<endl;
45 
46  double cosrs=cos(rho*s_t);
47  double sinrs=sin(rho*s_t);
48 
49  double px = px0*cosrs + py0*sinrs;
50  double py = py0*cosrs - px0*sinrs;
51  double pz = pz0;
52 
53  double x=x0 - px/a*sinrs + py/a*(1-cosrs);
54  double y=y0 - py/a*sinrs - px/a*(1-cosrs);
55  double z=z0 - lambda*s_t;
56 
57  l.SetX(px);
58  l.SetY(py);
59  l.SetZ(pz);
60 
61  p.SetX(x*100);
62  p.SetY(y*100);
63  p.SetZ(z*100);
64 }
Double_t z0
Definition: checkhelixhit.C:62
Double_t x0
Definition: checkhelixhit.C:70
Double_t p
Definition: anasim.C:58
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
Int_t i
Definition: run_full.C:25
Double_t lambda(Double_t x, Double_t y, Double_t z)
Definition: drawdal.C:48
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:111
TString pt(TString pts, TString exts="px py pz")
Definition: invexp.C:133
Int_t a
Definition: anaLmdDigi.C:126
Double_t y0
Definition: checkhelixhit.C:71
Double_t z
Double_t x
Double_t y
double pz[39]
Definition: pipisigmas.h:14