From 196a42591731aedf04e2d44c9073dce95ab1d35e Mon Sep 17 00:00:00 2001 From: Dmytro Kovalskyi Date: Sun, 6 Sep 2009 16:39:12 +0000 Subject: [PATCH] --- yaml --- r: 73087 b: "refs/heads/CMSSW_7_1_X" c: 0b8bf86192fac12280a70d6069d1a33b405abe7c h: "refs/heads/CMSSW_7_1_X" i: 73085: 6f621445df986f53469bcd0c0aed349d9edb4e43 73083: c592305b19634b62f622f96ca198569fffd1ac97 73079: 6f0ed47396c38db6b210480b9c3754daba880d83 73071: da0c8798e6e8d27e68b1f586c68fbff907d62eaa 73055: 7a0867dcdd01780f8b0dce93cd41a642244bdd74 73023: ad3e3384891a2e73f1e6473983bc0c0681dc6751 72959: 5fb1bbf94c84b97364c2153e29d73fdc8671d9b5 v: v3 --- [refs] | 2 +- .../interface/PreshowerDetIdAssociator.h | 42 +++++++ .../interface/TrackDetectorAssociator.h | 7 +- .../TrackAssociator/plugins/modules.cc | 2 + .../python/DetIdAssociatorESProducer_cff.py | 7 ++ .../src/TrackDetectorAssociator.cc | 117 +++++++----------- .../test/TestTrackAssociator.cc | 64 +++++----- .../test/TestTrackAssociator.py | 86 +++++++++++++ 8 files changed, 224 insertions(+), 103 deletions(-) create mode 100644 trunk/TrackingTools/TrackAssociator/interface/PreshowerDetIdAssociator.h create mode 100755 trunk/TrackingTools/TrackAssociator/test/TestTrackAssociator.py diff --git a/[refs] b/[refs] index 016d403a4a6c1..e8ae59188d051 100644 --- a/[refs] +++ b/[refs] @@ -1,3 +1,3 @@ --- refs/heads/gh-pages: 09c786f70121f131b3715aaf3464996502bbeb7e -"refs/heads/CMSSW_7_1_X": 4d0e5a217f434e1160dcee1b31aa535b0e91a962 +"refs/heads/CMSSW_7_1_X": 0b8bf86192fac12280a70d6069d1a33b405abe7c diff --git a/trunk/TrackingTools/TrackAssociator/interface/PreshowerDetIdAssociator.h b/trunk/TrackingTools/TrackAssociator/interface/PreshowerDetIdAssociator.h new file mode 100644 index 0000000000000..92e7da85f3674 --- /dev/null +++ b/trunk/TrackingTools/TrackAssociator/interface/PreshowerDetIdAssociator.h @@ -0,0 +1,42 @@ +#ifndef TrackAssociator_PreshowerDetIdAssociator_h +#define TrackAssociator_PreshowerDetIdAssociator_h 1 +// -*- C++ -*- +// +// Package: TrackAssociator +// Class: PreshowerDetIdAssociator +// +/* + + Description: + + Implementation: + +*/ +// +// Original Author: Dmytro Kovalskyi +// $Id: PreshowerDetIdAssociator.h,v 1.1.2.1 2009/07/01 10:04:16 dmytro Exp $ +// +// + +#include "TrackingTools/TrackAssociator/interface/CaloDetIdAssociator.h" +#include "DataFormats/EcalDetId/interface/EcalSubdetector.h" + +class PreshowerDetIdAssociator: public CaloDetIdAssociator{ + public: + PreshowerDetIdAssociator():CaloDetIdAssociator(30,60,0.1){}; + + PreshowerDetIdAssociator(const edm::ParameterSet& pSet):CaloDetIdAssociator(pSet){}; + + protected: + + virtual std::set getASetOfValidDetIds() const { + std::set setOfValidIds; + std::vector vectOfValidIds = geometry_->getValidDetIds(DetId::Ecal, EcalPreshower); + for(std::vector::const_iterator it = vectOfValidIds.begin(); it != vectOfValidIds.end(); ++it) + setOfValidIds.insert(*it); + + return setOfValidIds; + }; + +}; +#endif diff --git a/trunk/TrackingTools/TrackAssociator/interface/TrackDetectorAssociator.h b/trunk/TrackingTools/TrackAssociator/interface/TrackDetectorAssociator.h index ccb8269ee39fe..f6bfb1d352b9e 100644 --- a/trunk/TrackingTools/TrackAssociator/interface/TrackDetectorAssociator.h +++ b/trunk/TrackingTools/TrackAssociator/interface/TrackDetectorAssociator.h @@ -14,7 +14,7 @@ // // Original Author: Dmytro Kovalskyi // Created: Fri Apr 21 10:59:41 PDT 2006 -// $Id: TrackDetectorAssociator.h,v 1.14 2008/08/07 02:06:23 dmytro Exp $ +// $Id: TrackDetectorAssociator.h,v 1.15.2.1 2009/07/01 10:04:16 dmytro Exp $ // // @@ -141,6 +141,10 @@ class TrackDetectorAssociator { TrackDetMatchInfo&, const AssociatorParameters&); + void fillPreshower( const edm::Event& iEvent, + TrackDetMatchInfo& info, + const AssociatorParameters&); + void fillMuon( const edm::Event&, TrackDetMatchInfo&, const AssociatorParameters&); @@ -188,6 +192,7 @@ class TrackDetectorAssociator { edm::ESHandle hoDetIdAssociator_; edm::ESHandle caloDetIdAssociator_; edm::ESHandle muonDetIdAssociator_; + edm::ESHandle preshowerDetIdAssociator_; edm::ESHandle theCaloGeometry_; edm::ESHandle theTrackingGeometry_; diff --git a/trunk/TrackingTools/TrackAssociator/plugins/modules.cc b/trunk/TrackingTools/TrackAssociator/plugins/modules.cc index bedcf29655710..a1f036ca754ad 100644 --- a/trunk/TrackingTools/TrackAssociator/plugins/modules.cc +++ b/trunk/TrackingTools/TrackAssociator/plugins/modules.cc @@ -8,9 +8,11 @@ DEFINE_SEAL_MODULE(); #include "TrackingTools/TrackAssociator/interface/HODetIdAssociator.h" #include "TrackingTools/TrackAssociator/interface/CaloDetIdAssociator.h" #include "TrackingTools/TrackAssociator/interface/MuonDetIdAssociator.h" +#include "TrackingTools/TrackAssociator/interface/PreshowerDetIdAssociator.h" DEFINE_EDM_PLUGIN(DetIdAssociatorFactory, EcalDetIdAssociator, "EcalDetIdAssociator"); DEFINE_EDM_PLUGIN(DetIdAssociatorFactory, HcalDetIdAssociator, "HcalDetIdAssociator"); DEFINE_EDM_PLUGIN(DetIdAssociatorFactory, HODetIdAssociator, "HODetIdAssociator"); DEFINE_EDM_PLUGIN(DetIdAssociatorFactory, CaloDetIdAssociator, "CaloDetIdAssociator"); DEFINE_EDM_PLUGIN(DetIdAssociatorFactory, MuonDetIdAssociator, "MuonDetIdAssociator"); +DEFINE_EDM_PLUGIN(DetIdAssociatorFactory, PreshowerDetIdAssociator, "PreshowerDetIdAssociator"); diff --git a/trunk/TrackingTools/TrackAssociator/python/DetIdAssociatorESProducer_cff.py b/trunk/TrackingTools/TrackAssociator/python/DetIdAssociatorESProducer_cff.py index 4223b7b22aad1..ffc96ae17da72 100644 --- a/trunk/TrackingTools/TrackAssociator/python/DetIdAssociatorESProducer_cff.py +++ b/trunk/TrackingTools/TrackAssociator/python/DetIdAssociatorESProducer_cff.py @@ -36,4 +36,11 @@ includeBadChambers = cms.bool(False) ) +preshowerDetIdAssociator = cms.ESProducer("DetIdAssociatorESProducer", + ComponentName = cms.string('PreshowerDetIdAssociator'), + etaBinSize = cms.double(0.1), + nEta = cms.int32(60), + nPhi = cms.int32(30) +) + diff --git a/trunk/TrackingTools/TrackAssociator/src/TrackDetectorAssociator.cc b/trunk/TrackingTools/TrackAssociator/src/TrackDetectorAssociator.cc index 84a62aed29d60..f4d214e1676a2 100644 --- a/trunk/TrackingTools/TrackAssociator/src/TrackDetectorAssociator.cc +++ b/trunk/TrackingTools/TrackAssociator/src/TrackDetectorAssociator.cc @@ -13,7 +13,7 @@ // // Original Author: Dmytro Kovalskyi // Created: Fri Apr 21 10:59:41 PDT 2006 -// $Id: TrackDetectorAssociator.cc,v 1.37 2009/03/30 11:59:30 arizzi Exp $ +// $Id: TrackDetectorAssociator.cc,v 1.37.2.1 2009/07/01 10:04:17 dmytro Exp $ // // @@ -76,6 +76,7 @@ #include "TrackingTools/TrackAssociator/interface/CaloDetIdAssociator.h" #include "TrackingTools/TrackAssociator/interface/EcalDetIdAssociator.h" +#include "TrackingTools/TrackAssociator/interface/PreshowerDetIdAssociator.h" // #include "Utilities/Timing/interface/TimerStack.h" #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" @@ -150,6 +151,7 @@ void TrackDetectorAssociator::init( const edm::EventSetup& iSetup ) iSetup.get().get("HODetIdAssociator", hoDetIdAssociator_); iSetup.get().get("CaloDetIdAssociator", caloDetIdAssociator_); iSetup.get().get("MuonDetIdAssociator", muonDetIdAssociator_); + iSetup.get().get("PreshowerDetIdAssociator", preshowerDetIdAssociator_); } TrackDetMatchInfo TrackDetectorAssociator::associate( const edm::Event& iEvent, @@ -200,7 +202,7 @@ TrackDetMatchInfo TrackDetectorAssociator::associate( const edm::Event& iEvent, double HOmaxR = hoDetIdAssociator_->volume().maxR(); double HOmaxZ = hoDetIdAssociator_->volume().maxZ(); double minR = ecalDetIdAssociator_->volume().minR(); - double minZ = ecalDetIdAssociator_->volume().minZ(); + double minZ = preshowerDetIdAssociator_->volume().minZ(); cachedTrajectory_.setMaxHORadius(HOmaxR); cachedTrajectory_.setMaxHOLength(HOmaxZ*2.); cachedTrajectory_.setMinDetectorRadius(minR); @@ -242,6 +244,7 @@ TrackDetMatchInfo TrackDetectorAssociator::associate( const edm::Event& iEvent, cachedTrajectory_.findEcalTrajectory( ecalDetIdAssociator_->volume() ); cachedTrajectory_.findHcalTrajectory( hcalDetIdAssociator_->volume() ); cachedTrajectory_.findHOTrajectory( hoDetIdAssociator_->volume() ); + cachedTrajectory_.findPreshowerTrajectory( preshowerDetIdAssociator_->volume() ); info.trkGlobPosAtEcal = getPoint( cachedTrajectory_.getStateAtEcal().position() ); info.trkGlobPosAtHcal = getPoint( cachedTrajectory_.getStateAtHcal().position() ); @@ -253,6 +256,7 @@ TrackDetMatchInfo TrackDetectorAssociator::associate( const edm::Event& iEvent, if (parameters.useCalo) fillCaloTowers( iEvent, info, parameters); if (parameters.useHcal) fillHcal( iEvent, info, parameters); if (parameters.useHO) fillHO( iEvent, info, parameters); + if (parameters.usePreshower) fillPreshower( iEvent, info, parameters); if (parameters.useMuon) fillMuon( iEvent, info, parameters); if (parameters.truthMatch) fillCaloTruth( iEvent, info, parameters); @@ -274,20 +278,8 @@ void TrackDetectorAssociator::fillEcal( const edm::Event& iEvent, ", " << itr->position().z() << ", " << itr->position().phi(); std::vector coreTrajectory; - std::vector trajectoryWithErrors; - if ( parameters.crossedEnergyType == TrackAssociatorParameters::FivePointTwoSigmaElipseAlongTrajectory ) { - // timers.push("TrackDetectorAssociator::fillEcal::BuildEllipse"); - std::vector* wideTrajectory = cachedTrajectory_.getWideTrajectory(trajectoryStates, CachedTrajectory::Ecal); - trajectoryWithErrors = *wideTrajectory; - for(unsigned int trajit=0; trajitsize(); trajit+=5) - coreTrajectory.push_back(trajectoryWithErrors[trajit]); - LogTrace("TrackAssociator") << "Wide trajectory has " << wideTrajectory->size() << " points"; - // timers.pop(); - } else { - for(std::vector::const_iterator itr = trajectoryStates.begin(); - itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position()); - trajectoryWithErrors = coreTrajectory; - } + for(std::vector::const_iterator itr = trajectoryStates.begin(); + itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position()); if(coreTrajectory.empty()) { LogTrace("TrackAssociator") << "ECAL track trajectory is empty; moving on\n"; @@ -321,16 +313,8 @@ void TrackDetectorAssociator::fillEcal( const edm::Event& iEvent, if (parameters.dREcalPreselection > parameters.dREcal) ecalIdsInRegion = ecalDetIdAssociator_->getDetIdsInACone(ecalIdsInRegion, coreTrajectory, parameters.dREcal); LogTrace("TrackAssociator") << "ECAL hits in the cone: " << ecalIdsInRegion.size(); - std::vector crossedEcalIds; - if ( parameters.crossedEnergyType == TrackAssociatorParameters::FivePointTwoSigmaElipseAlongTrajectory ) { - float conesize = .0696; - std::set ecalIdsInSubRegion = ecalDetIdAssociator_->getDetIdsInACone(ecalIdsInRegion, coreTrajectory, conesize); - // timers.pop_and_push("TrackDetectorAssociator::fillEcal::matching::crossed"); - crossedEcalIds = ecalDetIdAssociator_->getCrossedDetIdsOrdered(ecalIdsInSubRegion, trajectoryWithErrors); - // timers.pop(); - } else { - crossedEcalIds = ecalDetIdAssociator_->getCrossedDetIdsOrdered(ecalIdsInRegion, trajectoryWithErrors); - } + std::vector crossedEcalIds = + ecalDetIdAssociator_->getCrossedDetIds(ecalIdsInRegion, coreTrajectory); LogTrace("TrackAssociator") << "ECAL crossed hits " << crossedEcalIds.size(); info.crossedEcalIds = crossedEcalIds; @@ -404,7 +388,7 @@ void TrackDetectorAssociator::fillCaloTowers( const edm::Event& iEvent, LogTrace("TrackAssociator") << "Towers in the region: " << caloTowerIdsInRegion.size(); std::set caloTowerIdsInACone = caloDetIdAssociator_->getDetIdsInACone(caloTowerIdsInRegion, trajectory, parameters.dRHcal); LogTrace("TrackAssociator") << "Towers in the cone: " << caloTowerIdsInACone.size(); - std::vector crossedCaloTowerIds = caloDetIdAssociator_->getCrossedDetIdsOrdered(caloTowerIdsInRegion, trajectory); + std::vector crossedCaloTowerIds = caloDetIdAssociator_->getCrossedDetIds(caloTowerIdsInRegion, trajectory); LogTrace("TrackAssociator") << "Towers crossed: " << crossedCaloTowerIds.size(); info.crossedTowerIds = crossedCaloTowerIds; @@ -432,6 +416,31 @@ void TrackDetectorAssociator::fillCaloTowers( const edm::Event& iEvent, } +void TrackDetectorAssociator::fillPreshower( const edm::Event& iEvent, + TrackDetMatchInfo& info, + const AssociatorParameters& parameters) +{ + std::vector trajectory; + const std::vector& trajectoryStates = cachedTrajectory_.getPreshowerTrajectory(); + for(std::vector::const_iterator itr = trajectoryStates.begin(); + itr != trajectoryStates.end(); itr++) trajectory.push_back(itr->position()); + + if(trajectory.empty()) { + LogTrace("TrackAssociator") << "Preshower trajectory is empty; moving on\n"; + return; + } + + std::set idsInRegion = + preshowerDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0], + parameters.dRPreshowerPreselection); + + LogTrace("TrackAssociator") << "Number of Preshower Ids in the region: " << idsInRegion.size(); + std::vector crossedIds = preshowerDetIdAssociator_->getCrossedDetIds(idsInRegion, trajectory); + LogTrace("TrackAssociator") << "Number of Preshower Ids in crossed: " << crossedIds.size(); + info.crossedPreshowerIds = crossedIds; +} + + void TrackDetectorAssociator::fillHcal( const edm::Event& iEvent, TrackDetMatchInfo& info, const AssociatorParameters& parameters) @@ -442,20 +451,8 @@ void TrackDetectorAssociator::fillHcal( const edm::Event& iEvent, const std::vector& trajectoryStates = cachedTrajectory_.getHcalTrajectory(); std::vector coreTrajectory; - std::vector trajectoryWithErrors; - if ( parameters.crossedEnergyType == TrackAssociatorParameters::FivePointTwoSigmaElipseAlongTrajectory ) { - // timers.push("TrackDetectorAssociator::fillHcal::BuildEllipse"); - std::vector* wideTrajectory = cachedTrajectory_.getWideTrajectory(trajectoryStates, CachedTrajectory::Hcal); - trajectoryWithErrors = *wideTrajectory; - for(unsigned int trajit=0; trajitsize(); trajit+=5) - coreTrajectory.push_back(trajectoryWithErrors[trajit]); - LogTrace("TrackAssociator") << "Wide trajectory has " << wideTrajectory->size() << " points"; - // timers.pop(); - } else { - for(std::vector::const_iterator itr = trajectoryStates.begin(); - itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position()); - trajectoryWithErrors = coreTrajectory; - } + for(std::vector::const_iterator itr = trajectoryStates.begin(); + itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position()); if(coreTrajectory.empty()) { LogTrace("TrackAssociator") << "HCAL trajectory is empty; moving on\n"; @@ -483,14 +480,8 @@ void TrackDetectorAssociator::fillHcal( const edm::Event& iEvent, LogTrace("TrackAssociator") << "HCAL hits in the region: " << idsInRegion.size() << "\n" << DetIdInfo::info(idsInRegion); std::set idsInACone = hcalDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal); LogTrace("TrackAssociator") << "HCAL hits in the cone: " << idsInACone.size() << "\n" << DetIdInfo::info(idsInACone); - std::vector crossedIds; - if ( parameters.crossedEnergyType == TrackAssociatorParameters::FivePointTwoSigmaElipseAlongTrajectory ) { - float conesize = 0.348; - std::set idsInSubRegion = hcalDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, conesize); - crossedIds = hcalDetIdAssociator_->getCrossedDetIdsOrdered(idsInSubRegion, trajectoryWithErrors); - } else { - crossedIds = hcalDetIdAssociator_->getCrossedDetIdsOrdered(idsInRegion, trajectoryWithErrors); - } + std::vector crossedIds = + hcalDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory); LogTrace("TrackAssociator") << "HCAL hits crossed: " << crossedIds.size() << "\n" << DetIdInfo::info(crossedIds); info.crossedHcalIds = crossedIds; @@ -526,20 +517,8 @@ void TrackDetectorAssociator::fillHO( const edm::Event& iEvent, const std::vector& trajectoryStates = cachedTrajectory_.getHOTrajectory(); std::vector coreTrajectory; - std::vector trajectoryWithErrors; - if ( parameters.crossedEnergyType == TrackAssociatorParameters::FivePointTwoSigmaElipseAlongTrajectory ) { - // timers.push("TrackDetectorAssociator::fillHO::BuildEllipse"); - std::vector* wideTrajectory = cachedTrajectory_.getWideTrajectory(trajectoryStates, CachedTrajectory::Hcal); - trajectoryWithErrors = *wideTrajectory; - for(unsigned int trajit=0; trajitsize(); trajit+=5) - coreTrajectory.push_back(trajectoryWithErrors[trajit]); - LogTrace("TrackAssociator") << "Wide trajectory has " << wideTrajectory->size() << " points"; - // timers.pop(); - } else { - for(std::vector::const_iterator itr = trajectoryStates.begin(); - itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position()); - trajectoryWithErrors = coreTrajectory; - } + for(std::vector::const_iterator itr = trajectoryStates.begin(); + itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position()); if(coreTrajectory.empty()) { LogTrace("TrackAssociator") << "HO trajectory is empty; moving on\n"; @@ -567,15 +546,8 @@ void TrackDetectorAssociator::fillHO( const edm::Event& iEvent, LogTrace("TrackAssociator") << "idsInRegion.size(): " << idsInRegion.size(); std::set idsInACone = hoDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal); LogTrace("TrackAssociator") << "idsInACone.size(): " << idsInACone.size(); - std::vector crossedIds; - if ( parameters.crossedEnergyType == TrackAssociatorParameters::FivePointTwoSigmaElipseAlongTrajectory ) { - float conesize=0.348; - std::set idsInSubRegion = hoDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, conesize); - crossedIds = hoDetIdAssociator_->getCrossedDetIdsOrdered(idsInSubRegion, trajectoryWithErrors); - LogTrace("TrackAssociator") << "crossedIds.size(): " << crossedIds.size(); - } else { - crossedIds = hoDetIdAssociator_->getCrossedDetIdsOrdered(idsInRegion, trajectoryWithErrors); - } + std::vector crossedIds = + hoDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory); info.crossedHOIds = crossedIds; @@ -789,7 +761,6 @@ void TrackDetectorAssociator::getTAMuonChamberMatches(std::vector simTracks; - iEvent.getByType(simTracks); - - Handle simVertices; - iEvent.getByType(simVertices); - if (! simVertices.isValid() ) throw cms::Exception("FatalError") << "No vertices found\n"; - - // loop over simulated tracks - LogVerbatim("TrackAssociator") << "Number of simulated tracks found in the event: " << simTracks->size() ; - for(SimTrackContainer::const_iterator tracksCI = simTracks->begin(); - tracksCI != simTracks->end(); tracksCI++){ + Handle muons; + iEvent.getByLabel("muons",muons); + + // loop + LogVerbatim("TrackAssociator") << "Number of muons found in the event: " << muons->size() ; + for(reco::MuonCollection::const_iterator muon = muons->begin(); + muon != muons->end(); ++muon){ // skip low Pt tracks - if (tracksCI->momentum().pt() < 5) { - LogVerbatim("TrackAssociator") << "Skipped low Pt track (Pt: " << tracksCI->momentum().pt() << ")" ; + if (muon->pt() < 2) { + LogVerbatim("TrackAssociator") << "Skipped low Pt muon (Pt: " << muon->pt() << ")" ; continue; } - // get vertex - int vertexIndex = tracksCI->vertIndex(); - // uint trackIndex = tracksCI->genpartIndex(); - - SimVertex vertex(math::XYZVectorD(0.,0.,0.),0); - if (vertexIndex >= 0) vertex = (*simVertices)[vertexIndex]; - // skip tracks originated away from the IP - if (vertex.position().rho() > 50) { - LogVerbatim("TrackAssociator") << "Skipped track originated away from IP: " <vertex().rho()) > 50) { + LogVerbatim("TrackAssociator") << "Skipped track with large impact parameter: " <vertex().rho(); continue; } - LogVerbatim("TrackAssociator") << "\n-------------------------------------------------------\n Track (pt,eta,phi): " << tracksCI->momentum().pt() << " , " << - tracksCI->momentum().eta() << " , " << tracksCI->momentum().phi() ; + LogVerbatim("TrackAssociator") << "\n-------------------------------------------------------\n Track (pt,eta,phi): " + << muon->pt() << " , " << muon->eta() << " , " << muon->phi() ; - TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup, - trackAssociator_.getFreeTrajectoryState(iSetup, *tracksCI, vertex), - parameters_); + TrackDetMatchInfo info; + if (muon->innerTrack().isAvailable()) + info = trackAssociator_.associate(iEvent, iSetup, *muon->innerTrack(), parameters_); + else { + if (!muon->outerTrack().isAvailable()) { + LogVerbatim("TrackAssociator") << "No refernced tracks are available, skim the muon"; + continue; + } + info = trackAssociator_.associate(iEvent, iSetup, *muon->outerTrack(), parameters_); + } + LogVerbatim("TrackAssociator") << "===========================================================================" ; LogVerbatim("TrackAssociator") << "ECAL RecHit energy: crossed, 3x3(max), 5x5(max), 3x3(direction), 5x5(direction), cone R0.5, generator"; DetId centerId = info.findMaxDeposition(TrackDetMatchInfo::EcalRecHits); @@ -184,6 +184,14 @@ void TestTrackAssociator::analyze( const edm::Event& iEvent, const edm::EventSet LogVerbatim("TrackAssociator") << "\t" << (*hit)->detid().rawId() << ", " << (*hit)->energy() << " \t(" << point.z() << ", \t" << point.perp() << ", \t" << point.eta() << ", \t" << point.phi() << ")"; } + LogVerbatim("TrackAssociator") << "Preshower crossed DetIds: (id, z, perp, eta, phi)"; + for(std::vector::const_iterator id = info.crossedPreshowerIds.begin(); + id != info.crossedPreshowerIds.end(); ++id) + { + GlobalPoint point = info.getPosition(*id); + LogVerbatim("TrackAssociator") << "\t" << id->rawId() << + " \t(" << point.z() << ", \t" << point.perp() << ", \t" << point.eta() << ", \t" << point.phi() << ")"; + } LogVerbatim("TrackAssociator") << "---------------------------------------------------------------------------" ; LogVerbatim("TrackAssociator") << "HCAL RecHit energy: crossed, 3x3(max), 5x5(max), 3x3(direction), 5x5(direction), cone R0.5, generator"; diff --git a/trunk/TrackingTools/TrackAssociator/test/TestTrackAssociator.py b/trunk/TrackingTools/TrackAssociator/test/TestTrackAssociator.py new file mode 100755 index 0000000000000..c44eb7f8ba5fd --- /dev/null +++ b/trunk/TrackingTools/TrackAssociator/test/TestTrackAssociator.py @@ -0,0 +1,86 @@ +import FWCore.ParameterSet.Config as cms +process = cms.Process("TEST") + +process.load("Configuration.StandardSequences.MagneticField_cff") +process.load("Configuration.StandardSequences.Geometry_cff") +process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") +process.GlobalTag.globaltag = 'MC_31X_V5::All' + + +process.load("Geometry.CMSCommonData.cmsIdealGeometryXML_cfi") +# process.load("MagneticField.Engine.volumeBasedMagneticField_cfi") +process.load("Geometry.CaloEventSetup.CaloGeometry_cff") + +process.load("Geometry.CaloEventSetup.CaloTopology_cfi") + +process.load("Geometry.CaloEventSetup.EcalTrigTowerConstituents_cfi") + +process.load("Geometry.TrackerGeometryBuilder.trackerGeometry_cfi") + +process.load("Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi") + +process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi") + +process.load("Geometry.DTGeometry.dtGeometry_cfi") + +process.load("Geometry.RPCGeometry.rpcGeometry_cfi") + +process.load("Geometry.CSCGeometry.cscGeometry_cfi") + +process.load("Geometry.CommonDetUnit.bareGlobalTrackingGeometry_cfi") + +process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi") + +process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi") + +process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAny_cfi") + +# add TrackDetectorAssociator lookup maps to the EventSetup +process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff") +# from TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff import * +from TrackingTools.TrackAssociator.default_cfi import * + +process.demo = cms.EDAnalyzer('TestTrackAssociator', + TrackAssociatorParameterBlock +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(100) +) + +process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring('cout'), + # categories = cms.untracked.vstring('TrackAssociator','TrackAssociatorVerbose'), + # categories = cms.untracked.vstring('TrackAssociator'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('INFO'), + # threshold = cms.untracked.string('DEBUG'), + noTimeStamps = cms.untracked.bool(True), + noLineBreaks = cms.untracked.bool(True), + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + # TrackAssociator = cms.untracked.PSet( + # limit = cms.untracked.int32(-1) + #), + # TrackAssociatorVerbose = cms.untracked.PSet( + # limit = cms.untracked.int32(-1) + #), + ), + debugModules = cms.untracked.vstring("demo") +) + +import FWCore.Framework.test.cmsExceptionsFatalOption_cff +options = cms.untracked.PSet( + Rethrow = FWCore.Framework.test.cmsExceptionsFatalOption_cff.Rethrow +) + +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( + '/store/relval/CMSSW_3_2_5/RelValSingleMuPt10/GEN-SIM-RECO/MC_31X_V5-v1/0011/E014EF8B-588E-DE11-8D06-001617E30E28.root' + ) +) + +process.p = cms.Path(process.demo) + +