Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[91X] SiPixelAli PCL payload creation thresholds from db - Consumer Code #18196

Merged
merged 18 commits into from Apr 6, 2017
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -12,6 +12,17 @@
from Alignment.CommonAlignmentProducer.LSNumberFilter_cfi import *


# Ugly as hell, but that's life
from CondCore.CondDB.CondDB_cfi import *
CondDB.connect = cms.string('frontier://FrontierPrep/CMS_CONDITIONS')
PoolDBESSource = cms.ESSource("PoolDBESSource",
CondDB,
toGet = cms.VPSet(cms.PSet(record = cms.string('AlignPCLThresholdsRcd'),
tag = cms.string('SiPixelAliThresholds_test_v0')
)
)
)

# Ingredient: offlineBeamSpot
from RecoVertex.BeamSpotProducer.BeamSpot_cfi import offlineBeamSpot

Expand Down
Expand Up @@ -9,6 +9,17 @@
# 0000, 0001, 0002,...
outputBinaryFile = cms.string('pedeBinary%04d.dat'))

# Ugly as hell, but that's life
from CondCore.CondDB.CondDB_cfi import *
CondDB.connect = cms.string('frontier://FrontierPrep/CMS_CONDITIONS')
PoolDBESSource = cms.ESSource("PoolDBESSource",
CondDB,
toGet = cms.VPSet(cms.PSet(record = cms.string('AlignPCLThresholdsRcd'),
tag = cms.string('SiPixelAliThresholds_test_v0')
)
)
)

from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import *
from Alignment.CommonAlignmentProducer.TrackerAlignmentProducerForPCL_cff import AlignmentProducer
SiPixelAliPedeAlignmentProducer = copy.deepcopy(AlignmentProducer)
Expand All @@ -25,7 +36,6 @@

SiPixelAliPedeAlignmentProducer.doMisalignmentScenario = False #True


SiPixelAliPedeAlignmentProducer.checkDbAlignmentValidity = False
SiPixelAliPedeAlignmentProducer.applyDbAlignment = True
SiPixelAliPedeAlignmentProducer.tjTkAssociationMapTag = 'TrackRefitter2'
Expand Down
1 change: 1 addition & 0 deletions Alignment/MillePedeAlignmentAlgorithm/BuildFile.xml
Expand Up @@ -4,6 +4,7 @@
<use name="Alignment/MuonAlignment"/>
<use name="Alignment/SurveyAnalysis"/>
<use name="Alignment/ReferenceTrajectories"/>
<use name="CondFormats/PCLConfig"/>
<use name="DataFormats/CLHEP"/>
<use name="DataFormats/SiStripDetId"/>
<use name="DataFormats/GeometryVector"/>
Expand Down
Expand Up @@ -10,15 +10,17 @@

/*** Alignment ***/
#include "Alignment/MillePedeAlignmentAlgorithm/interface/PedeLabelerBase.h"

#include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h"

class MillePedeFileReader {

//========================== PUBLIC METHODS ==================================
public: //====================================================================

explicit MillePedeFileReader(const edm::ParameterSet&,
const std::shared_ptr<const PedeLabelerBase>&);
const std::shared_ptr<const PedeLabelerBase>&,
const std::shared_ptr<const AlignPCLThresholds>&);

virtual ~MillePedeFileReader() = default;

