49 debug_ =
pset.getUntrackedParameter<
bool>(
"debug");
52 simHitLabel_ =
pset.getUntrackedParameter<
InputTag>(
"simHitLabel");
53 simHitToken_ = consumes<PSimHitContainer>(
pset.getUntrackedParameter<
InputTag>(
"simHitLabel"));
55 segment2DLabel_ =
pset.getUntrackedParameter<
InputTag>(
"segment2DLabel");
56 segment2DToken_ = consumes<DTRecSegment2DCollection>(
pset.getUntrackedParameter<
InputTag>(
"segment2DLabel"));
59 sigmaResPos_ =
pset.getParameter<
double>(
"sigmaResPos");
61 sigmaResAngle_ =
pset.getParameter<
double>(
"sigmaResAngle");
64 cout <<
"[DTSegment2DQuality] Constructor called " << endl;
72 histograms.h2DHitRPhi = std::make_unique<HRes2DHit>(
"RPhi", booker,
true,
true);
73 histograms.h2DHitRZ = std::make_unique<HRes2DHit>(
"RZ", booker,
true,
true);
74 histograms.h2DHitRZ_W0 = std::make_unique<HRes2DHit>(
"RZ_W0", booker,
true,
true);
75 histograms.h2DHitRZ_W1 = std::make_unique<HRes2DHit>(
"RZ_W1", booker,
true,
true);
76 histograms.h2DHitRZ_W2 = std::make_unique<HRes2DHit>(
"RZ_W2", booker,
true,
true);
78 histograms.h2DHitEff_RPhi = std::make_unique<HEff2DHit>(
"RPhi", booker);
79 histograms.h2DHitEff_RZ = std::make_unique<HEff2DHit>(
"RZ", booker);
80 histograms.h2DHitEff_RZ_W0 = std::make_unique<HEff2DHit>(
"RZ_W0", booker);
81 histograms.h2DHitEff_RZ_W1 = std::make_unique<HEff2DHit>(
"RZ_W1", booker);
82 histograms.h2DHitEff_RZ_W2 = std::make_unique<HEff2DHit>(
"RZ_W2", booker);
84 cout <<
"[DTSegment2DQuality] hitsos created " << endl;
98 event.getByToken(simHitToken_,
simHits);
101 map<DTSuperLayerId, PSimHitContainer> simHitsPerSl;
106 simHitsPerSl[slId].push_back(
simHit);
111 event.getByToken(segment2DToken_, segment2Ds);
113 if (not segment2Ds.
isValid()) {
115 cout <<
"[DTSegment2DQuality]**Warning: no 2DSegments with label: " << segment2DLabel_
116 <<
" in this event, skipping !" << endl;
123 for (slId = segment2Ds->id_begin(); slId != segment2Ds->id_end(); ++slId) {
131 int nMuSimHit = muSimHitPerWire.size();
132 if (nMuSimHit == 0
or nMuSimHit == 1) {
133 if (debug_ and nMuSimHit == 1) {
134 cout <<
"[DTSegment2DQuality] Only " << nMuSimHit <<
" mu SimHit in this SL, skipping !" << endl;
139 cout <<
"=== SL " << (*slId) <<
" has " << nMuSimHit <<
" SimHits" << endl;
145 if (inAndOutSimHit.first == inAndOutSimHit.second) {
146 cout <<
"[DTHitQualityUtils]***Warning: outermost and innermost SimHit "
153 pair<LocalVector, LocalPoint> dirAndPosSimSegm =
156 LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
157 LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
159 cout <<
" Simulated segment: local direction " << simSegmLocalDir << endl
160 <<
" local position " << simSegmLocalPos << endl;
167 float posSimSeg = simSegmLocalPos.
x();
169 float etaSimSeg = simSegmGlobalPos.
eta();
170 float phiSimSeg = simSegmGlobalPos.
phi();
174 bool recHitFound =
false;
178 cout <<
" Sl: " << *slId <<
" has " << nsegm <<
" 2D segments" << endl;
188 bool bestRecHitFound =
false;
189 double deltaAlpha = 99999;
194 if ((*segment2D).dimension() != 2) {
196 cout <<
"[DTSegment2DQuality]***Error: This is not 2D segment !!!" << endl;
201 LocalVector recSegDirection = (*segment2D).localDirection();
202 LocalPoint recSegPosition = (*segment2D).localPosition();
206 cout <<
" RecSegment direction: " << recSegDirection << endl
207 <<
" position : " << recSegPosition << endl
208 <<
" alpha : " << recSegAlpha << endl;
211 if (fabs(recSegAlpha - angleSimSeg) < deltaAlpha) {
212 deltaAlpha = fabs(recSegAlpha - angleSimSeg);
213 bestRecHit = &(*segment2D);
214 bestRecHitFound =
true;
218 if (bestRecHitFound) {
228 if (fabs(angleBestRHit - angleSimSeg) < 5 * sigmaResAngle_ and
229 fabs(bestRecHitLocalPos.
x() - posSimSeg) < 5 * sigmaResPos_) {
235 if ((*slId).superlayer() == 1
or (*slId).superlayer() == 3) {
237 }
else if ((*slId).superlayer() == 2) {
241 bestRecHitLocalPos.
x(),
244 sqrt(bestRecHitLocalPosErr.
xx()),
245 sqrt(bestRecHitLocalDirErr.
xx()));
246 if (
abs((*slId).wheel()) == 0) {
248 }
else if (
abs((*slId).wheel()) == 1) {
250 }
else if (
abs((*slId).wheel()) == 2) {
254 hRes->fill(angleSimSeg,
257 bestRecHitLocalPos.
x(),
260 sqrt(bestRecHitLocalPosErr.
xx()),
261 sqrt(bestRecHitLocalDirErr.
xx()));
267 if ((*slId).superlayer() == 1
or (*slId).superlayer() == 3) {
269 }
else if ((*slId).superlayer() == 2) {
270 histograms.h2DHitEff_RZ->fill(etaSimSeg, phiSimSeg, posSimSeg, angleSimSeg, recHitFound);
271 if (
abs((*slId).wheel()) == 0) {
273 }
else if (
abs((*slId).wheel()) == 1) {
275 }
else if (
abs((*slId).wheel()) == 2) {
279 hEff->
fill(etaSimSeg, phiSimSeg, posSimSeg, angleSimSeg, recHitFound);