98 if(
doall) h2DHitEff_SuperPhi->ComputeEfficiency();
115 event.getByToken(simHitToken_, simHits);
118 map<DTChamberId, PSimHitContainer > simHitsPerCh;
119 for(PSimHitContainer::const_iterator
simHit = simHits->begin();
124 simHitsPerCh[chamberId].push_back(*
simHit);
129 event.getByToken(segment4DToken_, segment4Ds);
133 <<
" in this event, skipping!" << endl;
138 DTRecSegment4DCollection::id_iterator chamberId;
139 for (chamberId = segment4Ds->id_begin();
140 chamberId != segment4Ds->id_end();
150 int nMuSimHit = muSimHitPerWire.size();
151 if(nMuSimHit == 0 || nMuSimHit == 1) {
152 if(
debug && nMuSimHit == 1)
153 cout <<
"[DTSegment2DSLPhiQuality] Only " << nMuSimHit <<
" mu SimHit in this chamber, skipping!" << endl;
157 cout <<
"=== Chamber " << (*chamberId) <<
" has " << nMuSimHit <<
" SimHits" << endl;
164 (*chamberId),&(*dtGeom));
166 LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
167 LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
173 float posSimSeg = simSegmLocalPos.
x();
175 float etaSimSeg = simSegmGlobalPos.
eta();
176 float phiSimSeg = simSegmGlobalPos.
phi();
179 cout<<
" Simulated segment: local direction "<<simSegmLocalDir<<endl
180 <<
" local position "<<simSegmLocalPos<<endl
181 <<
" angle "<<angleSimSeg<<endl;
185 bool recHitFound =
false;
187 int nsegm =
distance(range.first, range.second);
189 cout <<
" Chamber: " << *chamberId <<
" has " << nsegm
190 <<
" 4D segments" << endl;
199 bool bestRecHitFound =
false;
200 double deltaAlpha = 99999;
204 segment4D!=range.second;
207 if((*segment4D).dimension() != 4) {
208 if(
debug)
cout <<
"[DTSegment2DSLPhiQuality]***Error: This is not 4D segment!!!" << endl;
214 if((*phiSegment2D).dimension() != 2) {
215 if(
debug)
cout <<
"[DTSegment2DQuality]***Error: This is not 2D segment!!!" << endl;
220 LocalVector recSegDirection = (*phiSegment2D).localDirection();
224 cout <<
" RecSegment direction: " << recSegDirection << endl
225 <<
" position : " << (*phiSegment2D).localPosition() << endl
226 <<
" alpha : " << recSegAlpha << endl;
228 if(fabs(recSegAlpha - angleSimSeg) < deltaAlpha) {
229 deltaAlpha = fabs(recSegAlpha - angleSimSeg);
230 bestRecHit = &(*phiSegment2D);
231 bestRecHitFound =
true;
235 if(bestRecHitFound) {
245 fabs(bestRecHitLocalPos.
x() - posSimSeg) < 5*
sigmaResPos) {
250 h2DHitSuperPhi->Fill(angleSimSeg,
253 bestRecHitLocalPos.
x(),
256 sqrt(bestRecHitLocalPosErr.
xx()),
257 sqrt(bestRecHitLocalDirErr.
xx())
263 if(
doall) {h2DHitEff_SuperPhi->Fill(etaSimSeg,
T getParameter(std::string const &) const
virtual LocalError localPositionError() const
local position error in SL frame
DTSegment2DSLPhiQuality(const edm::ParameterSet &pset)
Constructor.
T getUntrackedParameter(std::string const &, T const &) const
std::pair< const_iterator, const_iterator > range
iterator range
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup)
Perform the real analysis.
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
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)
virtual LocalError localDirectionError() const
the local direction error (xx,xy,yy) in SL frame: only xx is not 0.
static std::map< DTWireId, const PSimHit * > mapMuSimHitsPerWire(const std::map< DTWireId, edm::PSimHitContainer > &simHitWireMap)
Create a map between the Mu SimHits and corresponding MuBarWireId ;.
virtual void beginRun(const edm::Run &iRun, const edm::EventSetup &setup)
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) ...
static std::pair< double, double > findSegmentAlphaAndBeta(const LocalVector &direction)
virtual LocalPoint localPosition() const
local position in SL frame
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...
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
virtual LocalVector localDirection() const
the local direction in SL frame
std::vector< PSimHit > PSimHitContainer
static std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
virtual ~DTSegment2DSLPhiQuality()
Destructor.