Skip to content

Commit

Permalink
Merge branch 'master' into EMTF_PR_2018_10_1X_algo_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
abrinke1 committed May 2, 2018
2 parents 7b0338d + 76c73d7 commit 18be756
Show file tree
Hide file tree
Showing 1,133 changed files with 44,817 additions and 22,542 deletions.
@@ -1,7 +1,7 @@
import os
from genericValidation import GenericValidation, GenericValidationData
from geometryComparison import GeometryComparison
from helperFunctions import getCommandOutput2, parsecolor, parsestyle
from helperFunctions import boolfromstring, getCommandOutput2, parsecolor, parsestyle
from monteCarloValidation import MonteCarloValidation
from offlineValidation import OfflineValidation
from plottingOptions import PlottingOptions
Expand Down Expand Up @@ -31,7 +31,7 @@ def __init__(self, valName, config):
if "|" in self.title or "," in self.title or '"' in self.title:
msg = "The characters '|', '\"', and ',' cannot be used in the alignment title!"
raise AllInOneError(msg)
self.needsproxy = bool(int(self.general["needsproxy"]))
self.needsproxy = boolfromstring(self.general["needsproxy"], "needsproxy")
self.jobid = self.general["jobid"]
if self.jobid:
try: #make sure it's actually a valid jobid
Expand Down
2 changes: 1 addition & 1 deletion Alignment/OfflineValidation/scripts/validateAlignments.py
Expand Up @@ -297,7 +297,7 @@ def createMergeScript( path, validations, options ):
for validation in validations:
for referenceName in validation.filesToCompare:
validationtype = type(validation)
if isinstance(validationtype, PreexistingValidation):
if issubclass(validationtype, PreexistingValidation):
#find the actual validationtype
for parentclass in validationtype.mro():
if not issubclass(parentclass, PreexistingValidation):
Expand Down
3 changes: 1 addition & 2 deletions CalibCalorimetry/HcalAlgos/interface/HcalPulseShape.h
Expand Up @@ -6,17 +6,16 @@
class HcalPulseShape {
public:
HcalPulseShape();
HcalPulseShape(const std::vector<double>&,unsigned);
void setNBin(int n);
void setShapeBin(int i, float f);
float getTpeak() const { return tpeak_; }
float operator()(double time) const;
float at(double time) const;
float integrate(double tmin, double tmax) const;
int nbins() const {return nbin_;}
private:
std::vector<float> shape_;
int nbin_;
float tpeak_;
};

#endif
36 changes: 32 additions & 4 deletions CalibCalorimetry/HcalAlgos/interface/HcalPulseShapes.h
Expand Up @@ -65,19 +65,47 @@ class HcalPulseShapes {
}
return result;
}
static std::vector<double> normalize(std::vector<double> nt, unsigned nbin){
//skip first bin, always 0
double norm = 0.;
for (unsigned int j = 1; j <= nbin; ++j) {
norm += (nt[j]>0) ? nt[j] : 0.;
}

double normInv=1./norm;
for (unsigned int j = 1; j <= nbin; ++j) {
nt[j] *= normInv;
}

return nt;
}
static std::vector<double> normalizeShift(std::vector<double> nt, unsigned nbin, int shift){
//skip first bin, always 0
double norm = 0.;
for (unsigned int j = std::max(1,-1*shift); j<=nbin; j++) {
norm += std::max(0., nt[j-shift]);
}
double normInv=1./norm;
std::vector<double> nt2(nt.size(),0);
for ( int j = 1; j<=(int)nbin; j++) {
if ( j-shift>=0 ) {
nt2[j] = nt[j-shift]*normInv;
}
}
return nt2;
}

