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);
int station() const
Return the station number.
std::pair< double, double > findSegmentAlphaAndBeta(const LocalVector &direction)
std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
std::pair< const_iterator, const_iterator > range
iterator range
LocalPoint localPosition() const override
local position in SL frame
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, dtsegment4d::Histograms const &) const override
Perform the real analysis.
LocalVector localDirection() const override
the local direction in SL frame
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
double t0() const
Get the segment t0 (if recomputed, 0 is returned otherwise)
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
std::unique_ptr< HRes4DHit > h4DHit_W0
Geom::Phi< T > phi() const
LocalError localDirectionError() const override
Local direction error in the Chamber frame.
std::unique_ptr< HEff4DHit > hEff_W2
std::pair< LocalVector, LocalPoint > findMuSimSegmentDirAndPos(const std::pair< const PSimHit *, const PSimHit *> &inAndOutSimHit, const DetId detId, const DTGeometry &muonGeom)
LocalVector localDirection() const override
Local direction in Chamber frame.
std::unique_ptr< HEff4DHit > hEff_W0
edm::InputTag segment4DLabel_
edm::InputTag simHitLabel_
LocalPoint localPosition() const override
Local position in Chamber frame.
const DTSLRecSegment2D * zSegment() const
The Z segment: 0 if not zed projection available.
std::atomic< bool > debug
edm::EDGetTokenT< DTRecSegment4DCollection > segment4DToken_
C::const_iterator const_iterator
constant access iterator type
DTSegment4DQuality(const edm::ParameterSet &pset)
Constructor.
std::unique_ptr< HRes4DHit > h4DHit
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return a DTSuperLayer given its id.
void fill(float etaSimSegm, float phiSimSegm, float xSimSegm, float ySimSegm, float alphaSimSegm, float betaSimSegm, bool fillRecHit, int nSeg)
LocalError localDirectionError() const override
the local direction error (xx,xy,yy) in SL frame: only xx is not 0.
std::map< DTWireId, const PSimHit * > mapMuSimHitsPerWire(const std::map< DTWireId, edm::PSimHitContainer > &simHitWireMap)
Create a map between the Mu SimHits and corresponding MuBarWireId ;.
std::unique_ptr< HRes4DHit > h4DHit_W2
Cos< T >::type cos(const T &t)
A set of histograms for efficiency 4D RecHits (producer)
Abs< T >::type abs(const T &t)
LocalError localPositionError() const override
local position error in SL frame
#define DEFINE_FWK_MODULE(type)
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, dtsegment4d::Histograms &) const override
Book the DQM plots.
DTSuperLayerId superLayerId() const
The id of the superlayer on which reside the segment.
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
std::unique_ptr< HRes4DHit > h4DHit_W1
std::pair< const PSimHit *, const PSimHit * > findMuSimSegment(const std::map< DTWireId, const PSimHit *> &mapWireAndMuSimHit)
int wheel() const
Return the wheel number.
std::unique_ptr< HEff4DHit > hEff_All
LocalError localPositionError() const override
Local position error in Chamber frame.
std::vector< PSimHit > PSimHitContainer
double sigmaAngle(double Angle, double sigma2TanAngle)
edm::EDGetTokenT< edm::PSimHitContainer > simHitToken_
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Geom::Theta< T > theta() const
std::unique_ptr< HEff4DHit > hEff_W1