Skip to content

Commit

Permalink
Added flag to enable/disable updatable alignables.
Browse files Browse the repository at this point in the history
  • Loading branch information
gregor-mittag committed Feb 10, 2017
1 parent 47fd7fb commit 2641982
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
Expand Up @@ -97,6 +97,7 @@ AlignmentProducer::AlignmentProducer(const edm::ParameterSet& iConfig) :
doMuon_( iConfig.getUntrackedParameter<bool>("doMuon") ),
useExtras_( iConfig.getUntrackedParameter<bool>("useExtras") ),
useSurvey_( iConfig.getParameter<bool>("useSurvey") ),
enableAlignableUpdates_(iConfig.getParameter<bool>("enableAlignableUpdates")),
tjTkAssociationMapTag_(iConfig.getParameter<edm::InputTag>("tjTkAssociationMapTag")),
beamSpotTag_(iConfig.getParameter<edm::InputTag>("beamSpotTag")),
tkLasBeamTag_(iConfig.getParameter<edm::InputTag>("tkLasBeamTag")),
Expand Down Expand Up @@ -393,14 +394,14 @@ AlignmentProducer::duringLoop( const edm::Event& event,
// ----------------------------------------------------------------------------
void AlignmentProducer::beginRun(const edm::Run &run, const edm::EventSetup &setup)
{
const auto changed = setupChanged(setup);
if (changed) {
const auto update = setupChanged(setup) && enableAlignableUpdates_;
if (update) {
edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginRun"
<< "EventSetup-Record changed.";
initAlignmentAlgorithm(setup, true);
}

theAlignmentAlgo->beginRun(run, setup, changed);
theAlignmentAlgo->beginRun(run, setup, update);
}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -447,6 +448,8 @@ AlignmentProducer::createAlignmentAlgorithm(const edm::ParameterSet& config)
iovSelection);
algoConfig.addUntrackedParameter<RunNumber>("firstIOV",
uniqueRunRanges_.front().first);
algoConfig.addUntrackedParameter<bool>("enableAlignableUpdates",
enableAlignableUpdates_);

const auto algoName = algoConfig.getParameter<std::string>("algoName");
theAlignmentAlgo =
Expand Down
Expand Up @@ -213,6 +213,7 @@ class AlignmentProducer : public edm::ESProducerLooper
const bool saveToDB_, saveApeToDB_,saveDeformationsToDB_;
const bool doTracker_,doMuon_,useExtras_;
const bool useSurvey_; // true to read survey info from DB
const bool enableAlignableUpdates_;

// event input tags
const edm::InputTag tjTkAssociationMapTag_; // map with tracks/trajectories
Expand Down
Expand Up @@ -70,7 +70,10 @@


# Save alignment to DB: true requires configuration of PoolDBOutputService
saveToDB = cms.bool(False), # save alignment?
saveApeToDB = cms.bool(False), # save APE?
saveDeformationsToDB = cms.bool(False) # save surface deformations (bows, etc.)?
saveToDB = cms.bool(False), # save alignment?
saveApeToDB = cms.bool(False), # save APE?
saveDeformationsToDB = cms.bool(False), # save surface deformations (bows, etc.)?

# update alignables if triggered by corresponding input IOV boundary
enableAlignableUpdates = cms.bool(False),
)
Expand Up @@ -99,6 +99,7 @@ MillePedeAlignmentAlgorithm::MillePedeAlignmentAlgorithm(const edm::ParameterSet
theMaximalCor2D(cfg.getParameter<double>("max2Dcorrelation")),
firstIOV_(cfg.getUntrackedParameter<AlignmentAlgorithmBase::RunNumber>("firstIOV")),
ignoreFirstIOVCheck_(cfg.getUntrackedParameter<bool>("ignoreFirstIOVCheck")),
enableAlignableUpdates_(cfg.getUntrackedParameter<bool>("enableAlignableUpdates")),
theLastWrittenIov(0),
theGblDoubleBinary(cfg.getParameter<bool>("doubleBinary")),
runAtPCL_(cfg.getParameter<bool>("runAtPCL")),
Expand All @@ -107,7 +108,7 @@ MillePedeAlignmentAlgorithm::MillePedeAlignmentAlgorithm(const edm::ParameterSet
uniqueRunRanges_
(align::makeUniqueRunRanges(cfg.getUntrackedParameter<edm::VParameterSet>("RunRangeSelection"),
cond::timeTypeSpecs[cond::runnumber].beginValue)),
enforceSingleIOVInput_(!areIOVsSpecified()),
enforceSingleIOVInput_(!(enableAlignableUpdates_ && areIOVsSpecified())),
lastProcessedRun_(cond::timeTypeSpecs[cond::runnumber].beginValue)
{
if (!theDir.empty() && theDir.find_last_of('/') != theDir.size()-1) theDir += '/';// may need '/'
Expand Down Expand Up @@ -344,8 +345,11 @@ bool MillePedeAlignmentAlgorithm::setParametersForRunRange(const RunRange &runra
{
if (this->isMode(myPedeReadBit)) {
// restore initial positions, rotations and deformations
// theAlignmentParameterStore->restoreCachedTransformations();
theAlignmentParameterStore->restoreCachedTransformations(runrange.first);
if (enableAlignableUpdates_) {
theAlignmentParameterStore->restoreCachedTransformations(runrange.first);
} else {
theAlignmentParameterStore->restoreCachedTransformations();
}

// Needed to shut up later warning from checkAliParams:
theAlignmentParameterStore->resetParameters();
Expand Down Expand Up @@ -394,7 +398,7 @@ void MillePedeAlignmentAlgorithm::terminate()

// cache all positions, rotations and deformations
theAlignmentParameterStore->cacheTransformations();
if (this->isMode(myPedeReadBit)) {
if (this->isMode(myPedeReadBit) && enableAlignableUpdates_) {
if (lastProcessedRun_ < uniqueRunRanges_.back().first) {
throw cms::Exception("BadConfig")
<< "@SUB=MillePedeAlignmentAlgorithm::terminate\n"
Expand Down Expand Up @@ -633,7 +637,7 @@ void MillePedeAlignmentAlgorithm::beginRun(const edm::Run& run,

lastProcessedRun_ = run.run();

if (changed) {
if (changed && enableAlignableUpdates_) {
const auto runNumber = run.run();
auto firstRun = cond::timeTypeSpecs[cond::runnumber].beginValue;
for (auto runRange = uniqueRunRanges_.crbegin();
Expand Down
Expand Up @@ -267,6 +267,7 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase
/// If larger, the 2D measurement gets diagonalized!!!
const align::RunNumber firstIOV_;
const bool ignoreFirstIOVCheck_;
const bool enableAlignableUpdates_;
int theLastWrittenIov; // keeping track for output trees...
std::vector<float> theFloatBufferX;
std::vector<float> theFloatBufferY;
Expand Down
Expand Up @@ -15,6 +15,9 @@ def setConfiguration(process, collection, mode, monitorFile, binaryFile,
# What tracks are used to construct the reference trajectories?
process.AlignmentProducer.tjTkAssociationMapTag = "FinalTrackRefitter"

# enable proper handling of multi-IOV input
process.AlignmentProducer.enableAlignableUpdates = True

# Configure the algorithm
process.AlignmentProducer.algoConfig = cms.PSet(
process.MillePedeAlignmentAlgorithm)
Expand Down

0 comments on commit 2641982

Please sign in to comment.