Skip to content

Commit

Permalink
Merge pull request #18196 from mmusich/91X_SiPixelAliThresholds_CC
Browse files Browse the repository at this point in the history
[91X] SiPixelAli PCL payload creation thresholds from db - Consumer Code
  • Loading branch information
cmsbuild committed Apr 6, 2017
2 parents c91dc25 + 9495d8e commit a2b3bb9
Show file tree
Hide file tree
Showing 11 changed files with 304 additions and 128 deletions.
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 @@ -4,21 +4,24 @@
/*** system includes ***/
#include <array>
#include <string>
#include <iostream>

/*** core framework functionality ***/
#include "FWCore/ParameterSet/interface/ParameterSet.h"

/*** 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 All @@ -39,6 +42,8 @@ class MillePedeFileReader {
const std::array<double, 6>& getTZobs() const { return tZobs_; }
const std::array<double, 6>& getTZobsErr() const { return tZobsErr_; }

const AlignPCLThresholds::threshold_map getThresholdMap() const {return theThresholds_.get()->getThreshold_Map (); }

private:
//========================= PRIVATE ENUMS ====================================
//============================================================================
Expand All @@ -57,26 +62,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 +85,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 +102,13 @@ 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.}};

};

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,15 @@ 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);
auto th = thresholdHandle.product();
theThresholds = std::make_shared<AlignPCLThresholds>();
storeThresholds(th->getNrecords(),th->getThreshold_Map());
}

theAlignableNavigator = std::make_unique<AlignableNavigator>(extras, tracker, muon);
theAlignmentParameterStore = store;
theAlignables = theAlignmentParameterStore->alignables();
Expand Down Expand Up @@ -313,6 +325,13 @@ bool MillePedeAlignmentAlgorithm::addCalibrations(const std::vector<IntegratedCa
return true;
}

//____________________________________________________
bool MillePedeAlignmentAlgorithm::storeThresholds(const int & nRecords,const AlignPCLThresholds::threshold_map & thresholdMap)
{
theThresholds->setAlignPCLThresholds(nRecords,thresholdMap);
return true;
}

//_____________________________________________________________________________
bool MillePedeAlignmentAlgorithm::processesEvents()
{
Expand All @@ -328,8 +347,11 @@ bool MillePedeAlignmentAlgorithm::storeAlignments()
{
if (isMode(myPedeRunBit)) {
if (runAtPCL_) {

MillePedeFileReader mpReader(theConfig.getParameter<edm::ParameterSet>("MillePedeFileReader"),
thePedeLabels);
thePedeLabels,
theThresholds
);
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 @@ -72,6 +73,8 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase
/// Pass integrated calibrations to Millepede (they are not owned by Millepede!)
virtual bool addCalibrations(const std::vector<IntegratedCalibrationBase*> &iCals) override;

virtual bool storeThresholds(const int & nRecords,const AlignPCLThresholds::threshold_map & thresholdMap);

/// Called at end of job
virtual void terminate(const edm::EventSetup& iSetup) override;
/// Called at end of job
Expand Down Expand Up @@ -262,6 +265,7 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase
std::unique_ptr<PedeSteerer> thePedeSteer;
std::unique_ptr<TrajectoryFactoryBase> theTrajectoryFactory;
std::vector<IntegratedCalibrationBase*> theCalibrations;
std::shared_ptr<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

0 comments on commit a2b3bb9

Please sign in to comment.