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