Skip to content

Commit

Permalink
Merge pull request #12 from cms-sw/master
Browse files Browse the repository at this point in the history
update master
  • Loading branch information
kskovpen authored Nov 9, 2021
2 parents 06672d1 + 4751d32 commit 6263c5a
Show file tree
Hide file tree
Showing 1,376 changed files with 29,087 additions and 23,566 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def getSequence(process, collection,
"minimumHits": 10,
})
elif collection in ("ALCARECOTkAlCosmicsCTF0T",
"ALCARECOTkAlCosmicsCosmicTF0T",
"ALCARECOTkAlCosmicsInCollisions"):
isCosmics = True
options["TrackSelector"]["HighPurity"] = {} # drop high purity cut
Expand Down Expand Up @@ -336,7 +337,7 @@ def getSequence(process, collection,
**(mod[2])), src
modules.append(getattr(process, src))
else:
if mods[-1][-1]["method"] is "load" and \
if mods[-1][-1]["method"] == "load" and \
not mods[-1][-1].get("clone", False):
print("Name of the last module needs to be modifiable.")
sys.exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "FWCore/PluginManager/interface/PluginFactory.h"
#include "Alignment/CommonAlignmentAlgorithm/interface/IntegratedCalibrationBase.h"

typedef edmplugin::PluginFactory<IntegratedCalibrationBase*(const edm::ParameterSet&)>
typedef edmplugin::PluginFactory<IntegratedCalibrationBase *(const edm::ParameterSet &, edm::ConsumesCollector &)>
IntegratedCalibrationPluginFactory;

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
Expand All @@ -37,6 +36,7 @@
#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

