CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FastMuPropagator.cc
Go to the documentation of this file.
2 #include "CLHEP/Units/GlobalPhysicalConstants.h"
3 #include "CLHEP/Vector/ThreeVector.h"
4 #include <CLHEP/Vector/LorentzVector.h>
10 
11 #include <cmath>
12 #include <stdlib.h>
13 #include <string>
14 #include <iostream>
15 #include <vector>
16 
17 //#define PROPAGATOR_DB
18 
19 using namespace std;
20 namespace cms {
22  FastMuPropagator::propagate(const FreeTrajectoryState& fts,
23  const Cylinder& boundcyl) const
24 {
26 
27  if(!checkfts(fts)) return badtsos;
28 
29 #ifdef PROPAGATOR_DB
30  cout<<"FastMuPropagator::propagate::Start propagation in barrel::zvert "<<theFmpConst->zvert<<endl;
31 #endif
32 
33  // Extract information from muchambers
34 
35  int charge;
36  int imin0,imax0;
37  double ptmax,ptmin,pt,phi,theta,theta0,z,pl;
38  double dfcalc,phnext,bound;
39  float ptboun=theFmpConst->ptboun;
40  float step=theFmpConst->step;
41 
42  GlobalVector moment=fts.parameters().momentum();
43  GlobalPoint posit=fts.parameters().position();
44  pt=moment.perp();
45  theta0=moment.theta();
46 // Correct theta
47  double zfts=fts.parameters().position().z()-theFmpConst->zvert;
48  double rfts=fts.parameters().position().perp();
49  theta = atan2(rfts,zfts);
50 
51 #ifdef PROPAGATOR_DB
52  cout<<"FastMuPropagator::propagate::Start propagation in barrel::theta old, new "<<theta0<<" "<<theta<<endl;
53 #endif
54 
55  phi=posit.phi();
56  ptmax=pt+fts.curvilinearError().matrix()(1,1);
57  ptmin=pt-fts.curvilinearError().matrix()(1,1);
58  bound=boundcyl.radius();
59  charge=fts.parameters().charge();
60 
61  imax0=(int)((ptmax-ptboun)/step)+1;
62  imin0=(int)((ptmin-ptboun)/step)+1;
63 #ifdef PROPAGATOR_DB
64  cout<<"FastMuPropagator::Look ptboun,step,imin0,imax0="<<ptboun<<" "<<step<<
65  " "<<imin0<<" "<<imax0<<endl;
66  cout<<"FastMuPropagator::Parameters (pt,theta,phi,ptmax,ptmin,bound)="<<pt<<" "
67  <<theta<<" "<<phi<<" "<<ptmax<<" "<<ptmin<<" "<<bound<<endl;
68 #endif
69  if(imax0 > 1){
70  if(imin0<1) imin0=1;
71  // ========================== phi ========================================
72  // new parametrisation (because of second mu-station)
73  //
74 
75 #ifdef PROPAGATOR_DB
76  cout<<"FastMuPropagator::New parameters="<<theFmpConst->newparam[0]<<endl;
77  cout<<"FastMuPropagator::New parameters for pt>40="<<
78  theFmpConst->newparamgt40[0]<<endl;
79 #endif
80 
81  if(pt<40.) {
82  dfcalc=charge/(theFmpConst->newparam[0]+theFmpConst->newparam[1]*pt
83  +theFmpConst->newparam[2]*pt*pt);
84  }else{
85  dfcalc=charge/(theFmpConst->newparamgt40[0]+
86  theFmpConst->newparamgt40[1]*pt+theFmpConst->newparamgt40[2]*pt*pt);
87  }
88 //
89 // !!!! temporarily decision till new parametrization appears.
90 //
91  if (abs(dfcalc) > 0.6 ) dfcalc = charge*0.6;
92 
93  phnext=dfcalc+phi;
94  if(phnext>=twopi) phnext=phnext-twopi;
95  if(phnext <0.) phnext=twopi+phnext;
96 #ifdef PROPAGATOR_DB
97  cout<<"FastMuPropagator::Phi in Muon Chamb="<<phi<<endl;
98  cout<<"FastMuPropagator::Phnext determined="<<phnext<<" dfcalc="<<dfcalc<<endl;
99 #endif
100  // ========================== Z ========================================
101  if(abs(theta-pi/2.)>0.00001){
102  z=bound/tan(theta)+theFmpConst->zvert;
103  if(fabs(z)>140) {
104 // Temporary implementation =====
105 // if(z>0.) z = z-45.;
106 // if(z<0.) z = z+45.;
107 // ==============================
108  }
109  }else{
110  z=0.;
111  }
112 #ifdef PROPAGATOR_DB
113  cout<<"FastMuPropgator::Z coordinate="<<z<<"bound="<<bound<<"theta="<<theta<<" "<<
114  abs(theta-pi/2.)<<endl;
115 #endif
116  // ====================== fill global point/vector =======================
117  GlobalPoint aX(bound*cos(phnext),bound*sin(phnext),z);
118  if(abs(theta-pi/2.)<0.00001){
119  pl=0.;
120  }else{
121  pl=pt/tan(theta);
122  }
123  // Recalculate momentum with some trick...
124  double dfcalcmom=charge*theFmpConst->partrack*bound/pt;
125  GlobalVector aP(pt*cos(phnext-dfcalcmom),pt*sin(phnext-dfcalcmom),pl);
126 
127 #ifdef PROPAGATOR_DB
128  cout<<"phnextmom="<<phnext-dfcalcmom<<endl;
129  cout<<"Cylinder aP="<<aP<<endl;
130  cout<<"Before propagation="<<pt*cos(phi)<< " "<<pt*sin(phi)<<" "<<pl<<endl;
131 #endif
132  // =======================================================================
133 
134  GlobalTrajectoryParameters gtp(aX,aP,charge,field);
136  int iwin;
137  float awin,bwin,phbound;
138 
139  if(pt>40.) {
140  iwin=8;
141  phbound=theFmpConst->phiwinb[7];
142  }else{
143  iwin=(int)(pt/theFmpConst->ptstep);
144  awin=(theFmpConst->phiwinb[iwin+1]-theFmpConst->phiwinb[iwin])
145  /(theFmpConst->ptwmax[iwin]-theFmpConst->ptwmin[iwin]);
146  bwin=theFmpConst->phiwinb[iwin]-awin*theFmpConst->ptwmin[iwin];
147  phbound=awin*pt+bwin;
148 
149  }
150 #ifdef PROPAGATOR_DB
151  cout<<"Size of window in phi="<<phbound<<" "<<iwin<<endl;
152  cout<<theFmpConst->phiwinb[iwin+1]<<" "<<theFmpConst->phiwinb[iwin]
153  <<" "<<theFmpConst->ptwmin[iwin]<<
154  " "<<theFmpConst->ptwmax[iwin]<<" awin="<<awin<<" bwin="<<bwin<<endl;
155 #endif
156  m(0,0)=(ptmax-ptmin)/6.; m(1,1)=phbound/theFmpConst->sigf;
157  m(2,2)=theFmpConst->zwin/theFmpConst->sigz;
158  m(3,3)=phbound/(2.*theFmpConst->sigf);m(4,4)=theFmpConst->zwin/(2.*theFmpConst->sigz);
159 
161 
162  FreeTrajectoryState fts(gtp,cte);
164  return tsos;
165 
166  }
167  return badtsos;
168 }
169 
170 
172  FastMuPropagator::propagate(const FreeTrajectoryState& fts,
173  const Plane& boundplane) const
174 
175 {
176  TrajectoryStateOnSurface badtsos;
177 
178 #ifdef PROPAGATOR_DB
179  cout<<"FastMuPropagator::propagate::Start propagation in forward::zvert "<<theFmpConst->zvert<<endl;
180 #endif
181  if(!checkfts(fts)) return badtsos;
182 
183  // Extract information from muchambers
184 
185  int imin0,imax0;
186  double ptmax,ptmin,pt,phi,theta,theta0,z,r,pl,plmin,plmax;
187  double dfcalc,phnext;
189  float ptboun=theFmpConst->ptboun;
190  float step=theFmpConst->step;
191 
192 
193  GlobalVector moment=fts.parameters().momentum();
194  GlobalPoint posit=fts.parameters().position();
195  pt=moment.perp();
196  theta0=moment.theta();
197 // Correct theta
198  double zfts=fts.parameters().position().z()-theFmpConst->zvert;
199  double rfts=fts.parameters().position().perp();
200  theta = atan2(rfts,zfts);
201 
202 #ifdef PROPAGATOR_DB
203  cout<<"FastMuPropagator::propagate::Start propagation in forward::theta old, new "<<theta0<<" "<<theta<<endl;
204 #endif
205 
206  phi=posit.phi();
207  ptmax=pt+fts.curvilinearError().matrix()(1,1);
208  ptmin=pt-fts.curvilinearError().matrix()(1,1);
209  pl=pt/tan(theta);
210  plmin=ptmin/tan(theta);
211  plmax=ptmax/tan(theta);
212  imax0=(int)((ptmax-ptboun)/step)+1;
213  imin0=(int)((ptmin-ptboun)/step)+1;
214 #ifdef PROPAGATOR_DB
215  cout<<"FastMuPropagator::Look ptboun,step,imin0,imax0="<<ptboun<<" "<<step<<
216  " "<<imin0<<" "<<imax0<<endl;
217  cout<<"FastMuPropagator::Parameters (pt,theta,phi,ptmax,ptmin)="<<pt<<" "
218  <<theta<<" "<<phi<<" "<<ptmax<<" "<<ptmin<<endl;
219 #endif
220  if(imax0 > 1){
221  if(imin0<1) imin0=1;
222 
223  z=boundplane.position().z();
224  r=(z-theFmpConst->zvert)*tan(theta);
225  charge=fts.parameters().charge();
226 
227  // pl evaluation
228 
229  dfcalc=theFmpConst->forwparam[0]+
230  charge*theFmpConst->forwparam[1]/abs(pl);
231  phnext=dfcalc+phi;
232  if(phnext>=twopi) phnext=phnext-twopi;
233  if(phnext <0.) phnext=twopi+phnext;
234 #ifdef PROPAGATOR_DB
235  cout<<"FastMuPropagator::Phi in Muon Chamb="<<phi<<endl;
236  cout<<"FastMuPropagator::Phnext determined="<<phnext<<" dfcalc="<<dfcalc<<endl;
237 #endif
238 
239  int iwin;
240  float awin,bwin,phbound;
242 
243  if(pt>40.) {
244  phbound=theFmpConst->phiwinf[7];
245  }else{ // r < bound
246  iwin=(int)(pt/theFmpConst->ptstep);
247  awin=(theFmpConst->phiwinf[iwin+1]-theFmpConst->phiwinf[iwin])
248  /(theFmpConst->ptwmax[iwin]-theFmpConst->ptwmin[iwin]);
249  bwin=theFmpConst->phiwinf[iwin]-awin*theFmpConst->ptwmin[iwin];
250  phbound=awin*pt+bwin;
251  }
252 #ifdef PROPAGATOR_DB
253  cout<<"Forward::Size of window in phi="<<phbound<<endl;
254 #endif
255  m(0,0)=abs(plmax-plmin)/6.; m(1,1)=phbound/theFmpConst->sigf;
256  m(2,2)=theFmpConst->zwin/theFmpConst->sigz;
257  m(3,3)=phbound/(2.*theFmpConst->sigf);m(4,4)=theFmpConst->zwin/(2.*theFmpConst->sigz);
258 
259  GlobalPoint aX(r*cos(phnext),r*sin(phnext),z);
260 
261  // Recalculate momentum with some trick...
262  double dfcalcmom=charge*theFmpConst->partrack*abs(z)/abs(pl);
263  GlobalVector aP(pt*cos(phnext-dfcalcmom),pt*sin(phnext-dfcalcmom),pl);
264 #ifdef PROPAGATOR_DB
265  cout<<"dfcalcmom="<<charge<<" "<<theFmpConst->partrack<<" "<<z<<" "<<pl<<" "<<phnext<<endl;
266  cout<<"phnextmom="<<phnext-dfcalcmom<<endl;
267 
268  cout<<"Plane aP="<<aP<<endl;
269  cout<<"Before propagation="<<pt*cos(phi)<< " "<<pt*sin(phi)<<" "<<pl<<endl;
270 #endif
271 
272  GlobalTrajectoryParameters gtp(aX,aP,charge,field);
274 
275  TrajectoryStateOnSurface tsos(gtp, CurvilinearTrajectoryError(m), boundplane);
276  return tsos;
277  }
278 
279  return badtsos;
280 }
281  bool
282  FastMuPropagator::checkfts(const FreeTrajectoryState& fts) const {
283  bool check=true;
284  double z=fts.parameters().position().z();
285  double r=fts.parameters().position().perp();
286  float mubarrelrad=theFmpConst->mubarrelrad;
287  float muforwardrad=theFmpConst->muforwardrad;
288  float muoffset=theFmpConst->muoffset;
289  mubarrelrad=350.; muforwardrad=400.;
290 #ifdef PROPAGATOR_DB
291  cout<<"checkfts::r,z="<<r<<" "<<z<<" "<<check<<endl;
292 #endif
293  if(r<mubarrelrad-muoffset&&abs(z)<muforwardrad-muoffset){
294  check=false;
295 #ifdef PROPAGATOR_DB
296  cout<<"checkfts::false="<<check<<endl;
297 #endif
298  }
299  return check;
300 }
301 }
T perp() const
Definition: PV3DBase.h:66
const GlobalTrajectoryParameters & parameters() const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
#define abs(x)
Definition: mlp_lapack.h:159
Geom::Theta< T > theta() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
double charge(const std::vector< uint8_t > &Ampls)
const CurvilinearTrajectoryError & curvilinearError() const
Definition: Plane.h:17
Geom::Theta< T > theta() const
Definition: PV3DBase.h:69
int TrackCharge
Definition: TrackCharge.h:4
Definition: DDAxes.h:10
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:55
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
T z() const
Definition: PV3DBase.h:58
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double ptmin
Definition: HydjetWrapper.h:86
const AlgebraicSymMatrix55 & matrix() const
tuple cout
Definition: gather_cfg.py:41
double pi
const PositionType & position() const
Definition: DDAxes.h:10