Skip to content

Commit

Permalink
Merge branch 'master' into common112Xupdates
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongeun authored Mar 19, 2021
2 parents 8d73184 + c7e8c5b commit 9832dd4
Show file tree
Hide file tree
Showing 5,604 changed files with 251,206 additions and 445,479 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ __init__.py
.#*
#*#
*~
*.pb
23 changes: 11 additions & 12 deletions Alignment/APEEstimation/plugins/ApeEstimator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
/////////
#include "DataFormats/GeometryVector/interface/LocalVector.h"
#include "DataFormats/GeometrySurface/interface/Bounds.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "CondFormats/DataRecord/interface/SiStripLorentzAngleRcd.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
Expand Down Expand Up @@ -181,6 +180,9 @@ class ApeEstimator : public edm::one::EDAnalyzer<> {

// ----------member data ---------------------------
const edm::ParameterSet parameterSet_;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
const edm::ESGetToken<SiStripLorentzAngle, SiStripLorentzAngleDepRcd> lorentzAngleToken_;

std::map<unsigned int, TrackerSectorStruct> m_tkSector_;
TrackerDetectorStruct tkDetector_;
SiStripClusterInfo siStripClusterInfo_;
Expand Down Expand Up @@ -219,6 +221,8 @@ class ApeEstimator : public edm::one::EDAnalyzer<> {
//
ApeEstimator::ApeEstimator(const edm::ParameterSet& iConfig)
: parameterSet_(iConfig),
magFieldToken_(esConsumes()),
lorentzAngleToken_(esConsumes()),
siStripClusterInfo_(consumesCollector(), std::string("")),
tjTagToken_(
consumes<TrajTrackAssociationCollection>(parameterSet_.getParameter<edm::InputTag>("tjTkAssociationMapTag"))),
Expand Down Expand Up @@ -1658,16 +1662,11 @@ TrackStruct::HitParameterStruct ApeEstimator::fillHitVariables(const TrajectoryM
return hitParams;
}

edm::ESHandle<MagneticField> magFieldHandle;
iSetup.get<IdealMagneticFieldRecord>().get(magFieldHandle);

edm::ESHandle<SiStripLorentzAngle> lorentzAngleHandle;
iSetup.get<SiStripLorentzAngleDepRcd>().get(lorentzAngleHandle); //MODIFIED BY LOIC QUERTENMONT
const MagneticField* magField = &iSetup.getData(magFieldToken_);
const SiStripLorentzAngle* lorentzAngle = &iSetup.getData(lorentzAngleToken_);

const StripGeomDetUnit* stripDet = (const StripGeomDetUnit*)(&detUnit);
const MagneticField* magField(magFieldHandle.product());
LocalVector bField = (stripDet->surface()).toLocal(magField->inTesla(stripDet->surface().position()));
const SiStripLorentzAngle* lorentzAngle(lorentzAngleHandle.product());
float tanLorentzAnglePerTesla = lorentzAngle->getLorentzAngle(stripDet->geographicalId().rawId());

float dirX = -tanLorentzAnglePerTesla * bField.y();
Expand Down Expand Up @@ -2572,14 +2571,14 @@ bool ApeEstimator::isHit2D(const TrackingRecHit& hit) const {
const ProjectedSiStripRecHit2D* pH = static_cast<const ProjectedSiStripRecHit2D*>(&hit);
return (this->isHit2D(pH->originalHit())); // depends on original...
} else {
edm::LogError("UnkownType") << "@SUB=AlignmentTrackSelector::isHit2D"
<< "Tracker hit not in pixel, neither SiStripRecHit[12]D nor "
<< "SiStripMatchedRecHit2D nor ProjectedSiStripRecHit2D.";
edm::LogError("UnknownType") << "@SUB=ApeEstimator::isHit2D"
<< "Tracker hit not in pixel, neither SiStripRecHit[12]D nor "
<< "SiStripMatchedRecHit2D nor ProjectedSiStripRecHit2D.";
return false;
}
}
} else { // not tracker??
edm::LogWarning("DetectorMismatch") << "@SUB=AlignmentTrackSelector::isHit2D"
edm::LogWarning("DetectorMismatch") << "@SUB=ApeEstimator::isHit2D"
<< "Hit not in tracker with 'official' dimension >=2.";
return true; // dimension() >= 2 so accept that...
}
Expand Down
85 changes: 59 additions & 26 deletions Alignment/APEEstimation/plugins/ApeEstimatorSummary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand All @@ -35,6 +34,7 @@

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Utilities/interface/isFinite.h"