#include "TTree.h"
#include "TFile.h"
Expand All @@ -54,7 +54,7 @@
class SiPixelLorentzAngleCalibration : public IntegratedCalibrationBase {
public:
/// Constructor
explicit SiPixelLorentzAngleCalibration(const edm::ParameterSet &cfg);
explicit SiPixelLorentzAngleCalibration(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC);

/// Destructor
~SiPixelLorentzAngleCalibration() override = default;
Expand Down Expand Up @@ -116,7 +116,8 @@ class SiPixelLorentzAngleCalibration : public IntegratedCalibrationBase {
const std::string outFileName_;
const std::vector<std::string> mergeFileNames_;
const std::string lorentzAngleLabel_;

const edm::ESGetToken<SiPixelLorentzAngle, SiPixelLorentzAngleRcd> lorentzAngleToken_;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
edm::ESWatcher<SiPixelLorentzAngleRcd> watchLorentzAngleRcd_;

// const AlignableTracker *alignableTracker_;
Expand All @@ -134,13 +135,15 @@ class SiPixelLorentzAngleCalibration : public IntegratedCalibrationBase {
//======================================================================
//======================================================================

SiPixelLorentzAngleCalibration::SiPixelLorentzAngleCalibration(const edm::ParameterSet &cfg)
SiPixelLorentzAngleCalibration::SiPixelLorentzAngleCalibration(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
: IntegratedCalibrationBase(cfg),
saveToDB_(cfg.getParameter<bool>("saveToDB")),
recordNameDBwrite_(cfg.getParameter<std::string>("recordNameDBwrite")),
outFileName_(cfg.getParameter<std::string>("treeFile")),
mergeFileNames_(cfg.getParameter<std::vector<std::string> >("mergeTreeFiles")),
lorentzAngleLabel_(cfg.getParameter<std::string>("lorentzAngleLabel")),
lorentzAngleToken_(iC.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", lorentzAngleLabel_))),
magFieldToken_(iC.esConsumes()),
moduleGroupSelCfg_(cfg.getParameter<edm::ParameterSet>("LorentzAngleModuleGroups")) {}

//======================================================================
Expand All @@ -165,9 +168,9 @@ void SiPixelLorentzAngleCalibration::beginRun(const edm::Run &run, const edm::Ev
}
}

edm::ESHandle<SiPixelLorentzAngle> lorentzAngleHandle;
const SiPixelLorentzAngle *lorentzAngleHandle = &setup.getData(lorentzAngleToken_);
const auto &lorentzAngleRcd = setup.get<SiPixelLorentzAngleRcd>();
lorentzAngleRcd.get(lorentzAngleLabel_, lorentzAngleHandle);

if (cachedLorentzAngleInputs_.find(firstRun) == cachedLorentzAngleInputs_.end()) {
cachedLorentzAngleInputs_.emplace(firstRun, SiPixelLorentzAngle(*lorentzAngleHandle));
} else {
Expand Down Expand Up @@ -202,8 +205,8 @@ unsigned int SiPixelLorentzAngleCalibration::derivatives(std::vector<ValuesIndex
const int index =
moduleGroupSelector_->getParameterIndexFromDetId(hit.det()->geographicalId(), eventInfo.eventId().run());
if (index >= 0) { // otherwise not treated
edm::ESHandle<MagneticField> magneticField;
setup.get<IdealMagneticFieldRecord>().get(magneticField);

const MagneticField *magneticField = &setup.getData(magFieldToken_);
const GlobalVector bField(magneticField->inTesla(hit.det()->surface().position()));
const LocalVector bFieldLocal(hit.det()->surface().toLocal(bField));
const double dZ = hit.det()->surface().bounds().thickness(); // it is a float only...
Expand Down Expand Up @@ -337,7 +340,7 @@ void SiPixelLorentzAngleCalibration::endOfJob() {
if (saveToDB_) { // If requested, write out to DB
edm::Service<cond::service::PoolDBOutputService> dbService;
if (dbService.isAvailable()) {
dbService->writeOne(&output, firstRunOfIOV, recordNameDBwrite_);
dbService->writeOneIOV(output, firstRunOfIOV, recordNameDBwrite_);
} else {
edm::LogError("BadConfig") << "@SUB=SiPixelLorentzAngleCalibration::endOfJob"
<< "No PoolDBOutputService available, but saveToDB true!";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/SiStripDetId/interface/SiStripDetId.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand All @@ -39,6 +38,7 @@
#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

#include "TTree.h"
#include "TFile.h"
Expand All @@ -54,7 +54,7 @@
class SiStripBackplaneCalibration : public IntegratedCalibrationBase {
public:
/// Constructor
explicit SiStripBackplaneCalibration(const edm::ParameterSet &cfg);
explicit SiStripBackplaneCalibration(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC);

/// Destructor
~SiStripBackplaneCalibration() override;
Expand Down Expand Up @@ -135,13 +135,17 @@ class SiStripBackplaneCalibration : public IntegratedCalibrationBase {

TkModuleGroupSelector *moduleGroupSelector_;
const edm::ParameterSet moduleGroupSelCfg_;
const edm::ESGetToken<SiStripLatency, SiStripLatencyRcd> latencyToken_;
const edm::ESGetToken<SiStripLorentzAngle, SiStripLorentzAngleRcd> lorentzAngleToken_;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
const edm::ESGetToken<SiStripBackPlaneCorrection, SiStripBackPlaneCorrectionRcd> backPlaneCorrToken_;
};

//======================================================================
//======================================================================
//======================================================================

SiStripBackplaneCalibration::SiStripBackplaneCalibration(const edm::ParameterSet &cfg)
SiStripBackplaneCalibration::SiStripBackplaneCalibration(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
: IntegratedCalibrationBase(cfg),
readoutModeName_(cfg.getParameter<std::string>("readoutMode")),
saveToDB_(cfg.getParameter<bool>("saveToDB")),
Expand All @@ -150,7 +154,11 @@ SiStripBackplaneCalibration::SiStripBackplaneCalibration(const edm::ParameterSet
mergeFileNames_(cfg.getParameter<std::vector<std::string> >("mergeTreeFiles")),
siStripBackPlaneCorrInput_(nullptr),
moduleGroupSelector_(nullptr),
moduleGroupSelCfg_(cfg.getParameter<edm::ParameterSet>("BackplaneModuleGroups")) {
moduleGroupSelCfg_(cfg.getParameter<edm::ParameterSet>("BackplaneModuleGroups")),
latencyToken_(iC.esConsumes()),
lorentzAngleToken_(iC.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", readoutModeName_))),
magFieldToken_(iC.esConsumes()),
backPlaneCorrToken_(iC.esConsumes(edm::ESInputTag("", readoutModeName_))) {
// SiStripLatency::singleReadOutMode() returns
// 1: all in peak, 0: all in deco, -1: mixed state
// (in principle one could treat even mixed state APV by APV...)
Expand Down Expand Up @@ -187,8 +195,7 @@ unsigned int SiStripBackplaneCalibration::derivatives(std::vector<ValuesIndexPai

outDerivInds.clear();

edm::ESHandle<SiStripLatency> latency;
setup.get<SiStripLatencyRcd>().get(latency);
const SiStripLatency *latency = &setup.getData(latencyToken_);
const int16_t mode = latency->singleReadOutMode();

if (mode == readoutMode_) {
Expand All @@ -197,16 +204,14 @@ unsigned int SiStripBackplaneCalibration::derivatives(std::vector<ValuesIndexPai
const int index =
moduleGroupSelector_->getParameterIndexFromDetId(hit.det()->geographicalId(), eventInfo.eventId().run());
if (index >= 0) { // otherwise not treated
edm::ESHandle<MagneticField> magneticField;
setup.get<IdealMagneticFieldRecord>().get(magneticField);
const MagneticField *magneticField = &setup.getData(magFieldToken_);
const GlobalVector bField(magneticField->inTesla(hit.det()->surface().position()));
const LocalVector bFieldLocal(hit.det()->surface().toLocal(bField));
//std::cout << "SiStripBackplaneCalibration derivatives " << readoutModeName_ << std::endl;
const double dZ = hit.det()->surface().bounds().thickness(); // it's a float only...
const double tanPsi = tsos.localParameters().mixedFormatVector()[1]; //float...

edm::ESHandle<SiStripLorentzAngle> lorentzAngleHandle;
setup.get<SiStripLorentzAngleRcd>().get(readoutModeName_, lorentzAngleHandle);
const SiStripLorentzAngle *lorentzAngleHandle = &setup.getData(lorentzAngleToken_);
// Yes, mobility (= LA/By) stored in object called LA...
const double mobility = lorentzAngleHandle->getLorentzAngle(hit.det()->geographicalId());
// shift due to dead back plane has two parts:
Expand Down Expand Up @@ -393,16 +398,17 @@ void SiStripBackplaneCalibration::endOfJob() {
//======================================================================
bool SiStripBackplaneCalibration::checkBackPlaneCorrectionInput(const edm::EventSetup &setup,
const EventInfo &eventInfo) {
edm::ESHandle<SiStripBackPlaneCorrection> backPlaneCorrHandle;
const SiStripBackPlaneCorrection *backPlaneCorrHandle = nullptr;
if (!siStripBackPlaneCorrInput_) {
setup.get<SiStripBackPlaneCorrectionRcd>().get(readoutModeName_, backPlaneCorrHandle);
backPlaneCorrHandle = &setup.getData(backPlaneCorrToken_);
siStripBackPlaneCorrInput_ = new SiStripBackPlaneCorrection(*backPlaneCorrHandle);
// FIXME: Should we call 'watchBackPlaneCorrRcd_.check(setup)' as well?
// Otherwise could be that next check has to check via following 'else', though
// no new IOV has started... (to be checked)
} else {
if (watchBackPlaneCorrRcd_.check(setup)) { // new IOV of input - but how to check peak vs deco?
setup.get<SiStripBackPlaneCorrectionRcd>().get(readoutModeName_, backPlaneCorrHandle);
backPlaneCorrHandle = &setup.getData(backPlaneCorrToken_);

if (backPlaneCorrHandle->getBackPlaneCorrections() // but only bad if non-identical values
!= siStripBackPlaneCorrInput_->getBackPlaneCorrections()) { // (comparing maps)
// Maps are containers sorted by key, but comparison problems may arise from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/SiStripDetId/interface/SiStripDetId.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
Expand All @@ -53,7 +53,7 @@
class SiStripLorentzAngleCalibration : public IntegratedCalibrationBase {
public:
/// Constructor
explicit SiStripLorentzAngleCalibration(const edm::ParameterSet &cfg);
explicit SiStripLorentzAngleCalibration(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC);

/// Destructor
~SiStripLorentzAngleCalibration() override = default;
Expand Down Expand Up @@ -130,20 +130,29 @@ class SiStripLorentzAngleCalibration : public IntegratedCalibrationBase {

std::unique_ptr<TkModuleGroupSelector> moduleGroupSelector_;
const edm::ParameterSet moduleGroupSelCfg_;

const edm::ESGetToken<SiStripLatency, SiStripLatencyRcd> latencyToken_;
const edm::ESGetToken<SiStripLorentzAngle, SiStripLorentzAngleRcd> lorentzAngleToken_;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
const edm::ESGetToken<SiStripBackPlaneCorrection, SiStripBackPlaneCorrectionRcd> backPlaneCorrToken_;
};

//======================================================================
//======================================================================
//======================================================================

SiStripLorentzAngleCalibration::SiStripLorentzAngleCalibration(const edm::ParameterSet &cfg)
SiStripLorentzAngleCalibration::SiStripLorentzAngleCalibration(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
: IntegratedCalibrationBase(cfg),
readoutModeName_(cfg.getParameter<std::string>("readoutMode")),
saveToDB_(cfg.getParameter<bool>("saveToDB")),
recordNameDBwrite_(cfg.getParameter<std::string>("recordNameDBwrite")),
outFileName_(cfg.getParameter<std::string>("treeFile")),
mergeFileNames_(cfg.getParameter<std::vector<std::string> >("mergeTreeFiles")),
moduleGroupSelCfg_(cfg.getParameter<edm::ParameterSet>("LorentzAngleModuleGroups")) {
moduleGroupSelCfg_(cfg.getParameter<edm::ParameterSet>("LorentzAngleModuleGroups")),
latencyToken_(iC.esConsumes()),
lorentzAngleToken_(iC.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", readoutModeName_))),
magFieldToken_(iC.esConsumes()),
backPlaneCorrToken_(iC.esConsumes(edm::ESInputTag("", readoutModeName_))) {
// SiStripLatency::singleReadOutMode() returns
// 1: all in peak, 0: all in deco, -1: mixed state
// (in principle one could treat even mixed state APV by APV...)
Expand Down Expand Up @@ -180,9 +189,8 @@ void SiStripLorentzAngleCalibration::beginRun(const edm::Run &run, const edm::Ev
}
}

edm::ESHandle<SiStripLorentzAngle> lorentzAngleHandle;
const SiStripLorentzAngle *lorentzAngleHandle = &setup.getData(lorentzAngleToken_);
const auto &lorentzAngleRcd = setup.get<SiStripLorentzAngleRcd>();
lorentzAngleRcd.get(readoutModeName_, lorentzAngleHandle);
if (cachedLorentzAngleInputs_.find(firstRun) == cachedLorentzAngleInputs_.end()) {
cachedLorentzAngleInputs_.emplace(firstRun, SiStripLorentzAngle(*lorentzAngleHandle));
} else {
Expand Down Expand Up @@ -212,17 +220,15 @@ unsigned int SiStripLorentzAngleCalibration::derivatives(std::vector<ValuesIndex
const EventInfo &eventInfo) const {
outDerivInds.clear();

edm::ESHandle<SiStripLatency> latency;
setup.get<SiStripLatencyRcd>().get(latency);
const SiStripLatency *latency = &setup.getData(latencyToken_);
const int16_t mode = latency->singleReadOutMode();
if (mode == readoutMode_) {
if (hit.det()) { // otherwise 'constraint hit' or whatever

const int index =
moduleGroupSelector_->getParameterIndexFromDetId(hit.det()->geographicalId(), eventInfo.eventId().run());
if (index >= 0) { // otherwise not treated
edm::ESHandle<MagneticField> magneticField;
setup.get<IdealMagneticFieldRecord>().get(magneticField);
const MagneticField *magneticField = &setup.getData(magFieldToken_);
const GlobalVector bField(magneticField->inTesla(hit.det()->surface().position()));
const LocalVector bFieldLocal(hit.det()->surface().toLocal(bField));
const double dZ = this->effectiveThickness(hit.det(), mode, setup);
Expand Down Expand Up @@ -377,7 +383,7 @@ void SiStripLorentzAngleCalibration::endOfJob() {
if (saveToDB_) { // If requested, write out to DB
edm::Service<cond::service::PoolDBOutputService> dbService;
if (dbService.isAvailable()) {
dbService->writeOne(&output, firstRunOfIOV, recordNameDBwrite_);
dbService->writeOneIOV(output, firstRunOfIOV, recordNameDBwrite_);
} else {
edm::LogError("BadConfig") << "@SUB=SiStripLorentzAngleCalibration::endOfJob"
<< "No PoolDBOutputService available, but saveToDB true!";
Expand All @@ -394,10 +400,9 @@ double SiStripLorentzAngleCalibration::effectiveThickness(const GeomDet *det,
return 0.;
double dZ = det->surface().bounds().thickness(); // it is a float only...
const SiStripDetId id(det->geographicalId());
edm::ESHandle<SiStripBackPlaneCorrection> backPlaneHandle;
const SiStripBackPlaneCorrection *backPlaneHandle = &setup.getData(backPlaneCorrToken_);
// FIXME: which one? DepRcd->get(handle) or Rcd->get(readoutModeName_, handle)??
// setup.get<SiStripBackPlaneCorrectionDepRcd>().get(backPlaneHandle); // get correct mode
setup.get<SiStripBackPlaneCorrectionRcd>().get(readoutModeName_, backPlaneHandle);
const double bpCor = backPlaneHandle->getBackPlaneCorrection(id); // it's a float...
// std::cout << "bpCor " << bpCor << " in subdet " << id.subdetId() << std::endl;
dZ *= (1. - bpCor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class AlignmentMonitorMuonSystemMap1D : public AlignmentMonitorBase {
const edm::ESGetToken<DetIdAssociator, DetIdAssociatorRecord> m_esTokenDetId;
const edm::ESGetToken<Propagator, TrackingComponentsRecord> m_esTokenProp;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> m_esTokenMF;
const MuonResidualsFromTrack::BuilderToken m_esTokenBuilder;

// parameters
edm::InputTag m_muonCollectionTag;
Expand Down Expand Up @@ -155,6 +156,7 @@ AlignmentMonitorMuonSystemMap1D::AlignmentMonitorMuonSystemMap1D(const edm::Para
m_esTokenDetId(iC.esConsumes(edm::ESInputTag("", "MuonDetIdAssociator"))),
m_esTokenProp(iC.esConsumes(edm::ESInputTag("", "SteppingHelixPropagatorAny"))),
m_esTokenMF(iC.esConsumes()),
m_esTokenBuilder(iC.esConsumes(MuonResidualsFromTrack::builderESInputTag())),
m_muonCollectionTag(cfg.getParameter<edm::InputTag>("muonCollectionTag")),
m_minTrackPt(cfg.getParameter<double>("minTrackPt")),
m_maxTrackPt(cfg.getParameter<double>("maxTrackPt")),
Expand Down Expand Up @@ -271,6 +273,7 @@ void AlignmentMonitorMuonSystemMap1D::event(const edm::Event &iEvent,
const DetIdAssociator *muonDetIdAssociator_ = &iSetup.getData(m_esTokenDetId);
const Propagator *prop = &iSetup.getData(m_esTokenProp);
const MagneticField *magneticField = &iSetup.getData(m_esTokenMF);
auto builder = iSetup.getHandle(m_esTokenBuilder);

if (m_muonCollectionTag.label().empty()) // use trajectories
{
Expand All @@ -287,7 +290,7 @@ void AlignmentMonitorMuonSystemMap1D::event(const edm::Event &iEvent,
m_counter_trackdxy++;

MuonResidualsFromTrack muonResidualsFromTrack(
iSetup, magneticField, globalGeometry, muonDetIdAssociator_, prop, traj, track, pNavigator(), 1000.);
builder, magneticField, globalGeometry, muonDetIdAssociator_, prop, traj, track, pNavigator(), 1000.);
processMuonResidualsFromTrack(muonResidualsFromTrack, iEvent);
}
} // end if track has acceptable momentum
Expand Down
Loading

0 comments on commit 6263c5a

Please sign in to comment.