34 std::unique_ptr<HRes4DHit> h4DHitWS[3][4];
40 std::unique_ptr<HEff4DHit> hEffWS[3][4];
52 constexpr
bool mirrorMinusWheels =
true;
58 debug_ =
pset.getUntrackedParameter<
bool>(
"debug");
62 simHitLabel_ =
pset.getUntrackedParameter<
InputTag>(
"simHitLabel");
63 simHitToken_ = consumes<PSimHitContainer>(
pset.getUntrackedParameter<
InputTag>(
"simHitLabel"));
65 segment4DLabel_ =
pset.getUntrackedParameter<
InputTag>(
"segment4DLabel");
66 segment4DToken_ = consumes<DTRecSegment4DCollection>(
pset.getUntrackedParameter<
InputTag>(
"segment4DLabel"));
69 sigmaResX_ =
pset.getParameter<
double>(
"sigmaResX");
70 sigmaResY_ =
pset.getParameter<
double>(
"sigmaResY");
72 sigmaResAlpha_ =
pset.getParameter<
double>(
"sigmaResAlpha");
73 sigmaResBeta_ =
pset.getParameter<
double>(
"sigmaResBeta");
74 doall_ =
pset.getUntrackedParameter<
bool>(
"doall",
false);
75 local_ =
pset.getUntrackedParameter<
bool>(
"local",
false);
82 histograms.h4DHit = std::make_unique<HRes4DHit>(
"All", booker, doall_, local_);
83 histograms.h4DHit_W0 = std::make_unique<HRes4DHit>(
"W0", booker, doall_, local_);
84 histograms.h4DHit_W1 = std::make_unique<HRes4DHit>(
"W1", booker, doall_, local_);
85 histograms.h4DHit_W2 = std::make_unique<HRes4DHit>(
"W2", booker, doall_, local_);
88 histograms.hEff_All = std::make_unique<HEff4DHit>(
"All", booker);
89 histograms.hEff_W0 = std::make_unique<HEff4DHit>(
"W0", booker);
90 histograms.hEff_W1 = std::make_unique<HEff4DHit>(
"W1", booker);
91 histograms.hEff_W2 = std::make_unique<HEff4DHit>(
"W2", booker);
97 for (
long w = 0;
w <= 2; ++
w) {
98 for (
long s = 1;
s <= 4; ++
s) {
100 TString nameWS = (
name +
w +
"_St" +
s);
101 histograms.h4DHitWS[
w][
s - 1] = std::make_unique<HRes4DHit>(nameWS.Data(), booker, doall_, local_);
102 histograms.hEffWS[
w][
s - 1] = std::make_unique<HEff4DHit>(nameWS.Data(), booker);
120 event.getByToken(simHitToken_,
simHits);
123 map<DTChamberId, PSimHitContainer> simHitsPerCh;
131 simHitsPerCh[chamberId].push_back(
simHit);
137 event.getByToken(segment4DToken_, segment4Ds);
141 cout <<
"[DTSegment4DQuality]**Warning: no 4D Segments with label: " << segment4DLabel_
142 <<
" in this event, skipping!" << endl;
148 for (
auto &simHitsInChamber : simHitsPerCh) {
151 if (
station == 4 && !(local_)) {
163 int nMuSimHit = muSimHitPerWire.size();
168 cout <<
"=== Chamber " << chamberId <<
" has " << nMuSimHit <<
" SimHits" << endl;
175 if ((
DTWireId(inAndOutSimHit.first->detUnitId())).superlayer() ==
176 (
DTWireId(inAndOutSimHit.second->detUnitId())).superLayer()) {
181 pair<LocalVector, LocalPoint> dirAndPosSimSegm =
184 LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
185 LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
194 float xSimSeg = simSegmLocalPos.
x();
195 float ySimSeg = simSegmLocalPos.
y();
197 float etaSimSeg = simSegmGlobalPos.
eta();
198 float phiSimSeg = simSegmGlobalPos.
phi();
200 double count_seg = 0;
203 cout <<
" Simulated segment: local direction " << simSegmLocalDir << endl
204 <<
" local position " << simSegmLocalPos << endl
205 <<
" alpha " << alphaSimSeg << endl
206 <<
" beta " << betaSimSeg << endl;
211 bool recHitFound =
false;
215 cout <<
" Chamber: " << chamberId <<
" has " << nsegm <<
" 4D segments" << endl;
225 double deltaAlpha = 99999;
226 double deltaBeta = 99999;
231 if (
station != 4 && (*segment4D).dimension() != 4) {
235 LocalVector recSegDirection = (*segment4D).localDirection();
236 LocalPoint recSegPosition = (*segment4D).localPosition();
239 float recSegAlpha = ab.first;
240 float recSegBeta = ab.second;
243 cout << &(*segment4D) <<
" RecSegment direction: " << recSegDirection << endl
244 <<
" position : " << (*segment4D).localPosition() << endl
245 <<
" alpha : " << recSegAlpha << endl
246 <<
" beta : " << recSegBeta << endl
247 <<
" nhits : " << (*segment4D).phiSegment()->recHits().size() <<
" "
248 << (((*segment4D).zSegment() !=
nullptr) ? (*segment4D).zSegment()->recHits().size() : 0) << endl;
251 float dAlphaRecSim = fabs(recSegAlpha - alphaSimSeg);
252 float dBetaRecSim = fabs(recSegBeta - betaSimSeg);
254 if ((fabs(recSegPosition.
x() - simSegmLocalPos.
x()) <
256 && ((fabs(recSegPosition.
y() - simSegmLocalPos.
y()) < 4) ||
257 (*segment4D).dimension() < 4)) {
260 if (fabs(dAlphaRecSim - deltaAlpha) <
epsilon) {
261 if (dBetaRecSim < deltaBeta) {
262 deltaAlpha = dAlphaRecSim;
263 deltaBeta = dBetaRecSim;
264 bestRecHit = &(*segment4D);
267 }
else if (dAlphaRecSim < deltaAlpha) {
268 deltaAlpha = dAlphaRecSim;
269 deltaBeta = dBetaRecSim;
270 bestRecHit = &(*segment4D);
278 cout << endl <<
"Chosen: " << bestRecHit << endl;
288 float alphaBestRHit = ab.first;
289 float betaBestRHit = ab.second;
303 float alphaBestRHitRZ = 0;
304 float alphaSimSegRZ = betaSimSeg;
320 simSegLocalPosRZTmp + simSegLocalDirRZ * (-simSegLocalPosRZTmp.
z() / (
cos(simSegLocalDirRZ.
theta())));
324 cout <<
"RZ SL: recPos " << bestRecHitLocalPosRZ <<
"recDir " << bestRecHitLocalDirRZ <<
"recAlpha "
325 << alphaBestRHitRZ << endl
326 <<
"RZ SL: simPos " << simSegLocalPosRZ <<
"simDir " << simSegLocalDirRZ <<
"simAlpha "
327 << alphaSimSegRZ << endl;
335 float t0theta = -999;
340 t0phi = phiSeg->
t0();
341 nHitPhi = phiSeg->
recHits().size();
345 t0theta = zedRecSeg->
t0();
346 nHitTheta = zedRecSeg->
recHits().size();
353 if (mirrorMinusWheels &&
wheel < 0) {
355 alphaBestRHit *= -1.;
373 float sigmaBetaBestRhit =
375 bestRecHitLocalDirErr.
yy()));
379 histo->fill(alphaSimSeg,
384 bestRecHitLocalPos.
x(),
386 bestRecHitLocalPos.
y(),
389 bestRecHitLocalPosRZ.
x(),
390 simSegLocalPosRZ.
x(),
395 sqrt(bestRecHitLocalPosErr.
xx()),
396 sqrt(bestRecHitLocalPosErr.
yy()),
397 sigmaAlphaBestRhitRZ,
398 sqrt(bestRecHitLocalPosErrRZ.
xx()),
409 bestRecHitLocalPos.
x(),
411 bestRecHitLocalPos.
y(),
414 bestRecHitLocalPosRZ.
x(),
415 simSegLocalPosRZ.
x(),
420 sqrt(bestRecHitLocalPosErr.
xx()),
421 sqrt(bestRecHitLocalPosErr.
yy()),
422 sigmaAlphaBestRhitRZ,
423 sqrt(bestRecHitLocalPosErrRZ.
xx()),
435 bestRecHitLocalPos.
x(),
437 bestRecHitLocalPos.
y(),
440 bestRecHitLocalPosRZ.
x(),
441 simSegLocalPosRZ.
x(),
446 sqrt(bestRecHitLocalPosErr.
xx()),
447 sqrt(bestRecHitLocalPosErr.
yy()),
448 sigmaAlphaBestRhitRZ,
449 sqrt(bestRecHitLocalPosErrRZ.
xx()),
471 heff->
fill(etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, recHitFound, count_seg);
473 etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, recHitFound, count_seg);
476 etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, recHitFound, count_seg);