#include "CLHEP/Matrix/SymMatrix.h"

Expand Down Expand Up @@ -78,6 +78,7 @@ class ApeEstimatorSummary : public edm::one::EDAnalyzer<> {

// ----------member data ---------------------------
const edm::ParameterSet parameterSet_;
const edm::ESGetToken<AlignmentErrorsExtended, TrackerAlignmentErrorExtendedRcd> alignmentErrorToken_;

bool firstEvent = true;

Expand All @@ -99,7 +100,7 @@ class ApeEstimatorSummary : public edm::one::EDAnalyzer<> {
// constructors and destructor
//
ApeEstimatorSummary::ApeEstimatorSummary(const edm::ParameterSet& iConfig)
: parameterSet_(iConfig), inputFile_(nullptr) {}
: parameterSet_(iConfig), alignmentErrorToken_(esConsumes()), inputFile_(nullptr) {}

ApeEstimatorSummary::~ApeEstimatorSummary() {}

Expand Down Expand Up @@ -364,9 +365,8 @@ void ApeEstimatorSummary::calculateApe() {
TTree* sectorNameTree(nullptr);
iterationFile->GetObject("nameTree;1", sectorNameTree);

bool firstIter(false);
if (!iterationTreeX) { // should be always true in setBaseline mode, since file is recreated
firstIter = true;
const bool firstIter(!iterationTreeX);
if (firstIter) { // should be always true in setBaseline mode, since file is recreated
if (!setBaseline) {
iterationTreeX = new TTree("iterTreeX", "Tree for APE x values of all iterations");
iterationTreeY = new TTree("iterTreeY", "Tree for APE y values of all iterations");
Expand Down Expand Up @@ -438,34 +438,44 @@ void ApeEstimatorSummary::calculateApe() {
}

// Check whether sector definitions are identical with the ones of previous iterations and with the ones in baseline file
bool failed(false);
for (auto& i_sector : m_tkSector_) {
const std::string& name(i_sector.second.name);
if (!firstIter) {
if (firstIter) {
a_sectorName[i_sector.first] = new std::string(name);
} else {
const std::string& nameLastIter(*a_sectorName[i_sector.first]);
if (name != nameLastIter) {
edm::LogError("CalculateAPE") << "Inconsistent sector definition in iterationFile for sector " << i_sector.first
<< ",\n"
<< "Recent iteration has name \"" << name << "\", while previous had \""
<< nameLastIter << "\"\n"
<< "...APE calculation stopped. Please check sector definitions in config!\n";
return;
failed = true;
}
} else {
a_sectorName[i_sector.first] = new std::string(name);
}
if (!setBaseline && baselineFile) {
const std::string& nameBaseline(*a_sectorBaselineName[i_sector.first]);
if (name != nameBaseline) {
failed = true;
edm::LogError("CalculateAPE") << "Inconsistent sector definition in baselineFile for sector " << i_sector.first
<< ",\n"
<< "Recent iteration has name \"" << name << "\", while baseline had \""
<< nameBaseline << "\"\n"
<< "...APE calculation stopped. Please check sector definitions in config!\n";
return;
}
}
}

if (failed) {
if (firstIter) {
for (auto& i_sector : m_tkSector_) {
delete a_sectorName[i_sector.first];
}
}
return;
}

// Set up text file for writing out APE values per module
std::ofstream apeOutputFile;
if (!setBaseline) {
Expand Down Expand Up @@ -634,13 +644,13 @@ void ApeEstimatorSummary::calculateApe() {
double correctionY_1 = correctionY2_1 >= 0. ? std::sqrt(correctionY2_1) : -std::sqrt(-correctionY2_1);
double correctionY_2 = correctionY2_2 >= 0. ? std::sqrt(correctionY2_2) : -std::sqrt(-correctionY2_2);
// Meanwhile, this got very bad default values, or? (negative corrections allowed)
if (isnan(correctionX_1))
if (edm::isNotFinite(correctionX_1))
correctionX_1 = -0.0010;
if (isnan(correctionX_2))
if (edm::isNotFinite(correctionX_2))
correctionX_2 = -0.0010;
if (isnan(correctionY_1))
if (edm::isNotFinite(correctionY_1))
correctionY_1 = -0.0010;
if (isnan(correctionY_2))
if (edm::isNotFinite(correctionY_2))
correctionY_2 = -0.0010;

if (entriesX < minHitsPerInterval) {
Expand Down Expand Up @@ -876,6 +886,9 @@ void ApeEstimatorSummary::calculateApe() {
if (firstIter) {
sectorNameTree->Fill();
sectorNameTree->Write("nameTree");
for (auto& i_sector : m_tkSector_) {
delete a_sectorName[i_sector.first];
}
}
iterationFile->Close();
delete iterationFile;
Expand All @@ -894,8 +907,7 @@ void ApeEstimatorSummary::analyze(const edm::Event& iEvent, const edm::EventSetu
// Set baseline or calculate APE value?
const bool setBaseline(parameterSet_.getParameter<bool>("setBaseline"));

edm::ESHandle<AlignmentErrorsExtended> alignmentErrors;
iSetup.get<TrackerAlignmentErrorExtendedRcd>().get(alignmentErrors);
const AlignmentErrorsExtended* alignmentErrors = &iSetup.getData(alignmentErrorToken_);

// Read in baseline file for calculation of APE value (if not setting baseline)
// Has same format as iterationFile
Expand Down Expand Up @@ -932,9 +944,8 @@ void ApeEstimatorSummary::analyze(const edm::Event& iEvent, const edm::EventSetu
TTree* sectorNameTree(nullptr);
defaultFile->GetObject("nameTree;1", sectorNameTree);

bool firstIter(false);
if (!defaultTreeX) { // should be always true in setBaseline mode, since file is recreated
firstIter = true;
const bool firstIter(!defaultTreeX);
if (firstIter) { // should be always true in setBaseline mode, since file is recreated
defaultTreeX = new TTree("iterTreeX", "Tree for default APE x values from GT");
defaultTreeY = new TTree("iterTreeY", "Tree for default APE y values from GT");
edm::LogInfo("CalculateAPE") << "First APE iteration (number 0.), create default file with TTree";
Expand Down Expand Up @@ -986,20 +997,22 @@ void ApeEstimatorSummary::analyze(const edm::Event& iEvent, const edm::EventSetu
}

// Check whether sector definitions are identical with the ones of previous iterations and with the ones in baseline file
bool failed(false);
for (auto& i_sector : m_tkSector_) {
const std::string& name(i_sector.second.name);
if (!firstIter) {
if (firstIter) {
a_sectorName[i_sector.first] = new std::string(name);
} else {
const std::string& nameLastIter(*a_sectorName[i_sector.first]);
if (name != nameLastIter) {
edm::LogError("CalculateAPE") << "Inconsistent sector definition in iterationFile for sector "
<< i_sector.first << ",\n"
<< "Recent iteration has name \"" << name << "\", while previous had \""
<< nameLastIter << "\"\n"
<< "...APE calculation stopped. Please check sector definitions in config!\n";
return;
failed = true;
}
} else
a_sectorName[i_sector.first] = new std::string(name);
}
if (!setBaseline && baselineFile) {
const std::string& nameBaseline(*a_sectorBaselineName[i_sector.first]);
if (name != nameBaseline) {
Expand All @@ -1008,9 +1021,21 @@ void ApeEstimatorSummary::analyze(const edm::Event& iEvent, const edm::EventSetu
<< "Recent iteration has name \"" << name << "\", while baseline had \""
<< nameBaseline << "\"\n"
<< "...APE calculation stopped. Please check sector definitions in config!\n";
return;
failed = true;
}
}
}

if (failed) {
if (firstIter) {
delete defaultTreeX;
delete defaultTreeY;
delete sectorNameTree;
for (auto& i_sector : m_tkSector_) {
delete a_sectorName[i_sector.first];
}
}
return;
}

// Loop over sectors for calculating getting default APE
Expand Down Expand Up @@ -1042,13 +1067,21 @@ void ApeEstimatorSummary::analyze(const edm::Event& iEvent, const edm::EventSetu
defaultTreeY->Write("iterTreeY");

defaultFile->Close();
delete defaultFile;

if (baselineFile) {
baselineFile->Close();
delete baselineFile;
}

delete defaultFile;
if (firstIter) {
for (auto& i_sector : m_tkSector_) {
delete a_sectorName[i_sector.first];
}
delete sectorNameTree;
delete defaultTreeX;
delete defaultTreeY;
}

firstEvent = false;
}
}
Expand Down
8 changes: 4 additions & 4 deletions Alignment/APEEstimation/plugins/ApeTreeCreateDefault.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down Expand Up @@ -81,6 +80,7 @@ class ApeTreeCreateDefault : public edm::one::EDAnalyzer<> {
bool checkModulePositions(const float, const std::vector<double>&) const;

// ----------member data ---------------------------
const edm::ESGetToken<AlignmentErrorsExtended, TrackerAlignmentErrorExtendedRcd> alignmentErrorToken_;
const std::string resultFile_;
const std::string trackerTreeFile_;
const std::vector<edm::ParameterSet> sectors_;
Expand All @@ -102,7 +102,8 @@ class ApeTreeCreateDefault : public edm::one::EDAnalyzer<> {
// constructors and destructor
//
ApeTreeCreateDefault::ApeTreeCreateDefault(const edm::ParameterSet& iConfig)
: resultFile_(iConfig.getParameter<std::string>("resultFile")),
: alignmentErrorToken_(esConsumes()),
resultFile_(iConfig.getParameter<std::string>("resultFile")),
trackerTreeFile_(iConfig.getParameter<std::string>("trackerTreeFile")),
sectors_(iConfig.getParameter<std::vector<edm::ParameterSet>>("sectors")) {}

Expand Down Expand Up @@ -399,8 +400,7 @@ void ApeTreeCreateDefault::analyze(const edm::Event& iEvent, const edm::EventSet
// Same procedure as in ApeEstimatorSummary.cc minus reading of baseline tree

// Load APEs from the GT and write them to root files similar to the ones from calculateAPE()
edm::ESHandle<AlignmentErrorsExtended> alignmentErrors;
iSetup.get<TrackerAlignmentErrorExtendedRcd>().get(alignmentErrors);
const AlignmentErrorsExtended* alignmentErrors = &iSetup.getData(alignmentErrorToken_);

// Set up root file for default APE values
const std::string defaultFileName(resultFile_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
## Message Logger
##
process.load("FWCore.MessageService.MessageLogger_cfi")
process.MessageLogger.categories.append('AlignmentTrackSelector')
#process.MessageLogger.categories.append('')
process.MessageLogger.AlignmentTrackSelector=dict()
process.MessageLogger.cerr.INFO.limit = 0
process.MessageLogger.cerr.default.limit = -1
process.MessageLogger.cerr.AlignmentTrackSelector = cms.untracked.PSet(limit = cms.untracked.int32(-1))
Expand Down
4 changes: 2 additions & 2 deletions Alignment/APEEstimation/test/apeTreeCreateDefault_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
## Message Logger
##
process.load("FWCore.MessageService.MessageLogger_cfi")
process.MessageLogger.categories.append('DefaultAPETree')
process.MessageLogger.categories.append('SectorBuilder')
process.MessageLogger.DefaultAPETree=dict()
process.MessageLogger.SectorBuilder=dict()
process.MessageLogger.cerr.INFO.limit = 0
process.MessageLogger.cerr.default.limit = 0
process.MessageLogger.cerr.DefaultAPETree = cms.untracked.PSet(limit = cms.untracked.int32(-1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
## Message Logger
##
process.load("FWCore.MessageService.MessageLogger_cfi")
process.MessageLogger.categories.append('CalculateAPE')
process.MessageLogger.CalculateAPE=dict()
process.MessageLogger.cerr.INFO.limit = 0
process.MessageLogger.cerr.default.limit = 0
process.MessageLogger.cerr.CalculateAPE = cms.untracked.PSet(limit = cms.untracked.int32(-1))
Expand Down
14 changes: 7 additions & 7 deletions Alignment/APEEstimation/test/cfgTemplate/apeEstimator_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
## Message Logger
##
process.load("FWCore.MessageService.MessageLogger_cfi")
process.MessageLogger.categories.append('SectorBuilder')
process.MessageLogger.categories.append('ResidualErrorBinning')
process.MessageLogger.categories.append('HitSelector')
process.MessageLogger.categories.append('CalculateAPE')
process.MessageLogger.categories.append('ApeEstimator')
process.MessageLogger.categories.append('TrackRefitter')
process.MessageLogger.categories.append('AlignmentTrackSelector')
process.MessageLogger.SectorBuilder=dict()
process.MessageLogger.ResidualErrorBinning=dict()
process.MessageLogger.HitSelector=dict()
process.MessageLogger.CalculateAPE=dict()
process.MessageLogger.ApeEstimator=dict()
process.MessageLogger.TrackRefitter=dict()
process.MessageLogger.AlignmentTrackSelector=dict()
process.MessageLogger.cerr.threshold = 'WARNING'
process.MessageLogger.cerr.INFO.limit = 0
process.MessageLogger.cerr.default.limit = -1
Expand Down
Loading

0 comments on commit 9832dd4

Please sign in to comment.