Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# file as real binary files to disk, so that the pede step can read them.
# This includes the formatting directive "%04d" which will be expanded to
# 0000, 0001, 0002,...
outputBinaryFile = cms.string('pedeBinary%04d.dat'))
outputBinaryFile = cms.string('pedeBinary%04d.dat.gz'))

from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import *
from Alignment.CommonAlignmentProducer.AlignmentProducerAsAnalyzer_cff import AlignmentProducer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# file as real binary files to disk, so that the pede step can read them.
# This includes the formatting directive "%04d" which will be expanded to
# 0000, 0001, 0002,...
outputBinaryFile = cms.string('pedeBinaryHGMinBias%04d.dat'))
outputBinaryFile = cms.string('pedeBinaryHGMinBias%04d.dat.gz'))

SiPixelAliMilleFileExtractorHGZMuMu = cms.EDAnalyzer("MillePedeFileExtractor",
fileBlobInputTag = cms.InputTag("SiPixelAliMillePedeFileConverterHGDimuon",''),
Expand All @@ -16,7 +16,7 @@
# file as real binary files to disk, so that the pede step can read them.
# This includes the formatting directive "%04d" which will be expanded to
# 0000, 0001, 0002,...
outputBinaryFile = cms.string('pedeBinaryHGDiMuon%04d.dat'))
outputBinaryFile = cms.string('pedeBinaryHGDiMuon%04d.dat.gz'))

from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import *
from Alignment.CommonAlignmentProducer.AlignmentProducerAsAnalyzer_cff import AlignmentProducer
Expand Down Expand Up @@ -44,7 +44,7 @@
runAtPCL = True,
#mergeBinaryFiles = [SiPixelAliMilleFileExtractorHGMinBias.outputBinaryFile.value()],
#mergeBinaryFiles = [SiPixelAliMilleFileExtractorHGZMuMu.outputBinaryFile.value()],
mergeBinaryFiles = ['pedeBinaryHGMinBias%04d.dat','pedeBinaryHGDiMuon%04d.dat -- 10.0'],
mergeBinaryFiles = ['pedeBinaryHGMinBias%04d.dat.gz','pedeBinaryHGDiMuon%04d.dat.gz -- 10.0'],
binaryFile = '',
TrajectoryFactory = cms.PSet(BrokenLinesTrajectoryFactory),
minNumHits = 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# file as real binary files to disk, so that the pede step can read them.
# This includes the formatting directive "%04d" which will be expanded to
# 0000, 0001, 0002,...
outputBinaryFile = cms.string('pedeBinaryHG%04d.dat'))
outputBinaryFile = cms.string('pedeBinaryHG%04d.dat.gz'))

from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import *
from Alignment.CommonAlignmentProducer.AlignmentProducerAsAnalyzer_cff import AlignmentProducer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# file as real binary files to disk, so that the pede step can read them.
# This includes the formatting directive "%04d" which will be expanded to
# 0000, 0001, 0002,...
outputBinaryFile = cms.string('pedeBinaryHLTHGMinBias%04d.dat'))
outputBinaryFile = cms.string('pedeBinaryHLTHGMinBias%04d.dat.gz'))

SiPixelAliMilleFileExtractorHLTHGZMuMu = cms.EDAnalyzer("MillePedeFileExtractor",
fileBlobInputTag = cms.InputTag("SiPixelAliMillePedeFileConverterHLTHGDimuon",''),
Expand All @@ -16,7 +16,7 @@
# file as real binary files to disk, so that the pede step can read them.
# This includes the formatting directive "%04d" which will be expanded to
# 0000, 0001, 0002,...
outputBinaryFile = cms.string('pedeBinaryHLTHGDiMuon%04d.dat'))
outputBinaryFile = cms.string('pedeBinaryHLTHGDiMuon%04d.dat.gz'))

from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import *
from Alignment.CommonAlignmentProducer.AlignmentProducerAsAnalyzer_cff import AlignmentProducer
Expand Down Expand Up @@ -44,7 +44,7 @@
runAtPCL = True,
#mergeBinaryFiles = [SiPixelAliMilleFileExtractorHGMinBias.outputBinaryFile.value()],
#mergeBinaryFiles = [SiPixelAliMilleFileExtractorHGZMuMu.outputBinaryFile.value()],
mergeBinaryFiles = ['pedeBinaryHLTHGMinBias%04d.dat','pedeBinaryHLTHGDiMuon%04d.dat -- 10.0'],
mergeBinaryFiles = ['pedeBinaryHLTHGMinBias%04d.dat.gz','pedeBinaryHLTHGDiMuon%04d.dat.gz -- 10.0'],
binaryFile = '',
TrajectoryFactory = cms.PSet(BrokenLinesTrajectoryFactory),
minNumHits = 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# file as real binary files to disk, so that the pede step can read them.
# This includes the formatting directive "%04d" which will be expanded to
# 0000, 0001, 0002,...
outputBinaryFile = cms.string('pedeBinary%04d.dat'))
outputBinaryFile = cms.string('pedeBinary%04d.dat.gz'))

