CMS 3D CMS Logo

MuonOverlapSeedFromRecHits.cc

Go to the documentation of this file.
00001 #include "RecoMuon/MuonSeedGenerator/src/MuonOverlapSeedFromRecHits.h"
00002 #include "RecoMuon/MuonSeedGenerator/src/MuonSeedPtExtractor.h"
00003 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00004 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
00005 #include "Geometry/CSCGeometry/interface/CSCChamberSpecs.h"
00006 #include "RecoMuon/TrackingTools/interface/MuonPatternRecoDumper.h"
00007 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00008 #include "DataFormats/TrajectoryState/interface/PTrajectoryStateOnDet.h"
00009 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "Geometry/CSCGeometry/interface/CSCChamberSpecs.h"
00012 #include <iomanip>
00013 
00014 
00015 MuonOverlapSeedFromRecHits::MuonOverlapSeedFromRecHits()
00016 : MuonSeedFromRecHits()
00017 {
00018   //FIXME make configurable
00019   // parameters for the fit of dphi between chambers vs. eta
00020   // pt = (c1 + c2 abs(eta))/ dphi
00021   fillConstants(1,4, 1.14, -0.883);
00022   fillConstants(1,6, 0.782, -0.509);
00023   fillConstants(1,8, 0.2823, -0.0706);
00024   fillConstants(2,4, 0.3649, -0.2865);
00025   fillConstants(2,6, 0.3703, -0.3507);
00026 
00027 }
00028 
00029 
00030 void MuonOverlapSeedFromRecHits::fillConstants(int dtStation, int cscChamberType, double c1, double c2)
00031 {
00032   theConstantsMap[std::make_pair(dtStation,cscChamberType)] = std::make_pair(c1, c2);
00033 }
00034 
00035 
00036 std::vector<TrajectorySeed> MuonOverlapSeedFromRecHits::seeds() const
00037 {
00038   std::vector<TrajectorySeed> result;
00039   //@@ doesn't handle overlap between ME11 and ME12 correctly
00040   // sort by station
00041   MuonRecHitContainer barrelHits, endcapHits;
00042   for ( MuonRecHitContainer::const_iterator iter = theRhits.begin(), end = theRhits.end();
00043         iter != end; ++iter)
00044   {
00045     if((*iter)->isDT())
00046     {
00047       barrelHits.push_back(*iter);
00048     }
00049     else
00050     {
00051       endcapHits.push_back(*iter);
00052     }
00053   }
00054 
00055   for ( MuonRecHitContainer::const_iterator barrelHitItr = barrelHits.begin(),
00056         lastBarrelHit = barrelHits.end();
00057         barrelHitItr != lastBarrelHit; ++barrelHitItr)
00058   {
00059     for ( MuonRecHitContainer::const_iterator endcapHitItr = endcapHits.begin(),
00060       lastEndcapHit = endcapHits.end();
00061       endcapHitItr != lastEndcapHit; ++endcapHitItr)
00062     {
00063       TrajectorySeed seed;
00064       bool good = makeSeed2(*barrelHitItr, *endcapHitItr, seed);
00065       if(good) result.push_back(seed);
00066       // try just one seed
00067       return result;
00068     }
00069   }
00070 
00071   //std::cout << "Overlap hits " << barrelHits.size() << " " 
00072   //                             << endcapHits.size() << std::endl;
00073 
00074   return result;
00075 }
00076 
00077 
00078 bool
00079 MuonOverlapSeedFromRecHits::makeSeed(MuonTransientTrackingRecHit::ConstMuonRecHitPointer barrelHit,
00080                                      MuonTransientTrackingRecHit::ConstMuonRecHitPointer endcapHit,
00081                                      TrajectorySeed & result) const
00082 {
00083   DTChamberId dtId(barrelHit->geographicalId().rawId());
00084   int dtStation = dtId.station();
00085 
00086 
00087   CSCDetId cscId(endcapHit->geographicalId().rawId());
00088   int cscChamberType = CSCChamberSpecs::whatChamberType(cscId.station(), cscId.ring());
00089   //std::cout << " CSC " << cscChamberType << std::endl;
00090 
00091 
00092 
00093   // find the parametrization constants
00094   std::pair<int, int> key(dtStation, cscChamberType);
00095   ConstantsMap::const_iterator mapItr = theConstantsMap.find(key);
00096   if(mapItr != theConstantsMap.end())
00097   {
00098 
00099     double dphi = (*barrelHit).globalPosition().phi() - (*endcapHit).globalPosition().phi();
00100 
00101     if(dphi > M_PI) dphi -= 2*M_PI;
00102     if(dphi < -M_PI) dphi += 2*M_PI;
00103     double eta = (*barrelHit).globalPosition().eta();
00104 
00105     double c1 = mapItr->second.first;
00106     double c2 = mapItr->second.second;
00107     // the parametrization
00108     double pt = (c1 + c2 * fabs(eta) ) / dphi;
00109     double minpt = 3.;
00110     float sigmapt = 25.;
00111     // if too small, probably an error.  Keep trying.
00112     if(fabs(pt) > minpt)
00113     {
00114       double maxpt = 2000.;
00115       if(pt > maxpt) {
00116         pt = maxpt;
00117         sigmapt = maxpt;
00118       }
00119       if(pt < -maxpt) {
00120         pt = -maxpt;
00121         sigmapt = maxpt;
00122       }
00123     }
00124 
00125     // use the endcap hit, since segments at the edge of the barrel
00126     // might just be 2D
00127     result = createSeed(pt, sigmapt, endcapHit);
00128     //std::cout << "OVERLAPFITTED PT " << pt << " dphi " << dphi << " eta " << eta << std::endl;
00129     return true;
00130   }
00131   return false;
00132 }
00133 
00134 
00135 bool
00136 MuonOverlapSeedFromRecHits::makeSeed2(MuonTransientTrackingRecHit::ConstMuonRecHitPointer barrelHit,
00137                                      MuonTransientTrackingRecHit::ConstMuonRecHitPointer endcapHit,
00138                                      TrajectorySeed & result) const
00139 {
00140   std::vector<double> pts = thePtExtractor->pT_extract(barrelHit, endcapHit);
00141   double minpt = 3.;
00142   double pt = pts[0];
00143   double sigmapt = pts[1];
00144     // if too small, probably an error.  Keep trying.
00145   if(pt != 0) {
00146     if(fabs(pt) > minpt)
00147     {
00148       double maxpt = 2000.;
00149       if(pt > maxpt) {
00150         pt = maxpt;
00151         sigmapt = maxpt;
00152       }
00153       if(pt < -maxpt) {
00154         pt = -maxpt;
00155         sigmapt = maxpt;
00156       }
00157     }
00158 
00159     // use the endcap hit, since segments at the edge of the barrel
00160     // might just be 2D
00161     result = createSeed(pt, sigmapt, endcapHit);
00162     //std::cout << "OVERLAPFITTED PT " << pt << " dphi " << dphi << " eta " << eta << std::endl;
00163     return true;
00164   }
00165   return false;
00166 }
00167 

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