Skip to content

Commit

Permalink
consumes migration in Validation/DTRecHits
Browse files Browse the repository at this point in the history
  • Loading branch information
ptraczyk authored and slava77devel committed Apr 24, 2014
1 parent 3f32294 commit 3ca6f62
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 13 deletions.
13 changes: 8 additions & 5 deletions Validation/DTRecHits/plugins/DTRecHitQuality.cc
Expand Up @@ -46,13 +46,16 @@ DTRecHitQuality::DTRecHitQuality(const ParameterSet& pset){
debug = pset.getUntrackedParameter<bool>("debug");
// the name of the simhit collection
simHitLabel = pset.getUntrackedParameter<InputTag>("simHitLabel");
simHitToken_ = consumes<PSimHitContainer>(pset.getParameter<InputTag>("simHitLabel"));
// the name of the 1D rec hit collection
recHitLabel = pset.getUntrackedParameter<InputTag>("recHitLabel");
recHitToken_ = consumes<DTRecHitCollection>(pset.getParameter<InputTag>("recHitLabel"));
// the name of the 2D rec hit collection
segment2DLabel = pset.getUntrackedParameter<InputTag>("segment2DLabel");
segment2DToken_ = consumes<DTRecSegment2DCollection>(pset.getParameter<InputTag>("segment2DLabel"));
// the name of the 4D rec hit collection
segment4DLabel = pset.getUntrackedParameter<InputTag>("segment4DLabel");

segment4DToken_ = consumes<DTRecSegment4DCollection>(pset.getParameter<InputTag>("segment4DLabel"));
// Switches for analysis at various steps
doStep1 = pset.getUntrackedParameter<bool>("doStep1", false);
doStep2 = pset.getUntrackedParameter<bool>("doStep2", false);
Expand Down Expand Up @@ -197,7 +200,7 @@ void DTRecHitQuality::endJob() {

// Get the SimHit collection from the event
Handle<PSimHitContainer> simHits;
event.getByLabel(simHitLabel, simHits);
event.getByToken(simHitToken_, simHits);

// Map simhits per wire
map<DTWireId, PSimHitContainer > simHitsPerWire =
Expand All @@ -212,7 +215,7 @@ void DTRecHitQuality::endJob() {
cout << " -- DTRecHit S1: begin analysis:" << endl;
// Get the rechit collection from the event
Handle<DTRecHitCollection> dtRecHits;
event.getByLabel(recHitLabel, dtRecHits);
event.getByToken(recHitToken_, dtRecHits);

if(!dtRecHits.isValid()) {
if(debug) cout << "[DTRecHitQuality]**Warning: no 1DRechits with label: " << recHitLabel << " in this event, skipping!" << endl;
Expand All @@ -235,7 +238,7 @@ void DTRecHitQuality::endJob() {

// Get the 2D rechits from the event
Handle<DTRecSegment2DCollection> segment2Ds;
event.getByLabel(segment2DLabel, segment2Ds);
event.getByToken(segment2DToken_, segment2Ds);

if(!segment2Ds.isValid()) {
if(debug) cout << "[DTRecHitQuality]**Warning: no 2DSegments with label: " << segment2DLabel
Expand All @@ -259,7 +262,7 @@ void DTRecHitQuality::endJob() {

// Get the 4D rechits from the event
Handle<DTRecSegment4DCollection> segment4Ds;
event.getByLabel(segment4DLabel, segment4Ds);
event.getByToken(segment4DToken_, segment4Ds);

if(!segment4Ds.isValid()) {
if(debug) cout << "[DTRecHitQuality]**Warning: no 4D Segments with label: " << segment4DLabel
Expand Down
6 changes: 6 additions & 0 deletions Validation/DTRecHits/plugins/DTRecHitQuality.h
Expand Up @@ -23,6 +23,7 @@
#include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
#include "DataFormats/DTRecHit/interface/DTRecSegment2DCollection.h"
#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
#include "Histograms.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMServices/Core/interface/MonitorElement.h"
Expand Down Expand Up @@ -77,6 +78,11 @@ class DTRecHitQuality : public edm::EDAnalyzer {
bool debug;
// Root file name
std::string rootFileName;
edm::EDGetTokenT<edm::PSimHitContainer> simHitToken_;
edm::EDGetTokenT<DTRecHitCollection> recHitToken_;
edm::EDGetTokenT<DTRecSegment2DCollection> segment2DToken_;
edm::EDGetTokenT<DTRecSegment4DCollection> segment4DToken_;;

edm::InputTag simHitLabel;
edm::InputTag recHitLabel;
edm::InputTag segment2DLabel;
Expand Down
6 changes: 4 additions & 2 deletions Validation/DTRecHits/plugins/DTSegment2DQuality.cc
Expand Up @@ -40,8 +40,10 @@ DTSegment2DQuality::DTSegment2DQuality(const ParameterSet& pset) {
DTHitQualityUtils::debug = debug;
// the name of the simhit collection
simHitLabel = pset.getUntrackedParameter<InputTag>("simHitLabel");
simHitToken_ = consumes<PSimHitContainer>(pset.getParameter<InputTag>("simHitLabel"));
// the name of the 2D rec hit collection
segment2DLabel = pset.getUntrackedParameter<InputTag>("segment2DLabel");
segment2DToken_ = consumes<DTRecSegment2DCollection>(pset.getParameter<InputTag>("segment2DLabel"));

//sigma resolution on position
sigmaResPos = pset.getParameter<double>("sigmaResPos");
Expand Down Expand Up @@ -125,7 +127,7 @@ void DTSegment2DQuality::analyze(const Event & event, const EventSetup& eventSet

// Get the SimHit collection from the event
edm::Handle<PSimHitContainer> simHits;
event.getByLabel(simHitLabel, simHits); //FIXME: second string to be removed
event.getByToken(simHitToken_, simHits); //FIXME: second string to be removed

//Map simHits by sl
map<DTSuperLayerId, PSimHitContainer > simHitsPerSl;
Expand All @@ -139,7 +141,7 @@ void DTSegment2DQuality::analyze(const Event & event, const EventSetup& eventSet

// Get the 2D rechits from the event
Handle<DTRecSegment2DCollection> segment2Ds;
event.getByLabel(segment2DLabel, segment2Ds);
event.getByToken(segment2DToken_, segment2Ds);

if(!segment2Ds.isValid()) {
if(debug) cout << "[DTSegment2DQuality]**Warning: no 2DSegments with label: " << segment2DLabel
Expand Down
5 changes: 5 additions & 0 deletions Validation/DTRecHits/plugins/DTSegment2DQuality.h
Expand Up @@ -14,6 +14,8 @@
#include "DQMServices/Core/interface/MonitorElement.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/DTRecHit/interface/DTRecSegment2DCollection.h"
#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"

#include <vector>
#include <map>
Expand Down Expand Up @@ -58,6 +60,9 @@ class DTSegment2DQuality : public edm::EDAnalyzer {
//Labels to read from event
edm::InputTag simHitLabel;
edm::InputTag segment2DLabel;
edm::EDGetTokenT<edm::PSimHitContainer> simHitToken_;
edm::EDGetTokenT<DTRecSegment2DCollection> segment2DToken_;

//Sigma resolution on position
double sigmaResPos;
//Sigma resolution on angle
Expand Down
8 changes: 5 additions & 3 deletions Validation/DTRecHits/plugins/DTSegment2DSLPhiQuality.cc
Expand Up @@ -44,8 +44,10 @@ DTSegment2DSLPhiQuality::DTSegment2DSLPhiQuality(const ParameterSet& pset) {

// the name of the simhit collection
simHitLabel = pset.getUntrackedParameter<InputTag>("simHitLabel");
// the name of the 4D rec hit collection
simHitToken_ = consumes<PSimHitContainer>(pset.getParameter<InputTag>("simHitLabel"));
// the name of the 2D rec hit collection
segment4DLabel = pset.getUntrackedParameter<InputTag>("segment4DLabel");
segment4DToken_ = consumes<DTRecSegment4DCollection>(pset.getParameter<InputTag>("segment4DLabel"));

//sigma resolution on position
sigmaResPos = pset.getParameter<double>("sigmaResPos");
Expand Down Expand Up @@ -110,7 +112,7 @@ void DTSegment2DSLPhiQuality::analyze(const Event & event, const EventSetup& eve

// Get the SimHit collection from the event
edm::Handle<PSimHitContainer> simHits;
event.getByLabel(simHitLabel, simHits); //FIXME: second string to be removed
event.getByToken(simHitToken_, simHits); //FIXME: second string to be removed

//Map simHits by chamber
map<DTChamberId, PSimHitContainer > simHitsPerCh;
Expand All @@ -124,7 +126,7 @@ void DTSegment2DSLPhiQuality::analyze(const Event & event, const EventSetup& eve

// Get the 4D rechits from the event
Handle<DTRecSegment4DCollection> segment4Ds;
event.getByLabel(segment4DLabel, segment4Ds);
event.getByToken(segment4DToken_, segment4Ds);

if(!segment4Ds.isValid()) {
if(debug) cout << "[DTSegment2DSLPhiQuality]**Warning: no 4D Segments with label: " << segment4DLabel
Expand Down
5 changes: 5 additions & 0 deletions Validation/DTRecHits/plugins/DTSegment2DSLPhiQuality.h
Expand Up @@ -18,6 +18,9 @@
#include <map>
#include <string>
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"


namespace edm {
class ParameterSet;
Expand Down Expand Up @@ -61,6 +64,8 @@ class DTSegment2DSLPhiQuality : public edm::EDAnalyzer {
//Labels to read from event
edm::InputTag simHitLabel;
edm::InputTag segment4DLabel;
edm::EDGetTokenT<edm::PSimHitContainer> simHitToken_;
edm::EDGetTokenT<DTRecSegment4DCollection> segment4DToken_;
//Sigma resolution on position
double sigmaResPos;
//Sigma resolution on angle
Expand Down
9 changes: 6 additions & 3 deletions Validation/DTRecHits/plugins/DTSegment4DQuality.cc
Expand Up @@ -52,8 +52,11 @@ DTSegment4DQuality::DTSegment4DQuality(const ParameterSet& pset) {
rootFileName = pset.getUntrackedParameter<string>("rootFileName");
// the name of the simhit collection
simHitLabel = pset.getUntrackedParameter<InputTag>("simHitLabel");
// the name of the 4D rec hit collection
simHitToken_ = consumes<PSimHitContainer>(pset.getParameter<InputTag>("simHitLabel"));
// the name of the 2D rec hit collection
segment4DLabel = pset.getUntrackedParameter<InputTag>("segment4DLabel");
segment4DToken_ = consumes<DTRecSegment4DCollection>(pset.getParameter<InputTag>("segment4DLabel"));


//sigma resolution on position
sigmaResX = pset.getParameter<double>("sigmaResX");
Expand Down Expand Up @@ -152,7 +155,7 @@ void DTSegment4DQuality::endJob() {

// Get the SimHit collection from the event
edm::Handle<PSimHitContainer> simHits;
event.getByLabel(simHitLabel, simHits); //FIXME: second string to be removed
event.getByToken(simHitToken_, simHits); //FIXME: second string to be removed

//Map simHits by chamber
map<DTChamberId, PSimHitContainer > simHitsPerCh;
Expand All @@ -170,7 +173,7 @@ void DTSegment4DQuality::endJob() {

// Get the 4D rechits from the event
Handle<DTRecSegment4DCollection> segment4Ds;
event.getByLabel(segment4DLabel, segment4Ds);
event.getByToken(segment4DToken_, segment4Ds);

if(!segment4Ds.isValid()) {
if(debug) cout << "[DTSegment4DQuality]**Warning: no 4D Segments with label: " <<segment4DLabel
Expand Down
4 changes: 4 additions & 0 deletions Validation/DTRecHits/plugins/DTSegment4DQuality.h
Expand Up @@ -25,6 +25,8 @@
#include "DQMServices/Core/interface/DQMStore.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"

#include <vector>
#include <map>
Expand Down Expand Up @@ -71,6 +73,8 @@ class DTSegment4DQuality : public edm::EDAnalyzer {
//Labels to read from event
edm::InputTag simHitLabel;
edm::InputTag segment4DLabel;
edm::EDGetTokenT<edm::PSimHitContainer> simHitToken_;
edm::EDGetTokenT<DTRecSegment4DCollection> segment4DToken_;
//Sigma resolution on position
double sigmaResX;
double sigmaResY;
Expand Down

0 comments on commit 3ca6f62

Please sign in to comment.