14 template <TrackerType pixel_or_strip>
17 tkDetMapToken_{esConsumes<TkDetMap, TrackerTopologyRcd, edm::Transition::BeginRun>()},
18 trackerTopologyRunToken_{esConsumes<TrackerTopology, TrackerTopologyRcd, edm::Transition::BeginRun>()},
19 trackerGeometryToken_{esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>()},
20 trackerTopologyEventToken_{esConsumes<TrackerTopology, TrackerTopologyRcd>()},
23 iConfig.getParameter<
edm::ParameterSet>(
"genericTriggerEventPSet"), consumesCollector(), *
this)),
24 avalidator_(iConfig, consumesCollector()) {
25 applyVertexCut_ = conf_.getUntrackedParameter<
bool>(
"VertexCut",
true);
26 ModOn = conf_.getParameter<
bool>(
"Mod_On");
27 offlinePrimaryVerticesToken_ = consumes<reco::VertexCollection>(
std::string(
"offlinePrimaryVertices"));
30 template <TrackerType pixel_or_strip>
32 if (genTriggerEventFlag_)
33 delete genTriggerEventFlag_;
36 template <TrackerType pixel_or_strip>
41 if (m_cacheID_ != cacheID) {
43 this->createMEs(ibooker, iSetup);
49 tkhisto_ResidualsMean =
50 std::make_unique<TkHistoMap>(tkDetMap, ibooker, topFolderName_,
"TkHMap_ResidualsMean", 0.0,
true);
53 template <TrackerType pixel_or_strip>
56 if (genTriggerEventFlag_->on())
57 genTriggerEventFlag_->initRun(
run, iSetup);
60 template <TrackerType pixel_or_strip>
65 auto id =
DetId(ModuleID);
66 switch (
id.subdetId()) {
98 return std::make_pair(subdet,
layer);
101 template <TrackerType pixel_or_strip>
109 double d_residual_xmin =
Parameters.getParameter<
double>(
"xmin");
110 double d_residual_xmax =
Parameters.getParameter<
double>(
"xmax");
113 double d_normres_xmin =
Parameters.getParameter<
double>(
"xmin");
114 double d_normres_xmax =
Parameters.getParameter<
double>(
"xmax");
125 for (
DetId id : ids) {
126 auto ModuleID =
id.rawId();
127 auto isPixel =
id.subdetId() == 1 ||
id.subdetId() == 2;
133 switch (
id.subdetId()) {
135 pixel_organizer.setModuleFolder(ibooker, ModuleID, 0);
138 pixel_organizer.setModuleFolder(ibooker, ModuleID, 0);
145 std::string hid = hidmanager.createHistoId(
"HitResidualsX",
"det", ModuleID);
146 std::string normhid = hidmanager.createHistoId(
"NormalizedHitResidualsX",
"det", ModuleID);
147 auto &
histos = m_ModuleResiduals[std::make_pair(
"", ModuleID)];
148 histos.x.base = ibooker.
book1D(hid, hid, i_residuals_Nbins, d_residual_xmin, d_residual_xmax);
149 histos.x.base->setAxisTitle(
"(x_{pred} - x_{rec})' [cm]");
150 histos.x.normed = ibooker.
book1D(normhid, normhid, i_normres_Nbins, d_normres_xmin, d_normres_xmax);
151 histos.x.normed->setAxisTitle(
"(x_{pred} - x_{rec})'/#sigma");
154 std::string hid = hidmanager.createHistoId(
"HitResidualsY",
"det", ModuleID);
155 std::string normhid = hidmanager.createHistoId(
"NormalizedHitResidualsY",
"det", ModuleID);
156 auto &
histos = m_ModuleResiduals[std::make_pair(
"", ModuleID)];
157 histos.y.base = ibooker.
book1D(hid, hid, i_residuals_Nbins, d_residual_xmin, d_residual_xmax);
158 histos.y.base->setAxisTitle(
"(y_{pred} - y_{rec})' [cm]");
159 histos.y.normed = ibooker.
book1D(normhid, normhid, i_normres_Nbins, d_normres_xmin, d_normres_xmax);
160 histos.y.normed->setAxisTitle(
"(y_{pred} - y_{rec})'/#sigma");
164 auto subdetandlayer = findSubdetAndLayer(ModuleID, tTopo);
165 if (m_SubdetLayerResiduals.find(subdetandlayer) == m_SubdetLayerResiduals.end()) {
167 auto &
histos = m_SubdetLayerResiduals[subdetandlayer];
168 switch (
id.subdetId()) {
180 strip_organizer.
setLayerFolder(ModuleID, tTopo, subdetandlayer.second);
183 auto isBarrel = subdetandlayer.first.find(
"B") != std::string::npos;
185 auto xy = std::vector<std::pair<HistoPair &, const char *>>{std::make_pair(std::ref(
histos.x),
"X"),
186 std::make_pair(std::ref(
histos.y),
"Y")};
187 for (
auto &histopair :
xy) {
192 if (!
isPixel && histopair.second[0] ==
'Y')
196 Form(
"HitResiduals%s_%s%d",
198 isBarrel ?
"L" : (subdetandlayer.second > 0 ?
"Dp" :
"Dm"),
200 : (Form(
"HitResiduals_%s__%s__%d",
202 subdetandlayer.first.c_str(),
206 std::string histotitle = Form(
"HitResiduals %s on %s%s full %s %d",
208 subdetandlayer.first.c_str(),
209 isBarrel ?
"" : (subdetandlayer.second > 0 ?
"+" :
"-"),
213 std::string normhistoname = Form(
"Normalized%s", histoname.c_str());
214 std::string normhistotitle = Form(
"Normalized%s", histotitle.c_str());
219 histopair.first.base =
220 ibooker.
book1D(histoname.c_str(), histotitle.c_str(), i_residuals_Nbins, d_residual_xmin, d_residual_xmax);
221 histopair.first.base->
setAxisTitle(
"(x_{pred} - x_{rec})' [cm]");
223 histopair.first.normed = ibooker.
book1D(
224 normhistoname.c_str(), normhistotitle.c_str(), i_normres_Nbins, d_normres_xmin, d_normres_xmax);
225 histopair.first.normed->
setAxisTitle(
"(x_{pred} - x_{rec})'/#sigma");
231 template <TrackerType pixel_or_strip>
233 auto vtracks = std::vector<TrackerValidationVariables::AVTrackStruct>();
235 if (genTriggerEventFlag_->on() && !genTriggerEventFlag_->accept(
iEvent, iSetup))
239 if (applyVertexCut_) {
248 avalidator_.fillTrackQuantities(
253 return (!applyVertexCut_ ||
258 for (
auto &
track : vtracks) {
259 for (
auto &it :
track.hits) {
260 uint RawId = it.rawDetId;
262 auto id =
DetId(RawId);
263 auto isPixel =
id.subdetId() == 1 ||
id.subdetId() == 2;
268 auto &mod_histos = m_ModuleResiduals[std::make_pair(
"", RawId)];
269 mod_histos.x.base->Fill(it.resXprime);
270 mod_histos.x.normed->Fill(it.resXprime / it.resXprimeErr);
271 mod_histos.y.base->Fill(it.resYprime);
272 mod_histos.y.normed->Fill(it.resYprime / it.resYprimeErr);
275 auto subdetandlayer = findSubdetAndLayer(RawId, tTopo);
276 auto histos = m_SubdetLayerResiduals[subdetandlayer];
278 if (it.resXprimeErr != 0 &&
histos.x.base) {
279 histos.x.base->Fill(it.resXprime);
280 histos.x.normed->Fill(it.resXprime / it.resXprimeErr);
282 tkhisto_ResidualsMean->fill(RawId, it.resXprime);
284 if (it.resYprimeErr != 0 &&
histos.y.base) {
285 histos.y.base->Fill(it.resYprime);
286 histos.y.normed->Fill(it.resYprime / it.resYprimeErr);
T getParameter(std::string const &) const
unsigned int tobLayer(const DetId &id) const
unsigned int pxbLayer(const DetId &id) const
void setSiStripFolderName(std::string name)
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
virtual void setCurrentFolder(std::string const &fullpath)
const DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
unsigned int tidSide(const DetId &id) const
#define DEFINE_FWK_MODULE(type)
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
void setLayerFolder(uint32_t rawdetid, const TrackerTopology *tTopo, int32_t layer=0, bool ring_flag=false)
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
constexpr std::array< uint8_t, layerIndexSize > layer
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
vector< ParameterSet > Parameters
unsigned int tecSide(const DetId &id) const
unsigned int pxfDisk(const DetId &id) const
Abs< T >::type abs(const T &t)
bool getData(T &iHolder) const
MonitorTrackResidualsBase(const edm::ParameterSet &)
~MonitorTrackResidualsBase() override
unsigned int pxfSide(const DetId &id) const
void createMEs(DQMStore::IBooker &, const edm::EventSetup &)
bool isPixel(HitType hitType)
unsigned int tibLayer(const DetId &id) const
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
void analyze(const edm::Event &, const edm::EventSetup &) override
std::pair< std::string, int32_t > findSubdetAndLayer(uint32_t ModuleID, const TrackerTopology *tTopo)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)