from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import *
from Alignment.CommonAlignmentProducer.AlignmentProducerAsAnalyzer_cff import AlignmentProducer
Expand Down
1 change: 1 addition & 0 deletions Alignment/MillePedeAlignmentAlgorithm/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<use name="FWCore/PluginManager"/>
<use name="Geometry/CommonDetUnit" source_only="1"/>
<use name="rootcore"/>
<use name="mille"/>
<export>
<lib name="1"/>
</export>
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#include "Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeMonitor.h"
#include "Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeVariables.h"
#include "Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeVariablesIORoot.h"
#include "Alignment/MillePedeAlignmentAlgorithm/src/Mille.h" // 'unpublished' interface located in src
#include "Alignment/MillePedeAlignmentAlgorithm/src/PedeSteerer.h" // ditto
#include "Alignment/MillePedeAlignmentAlgorithm/src/PedeReader.h" // ditto
#include "Mille/MilleFactory.h" // external Mille library
#include "Alignment/MillePedeAlignmentAlgorithm/src/PedeSteerer.h"
#include "Alignment/MillePedeAlignmentAlgorithm/src/PedeReader.h"
#include "Alignment/MillePedeAlignmentAlgorithm/interface/PedeLabelerBase.h"
#include "Alignment/MillePedeAlignmentAlgorithm/interface/PedeLabelerPluginFactory.h"

Expand Down Expand Up @@ -63,6 +63,7 @@
#include <fstream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <sys/stat.h>

#include <TMath.h>
Expand Down Expand Up @@ -121,11 +122,7 @@ MillePedeAlignmentAlgorithm::MillePedeAlignmentAlgorithm(const edm::ParameterSet
<< "Start in mode '" << theConfig.getUntrackedParameter<std::string>("mode")
<< "' with output directory '" << theDir << "'.";
if (this->isMode(myMilleBit)) {
theMille = std::make_unique<Mille>(
(theDir + theConfig.getParameter<std::string>("binaryFile")).c_str()); // add ', false);' for text output);
// use same file for GBL
theBinary = std::make_unique<MilleBinary>((theDir + theConfig.getParameter<std::string>("binaryFile")).c_str(),
theGblDoubleBinary);
theMille = Mille::spawnMilleRecord(theDir + theConfig.getParameter<std::string>("binaryFile"), theGblDoubleBinary);
}
}

