40 bool mirrorMinusWheels =
true;
126 TString name1=
"RPhi_W";
127 TString name2=
"RZ_W";
128 for (
long w=0;
w<=2;++
w) {
129 for (
long s=1;
s<=4;++
s){
168 hEff_S1RPhi->ComputeEfficiency();
169 hEff_S1RZ->ComputeEfficiency();
170 hEff_S1RZ_W0->ComputeEfficiency();
171 hEff_S1RZ_W1->ComputeEfficiency();
172 hEff_S1RZ_W2->ComputeEfficiency();
175 hEff_S2RPhi->ComputeEfficiency();
176 hEff_S2RZ->ComputeEfficiency();
177 hEff_S2RZ_W0->ComputeEfficiency();
178 hEff_S2RZ_W1->ComputeEfficiency();
179 hEff_S2RZ_W2->ComputeEfficiency();
182 hEff_S3RPhi->ComputeEfficiency();
183 hEff_S3RZ->ComputeEfficiency();
184 hEff_S3RZ_W0->ComputeEfficiency();
185 hEff_S3RZ_W1->ComputeEfficiency();
186 hEff_S3RZ_W2->ComputeEfficiency();
194 cout <<
"--- [DTRecHitQuality] Analysing Event: #Run: " <<
event.id().run()
195 <<
" #Event: " <<
event.id().event() << endl;
203 event.getByToken(simHitToken_, simHits);
206 map<DTWireId, PSimHitContainer > simHitsPerWire =
215 cout <<
" -- DTRecHit S1: begin analysis:" << endl;
218 event.getByToken(recHitToken_, dtRecHits);
221 if(
debug)
cout <<
"[DTRecHitQuality]**Warning: no 1DRechits with label: " <<
recHitLabel <<
" in this event, skipping!" << endl;
226 map<DTWireId,vector<DTRecHit1DPair> > recHitsPerWire =
227 map1DRecHitsPerWire(dtRecHits.
product());
237 cout <<
" -- DTRecHit S2: begin analysis:" << endl;
241 event.getByToken(segment2DToken_, segment2Ds);
245 <<
" in this event, skipping!" << endl;
250 map<DTWireId,vector<DTRecHit1D> > recHitsPerWire =
251 map1DRecHitsPerWire(segment2Ds.
product());
261 cout <<
" -- DTRecHit S3: begin analysis:" << endl;
265 event.getByToken(segment4DToken_, segment4Ds);
269 <<
" in this event, skipping!" << endl;
274 map<DTWireId,vector<DTRecHit1D> > recHitsPerWire =
275 map1DRecHitsPerWire(segment4Ds.
product());
285 map<DTWireId, vector<DTRecHit1DPair> >
287 map<DTWireId, vector<DTRecHit1DPair> > ret;
290 rechit != dt1DRecHitPairs->end(); rechit++) {
291 ret[(*rechit).wireId()].push_back(*rechit);
299 map<DTWireId, vector<DTRecHit1D> >
301 map<DTWireId, vector<DTRecHit1D> > ret;
305 segment != segment2Ds->end();
307 vector<DTRecHit1D> component1DHits= (*segment).specificRecHits();
309 for(vector<DTRecHit1D>::const_iterator
hit = component1DHits.begin();
310 hit != component1DHits.end();
312 ret[(*hit).wireId()].push_back(*
hit);
321 map<DTWireId, std::vector<DTRecHit1D> >
323 map<DTWireId, vector<DTRecHit1D> > ret;
326 segment != segment4Ds->end();
329 vector<const TrackingRecHit*> segment2Ds = (*segment).recHits();
331 for(vector<const TrackingRecHit*>::const_iterator segment2D = segment2Ds.begin();
332 segment2D != segment2Ds.end();
335 vector<const TrackingRecHit*>
hits = (*segment2D)->recHits();
337 for(vector<const TrackingRecHit*>::const_iterator
hit = hits.begin();
338 hit != hits.end();
hit++) {
340 ret[hit1D->
wireId()].push_back(*hit1D);
355 float xEntry = entryP.
x()-xwire;
356 float xExit = exitP.
x()-xwire;
358 return fabs(xEntry - (entryP.
z()*(xExit-xEntry))/(exitP.
z()-entryP.
z()));
367 float theta=(exitP.
x()-entryP.
x())/(exitP.
z()-entryP.
z());
381 return (entryP.
y()+exitP.
y())/2.+wireLenght;
386 template <
typename type>
390 const vector<type>& recHits,
391 const float simHitDist) {
393 const type* theBestRecHit = 0;
395 for(
typename vector<type>::const_iterator
recHit = recHits.begin();
398 float distTmp = recHitDistFromWire(*
recHit, layer);
399 if(fabs(distTmp-simHitDist) < res) {
400 res = fabs(distTmp-simHitDist);
401 theBestRecHit = &(*recHit);
405 return theBestRecHit;
426 template <
typename type>
432 for(
map<
DTWireId, vector<PSimHit> >::const_iterator wireAndSHits = simHitsPerWire.begin();
433 wireAndSHits != simHitsPerWire.end();
435 DTWireId wireId = (*wireAndSHits).first;
439 vector<PSimHit> simHitsInCell = (*wireAndSHits).second;
448 cout <<
" No mu SimHit in channel: " << wireId <<
", skipping! " << endl;
453 float simHitWireDist = simHitDistFromWire(layer, wireId, *muSimHit);
455 if(simHitWireDist>2.1) {
457 cout <<
" [DTRecHitQuality]###Warning: The mu SimHit in out of the cell, skipping!" << endl;
463 float simHitTheta = simHitImpactAngle(layer, wireId, *muSimHit);
466 float simHitFEDist = simHitDistFromFE(layer, wireId, *muSimHit);
468 bool recHitReconstructed =
false;
471 if(recHitsPerWire.find(wireId) == recHitsPerWire.end()) {
474 cout <<
" No RecHit found at Step: " << step <<
" in cell: " << wireId << endl;
476 recHitReconstructed =
true;
478 vector<type> recHits = recHitsPerWire.at(wireId);
480 cout <<
" " << recHits.size() <<
" RecHits, Step " << step <<
" in channel: " << wireId << endl;
483 const type* theBestRecHit = findBestRecHit(layer, wireId, recHits, simHitWireDist);
486 float recHitWireDist = recHitDistFromWire(*theBestRecHit, layer);
488 cout <<
" SimHit distance from wire: " << simHitWireDist << endl
489 <<
" SimHit distance from FE: " << simHitFEDist << endl
490 <<
" SimHit angle in layer RF: " << simHitTheta << endl
491 <<
" RecHit distance from wire: " << recHitWireDist << endl;
492 float recHitErr = recHitPositionError(*theBestRecHit);
497 if (mirrorMinusWheels && wheel<0 && sl!=2){
507 hResTot = hRes_S1RPhi;
509 hRes = hRes_S1RPhi_W0;
511 hRes = hRes_S1RPhi_W1;
513 hRes = hRes_S1RPhi_W2;
524 }
else if(step == 2) {
529 hRes = hRes_S2RPhi_W0;
531 hRes = hRes_S2RPhi_W1;
533 hRes = hRes_S2RPhi_W2;
544 }
else if(step == 3) {
547 hResTot = hRes_S3RPhi;
549 hRes = hRes_S3RPhi_W0;
551 hRes = hRes_S3RPhi_W1;
553 hRes = hRes_S3RPhi_W2;
554 if (
local) hRes_S3RPhiWS[
abs(wheel)][wireId.
station()-1]->
Fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.
eta(),simHitGlobalPos.
phi(),recHitErr,wireId.
station());
565 if (
local) hRes_S3RZWS[
abs(wheel)][wireId.
station()-1]->
Fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.
eta(),simHitGlobalPos.
phi(),recHitErr,wireId.
station());
569 hRes->
Fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.
eta(),
570 simHitGlobalPos.
phi(),recHitErr,wireId.
station());
572 hResTot->
Fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.
eta(),
573 simHitGlobalPos.
phi(),recHitErr,wireId.
station());
584 if (
local) hEff_S1RPhiWS[
abs(wheel)][wireId.
station()-1]->
Fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
593 if (
local) hEff_S1RZWS[
abs(wheel)][wireId.
station()-1]->
Fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
596 }
else if(step == 2) {
610 }
else if(step == 3) {
614 if (
local) hEff_S3RPhiWS[
abs(wheel)][wireId.
station()-1]->
Fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
623 if (
local) hEff_S3RZWS[
abs(wheel)][wireId.
station()-1]->
Fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
628 hEff->
Fill(simHitWireDist, simHitGlobalPos.
eta(), simHitGlobalPos.
phi(), recHitReconstructed);
630 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.
void Fill(float distSimHit, float etaSimHit, float phiSimHit, bool fillRecHit)
LocalError localPositionError() const override
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.
Geom::Phi< T > phi() const
void Fill(float distSimHit, float thetaSimHit, float distFESimHit, float distRecHit, float etaSimHit, float phiSimHit, float errRecHit, int station)
Geom::Theta< T > theta() const
static const PSimHit * findMuSimHit(const edm::PSimHitContainer &hits)
Select the SimHit from a muon in a vector of SimHits.
void compute(const DTGeometry *dtGeom, const std::map< DTWireId, std::vector< PSimHit > > &simHitsPerWire, const std::map< DTWireId, std::vector< type > > &recHitsPerWire, int step)
const type * findBestRecHit(const DTLayer *layer, DTWireId wireId, const std::vector< type > &recHits, const float simHitDist)
def setup(process, global_tag, zero_tesla=False)
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup)
Perform the real analysis.
virtual ~DTRecHitQuality()
Destructor.
float recHitPositionError(const DTRecHit1DPair &recHit)
const DTTopology & specificTopology() const
Local3DPoint exitPoint() const
Exit point in the local Det frame.
float simHitDistFromWire(const DTLayer *layer, DTWireId wireId, const PSimHit &hit)
DTRecHitQuality(const edm::ParameterSet &pset)
Constructor.
Local3DPoint localPosition() const
float recHitDistFromWire(const DTRecHit1DPair &hitPair, const DTLayer *layer)
Abs< T >::type abs(const T &t)
int superLayer() const
Return the superlayer number.
std::map< DTWireId, std::vector< DTRecHit1DPair > > map1DRecHitsPerWire(const DTRecHitCollection *dt1DRecHitPairs)
A set of histograms of residuals and pulls for 1D RecHits.
float simHitImpactAngle(const DTLayer *layer, DTWireId wireId, const PSimHit &hit)
int wire() const
Return the wire number.
float simHitDistFromFE(const DTLayer *layer, DTWireId wireId, const PSimHit &hit)
T const * product() const
virtual void beginRun(const edm::Run &iRun, const edm::EventSetup &setup)
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)
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.
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
DTWireId wireId() const
Return the wireId.