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 |
|
|
44 |
|
|
45 |
|
|
46 |
|
DetHitCompatibleCollector::DetHitCompatibleCollector(const edm::ParameterSet& cfg) |
47 |
+ |
: theNoDigiWarning(false) |
48 |
+ |
{ } |
49 |
+ |
|
50 |
+ |
DetHitCompatibleCollector::~ DetHitCompatibleCollector() |
51 |
|
{ |
52 |
+ |
if (theNoDigiWarning) std::cout <<" **** DetHitCompatibleCollector **** WARNING - NoDigiWarning was set!" << std::endl; |
53 |
|
} |
54 |
|
|
55 |
|
std::vector<uint32_t> DetHitCompatibleCollector::compatibleSIMU( const reco::Muon* muon, const edm::Event &ev, const edm::EventSetup &es) |
66 |
|
return detsSIMU; |
67 |
|
} |
68 |
|
|
69 |
< |
std::vector<uint32_t> DetHitCompatibleCollector::compatibleHits( const reco::Muon* muon, const edm::Event &ev, const edm::EventSetup &es) |
69 |
> |
std::vector<DetCluDigiObj> DetHitCompatibleCollector::compatibleHits( const reco::Muon* muon, const edm::Event &ev, const edm::EventSetup &es) |
70 |
|
{ |
71 |
< |
std::vector<uint32_t> detsHitsCompatibleWithMuon; |
71 |
> |
std::vector<DetCluDigiObj> detsHitsCompatibleWithMuon; |
72 |
> |
|
73 |
|
edm::Handle<RPCRecHitCollection> recHits; |
74 |
|
ev.getByLabel("rpcRecHits", recHits); |
75 |
|
|
76 |
+ |
edm::Handle<RPCDigiCollection> rpcDigis; |
77 |
+ |
ev.getByLabel("muonRPCDigis", rpcDigis); |
78 |
+ |
|
79 |
|
edm::ESHandle<RPCGeometry> rpcGeometry; |
80 |
|
es.get<MuonGeometryRecord>().get(rpcGeometry); |
81 |
|
|
82 |
|
TrackAtSurface trackAtSurface(muon, ev,es); |
83 |
|
|
84 |
+ |
std::map< uint32_t, std::pair<uint32_t,uint32_t> > aMap; |
85 |
|
typedef RPCRecHitCollection::const_iterator IH; |
86 |
|
for (IH ih=recHits->begin(); ih != recHits->end(); ++ih) { |
87 |
|
|
88 |
+ |
if (ih->BunchX() != 0) continue; |
89 |
+ |
if (! ih->isValid() ) continue; |
90 |
|
RPCDetId rpcDet = ih->rpcId(); |
91 |
|
GlobalPoint detPosition = rpcGeometry->idToDet(rpcDet)->position(); |
92 |
|
GlobalPoint hitPosition = rpcGeometry->idToDet(rpcDet)->toGlobal(ih->localPosition()); |
105 |
|
*/ |
106 |
|
// |
107 |
|
TrajectoryStateOnSurface trackAtHit= trackAtSurface.atDetFromClose(rpcDet,hitPosition); |
108 |
< |
if(!trackAtHit.isValid()) std::cout <<" TRAJ NOT VALID! "<< std::endl; |
108 |
> |
// if(!trackAtHit.isValid()) std::cout <<" TRAJ NOT VALID! "<< std::endl; |
109 |
|
if (!trackAtHit.isValid()) continue; |
110 |
|
LocalPoint hitPoint = ih->localPosition(); |
111 |
|
LocalError hitError = ih->localPositionError(); |
119 |
|
float pullY = distY/ sqrt( trackAtHitError.yy()+hitError.yy()); |
120 |
|
|
121 |
|
bool hitCompatible = (fabs(pullX) < 3.5 || fabs(distX) < 10.) && fabs(pullY) < 3.5 ; |
122 |
< |
if (hitCompatible && (detsHitsCompatibleWithMuon.end() == find(detsHitsCompatibleWithMuon.begin(),detsHitsCompatibleWithMuon.end(),rpcDet.rawId()) ) ) |
123 |
< |
detsHitsCompatibleWithMuon.push_back(rpcDet.rawId()); |
122 |
> |
if (hitCompatible) { |
123 |
> |
if (aMap.find(rpcDet.rawId()) == aMap.end() ) aMap[rpcDet.rawId()] = std::make_pair(0,0); |
124 |
> |
|
125 |
> |
unsigned int clusterSize = ih->clusterSize(); |
126 |
> |
if ( aMap[rpcDet.rawId()].first < clusterSize) aMap[rpcDet.rawId()].first = clusterSize; |
127 |
> |
|
128 |
> |
if (rpcDigis.isValid()) { |
129 |
> |
const RPCDigiCollection::Range range = rpcDigis->get( rpcDet.rawId() ); |
130 |
> |
std::map<int, bool> strips; |
131 |
> |
for (RPCDigiCollection::const_iterator id = range.first; id != range.second; ++id) if (id->bx() == 0) strips[id->strip()] = true; |
132 |
> |
if ( strips.size() == 0 ) std::cout <<"WARNING ***************"<<std::endl; |
133 |
> |
aMap[rpcDet.rawId()].second = strips.size(); |
134 |
> |
} else theNoDigiWarning = true; |
135 |
> |
} |
136 |
|
|
137 |
|
RPCDetIdUtil place(rpcDet); |
138 |
|
if (place.isBarrel()) { |
150 |
|
hPullY->Fill(pullY); |
151 |
|
} |
152 |
|
|
153 |
+ |
|
154 |
+ |
for ( std::map< uint32_t, std::pair<uint32_t,uint32_t> >::const_iterator it = aMap.begin(); it != aMap.end(); ++it) { |
155 |
+ |
DetCluDigiObj obj; |
156 |
+ |
obj.det = (*it).first; |
157 |
+ |
obj.clusterSize = (*it).second.first; |
158 |
+ |
obj.nDigis = (*it).second.second; |
159 |
+ |
detsHitsCompatibleWithMuon.push_back(obj); |
160 |
+ |
} |
161 |
|
return detsHitsCompatibleWithMuon; |
162 |
|
} |
163 |
|
|
164 |
+ |
/* |
165 |
+ |
std::vector<uint32_t> DetHitCompatibleCollector::clSizeCompDets(const std::vector<uint32_t> & detIds, const edm::Event &ev, const edm::EventSetup &es) |
166 |
+ |
{ |
167 |
+ |
std::vector<uint32_t> cluInDets; |
168 |
+ |
edm::Handle<RPCRecHitCollection> recHits; |
169 |
+ |
ev.getByLabel("rpcRecHits", recHits); |
170 |
+ |
for (std::vector<uint32_t>::const_iterator it = detIds.begin(); it != detIds.end(); ++it) { |
171 |
+ |
RPCRecHitCollection::range range = recHits->get(*it); |
172 |
+ |
// std::cout <<"DET: "<<*it << std::endl; |
173 |
+ |
for(RPCRecHitCollection::const_iterator ih= range.first; ih != range.second; ++ih) { |
174 |
+ |
if (ih->BunchX() == 0) { cluInDets.push_back(ih->clusterSize()); break; } |
175 |
+ |
} |
176 |
+ |
// for(RPCRecHitCollection::const_iterator ih= range.first; ih != range.second; ++ih) |
177 |
+ |
// std::cout <<" Hit: cluster:"<<ih->clusterSize() << "first strip: "<<ih->firstClusterStrip()<<std::endl; |
178 |
+ |
// if (range.second-range.first) cluInDets.push_back(range.first->clusterSize()); |
179 |
+ |
} |
180 |
+ |
return cluInDets; |
181 |
+ |
} |
182 |
+ |
|
183 |
+ |
std::vector<uint32_t> DetHitCompatibleCollector::nDigisCompDets(const std::vector<uint32_t> & detIds, const edm::Event &ev, const edm::EventSetup &es) |
184 |
+ |
{ |
185 |
+ |
std::vector<uint32_t> digisInDets; |
186 |
+ |
edm::Handle<RPCDigiCollection> rpcDigis; |
187 |
+ |
ev.getByLabel("muonRPCDigis", rpcDigis); |
188 |
+ |
for (std::vector<uint32_t>::const_iterator it = detIds.begin(); it != detIds.end(); ++it) { |
189 |
+ |
// std::cout <<"DET: "<<*it << std::endl; |
190 |
+ |
const RPCDigiCollection::Range range = rpcDigis->get(*it); |
191 |
+ |
std::map<int, bool> strips; |
192 |
+ |
// for (RPCDigiCollection::const_iterator id = range.first; id != range.second; ++id) id->print() ; |
193 |
+ |
for (RPCDigiCollection::const_iterator id = range.first; id != range.second; ++id) if (id->bx() == 0) strips[id->strip()] = true; |
194 |
+ |
if ( strips.size() == 0 ) std::cout <<"WARNING ***************"<<std::endl; |
195 |
+ |
digisInDets.push_back( strips.size()); |
196 |
+ |
// std::cout <<"SIZE is : "<<strips.size() << std::endl; |
197 |
+ |
} |
198 |
+ |
return digisInDets; |
199 |
+ |
} |
200 |
+ |
*/ |
201 |
+ |
|
202 |
|
std::vector<uint32_t> DetHitCompatibleCollector::compatibleDets( const reco::Muon* muon, const edm::Event &ev, const edm::EventSetup &es, bool deepInside) |
203 |
|
{ |
204 |
|
std::vector<uint32_t> detsCrossedByMuon; |