Expand Down Expand Up @@ -384,7 +381,6 @@ bool MillePedeAlignmentAlgorithm::setParametersForRunRange(const RunRange &runra
void MillePedeAlignmentAlgorithm::terminate(const edm::EventSetup &iSetup) { terminate(); }
void MillePedeAlignmentAlgorithm::terminate() {
theMille.reset(); // delete to close binary before running pede below (flush would be enough...)
theBinary.reset();

std::vector<std::string> files;
if (this->isMode(myMilleBit) || !theConfig.getParameter<std::string>("binaryFile").empty()) {
Expand Down Expand Up @@ -552,7 +548,7 @@ std::pair<unsigned int, unsigned int> MillePedeAlignmentAlgorithm::addReferenceT
std::cout << " GblFit: " << Chi2 << ", " << Ndf << ", " << lostWeight << std::endl; */
// write to MP binary file
if (aGblTrajectory.isValid() && aGblTrajectory.getNumPoints() >= theMinNumHits)
aGblTrajectory.milleOut(*theBinary);
aGblTrajectory.milleOut(theMille.get());
}
if (refTrajPtr->gblInput().size() == 2) {
// from TwoBodyDecay
Expand All @@ -562,7 +558,7 @@ std::pair<unsigned int, unsigned int> MillePedeAlignmentAlgorithm::addReferenceT
refTrajPtr->gblExtPrecisions());
// write to MP binary file
if (aGblTrajectory.isValid() && aGblTrajectory.getNumPoints() >= theMinNumHits)
aGblTrajectory.milleOut(*theBinary);
aGblTrajectory.milleOut(theMille.get());
}
} else {
// to add hits if all fine:
Expand Down Expand Up @@ -590,10 +586,10 @@ std::pair<unsigned int, unsigned int> MillePedeAlignmentAlgorithm::addReferenceT

// kill or end 'track' for mille, depends on #hits criterion
if (hitResultXy.first == 0 || hitResultXy.first < theMinNumHits) {
theMille->kill();
theMille->abort();
hitResultXy.first = hitResultXy.second = 0; //reset
} else {
theMille->end();
theMille->writeRecord();
// add x/y hit count to MillePedeVariables of parVec,
// returning number of y-hits of the reference trajectory
hitResultXy.second = this->addHitCount(parVec, validHitVecY);
Expand Down Expand Up @@ -732,9 +728,6 @@ void MillePedeAlignmentAlgorithm::beginLuminosityBlock(const edm::EventSetup &)
return;
if (this->isMode(myMilleBit)) {
theMille->resetOutputFile();
theBinary.reset(); // GBL output has to be considered since same binary file is used
theBinary = std::make_unique<MilleBinary>((theDir + theConfig.getParameter<std::string>("binaryFile")).c_str(),
theGblDoubleBinary);
}
}

Expand Down Expand Up @@ -1377,12 +1370,15 @@ int MillePedeAlignmentAlgorithm ::callMille1D(const ReferenceTrajectoryBase::Ref

// local derivatives
const AlgebraicMatrix &locDerivMatrix = refTrajPtr->derivatives();
const int nLocal = locDerivMatrix.num_col();
const size_t nLocal = locDerivMatrix.num_col();
std::vector<float> localDerivatives(nLocal);
for (unsigned int i = 0; i < localDerivatives.size(); ++i) {
localDerivatives[i] = locDerivMatrix[xIndex][i];
}

// build the list of local labels, numbered consecutively starting at 1
prepareLocalLabels(nLocal);

// residuum and error
float residX = refTrajPtr->measurements()[xIndex] - refTrajPtr->trajectoryPositions()[xIndex];
float hitErrX = TMath::Sqrt(refTrajPtr->measurementErrors()[xIndex][xIndex]);
Expand All @@ -1392,8 +1388,7 @@ int MillePedeAlignmentAlgorithm ::callMille1D(const ReferenceTrajectoryBase::Ref

// &(localDerivatives[0]) etc. are valid - as long as vector is not empty
// cf. http://www.parashift.com/c++-faq-lite/containers.html#faq-34.3
theMille->mille(
nLocal, &(localDerivatives[0]), nGlobal, &(globalDerivativesX[0]), &(globalLabels[0]), residX, hitErrX);
theMille->addData(residX, hitErrX, theLocalLabelBuffer_, localDerivatives, globalLabels, globalDerivativesX);

if (theMonitor) {
theMonitor->fillDerivatives(
Expand Down Expand Up @@ -1466,8 +1461,8 @@ int MillePedeAlignmentAlgorithm ::callMille2D(const ReferenceTrajectoryBase::Ref
float *newGlobDerivsX = &(newGlobDerivs[0]);
float *newGlobDerivsY = &(newGlobDerivs[aGlobalDerivativesM.cols()]);

const int nLocal = aLocalDerivativesM.cols();
const int nGlobal = aGlobalDerivativesM.cols();
const size_t nLocal = aLocalDerivativesM.cols();
const size_t nGlobal = aGlobalDerivativesM.cols();

if (diag && (newHitErrX > newHitErrY)) { // also for 2D hits?
// measurement with smaller error is x-measurement (for !is2D do not fill y-measurement):
Expand All @@ -1477,9 +1472,14 @@ int MillePedeAlignmentAlgorithm ::callMille2D(const ReferenceTrajectoryBase::Ref
std::swap(newGlobDerivsX, newGlobDerivsY);
}

// &(globalLabels[0]) is valid - as long as vector is not empty
// cf. http://www.parashift.com/c++-faq-lite/containers.html#faq-34.3
theMille->mille(nLocal, newLocalDerivsX, nGlobal, newGlobDerivsX, &(globalLabels[0]), newResidX, newHitErrX);
prepareLocalLabels(nLocal);
Copy link
Contributor

Choose a reason for hiding this comment

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

In this case you did not modify the argument nlocal to a size_t
Both nLocal and nGlobal here above should be left unsigned int for their usage as arguments for MilleArrayView... but the same happens later on at L1686: so better to stay consistent and define them as size_t also here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, moved both to size_t (and also used const consistently in all occurrences).


theMille->addData(newResidX,
newHitErrX,
theLocalLabelBuffer_,
Mille::MilleArrayView<float>(newLocalDerivsX, nLocal),
globalLabels,
Mille::MilleArrayView<float>(newGlobDerivsX, nGlobal));

if (theMonitor) {
theMonitor->fillDerivatives(aRecHit, newLocalDerivsX, nLocal, newGlobDerivsX, nGlobal, &(globalLabels[0]));
Expand All @@ -1488,7 +1488,12 @@ int MillePedeAlignmentAlgorithm ::callMille2D(const ReferenceTrajectoryBase::Ref
}
const bool isReal2DHit = this->is2D(aRecHit); // strip is 1D (except matched hits)
if (isReal2DHit) {
theMille->mille(nLocal, newLocalDerivsY, nGlobal, newGlobDerivsY, &(globalLabels[0]), newResidY, newHitErrY);
theMille->addData(newResidY,
newHitErrY,
theLocalLabelBuffer_,
Mille::MilleArrayView<float>(newLocalDerivsY, nLocal),
globalLabels,
Mille::MilleArrayView<float>(newGlobDerivsY, nGlobal));
if (theMonitor) {
theMonitor->fillDerivatives(aRecHit, newLocalDerivsY, nLocal, newGlobDerivsY, nGlobal, &(globalLabels[0]));
theMonitor->fillResiduals(
Expand All @@ -1498,6 +1503,14 @@ int MillePedeAlignmentAlgorithm ::callMille2D(const ReferenceTrajectoryBase::Ref

return (isReal2DHit ? 2 : 1);
}
void MillePedeAlignmentAlgorithm ::prepareLocalLabels(size_t nLocal) {
// content always the same - so only need to do something upon size change
if (nLocal != theLocalLabelBuffer_.size()) {
// build the list of local labels, numbered consecutively starting at 1
theLocalLabelBuffer_.resize(nLocal);
std::iota(theLocalLabelBuffer_.begin(), theLocalLabelBuffer_.end(), 1);
}
}

//__________________________________________________________________________________________________
void MillePedeAlignmentAlgorithm ::addVirtualMeas(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr,
Expand All @@ -1521,10 +1534,11 @@ void MillePedeAlignmentAlgorithm ::addVirtualMeas(const ReferenceTrajectoryBase:
Eigen::Map<Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> >(
newGlobDerivsX.data(), aGlobalDerivativesM.rows(), aGlobalDerivativesM.cols()) = aGlobalDerivativesM;

const int nLocal = aLocalDerivativesM.cols();
const int nGlobal = 0;
const size_t nLocal = aLocalDerivativesM.cols();
prepareLocalLabels(nLocal);

theMille->mille(nLocal, newLocalDerivsX.data(), nGlobal, newGlobDerivsX.data(), &nGlobal, newResidX, newHitErrX);
theMille->addData(
newResidX, newHitErrX, theLocalLabelBuffer_, newLocalDerivsX, std::vector<int>{}, std::vector<float>{});
}

//____________________________________________________
Expand Down Expand Up @@ -1581,17 +1595,11 @@ void MillePedeAlignmentAlgorithm::addLasBeam(const EventInfo &eventInfo,
const float residual = hit.localPosition().x() - tsoses[iHit].localPosition().x();
// error from file or assume 0.003
const float error = 0.003; // hit.localPositionError().xx(); sqrt???
Copy link
Contributor

Choose a reason for hiding this comment

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

This is beyond this PR, but I do wonder: is this really meant to be hardcoded at 0.003?

Copy link
Contributor

Choose a reason for hiding this comment

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

as this pertains to MillePedeAlignmentAlgorithm::addLasBeam (LAS system decomissioned in 2014) I hardly can see how this could be relevant.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didnt realize this was for LAS. So this function could be fully removed too then?

Copy link
Contributor

Choose a reason for hiding this comment

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

probably 🤷‍♂️


theMille->mille(lasLocalDerivsX.size(),
&(lasLocalDerivsX[0]),
theFloatBufferX.size(),
&(theFloatBufferX[0]),
&(theIntBuffer[0]),
residual,
error);
prepareLocalLabels(lasLocalDerivsX.size());
theMille->addData(residual, error, theLocalLabelBuffer_, lasLocalDerivsX, theIntBuffer, theFloatBufferX);
} // end of loop over hits

theMille->end();
theMille->writeRecord();
}

void MillePedeAlignmentAlgorithm::addPxbSurvey(const edm::ParameterSet &pxbSurveyCfg) {
Expand Down Expand Up @@ -1672,15 +1680,17 @@ void MillePedeAlignmentAlgorithm::addPxbSurvey(const edm::ParameterSet &pxbSurve

// pass the results from the local fit to mille
for (SurveyPxbImageLocalFit::count_t j = 0; j != SurveyPxbImageLocalFit::nMsrmts; j++) {
theMille->mille((int)measurements[i].getLocalDerivsSize(),
measurements[i].getLocalDerivsPtr(j),
(int)measurements[i].getGlobalDerivsSize(),
measurements[i].getGlobalDerivsPtr(j),
measurements[i].getGlobalDerivsLabelPtr(j),
measurements[i].getResiduum(j),
measurements[i].getSigma(j));
const size_t nLocal = measurements[i].getLocalDerivsSize();
const size_t nGlobal = measurements[i].getGlobalDerivsSize();
prepareLocalLabels(nLocal);
theMille->addData(measurements[i].getResiduum(j),
measurements[i].getSigma(j),
theLocalLabelBuffer_,
Mille::MilleArrayView<float>(measurements[i].getLocalDerivsPtr(j), nLocal),
Mille::MilleArrayView<int>(measurements[i].getGlobalDerivsLabelPtr(j), nGlobal),
Mille::MilleArrayView<float>(measurements[i].getGlobalDerivsPtr(j), nGlobal));
}
theMille->end();
theMille->writeRecord();
}
outfile.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class IntegratedCalibrationBase;
class MillePedeMonitor;
class PedeSteerer;
class PedeLabelerBase;
class Mille;
namespace Mille {
class MilleRecord;
}
class TrajectoryFactoryBase;

// already from base class - and forward declaration does not work since typedef!
Expand Down Expand Up @@ -266,6 +268,10 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase {
const TkFittedLasBeam &lasBeam,
const std::vector<TrajectoryStateOnSurface> &tsoses);

// ensure our local label vector for Mille has the expected
// size and content.
void prepareLocalLabels(size_t nLocal);

/// add measurement data from PXB survey
void addPxbSurvey(const edm::ParameterSet &pxbSurveyCfg);

Expand Down Expand Up @@ -294,7 +300,7 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase {
align::Alignables theAlignables;
std::unique_ptr<AlignableNavigator> theAlignableNavigator;
std::unique_ptr<MillePedeMonitor> theMonitor;
std::unique_ptr<Mille> theMille;
std::unique_ptr<Mille::MilleRecord> theMille;
std::shared_ptr<PedeLabelerBase> thePedeLabels;
std::unique_ptr<PedeSteerer> thePedeSteer;
std::unique_ptr<TrajectoryFactoryBase> theTrajectoryFactory;
Expand All @@ -312,9 +318,8 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase {
std::vector<float> theFloatBufferX;
std::vector<float> theFloatBufferY;
std::vector<int> theIntBuffer;
std::vector<unsigned int> theLocalLabelBuffer_ = {};
bool theDoSurveyPixelBarrel;
// CHK for GBL
std::unique_ptr<gbl::MilleBinary> theBinary;
bool theGblDoubleBinary;

const bool runAtPCL_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void MillePedeFileExtractor::fillDescriptions(edm::ConfigurationDescriptions& de
"Keep the fileDir empty if you want to write to the current "
"directory.");

desc.add<std::string>("outputBinaryFile", "milleBinary%04d.dat")
desc.add<std::string>("outputBinaryFile", "milleBinary%04d.dat.gz")
->setComment(
"Base filename of the files that will be created. This must "
"contain "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#TODO: Above sentence needs to be finished, otherwise I don't know what to fix.
fileBlobInputTag = cms.InputTag("SiPixelAliMillePedeFileConverter",""),
# You can add formatting directives like "%04d" in the output file name to setup numbering.
outputBinaryFile = cms.string('pippo%04d.dat'),
outputBinaryFile = cms.string('pippo%04d.dat.gz'),
fileDir = cms.string('/afs/cern.ch/work/b/bvanbesi/private/PCLALI/CMSSW_7_4_4/src/'))
##fileDir = cms.string('/afs/cern.ch/work/c/cerminar/pcl/ali/frombroen/new/CMSSW_7_4_4/src/'))

Expand Down
Loading