CMS 3D CMS Logo

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