81 bool mirrorMinusWheels =
true;
109 if (doall_ && doStep1_) {
124 if (doall_ && doStep2_) {
151 TString name1 =
"RPhi_W";
152 TString name2 =
"RZ_W";
153 for (
long w = 0;
w <= 2; ++
w) {
154 for (
long s = 1;
s <= 4; ++
s) {
180 cout <<
"--- [DTRecHitQuality] Analysing Event: #Run: " <<
event.id().run()
181 <<
" #Event: " <<
event.id().event() << endl;
190 event.getByToken(simHitToken_, simHits);
193 map<DTWireId, PSimHitContainer > simHitsPerWire =
198 if (doStep1_ && doall_) {
200 cout <<
" -- DTRecHit S1: begin analysis:" << endl;
204 event.getByToken(recHitToken_, dtRecHits);
207 if (debug_) {
cout <<
"[DTRecHitQuality]**Warning: no 1DRechits with label: " << recHitLabel_ <<
" in this event, skipping!" << endl;
213 auto const& recHitsPerWire = map1DRecHitsPerWire(dtRecHits.
product());
219 if (doStep2_ && doall_) {
221 cout <<
" -- DTRecHit S2: begin analysis:" << endl;
226 event.getByToken(segment2DToken_, segment2Ds);
230 cout <<
"[DTRecHitQuality]**Warning: no 2DSegments with label: " << segment2DLabel_
231 <<
" in this event, skipping!" << endl;
237 auto const& recHitsPerWire = map1DRecHitsPerWire(segment2Ds.
product());
246 cout <<
" -- DTRecHit S3: begin analysis:" << endl;
251 event.getByToken(segment4DToken_, segment4Ds);
254 if (debug_) {
cout <<
"[DTRecHitQuality]**Warning: no 4D Segments with label: " << segment4DLabel_
255 <<
" in this event, skipping!" << endl;
261 auto const& recHitsPerWire = map1DRecHitsPerWire(segment4Ds.
product());
267 map<DTWireId, vector<DTRecHit1DPair>>
269 map<DTWireId, vector<DTRecHit1DPair>> ret;
271 for (
const auto & dt1DRecHitPair : *dt1DRecHitPairs) {
272 ret[dt1DRecHitPair.wireId()].push_back(dt1DRecHitPair);
280 map<DTWireId, vector<DTRecHit1D>>
282 map<DTWireId, vector<DTRecHit1D>> ret;
285 for (
const auto & segment2D : *segment2Ds) {
286 vector<DTRecHit1D> component1DHits = segment2D.specificRecHits();
288 for (
auto & component1DHit : component1DHits) {
289 ret[component1DHit.wireId()].push_back(component1DHit);
296 map<DTWireId, std::vector<DTRecHit1D>>
298 map<DTWireId, vector<DTRecHit1D>> ret;
300 for (
const auto & segment4D : *segment4Ds) {
302 vector<const TrackingRecHit*> segment2Ds = segment4D.recHits();
304 for (
auto & segment2D : segment2Ds) {
306 vector<const TrackingRecHit*>
hits = segment2D->recHits();
308 for (
auto &
hit : hits) {
310 ret[hit1D->wireId()].push_back(*hit1D);
325 float xEntry = entryP.
x() - xwire;
326 float xExit = exitP.
x() - xwire;
328 return fabs(xEntry - (entryP.
z()*(xExit-xEntry))/(exitP.
z()-entryP.
z()));
337 float theta =(exitP.
x()-entryP.
x())/(exitP.
z()-entryP.
z());
351 return (entryP.
y()+exitP.
y())/2.+wireLenght;
356 template <
typename type>
360 const vector<type>& recHits,
361 const float simHitDist)
const {
363 const type* theBestRecHit =
nullptr;
365 for (
auto recHit = recHits.begin();
368 float distTmp = recHitDistFromWire(*
recHit, layer);
369 if (fabs(distTmp-simHitDist) < res) {
370 res = fabs(distTmp-simHitDist);
371 theBestRecHit = &(*recHit);
375 return theBestRecHit;
396 template <
typename type>
402 for (
const auto & wireAndSHits : simHitsPerWire) {
403 DTWireId wireId = wireAndSHits.first;
407 vector<PSimHit> simHitsInCell = wireAndSHits.second;
414 if (muSimHit ==
nullptr) {
416 cout <<
" No mu SimHit in channel: " << wireId <<
", skipping! " << endl;
422 float simHitWireDist = simHitDistFromWire(layer, wireId, *muSimHit);
424 if (simHitWireDist>2.1) {
426 cout <<
" [DTRecHitQuality]###Warning: The mu SimHit in out of the cell, skipping!" << endl;
433 float simHitTheta = simHitImpactAngle(layer, wireId, *muSimHit);
436 float simHitFEDist = simHitDistFromFE(layer, wireId, *muSimHit);
438 bool recHitReconstructed =
false;
441 if (recHitsPerWire.find(wireId) == recHitsPerWire.end()) {
444 cout <<
" No RecHit found at Step: " << step <<
" in cell: " << wireId << endl;
447 recHitReconstructed =
true;
449 const vector<type>& recHits = recHitsPerWire.at(wireId);
451 cout <<
" " << recHits.size() <<
" RecHits, Step " << step <<
" in channel: " << wireId << endl;
455 const type* theBestRecHit = findBestRecHit(layer, wireId, recHits, simHitWireDist);
458 float recHitWireDist = recHitDistFromWire(*theBestRecHit, layer);
460 cout <<
" SimHit distance from wire: " << simHitWireDist << endl
461 <<
" SimHit distance from FE: " << simHitFEDist << endl
462 <<
" SimHit angle in layer RF: " << simHitTheta << endl
463 <<
" RecHit distance from wire: " << recHitWireDist << endl;
465 float recHitErr = recHitPositionError(*theBestRecHit);
470 if (mirrorMinusWheels && wheel<0 && sl!= 2) {
484 if (
abs(wheel) == 1) {
487 if (
abs(wheel) == 2) {
495 if (
abs(wheel) == 1) {
498 if (
abs(wheel) == 2) {
503 }
else if (step == 2) {
510 if (
abs(wheel) == 1) {
513 if (
abs(wheel) == 2) {
521 if (
abs(wheel) == 1) {
524 if (
abs(wheel) == 2) {
529 }
else if (step == 3) {
536 if (
abs(wheel) == 1) {
539 if (
abs(wheel) == 2) {
543 histograms.
hRes_S3RPhiWS[
abs(wheel)][wireId.
station()-1]->
fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitErr, wireId.
station());
550 if (
abs(wheel) == 1) {
553 if (
abs(wheel) == 2) {
557 histograms.
hRes_S3RZWS[
abs(wheel)][wireId.
station()-1]->
fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitErr, wireId.
station());
563 hRes->
fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.
eta(),
564 simHitGlobalPos.
phi(), recHitErr, wireId.
station());
565 if (hResTot !=
nullptr) {
566 hResTot->
fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.
eta(),
567 simHitGlobalPos.
phi(), recHitErr, wireId.
station());
586 if (
abs(wheel) == 1) {
589 if (
abs(wheel) == 2) {
592 if (local_) { histograms.
hEff_S1RZWS[
abs(wheel)][wireId.
station()-1]->
fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
596 }
else if (step == 2) {
605 if (
abs(wheel) == 1) {
608 if (
abs(wheel) == 2) {
613 }
else if (step == 3) {
624 if (
abs(wheel) == 1) {
627 if (
abs(wheel) == 2) {
630 if (local_) { histograms.
hEff_S3RZWS[
abs(wheel)][wireId.
station()-1]->
fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
636 hEff->
fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
637 if (hEffTot !=
nullptr) {
638 hEffTot->
fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
LocalPoint localPosition() const override
Return the 3-dimensional local position.
HRes1DHit * hRes_S2RPhi_W1
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.
HEff1DHit * hEff_S1RPhiWS[3][4]
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, Histograms const &) const override
Perform the real analysis.
LocalError localPositionError() const override
#define DEFINE_FWK_MODULE(type)
LocalError localPositionError() const override
Return the 3-dimensional error on the local position.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
HRes1DHit * hRes_S1RPhi_W1
A set of histograms fo efficiency computation for 1D RecHits (producer)
float simHitImpactAngle(const DTLayer *layer, const DTWireId &wireId, const PSimHit &hit) const
Geom::Phi< T > phi() const
Geom::Theta< T > theta() const
static const PSimHit * findMuSimHit(const edm::PSimHitContainer &hits)
Select the SimHit from a muon in a vector of SimHits.
HRes1DHit * hRes_S1RPhi_W0
def setup(process, global_tag, zero_tesla=False)
HRes1DHit * hRes_S2RPhi_W0
HRes1DHit * hRes_S2RPhi_W2
std::map< DTWireId, std::vector< DTRecHit1DPair > > map1DRecHitsPerWire(const DTRecHitCollection *dt1DRecHitPairs) const
HEff1DHit * hEff_S1RZWS[3][4]
const DTTopology & specificTopology() const
Local3DPoint exitPoint() const
Exit point in the local Det frame.
HEff1DHit * hEff_S3RZWS[3][4]
void fill(float distSimHit, float thetaSimHit, float distFESimHit, float distRecHit, float etaSimHit, float phiSimHit, float errRecHit, int station)
DTRecHitQuality(const edm::ParameterSet &pset)
Constructor.
Local3DPoint localPosition() const
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
A set of histograms of residuals and pulls for 1D RecHits.
int wire() const
Return the wire number.
T const * product() const
HEff1DHit * hEff_S3RPhiWS[3][4]
void bookHistograms(DQMStore::ConcurrentBooker &, edm::Run const &, edm::EventSetup const &, Histograms &) const override
Book the DQM plots.
HRes1DHit * hRes_S3RPhi_W1
void compute(const DTGeometry *dtGeom, const std::map< DTWireId, std::vector< PSimHit >> &simHitsPerWire, const std::map< DTWireId, std::vector< type >> &recHitsPerWire, Histograms const &histograms, int step) const
void fill(float distSimHit, float etaSimHit, float phiSimHit, bool fillRecHit)
HRes1DHit * hRes_S1RPhi_W2
LocalPoint localPosition() const override
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
static std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
HRes1DHit * hRes_S3RPhi_W0
HRes1DHit * hRes_S3RZWS[3][4]
int station() const
Return the station number.
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
HRes1DHit * hRes_S3RPhiWS[3][4]
HRes1DHit * hRes_S3RPhi_W2
float simHitDistFromFE(const DTLayer *layer, const DTWireId &wireId, const PSimHit &hit) const
DTWireId wireId() const
Return the wireId.