157 cout <<
"[DTEfficiencyTask] Analyze #Run: " <<
event.id().run()
158 <<
" #Event: " <<
event.id().event() << endl;
174 DTRecSegment4DCollection::id_iterator chamberId;
175 for (chamberId = all4DSegments->id_begin();
176 chamberId != all4DSegments->id_end();
183 const vector<const DTSuperLayer*>& SLayers = chamber->
superLayers();
184 map<DTWireId, int> wireAnd1DRecHits;
185 for(vector<const DTSuperLayer*>::const_iterator superlayer = SLayers.begin();
186 superlayer != SLayers.end();
191 rechit!=range.second;
193 wireAnd1DRecHits[(*rechit).wireId()] = (*rechit).wireId().wire();
200 int nsegm =
distance(range.first, range.second);
202 cout <<
" Chamber: " << *chamberId <<
" has " << nsegm
203 <<
" 4D segments" << endl;
208 segment4D!=range.second;
211 cout <<
" == RecSegment dimension: " << (*segment4D).dimension() << endl;
215 if((*chamberId).station() != 4 && (*segment4D).dimension() != 4) {
217 cout <<
"[DTEfficiencyTask]***Warning: RecSegment dimension is not 4 but " 218 << (*segment4D).dimension() <<
", skipping!" << endl;
220 }
else if((*chamberId).station() == 4 && (*segment4D).dimension() != 2) {
222 cout <<
"[DTEfficiencyTask]***Warning: RecSegment dimension is not 2 but " 223 << (*segment4D).dimension() <<
", skipping!" << endl;
227 vector<DTRecHit1D> recHits1D;
235 if(phiRecHits.size() < 7 || phiRecHits.size() > 8 ) {
237 cout <<
"[DTEfficiencyTask] Phi segments has: " << phiRecHits.size()
238 <<
" hits, skipping" << endl;
241 copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D));
243 if((*segment4D).dimension() == 4) {
245 zSeg = (*segment4D).zSegment();
247 if(zRecHits.size() < 3 || zRecHits.size() > 4 ) {
249 cout <<
"[DTEfficiencyTask] Theta segments has: " << zRecHits.size()
250 <<
" hits, skipping" << endl;
253 copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D));
257 vector<DTWireId> wireMap;
258 for(vector<DTRecHit1D>::const_iterator recHit1D = recHits1D.begin();
259 recHit1D != recHits1D.end();
261 wireMap.push_back((*recHit1D).wireId());
264 bool hitsOnSameLayer =
false;
265 for(vector<DTWireId>::const_iterator channelId = wireMap.begin();
266 channelId != wireMap.end(); channelId++) {
267 vector<DTWireId>::const_iterator
next = channelId;
269 for(vector<DTWireId>::const_iterator ite = next; ite != wireMap.end(); ite++) {
270 if((*channelId).layerId() == (*ite).layerId()) {
271 hitsOnSameLayer =
true;
275 if(hitsOnSameLayer) {
277 cout <<
"[DTEfficiencyTask] This RecHit has 2 hits on the same layer, skipping!" << endl;
283 LocalVector phiDirectionInChamber = (*phiSeg).localDirection();
284 if(rPhi && fabs(phiDirectionInChamber.
x()/phiDirectionInChamber.
z()) > 1) {
286 cout <<
" RPhi segment has angle > 45 deg, skipping! " << endl;
287 cout <<
" Theta = " << phiDirectionInChamber.
theta() << endl;
292 LocalVector zDirectionInChamber = (*zSeg).localDirection();
293 if(fabs(zDirectionInChamber.
y()/zDirectionInChamber.
z()) > 1) {
295 cout <<
" RZ segment has angle > 45 deg, skipping! " << endl;
296 cout <<
" Theta = " << zDirectionInChamber.
theta() << endl;
304 if(recHits1D.size() == 10) {
306 cout <<
"[DTEfficiencyTask] 4D Segment with only 10 hits, skipping!" << endl;
312 if((rPhi && recHits1D.size() == 7) || (rZ && recHits1D.size() == 11)) {
315 if(rPhi && recHits1D.size() == 7)
316 cout <<
"[DTEfficiencyTask] MB4 Segment with only 7 hits!" << endl;
317 if(rZ && recHits1D.size() == 11)
318 cout <<
"[DTEfficiencyTask] 4D Segment with only 11 hits!" << endl;
322 const vector<const DTSuperLayer*>& SupLayers = chamber->
superLayers();
323 map<DTLayerId, bool> layerMap;
324 map<DTWireId, float> wireAndPosInChamberAtLayerZ;
326 for(vector<const DTSuperLayer*>::const_iterator superlayer = SupLayers.begin();
327 superlayer != SupLayers.end();
329 const vector<const DTLayer*> Layers = (*superlayer)->layers();
330 for(vector<const DTLayer*>::const_iterator layer = Layers.begin();
331 layer != Layers.end();
333 layerMap.insert(make_pair((*layer)->id(),
false));
334 const int firstWire = dtGeom->
layer((*layer)->id())->specificTopology().firstChannel();
335 const int lastWire = dtGeom->
layer((*layer)->id())->specificTopology().lastChannel();
336 for(
int i=firstWire;
i - lastWire <= 0;
i++) {
338 float wireX = (*layer)->specificTopology().wirePosition(wireId.wire());
340 GlobalPoint wirePosGlob = (*layer)->toGlobal(wirePosInLay);
342 if((*superlayer)->id().superlayer() == 1 || (*superlayer)->id().superlayer() == 3) {
343 wireAndPosInChamberAtLayerZ.insert(make_pair(wireId, wirePosInChamber.
x()));
345 wireAndPosInChamberAtLayerZ.insert(make_pair(wireId, wirePosInChamber.
y()));
352 map<DTLayerId, int> NumWireMap;
353 for(vector<DTRecHit1D>::const_iterator
recHit = recHits1D.begin();
354 recHit != recHits1D.end();
356 layerMap[(*recHit).wireId().layerId()]=
true;
357 NumWireMap[(*recHit).wireId().layerId()]= (*recHit).wireId().wire();
362 for(map<DTLayerId, bool>::const_iterator iter = layerMap.begin();
363 iter != layerMap.end(); iter++) {
364 if(!(*iter).second) missLayerId = (*iter).first;
367 cout <<
"[DTEfficiencyTask] Layer without recHits is: " << missLayerId << endl;
375 LocalPoint segPosAtZLayer = (*segment4D).localPosition()
376 + (*segment4D).localDirection()*missLayerPosInChamber.
z()/
cos((*segment4D).localDirection().theta());
381 for(map<DTWireId, float>::const_iterator wireAndPos = wireAndPosInChamberAtLayerZ.begin();
382 wireAndPos != wireAndPosInChamberAtLayerZ.end();
384 DTWireId wireId = (*wireAndPos).first;
385 if(wireId.
layerId() == missLayerId) {
387 if(fabs(segPosAtZLayer.
x() - (*wireAndPos).second) < 2.1)
390 if(fabs(segPosAtZLayer.
y() - (*wireAndPos).second) < 2.1)
396 cout <<
"[DTEfficiencyTask] Cell without hit is: " << missWireId << endl;
399 bool foundUnAssRechit =
false;
402 if(wireAnd1DRecHits.find(missWireId) != wireAnd1DRecHits.end()) {
404 cout <<
"[DTEfficiencyTask] Unassociated Hit found!" << endl;
405 foundUnAssRechit =
true;
409 for(map<DTLayerId, bool>::const_iterator iter = layerMap.begin();
410 iter != layerMap.end(); iter++) {
419 if((rPhi && recHits1D.size() == 8) || (rZ && recHits1D.size() == 12)) {
420 map<DTLayerId, int> NumWireMap;
422 for(vector<DTRecHit1D>::const_iterator
recHit = recHits1D.begin();
423 recHit != recHits1D.end();
425 LayerID = (*recHit).wireId().layerId();
426 NumWireMap[LayerID]= (*recHit).wireId().wire();
428 for(map<DTLayerId, int>::const_iterator iter = NumWireMap.begin();
429 iter != NumWireMap.end(); iter++) {
std::pair< const_iterator, const_iterator > range
iterator range
const DTLayer * layer(const DTLayerId &id) const
Return the layer corresponding to the given id.
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
static std::pair< DTLayerId, DTSuperLayerIdComparator > layersBySuperLayer(DTSuperLayerId slId)
Access by SL objects written into a RangeMap by layer.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
void fillHistos(DTLayerId lId, int firstWire, int lastWire, int numWire)
int firstChannel() const
Returns the wire number of the first wire.
Geom::Theta< T > theta() const
edm::EDGetTokenT< DTRecHitCollection > recHitToken_
edm::EDGetTokenT< DTRecSegment4DCollection > recHits4DToken_
int lastChannel() const
Returns the wire number of the last wire.
const DTTopology & specificTopology() const
const std::vector< const DTSuperLayer * > & superLayers() const
Return the superlayers in the chamber.
Cos< T >::type cos(const T &t)
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
int superlayer() const
Return the superlayer number (deprecated method name)
DTLayerId layerId() const
Return the corresponding LayerId.
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.