ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/src/DetHitCompatibleCollector.cc
(Generate patch)

Comparing UserCode/L1RpcTriggerAnalysis/src/DetHitCompatibleCollector.cc (file contents):
Revision 1.4 by konec, Tue Oct 2 13:21:27 2012 UTC vs.
Revision 1.6 by konec, Tue Oct 23 20:17:44 2012 UTC

# Line 61 | Line 61 | std::vector<uint32_t> DetHitCompatibleCo
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  
# Line 109 | Line 114 | std::vector<uint32_t> DetHitCompatibleCo
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()) {
# Line 128 | Line 143 | std::vector<uint32_t> DetHitCompatibleCo
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;
# Line 138 | Line 162 | std::vector<uint32_t> DetHitCompatibleCo
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 <    if (range.second-range.first) cluInDets.push_back(range.first->clusterSize());
166 <    for (RPCRecHitCollection::const_iterator ih= range.first; ih != range.second; ++ih) {
167 <    }
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   }
# Line 151 | Line 179 | std::vector<uint32_t> DetHitCompatibleCo
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() ;
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   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines