CMS 3D CMS Logo

MuonTrackingRegionBuilder.cc

Go to the documentation of this file.
00001 
00013 #include "RecoMuon/GlobalTrackingTools/interface/MuonTrackingRegionBuilder.h"
00014 
00015 //---------------
00016 // C++ Headers --
00017 //---------------
00018 
00019 
00020 //-------------------------------
00021 // Collaborating Class Headers --
00022 //-------------------------------
00023 
00024 #include "FWCore/Framework/interface/Event.h"
00025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00026 #include "DataFormats/Common/interface/Handle.h"
00027 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
00028 #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h"
00029 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00030 #include "TrackingTools/PatternTools/interface/TSCPBuilderNoMaterial.h"
00031 #include "DataFormats/VertexReco/interface/Vertex.h"
00032 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00033 
00034 using namespace std;
00035 
00036 //
00037 // constructor
00038 //
00039 MuonTrackingRegionBuilder::MuonTrackingRegionBuilder(const edm::ParameterSet& par, 
00040                                                      const MuonServiceProxy* service) :
00041  theService(service) {
00042 
00043   // vertex Collection and Beam Spot
00044   theBeamSpotTag = par.getParameter<edm::InputTag>("beamSpot");
00045   theVertexCollTag = par.getParameter<edm::InputTag>("vertexCollection");
00046 
00047   // parmeters
00048   theNsigmaEta  = par.getParameter<double>("Rescale_eta");
00049   theNsigmaPhi  = par.getParameter<double>("Rescale_phi");
00050   theNsigmaDz   = par.getParameter<double>("Rescale_Dz");
00051   theTkEscapePt = par.getParameter<double>("EscapePt");
00052 
00053   // upper limits parameters   
00054   theEtaRegionPar1 = par.getParameter<double>("EtaR_UpperLimit_Par1"); 
00055   theEtaRegionPar2 = par.getParameter<double>("EtaR_UpperLimit_Par2");
00056   thePhiRegionPar1 = par.getParameter<double>("PhiR_UpperLimit_Par1");
00057   thePhiRegionPar2 = par.getParameter<double>("PhiR_UpperLimit_Par2");
00058 
00059   useVertex = par.getParameter<bool>("UseVertex");
00060   useFixedRegion = par.getParameter<bool>("UseFixedRegion");
00061 
00062   // fixed limits
00063   thePhiFixed = par.getParameter<double>("Phi_fixed");
00064   theEtaFixed = par.getParameter<double>("Eta_fixed");
00065 
00066   thePhiMin = par.getParameter<double>("Phi_min");
00067   theEtaMin = par.getParameter<double>("Eta_min");
00068   theHalfZ  = par.getParameter<double>("DeltaZ_Region");
00069   theDeltaR = par.getParameter<double>("DeltaR");
00070 
00071   // perigee reference point
00072   theVertexPos = GlobalPoint(0.0,0.0,0.0);
00073 
00074   theOnDemand = par.getParameter<double>("OnDemand");
00075 }
00076 
00077 
00078 //
00079 //
00080 //
00081 RectangularEtaPhiTrackingRegion* 
00082 MuonTrackingRegionBuilder::region(const reco::TrackRef& track) const {
00083 
00084   return region(*track);
00085 
00086 }
00087 
00088 
00089 //
00090 //
00091 //
00092 void MuonTrackingRegionBuilder::setEvent(const edm::Event& event) {
00093   
00094   theEvent = &event;
00095 
00096 }
00097 
00098 
00099 //
00100 //
00101 //
00102 RectangularEtaPhiTrackingRegion* 
00103 MuonTrackingRegionBuilder::region(const reco::Track& staTrack) const {
00104 
00105   // get the free trajectory state of the muon updated at vertex
00106   TSCPBuilderNoMaterial tscpBuilder; 
00107   TrajectoryStateTransform tsTransform;
00108   FreeTrajectoryState muFTS = tsTransform.initialFreeState(staTrack,&*theService->magneticField());
00109    
00110   // get track direction at vertex
00111   GlobalVector dirVector(muFTS.momentum());
00112 
00113   // get track momentum
00114   const math::XYZVector& mo = staTrack.innerMomentum();
00115   GlobalVector mom(mo.x(),mo.y(),mo.z());
00116   if ( staTrack.p() > 1.5 ) {
00117     mom = dirVector; 
00118   }
00119 
00120   // initial vertex position -  in the following it is replaced with beam spot/vertexing
00121   GlobalPoint vertexPos(0.0,0.0,0.0);
00122   double deltaZatVTX = 0.0;
00123 
00124   // retrieve beam spot information
00125   edm::Handle<reco::BeamSpot> bsHandle;
00126   bool bsHandleFlag = theEvent->getByLabel(theBeamSpotTag, bsHandle);
00127   // check the validity, otherwise vertexing
00128   if ( bsHandleFlag && !useVertex ) {
00129     const reco::BeamSpot& bs = *bsHandle;
00130     vertexPos = GlobalPoint(bs.x0(), bs.y0(), bs.z0());
00131   } else {
00132     // get originZPos from list of reconstructed vertices (first or all)
00133     edm::Handle<reco::VertexCollection> vertexCollection;
00134     bool vtxHandleFlag = theEvent->getByLabel(theVertexCollTag,vertexCollection);
00135     // check if there exists at least one reconstructed vertex
00136     if ( vtxHandleFlag && !vertexCollection->empty() ) {
00137       // use the first vertex in the collection and assume it is the primary event vertex 
00138       reco::VertexCollection::const_iterator vtx = vertexCollection->begin();
00139       vertexPos = GlobalPoint(0.0,0.0,vtx->z());
00140       // delta Z from vertex error
00141       deltaZatVTX = vtx->zError() * theNsigmaDz;
00142     }
00143   }
00144 
00145   TrajectoryStateClosestToPoint tscp = tscpBuilder(muFTS,theVertexPos);
00146   const PerigeeTrajectoryError& covar = tscp.perigeeError();
00147   const PerigeeTrajectoryParameters& param = tscp.perigeeParameters();
00148 
00149   // calculate deltaEta from deltaTheta
00150   double deltaTheta = covar.thetaError();
00151   double theta      = param.theta();
00152   double sin_theta  = sin(theta);
00153 
00154   // get dEta and dPhi
00155   double deta = theNsigmaEta*(1/fabs(sin_theta))*deltaTheta;
00156   double dphi = theNsigmaPhi*(covar.phiError());
00157 
00158   /* Region_Parametrizations to take into account possible 
00159      L2 error matrix inconsistencies. Detailed Explanation in TWIKI
00160      page.
00161   */
00162   double region_dEta = 0;
00163   double region_dPhi = 0;
00164   double eta,phi;
00165 
00166   // eta, pt parametrization from MC study
00167   float pt = abs(mom.perp());
00168   if ( pt <= 10. ) {
00169      // angular coefficients
00170      float acoeff_Phi = (thePhiRegionPar2 - thePhiRegionPar1)/5;
00171      float acoeff_Eta = (theEtaRegionPar2 - theEtaRegionPar1)/5;
00172 
00173      eta = theEtaRegionPar1 + (acoeff_Eta)*(mom.perp()-5.);
00174      phi = thePhiRegionPar1 + (acoeff_Phi)*(mom.perp()-5.) ;
00175    }
00176    // parametrization 2nd bin in pt from MC study  
00177    if ( pt > 10. && pt < 100. ) {
00178      eta = theEtaRegionPar2;
00179      phi = thePhiRegionPar2;
00180    }
00181    // parametrization 3rd bin in pt from MC study
00182    if ( pt >= 100. ) {
00183      // angular coefficients
00184      float acoeff_Phi = (thePhiRegionPar1 - thePhiRegionPar2)/900;
00185      float acoeff_Eta = (theEtaRegionPar1 - theEtaRegionPar2)/900;
00186 
00187      eta = theEtaRegionPar2 + (acoeff_Eta)*(mom.perp()-100.);
00188      phi = thePhiRegionPar2 + (acoeff_Phi)*(mom.perp()-100.);
00189    }
00190 
00191   // decide to use either a parametrization or a dynamical region
00192   double region_dPhi1 = min(phi,dphi);
00193   double region_dEta1 = min(eta,deta);
00194 
00195   // minimum size
00196   region_dPhi = max(thePhiMin,region_dPhi1);
00197   region_dEta = max(theEtaMin,region_dEta1);
00198 
00199   float deltaZ = 0.0;
00200   // standard 15.9 is useVertex than region from vertexing
00201   if ( useVertex ) {
00202     deltaZ = deltaZatVTX;
00203   } else { 
00204     deltaZ = theHalfZ;
00205   }
00206 
00207   float deltaR = theDeltaR;
00208   double minPt = max(theTkEscapePt,mom.perp()*0.6);
00209 
00210   RectangularEtaPhiTrackingRegion* region = 0;  
00211 
00212   if (useFixedRegion) {
00213      region_dEta = theEtaFixed;
00214      region_dPhi = thePhiFixed;
00215   }
00216 
00217   region = new RectangularEtaPhiTrackingRegion(dirVector, vertexPos,
00218                                                minPt, deltaR,
00219                                                deltaZ, region_dEta, region_dPhi,
00220                                                theOnDemand);
00221   
00222   return region;
00223   
00224 }

Generated on Tue Jun 9 17:44:16 2009 for CMSSW by  doxygen 1.5.4