Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "DTSegment2DSLPhiQuality.h"
00010 #include "Validation/DTRecHits/interface/DTHitQualityUtils.h"
00011
00012 #include "DataFormats/MuonDetId/interface/DTWireId.h"
00013 #include "Geometry/DTGeometry/interface/DTChamber.h"
00014 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00015 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00016
00017 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00018 #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
00019 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
00020
00021 #include "FWCore/Framework/interface/MakerMacros.h"
00022 #include "FWCore/Framework/interface/Frameworkfwd.h"
00023 #include "FWCore/Framework/interface/Event.h"
00024 #include "FWCore/Framework/interface/ESHandle.h"
00025 #include "DQMServices/Core/interface/DQMStore.h"
00026 #include "DQMServices/Core/interface/MonitorElement.h"
00027
00028 #include "Histograms.h"
00029 #include "TStyle.h"
00030 #include "TFile.h"
00031
00032 #include <iostream>
00033 #include <map>
00034
00035
00036 using namespace std;
00037 using namespace edm;
00038
00039
00040
00041
00042 DTSegment2DSLPhiQuality::DTSegment2DSLPhiQuality(const ParameterSet& pset) {
00043
00044 debug = pset.getUntrackedParameter<bool>("debug");
00045 DTHitQualityUtils::debug = debug;
00046
00047
00048 simHitLabel = pset.getUntrackedParameter<InputTag>("simHitLabel");
00049
00050 segment4DLabel = pset.getUntrackedParameter<InputTag>("segment4DLabel");
00051
00052
00053 sigmaResPos = pset.getParameter<double>("sigmaResPos");
00054
00055 sigmaResAngle = pset.getParameter<double>("sigmaResAngle");
00056 doall = pset.getUntrackedParameter<bool>("doall", false);
00057 local = pset.getUntrackedParameter<bool>("local", false);
00058
00059
00060
00061
00062
00063
00064 dbe_ = 0;
00065 dbe_ = Service<DQMStore>().operator->();
00066 if ( dbe_ ) {
00067 if (debug) {
00068 dbe_->setVerbose(1);
00069 } else {
00070 dbe_->setVerbose(0);
00071 }
00072 }
00073 if ( dbe_ ) {
00074 if ( debug ) dbe_->showDirStructure();
00075 }
00076
00077
00078 h2DHitSuperPhi = new HRes2DHit ("SuperPhi",dbe_,doall,local);
00079 if(doall) h2DHitEff_SuperPhi = new HEff2DHit ("SuperPhi",dbe_);
00080 }
00081
00082
00083 DTSegment2DSLPhiQuality::~DTSegment2DSLPhiQuality(){
00084 }
00085
00086 void DTSegment2DSLPhiQuality::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg,
00087 edm::EventSetup const& c){
00088 }
00089
00090
00091
00092
00093 void DTSegment2DSLPhiQuality::endJob() {
00094
00095
00096
00097
00098 if(doall) h2DHitEff_SuperPhi->ComputeEfficiency();
00099
00100
00101
00102
00103 }
00104
00105
00106 void DTSegment2DSLPhiQuality::analyze(const Event & event, const EventSetup& eventSetup){
00107
00108
00109
00110 ESHandle<DTGeometry> dtGeom;
00111 eventSetup.get<MuonGeometryRecord>().get(dtGeom);
00112
00113
00114 edm::Handle<PSimHitContainer> simHits;
00115 event.getByLabel(simHitLabel, simHits);
00116
00117
00118 map<DTChamberId, PSimHitContainer > simHitsPerCh;
00119 for(PSimHitContainer::const_iterator simHit = simHits->begin();
00120 simHit != simHits->end(); simHit++){
00121
00122 DTChamberId chamberId = (((DTWireId(simHit->detUnitId())).layerId()).superlayerId()).chamberId();
00123
00124 simHitsPerCh[chamberId].push_back(*simHit);
00125 }
00126
00127
00128 Handle<DTRecSegment4DCollection> segment4Ds;
00129 event.getByLabel(segment4DLabel, segment4Ds);
00130
00131 if(!segment4Ds.isValid()) {
00132 if(debug) cout << "[DTSegment2DSLPhiQuality]**Warning: no 4D Segments with label: " << segment4DLabel
00133 << " in this event, skipping!" << endl;
00134 return;
00135 }
00136
00137
00138 DTRecSegment4DCollection::id_iterator chamberId;
00139 for (chamberId = segment4Ds->id_begin();
00140 chamberId != segment4Ds->id_end();
00141 ++chamberId){
00142
00143
00144
00145 PSimHitContainer simHits = simHitsPerCh[(*chamberId)];
00146
00147
00148 map<DTWireId, PSimHitContainer > simHitsPerWire = DTHitQualityUtils::mapSimHitsPerWire(simHits);
00149 map<DTWireId, const PSimHit*> muSimHitPerWire = DTHitQualityUtils::mapMuSimHitsPerWire(simHitsPerWire);
00150 int nMuSimHit = muSimHitPerWire.size();
00151 if(nMuSimHit == 0 || nMuSimHit == 1) {
00152 if(debug && nMuSimHit == 1)
00153 cout << "[DTSegment2DSLPhiQuality] Only " << nMuSimHit << " mu SimHit in this chamber, skipping!" << endl;
00154 continue;
00155 }
00156 if(debug)
00157 cout << "=== Chamber " << (*chamberId) << " has " << nMuSimHit << " SimHits" << endl;
00158
00159
00160 pair<const PSimHit*, const PSimHit*> inAndOutSimHit = DTHitQualityUtils::findMuSimSegment(muSimHitPerWire);
00161
00162
00163 pair<LocalVector, LocalPoint> dirAndPosSimSegm = DTHitQualityUtils::findMuSimSegmentDirAndPos(inAndOutSimHit,
00164 (*chamberId),&(*dtGeom));
00165
00166 LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
00167 LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
00168 const DTChamber* chamber = dtGeom->chamber(*chamberId);
00169 GlobalPoint simSegmGlobalPos = chamber->toGlobal(simSegmLocalPos);
00170
00171
00172 float angleSimSeg = DTHitQualityUtils::findSegmentAlphaAndBeta(simSegmLocalDir).first;
00173 float posSimSeg = simSegmLocalPos.x();
00174
00175 float etaSimSeg = simSegmGlobalPos.eta();
00176 float phiSimSeg = simSegmGlobalPos.phi();
00177
00178 if(debug)
00179 cout<<" Simulated segment: local direction "<<simSegmLocalDir<<endl
00180 <<" local position "<<simSegmLocalPos<<endl
00181 <<" angle "<<angleSimSeg<<endl;
00182
00183
00184
00185 bool recHitFound = false;
00186 DTRecSegment4DCollection::range range = segment4Ds->get(*chamberId);
00187 int nsegm = distance(range.first, range.second);
00188 if(debug)
00189 cout << " Chamber: " << *chamberId << " has " << nsegm
00190 << " 4D segments" << endl;
00191
00192 if (nsegm!=0) {
00193
00194
00195
00196
00197
00198 const DTRecSegment2D* bestRecHit = 0;
00199 bool bestRecHitFound = false;
00200 double deltaAlpha = 99999;
00201
00202
00203 for (DTRecSegment4DCollection::const_iterator segment4D = range.first;
00204 segment4D!=range.second;
00205 ++segment4D){
00206
00207 if((*segment4D).dimension() != 4) {
00208 if(debug) cout << "[DTSegment2DSLPhiQuality]***Error: This is not 4D segment!!!" << endl;
00209 continue;
00210 }
00211
00212
00213 const DTChamberRecSegment2D* phiSegment2D = (*segment4D).phiSegment();
00214 if((*phiSegment2D).dimension() != 2) {
00215 if(debug) cout << "[DTSegment2DQuality]***Error: This is not 2D segment!!!" << endl;
00216 abort();
00217 }
00218
00219
00220 LocalVector recSegDirection = (*phiSegment2D).localDirection();
00221
00222 float recSegAlpha = DTHitQualityUtils::findSegmentAlphaAndBeta(recSegDirection).first;
00223 if(debug)
00224 cout << " RecSegment direction: " << recSegDirection << endl
00225 << " position : " << (*phiSegment2D).localPosition() << endl
00226 << " alpha : " << recSegAlpha << endl;
00227
00228 if(fabs(recSegAlpha - angleSimSeg) < deltaAlpha) {
00229 deltaAlpha = fabs(recSegAlpha - angleSimSeg);
00230 bestRecHit = &(*phiSegment2D);
00231 bestRecHitFound = true;
00232 }
00233 }
00234
00235 if(bestRecHitFound) {
00236
00237 LocalPoint bestRecHitLocalPos = bestRecHit->localPosition();
00238 LocalVector bestRecHitLocalDir = bestRecHit->localDirection();
00239
00240 LocalError bestRecHitLocalPosErr = bestRecHit->localPositionError();
00241 LocalError bestRecHitLocalDirErr = bestRecHit->localDirectionError();
00242
00243 float angleBestRHit = DTHitQualityUtils::findSegmentAlphaAndBeta(bestRecHitLocalDir).first;
00244 if(fabs(angleBestRHit - angleSimSeg) < 5*sigmaResAngle &&
00245 fabs(bestRecHitLocalPos.x() - posSimSeg) < 5*sigmaResPos) {
00246 recHitFound = true;
00247 }
00248
00249
00250 h2DHitSuperPhi->Fill(angleSimSeg,
00251 angleBestRHit,
00252 posSimSeg,
00253 bestRecHitLocalPos.x(),
00254 etaSimSeg,
00255 phiSimSeg,
00256 sqrt(bestRecHitLocalPosErr.xx()),
00257 sqrt(bestRecHitLocalDirErr.xx())
00258 );
00259 }
00260 }
00261
00262
00263 if(doall) {h2DHitEff_SuperPhi->Fill(etaSimSeg,
00264 phiSimSeg,
00265 posSimSeg,
00266 angleSimSeg,
00267 recHitFound);}
00268 }
00269 }
00270
00271
00272
00273