CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoHI/HiMuonAlgos/src/HICMuonPropagator.cc

Go to the documentation of this file.
00001 #include "RecoHI/HiMuonAlgos/interface/HICMuonPropagator.h"
00002 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00003 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00004 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
00005 #include "DataFormats/GeometrySurface/interface/Surface.h"
00006 #include "DataFormats/GeometrySurface/interface/Plane.h"
00007  
00008 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00009 #include "CLHEP/Vector/ThreeVector.h"
00010 #include <CLHEP/Vector/LorentzVector.h>
00011 #include <cmath>
00012 #include <stdlib.h>
00013 #include <string>
00014 #include <iostream>
00015 #include <vector>
00016 //#define MUPROPAGATOR_DEBUG
00017 namespace cms {
00018 TrajectoryStateOnSurface
00019              HICMuonPropagator::propagate(const FreeTrajectoryState& fts,
00020                                           const Cylinder& surface) const
00021   {
00022 #ifdef MUPROPAGATOR_DEBUG
00023     cout<<"MuPropagator::Start propagation"<<endl;
00024 #endif
00025 // From FreeTrajectoryState to the vertex.
00026 
00027   GlobalPoint x = fts.parameters().position();
00028   GlobalVector p = fts.parameters().momentum();
00029   double px = p.x(); double py = p.y(); double pz = p.z();
00030   double aCharge = fts.charge();
00031   AlgebraicSymMatrix55 e = fts.curvilinearError().matrix();
00032   double dfcalc,phnext,zdet;
00033 //  double pt = p.perp();
00034   double a = p.perp()/pz;
00035 
00036   double b = -a*theHICConst->zvert; 
00037  
00038   double phiold=x.phi();
00039   if(x.phi()<0.) phiold=twopi+x.phi();
00040     
00041 #ifdef MUPROPAGATOR_DEBUG  
00042   cout<< "MuPropagator::xold=" << x<<" p="<<p<<endl;
00043   cout<<"MuPropagator::Propagate to cylinder="<<surface.radius()<<" pt="<<pt<<
00044   " line parameters="<<a<<" "<<b<<endl;
00045 #endif 
00046  
00047 // Propagate on surface:phidet
00048 
00049   dfcalc = aCharge*0.006*fabs(x.perp()-surface.radius())/p.perp();
00050   phnext = phiold+dfcalc;
00051 
00052   if(phnext>twopi) phnext = phnext-twopi;
00053   if(phnext<0.) phnext = phnext+twopi;
00054   
00055 // Propagate Zdet
00056 
00057   zdet = (surface.radius()-b)/a;
00058   
00059 // New state
00060   GlobalPoint xnew(surface.radius()*cos(phnext),surface.radius()*sin(phnext),zdet);
00061   GlobalVector pnew(px*cos(dfcalc)-py*sin(dfcalc),px*sin(dfcalc)+py*cos(dfcalc),pz);
00062 #ifdef MUPROPAGATOR_DEBUG
00063   cout<< "almost empty propagator for the moment phnext,zdet="<<phnext<<" "<<zdet<<endl;
00064   cout<<"New coordinates="<<xnew<<endl;
00065   cout<<"New momentum="<<pnew<<endl;
00066 #endif  
00067 
00068   TrajectoryStateOnSurface tsos(
00069                                  GlobalTrajectoryParameters(xnew, pnew, (int)aCharge, field),
00070                                  CurvilinearTrajectoryError(e), surface
00071                                  );
00072      return tsos;
00073   }
00074 
00075 TrajectoryStateOnSurface
00076              HICMuonPropagator::propagate(const FreeTrajectoryState& fts,
00077                                           const Plane& surface) const
00078   {
00079 
00080 
00081 //
00082 //  Check if it is detector or layer 
00083 //  if(surface.position().perp()>0.000001) {
00084 //  HICTrajectoryCorrector* theNewPropagator = new HICTrajectoryCorrector();
00085 //  TrajectoryStateOnSurface tsos = theCorrector->propagate(fts,surface);
00086 //  delete theNewPropagator;
00087 //  return tsos;
00088 //  } else {
00089 //  Check if it is forward pixel detector
00090 // if(abs(surface.position().z())>0. && abs(surface.position().z())<50.) {
00091 //  GtfPropagator* theNewPropagator = new GtfPropagator(oppositeToMomentum);
00092 //  TrajectoryStateOnSurface tsos = theCorrector->propagate(fts,surface);
00093 //  delete theNewPropagator;
00094 //  return tsos;
00095 // }
00096 // }
00097 //
00098   double dfcalc,phnext,rdet;
00099   
00100 #ifdef MUPROPAGATOR_DEBUG
00101     cout<<"MuPropagator::Start propagation"<<endl;
00102 #endif
00103 // Information from previous layer
00104 //
00105   GlobalPoint x = fts.parameters().position();
00106   GlobalVector p = fts.parameters().momentum();
00107   double px = p.x(); double py = p.y(); double pz = p.z();
00108   double aCharge = fts.charge();
00109   AlgebraicSymMatrix55 e = fts.curvilinearError().matrix();
00110   double phiold=x.phi();
00111   if(x.phi()<0.) phiold=twopi+x.phi();
00112 
00113 #ifdef MUPROPAGATOR_DEBUG  
00114   cout<< "MuPropagator::xold=" << x<<" p= "<<p<<endl;
00115 #endif  
00116 
00117     double a = p.perp()/pz;
00118     double b = x.perp()-a*x.z();
00119     
00120 #ifdef MUPROPAGATOR_DEBUG  
00121   cout<<"MuPropagator::Propagate to disk="<<surface.position().z()<<" pz="<<pz<<
00122   " line parameters="<<a<<" "<<b<<endl;
00123 #endif 
00124  
00125 // Propagate on surface:phidet
00126 //
00127   dfcalc = aCharge*0.006*fabs(x.z()-surface.position().z())/fabs(pz);
00128   phnext = phiold+dfcalc;
00129   
00130   if(phnext>twopi) phnext = phnext-twopi;
00131   if(phnext<0.) phnext = phnext+twopi;
00132   
00133 // Propagate Zdet
00134 //
00135   rdet = a*surface.position().z()-b;
00136   
00137 // New state
00138   GlobalPoint xnew(rdet*cos(phnext),rdet*sin(phnext),surface.position().z());
00139   GlobalVector pnew(px*cos(dfcalc)-py*sin(dfcalc),px*sin(dfcalc)+py*cos(dfcalc),pz);
00140   
00141 #ifdef MUPROPAGATOR_DEBUG
00142   cout<< "MuPropagator::phiold,phnext,zdet,charge,dfcalc="
00143   <<phiold<<" "<<phnext<<" "<<
00144   surface.position().z()<<" "<<aCharge<<" "<<dfcalc<<endl;
00145   cout<<"New coordinates="<<xnew<<endl;
00146   cout<<"New momentum="<<pnew<<endl;
00147 #endif  
00148 
00149   TrajectoryStateOnSurface tsos(
00150                                  GlobalTrajectoryParameters(xnew, pnew, (int)aCharge, field),
00151                                  CurvilinearTrajectoryError(e),
00152                                  surface);
00153      return tsos;
00154   }
00155 
00156 }