Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Alignment/MuonAlignment/interface/MuonAlignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class MuonAlignment {
public:
MuonAlignment(const edm::EventSetup& iSetup);
MuonAlignment(const edm::EventSetup& iSetup, edm::ConsumesCollector iC);
Copy link
Contributor

@makortel makortel Oct 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem lies here. As the error message says, all consumes declarations must be done in EDModule (or ESProducer) constructor, or in functions called from the constructor. Therefore, any function that takes EventSetup (not available at module construction time) and ConsumesCollector (not usable outside module construction time) will not work.

This implies that the code needs to be organized differently. Based on a quick look on how MuonAlignment is used, I'd look into moving the construction of MuonAlignment to the constructors of the EDModules, and passing in the EventSetup in a member function call instead of the constructor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hyunyong any updates on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hyunyong any updates on this?
I'm testing and validating updates.
I will close this PR and make a new one.


MuonAlignment(const edm::EventSetup& iSetup, const MuonAlignmentInputMethod& input);

Expand All @@ -45,7 +45,7 @@ class MuonAlignment {
void fillGapsInSurvey(double shiftErr, double angleErr);
void copySurveyToAlignment();

void writeXML(const edm::ParameterSet& iConfig, const edm::EventSetup& iSetup);
void writeXML(const edm::ParameterSet& iConfig, const edm::EventSetup& iSetup, edm::ConsumesCollector);

void saveDTSurveyToDB();
void saveCSCSurveyToDB();
Expand All @@ -66,9 +66,9 @@ class MuonAlignment {
std::string theDTSurveyRecordName, theDTSurveyErrorRecordName;
std::string theCSCSurveyRecordName, theCSCSurveyErrorRecordName;

edm::ESGetToken<DTGeometry, MuonGeometryRecord> esTokenDT_;
edm::ESGetToken<CSCGeometry, MuonGeometryRecord> esTokenCSC_;
edm::ESGetToken<GEMGeometry, MuonGeometryRecord> esTokenGEM_;
const edm::ESGetToken<DTGeometry, MuonGeometryRecord> esTokenDT_;
const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> esTokenCSC_;
const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> esTokenGEM_;

align::Scalars displacements;

Expand Down
40 changes: 29 additions & 11 deletions Alignment/MuonAlignment/interface/MuonAlignmentInputDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,26 @@
// $Id: MuonAlignmentInputDB.h,v 1.1 2008/03/15 20:26:46 pivarski Exp $
//

// system include files

// user include files
#include "Alignment/MuonAlignment/interface/MuonAlignmentInputMethod.h"

// forward declarations
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "CondFormats/Alignment/interface/Alignments.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h"
#include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorRcd.h"
#include "CondFormats/AlignmentRecord/interface/CSCAlignmentRcd.h"
#include "CondFormats/AlignmentRecord/interface/CSCAlignmentErrorRcd.h"
#include "CondFormats/AlignmentRecord/interface/GEMAlignmentRcd.h"
#include "CondFormats/AlignmentRecord/interface/GEMAlignmentErrorRcd.h"

class MuonAlignmentInputDB : public MuonAlignmentInputMethod {
public:
MuonAlignmentInputDB();
MuonAlignmentInputDB(
std::string dtLabel, std::string cscLabel, std::string gemLabel, std::string idealLabel, bool getAPEs);
MuonAlignmentInputDB(edm::ConsumesCollector iC);
MuonAlignmentInputDB(std::string dtLabel,
std::string cscLabel,
std::string gemLabel,
std::string idealLabel,
bool getAPEs,
edm::ConsumesCollector iC);
~MuonAlignmentInputDB() override;

// ---------- const member functions ---------------------
Expand All @@ -47,9 +55,19 @@ class MuonAlignmentInputDB : public MuonAlignmentInputMethod {

private:
// ---------- member data --------------------------------

std::string m_dtLabel, m_cscLabel, m_gemLabel, idealGeometryLabel;
bool m_getAPEs;
const std::string m_dtLabel, m_cscLabel, m_gemLabel, idealGeometryLabel;
const bool m_getAPEs;

const edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken_;
const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken_;
const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemGeomToken_;
const edm::ESGetToken<Alignments, DTAlignmentRcd> dtAliToken_;
const edm::ESGetToken<Alignments, CSCAlignmentRcd> cscAliToken_;
const edm::ESGetToken<Alignments, GEMAlignmentRcd> gemAliToken_;
const edm::ESGetToken<AlignmentErrorsExtended, DTAlignmentErrorExtendedRcd> dtAliErrToken_;
const edm::ESGetToken<AlignmentErrorsExtended, CSCAlignmentErrorExtendedRcd> cscAliErrToken_;
const edm::ESGetToken<AlignmentErrorsExtended, GEMAlignmentErrorExtendedRcd> gemAliErrToken_;
const edm::ESGetToken<Alignments, GlobalPositionRcd> gprToken_;
};

#endif
15 changes: 9 additions & 6 deletions Alignment/MuonAlignment/interface/MuonAlignmentInputMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@
#include <memory>

#include "FWCore/Framework/interface/EventSetup.h"

#include "FWCore/Framework/interface/ConsumesCollector.h"
// user include files
#include "Alignment/MuonAlignment/interface/AlignableMuon.h"
#include "Geometry/DTGeometry/interface/DTGeometry.h"
#include "Geometry/CSCGeometry/interface/CSCGeometry.h"

#include "Geometry/Records/interface/MuonGeometryRecord.h"
// forward declarations

class MuonAlignmentInputMethod {
public:
MuonAlignmentInputMethod();
MuonAlignmentInputMethod(std::string idealLabel);
MuonAlignmentInputMethod(edm::ConsumesCollector iC);
MuonAlignmentInputMethod(std::string idealLabel, edm::ConsumesCollector iC);
virtual ~MuonAlignmentInputMethod();

// ---------- const member functions ---------------------
Expand All @@ -51,7 +50,11 @@ class MuonAlignmentInputMethod {

private:
// ---------- member data --------------------------------
std::string idealGeometryLabel;
const std::string idealGeometryLabel;

const edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken_;
const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken_;
const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemGeomToken_;
};

#endif
26 changes: 21 additions & 5 deletions Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,25 @@
// system include files

// user include files
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "Alignment/MuonAlignment/interface/MuonAlignmentInputMethod.h"
#include "Alignment/CommonAlignment/interface/SurveyDet.h"
#include "CondFormats/Alignment/interface/Alignments.h"
#include "CondFormats/Alignment/interface/SurveyErrors.h"

#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "CondFormats/AlignmentRecord/interface/DTSurveyRcd.h"
#include "CondFormats/AlignmentRecord/interface/DTSurveyErrorExtendedRcd.h"
#include "CondFormats/AlignmentRecord/interface/CSCSurveyRcd.h"
#include "CondFormats/AlignmentRecord/interface/CSCSurveyErrorExtendedRcd.h"
// forward declarations

class MuonAlignmentInputSurveyDB : public MuonAlignmentInputMethod {
public:
MuonAlignmentInputSurveyDB();
MuonAlignmentInputSurveyDB(std::string dtLabel, std::string cscLabel, std::string idealLabel);
MuonAlignmentInputSurveyDB(edm::ConsumesCollector iC);
MuonAlignmentInputSurveyDB(std::string dtLabel,
std::string cscLabel,
std::string idealLabel,
edm::ConsumesCollector iC);
~MuonAlignmentInputSurveyDB() override;

// ---------- const member functions ---------------------
Expand All @@ -53,8 +62,15 @@ class MuonAlignmentInputSurveyDB : public MuonAlignmentInputMethod {
const SurveyErrors* theSurveyErrors) const;

// ---------- member data --------------------------------

std::string m_dtLabel, m_cscLabel, idealGeometryLabel;
const std::string m_dtLabel, m_cscLabel, idealGeometryLabel;

const edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken_;
const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken_;
const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemGeomToken_;
const edm::ESGetToken<Alignments, DTSurveyRcd> dtSurveyToken_;
const edm::ESGetToken<SurveyErrors, DTSurveyErrorExtendedRcd> dtSurvErrorToken_;
const edm::ESGetToken<Alignments, CSCSurveyRcd> cscSurveyToken_;
const edm::ESGetToken<SurveyErrors, CSCSurveyErrorExtendedRcd> cscSurvErrorToken_;
};

#endif
11 changes: 8 additions & 3 deletions Alignment/MuonAlignment/interface/MuonAlignmentInputXML.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
#include "xercesc/util/XercesDefs.hpp"

// user include files
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "Alignment/MuonAlignment/interface/MuonAlignmentInputMethod.h"
#include "Alignment/CommonAlignment/interface/Alignable.h"

#include "Geometry/Records/interface/MuonGeometryRecord.h"
// forward declarations

class MuonAlignmentInputXML : public MuonAlignmentInputMethod {
public:
MuonAlignmentInputXML(const std::string &fileName, std::string idealLabel);
MuonAlignmentInputXML(const std::string &fileName, std::string idealLabel, edm::ConsumesCollector iC);
~MuonAlignmentInputXML() override;

// ---------- const member functions ---------------------
Expand Down Expand Up @@ -96,7 +97,11 @@ class MuonAlignmentInputXML : public MuonAlignmentInputMethod {
std::map<Alignable *, Alignable *> &alitoideal) const;

// ---------- member data --------------------------------
std::string m_fileName, idealGeometryLabel;
const std::string m_fileName, idealGeometryLabel;

const edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken_;
const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken_;
const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemGeomToken_;

XMLCh *str_operation;
XMLCh *str_collection;
Expand Down
12 changes: 9 additions & 3 deletions Alignment/MuonAlignment/interface/MuonAlignmentOutputXML.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/EventSetup.h"

#include "FWCore/Framework/interface/ConsumesCollector.h"
// user include files
#include "Alignment/MuonAlignment/interface/AlignableMuon.h"
#include "CondFormats/Alignment/interface/AlignTransformErrorExtended.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"

// forward declarations
class AlignableObjectId;

class MuonAlignmentOutputXML {
public:
MuonAlignmentOutputXML(const edm::ParameterSet &iConfig);
MuonAlignmentOutputXML(const edm::ParameterSet &iConfig, edm::ConsumesCollector iC);
virtual ~MuonAlignmentOutputXML();

// ---------- const member functions ---------------------
Expand Down Expand Up @@ -65,7 +66,12 @@ class MuonAlignmentOutputXML {
bool m_suppressDTBarrel, m_suppressDTWheels, m_suppressDTStations, m_suppressDTChambers, m_suppressDTSuperLayers,
m_suppressDTLayers;
bool m_suppressCSCEndcaps, m_suppressCSCStations, m_suppressCSCRings, m_suppressCSCChambers, m_suppressCSCLayers;
std::string idealGeometryLabel;

const std::string idealGeometryLabel;

const edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken_;
const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken_;
const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemGeomToken_;
};

#endif
9 changes: 5 additions & 4 deletions Alignment/MuonAlignment/plugins/MuonGeometryArrange.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ MuonGeometryArrange::MuonGeometryArrange(const edm::ParameterSet& cfg)
firstEvent_(true),
idealInputLabel1("MuonGeometryArrangeLabel1"),
idealInputLabel2("MuonGeometryArrangeLabel2"),
idealInputLabel2a("MuonGeometryArrangeLabel2a") {
idealInputLabel2a("MuonGeometryArrangeLabel2a"),
m_cc(consumesCollector()) {
referenceMuon = nullptr;
currentMuon = nullptr;
// Input is XML
Expand Down Expand Up @@ -623,13 +624,13 @@ void MuonGeometryArrange::createROOTGeometry(const edm::EventSetup& iSetup) {}
void MuonGeometryArrange::analyze(const edm::Event&, const edm::EventSetup& iSetup) {
if (firstEvent_) {
// My stuff
MuonAlignmentInputXML inputMethod1(_inputXMLCurrent, idealInputLabel1);
MuonAlignmentInputXML inputMethod1(_inputXMLCurrent, idealInputLabel1, m_cc);
inputAlign1 = new MuonAlignment(iSetup, inputMethod1);
inputAlign1->fillGapsInSurvey(0, 0);
MuonAlignmentInputXML inputMethod2(_inputXMLReference, idealInputLabel2);
MuonAlignmentInputXML inputMethod2(_inputXMLReference, idealInputLabel2, m_cc);
inputAlign2 = new MuonAlignment(iSetup, inputMethod2);
inputAlign2->fillGapsInSurvey(0, 0);
MuonAlignmentInputXML inputMethod2a(_inputXMLReference, idealInputLabel2a);
MuonAlignmentInputXML inputMethod2a(_inputXMLReference, idealInputLabel2a, m_cc);
inputAlign2a = new MuonAlignment(iSetup, inputMethod2a);
inputAlign2a->fillGapsInSurvey(0, 0);

Expand Down
4 changes: 3 additions & 1 deletion Alignment/MuonAlignment/plugins/MuonGeometryArrange.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ class MuonGeometryArrange : public edm::EDAnalyzer {

bool firstEvent_;

std::string idealInputLabel1, idealInputLabel2, idealInputLabel2a;
const std::string idealInputLabel1, idealInputLabel2, idealInputLabel2a;

edm::ConsumesCollector m_cc;
};

#endif
22 changes: 13 additions & 9 deletions Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ class MuonGeometryDBConverter : public edm::one::EDAnalyzer<> {

edm::ParameterSet m_misalignmentScenario;
edm::ParameterSet m_outputXML;
std::string idealGeometryLabelForInputMethod, idealGeometryLabelForInputDB, idealGeometryLabelForInputXML,

const std::string idealGeometryLabelForInputMethod, idealGeometryLabelForInputDB, idealGeometryLabelForInputXML,
idealGeometryLabelForInputSurveyDB;

edm::ConsumesCollector m_cc;
};

//
Expand All @@ -86,15 +89,15 @@ MuonGeometryDBConverter::MuonGeometryDBConverter(const edm::ParameterSet &iConfi
idealGeometryLabelForInputMethod("idealForInputMethod"),
idealGeometryLabelForInputDB("idealForInputDB"),
idealGeometryLabelForInputXML("idealForInputXML"),
idealGeometryLabelForInputSurveyDB("idealForInputSurveyDB") {
idealGeometryLabelForInputSurveyDB("idealForInputSurveyDB"),
m_cc(consumesCollector()) {
////////////////////////////////////////////////////////////////////
// Version V02-03-02 and earlier of this module had support for //
// "cfg" as an input/output format. It turns out that reading //
// thousands of parameters from a configuration file takes a very //
// long time, so "cfg" wasn't very practical. When I reorganized //
// the code, I didn't bother to port it. //
////////////////////////////////////////////////////////////////////

if (m_input == std::string("ideal")) {
}

Expand Down Expand Up @@ -155,27 +158,28 @@ void MuonGeometryDBConverter::analyze(const edm::Event &iEvent, const edm::Event
MuonAlignment *muonAlignment = nullptr;

if (m_input == std::string("ideal")) {
MuonAlignmentInputMethod inputMethod;
MuonAlignmentInputMethod inputMethod(m_cc);
muonAlignment = new MuonAlignment(iSetup, inputMethod);
muonAlignment->fillGapsInSurvey(0., 0.);
}

else if (m_input == std::string("db")) {
MuonAlignmentInputDB inputMethod(m_dtLabel, m_cscLabel, m_gemLabel, idealGeometryLabelForInputDB, m_getAPEs);
MuonAlignmentInputDB inputMethod(
m_dtLabel, m_cscLabel, m_gemLabel, idealGeometryLabelForInputDB, m_getAPEs, m_cc);
muonAlignment = new MuonAlignment(iSetup, inputMethod);
if (m_getAPEs) {
muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr);
}
}

else if (m_input == std::string("surveydb")) {
MuonAlignmentInputSurveyDB inputMethod(m_dtLabel, m_cscLabel, idealGeometryLabelForInputSurveyDB);
MuonAlignmentInputSurveyDB inputMethod(m_dtLabel, m_cscLabel, idealGeometryLabelForInputSurveyDB, m_cc);
muonAlignment = new MuonAlignment(iSetup, inputMethod);
muonAlignment->copySurveyToAlignment();
}

else if (m_input == std::string("scenario")) {
MuonAlignmentInputMethod inputMethod;
MuonAlignmentInputMethod inputMethod(m_cc);
muonAlignment = new MuonAlignment(iSetup, inputMethod);

MuonScenarioBuilder muonScenarioBuilder(muonAlignment->getAlignableMuon());
Expand All @@ -184,7 +188,7 @@ void MuonGeometryDBConverter::analyze(const edm::Event &iEvent, const edm::Event
}

else if (m_input == std::string("xml")) {
MuonAlignmentInputXML inputMethod(m_fileName, idealGeometryLabelForInputXML);
MuonAlignmentInputXML inputMethod(m_fileName, idealGeometryLabelForInputXML, m_cc);
muonAlignment = new MuonAlignment(iSetup, inputMethod);
muonAlignment->fillGapsInSurvey(m_shiftErr, m_angleErr);
}
Expand All @@ -204,7 +208,7 @@ void MuonGeometryDBConverter::analyze(const edm::Event &iEvent, const edm::Event
}

else if (m_output == std::string("xml")) {
muonAlignment->writeXML(m_outputXML, iSetup);
muonAlignment->writeXML(m_outputXML, iSetup, m_cc);
}

delete muonAlignment;
Expand Down
6 changes: 4 additions & 2 deletions Alignment/MuonAlignment/plugins/MuonGeometrySVGTemplate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class MuonGeometrySVGTemplate : public edm::EDAnalyzer {
void analyze(const edm::Event &, const edm::EventSetup &iConfig) override;

std::string m_wheelTemplateName;

edm::ConsumesCollector m_cc;
// std::string m_disk1TemplateName;
// std::string m_disk23TemplateName;
// std::string m_diskp4TemplateName;
Expand All @@ -71,14 +73,14 @@ class MuonGeometrySVGTemplate : public edm::EDAnalyzer {
//

MuonGeometrySVGTemplate::MuonGeometrySVGTemplate(const edm::ParameterSet &iConfig)
: m_wheelTemplateName(iConfig.getParameter<std::string>("wheelTemplateName")) {}
: m_wheelTemplateName(iConfig.getParameter<std::string>("wheelTemplateName")), m_cc(consumesCollector()) {}

MuonGeometrySVGTemplate::~MuonGeometrySVGTemplate() {}

// ------------ method called to for each event ------------
void MuonGeometrySVGTemplate::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
// loads ideal geometry
MuonAlignmentInputMethod inputMethod;
MuonAlignmentInputMethod inputMethod(m_cc);
MuonAlignment muonAlignment(iSetup, inputMethod);
AlignableNavigator *alignableNavigator = muonAlignment.getAlignableNavigator();

Expand Down
Loading