Skip to content

Commit

Permalink
make mcShape and recoShape configurable parameters for HcalHardcodeCa…
Browse files Browse the repository at this point in the history
…librations
  • Loading branch information
kpedro88 committed Jul 27, 2016
1 parent 1cd50e3 commit 2f91842
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 85 deletions.
Expand Up @@ -11,7 +11,7 @@ class HcalHardcodeParameters {
HcalHardcodeParameters() {}
//construct from values
HcalHardcodeParameters(double pedestal, double pedestalWidth, std::vector<double> gain, std::vector<double> gainWidth,
int qieType, std::vector<double> qieOffset, std::vector<double> qieSlope);
int qieType, std::vector<double> qieOffset, std::vector<double> qieSlope, int mcShape, int recoShape);
//construct from pset
HcalHardcodeParameters(const edm::ParameterSet & p);

Expand All @@ -27,13 +27,16 @@ class HcalHardcodeParameters {
const int qieType() const { return qieType_; }
const double qieOffset(unsigned range) const { return qieOffset_.at(range); }
const double qieSlope(unsigned range) const { return qieSlope_.at(range); }
const int mcShape() const { return mcShape_; }
const int recoShape() const { return recoShape_; }

private:
//member variables
double pedestal_, pedestalWidth_;
std::vector<double> gain_, gainWidth_;
int qieType_;
std::vector<double> qieOffset_, qieSlope_;
int mcShape_, recoShape_;
};

#endif
100 changes: 32 additions & 68 deletions CalibCalorimetry/HcalAlgos/src/HcalDbHardcode.cc
Expand Up @@ -10,7 +10,7 @@
#include "DataFormats/HcalDigi/interface/HcalQIENum.h"

