Skip to content

Commit

Permalink
Merge pull request #14 from cms-sw/master
Browse files Browse the repository at this point in the history
update master
  • Loading branch information
kskovpen authored Nov 20, 2021
2 parents c49a955 + 3908b5d commit 8cd59c5
Show file tree
Hide file tree
Showing 352 changed files with 168,918 additions and 9,448 deletions.
1 change: 0 additions & 1 deletion Alignment/CocoaApplication/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
<use name="root"/>
<use name="dd4hep"/>
<use name="Alignment/CocoaFit"/>
<use name="CondCore/DBOutputService"/>
<use name="DetectorDescription/DDCMS"/>
<flags EDM_PLUGIN="1"/>
1 change: 0 additions & 1 deletion Alignment/CocoaApplication/src/CocoaAnalyzer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
#include "CondFormats/DataRecord/interface/OpticalAlignmentsRcd.h"
#include "CondFormats/OptAlignObjects/interface/OpticalAlignMeasurementInfo.h"
#include <DD4hep/DD4hepUnits.h>
Expand Down
5 changes: 3 additions & 2 deletions Alignment/CocoaFit/interface/CocoaDBMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <string>
#include <iostream>
#include <map>
#include <memory>

class Event;
class EventSetup;
Expand Down Expand Up @@ -45,13 +46,13 @@ class CocoaDBMgr {
bool DumpCocoaResults();

private:
OpticalAlignments* BuildOpticalAlignments();
std::unique_ptr<OpticalAlignments> BuildOpticalAlignments();
double GetEntryError(const Entry* entry);
double GetEntryError(const Entry* entry1, const Entry* entry2);

OpticalAlignInfo GetOptAlignInfoFromOptO(OpticalObject* opto);

std::pair<Alignments*, AlignmentErrorsExtended*> BuildAlignments(bool bDT);
std::pair<std::unique_ptr<Alignments>, std::unique_ptr<AlignmentErrorsExtended> > BuildAlignments(bool bDT);
AlignTransform* GetAlignInfoFromOptO(OpticalObject* opto);
AlignTransformErrorExtended* GetAlignInfoErrorFromOptO(OpticalObject* opto);

Expand Down
72 changes: 28 additions & 44 deletions Alignment/CocoaFit/src/CocoaDBMgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ bool CocoaDBMgr::DumpCocoaResults() {
cond::Time_t appendTime = Fit::nEvent + 1;
if (gomgr->GlobalOptions()["writeDBOptAlign"] > 0) {
//----- Build OpticalAlignments
OpticalAlignments* optalign = BuildOpticalAlignments();
std::unique_ptr<OpticalAlignments> optalign = BuildOpticalAlignments();

//--- Dump OpticalAlignments
nrcd = optalign->opticalAlignments_.size();
Expand All @@ -67,21 +67,11 @@ bool CocoaDBMgr::DumpCocoaResults() {
std::cout << " new OA to DB "
<< "begin " << myDbService->beginOfTime() << " current " << myDbService->currentTime() << " end "
<< myDbService->endOfTime() << std::endl;
myDbService->createNewIOV<OpticalAlignments>(
optalign,
myDbService->beginOfTime(),
myDbService->endOfTime(),
// myDbService->endOfTime(),
"OpticalAlignmentsRcd");
myDbService->createOneIOV<OpticalAlignments>(*optalign, myDbService->beginOfTime(), "OpticalAlignmentsRcd");
} else {
std::cout << " old OA to DB "
<< " current " << myDbService->currentTime() << " end " << myDbService->endOfTime() << std::endl;
myDbService->appendSinceTime<OpticalAlignments>(
optalign,
// myDbService->endOfTime(),
appendTime,
// myDbService->currentTime(),
"OpticalAlignmentsRcd");
myDbService->appendOneIOV<OpticalAlignments>(*optalign, appendTime, "OpticalAlignmentsRcd");
}

/* }catch(const cond::Exception& er) {
Expand All @@ -98,60 +88,53 @@ bool CocoaDBMgr::DumpCocoaResults() {

if (gomgr->GlobalOptions()["writeDBAlign"] > 0) {
// Build DT alignments and errors
std::pair<Alignments*, AlignmentErrorsExtended*> dtali = BuildAlignments(true);
Alignments* dt_Alignments = dtali.first;
AlignmentErrorsExtended* dt_AlignmentErrors = dtali.second;
const auto& dtali = BuildAlignments(true);
auto& dt_Alignments = dtali.first;
auto& dt_AlignmentErrors = dtali.second;

// Dump DT alignments and errors
nrcd = dt_Alignments->m_align.size();
if (myDbService->isNewTagRequest("DTAlignmentRcd")) {
myDbService->createNewIOV<Alignments>(
&(*dt_Alignments), myDbService->beginOfTime(), myDbService->endOfTime(), "DTAlignmentRcd");
myDbService->createOneIOV<Alignments>(*dt_Alignments, myDbService->beginOfTime(), "DTAlignmentRcd");
} else {
myDbService->appendSinceTime<Alignments>(&(*dt_Alignments),
appendTime,
// myDbService->currentTime(),
"DTAlignmentRcd");
myDbService->appendOneIOV<Alignments>(*dt_Alignments, appendTime, "DTAlignmentRcd");
}
if (ALIUtils::debug >= 2)
std::cout << "DTAlignmentRcd WRITTEN TO DB : " << nrcd << std::endl;

nrcd = dt_AlignmentErrors->m_alignError.size();
if (myDbService->isNewTagRequest("DTAlignmentErrorExtendedRcd")) {
myDbService->createNewIOV<AlignmentErrorsExtended>(
&(*dt_AlignmentErrors), myDbService->beginOfTime(), myDbService->endOfTime(), "DTAlignmentErrorExtendedRcd");
myDbService->createOneIOV<AlignmentErrorsExtended>(
*dt_AlignmentErrors, myDbService->beginOfTime(), "DTAlignmentErrorExtendedRcd");
} else {
myDbService->appendSinceTime<AlignmentErrorsExtended>(
&(*dt_AlignmentErrors), appendTime, "DTAlignmentErrorExtendedRcd");
myDbService->appendOneIOV<AlignmentErrorsExtended>(
*dt_AlignmentErrors, appendTime, "DTAlignmentErrorExtendedRcd");
}
if (ALIUtils::debug >= 2)
std::cout << "DTAlignmentErrorExtendedRcd WRITTEN TO DB : " << nrcd << std::endl;

// Build CSC alignments and errors
std::pair<Alignments*, AlignmentErrorsExtended*> cscali = BuildAlignments(false);
Alignments* csc_Alignments = cscali.first;
AlignmentErrorsExtended* csc_AlignmentErrors = cscali.second;
const auto& cscali = BuildAlignments(false);
auto& csc_Alignments = cscali.first;
auto& csc_AlignmentErrors = cscali.second;

// Dump CSC alignments and errors
nrcd = csc_Alignments->m_align.size();
if (myDbService->isNewTagRequest("CSCAlignmentRcd")) {
myDbService->createNewIOV<Alignments>(
&(*csc_Alignments), myDbService->beginOfTime(), myDbService->endOfTime(), "CSCAlignmentRcd");
myDbService->createOneIOV<Alignments>(*csc_Alignments, myDbService->beginOfTime(), "CSCAlignmentRcd");
} else {
myDbService->appendSinceTime<Alignments>(&(*csc_Alignments), appendTime, "CSCAlignmentRcd");
myDbService->appendOneIOV<Alignments>(*csc_Alignments, appendTime, "CSCAlignmentRcd");
}
if (ALIUtils::debug >= 2)
std::cout << "CSCAlignmentRcd WRITTEN TO DB : " << nrcd << std::endl;

nrcd = csc_AlignmentErrors->m_alignError.size();
if (myDbService->isNewTagRequest("CSCAlignmentErrorExtendedRcd")) {
myDbService->createNewIOV<AlignmentErrorsExtended>(&(*csc_AlignmentErrors),
myDbService->beginOfTime(),
myDbService->endOfTime(),
"CSCAlignmentErrorExtendedRcd");
myDbService->createOneIOV<AlignmentErrorsExtended>(
*csc_AlignmentErrors, myDbService->beginOfTime(), "CSCAlignmentErrorExtendedRcd");
} else {
myDbService->appendSinceTime<AlignmentErrorsExtended>(
&(*csc_AlignmentErrors), appendTime, "CSCAlignmentErrorExtendedRcd");
myDbService->appendOneIOV<AlignmentErrorsExtended>(
*csc_AlignmentErrors, appendTime, "CSCAlignmentErrorExtendedRcd");
}
if (ALIUtils::debug >= 2)
std::cout << "CSCAlignmentErrorExtendedRcd WRITTEN TO DB : " << nrcd << std::endl;
Expand Down Expand Up @@ -280,8 +263,8 @@ double CocoaDBMgr::GetEntryError(const Entry* entry1, const Entry* entry2) {
}

//-----------------------------------------------------------------------
OpticalAlignments* CocoaDBMgr::BuildOpticalAlignments() {
OpticalAlignments* optalign = new OpticalAlignments;
std::unique_ptr<OpticalAlignments> CocoaDBMgr::BuildOpticalAlignments() {
std::unique_ptr<OpticalAlignments> optalign = std::make_unique<OpticalAlignments>();

static std::vector<OpticalObject*> optolist = Model::OptOList();
static std::vector<OpticalObject*>::const_iterator ite;
Expand All @@ -298,9 +281,9 @@ OpticalAlignments* CocoaDBMgr::BuildOpticalAlignments() {
}

//-----------------------------------------------------------------------
std::pair<Alignments*, AlignmentErrorsExtended*> CocoaDBMgr::BuildAlignments(bool bDT) {
Alignments* alignments = new Alignments;
AlignmentErrorsExtended* alignmentErrors = new AlignmentErrorsExtended;
std::pair<std::unique_ptr<Alignments>, std::unique_ptr<AlignmentErrorsExtended> > CocoaDBMgr::BuildAlignments(bool bDT) {
std::unique_ptr<Alignments> alignments = std::make_unique<Alignments>();
std::unique_ptr<AlignmentErrorsExtended> alignmentErrors = std::make_unique<AlignmentErrorsExtended>();

//read
static std::vector<OpticalObject*> optolist = Model::OptOList();
Expand All @@ -326,7 +309,8 @@ std::pair<Alignments*, AlignmentErrorsExtended*> CocoaDBMgr::BuildAlignments(boo
if (ALIUtils::debug >= 4)
std::cout << "CocoaDBMgr::BuildAlignments end with n alignment " << alignments->m_align.size()
<< " n alignmentError " << alignmentErrors->m_alignError.size() << std::endl;
return std::pair<Alignments*, AlignmentErrorsExtended*>(alignments, alignmentErrors);

return std::make_pair(std::move(alignments), std::move(alignmentErrors));
}

//-----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class SiStripBackplaneCalibration : public IntegratedCalibrationBase {
/// and the given run.
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const;

void writeTree(const SiStripBackPlaneCorrection *backPlaneCorr,
void writeTree(const SiStripBackPlaneCorrection &backPlaneCorr,
const std::map<unsigned int, TreeStruct> &treeInfo,
const char *treeName) const;
SiStripBackPlaneCorrection *createFromTree(const char *fileName, const char *treeName) const;
Expand Down Expand Up @@ -320,7 +320,7 @@ void SiStripBackplaneCalibration::endOfJob() {
// now write 'input' tree
const SiStripBackPlaneCorrection *input = this->getBackPlaneCorrectionInput(); // never NULL
const std::string treeName(this->name() + '_' + readoutModeName_ + '_');
this->writeTree(input, treeInfo, (treeName + "input").c_str()); // empty treeInfo for input...
this->writeTree(*input, treeInfo, (treeName + "input").c_str()); // empty treeInfo for input...

if (input->getBackPlaneCorrections().empty()) {
edm::LogError("Alignment") << "@SUB=SiStripBackplaneCalibration::endOfJob"
Expand All @@ -335,7 +335,7 @@ void SiStripBackplaneCalibration::endOfJob() {

for (unsigned int iIOV = 0; iIOV < moduleGroupSelector_->numIovs(); ++iIOV) {
cond::Time_t firstRunOfIOV = moduleGroupSelector_->firstRunOfIOV(iIOV);
SiStripBackPlaneCorrection *output = new SiStripBackPlaneCorrection;
SiStripBackPlaneCorrection output{};
// Loop on map of values from input and add (possible) parameter results
for (auto iterIdValue = input->getBackPlaneCorrections().begin();
iterIdValue != input->getBackPlaneCorrections().end();
Expand Down Expand Up @@ -370,7 +370,7 @@ void SiStripBackplaneCalibration::endOfJob() {
// }
const double param = this->getParameterForDetId(detId, firstRunOfIOV);
// put result in output, i.e. sum of input and determined parameter:
output->putBackPlaneCorrection(detId, iterIdValue->second + param);
output.putBackPlaneCorrection(detId, iterIdValue->second + param);
const int paramIndex = moduleGroupSelector_->getParameterIndexFromDetId(detId, firstRunOfIOV);
treeInfo[detId] = TreeStruct(param, this->getParameterError(paramIndex), paramIndex);
}
Expand All @@ -382,15 +382,12 @@ void SiStripBackplaneCalibration::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_);
// no 'delete output;': writeOne(..) took over ownership
} else {
delete output;
edm::LogError("BadConfig") << "@SUB=SiStripBackplaneCalibration::endOfJob"
<< "No PoolDBOutputService available, but saveToDB true!";
}
} else {
delete output;
}
} // end loop on IOVs
}
Expand Down Expand Up @@ -470,12 +467,9 @@ double SiStripBackplaneCalibration::getParameterForDetId(unsigned int detId, edm
}

//======================================================================
void SiStripBackplaneCalibration::writeTree(const SiStripBackPlaneCorrection *backPlaneCorrection,
void SiStripBackplaneCalibration::writeTree(const SiStripBackPlaneCorrection &backPlaneCorrection,
const std::map<unsigned int, TreeStruct> &treeInfo,
const char *treeName) const {
if (!backPlaneCorrection)
return;

TFile *file = TFile::Open(outFileName_.c_str(), "UPDATE");
if (!file) {
edm::LogError("BadConfig") << "@SUB=SiStripBackplaneCalibration::writeTree"
Expand All @@ -491,8 +485,8 @@ void SiStripBackplaneCalibration::writeTree(const SiStripBackPlaneCorrection *ba
tree->Branch("value", &value, "value/F");
tree->Branch("treeStruct", &treeStruct, TreeStruct::LeafList());

for (auto iterIdValue = backPlaneCorrection->getBackPlaneCorrections().begin();
iterIdValue != backPlaneCorrection->getBackPlaneCorrections().end();
for (auto iterIdValue = backPlaneCorrection.getBackPlaneCorrections().begin();
iterIdValue != backPlaneCorrection.getBackPlaneCorrections().end();
++iterIdValue) {
// type of (*iterIdValue) is pair<unsigned int, float>
id = iterIdValue->first; // key of map is DetId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class AlignmentProducerBase {

/// Writes SurfaceDeformations (bows & kinks) to DB for given record name
/// Takes over ownership of AlignmentSurfaceDeformations.
void writeDB(AlignmentSurfaceDeformations*, const std::string&, cond::Time_t) const;
void writeDB(const AlignmentSurfaceDeformations&, const std::string&, cond::Time_t) const;

//========================== PRIVATE DATA ====================================
//============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3347,7 +3347,7 @@ void GlobalTrackerMuonAlignment::writeGlPosRcd(CLHEP::HepVector& paramVec) {

CLHEP::HepVector param0(6, 0);

Alignments* globalPositions = new Alignments();
Alignments globalPositions{};

//Tracker
AlignTransform tracker(
Expand Down Expand Up @@ -3417,11 +3417,11 @@ void GlobalTrackerMuonAlignment::writeGlPosRcd(CLHEP::HepVector& paramVec) {
<< std::endl;
std::cout << calo.rotation() << std::endl;

globalPositions->m_align.push_back(tracker);
globalPositions->m_align.push_back(muon);
globalPositions->m_align.push_back(ecal);
globalPositions->m_align.push_back(hcal);
globalPositions->m_align.push_back(calo);
globalPositions.m_align.push_back(tracker);
globalPositions.m_align.push_back(muon);
globalPositions.m_align.push_back(ecal);
globalPositions.m_align.push_back(hcal);
globalPositions.m_align.push_back(calo);

std::cout << "Uploading to the database..." << std::endl;

Expand All @@ -3435,10 +3435,7 @@ void GlobalTrackerMuonAlignment::writeGlPosRcd(CLHEP::HepVector& paramVec) {
// } else {
// poolDbService->appendSinceTime<Alignments>(&(*globalPositions), poolDbService->currentTime(), "GlobalPositionRcd");
// }
poolDbService->writeOne<Alignments>(&(*globalPositions),
poolDbService->currentTime(),
//poolDbService->beginOfTime(),
"GlobalPositionRcd");
poolDbService->writeOneIOV<Alignments>(globalPositions, poolDbService->currentTime(), "GlobalPositionRcd");
std::cout << "done!" << std::endl;

return;
Expand Down
Loading

0 comments on commit 8cd59c5

Please sign in to comment.