private:
void computeHPDShape(float, float, float, float, float ,
float, float, float, Shape&);
void computeHFShape();
void computeSiPMShapeHO();
void computeSiPMShapeHE203();
void computeSiPMShapeHE206();
const HcalPulseShape& computeSiPMShapeHE203();
const HcalPulseShape& computeSiPMShapeHE206();
void computeSiPMShapeData2017();
void computeSiPMShapeData2018();
Shape hpdShape_, hfShape_, siPMShapeHO_;
Shape siPMShapeMC2017_, siPMShapeData2017_;
Shape siPMShapeMC2018_, siPMShapeData2018_;
Shape siPMShapeData2017_, siPMShapeData2018_;
Shape hpdShape_v2, hpdShapeMC_v2;
Shape hpdShape_v3, hpdShapeMC_v3;
Shape hpdBV30Shape_v2, hpdBV30ShapeMC_v2;
Expand Down
8 changes: 7 additions & 1 deletion CalibCalorimetry/HcalAlgos/src/HcalPulseShape.cc
Expand Up @@ -2,9 +2,15 @@

HcalPulseShape::HcalPulseShape() {
nbin_=0;
tpeak_=0;
}

HcalPulseShape::HcalPulseShape(const std::vector<double>& shape, unsigned nbin) :
shape_(shape.begin(),shape.begin()+nbin),
nbin_(nbin)
{
}


void HcalPulseShape::setNBin(int n) {
nbin_=n;
shape_=std::vector<float>(n,0.0f);
Expand Down
51 changes: 9 additions & 42 deletions CalibCalorimetry/HcalAlgos/src/HcalPulseShapes.cc
Expand Up @@ -77,16 +77,14 @@ Reco MC

computeHFShape();
computeSiPMShapeHO();
computeSiPMShapeHE203();
computeSiPMShapeHE206();
computeSiPMShapeData2017();
computeSiPMShapeData2018();

theShapes[201] = &siPMShapeHO_;
theShapes[202] = theShapes[201];
theShapes[203] = &siPMShapeMC2017_;
theShapes[203] = &(computeSiPMShapeHE203());
theShapes[205] = &siPMShapeData2017_;
theShapes[206] = &siPMShapeMC2018_;
theShapes[206] = &(computeSiPMShapeHE206());
theShapes[207] = &siPMShapeData2018_;
theShapes[301] = &hfShape_;
//theShapes[401] = new CaloCachedShapeIntegrator(&theZDCShape);
Expand Down Expand Up @@ -380,50 +378,19 @@ void HcalPulseShapes::computeSiPMShapeHO()
}
}

void HcalPulseShapes::computeSiPMShapeHE203()
const HcalPulseShape& HcalPulseShapes::computeSiPMShapeHE203()
{
//numerical convolution of SiPM pulse + WLS fiber shape
std::vector<double> nt = convolve(nBinsSiPM_,analyticPulseShapeSiPMHE,Y11203);

siPMShapeMC2017_.setNBin(nBinsSiPM_);

//skip first bin, always 0
double norm = 0.;
for (unsigned int j = 1; j <= nBinsSiPM_; ++j) {
norm += (nt[j]>0) ? nt[j] : 0.;
}

for (unsigned int j = 1; j <= nBinsSiPM_; ++j) {
nt[j] /= norm;
siPMShapeMC2017_.setShapeBin(j,nt[j]);
}
static const HcalPulseShape siPMShapeMC2017(normalize(convolve(nBinsSiPM_,analyticPulseShapeSiPMHE,Y11203),nBinsSiPM_),nBinsSiPM_);
return siPMShapeMC2017;
}

void HcalPulseShapes::computeSiPMShapeHE206()
const HcalPulseShape& HcalPulseShapes::computeSiPMShapeHE206()
{
//numerical convolution of SiPM pulse + WLS fiber shape
std::vector<double> nt = convolve(nBinsSiPM_,analyticPulseShapeSiPMHE,Y11206);

siPMShapeMC2018_.setNBin(nBinsSiPM_);

//Aligning 206 phase closer to 205 in order to have good reco agreement
int shift = -2;

//skip first bin, always 0
double norm = 0.;
for (unsigned int j = std::max(1,-1*shift); j<=nBinsSiPM_; j++) {
norm += std::max(0., nt[j-shift]);
}
double normInv=1./norm;
for ( int j = 1; j<=nBinsSiPM_; j++) {
if ( j-shift>=0 ) {
nt[j-shift]*=normInv;
siPMShapeMC2018_.setShapeBin(j,nt[j-shift]);
}
else{
siPMShapeMC2018_.setShapeBin(j,0);
}
}
//shift: aligning 206 phase closer to 205 in order to have good reco agreement
static const HcalPulseShape siPMShapeMC2018(normalizeShift(convolve(nBinsSiPM_,analyticPulseShapeSiPMHE,Y11206),nBinsSiPM_,-2),nBinsSiPM_);
return siPMShapeMC2018;
}

