Skip to content

Commit

Permalink
fix AlignmentProducerBase::writeDB
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed May 11, 2022
1 parent fb7e18c commit eb88897
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions Alignment/CommonAlignmentProducer/src/AlignmentProducerBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -887,23 +887,25 @@ void AlignmentProducerBase::writeDB(Alignments* alignments,
const std::string& errRcd,
const AlignTransform* globalCoordinates,
cond::Time_t time) const {
Alignments tempAlignments = *alignments;
AlignmentErrorsExtended tempAlignmentErrorsExtended = *alignmentErrors;
Alignments* tempAlignments = alignments;
AlignmentErrorsExtended* tempAlignmentErrorsExtended = alignmentErrors;

// Call service
edm::Service<cond::service::PoolDBOutputService> poolDb;
if (!poolDb.isAvailable()) { // Die if not available
if (!poolDb.isAvailable()) { // Die if not available
delete tempAlignments; // promised to take over ownership...
delete tempAlignmentErrorsExtended; // ditto
throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
}

if (globalCoordinates // happens only if (applyDbAlignment_ == true)
&& globalCoordinates->transform() != AlignTransform::Transform::Identity) {
Alignments tempAlignments{}; // temporary storage for
AlignmentErrorsExtended tempAlignmentErrorsExtended{}; // final alignments and errors
tempAlignments = new Alignments(); // temporary storage for
tempAlignmentErrorsExtended = new AlignmentErrorsExtended(); // final alignments and errors

GeometryAligner aligner;
aligner.removeGlobalTransform(
alignments, alignmentErrors, *globalCoordinates, &tempAlignments, &tempAlignmentErrorsExtended);
alignments, alignmentErrors, *globalCoordinates, tempAlignments, tempAlignmentErrorsExtended);

delete alignments; // have to delete original alignments
delete alignmentErrors; // same thing for the errors
Expand All @@ -915,12 +917,16 @@ void AlignmentProducerBase::writeDB(Alignments* alignments,

if (saveToDB_) {
edm::LogInfo("Alignment") << "Writing Alignments for run " << time << " to " << alignRcd << ".";
poolDb->writeOneIOV<Alignments>(tempAlignments, time, alignRcd);
poolDb->writeOneIOV<Alignments>(*tempAlignments, time, alignRcd);
} else {
delete tempAlignments; // ...otherwise we have to delete, as promised!
}

if (saveApeToDB_) {
edm::LogInfo("Alignment") << "Writing AlignmentErrorsExtended for run " << time << " to " << errRcd << ".";
poolDb->writeOneIOV<AlignmentErrorsExtended>(tempAlignmentErrorsExtended, time, errRcd);
poolDb->writeOneIOV<AlignmentErrorsExtended>(*tempAlignmentErrorsExtended, time, errRcd);
} else {
delete tempAlignmentErrorsExtended; // ...otherwise we have to delete, as promised!
}
}

Expand Down

0 comments on commit eb88897

Please sign in to comment.