00001 00015 #include "RecoMuon/GlobalTrackingTools/interface/ChamberSegmentUtility.h" 00016 #include "FWCore/Framework/interface/Frameworkfwd.h" 00017 #include "FWCore/Framework/interface/EDAnalyzer.h" 00018 #include "FWCore/Framework/interface/Event.h" 00019 #include "FWCore/Framework/interface/MakerMacros.h" 00020 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00021 #include "FWCore/Utilities/interface/InputTag.h" 00022 #include "DataFormats/TrackReco/interface/Track.h" 00023 #include "DataFormats/TrackReco/interface/TrackFwd.h" 00024 #include "Geometry/DTGeometry/interface/DTGeometry.h" 00025 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" 00026 #include "FWCore/Framework/interface/ESHandle.h" 00027 #include "Geometry/Records/interface/MuonGeometryRecord.h" 00028 00029 #include <iostream> 00030 #include <map> 00031 #include <vector> 00032 #include <iostream> 00033 00034 using namespace edm; 00035 using namespace std; 00036 using namespace reco; 00037 00038 ChamberSegmentUtility::ChamberSegmentUtility(const edm::Event& Event, const edm::EventSetup& Setup) 00039 { 00040 00041 Setup.get<MuonGeometryRecord>().get(cscGeometry); 00042 Event.getByLabel("cscSegments", CSCSegments); 00043 Setup.get<MuonGeometryRecord>().get(dtGeom); 00044 Event.getByLabel("dt4DSegments", all4DSegments); 00045 00046 unsigned int index = 0; 00047 for ( CSCSegmentCollection::id_iterator chamberId = CSCSegments->id_begin(); 00048 chamberId != CSCSegments->id_end(); ++chamberId, ++index ) { 00049 00050 CSCSegmentCollection::range range = CSCSegments->get((*chamberId)); 00051 00052 for (CSCSegmentCollection::const_iterator segment = range.first; 00053 segment!=range.second; ++segment) { 00054 if ((*chamberId).station() == 1) cscsegMap[1].push_back(*segment); 00055 if ((*chamberId).station() == 2) cscsegMap[2].push_back(*segment); 00056 if ((*chamberId).station() == 3) cscsegMap[3].push_back(*segment); 00057 if ((*chamberId).station() == 4) cscsegMap[4].push_back(*segment); 00058 } 00059 } 00060 00061 DTRecSegment4DCollection::id_iterator chamberIdIt; 00062 for (chamberIdIt = all4DSegments->id_begin(); 00063 chamberIdIt != all4DSegments->id_end(); 00064 ++chamberIdIt){ 00065 00066 DTRecSegment4DCollection::range range = all4DSegments->get((*chamberIdIt)); 00067 00068 for (DTRecSegment4DCollection::const_iterator segment = range.first; 00069 segment!=range.second; ++segment){ 00070 00071 if ((*chamberIdIt).station() == 1) dtsegMap[1].push_back(*segment); 00072 if ((*chamberIdIt).station() == 2) dtsegMap[2].push_back(*segment); 00073 if ((*chamberIdIt).station() == 3) dtsegMap[3].push_back(*segment); 00074 if ((*chamberIdIt).station() == 4) dtsegMap[4].push_back(*segment); 00075 } 00076 } 00077 00078 00079 } 00080 00081 00082 00083 vector<CSCSegment> ChamberSegmentUtility::getCSCSegmentsInChamber(CSCDetId sel) 00084 { 00085 00086 // loop on segments 4D 00087 unsigned int index = 0; 00088 for ( CSCSegmentCollection::id_iterator chamberId = CSCSegments->id_begin(); 00089 chamberId != CSCSegments->id_end(); ++chamberId, ++index ) { 00090 00091 if ((*chamberId).chamber() != sel.chamber()) continue; 00092 00093 // Get the range for the corresponding ChamberId 00094 CSCSegmentCollection::range range = CSCSegments->get((*chamberId)); 00095 00096 // Loop over the rechits of this DetUnit 00097 for (CSCSegmentCollection::const_iterator segment = range.first; 00098 segment!=range.second; ++segment) { 00099 cscseg.push_back(*segment); 00100 } 00101 } 00102 return cscseg; 00103 } 00104 00105 00106 00107 vector<DTRecSegment4D> ChamberSegmentUtility::getDTSegmentsInChamber(DTChamberId sel) 00108 { 00109 00110 // loop on segments 4D 00111 DTRecSegment4DCollection::id_iterator chamberIdIt; 00112 for (chamberIdIt = all4DSegments->id_begin(); 00113 chamberIdIt != all4DSegments->id_end(); 00114 ++chamberIdIt){ 00115 00116 if (*chamberIdIt != sel) continue; 00117 00118 // Get the range for the corresponding ChamberId 00119 DTRecSegment4DCollection::range range = all4DSegments->get((*chamberIdIt)); 00120 00121 // Loop over the rechits of this DetUnit 00122 for (DTRecSegment4DCollection::const_iterator segment = range.first; 00123 segment!=range.second; ++segment){ 00124 dtseg.push_back(*segment); 00125 } 00126 } 00127 return dtseg; 00128 } 00129 00130 00131 00132 vector<CSCRecHit2D> ChamberSegmentUtility::getCSCRHmap(CSCSegment selected) 00133 { 00134 00135 vector<CSCRecHit2D> allchRH; 00136 00137 // loop on segments 4D 00138 unsigned int index = 0; 00139 for ( CSCSegmentCollection::id_iterator chamberId = CSCSegments->id_begin(); 00140 chamberId != CSCSegments->id_end(); ++chamberId, ++index ) { 00141 00142 // Get the range for the corresponding ChamberId 00143 CSCSegmentCollection::range range = CSCSegments->get((*chamberId)); 00144 00145 // Loop over the rechits of this DetUnit 00146 for (CSCSegmentCollection::const_iterator segment = range.first; 00147 segment!=range.second; ++segment) { 00148 00149 if((*segment).parameters() == selected.parameters()) { 00150 allchRH = (*segment).specificRecHits(); 00151 } 00152 } 00153 } 00154 return allchRH; 00155 } 00156 00157 00158 vector<DTRecHit1D> ChamberSegmentUtility::getDTRHmap(DTRecSegment4D selected) 00159 { 00160 00161 vector<DTRecHit1D> allchRH; 00162 phiSegRH.clear(); 00163 zSegRH.clear(); 00164 00165 // loop on segments 4D 00166 DTRecSegment4DCollection::id_iterator chamberIdIt; 00167 for (chamberIdIt = all4DSegments->id_begin(); 00168 chamberIdIt != all4DSegments->id_end(); 00169 ++chamberIdIt){ 00170 00171 // Get the range for the corresponding ChamberId 00172 DTRecSegment4DCollection::range range = all4DSegments->get((*chamberIdIt)); 00173 00174 // Loop over the rechits of this DetUnit 00175 for (DTRecSegment4DCollection::const_iterator segment = range.first; 00176 segment!=range.second; ++segment){ 00177 00178 if((*segment).parameters() == selected.parameters()) { 00179 if((*segment).hasPhi()){ 00180 const DTChamberRecSegment2D* phiSeg = (*segment).phiSegment(); 00181 phiSegRH = phiSeg->specificRecHits(); 00182 } 00183 if((*segment).hasZed()){ 00184 const DTSLRecSegment2D* zSeg = (*segment).zSegment(); 00185 zSegRH = zSeg->specificRecHits(); 00186 } 00187 00188 // RecHits will be ordered later 00189 for (vector<DTRecHit1D>::const_iterator itphi = phiSegRH.begin(); itphi != phiSegRH.end(); itphi++) allchRH.push_back(*itphi); 00190 for (vector<DTRecHit1D>::iterator itz = zSegRH.begin(); itz < zSegRH.end(); itz++) allchRH.push_back(*itz); 00191 00192 } 00193 } 00194 } 00195 return allchRH; 00196 } 00197 00198 00199