const HcalPulseShapes::Shape &
Expand Down
8 changes: 3 additions & 5 deletions CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h
Expand Up @@ -64,9 +64,7 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {

static const int QIE8_LUT_BITMASK = 0x3FF;
static const int QIE10_LUT_BITMASK = 0x7FF;
static const int QIE11_LUT_BITMASK = 0x7FF;
// only the lowest 10 bits were used in 2017
static const int QIE11_LUT_BITMASK_2017 = 0x3FF;
static const int QIE11_LUT_BITMASK = 0x3FF;

private:
// typedef
Expand All @@ -79,8 +77,8 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {
static const int nFi_ = 72;

static const int QIE8_LUT_MSB = 0x400;
static const int QIE11_LUT_MSB0 = 0x800;
static const int QIE11_LUT_MSB1 = 0x1000;
static const int QIE11_LUT_MSB0 = 0x400;
static const int QIE11_LUT_MSB1 = 0x800;
static const int QIE10_LUT_MSB = 0x1000;

// member variables
Expand Down
4 changes: 1 addition & 3 deletions CalibCalorimetry/HcalTPGAlgos/src/HcaluLUTTPGCoder.cc
Expand Up @@ -35,7 +35,6 @@ const float HcaluLUTTPGCoder::lsb_=1./16;
const int HcaluLUTTPGCoder::QIE8_LUT_BITMASK;
const int HcaluLUTTPGCoder::QIE10_LUT_BITMASK;
const int HcaluLUTTPGCoder::QIE11_LUT_BITMASK;
const int HcaluLUTTPGCoder::QIE11_LUT_BITMASK_2017;

constexpr double MaximumFractionalError = 0.002; // 0.2% error allowed from this source

Expand Down Expand Up @@ -348,8 +347,7 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {

const size_t SIZE = qieType==QIE8 ? INPUT_LUT_SIZE : UPGRADE_LUT_SIZE;
const int MASK = qieType==QIE8 ? QIE8_LUT_BITMASK :
qieType==QIE10 ? QIE10_LUT_BITMASK :
is2018OrLater ? QIE11_LUT_BITMASK : QIE11_LUT_BITMASK_2017;
qieType==QIE10 ? QIE10_LUT_BITMASK : QIE11_LUT_BITMASK;
double linearLSB = linearLSB_QIE8_;
if (qieType == QIE11 and cell.ietaAbs() == topo_->lastHBRing())
linearLSB = linearLSB_QIE11Overlap_;
Expand Down
@@ -0,0 +1,33 @@
#ifndef CalibTracker_SiPixelESProducers_SiPixel2DTemplateDBObjectESProducer_h
#define CalibTracker_SiPixelESProducers_SiPixel2DTemplateDBObjectESProducer_h
// -*- C++ -*-
//
// Package: SiPixel2DTemplateDBObjectESProducer
// Class: SiPixel2DTemplateDBObjectESProducer
//
/**\class SiPixel2DTemplateDBObjectESProducer SiPixel2DTemplateDBObjectESProducer.cc CalibTracker/SiPixelESProducers/plugin/SiPixel2DTemplateDBObjectESProducer.cc
Description: ESProducer for magnetic-field-dependent local reco templates
Implementation: Used inside the RecoLocalTracker/Records/TkPixelRecord to select the correct db for given magnetic field
*/
//
// Original Author: D.Fehling
// Created: Tue Sep 29 14:49:31 CET 2009
//
//

#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "CondFormats/SiPixelObjects/interface/SiPixel2DTemplateDBObject.h"
#include "CalibTracker/Records/interface/SiPixel2DTemplateDBObjectESProducerRcd.h"

class SiPixel2DTemplateDBObjectESProducer : public edm::ESProducer {

public:

SiPixel2DTemplateDBObjectESProducer(const edm::ParameterSet& iConfig);
~SiPixel2DTemplateDBObjectESProducer() override;
std::shared_ptr<SiPixel2DTemplateDBObject> produce(const SiPixel2DTemplateDBObjectESProducerRcd &);
};
#endif
Expand Up @@ -73,6 +73,8 @@ class SiPixelGainCalibrationServicePayloadGetter : public SiPixelGainCalibration

void setESObjects(const edm::EventSetup& es ) override;

thePayloadObject const & payload() const { return *ped; }

std::vector<uint32_t> getDetIds() override;
double getGainLow() override;
double getGainHigh() override;
Expand Down
@@ -0,0 +1,64 @@
// -*- C++ -*-
// Package: SiPixelESProducers
// Class: SiPixel2DTemplateDBObjectESProducer
// Original Author: D.Fehling
// Created: Tue Sep 29 14:49:31 CET 2009
//

#include "CalibTracker/SiPixelESProducers/interface/SiPixel2DTemplateDBObjectESProducer.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/do_nothing_deleter.h"

#include <memory>
#include "boost/mpl/vector.hpp"

#include "FWCore/Framework/interface/ModuleFactory.h"
#include "MagneticField/Engine/interface/MagneticField.h"

using namespace edm;

SiPixel2DTemplateDBObjectESProducer::SiPixel2DTemplateDBObjectESProducer(const edm::ParameterSet& iConfig) {
setWhatProduced(this);
}


SiPixel2DTemplateDBObjectESProducer::~SiPixel2DTemplateDBObjectESProducer(){
}




std::shared_ptr<SiPixel2DTemplateDBObject> SiPixel2DTemplateDBObjectESProducer::produce(const SiPixel2DTemplateDBObjectESProducerRcd & iRecord) {

ESHandle<MagneticField> magfield;
iRecord.getRecord<IdealMagneticFieldRecord>().get(magfield);

GlobalPoint center(0.0, 0.0, 0.0);
float theMagField = magfield.product()->inTesla(center).mag();

// std::string label = "numerator"; // &&& Temporary: matches Barrel Layer1 for 2017 data
// std::string label = "denominator"; // &&& Temporary: matches Barrel Layer1 fullsim MC
std::string label = ""; // the correct default

if( theMagField>=-0.1 && theMagField<1.0 ) label = "0T";
else if(theMagField>=1.0 && theMagField<2.5 ) label = "2T";
else if(theMagField>=2.5 && theMagField<3.25) label = "3T";
else if(theMagField>=3.25 && theMagField<3.65) label = "35T";
else if(theMagField>=3.9 && theMagField<4.1 ) label = "4T";
else {
//label = "3.8T";
if(theMagField>=4.1 || theMagField<-0.1) edm::LogWarning("UnexpectedMagneticFieldUsingDefaultPixel2DTemplate") << "Magnetic field is " << theMagField;
}
ESHandle<SiPixel2DTemplateDBObject> dbobject;
iRecord.getRecord<SiPixel2DTemplateDBObjectRcd>().get(label,dbobject);

if(std::fabs(theMagField-dbobject->sVector()[22])>0.1)
edm::LogWarning("UnexpectedMagneticFieldUsingNonIdealPixel2DTemplate") << "Magnetic field is " << theMagField << " Template Magnetic field is " << dbobject->sVector()[22];

return std::shared_ptr<SiPixel2DTemplateDBObject>(const_cast<SiPixel2DTemplateDBObject*>(&(*dbobject)), edm::do_nothing_deleter());
}

DEFINE_FWK_EVENTSETUP_MODULE(SiPixel2DTemplateDBObjectESProducer);
@@ -0,0 +1,4 @@
import FWCore.ParameterSet.Config as cms

siPixel2DTemplateDBObjectESProducer = cms.ESProducer("SiPixel2DTemplateDBObjectESProducer")

0 comments on commit 18be756

Please sign in to comment.