Skip to content

Commit

Permalink
Merge branch 'CMSSW_8_0_X' into from-CMSSW_8_0_0
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael committed Mar 17, 2016
2 parents 9f8fd06 + bd2081e commit 2ae1a25
Show file tree
Hide file tree
Showing 508 changed files with 14,212 additions and 373,998 deletions.
Expand Up @@ -68,7 +68,8 @@ class AlignmentTrackSelector
ComparePt ptComparator;

const bool applyBasicCuts_, applyNHighestPt_, applyMultiplicityFilter_;
const bool seedOnlyFromAbove_, applyIsolation_, chargeCheck_ ;
const int seedOnlyFromAbove_;
const bool applyIsolation_, chargeCheck_;
const int nHighestPt_, minMultiplicity_, maxMultiplicity_;
const bool multiplicityOnInput_; /// if true, cut min/maxMultiplicity on input instead of on final result
const double ptMin_,ptMax_,pMin_,pMax_,etaMin_,etaMax_,phiMin_,phiMax_;
Expand Down
Expand Up @@ -206,7 +206,7 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase

/// Generates list of files to read, given the list and dir from the configuration.
/// This will automatically expand formatting directives, if they appear.
std::vector<std::string> getExistingFormattedFiles(const std::vector<std::string> plainFiles, std::string theDir);
std::vector<std::string> getExistingFormattedFiles(const std::vector<std::string>& plainFiles, const std::string& theDir);

void addLaserData(const EventInfo &eventInfo,
const TkFittedLasBeamCollection &tkLasBeams,
Expand Down
Expand Up @@ -311,10 +311,12 @@ void MillePedeAlignmentAlgorithm::terminate()
files = getExistingFormattedFiles(plainFiles, theDir);
// Do some logging:
std::string filesForLogOutput;
for (std::vector<std::string>::const_iterator i = files.begin(), iEnd = files.end(); i != iEnd; ++i) {
filesForLogOutput += " " + *i;
}
edm::LogInfo("Alignment") << "Based on the config parameter mergeBinaryFiles, using the following files as input:" << filesForLogOutput;
for (const auto& file: files) filesForLogOutput += " " + file + ",";
if (filesForLogOutput.length() != 0) filesForLogOutput.pop_back();
edm::LogInfo("Alignment")
<< "Based on the config parameter mergeBinaryFiles, using the following "
<< "files as input (assigned weights are indicated by ' -- <weight>'):"
<< filesForLogOutput;
}

// cache all positions, rotations and deformations
Expand All @@ -331,20 +333,22 @@ void MillePedeAlignmentAlgorithm::terminate()
theLastWrittenIov = 0;
}

