/
PixelCPEGenericESProducer.cc
111 lines (93 loc) · 4.63 KB
/
PixelCPEGenericESProducer.cc
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "RecoLocalTracker/SiPixelRecHits/interface/PixelCPEGeneric.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "RecoLocalTracker/Records/interface/TkPixelCPERecord.h"
#include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESProducer.h"
// new record
#include "CondFormats/DataRecord/interface/SiPixelGenErrorDBObjectRcd.h"
#include <string>
#include <memory>
class PixelCPEGenericESProducer : public edm::ESProducer {
public:
PixelCPEGenericESProducer(const edm::ParameterSet& p);
std::unique_ptr<PixelClusterParameterEstimator> produce(const TkPixelCPERecord&);
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
private:
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magfieldToken_;
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> pDDToken_;
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> hTTToken_;
edm::ESGetToken<SiPixelLorentzAngle, SiPixelLorentzAngleRcd> lorentzAngleToken_;
edm::ESGetToken<SiPixelLorentzAngle, SiPixelLorentzAngleRcd> lorentzAngleWidthToken_;
edm::ESGetToken<SiPixelGenErrorDBObject, SiPixelGenErrorDBObjectRcd> genErrorDBObjectToken_;
edm::ParameterSet pset_;
bool useLAWidthFromDB_;
bool UseErrorsFromTemplates_;
};
using namespace edm;
PixelCPEGenericESProducer::PixelCPEGenericESProducer(const edm::ParameterSet& p) {
std::string myname = p.getParameter<std::string>("ComponentName");
// Use LA-width from DB. If both (upper and this) are false LA-width is calcuated from LA-offset
useLAWidthFromDB_ = p.getParameter<bool>("useLAWidthFromDB");
// Use Alignment LA-offset
const bool doLorentzFromAlignment = p.getParameter<bool>("doLorentzFromAlignment");
char const* laLabel = ""; // standard LA, from calibration, label=""
if (doLorentzFromAlignment) {
laLabel = "fromAlignment";
}
auto magname = p.getParameter<edm::ESInputTag>("MagneticFieldRecord");
UseErrorsFromTemplates_ = p.getParameter<bool>("UseErrorsFromTemplates");
pset_ = p;
auto c = setWhatProduced(this, myname);
magfieldToken_ = c.consumes(magname);
pDDToken_ = c.consumes();
hTTToken_ = c.consumes();
lorentzAngleToken_ = c.consumes(edm::ESInputTag("", laLabel));
if (useLAWidthFromDB_) {
lorentzAngleWidthToken_ = c.consumes(edm::ESInputTag("", "forWidth"));
}
if (UseErrorsFromTemplates_) {
genErrorDBObjectToken_ = c.consumes();
}
}
std::unique_ptr<PixelClusterParameterEstimator> PixelCPEGenericESProducer::produce(const TkPixelCPERecord& iRecord) {
// add the new la width object
const SiPixelLorentzAngle* lorentzAngleWidthProduct = nullptr;
if (useLAWidthFromDB_) { // use the width LA
lorentzAngleWidthProduct = &iRecord.get(lorentzAngleWidthToken_);
}
//std::cout<<" la width "<<lorentzAngleWidthProduct<<std::endl; //dk
const SiPixelGenErrorDBObject* genErrorDBObjectProduct = nullptr;
// Errors take only from new GenError
if (UseErrorsFromTemplates_) { // do only when generrors are needed
genErrorDBObjectProduct = &iRecord.get(genErrorDBObjectToken_);
//} else {
//std::cout<<" pass an empty GenError pointer"<<std::endl;
}
return std::make_unique<PixelCPEGeneric>(pset_,
&iRecord.get(magfieldToken_),
iRecord.get(pDDToken_),
iRecord.get(hTTToken_),
&iRecord.get(lorentzAngleToken_),
genErrorDBObjectProduct,
lorentzAngleWidthProduct);
}
void PixelCPEGenericESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
// from PixelCPEBase
PixelCPEBase::fillPSetDescription(desc);
// from PixelCPEGeneric
PixelCPEGeneric::fillPSetDescription(desc);
// specific to PixelCPEGenericESProducer
desc.add<std::string>("ComponentName", "PixelCPEGeneric");
desc.add<edm::ESInputTag>("MagneticFieldRecord", edm::ESInputTag(""));
descriptions.add("_generic_default", desc);
}
DEFINE_FWK_EVENTSETUP_MODULE(PixelCPEGenericESProducer);