diff --git a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester0T_cff.py b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester0T_cff.py index d0100ecc7297a..bb75ff1a51e27 100644 --- a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester0T_cff.py +++ b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester0T_cff.py @@ -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 diff --git a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvesterHGCombined_cff.py b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvesterHGCombined_cff.py index d75ff274479c3..5383ac90d01e2 100644 --- a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvesterHGCombined_cff.py +++ b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvesterHGCombined_cff.py @@ -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",''), @@ -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 @@ -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, diff --git a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvesterHG_cff.py b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvesterHG_cff.py index 56a930fcb8cc0..17a9dbee3e5fc 100644 --- a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvesterHG_cff.py +++ b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvesterHG_cff.py @@ -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 diff --git a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvesterHLTHGCombined_cff.py b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvesterHLTHGCombined_cff.py index 91714f09df13d..02d62edab84e9 100644 --- a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvesterHLTHGCombined_cff.py +++ b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvesterHLTHGCombined_cff.py @@ -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",''), @@ -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 @@ -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, diff --git a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py index e3de9a5155ec5..d80355da3c639 100644 --- a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py +++ b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py @@ -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 diff --git a/Alignment/MillePedeAlignmentAlgorithm/BuildFile.xml b/Alignment/MillePedeAlignmentAlgorithm/BuildFile.xml index 6816045aa2463..d0b8007a72ab9 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/BuildFile.xml +++ b/Alignment/MillePedeAlignmentAlgorithm/BuildFile.xml @@ -15,6 +15,7 @@ + diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc index 5ffe0431cea6e..eef21aeb3262d 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc @@ -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" @@ -63,6 +63,7 @@ #include #include #include +#include #include #include @@ -121,11 +122,7 @@ MillePedeAlignmentAlgorithm::MillePedeAlignmentAlgorithm(const edm::ParameterSet << "Start in mode '" << theConfig.getUntrackedParameter("mode") << "' with output directory '" << theDir << "'."; if (this->isMode(myMilleBit)) { - theMille = std::make_unique( - (theDir + theConfig.getParameter("binaryFile")).c_str()); // add ', false);' for text output); - // use same file for GBL - theBinary = std::make_unique((theDir + theConfig.getParameter("binaryFile")).c_str(), - theGblDoubleBinary); + theMille = Mille::spawnMilleRecord(theDir + theConfig.getParameter("binaryFile"), theGblDoubleBinary); } } @@ -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 files; if (this->isMode(myMilleBit) || !theConfig.getParameter("binaryFile").empty()) { @@ -552,7 +548,7 @@ std::pair 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 @@ -562,7 +558,7 @@ std::pair 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: @@ -590,10 +586,10 @@ std::pair 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); @@ -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((theDir + theConfig.getParameter("binaryFile")).c_str(), - theGblDoubleBinary); } } @@ -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 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]); @@ -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( @@ -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): @@ -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); + + theMille->addData(newResidX, + newHitErrX, + theLocalLabelBuffer_, + Mille::MilleArrayView(newLocalDerivsX, nLocal), + globalLabels, + Mille::MilleArrayView(newGlobDerivsX, nGlobal)); if (theMonitor) { theMonitor->fillDerivatives(aRecHit, newLocalDerivsX, nLocal, newGlobDerivsX, nGlobal, &(globalLabels[0])); @@ -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(newLocalDerivsY, nLocal), + globalLabels, + Mille::MilleArrayView(newGlobDerivsY, nGlobal)); if (theMonitor) { theMonitor->fillDerivatives(aRecHit, newLocalDerivsY, nLocal, newGlobDerivsY, nGlobal, &(globalLabels[0])); theMonitor->fillResiduals( @@ -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, @@ -1521,10 +1534,11 @@ void MillePedeAlignmentAlgorithm ::addVirtualMeas(const ReferenceTrajectoryBase: Eigen::Map >( 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{}, std::vector{}); } //____________________________________________________ @@ -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??? - - 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) { @@ -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(measurements[i].getLocalDerivsPtr(j), nLocal), + Mille::MilleArrayView(measurements[i].getGlobalDerivsLabelPtr(j), nGlobal), + Mille::MilleArrayView(measurements[i].getGlobalDerivsPtr(j), nGlobal)); } - theMille->end(); + theMille->writeRecord(); } outfile.close(); } diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.h b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.h index af30910c9ddee..9f6df61b3095e 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.h +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.h @@ -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! @@ -266,6 +268,10 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase { const TkFittedLasBeam &lasBeam, const std::vector &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); @@ -294,7 +300,7 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase { align::Alignables theAlignables; std::unique_ptr theAlignableNavigator; std::unique_ptr theMonitor; - std::unique_ptr theMille; + std::unique_ptr theMille; std::shared_ptr thePedeLabels; std::unique_ptr thePedeSteer; std::unique_ptr theTrajectoryFactory; @@ -312,9 +318,8 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase { std::vector theFloatBufferX; std::vector theFloatBufferY; std::vector theIntBuffer; + std::vector theLocalLabelBuffer_ = {}; bool theDoSurveyPixelBarrel; - // CHK for GBL - std::unique_ptr theBinary; bool theGblDoubleBinary; const bool runAtPCL_; diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc index e5e32a919d07c..fc9edf48cb341 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc @@ -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("outputBinaryFile", "milleBinary%04d.dat") + desc.add("outputBinaryFile", "milleBinary%04d.dat.gz") ->setComment( "Base filename of the files that will be created. This must " "contain " diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileExtractor_cfg.py b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileExtractor_cfg.py index 04da8ca22da15..a21747a917391 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileExtractor_cfg.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileExtractor_cfg.py @@ -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/')) diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/Mille.cc b/Alignment/MillePedeAlignmentAlgorithm/src/Mille.cc deleted file mode 100644 index 1eea086dece9c..0000000000000 --- a/Alignment/MillePedeAlignmentAlgorithm/src/Mille.cc +++ /dev/null @@ -1,199 +0,0 @@ -/** - * \file Mille.cc - * \author : Gero Flucke - * date : October 2006 - * $Revision: 1.3 $ - * $Date: 2007/04/16 17:47:38 $ - * (last update by $Author: flucke $) - */ - -#include "Mille.h" - -#include -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -//___________________________________________________________________________ - -Mille::Mille(const char *outFileName, bool asBinary, bool writeZero) - : fileMode_(asBinary ? (std::ios::binary | std::ios::out) : std::ios::out), - fileName_(outFileName), - outFile_(fileName_, fileMode_), - asBinary_(asBinary), - writeZero_(writeZero), - bufferPos_(-1), - hasSpecial_(false) { - // opens outFileName, by default as binary file - - // Instead bufferPos_(-1), hasSpecial_(false) and the following two lines - // we could call newSet() and kill()... - bufferInt_[0] = 0; - bufferFloat_[0] = 0.; - - if (!outFile_.is_open()) { - edm::LogError("Alignment") << "Mille::Mille: Could not open " << fileName_ << " as output file."; - } -} - -//___________________________________________________________________________ - -Mille::~Mille() { - // closes file - outFile_.close(); -} - -//___________________________________________________________________________ - -void Mille::mille(int NLC, const float *derLc, int NGL, const float *derGl, const int *label, float rMeas, float sigma) { - if (sigma <= 0.) - return; - if (bufferPos_ == -1) - this->newSet(); // start, e.g. new track - if (!this->checkBufferSize(NLC, NGL)) - return; - - // first store measurement - ++bufferPos_; - bufferFloat_[bufferPos_] = rMeas; - bufferInt_[bufferPos_] = 0; - - // store local derivatives and local 'lables' 1,...,NLC - for (int i = 0; i < NLC; ++i) { - if (derLc[i] || writeZero_) { // by default store only non-zero derivatives - ++bufferPos_; - bufferFloat_[bufferPos_] = derLc[i]; // local derivatives - bufferInt_[bufferPos_] = i + 1; // index of local parameter - } - } - - // store uncertainty of measurement in between locals and globals - ++bufferPos_; - bufferFloat_[bufferPos_] = sigma; - bufferInt_[bufferPos_] = 0; - - // store global derivatives and their lables - for (int i = 0; i < NGL; ++i) { - if (derGl[i] || writeZero_) { // by default store only non-zero derivatives - if ((label[i] > 0 || writeZero_) && label[i] <= maxLabel_) { // and for valid labels - ++bufferPos_; - bufferFloat_[bufferPos_] = derGl[i]; // global derivatives - bufferInt_[bufferPos_] = label[i]; // index of global parameter - } else { - edm::LogError("Alignment") << "Mille::mille: Invalid label " << label[i] << " <= 0 or > " << maxLabel_; - } - } - } -} - -//___________________________________________________________________________ -void Mille::special(int nSpecial, const float *floatings, const int *integers) { - if (nSpecial == 0) - return; - if (bufferPos_ == -1) - this->newSet(); // start, e.g. new track - if (hasSpecial_) { - edm::LogError("Alignment") << "Mille::special: Special values already stored for this record."; - return; - } - if (!this->checkBufferSize(nSpecial, 0)) - return; - hasSpecial_ = true; // after newSet() (Note: MILLSP sets to buffer position...) - - // bufferFloat_[.] | bufferInt_[.] - // ------------------------------------ - // 0.0 | 0 - // -float(nSpecial) | 0 - // The above indicates special data, following are nSpecial floating and nSpecial integer data. - - ++bufferPos_; // zero pair - bufferFloat_[bufferPos_] = 0.; - bufferInt_[bufferPos_] = 0; - - ++bufferPos_; // nSpecial and zero - bufferFloat_[bufferPos_] = -nSpecial; // automatic conversion to float - bufferInt_[bufferPos_] = 0; - - for (int i = 0; i < nSpecial; ++i) { - ++bufferPos_; - bufferFloat_[bufferPos_] = floatings[i]; - bufferInt_[bufferPos_] = integers[i]; - } -} - -//___________________________________________________________________________ - -void Mille::kill() { - // reset buffers, i.e. kill derivatives accumulated for current set - bufferPos_ = -1; -} - -//___________________________________________________________________________ - -void Mille::flushOutputFile() { - // flush output file - outFile_.flush(); -} - -//___________________________________________________________________________ - -void Mille::resetOutputFile() { - // flush output file - outFile_.close(); - outFile_.open(fileName_, fileMode_); - if (!outFile_.is_open()) { - edm::LogError("Alignment") << "Mille::resetOutputFile: Could not reopen " << fileName_ << "."; - } -} - -//___________________________________________________________________________ - -void Mille::end() { - // write set of derivatives with same local parameters to file - if (bufferPos_ > 0) { // only if anything stored... - const int numWordsToWrite = (bufferPos_ + 1) * 2; - - if (asBinary_) { - outFile_.write(reinterpret_cast(&numWordsToWrite), sizeof(numWordsToWrite)); - outFile_.write(reinterpret_cast(bufferFloat_), (bufferPos_ + 1) * sizeof(bufferFloat_[0])); - outFile_.write(reinterpret_cast(bufferInt_), (bufferPos_ + 1) * sizeof(bufferInt_[0])); - } else { - outFile_ << numWordsToWrite << "\n"; - for (int i = 0; i < bufferPos_ + 1; ++i) { - outFile_ << bufferFloat_[i] << " "; - } - outFile_ << "\n"; - - for (int i = 0; i < bufferPos_ + 1; ++i) { - outFile_ << bufferInt_[i] << " "; - } - outFile_ << "\n"; - } - } - bufferPos_ = -1; // reset buffer for next set of derivatives -} - -//___________________________________________________________________________ - -void Mille::newSet() { - // initilise for new set of locals, e.g. new track - bufferPos_ = 0; - hasSpecial_ = false; - bufferFloat_[0] = 0.0; - bufferInt_[0] = 0; // position 0 used as error counter -} - -//___________________________________________________________________________ - -bool Mille::checkBufferSize(int nLocal, int nGlobal) { - // enough space for next nLocal + nGlobal derivatives incl. measurement? - - if (bufferPos_ + nLocal + nGlobal + 2 >= bufferSize_) { - ++(bufferInt_[0]); // increase error count - edm::LogError("Alignment") << "Mille::checkBufferSize: Buffer too short (" << bufferSize_ << ")," - << "\n need space for nLocal (" << nLocal << ")" - << "/nGlobal (" << nGlobal << ") local/global derivatives, " << bufferPos_ + 1 - << " already stored!"; - return false; - } else { - return true; - } -} diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/Mille.h b/Alignment/MillePedeAlignmentAlgorithm/src/Mille.h deleted file mode 100644 index f93de120e09f9..0000000000000 --- a/Alignment/MillePedeAlignmentAlgorithm/src/Mille.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef MILLE_H -#define MILLE_H - -#include - -/** - * \class Mille - * - * Class to write a C binary (cf. below) file of a given name and to fill it - * with information used as input to pede. - * Use its member functions mille(...), special(...), kill() and end() as you would - * use the fortran MILLE and its entry points MILLSP, KILLE and ENDLE. - * - * For debugging purposes constructor flags enable switching to text output and/or - * to write also derivatives and lables which are ==0. - * But note that pede will not be able to read text output and has not been tested with - * derivatives/labels ==0. - * - * \author : Gero Flucke - * date : October 2006 - * $Revision: 1.2 $ - * $Date: 2007/03/16 16:44:47 $ - * (last update by $Author: flucke $) - */ - -class Mille { -public: - Mille(const char *outFileName, bool asBinary = true, bool writeZero = false); - ~Mille(); - - void mille(int NLC, const float *derLc, int NGL, const float *derGl, const int *label, float rMeas, float sigma); - void special(int nSpecial, const float *floatings, const int *integers); - void kill(); - void flushOutputFile(); - void resetOutputFile(); - void end(); - -private: - void newSet(); - bool checkBufferSize(int nLocal, int nGlobal); - - const std::ios_base::openmode fileMode_; // file open mode of the binary - const std::string fileName_; // file name of the binary - std::ofstream outFile_; // C-binary for output - bool asBinary_; // if false output as text - bool writeZero_; // if true also write out derivatives/lables ==0 - - enum { bufferSize_ = 5000 }; - int bufferInt_[bufferSize_]; // to collect labels etc. - float bufferFloat_[bufferSize_]; // to collect derivatives etc. - int bufferPos_; - bool hasSpecial_; // if true, special(..) already called for this record - - enum { maxLabel_ = (0xFFFFFFFF - (1 << 31)) }; // largest label allowed: 2^31 - 1 -}; -#endif diff --git a/Alignment/ReferenceTrajectories/BuildFile.xml b/Alignment/ReferenceTrajectories/BuildFile.xml index 1b5a5c3cc1320..26be81664cc1c 100644 --- a/Alignment/ReferenceTrajectories/BuildFile.xml +++ b/Alignment/ReferenceTrajectories/BuildFile.xml @@ -16,6 +16,7 @@ + diff --git a/PhysicsTools/PythonAnalysis/scripts/edmMakePhDThesis b/PhysicsTools/PythonAnalysis/scripts/edmMakePhDThesis index 3496d01c29ec0..1c030f0e5b323 100755 --- a/PhysicsTools/PythonAnalysis/scripts/edmMakePhDThesis +++ b/PhysicsTools/PythonAnalysis/scripts/edmMakePhDThesis @@ -156,7 +156,7 @@ from /afs/cern.ch/cms/sw/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libRint.s ### show rotating symbol, since non working software should at least look fancy def printRotor(number, end=" \n"): - rotor = "-\|/" + rotor = "-\\|/" sys.stdout.write(" ") for i in range(number): for symbol in rotor: @@ -170,8 +170,8 @@ def printRotor(number, end=" \n"): # got it? we are writing crap ;-) def printSingleLine(line,number, end = " "): - print line.ljust(40), - printRotor(number,end = end) + print (line.ljust(40), + printRotor(number,end = end)) ########################### @@ -181,10 +181,12 @@ if __name__ == "__main__": title = titles[int(random.random()*len(titles))] - print "Searching for topic... ", - printRotor(6) - print "\nProposing: ",title,"\n" + print ("Searching for topic... ", + printRotor(6)) + print ("\nProposing: ",title,"\n") + #TODO: Add ChatGPT API calls to produce an actual Thesis. + time.sleep(2) for line in initialMessages.splitlines(): printSingleLine(line, 2, end="DONE\n") @@ -193,11 +195,11 @@ if __name__ == "__main__": # and now let the poor user read tons of stupid output try: - for i in xrange(10): + for i in range(10): for line in stackTrace.splitlines(): - print line + print (line) time.sleep(0.01) except KeyboardInterrupt: - print "\nAh! Smart enough to find the way out of the procedure. ;-)" - print "That was saving you from another",int((10-i)*131*0.01),"seconds of silly output." + print ("\nAh! Smart enough to find the way out of the procedure. ;-)") + print ("That was saving you from another",int((10-i)*131*0.01),"seconds of silly output.")