std::vector<std::string> MillePedeAlignmentAlgorithm::getExistingFormattedFiles(const std::vector<std::string> plainFiles, std::string theDir) {
std::vector<std::string> MillePedeAlignmentAlgorithm::getExistingFormattedFiles(const std::vector<std::string>& plainFiles, const std::string& theDir) {
std::vector<std::string> files;
for (std::vector<std::string>::const_iterator i = plainFiles.begin(), iEnd = plainFiles.end(); i != iEnd; ++i) {
std::string theInputFileName = *i;
for (const auto& plainFile: plainFiles) {
std::string theInputFileName = plainFile;
int theNumber = 0;
while (true) {
// Create a formatted version of the filename, with growing numbers
// If the parameter doesn't contain a formatting directive, it just stays unchanged
char theNumberedInputFileName[200];
sprintf(theNumberedInputFileName, theInputFileName.c_str(), theNumber);
std::string theCompleteInputFileName = theDir + theNumberedInputFileName;
const auto endOfStrippedFileName = theCompleteInputFileName.rfind(" --");
const auto strippedInputFileName = theCompleteInputFileName.substr(0, endOfStrippedFileName);
// Check if the file exists
struct stat buffer;
if (stat (theCompleteInputFileName.c_str(), &buffer) == 0) {
if (stat (strippedInputFileName.c_str(), &buffer) == 0) {
// If the file exists, add it to the list
files.push_back(theCompleteInputFileName);
if (theNumberedInputFileName == theInputFileName) {
Expand All @@ -356,6 +360,8 @@ std::vector<std::string> MillePedeAlignmentAlgorithm::getExistingFormattedFiles(
}
} else {
// The file doesn't exist, break out of the loop
edm::LogWarning("Alignment")
<< "The input file '" << strippedInputFileName << "' does not exist.";
break;
}
}
Expand Down
Expand Up @@ -81,10 +81,12 @@ class TrackerValidationVariables
void fillTrackQuantities(const edm::Event&,
const edm::EventSetup&,
std::vector<AVTrackStruct> & v_avtrackout);

// need the following method for MonitorTrackResiduals in DQM/TrackerMonitorTrack
void fillHitQuantities(const edm::Event&, std::vector<AVHitStruct> & v_avhitout);

// all Tracks are passed to the trackFilter first, and only processed if it returns true.
void fillTrackQuantities(const edm::Event& event,
const edm::EventSetup& eventSetup,
std::function<bool(const reco::Track&)> trackFilter,
std::vector<AVTrackStruct> & v_avtrackout);

private:

edm::EDGetTokenT<std::vector<Trajectory> > trajCollectionToken_;
Expand Down
29 changes: 14 additions & 15 deletions Alignment/OfflineValidation/src/TrackerValidationVariables.cc
Expand Up @@ -309,6 +309,18 @@ void
TrackerValidationVariables::fillTrackQuantities(const edm::Event& event,
const edm::EventSetup& eventSetup,
std::vector<AVTrackStruct> & v_avtrackout)
{
fillTrackQuantities(event,
eventSetup,
[](const reco::Track&) -> bool { return true; },
v_avtrackout);
}

void
TrackerValidationVariables::fillTrackQuantities(const edm::Event& event,
const edm::EventSetup& eventSetup,
std::function<bool(const reco::Track&)> trackFilter,
std::vector<AVTrackStruct> & v_avtrackout)
{
edm::ESHandle<MagneticField> magneticField;
eventSetup.get<IdealMagneticFieldRecord>().get(magneticField);
Expand All @@ -327,6 +339,8 @@ TrackerValidationVariables::fillTrackQuantities(const edm::Event& event,
trajectory = &(*(*iPair).key);
track = &(*(*iPair).val);

if (!trackFilter(*track)) continue;

AVTrackStruct trackStruct;

trackStruct.p = track->p();
Expand Down Expand Up @@ -355,18 +369,3 @@ TrackerValidationVariables::fillTrackQuantities(const edm::Event& event,
}
}

void
TrackerValidationVariables::fillHitQuantities(const edm::Event& event, std::vector<AVHitStruct> & v_avhitout)
{
edm::Handle<std::vector<Trajectory> > trajCollectionHandle;
event.getByToken(trajCollectionToken_, trajCollectionHandle);

LogDebug("TrackerValidationVariables") << "trajColl->size(): " << trajCollectionHandle->size() ;

for (std::vector<Trajectory>::const_iterator it = trajCollectionHandle->begin(), itEnd = trajCollectionHandle->end();
it!=itEnd;
++it) {

fillHitQuantities(&(*it), v_avhitout);
}
}
1 change: 1 addition & 0 deletions CalibCalorimetry/CaloTPG/BuildFile.xml
Expand Up @@ -5,6 +5,7 @@
<use name="CalibFormats/HcalObjects"/>
<use name="Geometry/CaloTopology"/>
<use name="Geometry/HcalTowerAlgo"/>
<use name="CalibCalorimetry/HcalTPGAlgos"/>
<export>
<lib name="1"/>
</export>
7 changes: 6 additions & 1 deletion CalibCalorimetry/CaloTPG/plugins/CaloTPGTranscoderULUTs.cc
Expand Up @@ -62,6 +62,8 @@ class CaloTPGTranscoderULUTs : public edm::ESProducer {
std::vector<int> LUTfactor;
double nominal_gain;
double RCTLSB;
int NCTScaleShift;
int RCTScaleShift;
};

//
Expand Down Expand Up @@ -96,6 +98,9 @@ CaloTPGTranscoderULUTs::CaloTPGTranscoderULUTs(const edm::ParameterSet& iConfig)
nominal_gain = iConfig.getParameter<double>("nominal_gain");
RCTLSB = iConfig.getParameter<double>("RCTLSB");

edm::ParameterSet hfSS=iConfig.getParameter<edm::ParameterSet>("HFTPScaleShift");
NCTScaleShift = hfSS.getParameter<int>("NCT");
RCTScaleShift = hfSS.getParameter<int>("RCT");
}


Expand Down Expand Up @@ -157,7 +162,7 @@ CaloTPGTranscoderULUTs::produce(const CaloTPGRecord& iRecord)
fullLut.setTopo(htopo.product());

std::auto_ptr<CaloTPGTranscoderULUT> pTCoder(new CaloTPGTranscoderULUT(file1, file2));
pTCoder->setup(fullLut, *theTrigTowerGeometry);
pTCoder->setup(fullLut, *theTrigTowerGeometry, NCTScaleShift, RCTScaleShift);
return std::auto_ptr<CaloTPGTranscoder>( pTCoder );
}

Expand Down
8 changes: 7 additions & 1 deletion CalibCalorimetry/CaloTPG/python/CaloTPGTranscoder_cfi.py
@@ -1,5 +1,10 @@
import FWCore.ParameterSet.Config as cms

hfTPScaleShift =cms.PSet(
NCT= cms.int32(1),
RCT= cms.int32(3)
)

CaloTPGTranscoder = cms.ESProducer("CaloTPGTranscoderULUTs",
hcalLUT1 = cms.FileInPath('CalibCalorimetry/CaloTPG/data/outputLUTtranscoder_physics.dat'),
hcalLUT2 = cms.FileInPath('CalibCalorimetry/CaloTPG/data/TPGcalcDecompress2.txt'),
Expand All @@ -10,5 +15,6 @@
ZS = cms.vint32(4,2,1,0),
LUTfactor = cms.vint32(1,2,5,0),
nominal_gain = cms.double(0.177),
RCTLSB = cms.double(0.25)
RCTLSB = cms.double(0.25),
HFTPScaleShift = hfTPScaleShift,
)
25 changes: 11 additions & 14 deletions CalibCalorimetry/CaloTPG/src/CaloTPGTranscoderULUT.cc
Expand Up @@ -12,16 +12,14 @@
//#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "CondFormats/DataRecord/interface/HcalLutMetadataRcd.h"
#include "CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h"

using namespace std;

constexpr float CaloTPGTranscoderULUT::LSB_HF;
constexpr float CaloTPGTranscoderULUT::LSB_HBHE;

CaloTPGTranscoderULUT::CaloTPGTranscoderULUT(const std::string& compressionFile,
const std::string& decompressionFile)
: theTopology(0),
nominal_gain_(0.), rctlsb_factor_(0.),
nominal_gain_(0.), rctlsb_factor_(0.), nctlsb_factor_(0),
compressionFile_(compressionFile),
decompressionFile_(decompressionFile)
{
Expand Down Expand Up @@ -92,7 +90,9 @@ void CaloTPGTranscoderULUT::loadHCALCompress(HcalLutMetadata const& lutMetadata,
double cosh_ieta = fabs(cosh((eta_low + eta_high)/2.));
double granularity = meta->getLutGranularity();

double factor = isHBHE ? (nominal_gain_ / cosh_ieta * granularity) : rctlsb_factor_;
double factor = isHBHE ?
(nominal_gain_ / cosh_ieta * granularity) :
(version==0 ? rctlsb_factor_ : nctlsb_factor_);

LUT tpg = outputLUT_[index][0];
int low = 0;
Expand Down Expand Up @@ -207,15 +207,13 @@ const std::vector<unsigned int>& CaloTPGTranscoderULUT::getCompressionLUT(const
return outputLUT_[itower];
}

void CaloTPGTranscoderULUT::setup(HcalLutMetadata const& lutMetadata, HcalTrigTowerGeometry const& theTrigTowerGeometry)
void CaloTPGTranscoderULUT::setup(HcalLutMetadata const& lutMetadata, HcalTrigTowerGeometry const& theTrigTowerGeometry, int nctScaleShift, int rctScaleShift)
{
theTopology = lutMetadata.topo();
nominal_gain_ = lutMetadata.getNominalGain();
float rctlsb =lutMetadata.getRctLsb();
if (rctlsb != LSB_HBHE && rctlsb != LSB_HF)
throw cms::Exception("RCTLSB") << " value=" << rctlsb << " (should be " << LSB_HBHE
<< " or " << LSB_HF << ")" << std::endl;
rctlsb_factor_ = rctlsb;
theTopology = lutMetadata.topo();
nominal_gain_ = lutMetadata.getNominalGain();

rctlsb_factor_ = HcaluLUTTPGCoder::lsb_*(1<<rctScaleShift);
nctlsb_factor_ = HcaluLUTTPGCoder::lsb_*(1<<nctScaleShift);

if (compressionFile_.empty() && decompressionFile_.empty()) {
loadHCALCompress(lutMetadata,theTrigTowerGeometry);
Expand All @@ -224,4 +222,3 @@ void CaloTPGTranscoderULUT::setup(HcalLutMetadata const& lutMetadata, HcalTrigTo
throw cms::Exception("Not Implemented") << "setup of CaloTPGTranscoderULUT from text files";
}
}

6 changes: 2 additions & 4 deletions CalibCalorimetry/CaloTPG/src/CaloTPGTranscoderULUT.h
Expand Up @@ -34,7 +34,7 @@ class CaloTPGTranscoderULUT : public CaloTPGTranscoder {
virtual double hcaletValue(const HcalTrigTowerDetId& hid, const HcalTriggerPrimitiveSample& hc) const;
virtual bool HTvalid(const int ieta, const int iphi) const;
virtual const std::vector<unsigned int>& getCompressionLUT(const HcalTrigTowerDetId& id) const;
virtual void setup(HcalLutMetadata const&, HcalTrigTowerGeometry const&);
virtual void setup(HcalLutMetadata const&, HcalTrigTowerGeometry const&, int, int);
virtual int getOutputLUTId(const HcalTrigTowerDetId& id) const;
virtual int getOutputLUTId(const int ieta, const int iphi) const;

Expand All @@ -50,15 +50,13 @@ class CaloTPGTranscoderULUT : public CaloTPGTranscoder {
static const unsigned int TPGMAX = 256;
static const bool newHFphi = true;

static constexpr float LSB_HBHE = 0.25f;
static constexpr float LSB_HF = 0.5f;

// Member functions
void loadHCALCompress(HcalLutMetadata const&, HcalTrigTowerGeometry const&) ; //Analytical compression tables

// Member Variables
double nominal_gain_;
double rctlsb_factor_;
double nctlsb_factor_;
std::string compressionFile_;
std::string decompressionFile_;
std::vector<int> ietal;
Expand Down
2 changes: 2 additions & 0 deletions CalibCalorimetry/HcalAlgos/interface/HcalDbHardcode.h
Expand Up @@ -13,6 +13,7 @@
#include "CondFormats/HcalObjects/interface/HcalGainWidth.h"
#include "CondFormats/HcalObjects/interface/HcalQIECoder.h"
#include "CondFormats/HcalObjects/interface/HcalQIEShape.h"
#include "CondFormats/HcalObjects/interface/HcalQIEType.h"
#include "CondFormats/HcalObjects/interface/HcalCalibrationQIECoder.h"
#include "CondFormats/HcalObjects/interface/HcalElectronicsMap.h"
#include "DataFormats/HcalDetId/interface/HcalDcsDetId.h"
Expand All @@ -38,6 +39,7 @@ namespace HcalDbHardcode {
HcalQIECoder makeQIECoder (HcalGenericDetId fId);
HcalCalibrationQIECoder makeCalibrationQIECoder (HcalGenericDetId fId);
HcalQIEShape makeQIEShape ();
HcalQIEType makeQIEType (HcalGenericDetId fId, bool testHFQIE10);
HcalRecoParam makeRecoParam (HcalGenericDetId fId);
HcalMCParam makeMCParam (HcalGenericDetId fId);
HcalTimingParam makeTimingParam (HcalGenericDetId fId);
Expand Down
23 changes: 23 additions & 0 deletions CalibCalorimetry/HcalAlgos/src/HcalDbHardcode.cc
Expand Up @@ -6,6 +6,7 @@

#include "CLHEP/Random/RandGauss.h"
#include "CalibCalorimetry/HcalAlgos/interface/HcalDbHardcode.h"
#include "DataFormats/HcalDigi/interface/HcalQIENum.h"

HcalPedestal HcalDbHardcode::makePedestal (HcalGenericDetId fId, bool fSmear) {
HcalPedestalWidth width = makePedestalWidth (fId);
Expand Down Expand Up @@ -564,6 +565,28 @@ HcalQIECoder HcalDbHardcode::makeQIECoder (HcalGenericDetId fId) {
return result;
}

HcalQIEType HcalDbHardcode::makeQIEType (HcalGenericDetId fId, bool testHFQIE10) {
HcalQIENum qieType = QIE8; //default
if (testHFQIE10){ //2016 test
if(fId.genericSubdet() == HcalGenericDetId::HcalGenForward && fId.isHcalDetId()) {
HcalDetId hid(fId);
if(hid.depth()>=3) qieType = QIE10;
}
}
else { //generic upgrade case: QIE8 for HO, QIE10 for HF, QIE11 for HBHE
if (fId.genericSubdet() == HcalGenericDetId::HcalGenBarrel || fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap) {
qieType = QIE11;
} else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) {
qieType = QIE8;
} else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) {
qieType = QIE10;
}
}

HcalQIEType result(fId.rawId(),qieType);
return result;
}

HcalCalibrationQIECoder HcalDbHardcode::makeCalibrationQIECoder (HcalGenericDetId fId) {
HcalCalibrationQIECoder result (fId.rawId ());
float lowEdges [64];
Expand Down
Expand Up @@ -5,20 +5,21 @@
file = cms.untracked.string('')
)

from Geometry.HcalEventSetup.HcalRelabel_cfi import HcalReLabel
#------------------------- HARDCODED conditions

es_hardcode = cms.ESSource("HcalHardcodeCalibrations",
toGet = cms.untracked.vstring('GainWidths'),
#--- the following 5 parameters can be omitted in case of regular Geometry
iLumi = cms.double(-1.), # for Upgrade: fb-1
HcalReLabel = HcalReLabel, # for Upgrade
HERecalibration = cms.bool(False), # True for Upgrade
HEreCalibCutoff = cms.double(20.), # if above is True
HFRecalibration = cms.bool(False), # True for Upgrade
GainWidthsForTrigPrims = cms.bool(False) # True Upgrade
GainWidthsForTrigPrims = cms.bool(False),# True Upgrade
testHFQIE10 = cms.bool(False) # True 2016
)

from Configuration.StandardSequences.Eras import eras
eras.run2_HF_2016.toModify( es_hardcode, testHFQIE10=cms.bool(True) )

es_prefer_hcalHardcode = cms.ESPrefer("HcalHardcodeCalibrations", "es_hardcode")

20 changes: 18 additions & 2 deletions CalibCalorimetry/HcalPlugins/src/HcalHardcodeCalibrations.cc
Expand Up @@ -115,7 +115,9 @@ namespace {

}

HcalHardcodeCalibrations::HcalHardcodeCalibrations ( const edm::ParameterSet& iConfig ): he_recalibration(0), hf_recalibration(0), setHEdsegm(false), setHBdsegm(false), SipmLumi(0.0) {
HcalHardcodeCalibrations::HcalHardcodeCalibrations ( const edm::ParameterSet& iConfig ):
he_recalibration(0), hf_recalibration(0), setHEdsegm(false), setHBdsegm(false), SipmLumi(0.0), testHFQIE10(iConfig.getParameter<bool>("testHFQIE10"))
{
edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::HcalHardcodeCalibrations->...";

if ( iConfig.exists("GainWidthsForTrigPrims") )
Expand Down Expand Up @@ -365,7 +367,7 @@ std::auto_ptr<HcalQIETypes> HcalHardcodeCalibrations::produceQIETypes (const Hca
std::auto_ptr<HcalQIETypes> result (new HcalQIETypes (topo));
std::vector <HcalGenericDetId> cells = allCells(*topo);
for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); ++cell) {
HcalQIEType item(cell->rawId(),0);
HcalQIEType item = HcalDbHardcode::makeQIEType(*cell,testHFQIE10);
result->addValues(item);
}
return result;
Expand Down Expand Up @@ -758,3 +760,17 @@ std::auto_ptr<HcalCovarianceMatrices> HcalHardcodeCalibrations::produceCovarianc
}
return result;
}

void HcalHardcodeCalibrations::fillDescriptions(edm::ConfigurationDescriptions & descriptions){
edm::ParameterSetDescription desc;
desc.add<double>("iLumi",-1.);
desc.add<bool>("HERecalibration",false);
desc.add<double>("HEreCalibCutoff",20.);
desc.add<bool>("HFRecalibration",false);
desc.add<bool>("GainWidthsForTrigPrims",false);
desc.add<bool>("testHFQIE10",false);
desc.addUntracked<std::vector<std::string>>("toGet",std::vector<std::string>());
desc.addUntracked<bool>("fromDDD",false);

descriptions.addDefault(desc);
}

0 comments on commit 2ae1a25

Please sign in to comment.