![]() |
![]() |
#include <FastSimulation/Muons/plugins/FastTSGFromL2Muon.h>
Public Member Functions | |
virtual void | beginJob (const edm::EventSetup &es) |
FastTSGFromL2Muon (const edm::ParameterSet &cfg) | |
virtual void | produce (edm::Event &ev, const edm::EventSetup &es) |
virtual | ~FastTSGFromL2Muon () |
Private Member Functions | |
bool | clean (reco::TrackRef muRef, RectangularEtaPhiTrackingRegion *region, const BasicTrajectorySeed *aSeed, const SimTrack &theSimTrack) |
Private Attributes | |
edm::ParameterSet | theConfig |
edm::InputTag | theL2CollectionLabel |
double | thePtCut |
MuonTrackingRegionBuilder * | theRegionBuilder |
std::vector< edm::InputTag > | theSeedCollectionLabels |
MuonServiceProxy * | theService |
edm::InputTag | theSimTrackCollectionLabel |
Definition at line 22 of file FastTSGFromL2Muon.h.
FastTSGFromL2Muon::FastTSGFromL2Muon | ( | const edm::ParameterSet & | cfg | ) |
Definition at line 21 of file FastTSGFromL2Muon.cc.
References edm::ParameterSet::getParameter(), MuonServiceProxy_cff::MuonServiceProxy, theL2CollectionLabel, thePtCut, theSeedCollectionLabels, theService, and theSimTrackCollectionLabel.
00021 : theConfig(cfg) 00022 { 00023 produces<L3MuonTrajectorySeedCollection>(); 00024 00025 edm::ParameterSet serviceParameters = 00026 cfg.getParameter<edm::ParameterSet>("ServiceParameters"); 00027 theService = new MuonServiceProxy(serviceParameters); 00028 00029 thePtCut = cfg.getParameter<double>("PtCut"); 00030 00031 theL2CollectionLabel = cfg.getParameter<edm::InputTag>("MuonCollectionLabel"); 00032 theSeedCollectionLabels = cfg.getParameter<std::vector<edm::InputTag> >("SeedCollectionLabels"); 00033 theSimTrackCollectionLabel = cfg.getParameter<edm::InputTag>("SimTrackCollectionLabel"); 00034 // useTFileService_ = cfg.getUntrackedParameter<bool>("UseTFileService",false); 00035 00036 }
FastTSGFromL2Muon::~FastTSGFromL2Muon | ( | ) | [virtual] |
void FastTSGFromL2Muon::beginJob | ( | const edm::EventSetup & | es | ) | [virtual] |
Reimplemented from edm::EDProducer.
Definition at line 43 of file FastTSGFromL2Muon.cc.
References edm::ParameterSet::getParameter(), theConfig, theRegionBuilder, and theService.
00044 { 00045 //update muon proxy service 00046 theService->update(es); 00047 00048 //region builder 00049 edm::ParameterSet regionBuilderPSet = 00050 theConfig.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder"); 00051 theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet,theService); 00052 00053 /* 00054 if(useTFileService_) { 00055 edm::Service<TFileService> fs; 00056 h_nSeedPerTrack = fs->make<TH1F>("nSeedPerTrack","nSeedPerTrack",76,-0.5,75.5); 00057 h_nGoodSeedPerTrack = fs->make<TH1F>("nGoodSeedPerTrack","nGoodSeedPerTrack",75,-0.5,75.5); 00058 h_nGoodSeedPerEvent = fs->make<TH1F>("nGoodSeedPerEvent","nGoodSeedPerEvent",75,-0.5,75.5); 00059 } else { 00060 h_nSeedPerTrack = 0; 00061 h_nGoodSeedPerEvent = 0; 00062 h_nGoodSeedPerTrack = 0; 00063 } 00064 */ 00065 00066 }
bool FastTSGFromL2Muon::clean | ( | reco::TrackRef | muRef, | |
RectangularEtaPhiTrackingRegion * | region, | |||
const BasicTrajectorySeed * | aSeed, | |||
const SimTrack & | theSimTrack | |||
) | [private] |
Definition at line 180 of file FastTSGFromL2Muon.cc.
References deltaPhi(), TrackingRegionBase::direction(), RectangularEtaPhiTrackingRegion::etaRange(), PixelRecoRange< T >::max(), PixelRecoRange< T >::mean(), CoreSimTrack::momentum(), PV3DBase< T, PVType, FrameType >::phi(), RectangularEtaPhiTrackingRegion::phiMargin(), TrackingRegionBase::ptMin(), RegionalCKFTracksForL3Isolation_cfi::ptMin, TkTrackingRegionsMargin< T >::right(), and funct::sqrt().
Referenced by produce().
00183 { 00184 00185 // Eta cleaner 00186 const PixelRecoRange<float>& etaRange = region->etaRange() ; 00187 double etaSeed = theSimTrack.momentum().Eta(); 00188 double etaLimit = (fabs(fabs(etaRange.max())-fabs(etaRange.mean())) <0.05) ? 00189 0.05 : fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) ; 00190 bool inEtaRange = 00191 etaSeed >= (etaRange.mean() - etaLimit) && 00192 etaSeed <= (etaRange.mean() + etaLimit) ; 00193 if ( !inEtaRange ) return false; 00194 00195 // Phi cleaner 00196 const TkTrackingRegionsMargin<float>& phiMargin = region->phiMargin(); 00197 double phiSeed = theSimTrack.momentum().Phi(); 00198 double phiLimit = (phiMargin.right() < 0.05 ) ? 0.05 : phiMargin.right(); 00199 bool inPhiRange = 00200 (fabs(deltaPhi(phiSeed,double(region->direction().phi()))) < phiLimit ); 00201 if ( !inPhiRange ) return false; 00202 00203 // pt cleaner 00204 double ptSeed = std::sqrt(theSimTrack.momentum().Perp2()); 00205 double ptMin = (region->ptMin()>3.5) ? 3.5: region->ptMin(); 00206 bool inPtRange = ptSeed >= ptMin && ptSeed<= 2*(muRef->pt()); 00207 return inPtRange; 00208 00209 }
void FastTSGFromL2Muon::produce | ( | edm::Event & | ev, | |
const edm::EventSetup & | es | |||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 70 of file FastTSGFromL2Muon.cc.
References clean(), edm::Event::getByLabel(), edm::Event::put(), TrajectorySeed::recHits(), MuonTrackingRegionBuilder::region(), HLT_VtxMuL3::result, MuonTrackingRegionBuilder::setEvent(), SiTrackerGSMatchedRecHit2D::simtrackId(), simTrackId, theL2CollectionLabel, thePtCut, theRegionBuilder, theSeedCollectionLabels, theService, and theSimTrackCollectionLabel.
00071 { 00072 00073 // Initialize the output product 00074 std::auto_ptr<L3MuonTrajectorySeedCollection> result(new L3MuonTrajectorySeedCollection()); 00075 00076 //intialize service 00077 theService->update(es); 00078 00079 // Region builder 00080 theRegionBuilder->setEvent(ev); 00081 00082 // Retrieve the Monte Carlo truth (SimTracks) 00083 edm::Handle<edm::SimTrackContainer> theSimTracks; 00084 ev.getByLabel(theSimTrackCollectionLabel,theSimTracks); 00085 00086 // Retrieve L2 muon collection 00087 edm::Handle<reco::TrackCollection> l2muonH; 00088 ev.getByLabel(theL2CollectionLabel ,l2muonH); 00089 00090 // Retrieve Seed collection 00091 unsigned seedCollections = theSeedCollectionLabels.size(); 00092 std::vector<edm::Handle<edm::View<TrajectorySeed> > > theSeeds; 00093 theSeeds.resize(seedCollections); 00094 unsigned seed_size = 0; 00095 for ( unsigned iseed=0; iseed<seedCollections; ++iseed ) { 00096 ev.getByLabel(theSeedCollectionLabels[iseed], theSeeds[iseed]); 00097 seed_size += theSeeds[iseed]->size(); 00098 } 00099 00100 // Loop on L2 muons 00101 uint imu=0; 00102 uint imuMax=l2muonH->size(); 00103 // std::cout << "Found " << imuMax << " L2 muons" << std::endl; 00104 for (;imu!=imuMax;++imu){ 00105 00106 // Make a ref to l2 muon 00107 reco::TrackRef muRef(l2muonH, imu); 00108 00109 // Cut on muons with low momenta 00110 if ( muRef->pt() < thePtCut 00111 || muRef->innerMomentum().Rho() < thePtCut 00112 || muRef->innerMomentum().R() < 2.5 ) continue; 00113 00114 // Define the region of interest 00115 RectangularEtaPhiTrackingRegion * region = theRegionBuilder->region(muRef); 00116 00117 // Copy the collection of seeds (ahem, this is time consuming!) 00118 std::vector<TrajectorySeed> tkSeeds; 00119 std::set<unsigned> tkIds; 00120 tkSeeds.reserve(seed_size); 00121 for ( unsigned iseed=0; iseed<seedCollections; ++iseed ) { 00122 edm::Handle<edm::View<TrajectorySeed> > aSeedCollection = theSeeds[iseed]; 00123 unsigned nSeeds = aSeedCollection->size(); 00124 for (unsigned seednr = 0; seednr < nSeeds; ++seednr) { 00125 00126 // The seed 00127 const BasicTrajectorySeed* aSeed = &((*aSeedCollection)[seednr]); 00128 00129 // Find the first hit of the Seed 00130 TrajectorySeed::range theSeedingRecHitRange = aSeed->recHits(); 00131 const SiTrackerGSMatchedRecHit2D * theFirstSeedingRecHit = 00132 (const SiTrackerGSMatchedRecHit2D*) (&(*(theSeedingRecHitRange.first))); 00133 00134 // The SimTrack id associated to that recHit 00135 int simTrackId = theFirstSeedingRecHit->simtrackId(); 00136 00137 // Track already associated to a seed 00138 std::set<unsigned>::iterator tkId = tkIds.find(simTrackId); 00139 if( tkId != tkIds.end() ) continue; 00140 00141 const SimTrack& theSimTrack = (*theSimTracks)[simTrackId]; 00142 00143 if ( clean(muRef,region,aSeed,theSimTrack) ) tkSeeds.push_back(*aSeed); 00144 tkIds.insert(simTrackId); 00145 00146 } // End loop on seeds 00147 00148 } // End loop on seed collections 00149 00150 // Free memory 00151 delete region; 00152 00153 // A plot 00154 // if(h_nSeedPerTrack) h_nSeedPerTrack->Fill(tkSeeds.size()); 00155 00156 // Another plot 00157 // if(h_nGoodSeedPerTrack) h_nGoodSeedPerTrack->Fill(tkSeeds.size()); 00158 00159 00160 // Now create the Muon Trajectory Seed 00161 uint is=0; 00162 uint isMax=tkSeeds.size(); 00163 for (;is!=isMax;++is){ 00164 result->push_back( L3MuonTrajectorySeed(tkSeeds[is], muRef)); 00165 } // End of tk seed loop 00166 00167 } // End of l2 muon loop 00168 00169 // std::cout << "Found " << result->size() << " seeds for muons" << std::endl; 00170 00171 // And yet another plot 00172 // if(h_nGoodSeedPerEvent) h_nGoodSeedPerEvent->Fill(result->size()); 00173 00174 //put in the event 00175 ev.put(result); 00176 00177 }
Definition at line 42 of file FastTSGFromL2Muon.h.
Referenced by FastTSGFromL2Muon(), and produce().
double FastTSGFromL2Muon::thePtCut [private] |
Definition at line 48 of file FastTSGFromL2Muon.h.
Referenced by FastTSGFromL2Muon(), and produce().
std::vector<edm::InputTag> FastTSGFromL2Muon::theSeedCollectionLabels [private] |
Definition at line 43 of file FastTSGFromL2Muon.h.
Referenced by FastTSGFromL2Muon(), and produce().
MuonServiceProxy* FastTSGFromL2Muon::theService [private] |
Definition at line 47 of file FastTSGFromL2Muon.h.
Referenced by beginJob(), FastTSGFromL2Muon(), and produce().
Definition at line 41 of file FastTSGFromL2Muon.h.
Referenced by FastTSGFromL2Muon(), and produce().