FairRoot/PandaRoot
ana_Lambda.C
Go to the documentation of this file.
1 void propagate(TLorentzVector &l, TVector3 &p, float charge, TH2F* hpro=0)
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 }
65 
66 int ana_Lambda(TString fname="tmp.root",int num=0)
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",600,600);
78 
79  // **** access the datastructure holding the particle lists
80  //
81  TFile* f = new TFile(fname.Data());
82  TTree *t=f->Get("pndsim") ;
83 
84  // **** for every event, a TCLonesArray with the candidates is stored in pndsim
85  //
86  TClonesArray *fChrgCands=new TClonesArray("TCandidate");
87  //TClonesArray *fNeutCands=new TClonesArray("TCandidate");
88  //TClonesArray *fMcCands=new TClonesArray("TCandidate");
89 
90  t->SetBranchAddress("PndChargedCandidates",&fChrgCands);
91  //t->SetBranchAddress("PndNeutralCandidates",&fNeutCands);
92  //t->SetBranchAddress("PndMcTracks",&fMcCands);
93 
94  TCandidate *tc;
95 
96  // **** create and setup some histos for QA plots
97  //
98  TH1F *ppimass = new TH1F("ppimass","p pi cands",100,1.115-0.2,1.115+0.2);
99 
100  ppimass->SetMinimum(0);
101 
102  if (num==0) num= t->GetEntriesFast();
103  cout <<"\n####### Processing "<<num <<" events...\n"<<endl;
104 
105  // **** create all the particle lists we'll need for rebuilding the decay tree
106  //
107  TCandList mcCands;
108 
109  TCandList allCands,chargedCands, minusCands, plusCands, pplusCands, pminusCands, piplusCands, piminusCands;
110 
111  TCandList ppiCands;
112 
113  // **** create and configure the selectors/filters we'd like to use later
114  //
115  TPidChargedSelector *chargedSel = new TPidChargedSelector;
116  TPidNeutralSelector *neutralSel = new TPidNeutralSelector;
117 
118  TPidPlusSelector *plusSel = new TPidPlusSelector;
119  TPidMinusSelector *minusSel = new TPidMinusSelector;
120 
121  // **** mass selectors for the resonances/composites
122  //
123  TPidSimplePionSelector *piSel = new TPidSimplePionSelector();
124  piSel->SetCriterion("veryLoose");
125  TPidSimpleProtonSelector *pSel = new TPidSimpleProtonSelector();
126  pSel->SetCriterion("veryLoose");
127 
128  int i1,i2;
129 
130  // **** loop over all _events_
131  //
132  for (Int_t j=0; j< num;j++)
133  {
134  if ((j%100)==0) cout <<"evt "<<j<<endl;
135 
136  t->GetEntry(j);
137  TFactory::Instance()->Reset();
138 
139  chargedCands.Cleanup();
140 
141  // **** loop over all Candidates and add them to the list allCands
142  //
143 
144  for (i1=0; i1<fChrgCands->GetEntriesFast(); i1++){
145  tc = (TCandidate *)fChrgCands->At(i1);
146 
147  TLorentzVector l=tc->P4();
148  TVector3 p=tc->Pos();
149 
150  propagate(l,p,tc->GetCharge());
151  tc->SetP4(l);
152  tc->SetPos(p);
153 
154  chargedCands.Add(*tc);
155 
156  }
157 
158  plusCands.Select(chargedCands, plusSel);
159  minusCands.Select(chargedCands, minusSel);
160 
161  pplusCands.Select(plusCands,pSel);
162  pminusCands.Select(minusCands,pSel);
163 
164  piplusCands.Select(plusCands,piSel);
165  piminusCands.Select(minusCands,piSel);
166 
167  cout <<"chrg:"<<chargedCands.GetLength()<<" ";
168  cout <<"plus:"<<plusCands.GetLength()<<" ";
169  cout <<"minus:"<<minusCands.GetLength()<<" ";
170  cout <<"p+:"<<pplusCands.GetLength()<<" ";
171  cout <<"p-:"<<pminusCands.GetLength()<<" ";
172  cout <<"pi+:"<<piplusCands.GetLength()<<" ";
173  cout <<"pi-:"<<piminusCands.GetLength()<<endl;
174 
175  // **** select all the basic list
176  //
177 
178  //cout <<"c:"<<chargedCands.GetLength()<<" n:"<<neutralCands.GetLength()<<endl;
179 
180 
181  ppiCands.Combine(pplusCands,piminusCands);
182  ppiCands.CombineAndAppend(pminusCands,piplusCands);
183 
184  TCandListIterator iterP(ppiCands);
185  while (tc=iterP.Next()) ppimass->Fill(tc->M());
186  }
187  // **** plot all that stuff
188  //
189  c1->cd(1);
190  ppimass->Draw();
191 
192 
193  timer.Stop();
194  Double_t rtime = timer.RealTime();
195  Double_t ctime = timer.CpuTime();
196 
197  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
198 
199  return 0;
200 }
201 
202 /*void printTree(TCandidate *tc, int level=0)
203 {
204  int i=0;
205  int nd=tc->NDaughters();
206  if (nd==0) return;
207  cout <<tc->Uid()<<"("<<level<<") -> ";
208  for (i=0;i<nd;i++) cout<<tc->Daughter(i)->Uid()<<" ";
209  cout <<endl;
210  for (i=0;i<nd;i++) printTree(tc->Daughter(i),level+1);
211  if (level==0) cout <<endl;
212 }
213 */
Double_t z0
Definition: checkhelixhit.C:62
Double_t x0
Definition: checkhelixhit.C:70
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
basiclibs()
int num[96]
Definition: ranlxd.cxx:381
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
void propagate(TLorentzVector &l, TVector3 &p, float charge, TH2F *hpro=0)
Definition: ana_Lambda.C:1
Double_t y0
Definition: checkhelixhit.C:71
TStopwatch timer
Definition: hit_dirc.C:51
TFile * f
Definition: bump_analys.C:12
Double_t z
c1
Definition: plot_dirc.C:35
Double_t ctime
Definition: hit_dirc.C:114
Double_t x
TTree * t
Definition: bump_analys.C:13
int ana_Lambda(TString fname="tmp.root", int num=0)
Definition: ana_Lambda.C:66
Double_t y
Double_t rtime
Definition: hit_dirc.C:113
double pz[39]
Definition: pipisigmas.h:14