50 std::unique_ptr<HRes1DHit> hRes_S3RPhiWS[3][4];
51 std::unique_ptr<HRes1DHit> hRes_S3RZWS[3][4];
68 std::unique_ptr<HEff1DHit> hEff_S1RPhiWS[3][4];
69 std::unique_ptr<HEff1DHit> hEff_S3RPhiWS[3][4];
70 std::unique_ptr<HEff1DHit> hEff_S1RZWS[3][4];
71 std::unique_ptr<HEff1DHit> hEff_S3RZWS[3][4];
84 constexpr
bool mirrorMinusWheels =
true;
90 debug_ =
pset.getUntrackedParameter<
bool>(
"debug");
92 simHitLabel_ =
pset.getUntrackedParameter<
InputTag>(
"simHitLabel");
93 simHitToken_ = consumes<PSimHitContainer>(
pset.getUntrackedParameter<
InputTag>(
"simHitLabel"));
95 recHitLabel_ =
pset.getUntrackedParameter<
InputTag>(
"recHitLabel");
96 recHitToken_ = consumes<DTRecHitCollection>(
pset.getUntrackedParameter<
InputTag>(
"recHitLabel"));
98 segment2DLabel_ =
pset.getUntrackedParameter<
InputTag>(
"segment2DLabel");
99 segment2DToken_ = consumes<DTRecSegment2DCollection>(
pset.getUntrackedParameter<
InputTag>(
"segment2DLabel"));
101 segment4DLabel_ =
pset.getUntrackedParameter<
InputTag>(
"segment4DLabel");
102 segment4DToken_ = consumes<DTRecSegment4DCollection>(
pset.getUntrackedParameter<
InputTag>(
"segment4DLabel"));
104 doStep1_ =
pset.getUntrackedParameter<
bool>(
"doStep1",
false);
105 doStep2_ =
pset.getUntrackedParameter<
bool>(
"doStep2",
false);
106 doStep3_ =
pset.getUntrackedParameter<
bool>(
"doStep3",
false);
107 doall_ =
pset.getUntrackedParameter<
bool>(
"doall",
false);
108 local_ =
pset.getUntrackedParameter<
bool>(
"local",
true);
115 if (doall_ && doStep1_) {
116 histograms.hRes_S1RPhi = std::make_unique<HRes1DHit>(
"S1RPhi", booker,
true, local_);
118 std::make_unique<HRes1DHit>(
"S1RPhi_W0", booker,
true, local_);
120 std::make_unique<HRes1DHit>(
"S1RPhi_W1", booker,
true, local_);
122 std::make_unique<HRes1DHit>(
"S1RPhi_W2", booker,
true, local_);
123 histograms.hRes_S1RZ = std::make_unique<HRes1DHit>(
"S1RZ", booker,
true, local_);
125 std::make_unique<HRes1DHit>(
"S1RZ_W0", booker,
true, local_);
127 std::make_unique<HRes1DHit>(
"S1RZ_W1", booker,
true, local_);
129 std::make_unique<HRes1DHit>(
"S1RZ_W2", booker,
true, local_);
130 histograms.hEff_S1RPhi = std::make_unique<HEff1DHit>(
"S1RPhi", booker);
131 histograms.hEff_S1RZ = std::make_unique<HEff1DHit>(
"S1RZ", booker);
132 histograms.hEff_S1RZ_W0 = std::make_unique<HEff1DHit>(
"S1RZ_W0", booker);
133 histograms.hEff_S1RZ_W1 = std::make_unique<HEff1DHit>(
"S1RZ_W1", booker);
134 histograms.hEff_S1RZ_W2 = std::make_unique<HEff1DHit>(
"S1RZ_W2", booker);
136 if (doall_ && doStep2_) {
137 histograms.hRes_S2RPhi = std::make_unique<HRes1DHit>(
"S2RPhi", booker,
true, local_);
139 std::make_unique<HRes1DHit>(
"S2RPhi_W0", booker,
true, local_);
141 std::make_unique<HRes1DHit>(
"S2RPhi_W1", booker,
true, local_);
143 std::make_unique<HRes1DHit>(
"S2RPhi_W2", booker,
true, local_);
144 histograms.hRes_S2RZ = std::make_unique<HRes1DHit>(
"S2RZ", booker,
true, local_);
146 std::make_unique<HRes1DHit>(
"S2RZ_W0", booker,
true, local_);
148 std::make_unique<HRes1DHit>(
"S2RZ_W1", booker,
true, local_);
150 std::make_unique<HRes1DHit>(
"S2RZ_W2", booker,
true, local_);
151 histograms.hEff_S2RPhi = std::make_unique<HEff1DHit>(
"S2RPhi", booker);
152 histograms.hEff_S2RZ_W0 = std::make_unique<HEff1DHit>(
"S2RZ_W0", booker);
153 histograms.hEff_S2RZ_W1 = std::make_unique<HEff1DHit>(
"S2RZ_W1", booker);
154 histograms.hEff_S2RZ_W2 = std::make_unique<HEff1DHit>(
"S2RZ_W2", booker);
155 histograms.hEff_S2RZ = std::make_unique<HEff1DHit>(
"S2RZ", booker);
158 histograms.hRes_S3RPhi = std::make_unique<HRes1DHit>(
"S3RPhi", booker, doall_, local_);
160 std::make_unique<HRes1DHit>(
"S3RPhi_W0", booker, doall_, local_);
161 histograms.hRes_S3RPhi_W1 = std::make_unique<HRes1DHit>(
"S3RPhi_W1",
165 histograms.hRes_S3RPhi_W2 = std::make_unique<HRes1DHit>(
"S3RPhi_W2",
169 histograms.hRes_S3RZ = std::make_unique<HRes1DHit>(
"S3RZ", booker, doall_, local_);
171 std::make_unique<HRes1DHit>(
"S3RZ_W0", booker, doall_, local_);
173 std::make_unique<HRes1DHit>(
"S3RZ_W1", booker, doall_, local_);
175 std::make_unique<HRes1DHit>(
"S3RZ_W2", booker, doall_, local_);
179 TString name1 =
"RPhi_W";
180 TString
name2 =
"RZ_W";
181 for (
long w = 0;
w <= 2; ++
w) {
182 for (
long s = 1;
s <= 4; ++
s) {
184 std::make_unique<HRes1DHit>((
"S3" + name1 +
w +
"_St" +
s).Data(), booker, doall_, local_);
186 std::make_unique<HEff1DHit>((
"S1" + name1 +
w +
"_St" +
s).Data(), booker);
188 std::make_unique<HEff1DHit>((
"S3" + name1 +
w +
"_St" +
s).Data(), booker);
191 std::make_unique<HRes1DHit>((
"S3" +
name2 +
w +
"_St" +
s).Data(), booker, doall_, local_);
193 std::make_unique<HEff1DHit>((
"S1" +
name2 +
w +
"_St" +
s).Data(), booker);
195 std::make_unique<HEff1DHit>((
"S3" +
name2 +
w +
"_St" +
s).Data(), booker);
202 histograms.hEff_S3RPhi = std::make_unique<HEff1DHit>(
"S3RPhi", booker);
203 histograms.hEff_S3RZ = std::make_unique<HEff1DHit>(
"S3RZ", booker);
204 histograms.hEff_S3RZ_W0 = std::make_unique<HEff1DHit>(
"S3RZ_W0", booker);
205 histograms.hEff_S3RZ_W1 = std::make_unique<HEff1DHit>(
"S3RZ_W1", booker);
206 histograms.hEff_S3RZ_W2 = std::make_unique<HEff1DHit>(
"S3RZ_W2", booker);
216 cout <<
"--- [DTRecHitQuality] Analysing Event: #Run: " <<
event.id().run() <<
" #Event: " <<
event.id().event()
226 event.getByToken(simHitToken_,
simHits);
233 if (doStep1_ && doall_) {
235 cout <<
" -- DTRecHit S1: begin analysis:" << endl;
239 event.getByToken(recHitToken_, dtRecHits);
243 cout <<
"[DTRecHitQuality]**Warning: no 1DRechits with label: " << recHitLabel_ <<
" in this event, skipping!"
250 auto const &recHitsPerWire = map1DRecHitsPerWire(dtRecHits.
product());
256 if (doStep2_ && doall_) {
258 cout <<
" -- DTRecHit S2: begin analysis:" << endl;
263 event.getByToken(segment2DToken_, segment2Ds);
267 cout <<
"[DTRecHitQuality]**Warning: no 2DSegments with label: " << segment2DLabel_
268 <<
" in this event, skipping!" << endl;
273 auto const &recHitsPerWire = map1DRecHitsPerWire(segment2Ds.
product());
282 cout <<
" -- DTRecHit S3: begin analysis:" << endl;
287 event.getByToken(segment4DToken_, segment4Ds);
291 cout <<
"[DTRecHitQuality]**Warning: no 4D Segments with label: " << segment4DLabel_
292 <<
" in this event, skipping!" << endl;
298 auto const &recHitsPerWire = map1DRecHitsPerWire(segment4Ds.
product());
306 map<DTWireId, vector<DTRecHit1DPair>>
ret;
308 for (
const auto &dt1DRecHitPair : *dt1DRecHitPairs) {
309 ret[dt1DRecHitPair.wireId()].push_back(dt1DRecHitPair);
318 map<DTWireId, vector<DTRecHit1D>>
ret;
321 for (
const auto &segment2D : *segment2Ds) {
322 vector<DTRecHit1D> component1DHits = segment2D.specificRecHits();
324 for (
auto &component1DHit : component1DHits) {
325 ret[component1DHit.wireId()].push_back(component1DHit);
334 map<DTWireId, vector<DTRecHit1D>>
ret;
336 for (
const auto &segment4D : *segment4Ds) {
338 vector<const TrackingRecHit *> segment2Ds = segment4D.recHits();
340 for (
auto &segment2D : segment2Ds) {
342 vector<const TrackingRecHit *>
hits = segment2D->recHits();
345 const auto *hit1D = dynamic_cast<const DTRecHit1D *>(
hit);
346 ret[hit1D->wireId()].push_back(*hit1D);
356 float xwire =
layer->specificTopology().wirePosition(wireId.
wire());
359 float xEntry = entryP.
x() - xwire;
360 float xExit = exitP.
x() - xwire;
362 return fabs(xEntry - (entryP.
z() * (xExit - xEntry)) / (exitP.
z() - entryP.
z()));
369 float theta = (exitP.
x() - entryP.
x()) / (exitP.
z() - entryP.
z());
377 float wireLenght =
layer->specificTopology().cellLenght();
381 return (entryP.
y() + exitP.
y()) / 2. + wireLenght;
385 template <
typename type>
389 const float simHitDist)
const {
391 const type *theBestRecHit =
nullptr;
394 float distTmp = recHitDistFromWire(*
recHit,
layer);
395 if (fabs(distTmp - simHitDist) <
res) {
396 res = fabs(distTmp - simHitDist);
397 theBestRecHit = &(*recHit);
401 return theBestRecHit;
412 return fabs(
recHit.localPosition().x() -
layer->specificTopology().wirePosition(
recHit.wireId().wire()));
415 template <
typename type>
422 for (
const auto &wireAndSHits : simHitsPerWire) {
423 DTWireId wireId = wireAndSHits.first;
427 vector<PSimHit> simHitsInCell = wireAndSHits.second;
434 if (muSimHit ==
nullptr) {
436 cout <<
" No mu SimHit in channel: " << wireId <<
", skipping! " << endl;
442 float simHitWireDist = simHitDistFromWire(
layer, wireId, *muSimHit);
444 if (simHitWireDist > 2.1) {
446 cout <<
" [DTRecHitQuality]###Warning: The mu SimHit in out of the "
455 float simHitTheta = simHitImpactAngle(
layer, wireId, *muSimHit);
458 float simHitFEDist = simHitDistFromFE(
layer, wireId, *muSimHit);
460 bool recHitReconstructed =
false;
463 if (recHitsPerWire.find(wireId) == recHitsPerWire.end()) {
466 cout <<
" No RecHit found at Step: " <<
step <<
" in cell: " << wireId << endl;
469 recHitReconstructed =
true;
471 const vector<type> &
recHits = recHitsPerWire.at(wireId);
473 cout <<
" " <<
recHits.size() <<
" RecHits, Step " <<
step <<
" in channel: " << wireId << endl;
477 const type *theBestRecHit = findBestRecHit(
layer, wireId,
recHits, simHitWireDist);
479 float recHitWireDist = recHitDistFromWire(*theBestRecHit,
layer);
481 cout <<
" SimHit distance from wire: " << simHitWireDist << endl
482 <<
" SimHit distance from FE: " << simHitFEDist << endl
483 <<
" SimHit angle in layer RF: " << simHitTheta << endl
484 <<
" RecHit distance from wire: " << recHitWireDist << endl;
486 float recHitErr = recHitPositionError(*theBestRecHit);
491 if (mirrorMinusWheels &&
wheel < 0 && sl != 2) {
524 }
else if (
step == 2) {
550 }
else if (
step == 3) {
568 simHitGlobalPos.
eta(),
569 simHitGlobalPos.
phi(),
589 simHitGlobalPos.
eta(),
590 simHitGlobalPos.
phi(),
598 hRes->fill(simHitWireDist,
602 simHitGlobalPos.
eta(),
603 simHitGlobalPos.
phi(),
606 if (hResTot !=
nullptr) {
607 hResTot->
fill(simHitWireDist,
611 simHitGlobalPos.
eta(),
612 simHitGlobalPos.
phi(),
628 simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
643 simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
647 }
else if (
step == 2) {
664 }
else if (
step == 3) {
670 simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
685 simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
690 hEff->
fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
691 if (hEffTot !=
nullptr) {
692 hEffTot->
fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
705 return sqrt(
recHit.localPositionError().xx());