13 |
|
#include "Geometry/CommonDetUnit/interface/GeomDet.h" |
14 |
|
#include "DataFormats/MuonDetId/interface/RPCDetId.h" |
15 |
|
#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" |
16 |
+ |
#include "DataFormats/RPCDigi/interface/RPCDigiCollection.h" |
17 |
|
#include "DataFormats/DetId/interface/DetIdCollection.h" |
18 |
|
#include "DataFormats/TrackReco/interface/HitPattern.h" |
19 |
|
|
61 |
|
return detsSIMU; |
62 |
|
} |
63 |
|
|
64 |
< |
std::vector<uint32_t> DetHitCompatibleCollector::compatibleHits( const reco::Muon* muon, const edm::Event &ev, const edm::EventSetup &es) |
64 |
> |
std::vector<DetCluDigiObj> DetHitCompatibleCollector::compatibleHits( const reco::Muon* muon, const edm::Event &ev, const edm::EventSetup &es) |
65 |
|
{ |
66 |
< |
std::vector<uint32_t> detsHitsCompatibleWithMuon; |
66 |
> |
std::vector<DetCluDigiObj> detsHitsCompatibleWithMuon; |
67 |
> |
|
68 |
|
edm::Handle<RPCRecHitCollection> recHits; |
69 |
|
ev.getByLabel("rpcRecHits", recHits); |
70 |
|
|
71 |
+ |
edm::Handle<RPCDigiCollection> rpcDigis; |
72 |
+ |
ev.getByLabel("muonRPCDigis", rpcDigis); |
73 |
+ |
|
74 |
|
edm::ESHandle<RPCGeometry> rpcGeometry; |
75 |
|
es.get<MuonGeometryRecord>().get(rpcGeometry); |
76 |
|
|
77 |
|
TrackAtSurface trackAtSurface(muon, ev,es); |
78 |
|
|
79 |
+ |
std::map< uint32_t, std::pair<uint32_t,uint32_t> > aMap; |
80 |
|
typedef RPCRecHitCollection::const_iterator IH; |
81 |
|
for (IH ih=recHits->begin(); ih != recHits->end(); ++ih) { |
82 |
|
|
83 |
+ |
if (ih->BunchX() != 0) continue; |
84 |
+ |
if (! ih->isValid() ) continue; |
85 |
|
RPCDetId rpcDet = ih->rpcId(); |
86 |
|
GlobalPoint detPosition = rpcGeometry->idToDet(rpcDet)->position(); |
87 |
|
GlobalPoint hitPosition = rpcGeometry->idToDet(rpcDet)->toGlobal(ih->localPosition()); |
100 |
|
*/ |
101 |
|
// |
102 |
|
TrajectoryStateOnSurface trackAtHit= trackAtSurface.atDetFromClose(rpcDet,hitPosition); |
103 |
< |
if(!trackAtHit.isValid()) std::cout <<" TRAJ NOT VALID! "<< std::endl; |
103 |
> |
// if(!trackAtHit.isValid()) std::cout <<" TRAJ NOT VALID! "<< std::endl; |
104 |
|
if (!trackAtHit.isValid()) continue; |
105 |
|
LocalPoint hitPoint = ih->localPosition(); |
106 |
|
LocalError hitError = ih->localPositionError(); |
114 |
|
float pullY = distY/ sqrt( trackAtHitError.yy()+hitError.yy()); |
115 |
|
|
116 |
|
bool hitCompatible = (fabs(pullX) < 3.5 || fabs(distX) < 10.) && fabs(pullY) < 3.5 ; |
117 |
< |
if (hitCompatible && (detsHitsCompatibleWithMuon.end() == find(detsHitsCompatibleWithMuon.begin(),detsHitsCompatibleWithMuon.end(),rpcDet.rawId()) ) ) |
118 |
< |
detsHitsCompatibleWithMuon.push_back(rpcDet.rawId()); |
117 |
> |
if (hitCompatible) { |
118 |
> |
if (aMap.find(rpcDet.rawId()) == aMap.end() ) aMap[rpcDet.rawId()] = std::make_pair(0,0); |
119 |
> |
|
120 |
> |
unsigned int clusterSize = ih->clusterSize(); |
121 |
> |
if ( aMap[rpcDet.rawId()].first < clusterSize) aMap[rpcDet.rawId()].first = clusterSize; |
122 |
> |
|
123 |
> |
const RPCDigiCollection::Range range = rpcDigis->get( rpcDet.rawId() ); |
124 |
> |
std::map<int, bool> strips; |
125 |
> |
for (RPCDigiCollection::const_iterator id = range.first; id != range.second; ++id) if (id->bx() == 0) strips[id->strip()] = true; |
126 |
> |
if ( strips.size() == 0 ) std::cout <<"WARNING ***************"<<std::endl; |
127 |
> |
aMap[rpcDet.rawId()].second = strips.size(); |
128 |
> |
} |
129 |
|
|
130 |
|
RPCDetIdUtil place(rpcDet); |
131 |
|
if (place.isBarrel()) { |
143 |
|
hPullY->Fill(pullY); |
144 |
|
} |
145 |
|
|
146 |
+ |
|
147 |
+ |
for ( std::map< uint32_t, std::pair<uint32_t,uint32_t> >::const_iterator it = aMap.begin(); it != aMap.end(); ++it) { |
148 |
+ |
DetCluDigiObj obj; |
149 |
+ |
obj.det = (*it).first; |
150 |
+ |
obj.clusterSize = (*it).second.first; |
151 |
+ |
obj.nDigis = (*it).second.second; |
152 |
+ |
detsHitsCompatibleWithMuon.push_back(obj); |
153 |
+ |
} |
154 |
|
return detsHitsCompatibleWithMuon; |
155 |
|
} |
156 |
|
|
157 |
+ |
/* |
158 |
+ |
std::vector<uint32_t> DetHitCompatibleCollector::clSizeCompDets(const std::vector<uint32_t> & detIds, const edm::Event &ev, const edm::EventSetup &es) |
159 |
+ |
{ |
160 |
+ |
std::vector<uint32_t> cluInDets; |
161 |
+ |
edm::Handle<RPCRecHitCollection> recHits; |
162 |
+ |
ev.getByLabel("rpcRecHits", recHits); |
163 |
+ |
for (std::vector<uint32_t>::const_iterator it = detIds.begin(); it != detIds.end(); ++it) { |
164 |
+ |
RPCRecHitCollection::range range = recHits->get(*it); |
165 |
+ |
// std::cout <<"DET: "<<*it << std::endl; |
166 |
+ |
for(RPCRecHitCollection::const_iterator ih= range.first; ih != range.second; ++ih) { |
167 |
+ |
if (ih->BunchX() == 0) { cluInDets.push_back(ih->clusterSize()); break; } |
168 |
+ |
} |
169 |
+ |
// for(RPCRecHitCollection::const_iterator ih= range.first; ih != range.second; ++ih) |
170 |
+ |
// std::cout <<" Hit: cluster:"<<ih->clusterSize() << "first strip: "<<ih->firstClusterStrip()<<std::endl; |
171 |
+ |
// if (range.second-range.first) cluInDets.push_back(range.first->clusterSize()); |
172 |
+ |
} |
173 |
+ |
return cluInDets; |
174 |
+ |
} |
175 |
+ |
|
176 |
+ |
std::vector<uint32_t> DetHitCompatibleCollector::nDigisCompDets(const std::vector<uint32_t> & detIds, const edm::Event &ev, const edm::EventSetup &es) |
177 |
+ |
{ |
178 |
+ |
std::vector<uint32_t> digisInDets; |
179 |
+ |
edm::Handle<RPCDigiCollection> rpcDigis; |
180 |
+ |
ev.getByLabel("muonRPCDigis", rpcDigis); |
181 |
+ |
for (std::vector<uint32_t>::const_iterator it = detIds.begin(); it != detIds.end(); ++it) { |
182 |
+ |
// std::cout <<"DET: "<<*it << std::endl; |
183 |
+ |
const RPCDigiCollection::Range range = rpcDigis->get(*it); |
184 |
+ |
std::map<int, bool> strips; |
185 |
+ |
// for (RPCDigiCollection::const_iterator id = range.first; id != range.second; ++id) id->print() ; |
186 |
+ |
for (RPCDigiCollection::const_iterator id = range.first; id != range.second; ++id) if (id->bx() == 0) strips[id->strip()] = true; |
187 |
+ |
if ( strips.size() == 0 ) std::cout <<"WARNING ***************"<<std::endl; |
188 |
+ |
digisInDets.push_back( strips.size()); |
189 |
+ |
// std::cout <<"SIZE is : "<<strips.size() << std::endl; |
190 |
+ |
} |
191 |
+ |
return digisInDets; |
192 |
+ |
} |
193 |
+ |
*/ |
194 |
+ |
|
195 |
|
std::vector<uint32_t> DetHitCompatibleCollector::compatibleDets( const reco::Muon* muon, const edm::Event &ev, const edm::EventSetup &es, bool deepInside) |
196 |
|
{ |
197 |
|
std::vector<uint32_t> detsCrossedByMuon; |
215 |
|
if (! (det->surface().bounds().inside(stateAtDet.localPosition()))) continue; |
216 |
|
if (deepInside) { |
217 |
|
LocalError stateAtDetError = stateAtDet.localError().positionError(); |
218 |
< |
LocalPoint farEdge( fabs(stateAtDet.localPosition().x())+3.5*sqrt(stateAtDetError.xx()), fabs(stateAtDet.localPosition().y())+3.5*sqrt(stateAtDetError.yy())); |
218 |
> |
LocalPoint farEdge( fabs(stateAtDet.localPosition().x())+3.5*sqrt(stateAtDetError.xx())+5., fabs(stateAtDet.localPosition().y())+3.5*sqrt(stateAtDetError.yy())+5.); |
219 |
|
if (! det->surface().bounds().inside(farEdge) ) continue; |
220 |
|
} |
221 |
|
if (detsCrossedByMuon.end() == find(detsCrossedByMuon.begin(),detsCrossedByMuon.end(),rpcDet.rawId()) ) |