31 typedef std::pair<uint32_t, unsigned char>
ChipId;
48 double getChi2(
const std::vector<double>&,
const std::vector<std::pair<double, int> >&,
const double&,
const double&);
53 const std::vector<bool>&,
75 : applyGain_(iConfig.getParameter<
bool>(
"applyGain")),
76 MeVPerElectron_(iConfig.getParameter<double>(
"MeVPerElectron")),
77 VCaltoElectronGain_(iConfig.getParameter<
int>(
"VCaltoElectronGain")),
78 VCaltoElectronGain_L1_(iConfig.getParameter<
int>(
"VCaltoElectronGain_L1")),
79 VCaltoElectronOffset_(iConfig.getParameter<
int>(
"VCaltoElectronOffset")),
80 VCaltoElectronOffset_L1_(iConfig.getParameter<
int>(
"VCaltoElectronOffset_L1")),
81 pixelSaturationThr_(iConfig.getParameter<
int>(
"pixelSaturationThr")),
87 pixelCalib_(iConfig, consumesCollector()) {
88 produces<reco::TrackDeDxHitsCollection>(
"PixelHits");
89 produces<reco::TrackDeDxHitsCollection>(
"StripHits");
94 desc.add<
bool>(
"applyGain",
true);
95 desc.add<
double>(
"MeVPerElectron", 3.61e-06);
96 desc.add<
int>(
"VCaltoElectronGain", 65);
97 desc.add<
int>(
"VCaltoElectronGain_L1", 65);
98 desc.add<
int>(
"VCaltoElectronOffset", -414);
99 desc.add<
int>(
"VCaltoElectronOffset_L1", -414);
100 desc.add<
int>(
"pixelSaturationThr", 254);
103 descriptions.
add(
"dedxHitCalibrator",
desc);
121 for (
size_t i = 0;
i <
tracks->size();
i++) {
124 if (dedxHits.isNull())
145 for (
size_t i = 0;
i <
info.size();
i++) {
152 const auto& pl =
info.pathlength(
i);
153 const auto pathLength = pl * (1. +
a *
std::log(pl / l0));
164 std::vector<std::pair<double, int> >
b;
180 const auto&
charge = pathLength != 0. ?
energy / pathLength : 0.;
207 else if (DBgain > 0.) {
214 const auto adc = std::round(DBpedestal + vcal / DBgain);
227 const auto&
charge = pathLength != 0. ?
energy / pathLength : 0.;
235 const auto& subdet =
id.subdetId() - 1;
252 const double& coupling,
253 const double& iSigma) {
254 const auto& npar =
b.size();
255 std::vector<double>
y(npar, 0.);
256 for (
size_t i = 0;
i < npar;
i++) {
257 const auto dx = coupling *
x[
i];
265 for (
size_t i = 0;
i < npar;
i++) {
266 auto q = (
b[
i].first -
y[
i]) * iSigma;
290 CLHEP::HepMatrix&
alpha,
291 CLHEP::HepVector&
beta,
292 const std::vector<bool>& isFix,
293 const double& coupling,
294 const double& iSigma) {
295 const auto& npar =
b.size();
296 const auto a0 = coupling * iSigma;
297 const auto a1 = (1 - 2 * coupling) * iSigma;
298 const auto a00 =
a0 *
a0;
299 const auto a11 =
a1 *
a1;
300 const auto a01 =
a0 *
a1;
301 std::vector<double>
y(npar, 0.);
302 for (
size_t i = 0;
i < npar;
i++)
304 const auto dx = coupling *
x[
i];
311 for (
size_t i = 0;
i < npar;
i++) {
312 auto q = (
y[
i] -
b[
i].first) * iSigma;
352 alpha[
i][
i] += 2 * iSigma * iSigma;
354 beta[
i] += 2 *
q * iSigma;
357 for (
size_t i = 0;
i < npar;
i++)
366 const double& coupling,
367 const double& iSigma) {
368 const auto& npar =
b.size();
369 std::vector<bool> isFix(npar,
false);
370 std::vector<double>
x;
372 for (
const auto&
ib :
b)
373 x.emplace_back(
ib.first);
376 CLHEP::HepMatrix hessian(npar, npar);
380 auto old =
getChi2(
x,
b, coupling, iSigma);
382 CLHEP::HepMatrix
alpha(npar, npar, 0.);
383 CLHEP::HepVector
beta(npar, 0.);
387 std::vector<double> xn(npar);
388 for (
size_t i = 0;
i < npar;
i++)
397 }
while (
diff > 1
e-6 && iter < 100);
399 const auto& mi = std::min_element(
x.begin(),
x.end()) -
x.begin();
405 }
while (!
ok && iter < 100);
408 hessian.invert(
flag);
411 for (
size_t i = 0;
i < npar;
i++)
412 for (
size_t j = 0;
j < npar;
j++)
413 if (!isFix[
i] && !isFix[
j])
414 var2 += hessian[
i][
j];
418 for (
size_t i = 0;
i < npar;
i++)
void processHitInfo(const reco::DeDxHitInfo &, const float &trackMomentum, reco::DeDxHitCollection &, reco::DeDxHitCollection &)
std::pair< uint32_t, unsigned char > ChipId
unsigned int pxbLayer(const DetId &id) const
std::pair< double, double > fitStripCluster(const std::vector< std::pair< double, int > > &, const double &, const double &)
static constexpr int TECThick
std::vector< Track > TrackCollection
collection of Tracks
edm::ESHandle< TrackerGeometry > tkGeom_
std::vector< DeDxHit > DeDxHitCollection
static constexpr int Compatible
const std::vector< double > & thr() const
void beginRun(edm::Run const &, const edm::EventSetup &) override
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
const std::vector< double > & alpha() const
const std::map< ChipId, float > & gain() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
U second(std::pair< T, U > const &p)
static constexpr int nChannels
edm::ESHandle< TrackerTopology > tkTopo_
edm::Association< DeDxHitInfoCollection > DeDxHitInfoAss
const edm::EDGetTokenT< reco::DeDxHitInfoAss > dedxHitInfoToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tkTopoToken_
edm::ESHandle< DeDxCalibration > dedxCalib_
void setESObjects(const edm::EventSetup &es) override
const edm::ESGetToken< DeDxCalibration, DeDxCalibrationRcd > dedxCalibToken_
double getChi2(const std::vector< double > &, const std::vector< std::pair< double, int > > &, const double &, const double &)
Abs< T >::type abs(const T &t)
int getDetId(const DetId &, const float &)
static void fillDescriptions(edm::ConfigurationDescriptions &)
#define DEFINE_FWK_MODULE(type)
const int VCaltoElectronGain_
edm::RefProd< TrackCollection > TrackRefProd
persistent reference to a Track collection
const int VCaltoElectronOffset_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
const TrackerGeomDet * idToDet(DetId) const override
~DeDxHitCalibrator() override=default
static constexpr int TECThin
const int VCaltoElectronOffset_L1_
void getAlphaBeta(const std::vector< double > &, const std::vector< std::pair< double, int > > &, CLHEP::HepMatrix &, CLHEP::HepVector &, const std::vector< bool > &, const double &, const double &)
static constexpr float a0
const edm::EDGetTokenT< reco::TrackCollection > tracksToken_
Constants and enumerated types for FED/FEC systems.
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
void add(std::string const &label, ParameterSetDescription const &psetDescription)
DeDxHitCalibrator(const edm::ParameterSet &)
static constexpr int Complete
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)
static constexpr int kIsOver
void produce(edm::Event &, const edm::EventSetup &) override
SiPixelGainCalibrationOfflineService pixelCalib_
const int VCaltoElectronGain_L1_
static const uint16_t STRIPS_PER_APV
static constexpr float MeVperADCStrip
float correctEnergy(const float &, const ChipId &)
const std::vector< double > & sigma() const
float getPedestal(const uint32_t &detID, const int &col, const int &row) override
const double MeVPerElectron_
static constexpr int kIsNormal
uint16_t *__restrict__ uint16_t const *__restrict__ adc
float getGain(const uint32_t &detID, const int &col, const int &row) override
static constexpr int kIsBelow
const int pixelSaturationThr_