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 ModOn = conf_.getParameter<
bool>(
"Mod_On");
26 offlinePrimaryVerticesToken_ = consumes<reco::VertexCollection>(
std::string(
"offlinePrimaryVertices"));
29 template <TrackerType pixel_or_strip>
31 if (genTriggerEventFlag_)
32 delete genTriggerEventFlag_;
35 template <TrackerType pixel_or_strip>
40 if (m_cacheID_ != cacheID) {
42 this->createMEs(ibooker, iSetup);
48 tkhisto_ResidualsMean =
49 std::make_unique<TkHistoMap>(tkDetMap, ibooker, topFolderName_,
"TkHMap_ResidualsMean", 0.0,
true);
52 template <TrackerType pixel_or_strip>
55 if (genTriggerEventFlag_->on())
56 genTriggerEventFlag_->initRun(
run, iSetup);
59 template <TrackerType pixel_or_strip>
64 auto id =
DetId(ModuleID);
65 switch (
id.subdetId()) {
73 layer = tTopo->
pxfDisk(
id) * (tTopo->
pxfSide(ModuleID) == 1 ? -1 : +1);
82 layer = tTopo->
tidWheel(
id) * (tTopo->
tidSide(ModuleID) == 1 ? -1 : +1);
90 layer = tTopo->
tecWheel(
id) * (tTopo->
tecSide(ModuleID) == 1 ? -1 : +1);
97 return std::make_pair(subdet, layer);
100 template <TrackerType pixel_or_strip>
108 double d_residual_xmin =
Parameters.getParameter<
double>(
"xmin");
109 double d_residual_xmax =
Parameters.getParameter<
double>(
"xmax");
112 double d_normres_xmin =
Parameters.getParameter<
double>(
"xmin");
113 double d_normres_xmax =
Parameters.getParameter<
double>(
"xmax");
124 for (
DetId id : ids) {
125 auto ModuleID =
id.rawId();
126 auto isPixel =
id.subdetId() == 1 ||
id.subdetId() == 2;
132 switch (
id.subdetId()) {
134 pixel_organizer.setModuleFolder(ibooker, ModuleID, 0);
137 pixel_organizer.setModuleFolder(ibooker, ModuleID, 0);
144 std::string hid = hidmanager.createHistoId(
"HitResidualsX",
"det", ModuleID);
145 std::string normhid = hidmanager.createHistoId(
"NormalizedHitResidualsX",
"det", ModuleID);
146 auto &
histos = m_ModuleResiduals[std::make_pair(
"", ModuleID)];
147 histos.x.base = ibooker.
book1D(hid, hid, i_residuals_Nbins, d_residual_xmin, d_residual_xmax);
148 histos.x.base->setAxisTitle(
"(x_{pred} - x_{rec})' [cm]");
149 histos.x.normed = ibooker.
book1D(normhid, normhid, i_normres_Nbins, d_normres_xmin, d_normres_xmax);
150 histos.x.normed->setAxisTitle(
"(x_{pred} - x_{rec})'/#sigma");
153 std::string hid = hidmanager.createHistoId(
"HitResidualsY",
"det", ModuleID);
154 std::string normhid = hidmanager.createHistoId(
"NormalizedHitResidualsY",
"det", ModuleID);
155 auto &
histos = m_ModuleResiduals[std::make_pair(
"", ModuleID)];
156 histos.y.base = ibooker.
book1D(hid, hid, i_residuals_Nbins, d_residual_xmin, d_residual_xmax);
157 histos.y.base->setAxisTitle(
"(y_{pred} - y_{rec})' [cm]");
158 histos.y.normed = ibooker.
book1D(normhid, normhid, i_normres_Nbins, d_normres_xmin, d_normres_xmax);
159 histos.y.normed->setAxisTitle(
"(y_{pred} - y_{rec})'/#sigma");
163 auto subdetandlayer = findSubdetAndLayer(ModuleID, tTopo);
164 if (m_SubdetLayerResiduals.find(subdetandlayer) == m_SubdetLayerResiduals.end()) {
166 auto &
histos = m_SubdetLayerResiduals[subdetandlayer];
167 switch (
id.subdetId()) {
179 strip_organizer.
setLayerFolder(ModuleID, tTopo, subdetandlayer.second);
182 auto isBarrel = subdetandlayer.first.find(
"B") != std::string::npos;
184 auto xy = std::vector<std::pair<HistoPair &, const char *>>{std::make_pair(std::ref(
histos.x),
"X"),
185 std::make_pair(std::ref(
histos.y),
"Y")};
186 for (
auto &histopair :
xy) {
191 if (!
isPixel && histopair.second[0] ==
'Y')
195 Form(
"HitResiduals%s_%s%d",
197 isBarrel ?
"L" : (subdetandlayer.second > 0 ?
"Dp" :
"Dm"),
199 : (Form(
"HitResiduals_%s__%s__%d",
201 subdetandlayer.first.c_str(),
205 std::string histotitle = Form(
"HitResiduals %s on %s%s full %s %d",
207 subdetandlayer.first.c_str(),
208 isBarrel ?
"" : (subdetandlayer.second > 0 ?
"+" :
"-"),
212 std::string normhistoname = Form(
"Normalized%s", histoname.c_str());
213 std::string normhistotitle = Form(
"Normalized%s", histotitle.c_str());
218 histopair.first.base =
219 ibooker.
book1D(histoname.c_str(), histotitle.c_str(), i_residuals_Nbins, d_residual_xmin, d_residual_xmax);
220 histopair.first.base->
setAxisTitle(
"(x_{pred} - x_{rec})' [cm]");
222 histopair.first.normed = ibooker.
book1D(
223 normhistoname.c_str(), normhistotitle.c_str(), i_normres_Nbins, d_normres_xmin, d_normres_xmax);
224 histopair.first.normed->
setAxisTitle(
"(x_{pred} - x_{rec})'/#sigma");
230 template <TrackerType pixel_or_strip>
232 auto vtracks = std::vector<TrackerValidationVariables::AVTrackStruct>();
234 if (genTriggerEventFlag_->on() && !genTriggerEventFlag_->accept(
iEvent, iSetup))
246 avalidator_.fillTrackQuantities(
255 for (
auto &
track : vtracks) {
256 for (
auto &it :
track.hits) {
257 uint RawId = it.rawDetId;
259 auto id =
DetId(RawId);
260 auto isPixel =
id.subdetId() == 1 ||
id.subdetId() == 2;
265 auto &mod_histos = m_ModuleResiduals[std::make_pair(
"", RawId)];
266 mod_histos.x.base->Fill(it.resXprime);
267 mod_histos.x.normed->Fill(it.resXprime / it.resXprimeErr);
268 mod_histos.y.base->Fill(it.resYprime);
269 mod_histos.y.normed->Fill(it.resYprime / it.resYprimeErr);
272 auto subdetandlayer = findSubdetAndLayer(RawId, tTopo);
273 auto histos = m_SubdetLayerResiduals[subdetandlayer];
275 if (it.resXprimeErr != 0 &&
histos.x.base) {
276 histos.x.base->Fill(it.resXprime);
277 histos.x.normed->Fill(it.resXprime / it.resXprimeErr);
279 tkhisto_ResidualsMean->fill(RawId, it.resXprime);
281 if (it.resYprimeErr != 0 &&
histos.y.base) {
282 histos.y.base->Fill(it.resYprime);
283 histos.y.normed->Fill(it.resYprime / it.resYprimeErr);