1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// -*- C++ -*-
//
// Package: SiPixelGenErrorDBObjectESProducer
// Class: SiPixelGenErrorDBObjectESProducer
//
/**\class SiPixelGenErrorDBObjectESProducer SiPixelGenErrorDBObjectESProducer.cc CalibTracker/SiPixelESProducers/plugin/SiPixelGenErrorDBObjectESProducer.cc
Description: ESProducer for magnetic-field-dependent local reco GenErrors
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 "FWCore/Utilities/interface/ESProductTag.h"
#include "FWCore/Utilities/interface/do_nothing_deleter.h"
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelGenErrorDBObject.h"
#include "CalibTracker/Records/interface/SiPixelGenErrorDBObjectESProducerRcd.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include <memory>
using namespace edm;
class SiPixelGenErrorDBObjectESProducer : public edm::ESProducer {
public:
SiPixelGenErrorDBObjectESProducer(const edm::ParameterSet& iConfig);
std::shared_ptr<const SiPixelGenErrorDBObject> produce(const SiPixelGenErrorDBObjectESProducerRcd&);
private:
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magfieldToken_;
edm::ESGetToken<SiPixelGenErrorDBObject, SiPixelGenErrorDBObjectRcd> genErrorToken_;
};
SiPixelGenErrorDBObjectESProducer::SiPixelGenErrorDBObjectESProducer(const edm::ParameterSet& iConfig) {
auto cc = setWhatProduced(this);
cc.setMayConsume(
genErrorToken_,
[](const auto& get, edm::ESTransientHandle<MagneticField> iMagfield) {
const GlobalPoint center(0.0, 0.0, 0.0);
const float theMagField = iMagfield->inTesla(center).mag();
if (theMagField >= -0.1 && theMagField < 1.0)
return get("", "0T");
else {
if (theMagField >= 3.9 || theMagField < 3.65)
edm::LogWarning("UnexpectedMagneticFieldUsingDefaultPixelGenError") << "Magnetic field is " << theMagField;
return get("", "");
}
},
edm::ESProductTag<MagneticField, IdealMagneticFieldRecord>("", ""));
magfieldToken_ = cc.consumes();
}
std::shared_ptr<const SiPixelGenErrorDBObject> SiPixelGenErrorDBObjectESProducer::produce(
const SiPixelGenErrorDBObjectESProducerRcd& iRecord) {
const GlobalPoint center(0.0, 0.0, 0.0);
const float theMagField = iRecord.get(magfieldToken_).inTesla(center).mag();
const auto& dbobject = iRecord.get(genErrorToken_);
if (std::fabs(theMagField - dbobject.sVector()[22]) > 0.1)
edm::LogWarning("UnexpectedMagneticFieldUsingNonIdealPixelGenError")
<< "Magnetic field is " << theMagField << " GenError Magnetic field is " << dbobject.sVector()[22];
return std::shared_ptr<const SiPixelGenErrorDBObject>(&dbobject, edm::do_nothing_deleter());
}
DEFINE_FWK_EVENTSETUP_MODULE(SiPixelGenErrorDBObjectESProducer);
|