CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/RecoHI/HiMuonAlgos/src/FastMuPropagator.cc

Go to the documentation of this file.
00001 #include "RecoHI/HiMuonAlgos/interface/FastMuPropagator.h"
00002 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00003 #include "CLHEP/Vector/ThreeVector.h"
00004 #include <CLHEP/Vector/LorentzVector.h>
00005 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00006 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00007 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
00008 #include "DataFormats/GeometrySurface/interface/Surface.h"
00009 #include "DataFormats/GeometrySurface/interface/Plane.h"
00010 
00011 #include <cmath>
00012 #include <stdlib.h>
00013 #include <string>
00014 #include <iostream>
00015 #include <vector>
00016 
00017 //#define PROPAGATOR_DB
00018 
00019 using namespace std;
00020 namespace cms {
00021 TrajectoryStateOnSurface
00022              FastMuPropagator::propagate(const FreeTrajectoryState& fts,
00023                                          const Cylinder& boundcyl) const
00024 {
00025   TrajectoryStateOnSurface badtsos;
00026 
00027   if(!checkfts(fts)) return badtsos;
00028 
00029 #ifdef PROPAGATOR_DB 
00030   cout<<"FastMuPropagator::propagate::Start propagation in barrel::zvert "<<theFmpConst->zvert<<endl;
00031 #endif    
00032 
00033   // Extract information from muchambers
00034 
00035   int charge;
00036   int imin0,imax0;
00037   double ptmax,ptmin,pt,phi,theta,theta0,z,pl;
00038   double dfcalc,phnext,bound;
00039   float ptboun=theFmpConst->ptboun;
00040   float step=theFmpConst->step;
00041   
00042   GlobalVector moment=fts.parameters().momentum();
00043   GlobalPoint posit=fts.parameters().position();
00044   pt=moment.perp();
00045   theta0=moment.theta();
00046 // Correct theta
00047           double zfts=fts.parameters().position().z()-theFmpConst->zvert;
00048           double rfts=fts.parameters().position().perp();
00049   theta = atan2(rfts,zfts);
00050 
00051 #ifdef PROPAGATOR_DB
00052   cout<<"FastMuPropagator::propagate::Start propagation in barrel::theta old, new "<<theta0<<" "<<theta<<endl;
00053 #endif
00054 
00055   phi=posit.phi();
00056   ptmax=pt+fts.curvilinearError().matrix()(1,1);
00057   ptmin=pt-fts.curvilinearError().matrix()(1,1);
00058   bound=boundcyl.radius();
00059   charge=fts.parameters().charge();
00060 
00061   imax0=(int)((ptmax-ptboun)/step)+1;
00062   imin0=(int)((ptmin-ptboun)/step)+1;
00063 #ifdef PROPAGATOR_DB     
00064   cout<<"FastMuPropagator::Look ptboun,step,imin0,imax0="<<ptboun<<" "<<step<<
00065     " "<<imin0<<" "<<imax0<<endl;
00066   cout<<"FastMuPropagator::Parameters (pt,theta,phi,ptmax,ptmin,bound)="<<pt<<" "
00067       <<theta<<" "<<phi<<" "<<ptmax<<" "<<ptmin<<" "<<bound<<endl;       
00068 #endif   
00069   if(imax0 > 1){
00070     if(imin0<1) imin0=1;
00071     // ========================== phi ========================================    
00072     // new parametrisation (because of second mu-station)
00073     //
00074 
00075 #ifdef PROPAGATOR_DB
00076     cout<<"FastMuPropagator::New parameters="<<theFmpConst->newparam[0]<<endl;
00077     cout<<"FastMuPropagator::New parameters for pt>40="<<
00078            theFmpConst->newparamgt40[0]<<endl;
00079 #endif
00080 
00081     if(pt<40.) {
00082       dfcalc=charge/(theFmpConst->newparam[0]+theFmpConst->newparam[1]*pt
00083              +theFmpConst->newparam[2]*pt*pt);       
00084     }else{
00085       dfcalc=charge/(theFmpConst->newparamgt40[0]+
00086       theFmpConst->newparamgt40[1]*pt+theFmpConst->newparamgt40[2]*pt*pt);
00087     }
00088 //
00089 // !!!! temporarily decision till new parametrization appears.
00090 //    
00091     if (abs(dfcalc) > 0.6 ) dfcalc = charge*0.6;
00092     
00093     phnext=dfcalc+phi;
00094     if(phnext>=twopi) phnext=phnext-twopi;
00095     if(phnext <0.) phnext=twopi+phnext;
00096 #ifdef PROPAGATOR_DB    
00097     cout<<"FastMuPropagator::Phi in Muon Chamb="<<phi<<endl;
00098     cout<<"FastMuPropagator::Phnext determined="<<phnext<<" dfcalc="<<dfcalc<<endl;
00099 #endif    
00100     // ==========================  Z  ========================================    
00101     if(abs(theta-pi/2.)>0.00001){
00102       z=bound/tan(theta)+theFmpConst->zvert;
00103       if(fabs(z)>140) {
00104 // Temporary implementation =====      
00105 //         if(z>0.) z = z-45.;
00106 //       if(z<0.) z = z+45.;
00107 // ==============================        
00108       }
00109     }else{
00110       z=0.;
00111     }
00112 #ifdef PROPAGATOR_DB    
00113     cout<<"FastMuPropgator::Z coordinate="<<z<<"bound="<<bound<<"theta="<<theta<<" "<<
00114       abs(theta-pi/2.)<<endl;
00115 #endif
00116     // ====================== fill global point/vector =======================    
00117     GlobalPoint aX(bound*cos(phnext),bound*sin(phnext),z);
00118     if(abs(theta-pi/2.)<0.00001){
00119       pl=0.;
00120     }else{
00121       pl=pt/tan(theta);
00122     }
00123     // Recalculate momentum with some trick...
00124     double dfcalcmom=charge*theFmpConst->partrack*bound/pt;    
00125     GlobalVector aP(pt*cos(phnext-dfcalcmom),pt*sin(phnext-dfcalcmom),pl);
00126      
00127 #ifdef PROPAGATOR_DB
00128     cout<<"phnextmom="<<phnext-dfcalcmom<<endl;
00129     cout<<"Cylinder aP="<<aP<<endl;
00130     cout<<"Before propagation="<<pt*cos(phi)<< " "<<pt*sin(phi)<<" "<<pl<<endl;
00131 #endif       
00132     // =======================================================================    
00133     
00134     GlobalTrajectoryParameters gtp(aX,aP,charge,field);
00135     AlgebraicSymMatrix55 m;
00136     int iwin;
00137     float awin,bwin,phbound;
00138     
00139     if(pt>40.) {
00140       iwin=8;
00141       phbound=theFmpConst->phiwinb[7];
00142     }else{
00143       iwin=(int)(pt/theFmpConst->ptstep);
00144       awin=(theFmpConst->phiwinb[iwin+1]-theFmpConst->phiwinb[iwin])
00145                /(theFmpConst->ptwmax[iwin]-theFmpConst->ptwmin[iwin]);
00146       bwin=theFmpConst->phiwinb[iwin]-awin*theFmpConst->ptwmin[iwin];
00147       phbound=awin*pt+bwin;
00148 
00149     }
00150 #ifdef PROPAGATOR_DB
00151     cout<<"Size of window in phi="<<phbound<<" "<<iwin<<endl;
00152     cout<<theFmpConst->phiwinb[iwin+1]<<" "<<theFmpConst->phiwinb[iwin]
00153             <<" "<<theFmpConst->ptwmin[iwin]<<
00154       " "<<theFmpConst->ptwmax[iwin]<<" awin="<<awin<<" bwin="<<bwin<<endl;
00155 #endif    
00156     m(0,0)=(ptmax-ptmin)/6.; m(1,1)=phbound/theFmpConst->sigf;
00157          m(2,2)=theFmpConst->zwin/theFmpConst->sigz;
00158     m(3,3)=phbound/(2.*theFmpConst->sigf);m(4,4)=theFmpConst->zwin/(2.*theFmpConst->sigz); 
00159     
00160     CurvilinearTrajectoryError cte(m);
00161 
00162     FreeTrajectoryState fts(gtp,cte);
00163     TrajectoryStateOnSurface tsos(gtp, CurvilinearTrajectoryError(m), boundcyl);
00164     return tsos;                           
00165     
00166   }
00167   return badtsos;
00168 }
00169 
00170 
00171 TrajectoryStateOnSurface
00172              FastMuPropagator::propagate(const FreeTrajectoryState& fts,
00173                                      const Plane& boundplane) const
00174                                      
00175 {
00176   TrajectoryStateOnSurface badtsos;
00177 
00178 #ifdef PROPAGATOR_DB 
00179   cout<<"FastMuPropagator::propagate::Start propagation in forward::zvert "<<theFmpConst->zvert<<endl;
00180 #endif    
00181   if(!checkfts(fts)) return badtsos;
00182    
00183   // Extract information from muchambers
00184 
00185   int imin0,imax0;
00186   double ptmax,ptmin,pt,phi,theta,theta0,z,r,pl,plmin,plmax;
00187   double dfcalc,phnext;
00188   TrackCharge charge;
00189   float ptboun=theFmpConst->ptboun;
00190   float step=theFmpConst->step;
00191 
00192   
00193   GlobalVector moment=fts.parameters().momentum();
00194   GlobalPoint posit=fts.parameters().position();
00195   pt=moment.perp();
00196   theta0=moment.theta();
00197 // Correct theta
00198           double zfts=fts.parameters().position().z()-theFmpConst->zvert;
00199           double rfts=fts.parameters().position().perp();
00200   theta = atan2(rfts,zfts);
00201 
00202 #ifdef PROPAGATOR_DB
00203   cout<<"FastMuPropagator::propagate::Start propagation in forward::theta old, new "<<theta0<<" "<<theta<<endl;
00204 #endif
00205 
00206   phi=posit.phi();
00207   ptmax=pt+fts.curvilinearError().matrix()(1,1);
00208   ptmin=pt-fts.curvilinearError().matrix()(1,1);
00209   pl=pt/tan(theta);
00210   plmin=ptmin/tan(theta);
00211   plmax=ptmax/tan(theta);
00212   imax0=(int)((ptmax-ptboun)/step)+1;
00213   imin0=(int)((ptmin-ptboun)/step)+1;
00214 #ifdef PROPAGATOR_DB     
00215   cout<<"FastMuPropagator::Look ptboun,step,imin0,imax0="<<ptboun<<" "<<step<<
00216     " "<<imin0<<" "<<imax0<<endl;
00217   cout<<"FastMuPropagator::Parameters (pt,theta,phi,ptmax,ptmin)="<<pt<<" "
00218       <<theta<<" "<<phi<<" "<<ptmax<<" "<<ptmin<<endl;   
00219 #endif   
00220   if(imax0 > 1){
00221     if(imin0<1) imin0=1;
00222   
00223     z=boundplane.position().z();
00224     r=(z-theFmpConst->zvert)*tan(theta);
00225     charge=fts.parameters().charge();
00226 
00227     // pl evaluation  
00228   
00229     dfcalc=theFmpConst->forwparam[0]+
00230                    charge*theFmpConst->forwparam[1]/abs(pl);  
00231     phnext=dfcalc+phi;
00232     if(phnext>=twopi) phnext=phnext-twopi;
00233     if(phnext <0.) phnext=twopi+phnext;
00234 #ifdef PROPAGATOR_DB    
00235     cout<<"FastMuPropagator::Phi in Muon Chamb="<<phi<<endl;
00236     cout<<"FastMuPropagator::Phnext determined="<<phnext<<" dfcalc="<<dfcalc<<endl;
00237 #endif    
00238 
00239     int iwin;
00240     float awin,bwin,phbound;
00241     AlgebraicSymMatrix55 m;
00242       
00243     if(pt>40.) {
00244       phbound=theFmpConst->phiwinf[7];
00245     }else{ // r < bound
00246       iwin=(int)(pt/theFmpConst->ptstep);
00247       awin=(theFmpConst->phiwinf[iwin+1]-theFmpConst->phiwinf[iwin])
00248              /(theFmpConst->ptwmax[iwin]-theFmpConst->ptwmin[iwin]);
00249       bwin=theFmpConst->phiwinf[iwin]-awin*theFmpConst->ptwmin[iwin];
00250       phbound=awin*pt+bwin;
00251     }
00252 #ifdef PROPAGATOR_DB
00253     cout<<"Forward::Size of window in phi="<<phbound<<endl;
00254 #endif    
00255     m(0,0)=abs(plmax-plmin)/6.; m(1,1)=phbound/theFmpConst->sigf;
00256           m(2,2)=theFmpConst->zwin/theFmpConst->sigz;
00257     m(3,3)=phbound/(2.*theFmpConst->sigf);m(4,4)=theFmpConst->zwin/(2.*theFmpConst->sigz); 
00258     
00259     GlobalPoint aX(r*cos(phnext),r*sin(phnext),z);
00260     
00261     // Recalculate momentum with some trick...    
00262     double dfcalcmom=charge*theFmpConst->partrack*abs(z)/abs(pl);
00263     GlobalVector aP(pt*cos(phnext-dfcalcmom),pt*sin(phnext-dfcalcmom),pl); 
00264 #ifdef PROPAGATOR_DB
00265     cout<<"dfcalcmom="<<charge<<" "<<theFmpConst->partrack<<" "<<z<<" "<<pl<<" "<<phnext<<endl;
00266     cout<<"phnextmom="<<phnext-dfcalcmom<<endl;
00267 
00268     cout<<"Plane aP="<<aP<<endl;
00269     cout<<"Before propagation="<<pt*cos(phi)<< " "<<pt*sin(phi)<<" "<<pl<<endl;
00270 #endif       
00271        
00272     GlobalTrajectoryParameters gtp(aX,aP,charge,field);
00273     CurvilinearTrajectoryError cte(m);
00274    
00275     TrajectoryStateOnSurface tsos(gtp, CurvilinearTrajectoryError(m), boundplane);
00276     return tsos;                                                   
00277   }
00278     
00279   return badtsos;
00280 }
00281   bool
00282          FastMuPropagator::checkfts(const FreeTrajectoryState& fts) const {
00283           bool check=true;
00284           double z=fts.parameters().position().z();
00285           double r=fts.parameters().position().perp();
00286           float mubarrelrad=theFmpConst->mubarrelrad;
00287           float muforwardrad=theFmpConst->muforwardrad;
00288           float muoffset=theFmpConst->muoffset;
00289           mubarrelrad=350.; muforwardrad=400.;
00290 #ifdef PROPAGATOR_DB
00291         cout<<"checkfts::r,z="<<r<<" "<<z<<" "<<check<<endl;
00292 #endif    
00293           if(r<mubarrelrad-muoffset&&abs(z)<muforwardrad-muoffset){
00294           check=false;
00295 #ifdef PROPAGATOR_DB
00296         cout<<"checkfts::false="<<check<<endl;
00297 #endif    
00298           }   
00299           return check;
00300 }
00301 }