Skip to content

Commit

Permalink
Merge pull request #3428 from yiiyama/ecal-validation-consumes
Browse files Browse the repository at this point in the history
Consumes -- Ecal validation
  • Loading branch information
ktf committed Apr 23, 2014
2 parents c94b91c + c7a4543 commit 256ad47
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
19 changes: 17 additions & 2 deletions Validation/EcalDigis/src/CollHandle.h
Expand Up @@ -6,6 +6,7 @@

#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

/** Utilitity class for handling an EDM data collection. This class
Expand All @@ -32,16 +33,27 @@ class CollHandle {
CollHandle(const edm::InputTag& tag,
bool failIfNotFound = true,
bool notFoundWarn = true): tag_(tag),
token_(),
currentColl_(&emptyColl_),
notFoundAlreadyWarned_(false),
failIfNotFound_(failIfNotFound),
notFoundWarn_(notFoundWarn){}

//method(s)
public:
/*
Receives the "ConsumesCollector" from the EDAnalyzer and declares the usage
of the collection, as well as storing the token for it.
*/

void setToken(edm::ConsumesCollector& collector)
{
token_ = collector.consumes<T>(tag_);
}

/** Retrieves the collection from the event. If failIfNotFound is true and
* the collection is not found, then an edm::Exception is thrown. For other
* case of exception throw see edm::Event::getByLabel() method documentation.
* case of exception throw see edm::Event::getByToken() method documentation.
* If failIfNotFound is false and the collection is not found, an empty
* collection is used; a warn message will be logged the first time
* the collection is not found.
Expand All @@ -50,7 +62,7 @@ class CollHandle {
void read(const edm::Event& event){
// try{
edm::Handle<T> hColl;
event.getByLabel(tag_, hColl);
event.getByToken(token_, hColl);

//If we must be tolerant to product absence, then
//we must check validaty before calling Handle::operator*
Expand Down Expand Up @@ -92,6 +104,9 @@ class CollHandle {
*/
const edm::InputTag tag_;

/* EDM "Token" that is used in the actual data retrieval */
edm::EDGetTokenT<T> token_;

/** Pointer to the last read collection, points to emptColl be default
*/
const T* currentColl_;
Expand Down
17 changes: 17 additions & 0 deletions Validation/EcalDigis/src/EcalSelectiveReadoutValidation.cc
Expand Up @@ -13,6 +13,7 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
Expand Down Expand Up @@ -138,6 +139,22 @@ EcalSelectiveReadoutValidation::EcalSelectiveReadoutValidation(const ParameterSe
withEeSimHit_(false),
withEbSimHit_(false){

edm::ConsumesCollector collector(consumesCollector());
ebDigis_.setToken(collector);
eeDigis_.setToken(collector);
ebNoZsDigis_.setToken(collector);
eeNoZsDigis_.setToken(collector);
ebSrFlags_.setToken(collector);
eeSrFlags_.setToken(collector);
ebComputedSrFlags_.setToken(collector);
eeComputedSrFlags_.setToken(collector);
ebSimHits_.setToken(collector);
eeSimHits_.setToken(collector);
tps_.setToken(collector);
ebRecHits_.setToken(collector);
eeRecHits_.setToken(collector);
fedRaw_.setToken(collector);

PgTiming t("EcalSelectiveReadoutValidation ctor");

// std::vector<int> excludedFeds =
Expand Down
8 changes: 4 additions & 4 deletions Validation/EcalHits/interface/EcalSimHitsValidation.h
Expand Up @@ -64,11 +64,11 @@ void endJob(void);

private:

std::string HepMCLabel;
std::string g4InfoLabel;
std::string EBHitsCollection;
std::string EEHitsCollection;
std::string ESHitsCollection;
edm::EDGetTokenT<edm::HepMCProduct> HepMCToken;
edm::EDGetTokenT<edm::PCaloHitContainer> EBHitsCollectionToken;
edm::EDGetTokenT<edm::PCaloHitContainer> EEHitsCollectionToken;
edm::EDGetTokenT<edm::PCaloHitContainer> ESHitsCollectionToken;

bool verbose_;

Expand Down
18 changes: 10 additions & 8 deletions Validation/EcalHits/src/EcalSimHitsValidation.cc
Expand Up @@ -9,6 +9,7 @@
#include <DataFormats/EcalDetId/interface/EEDetId.h>
#include <DataFormats/EcalDetId/interface/ESDetId.h>
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "Validation/EcalHits/interface/EcalSimHitsValidation.h"
#include "DQMServices/Core/interface/DQMStore.h"

Expand All @@ -17,11 +18,12 @@ using namespace edm;
using namespace std;

EcalSimHitsValidation::EcalSimHitsValidation(const edm::ParameterSet& ps):
HepMCLabel(ps.getParameter<std::string>("moduleLabelMC")),
g4InfoLabel(ps.getParameter<std::string>("moduleLabelG4")),
EBHitsCollection(ps.getParameter<std::string>("EBHitsCollection")),
EEHitsCollection(ps.getParameter<std::string>("EEHitsCollection")),
ESHitsCollection(ps.getParameter<std::string>("ESHitsCollection")){
HepMCToken(consumes<edm::HepMCProduct>(ps.getParameter<std::string>("moduleLabelMC")))
{
EBHitsCollectionToken = consumes<edm::PCaloHitContainer>(edm::InputTag(g4InfoLabel, ps.getParameter<std::string>("EBHitsCollection")));
EEHitsCollectionToken = consumes<edm::PCaloHitContainer>(edm::InputTag(g4InfoLabel, ps.getParameter<std::string>("EEHitsCollection")));
ESHitsCollectionToken = consumes<edm::PCaloHitContainer>(edm::InputTag(g4InfoLabel, ps.getParameter<std::string>("ESHitsCollection")));

// DQM ROOT output
outputFile_ = ps.getUntrackedParameter<std::string>("outputFile", "");
Expand Down Expand Up @@ -110,10 +112,10 @@ void EcalSimHitsValidation::analyze(const edm::Event& e, const edm::EventSetup&
edm::Handle<edm::PCaloHitContainer> EcalHitsEE;
edm::Handle<edm::PCaloHitContainer> EcalHitsES;

e.getByLabel(HepMCLabel, MCEvt);
e.getByLabel(g4InfoLabel,EBHitsCollection,EcalHitsEB);
e.getByLabel(g4InfoLabel,EEHitsCollection,EcalHitsEE);
e.getByLabel(g4InfoLabel,ESHitsCollection,EcalHitsES);
e.getByToken(HepMCToken, MCEvt);
e.getByToken(EBHitsCollectionToken, EcalHitsEB);
e.getByToken(EEHitsCollectionToken, EcalHitsEE);
e.getByToken(ESHitsCollectionToken, EcalHitsES);

for ( HepMC::GenEvent::particle_const_iterator p = MCEvt->GetEvent()->particles_begin();
p != MCEvt->GetEvent()->particles_end(); ++p ) {
Expand Down

0 comments on commit 256ad47

Please sign in to comment.