void read();
Expand Down Expand Up @@ -57,26 +59,21 @@ class MillePedeFileReader {
void readMillePedeLogFile();
void readMillePedeResultFile();
PclHLS getHLS(const Alignable*);
std::string getStringFromHLS(PclHLS HLS);

//========================== PRIVATE DATA ====================================
//============================================================================

// pede labeler plugin
const std::shared_ptr<const PedeLabelerBase> pedeLabeler_;

// thresholds from DB
const std::shared_ptr<const AlignPCLThresholds> theThresholds_;

// file-names
const std::string millePedeLogFile_;
const std::string millePedeResFile_;

// signifiance of movement must be above
const double sigCut_;
// cutoff in micro-meter & micro-rad
const double Xcut_, tXcut_;
const double Ycut_, tYcut_;
const double Zcut_, tZcut_;
// maximum movement in micro-meter/rad
const double maxMoveCut_, maxErrorCut_;


// conversion factors: cm to um & rad to urad
static constexpr std::array<double, 6> multiplier_ = {{ 10000., // X
10000., // Y
Expand All @@ -85,9 +82,6 @@ class MillePedeFileReader {
1000000., // tY
1000000. }}; // tZ

const std::array<double, 6> cutoffs_ = {{ Xcut_, Ycut_, Zcut_,
tXcut_, tYcut_, tZcut_}};

bool updateDB_{false};
int Nrec_{0};

Expand All @@ -105,7 +99,14 @@ class MillePedeFileReader {
std::array<double, 6> ZobsErr_ = {{0.,0.,0.,0.,0.,0.}};
std::array<double, 6> tZobs_ = {{0.,0.,0.,0.,0.,0.}};
std::array<double, 6> tZobsErr_ = {{0.,0.,0.,0.,0.,0.}};

};

#include<iostream>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmusich please move includes to the top of the file

const std::array<std::string,8> coord_str = {{"X", "Y", "Z", "theta_X", "theta_Y", "theta_Z", "extra_DOF", "none"}};
inline std::ostream & operator<<(std::ostream & os, const AlignPCLThresholds::coordType& c) {
if (c >= AlignPCLThresholds::endOfTypes || c < 0) return os << "unrecongnized coordinate";
return os << coord_str[c];
}

#endif /* ALIGNMENT_MILLEPEDEALIGNMENTALGORITHM_INTERFACE_MILLEPEDEFILEREADER_H_ */
Expand Up @@ -60,6 +60,9 @@
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"

#include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h"
#include "CondFormats/DataRecord/interface/AlignPCLThresholdsRcd.h"

#include "DataFormats/TrackerRecHit2D/interface/ProjectedSiStripRecHit2D.h"

#include <fstream>
Expand Down Expand Up @@ -195,6 +198,16 @@ void MillePedeAlignmentAlgorithm::initialize(const edm::EventSetup &setup,
setup.get<TrackerTopologyRcd>().get(tTopoHandle);
const TrackerTopology* const tTopo = tTopoHandle.product();

//Retrieve the thresolds cuts from DB for the PCL
if (runAtPCL_) {
edm::ESHandle<AlignPCLThresholds> thresholdHandle;
setup.get<AlignPCLThresholdsRcd>().get(thresholdHandle);
theThresholds = thresholdHandle.product();
} else {
theThresholds = new AlignPCLThresholds();
edm::LogInfo("MillePedeAlignmentAlgorithm")<<"Creating a fake AlignPCLThresholds objects. Irrelevant since the running mode is not PCL"<<std::endl;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmusich I think the else clause is redundant. You could just leave it as nullptr.
Also, for the non-PCL case we have a memory leak here, while I am not sure who owns the object pointed to by theThresholds in case we run at PCL.


theAlignableNavigator = std::make_unique<AlignableNavigator>(extras, tracker, muon);
theAlignmentParameterStore = store;
theAlignables = theAlignmentParameterStore->alignables();
Expand Down Expand Up @@ -328,8 +341,13 @@ bool MillePedeAlignmentAlgorithm::storeAlignments()
{
if (isMode(myPedeRunBit)) {
if (runAtPCL_) {

auto myThresholds = new AlignPCLThresholds();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend wrapping this into a call to std::make_shared

myThresholds->setAlignPCLThresholds(theThresholds->getNrecords(),theThresholds->getThreshold_Map());

MillePedeFileReader mpReader(theConfig.getParameter<edm::ParameterSet>("MillePedeFileReader"),
thePedeLabels);
thePedeLabels,
std::shared_ptr<const AlignPCLThresholds>(myThresholds));
mpReader.read();
return mpReader.storeAlignments();
} else {
Expand Down
Expand Up @@ -20,6 +20,7 @@
#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"

#include "Alignment/ReferenceTrajectories/interface/ReferenceTrajectoryBase.h"
#include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h"

#include <vector>
#include <string>
Expand Down Expand Up @@ -262,6 +263,7 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase
std::unique_ptr<PedeSteerer> thePedeSteer;
std::unique_ptr<TrajectoryFactoryBase> theTrajectoryFactory;
std::vector<IntegratedCalibrationBase*> theCalibrations;
const AlignPCLThresholds* theThresholds;
unsigned int theMinNumHits;
double theMaximalCor2D; /// maximal correlation allowed for 2D hit in TID/TEC.
/// If larger, the 2D measurement gets diagonalized!!!
Expand Down