54 cout <<
"[DTSegment2DQuality] Constructor called " << endl;
86 cout <<
"[DTSegment2DQuality] hitsos created " << endl;
104 h2DHitEff_RPhi->ComputeEfficiency();
105 h2DHitEff_RZ->ComputeEfficiency();
106 h2DHitEff_RZ_W0->ComputeEfficiency();
107 h2DHitEff_RZ_W1->ComputeEfficiency();
108 h2DHitEff_RZ_W2->ComputeEfficiency();
130 event.getByToken(simHitToken_, simHits);
133 map<DTSuperLayerId, PSimHitContainer > simHitsPerSl;
134 for(PSimHitContainer::const_iterator
simHit = simHits->begin();
139 simHitsPerSl[slId].push_back(*
simHit);
144 event.getByToken(segment2DToken_, segment2Ds);
148 <<
" in this event, skipping!" << endl;
153 DTRecSegment2DCollection::id_iterator slId;
154 for (slId = segment2Ds->id_begin();
155 slId != segment2Ds->id_end();
165 int nMuSimHit = muSimHitPerWire.size();
166 if(nMuSimHit == 0 || nMuSimHit == 1) {
167 if(
debug && nMuSimHit == 1)
168 cout <<
"[DTSegment2DQuality] Only " << nMuSimHit <<
" mu SimHit in this SL, skipping!" << endl;
172 cout <<
"=== SL " << (*slId) <<
" has " << nMuSimHit <<
" SimHits" << endl;
177 if(inAndOutSimHit.first ==inAndOutSimHit.second ) {
178 cout <<
"[DTHitQualityUtils]***Warning: outermost and innermost SimHit are the same!" << endl;
186 LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
187 LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
189 cout<<
" Simulated segment: local direction "<<simSegmLocalDir<<endl
190 <<
" local position "<<simSegmLocalPos<<endl;
196 float posSimSeg = simSegmLocalPos.
x();
198 float etaSimSeg = simSegmGlobalPos.
eta();
199 float phiSimSeg = simSegmGlobalPos.
phi();
204 bool recHitFound =
false;
206 int nsegm =
distance(range.first, range.second);
208 cout <<
" Sl: " << *slId <<
" has " << nsegm
209 <<
" 2D segments" << endl;
218 bool bestRecHitFound =
false;
219 double deltaAlpha = 99999;
223 segment2D!=range.second;
226 if((*segment2D).dimension() != 2) {
227 if(
debug)
cout <<
"[DTSegment2DQuality]***Error: This is not 2D segment!!!" << endl;
231 LocalVector recSegDirection = (*segment2D).localDirection();
232 LocalPoint recSegPosition = (*segment2D).localPosition();
236 cout <<
" RecSegment direction: " << recSegDirection << endl
237 <<
" position : " << recSegPosition << endl
238 <<
" alpha : " << recSegAlpha << endl;
240 if(fabs(recSegAlpha - angleSimSeg) < deltaAlpha) {
241 deltaAlpha = fabs(recSegAlpha - angleSimSeg);
242 bestRecHit = &(*segment2D);
243 bestRecHitFound =
true;
247 if(bestRecHitFound) {
258 fabs(bestRecHitLocalPos.
x() - posSimSeg) < 5*
sigmaResPos) {
264 if((*slId).superlayer() == 1 || (*slId).superlayer() == 3) {
266 }
else if((*slId).superlayer() == 2) {
267 h2DHitRZ->
Fill(angleSimSeg,
270 bestRecHitLocalPos.
x(),
273 sqrt(bestRecHitLocalPosErr.
xx()),
274 sqrt(bestRecHitLocalDirErr.
xx())
276 if(
abs((*slId).wheel()) == 0)
278 else if(
abs((*slId).wheel()) == 1)
280 else if(
abs((*slId).wheel()) == 2)
283 hRes->
Fill(angleSimSeg,
286 bestRecHitLocalPos.
x(),
289 sqrt(bestRecHitLocalPosErr.
xx()),
290 sqrt(bestRecHitLocalDirErr.
xx())
297 if((*slId).superlayer() == 1 || (*slId).superlayer() == 3) {
298 hEff = h2DHitEff_RPhi;
299 }
else if((*slId).superlayer() == 2) {
300 h2DHitEff_RZ->
Fill(etaSimSeg, phiSimSeg, posSimSeg, angleSimSeg, recHitFound);
301 if(
abs((*slId).wheel()) == 0)
302 hEff = h2DHitEff_RZ_W0;
303 else if(
abs((*slId).wheel()) == 1)
304 hEff = h2DHitEff_RZ_W1;
305 else if(
abs((*slId).wheel()) == 2)
306 hEff = h2DHitEff_RZ_W2;
308 hEff->
Fill(etaSimSeg, phiSimSeg, posSimSeg, angleSimSeg, recHitFound);
LocalError localPositionError() const override
local position error in SL frame
T getParameter(std::string const &) const
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
Perform the real analysis.
T getUntrackedParameter(std::string const &, T const &) const
std::pair< const_iterator, const_iterator > range
iterator range
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Geom::Phi< T > phi() const
def setup(process, global_tag, zero_tesla=False)
DTSegment2DQuality(const edm::ParameterSet &pset)
Constructor.
static std::map< DTWireId, const PSimHit * > mapMuSimHitsPerWire(const std::map< DTWireId, edm::PSimHitContainer > &simHitWireMap)
Create a map between the Mu SimHits and corresponding MuBarWireId ;.
static std::pair< const PSimHit *, const PSimHit * > findMuSimSegment(const std::map< DTWireId, const PSimHit * > &mapWireAndMuSimHit)
Find Innermost and outermost SimHit from Mu in a SL (they identify a simulated segment) ...
void beginRun(const edm::Run &iRun, const edm::EventSetup &setup) override
void Fill(float angleSimSegment, float angleRecSegment, float posSimSegment, float posRecSegment, float etaSimSegment, float phiSimSegment, float sigmaPos, float sigmaAngle)
Abs< T >::type abs(const T &t)
static std::pair< double, double > findSegmentAlphaAndBeta(const LocalVector &direction)
static std::pair< LocalVector, LocalPoint > findMuSimSegmentDirAndPos(const std::pair< const PSimHit *, const PSimHit * > &inAndOutSimHit, const DetId detId, const DTGeometry *muonGeom)
Find direction and position of a segment (in local RF) from outer and inner mu SimHit in the RF of ob...
LocalPoint localPosition() const override
local position in SL frame
void Fill(float etaSimSegm, float phiSimSegm, float posSimSegm, float angleSimSegm, bool fillRecHit)
~DTSegment2DQuality() override
Destructor.
LocalVector localDirection() const override
the local direction in SL frame
std::vector< PSimHit > PSimHitContainer
static std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
LocalError localDirectionError() const override
the local direction error (xx,xy,yy) in SL frame: only xx is not 0.
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return a DTSuperLayer given its id.