HcalDbHardcode::HcalDbHardcode()
: theDefaultParameters_(3.0,0.5,{0.2,0.2},{0.0,0.0},0,{0.0,0.0,0.0,0.0},{0.9,0.9,0.9,0.9}), //"generic" set of conditions
: theDefaultParameters_(3.0,0.5,{0.2,0.2},{0.0,0.0},0,{0.0,0.0,0.0,0.0},{0.9,0.9,0.9,0.9},125,105), //"generic" set of conditions
setHB_(false), setHE_(false), setHF_(false), setHO_(false),
setHBUpgrade_(false), setHEUpgrade_(false), setHFUpgrade_(false),
useHBUpgrade_(false), useHEUpgrade_(false), useHFUpgrade_(false), testHFQIE10_(false)
Expand Down Expand Up @@ -153,53 +153,51 @@ HcalQIEShape HcalDbHardcode::makeQIEShape () {
HcalMCParam HcalDbHardcode::makeMCParam (HcalGenericDetId fId) {

int r1bit[5];
int pulseShapeID = 125; r1bit[0] = 9; // [0,9]
r1bit[0] = 9; // [0,9]
int syncPhase = 0; r1bit[1] = 1;
int binOfMaximum = 0; r1bit[2] = 4;
float phase = -25.0f; // [-25.0,25.0]
float Xphase = (phase + 32.0f) * 4.0f; // never change this line
// (offset 50nsec, 0.25ns step)
int Iphase = Xphase; r1bit[3] = 8; // [0,256] offset 50ns, .25ns step
int timeSmearing = 0; r1bit[4] = 1; // bool


const HcalHardcodeParameters& hparam(getParameters(fId));
int pulseShapeID = hparam.mcShape(); // a0

if (fId.genericSubdet() == HcalGenericDetId::HcalGenBarrel) {

syncPhase = 1; // a0 bool
binOfMaximum = 5; // a1
phase = 5.0f; // a2 [-25.0,25.0]
syncPhase = 1; // a1 bool
binOfMaximum = 5; // a2
phase = 5.0f; // a3 [-25.0,25.0]
Xphase = (phase + 32.0f) * 4.0f; // never change this line
// (offset 50nsec, 0.25ns step)
Iphase = Xphase;
timeSmearing = 1; // a3
pulseShapeID = 201; // a4 201 - Zecotec shape
// 202 - Hamamatsu
timeSmearing = 1; // a4

}

else if (fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap) {

syncPhase = 1; // a0 bool
binOfMaximum = 5; // a1
phase = 5.0f; // a2 [-25.0,25.0]
syncPhase = 1; // a1 bool
binOfMaximum = 5; // a2
phase = 5.0f; // a3 [-25.0,25.0]
Xphase = (phase + 32.0f) * 4.0f; // never change this line
// (offset 50nsec, 0.25ns step)
Iphase = Xphase;
timeSmearing = 1; // a3
pulseShapeID = 201; // a4
timeSmearing = 1; // a4

}

else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) {

syncPhase = 1; // a0 bool
binOfMaximum = 5; // a1
phase = 5.0f; // a2 [-25.0,25.0]
syncPhase = 1; // a1 bool
binOfMaximum = 5; // a2
phase = 5.0f; // a3 [-25.0,25.0]
Xphase = (phase + 32.0f) * 4.0f; // never change this line
// (offset 50nsec, 0.25ns step)
Iphase = Xphase;
timeSmearing = 0; // a3
pulseShapeID = 201; // a4
timeSmearing = 0; // a4

HcalDetId cell = HcalDetId(fId);
if (cell.ieta() == 1 && cell.iphi() == 1) pulseShapeID = 125;
Expand All @@ -208,29 +206,26 @@ HcalMCParam HcalDbHardcode::makeMCParam (HcalGenericDetId fId) {

else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) {

syncPhase = 1; // a0 bool
binOfMaximum = 3; // a1
phase = 14.0f; // a2 [-25.0,25.0]
syncPhase = 1; // a1 bool
binOfMaximum = 3; // a2
phase = 14.0f; // a3 [-25.0,25.0]
Xphase = (phase + 32.0f) * 4.0f; // never change this line
// (offset 50nsec, 0.25ns step)
Iphase = Xphase;
timeSmearing = 0; // a3
pulseShapeID = 301; // a4
timeSmearing = 0; // a4

}

else if (fId.genericSubdet() == HcalGenericDetId::HcalGenZDC) {

// std::cout << " >>> ZDC " << std::endl;

syncPhase = 1; // a0 bool
binOfMaximum = 5; // a1
phase = -4.0f; // a2 [-25.0,25.0]
pulseShapeID = 401; // a0
syncPhase = 1; // a1 bool
binOfMaximum = 5; // a2
phase = -4.0f; // a3 [-25.0,25.0]
Xphase = (phase + 32.0f) * 4.0f; // never change this line
// (offset 50nsec, 0.25ns step)
Iphase = Xphase;
timeSmearing = 0; // a3
pulseShapeID = 401; // a4
timeSmearing = 0; // a4

}

Expand All @@ -241,7 +236,7 @@ HcalMCParam HcalDbHardcode::makeMCParam (HcalGenericDetId fId) {
rshift[k+1]=rshift[k]+r1bit[k];
}

int packingScheme = 1;
int packingScheme = 1; // a5
unsigned int param = pulseShapeID |
syncPhase<<rshift[1] |
(binOfMaximum << rshift[2]) |
Expand All @@ -268,7 +263,10 @@ HcalRecoParam HcalDbHardcode::makeRecoParam (HcalGenericDetId fId) {
// (offset 50ns, 0.25ns step
int firstSample = 4; p1bit[3]=4; // [0,9]
int samplesToAdd = 2; p1bit[4]=4; // [0,9]
int pulseShapeID = 105; p1bit[5]=9; // [0,9]
p1bit[5]=9; // [0,9]

const HcalHardcodeParameters& hparam(getParameters(fId));
int pulseShapeID = hparam.recoShape(); // a5

int q2bit[10];
// param2.
Expand All @@ -295,7 +293,6 @@ HcalRecoParam HcalDbHardcode::makeRecoParam (HcalGenericDetId fId) {
Iphase = Xphase; // p2
firstSample = 4; // p3
samplesToAdd = 2; // p4
pulseShapeID = 201; // p5

// param2.
useLeakCorrection = 0; // q0
Expand All @@ -320,7 +317,7 @@ HcalRecoParam HcalDbHardcode::makeRecoParam (HcalGenericDetId fId) {
Iphase = Xphase; // p2
firstSample = 4; // p3
samplesToAdd = 4; // p4
pulseShapeID = 201; // p5

// param2.
useLeakCorrection = 0; // q0
LeakCorrectionID = 0; // q1
Expand All @@ -341,11 +338,8 @@ HcalRecoParam HcalDbHardcode::makeRecoParam (HcalGenericDetId fId) {
float Xphase = (phase + 32.0) * 4.0; // never change this line
// (offset 50nsec, 0.25ns step)
Iphase = Xphase; // p2
pulseShapeID = 301; // p5

firstSample = 2; // p3
samplesToAdd = 1; // p4
pulseShapeID = 301; // p5

// param2.
useLeakCorrection = 0; // q0
Expand Down Expand Up @@ -394,36 +388,6 @@ HcalRecoParam HcalDbHardcode::makeRecoParam (HcalGenericDetId fId) {
(pileupCleaningID << q2shift[8]) |
(packingScheme << q2shift[9]) ;

// Test printout
/*
int a0=param1%2;
int a1=(param1/2)%2;
int a2=(param1/(2*2))%256;
int a3=(param1/(2*2*256))%16;
int a4=(param1/(2*2*256*16))%16;
int a5=(param1/(2*2*256*16*16))%512;
a2=(a2/4)-32;
int b0=param2%2;
int b1=(param2/2)%16;
int b2=(param2/(2*16))%2;
int b3=(param2/(2*16*2))%16;
int b4=(param2/(2*16*2*16))%2;
int b5=(param2/(2*16*2*16*2))%16;
int b6=(param2/(2*16*2*16*2*16))%16;
int b7=(param2/(2*16*2*16*2*16*16))%16;
int b8=(param2/(2*16*2*16*2*16*16*16))%16;
int b9=(param2/(2*16*2*16*2*16*16*16*16))%16;
std::cout << " param1 (a012) " << a0 << " " <<a1 << " " << a2
<< " (a345) " << a3 << " " << a4 << " "<< a5
<< " param2 (b012) " << b0 << " " << b1 << " " <<b2
<< " (b345) " << b3 << " " << b4 << " " << b5
<< " (b678) " << b6 << " " << b7 << " " << b8 << " b9 " << b9
<< std::endl;
*/


HcalRecoParam result(fId.rawId(), param1, param2);

return result;
Expand Down
10 changes: 7 additions & 3 deletions CalibCalorimetry/HcalAlgos/src/HcalHardcodeParameters.cc
@@ -1,14 +1,16 @@
#include "CalibCalorimetry/HcalAlgos/interface/HcalHardcodeParameters.h"

HcalHardcodeParameters::HcalHardcodeParameters(double pedestal, double pedestalWidth, std::vector<double> gain, std::vector<double> gainWidth,
int qieType, std::vector<double> qieOffset, std::vector<double> qieSlope)
int qieType, std::vector<double> qieOffset, std::vector<double> qieSlope, int mcShape, int recoShape)
: pedestal_(pedestal),
pedestalWidth_(pedestalWidth),
gain_(gain),
gainWidth_(gainWidth),
qieType_(qieType),
qieOffset_(qieOffset),
qieSlope_(qieSlope)
qieSlope_(qieSlope),
mcShape_(mcShape),
recoShape_(recoShape)
{
}

Expand All @@ -19,6 +21,8 @@ HcalHardcodeParameters::HcalHardcodeParameters(const edm::ParameterSet & p)
gainWidth_(p.getParameter<std::vector<double>>("gainWidth")),
qieType_(p.getParameter<int>("qieType")),
qieOffset_(p.getParameter<std::vector<double>>("qieOffset")),
qieSlope_(p.getParameter<std::vector<double>>("qieSlope"))
qieSlope_(p.getParameter<std::vector<double>>("qieSlope")),
mcShape_(p.getParameter<int>("mcShape")),
recoShape_(p.getParameter<int>("recoShape"))
{
}
Expand Up @@ -29,7 +29,9 @@
gainWidth = cms.vdouble(0.0),
qieType = cms.int32(0),
qieOffset = cms.vdouble(-0.49,1.8,7.2,37.9),
qieSlope = cms.vdouble(0.912,0.917,0.922,0.923)
qieSlope = cms.vdouble(0.912,0.917,0.922,0.923),
mcShape = cms.int32(125),
recoShape = cms.int32(105),
),
he = cms.PSet(
pedestal = cms.double(3.0),
Expand All @@ -38,7 +40,9 @@
gainWidth = cms.vdouble(0),
qieType = cms.int32(0),
qieOffset = cms.vdouble(-0.38,2.0,7.6,39.6),
qieSlope = cms.vdouble(0.912,0.916,0.920,0.922)
qieSlope = cms.vdouble(0.912,0.916,0.920,0.922),
mcShape = cms.int32(125),
recoShape = cms.int32(105),
),
hf = cms.PSet(
pedestal = cms.double(3.0),
Expand All @@ -47,7 +51,9 @@
gainWidth = cms.vdouble(0.0,0.0),
qieType = cms.int32(0),
qieOffset = cms.vdouble(-0.87,1.4,7.8,-29.6),
qieSlope = cms.vdouble(0.359,0.358,0.360,0.367)
qieSlope = cms.vdouble(0.359,0.358,0.360,0.367),
mcShape = cms.int32(301),
recoShape = cms.int32(301),
),
ho = cms.PSet(
pedestal = cms.double(11.0),
Expand All @@ -56,7 +62,9 @@
gainWidth = cms.vdouble(0.0,0.0),
qieType = cms.int32(0),
qieOffset = cms.vdouble(-0.44,1.4,7.1,38.5),
qieSlope = cms.vdouble(0.907,0.915,0.920,0.921)
qieSlope = cms.vdouble(0.907,0.915,0.920,0.921),
mcShape = cms.int32(201),
recoShape = cms.int32(201),
),
hbUpgrade = cms.PSet(
pedestal = cms.double(17.3),
Expand All @@ -65,7 +73,9 @@
gainWidth = cms.vdouble(0),
qieType = cms.int32(2),
qieOffset = cms.vdouble(0.,0.,0.,0.),
qieSlope = cms.vdouble(0.333,0.333,0.333,0.333)
qieSlope = cms.vdouble(0.333,0.333,0.333,0.333),
mcShape = cms.int32(203),
recoShape = cms.int32(203),
),
heUpgrade = cms.PSet(
pedestal = cms.double(17.3),
Expand All @@ -74,7 +84,9 @@
gainWidth = cms.vdouble(0),
qieType = cms.int32(2),
qieOffset = cms.vdouble(0.,0.,0.,0.),
qieSlope = cms.vdouble(0.333,0.333,0.333,0.333)
qieSlope = cms.vdouble(0.333,0.333,0.333,0.333),
mcShape = cms.int32(203),
recoShape = cms.int32(203),
),
hfUpgrade = cms.PSet(
pedestal = cms.double(13.33),
Expand All @@ -83,7 +95,9 @@
gainWidth = cms.vdouble(0.0,0.0),
qieType = cms.int32(1),
qieOffset = cms.vdouble(0.0697,-0.7405,12.38,-671.9),
qieSlope = cms.vdouble(0.297,0.298,0.298,0.313)
qieSlope = cms.vdouble(0.297,0.298,0.298,0.313),
mcShape = cms.int32(301),
recoShape = cms.int32(301),
),
)

Expand Down

0 comments on commit 2f91842

Please sign in to comment.