33 std::unique_ptr<HRes4DHit> h4DHitWS[3][4];
39 std::unique_ptr<HEff4DHit> hEffWS[3][4];
51 constexpr
bool mirrorMinusWheels =
true;
57 debug_ =
pset.getUntrackedParameter<
bool>(
"debug");
73 doall_ =
pset.getUntrackedParameter<
bool>(
"doall",
false);
74 local_ =
pset.getUntrackedParameter<
bool>(
"local",
false);
87 histograms.hEff_All = std::make_unique<HEff4DHit>(
"All", booker);
88 histograms.hEff_W0 = std::make_unique<HEff4DHit>(
"W0", booker);
89 histograms.hEff_W1 = std::make_unique<HEff4DHit>(
"W1", booker);
90 histograms.hEff_W2 = std::make_unique<HEff4DHit>(
"W2", booker);
96 for (
long w = 0;
w <= 2; ++
w) {
97 for (
long s = 1;
s <= 4; ++
s) {
99 TString nameWS = (
name +
w +
"_St" +
s);
101 histograms.hEffWS[
w][
s - 1] = std::make_unique<HEff4DHit>(nameWS.Data(), booker);
121 map<DTChamberId, PSimHitContainer> simHitsPerCh;
129 simHitsPerCh[chamberId].push_back(
simHit);
140 <<
" in this event, skipping!" << endl;
146 for (
auto &simHitsInChamber : simHitsPerCh) {
161 int nMuSimHit = muSimHitPerWire.size();
166 cout <<
"=== Chamber " << chamberId <<
" has " << nMuSimHit <<
" SimHits" << endl;
173 if ((
DTWireId(inAndOutSimHit.first->detUnitId())).superlayer() ==
174 (
DTWireId(inAndOutSimHit.second->detUnitId())).superLayer()) {
179 pair<LocalVector, LocalPoint> dirAndPosSimSegm =
182 LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
183 LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
192 float xSimSeg = simSegmLocalPos.
x();
193 float ySimSeg = simSegmLocalPos.
y();
195 float etaSimSeg = simSegmGlobalPos.
eta();
196 float phiSimSeg = simSegmGlobalPos.
phi();
198 double count_seg = 0;
201 cout <<
" Simulated segment: local direction " << simSegmLocalDir << endl
202 <<
" local position " << simSegmLocalPos << endl
203 <<
" alpha " << alphaSimSeg << endl
204 <<
" beta " << betaSimSeg << endl;
209 bool recHitFound =
false;
213 cout <<
" Chamber: " << chamberId <<
" has " << nsegm <<
" 4D segments" << endl;
223 double deltaAlpha = 99999;
224 double deltaBeta = 99999;
229 if (
station != 4 && (*segment4D).dimension() != 4) {
233 LocalVector recSegDirection = (*segment4D).localDirection();
234 LocalPoint recSegPosition = (*segment4D).localPosition();
237 float recSegAlpha = ab.first;
238 float recSegBeta = ab.second;
241 cout << &(*segment4D) <<
" RecSegment direction: " << recSegDirection << endl
242 <<
" position : " << (*segment4D).localPosition() << endl
243 <<
" alpha : " << recSegAlpha << endl
244 <<
" beta : " << recSegBeta << endl
245 <<
" nhits : " << (*segment4D).phiSegment()->recHits().size() <<
" "
246 << (((*segment4D).zSegment() !=
nullptr) ? (*segment4D).zSegment()->recHits().size() : 0) << endl;
249 float dAlphaRecSim = fabs(recSegAlpha - alphaSimSeg);
250 float dBetaRecSim = fabs(recSegBeta - betaSimSeg);
252 if ((fabs(recSegPosition.
x() - simSegmLocalPos.
x()) <
254 && ((fabs(recSegPosition.
y() - simSegmLocalPos.
y()) < 4) ||
255 (*segment4D).dimension() < 4)) {
258 if (fabs(dAlphaRecSim - deltaAlpha) <
epsilon) {
259 if (dBetaRecSim < deltaBeta) {
260 deltaAlpha = dAlphaRecSim;
261 deltaBeta = dBetaRecSim;
262 bestRecHit = &(*segment4D);
265 }
else if (dAlphaRecSim < deltaAlpha) {
266 deltaAlpha = dAlphaRecSim;
267 deltaBeta = dBetaRecSim;
268 bestRecHit = &(*segment4D);
276 cout << endl <<
"Chosen: " << bestRecHit << endl;
286 float alphaBestRHit = ab.first;
287 float betaBestRHit = ab.second;
301 float alphaBestRHitRZ = 0;
302 float alphaSimSegRZ = betaSimSeg;
318 simSegLocalPosRZTmp + simSegLocalDirRZ * (-simSegLocalPosRZTmp.
z() / (
cos(simSegLocalDirRZ.
theta())));
322 cout <<
"RZ SL: recPos " << bestRecHitLocalPosRZ <<
"recDir " << bestRecHitLocalDirRZ <<
"recAlpha "
323 << alphaBestRHitRZ << endl
324 <<
"RZ SL: simPos " << simSegLocalPosRZ <<
"simDir " << simSegLocalDirRZ <<
"simAlpha "
325 << alphaSimSegRZ << endl;
333 float t0theta = -999;
338 t0phi = phiSeg->
t0();
339 nHitPhi = phiSeg->
recHits().size();
343 t0theta = zedRecSeg->
t0();
344 nHitTheta = zedRecSeg->
recHits().size();
351 if (mirrorMinusWheels &&
wheel < 0) {
353 alphaBestRHit *= -1.;
371 float sigmaBetaBestRhit =
373 bestRecHitLocalDirErr.
yy()));
377 histo->fill(alphaSimSeg,
382 bestRecHitLocalPos.
x(),
384 bestRecHitLocalPos.
y(),
387 bestRecHitLocalPosRZ.
x(),
388 simSegLocalPosRZ.
x(),
393 sqrt(bestRecHitLocalPosErr.
xx()),
394 sqrt(bestRecHitLocalPosErr.
yy()),
395 sigmaAlphaBestRhitRZ,
396 sqrt(bestRecHitLocalPosErrRZ.
xx()),
407 bestRecHitLocalPos.
x(),
409 bestRecHitLocalPos.
y(),
412 bestRecHitLocalPosRZ.
x(),
413 simSegLocalPosRZ.
x(),
418 sqrt(bestRecHitLocalPosErr.
xx()),
419 sqrt(bestRecHitLocalPosErr.
yy()),
420 sigmaAlphaBestRhitRZ,
421 sqrt(bestRecHitLocalPosErrRZ.
xx()),
433 bestRecHitLocalPos.
x(),
435 bestRecHitLocalPos.
y(),
438 bestRecHitLocalPosRZ.
x(),
439 simSegLocalPosRZ.
x(),
444 sqrt(bestRecHitLocalPosErr.
xx()),
445 sqrt(bestRecHitLocalPosErr.
yy()),
446 sigmaAlphaBestRhitRZ,
447 sqrt(bestRecHitLocalPosErrRZ.
xx()),
469 heff->
fill(etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, recHitFound, count_seg);
471 etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, recHitFound, count_seg);
474 etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, recHitFound, count_seg);