27 namespace dtsegment4d {
33 std::unique_ptr<HRes4DHit> h4DHitWS[3][4];
39 std::unique_ptr<HEff4DHit> hEffWS[3][4];
42 using namespace dtsegment4d;
51 constexpr
bool mirrorMinusWheels =
true;
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;
122 for (
const auto &simHit : *simHits) {
125 if (
abs(simHit.particleType()) == 13) {
127 DTChamberId chamberId = (((
DTWireId(simHit.detUnitId())).layerId()).superlayerId()).chamberId();
129 simHitsPerCh[chamberId].push_back(simHit);
140 <<
" in this event, skipping!" << endl;
146 for (
auto &simHitsInChamber : simHitsPerCh) {
149 if (station == 4 && !(
local_)) {
152 int wheel = chamberId.
wheel();
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;
211 int nsegm =
distance(range.first, range.second);
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.;
364 }
else if (
abs(wheel) == 1) {
366 }
else if (
abs(wheel) == 2) {
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()),
402 histograms.
h4DHit->fill(alphaSimSeg,
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()),
428 histograms.
h4DHitWS[
abs(wheel)][station - 1]->fill(alphaSimSeg,
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()),
463 heff = histograms.
hEff_W0.get();
464 }
else if (
abs(wheel) == 1) {
465 heff = histograms.
hEff_W1.get();
466 }
else if (
abs(wheel) == 2) {
467 heff = histograms.
hEff_W2.get();
469 heff->
fill(etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, recHitFound, count_seg);
471 etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, recHitFound, count_seg);
473 histograms.
hEffWS[
abs(wheel)][station - 1]->fill(
474 etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, recHitFound, count_seg);
std::pair< double, double > findSegmentAlphaAndBeta(const LocalVector &direction)
T getUntrackedParameter(std::string const &, T const &) const
std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
std::unique_ptr< HRes4DHit > h4DHitWS[3][4]
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
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
std::unique_ptr< HRes4DHit > h4DHit_W0
#define DEFINE_FWK_MODULE(type)
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
LocalError localDirectionError() const override
Local direction error in the Chamber frame.
std::unique_ptr< HEff4DHit > hEff_W2
Geom::Phi< T > phi() const
LocalVector localDirection() const override
Local direction in Chamber frame.
std::unique_ptr< HEff4DHit > hEff_W0
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
std::pair< LocalVector, LocalPoint > findMuSimSegmentDirAndPos(const std::pair< const PSimHit *, const PSimHit * > &inAndOutSimHit, const DetId detId, const DTGeometry &muonGeom)
edm::InputTag segment4DLabel_
edm::InputTag simHitLabel_
LocalPoint localPosition() const override
Local position in Chamber frame.
std::atomic< bool > debug
edm::EDGetTokenT< DTRecSegment4DCollection > segment4DToken_
const uint16_t range(const Frame &aFrame)
Geom::Theta< T > theta() const
bool getData(T &iHolder) const
std::unique_ptr< HEff4DHit > hEffWS[3][4]
C::const_iterator const_iterator
constant access iterator type
DTSegment4DQuality(const edm::ParameterSet &pset)
Constructor.
std::unique_ptr< HRes4DHit > h4DHit
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
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.
std::pair< const PSimHit *, const PSimHit * > findMuSimSegment(const std::map< DTWireId, const PSimHit * > &mapWireAndMuSimHit)
DTSuperLayerId superLayerId() const
The id of the superlayer on which reside the segment.
const DTSLRecSegment2D * zSegment() const
The Z segment: 0 if not zed projection available.
std::unique_ptr< HRes4DHit > h4DHit_W1
void fill(float simDirectionAlpha, float recDirectionAlpha, float simDirectionBeta, float recDirectionBeta, float simX, float recX, float simY, float recY, float simEta, float simPhi, float recYRZ, float simYRZ, float recBetaRZ, float simBetaRZ, float sigmaAlpha, float sigmaBeta, float sigmaX, float sigmaY, float sigmaBetaRZ, float sigmaYRZ, int nHitsPhi, int nHitsTheta, float t0Phi, float t0Theta)
T getParameter(std::string const &) const
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)
double t0() const
Get the segment t0 (if recomputed, 0 is returned otherwise)
int station() const
Return the station number.
edm::EDGetTokenT< edm::PSimHitContainer > simHitToken_
int wheel() const
Return the wheel number.
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return a DTSuperLayer given its id.
std::unique_ptr< HEff4DHit > hEff_W1