FairRoot/PandaRoot
Functions
ana_Lambda_fit.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_fit (TString fname="tmp.root", int num=0)
 

Function Documentation

int ana_Lambda_fit ( TString  fname = "tmp.root",
int  num = 0 
)

Definition at line 66 of file ana_Lambda_fit.C.

References basiclibs(), c1, ctime, d, Double_t, f, jj, npi, 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  t->GetEntry(j);
145  TFactory::Instance()->Reset();
146 
147  chargedCands.Cleanup();
148 
149  t->GetEntry(j);
150  if ((j%100)==0)
151  {
152  cout <<"evt "<<j<<endl;
153  c1->cd(1);
154  if (ppi2mass->GetMaximum()<ppimass->GetMaximum()) ppi2mass->SetMaximum(ppimass->GetMaximum()*1.05);
155 
156  ppi2mass->Draw();
157  ppimass->Draw("same");
158 
159  c1->cd(2);
160  hdist->Draw();
161  c1->cd(3);
162  hvtx->Draw("");
163  c1->cd(4);
164  hvtx2->Draw("");
165  c1->Update();
166  }
167 
168  // **** loop over all Candidates and add them to the list allCands
169  //
170 
171  for (i1=0; i1<fChrgCands->GetEntriesFast(); i1++){
172  tc = (TCandidate *)fChrgCands->At(i1);
173 
174  //TMatrixD cov=tc->Cov7();
175  //cov.Print();
176 
177  TLorentzVector l=tc->P4();
178  TVector3 p=tc->Pos();
179 
180  propagate(l,p,tc->GetCharge());
181  tc->SetP4(l);
182  tc->SetPos(p);
183 
184  //TMatrixD cov=tc->Cov7();
185  //cov.Print();
186 
187  chargedCands.Add(*tc);
188 
189  //TMatrixD cov2=chargedCands[chargedCands.GetLength()-1].Cov7();
190  //cov2.Print();
191 
192  }
193 
194  plusCands.Select(chargedCands, plusSel);
195  minusCands.Select(chargedCands, minusSel);
196 
197  pplusCands.Select(plusCands,pSel);
198  pminusCands.Select(minusCands,pSel);
199 
200  piplusCands.Select(plusCands,piSel);
201  piminusCands.Select(minusCands,piSel);
202  cout <<endl<<"---------------------"<<endl;
203  cout <<"chrg:"<<chargedCands.GetLength()<<" ";
204  cout <<"plus:"<<plusCands.GetLength()<<" ";
205  cout <<"minus:"<<minusCands.GetLength()<<" ";
206  cout <<"p+:"<<pplusCands.GetLength()<<" ";
207  cout <<"p-:"<<pminusCands.GetLength()<<" ";
208  cout <<"pi+:"<<piplusCands.GetLength()<<" ";
209  cout <<"pi-:"<<piminusCands.GetLength()<<endl;
210 
211  // **** select all the basic list
212  //
213 
214  //cout <<"c:"<<chargedCands.GetLength()<<" n:"<<neutralCands.GetLength()<<endl;
215 
216  /*
217  ppiCands.Combine(pplusCands,piminusCands);
218  //ppiCands.Combine(pminusCands,piplusCands);
219 
220  TCandListIterator iterP(ppiCands);
221  while (tc=iterP.Next()) ppimass->Fill(tc->M());
222  */
223  int ii,jj;
224 
225  int npi=piminusCands.GetLength();
226  int np=pplusCands.GetLength();
227 
228 
229  for (ii=0;ii<npi;ii++)
230  {
231  for (jj=0;jj<np;jj++)
232  {
233  TCandidate pim=piminusCands[ii];
234  TCandidate pp=pplusCands[jj];
235 
236  if( pp.Overlaps(pim)) continue;
237 
238  //TMatrixD pcov=pp.Cov7();
239  //TMatrixD picov=pim.Cov7();
240 
241  TCandidate *compo=pim.Combine(pp);
242  ppimass->Fill(compo->Mass());
243  PndVtxFitter vtxf(*compo);
244  vtxf.Fit();
245  TCandidate *fitted=vtxf.FittedCand(*compo);
246  cout <<"unfitted="<<(*compo)<<endl;
247  if (fitted)
248  {
249  double d=fitted->Pos().Mag();
250  if (d==0) continue;
251  cout <<"fitted = "<<(*fitted)<<endl;
252  ppi2mass->Fill(fitted->Mass());
253  hvtx->Fill(fitted->Pos().X(),fitted->Pos().Y());
254  hvtx2->Fill(fitted->Pos().X(),fitted->Pos().Z());
255  hdist->Fill(fitted->Pos().Mag());
256  }
257  /*
258  cout <<"Proton:" <<pp<<endl;
259  pcov.Print();
260  cout <<"Pion:"<<pim<<endl;
261  picov.Print();
262  */
263  //delete compo;
264  }
265  }
266 
267  }
268  // **** plot all that stuff
269  //
270  c1->cd(1);
271  if (ppi2mass->GetMaximum()<ppimass->GetMaximum()) ppi2mass->SetMaximum(ppimass->GetMaximum()*1.05);
272 
273  ppi2mass->Draw();
274  ppimass->Draw("same");
275 
276  c1->cd(2);
277  hdist->Draw();
278  c1->cd(3);
279  hvtx->Draw("");
280  c1->cd(4);
281  hvtx2->Draw("");
282  c1->Update();
283 
284  timer.Stop();
285  Double_t rtime = timer.RealTime();
286  Double_t ctime = timer.CpuTime();
287 
288  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
289 return 0;
290 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
TObjArray * d
basiclibs()
int num[96]
Definition: ranlxd.cxx:381
void propagate(TLorentzVector &l, TVector3 &p, float charge, TH2F *hpro=0)
Definition: ana_Lambda_fit.C:1
Double_t p
Definition: anasim.C:58
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
int npi
Definition: toy_core.C:124
void propagate ( TLorentzVector &  l,
TVector3 &  p,
float  charge,
TH2F *  hpro = 0 
)

Definition at line 1 of file ana_Lambda_fit.C.

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

Referenced by ana_Lambda_fit().

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
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
Double_t p
Definition: anasim.C:58
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