50 std::unique_ptr<HRes1DHit> hRes_S3RPhiWS[3][4];
51 std::unique_ptr<HRes1DHit> hRes_S3RZWS[3][4];
68 std::unique_ptr<HEff1DHit> hEff_S1RPhiWS[3][4];
69 std::unique_ptr<HEff1DHit> hEff_S3RPhiWS[3][4];
70 std::unique_ptr<HEff1DHit> hEff_S1RZWS[3][4];
71 std::unique_ptr<HEff1DHit> hEff_S3RZWS[3][4];
112 if (doall_ && doStep1_) {
113 histograms.
hRes_S1RPhi = std::make_unique<HRes1DHit>(
"S1RPhi", booker,
true, local_);
114 histograms.
hRes_S1RPhi_W0 = std::make_unique<HRes1DHit>(
"S1RPhi_W0", booker,
true, local_);
115 histograms.
hRes_S1RPhi_W1 = std::make_unique<HRes1DHit>(
"S1RPhi_W1", booker,
true, local_);
116 histograms.
hRes_S1RPhi_W2 = std::make_unique<HRes1DHit>(
"S1RPhi_W2", booker,
true, local_);
117 histograms.
hRes_S1RZ = std::make_unique<HRes1DHit>(
"S1RZ", booker,
true, local_);
118 histograms.
hRes_S1RZ_W0 = std::make_unique<HRes1DHit>(
"S1RZ_W0", booker,
true, local_);
119 histograms.
hRes_S1RZ_W1 = std::make_unique<HRes1DHit>(
"S1RZ_W1", booker,
true, local_);
120 histograms.
hRes_S1RZ_W2 = std::make_unique<HRes1DHit>(
"S1RZ_W2", booker,
true, local_);
121 histograms.
hEff_S1RPhi = std::make_unique<HEff1DHit>(
"S1RPhi", booker);
122 histograms.
hEff_S1RZ = std::make_unique<HEff1DHit>(
"S1RZ", booker);
123 histograms.
hEff_S1RZ_W0 = std::make_unique<HEff1DHit>(
"S1RZ_W0", booker);
124 histograms.
hEff_S1RZ_W1 = std::make_unique<HEff1DHit>(
"S1RZ_W1", booker);
125 histograms.
hEff_S1RZ_W2 = std::make_unique<HEff1DHit>(
"S1RZ_W2", booker);
127 if (doall_ && doStep2_) {
128 histograms.
hRes_S2RPhi = std::make_unique<HRes1DHit>(
"S2RPhi", booker,
true, local_);
129 histograms.
hRes_S2RPhi_W0 = std::make_unique<HRes1DHit>(
"S2RPhi_W0", booker,
true, local_);
130 histograms.
hRes_S2RPhi_W1 = std::make_unique<HRes1DHit>(
"S2RPhi_W1", booker,
true, local_);
131 histograms.
hRes_S2RPhi_W2 = std::make_unique<HRes1DHit>(
"S2RPhi_W2", booker,
true, local_);
132 histograms.
hRes_S2RZ = std::make_unique<HRes1DHit>(
"S2RZ", booker,
true, local_);
133 histograms.
hRes_S2RZ_W0 = std::make_unique<HRes1DHit>(
"S2RZ_W0", booker,
true, local_);
134 histograms.
hRes_S2RZ_W1 = std::make_unique<HRes1DHit>(
"S2RZ_W1", booker,
true, local_);
135 histograms.
hRes_S2RZ_W2 = std::make_unique<HRes1DHit>(
"S2RZ_W2", booker,
true, local_);
136 histograms.
hEff_S2RPhi = std::make_unique<HEff1DHit>(
"S2RPhi", booker);
137 histograms.
hEff_S2RZ_W0 = std::make_unique<HEff1DHit>(
"S2RZ_W0", booker);
138 histograms.
hEff_S2RZ_W1 = std::make_unique<HEff1DHit>(
"S2RZ_W1", booker);
139 histograms.
hEff_S2RZ_W2 = std::make_unique<HEff1DHit>(
"S2RZ_W2", booker);
140 histograms.
hEff_S2RZ = std::make_unique<HEff1DHit>(
"S2RZ", booker);
143 histograms.
hRes_S3RPhi = std::make_unique<HRes1DHit>(
"S3RPhi", booker, doall_, local_);
144 histograms.
hRes_S3RPhi_W0 = std::make_unique<HRes1DHit>(
"S3RPhi_W0", booker, doall_, local_);
145 histograms.
hRes_S3RPhi_W1 = std::make_unique<HRes1DHit>(
"S3RPhi_W1", booker, doall_, local_);
146 histograms.
hRes_S3RPhi_W2 = std::make_unique<HRes1DHit>(
"S3RPhi_W2", booker, doall_, local_);
147 histograms.
hRes_S3RZ = std::make_unique<HRes1DHit>(
"S3RZ", booker, doall_, local_);
148 histograms.
hRes_S3RZ_W0 = std::make_unique<HRes1DHit>(
"S3RZ_W0", booker, doall_, local_);
149 histograms.
hRes_S3RZ_W1 = std::make_unique<HRes1DHit>(
"S3RZ_W1", booker, doall_, local_);
150 histograms.
hRes_S3RZ_W2 = std::make_unique<HRes1DHit>(
"S3RZ_W2", booker, doall_, local_);
154 TString name1 =
"RPhi_W";
155 TString name2 =
"RZ_W";
156 for (
long w = 0;
w <= 2; ++
w) {
157 for (
long s = 1;
s <= 4; ++
s) {
158 histograms.
hRes_S3RPhiWS[
w][
s-1] = std::make_unique<HRes1DHit>((
"S3"+name1+
w+
"_St"+
s).Data(), booker, doall_, local_);
159 histograms.
hEff_S1RPhiWS[
w][
s-1] = std::make_unique<HEff1DHit>((
"S1"+name1+
w+
"_St"+
s).Data(), booker);
160 histograms.
hEff_S3RPhiWS[
w][
s-1] = std::make_unique<HEff1DHit>((
"S3"+name1+
w+
"_St"+
s).Data(), booker);
162 histograms.
hRes_S3RZWS[
w][
s-1] = std::make_unique<HRes1DHit>((
"S3"+name2+
w+
"_St"+
s).Data(), booker, doall_, local_);
163 histograms.
hEff_S1RZWS[
w][
s-1] = std::make_unique<HEff1DHit>((
"S1"+name2+
w+
"_St"+
s).Data(), booker);
164 histograms.
hEff_S3RZWS[
w][
s-1] = std::make_unique<HEff1DHit>((
"S3"+name2+
w+
"_St"+
s).Data(), booker);
171 histograms.
hEff_S3RPhi = std::make_unique<HEff1DHit>(
"S3RPhi", booker);
172 histograms.
hEff_S3RZ = std::make_unique<HEff1DHit>(
"S3RZ", booker);
173 histograms.
hEff_S3RZ_W0 = std::make_unique<HEff1DHit>(
"S3RZ_W0", booker);
174 histograms.
hEff_S3RZ_W1 = std::make_unique<HEff1DHit>(
"S3RZ_W1", booker);
175 histograms.
hEff_S3RZ_W2 = std::make_unique<HEff1DHit>(
"S3RZ_W2", booker);
183 cout <<
"--- [DTRecHitQuality] Analysing Event: #Run: " <<
event.id().run()
184 <<
" #Event: " <<
event.id().event() << endl;
193 event.getByToken(simHitToken_, simHits);
196 map<DTWireId, PSimHitContainer > simHitsPerWire =
201 if (doStep1_ && doall_) {
203 cout <<
" -- DTRecHit S1: begin analysis:" << endl;
207 event.getByToken(recHitToken_, dtRecHits);
210 if (debug_) {
cout <<
"[DTRecHitQuality]**Warning: no 1DRechits with label: " << recHitLabel_ <<
" in this event, skipping!" << endl;
216 auto const& recHitsPerWire = map1DRecHitsPerWire(dtRecHits.
product());
222 if (doStep2_ && doall_) {
224 cout <<
" -- DTRecHit S2: begin analysis:" << endl;
229 event.getByToken(segment2DToken_, segment2Ds);
233 cout <<
"[DTRecHitQuality]**Warning: no 2DSegments with label: " << segment2DLabel_
234 <<
" in this event, skipping!" << endl;
240 auto const& recHitsPerWire = map1DRecHitsPerWire(segment2Ds.
product());
249 cout <<
" -- DTRecHit S3: begin analysis:" << endl;
254 event.getByToken(segment4DToken_, segment4Ds);
257 if (debug_) {
cout <<
"[DTRecHitQuality]**Warning: no 4D Segments with label: " << segment4DLabel_
258 <<
" in this event, skipping!" << endl;
264 auto const& recHitsPerWire = map1DRecHitsPerWire(segment4Ds.
product());
270 map<DTWireId, vector<DTRecHit1DPair>>
272 map<DTWireId, vector<DTRecHit1DPair>> ret;
274 for (
const auto & dt1DRecHitPair : *dt1DRecHitPairs) {
275 ret[dt1DRecHitPair.wireId()].push_back(dt1DRecHitPair);
283 map<DTWireId, vector<DTRecHit1D>>
285 map<DTWireId, vector<DTRecHit1D>> ret;
288 for (
const auto & segment2D : *segment2Ds) {
289 vector<DTRecHit1D> component1DHits = segment2D.specificRecHits();
291 for (
auto & component1DHit : component1DHits) {
292 ret[component1DHit.wireId()].push_back(component1DHit);
299 map<DTWireId, std::vector<DTRecHit1D>>
301 map<DTWireId, vector<DTRecHit1D>> ret;
303 for (
const auto & segment4D : *segment4Ds) {
305 vector<const TrackingRecHit*> segment2Ds = segment4D.recHits();
307 for (
auto & segment2D : segment2Ds) {
309 vector<const TrackingRecHit*>
hits = segment2D->recHits();
311 for (
auto &
hit : hits) {
313 ret[hit1D->wireId()].push_back(*hit1D);
328 float xEntry = entryP.
x() - xwire;
329 float xExit = exitP.
x() - xwire;
331 return fabs(xEntry - (entryP.
z()*(xExit-xEntry))/(exitP.
z()-entryP.
z()));
340 float theta =(exitP.
x()-entryP.
x())/(exitP.
z()-entryP.
z());
354 return (entryP.
y()+exitP.
y())/2.+wireLenght;
359 template <
typename type>
363 const vector<type>& recHits,
364 const float simHitDist)
const {
366 const type* theBestRecHit =
nullptr;
368 for (
auto recHit = recHits.begin();
371 float distTmp = recHitDistFromWire(*
recHit, layer);
372 if (fabs(distTmp-simHitDist) < res) {
373 res = fabs(distTmp-simHitDist);
374 theBestRecHit = &(*recHit);
378 return theBestRecHit;
399 template <
typename type>
405 for (
const auto & wireAndSHits : simHitsPerWire) {
406 DTWireId wireId = wireAndSHits.first;
410 vector<PSimHit> simHitsInCell = wireAndSHits.second;
417 if (muSimHit ==
nullptr) {
419 cout <<
" No mu SimHit in channel: " << wireId <<
", skipping! " << endl;
425 float simHitWireDist = simHitDistFromWire(layer, wireId, *muSimHit);
427 if (simHitWireDist>2.1) {
429 cout <<
" [DTRecHitQuality]###Warning: The mu SimHit in out of the cell, skipping!" << endl;
436 float simHitTheta = simHitImpactAngle(layer, wireId, *muSimHit);
439 float simHitFEDist = simHitDistFromFE(layer, wireId, *muSimHit);
441 bool recHitReconstructed =
false;
444 if (recHitsPerWire.find(wireId) == recHitsPerWire.end()) {
447 cout <<
" No RecHit found at Step: " << step <<
" in cell: " << wireId << endl;
450 recHitReconstructed =
true;
452 const vector<type>& recHits = recHitsPerWire.at(wireId);
454 cout <<
" " << recHits.size() <<
" RecHits, Step " << step <<
" in channel: " << wireId << endl;
458 const type* theBestRecHit = findBestRecHit(layer, wireId, recHits, simHitWireDist);
461 float recHitWireDist = recHitDistFromWire(*theBestRecHit, layer);
463 cout <<
" SimHit distance from wire: " << simHitWireDist << endl
464 <<
" SimHit distance from FE: " << simHitFEDist << endl
465 <<
" SimHit angle in layer RF: " << simHitTheta << endl
466 <<
" RecHit distance from wire: " << recHitWireDist << endl;
468 float recHitErr = recHitPositionError(*theBestRecHit);
473 if (mirrorMinusWheels && wheel<0 && sl!= 2) {
487 if (
abs(wheel) == 1) {
490 if (
abs(wheel) == 2) {
498 if (
abs(wheel) == 1) {
501 if (
abs(wheel) == 2) {
506 }
else if (step == 2) {
513 if (
abs(wheel) == 1) {
516 if (
abs(wheel) == 2) {
524 if (
abs(wheel) == 1) {
527 if (
abs(wheel) == 2) {
532 }
else if (step == 3) {
539 if (
abs(wheel) == 1) {
542 if (
abs(wheel) == 2) {
546 histograms.
hRes_S3RPhiWS[
abs(wheel)][wireId.
station()-1]->fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitErr, wireId.
station());
553 if (
abs(wheel) == 1) {
556 if (
abs(wheel) == 2) {
560 histograms.
hRes_S3RZWS[
abs(wheel)][wireId.
station()-1]->fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitErr, wireId.
station());
566 hRes->
fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.
eta(),
567 simHitGlobalPos.
phi(), recHitErr, wireId.
station());
568 if (hResTot !=
nullptr) {
569 hResTot->
fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.
eta(),
570 simHitGlobalPos.
phi(), recHitErr, wireId.
station());
582 if (local_) { histograms.
hEff_S1RPhiWS[
abs(wheel)][wireId.
station()-1]->fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
589 if (
abs(wheel) == 1) {
592 if (
abs(wheel) == 2) {
595 if (local_) { histograms.
hEff_S1RZWS[
abs(wheel)][wireId.
station()-1]->fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
599 }
else if (step == 2) {
608 if (
abs(wheel) == 1) {
611 if (
abs(wheel) == 2) {
616 }
else if (step == 3) {
620 if (local_) { histograms.
hEff_S3RPhiWS[
abs(wheel)][wireId.
station()-1]->fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
627 if (
abs(wheel) == 1) {
630 if (
abs(wheel) == 2) {
633 if (local_) { histograms.
hEff_S3RZWS[
abs(wheel)][wireId.
station()-1]->fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
639 hEff->
fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
640 if (hEffTot !=
nullptr) {
641 hEffTot->
fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
LocalPoint localPosition() const override
Return the 3-dimensional local position.
T getUntrackedParameter(std::string const &, T const &) const
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
std::unique_ptr< HRes1DHit > hRes_S3RPhi_W0
std::unique_ptr< HRes1DHit > hRes_S2RZ_W2
std::unique_ptr< HRes1DHit > hRes_S1RPhi
std::unique_ptr< HRes1DHit > hRes_S3RPhi_W2
std::unique_ptr< HRes1DHit > hRes_S3RPhiWS[3][4]
LocalError localPositionError() const override
#define DEFINE_FWK_MODULE(type)
LocalError localPositionError() const override
Return the 3-dimensional error on the local position.
std::unique_ptr< HRes1DHit > hRes_S2RZ
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
std::unique_ptr< HEff1DHit > hEff_S3RPhi
A set of histograms fo efficiency computation for 1D RecHits (producer)
std::unique_ptr< HEff1DHit > hEff_S3RZ
std::unique_ptr< HRes1DHit > hRes_S2RPhi_W1
void compute(const DTGeometry *dtGeom, const std::map< DTWireId, std::vector< PSimHit >> &simHitsPerWire, const std::map< DTWireId, std::vector< type >> &recHitsPerWire, dtrechit::Histograms const &histograms, int step) const
float simHitImpactAngle(const DTLayer *layer, const DTWireId &wireId, const PSimHit &hit) const
Geom::Phi< T > phi() const
Geom::Theta< T > theta() const
std::unique_ptr< HRes1DHit > hRes_S1RPhi_W0
def setup(process, global_tag, zero_tesla=False)
std::unique_ptr< HRes1DHit > hRes_S3RZ_W2
std::unique_ptr< HEff1DHit > hEff_S3RZ_W1
std::unique_ptr< HEff1DHit > hEff_S2RZ_W1
std::unique_ptr< HRes1DHit > hRes_S1RPhi_W1
std::unique_ptr< HRes1DHit > hRes_S3RZWS[3][4]
std::unique_ptr< HRes1DHit > hRes_S1RZ
std::map< DTWireId, std::vector< DTRecHit1DPair > > map1DRecHitsPerWire(const DTRecHitCollection *dt1DRecHitPairs) const
std::unique_ptr< HRes1DHit > hRes_S2RPhi_W2
const DTTopology & specificTopology() const
Local3DPoint exitPoint() const
Exit point in the local Det frame.
void fill(float distSimHit, float thetaSimHit, float distFESimHit, float distRecHit, float etaSimHit, float phiSimHit, float errRecHit, int station)
DTRecHitQuality(const edm::ParameterSet &pset)
Constructor.
std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
std::unique_ptr< HRes1DHit > hRes_S1RZ_W2
Local3DPoint localPosition() const
std::unique_ptr< HEff1DHit > hEff_S1RZ_W2
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, dtrechit::Histograms const &) const override
Perform the real analysis.
std::unique_ptr< HRes1DHit > hRes_S3RZ_W1
std::unique_ptr< HRes1DHit > hRes_S3RZ
Abs< T >::type abs(const T &t)
int superLayer() const
Return the superlayer number.
float simHitDistFromWire(const DTLayer *layer, const DTWireId &wireId, const PSimHit &hit) const
float recHitDistFromWire(const DTRecHit1DPair &hitPair, const DTLayer *layer) const
const type * findBestRecHit(const DTLayer *layer, const DTWireId &wireId, const std::vector< type > &recHits, float simHitDist) const
const PSimHit * findMuSimHit(const edm::PSimHitContainer &hits)
Select the SimHit from a muon in a vector of SimHits.
A set of histograms of residuals and pulls for 1D RecHits.
std::unique_ptr< HEff1DHit > hEff_S1RPhiWS[3][4]
std::unique_ptr< HRes1DHit > hRes_S3RPhi
std::unique_ptr< HEff1DHit > hEff_S3RZWS[3][4]
std::unique_ptr< HEff1DHit > hEff_S1RZ_W1
std::unique_ptr< HEff1DHit > hEff_S1RZ_W0
std::unique_ptr< HRes1DHit > hRes_S2RPhi
int wire() const
Return the wire number.
T const * product() const
std::unique_ptr< HEff1DHit > hEff_S1RZWS[3][4]
std::unique_ptr< HEff1DHit > hEff_S2RPhi
std::unique_ptr< HRes1DHit > hRes_S1RPhi_W2
std::unique_ptr< HRes1DHit > hRes_S2RZ_W1
std::unique_ptr< HRes1DHit > hRes_S2RPhi_W0
void bookHistograms(DQMStore::ConcurrentBooker &, edm::Run const &, edm::EventSetup const &, dtrechit::Histograms &) const override
Book the DQM plots.
std::unique_ptr< HRes1DHit > hRes_S1RZ_W0
std::unique_ptr< HEff1DHit > hEff_S1RZ
std::unique_ptr< HEff1DHit > hEff_S3RPhiWS[3][4]
std::unique_ptr< HRes1DHit > hRes_S3RZ_W0
void fill(float distSimHit, float etaSimHit, float phiSimHit, bool fillRecHit)
LocalPoint localPosition() const override
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
std::unique_ptr< HRes1DHit > hRes_S1RZ_W1
int station() const
Return the station number.
std::unique_ptr< HEff1DHit > hEff_S2RZ_W0
int wheel() const
Return the wheel number.
T const * product() const
Local3DPoint entryPoint() const
Entry point in the local Det frame.
float recHitPositionError(const DTRecHit1DPair &recHit) const
std::unique_ptr< HEff1DHit > hEff_S3RZ_W2
std::unique_ptr< HEff1DHit > hEff_S1RPhi
std::unique_ptr< HRes1DHit > hRes_S3RPhi_W1
std::unique_ptr< HEff1DHit > hEff_S2RZ_W2
std::unique_ptr< HEff1DHit > hEff_S2RZ
std::unique_ptr< HRes1DHit > hRes_S2RZ_W0
std::unique_ptr< HEff1DHit > hEff_S3RZ_W0
float simHitDistFromFE(const DTLayer *layer, const DTWireId &wireId, const PSimHit &hit) const
DTWireId wireId() const
Return the wireId.