New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DQM] esConsumes migration for Validation package leftovers #34604
Changes from 10 commits
30fdc43
ae14ab3
33db642
0d84b83
265b517
05b5120
1ef638e
7d0c451
68188fd
283ec8d
9e53f92
3a1f829
a64422a
16b1bf0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,10 @@ class CosmicTrackingParticleSelector { | |
minHit_(cfg.getParameter<int>("minHit")), | ||
chargedOnly_(cfg.getParameter<bool>("chargedOnly")), | ||
pdgId_(cfg.getParameter<std::vector<int> >("pdgId")), | ||
beamSpotToken_(iC.consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"))) {} | ||
beamSpotToken_(iC.consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"))), | ||
trackerDigiGeomToken_(iC.esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()), | ||
globalTrackingGeomToken_(iC.esConsumes<GlobalTrackingGeometry, GlobalTrackingGeometryRecord>()), | ||
theMFToken_(iC.esConsumes<MagneticField, IdealMagneticFieldRecord>()) {} | ||
|
||
void select(const edm::Handle<collection>& c, const edm::Event& event, const edm::EventSetup& setup) { | ||
selected_.clear(); | ||
|
@@ -103,13 +106,10 @@ class CosmicTrackingParticleSelector { | |
//if (tpr->pdgId()==pdgId_[it]) testId = true; | ||
//} | ||
|
||
edm::ESHandle<TrackerGeometry> tracker; | ||
iSetup.get<TrackerDigiGeometryRecord>().get(tracker); | ||
edm::ESHandle<GlobalTrackingGeometry> theGeometry; | ||
iSetup.get<GlobalTrackingGeometryRecord>().get(theGeometry); | ||
edm::ESHandle<TrackerGeometry> tracker = iSetup.getHandle(trackerDigiGeomToken_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this used anywhere in this file? |
||
edm::ESHandle<GlobalTrackingGeometry> theGeometry = iSetup.getHandle(globalTrackingGeomToken_); | ||
|
||
edm::ESHandle<MagneticField> theMF; | ||
iSetup.get<IdealMagneticFieldRecord>().get(theMF); | ||
edm::ESHandle<MagneticField> theMF = iSetup.getHandle(theMFToken_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the validity of the |
||
|
||
GlobalVector finalGV(0, 0, 0); | ||
GlobalPoint finalGP(0, 0, 0); | ||
|
@@ -217,6 +217,9 @@ class CosmicTrackingParticleSelector { | |
std::vector<int> pdgId_; | ||
container selected_; | ||
edm::EDGetTokenT<reco::BeamSpot> beamSpotToken_; | ||
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerDigiGeomToken_; | ||
edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> globalTrackingGeomToken_; | ||
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theMFToken_; | ||
|
||
mutable edm::Handle<SimHitTPAssociationProducer::SimHitTPAssociationList> simHitsTPAssoc; | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -505,39 +505,38 @@ namespace SingleTopTChannelLepton { | |
return; | ||
} | ||
|
||
edm::Handle<reco::JetCorrector> corrector; | ||
/*edm::Handle<reco::JetCorrector> corrector; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this commented out code, as it is not needed any more |
||
event.getByToken(mJetCorrector, corrector); | ||
if (!event.getByToken(mJetCorrector, corrector)) | ||
return; | ||
return;*/ | ||
// load jet | ||
// corrector if configured such | ||
// const JetCorrector* corrector = 0; | ||
// if (!jetCorrector_.empty()) { | ||
|
||
// check whether a jet correcto is in the event setup or not | ||
// if (setup.find(edm::eventsetup::EventSetupRecordKey::makeKey< | ||
// JetCorrectionsRecord>())) { | ||
// corrector = JetCorrector::getJetCorrector(jetCorrector_, setup); | ||
// } else { | ||
// edm::LogVerbatim("SingleTopTChannelLeptonDQM") | ||
// << "\n" | ||
// << "-----------------------------------------------------------------" | ||
// "-------------------- \n" | ||
// << " No JetCorrectionsRecord available from EventSetup:\n" | ||
// << " - Jets will not be corrected.\n" | ||
// << " - If you want to change this add the following lines to your " | ||
// "cfg file:\n" | ||
// << "\n" | ||
// << " ## load jet corrections\n" | ||
// << " " | ||
// "process.load(\"JetMETCorrections.Configuration." | ||
// "JetCorrectionServicesAllAlgos_cff\") \n" | ||
// << " process.prefer(\"ak5CaloL2L3\")\n" | ||
// << "\n" | ||
// << "-----------------------------------------------------------------" | ||
// "-------------------- \n"; | ||
// } | ||
//} | ||
const JetCorrector* corrector = nullptr; | ||
if (!jetCorrector_.isInitialized()) { | ||
// check whether a jet correcto is in the event setup or not | ||
if (setup.find(edm::eventsetup::EventSetupRecordKey::makeKey<JetCorrectionsRecord>())) { | ||
corrector = &setup.getData(jetCorrector_); | ||
; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ??? |
||
} else { | ||
edm::LogVerbatim("SingleTopTChannelLeptonDQM") | ||
<< "\n" | ||
<< "-----------------------------------------------------------------" | ||
"-------------------- \n" | ||
<< " No JetCorrectionsRecord available from EventSetup:\n" | ||
<< " - Jets will not be corrected.\n" | ||
<< " - If you want to change this add the following lines to your " | ||
"cfg file:\n" | ||
<< "\n" | ||
<< " ## load jet corrections\n" | ||
<< " " | ||
"process.load(\"JetMETCorrections.Configuration." | ||
"JetCorrectionServicesAllAlgos_cff\") \n" | ||
<< " process.prefer(\"ak5CaloL2L3\")\n" | ||
<< "\n" | ||
<< "-----------------------------------------------------------------" | ||
"-------------------- \n"; | ||
} | ||
} | ||
// loop jet collection | ||
std::vector<reco::Jet> correctedJets; | ||
std::vector<double> JetTagValues; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,10 @@ TrackClassifier::TrackClassifier(edm::ParameterSet const &config, edm::ConsumesC | |
hepMCLabel_(config.getUntrackedParameter<edm::InputTag>("hepMC")), | ||
beamSpotLabel_(config.getUntrackedParameter<edm::InputTag>("beamSpot")), | ||
tracer_(config, std::move(collector)), | ||
quality_(config, collector) { | ||
quality_(config, collector), | ||
magneticFieldToken_(collector.esConsumes<MagneticField, IdealMagneticFieldRecord>()), | ||
transientTrackBuilderToken_(collector.esConsumes<TransientTrackBuilder, TransientTrackRecord>()), | ||
tTopoHandToken_(collector.esConsumes<TrackerTopology, TrackerTopologyRcd>()) { | ||
collector.consumes<edm::HepMCProduct>(hepMCLabel_); | ||
collector.consumes<reco::BeamSpot>(beamSpotLabel_); | ||
|
||
|
@@ -52,7 +55,7 @@ void TrackClassifier::newEvent(edm::Event const &event, edm::EventSetup const &s | |
event.getByLabel(hepMCLabel_, mcInformation_); | ||
|
||
// Magnetic field | ||
setup.get<IdealMagneticFieldRecord>().get(magneticField_); | ||
magneticField_ = setup.getHandle(magneticFieldToken_); | ||
|
||
// Get the partivle data table | ||
setup.getData(particleDataTable_); | ||
|
@@ -61,14 +64,13 @@ void TrackClassifier::newEvent(edm::Event const &event, edm::EventSetup const &s | |
event.getByLabel(beamSpotLabel_, beamSpot_); | ||
|
||
// Transient track builder | ||
setup.get<TransientTrackRecord>().get("TransientTrackBuilder", transientTrackBuilder_); | ||
transientTrackBuilder_ = setup.getHandle(transientTrackBuilderToken_); | ||
|
||
// Create the list of primary vertices associated to the event | ||
genPrimaryVertices(); | ||
|
||
// Retrieve tracker topology from geometry | ||
edm::ESHandle<TrackerTopology> tTopoHand; | ||
setup.get<TrackerTopologyRcd>().get(tTopoHand); | ||
edm::ESHandle<TrackerTopology> tTopoHand = setup.getHandle(tTopoHandToken_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about getting the product directly without passing for the |
||
tTopo_ = tTopoHand.product(); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken one does not need to re-declare the objects consumed in the tokens in the
esConsumes
call. Removing them will make the code shorter.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct, plain
iC.esConsumes()
is sufficient (as would beiC.consumes()
for Event data products nowadays). They use a trick to deduce the product and record types from the token.