91 cout <<
"[DTEfficiencyTask] Analyze #Run: " <<
event.id().run()
92 <<
" #Event: " <<
event.id().event() << endl;
108 DTRecSegment4DCollection::id_iterator chamberId;
109 for (chamberId = all4DSegments->id_begin();
110 chamberId != all4DSegments->id_end();
114 const DTChamber* chamber = dtGeom->chamber(*chamberId);
117 const vector<const DTSuperLayer*> SLayers = chamber->
superLayers();
118 map<DTWireId, int> wireAnd1DRecHits;
119 for(vector<const DTSuperLayer*>::const_iterator superlayer = SLayers.begin();
120 superlayer != SLayers.end();
125 rechit!=range.second;
127 wireAnd1DRecHits[(*rechit).wireId()] = (*rechit).wireId().wire();
134 int nsegm = distance(range.first, range.second);
136 cout <<
" Chamber: " << *chamberId <<
" has " << nsegm
137 <<
" 4D segments" << endl;
142 segment4D!=range.second;
145 cout <<
" == RecSegment dimension: " << (*segment4D).dimension() << endl;
149 if((*chamberId).station() != 4 && (*segment4D).dimension() != 4) {
151 cout <<
"[DTEfficiencyTask]***Warning: RecSegment dimension is not 4 but "
152 << (*segment4D).dimension() <<
", skipping!" << endl;
154 }
else if((*chamberId).station() == 4 && (*segment4D).dimension() != 2) {
156 cout <<
"[DTEfficiencyTask]***Warning: RecSegment dimension is not 2 but "
157 << (*segment4D).dimension() <<
", skipping!" << endl;
161 vector<DTRecHit1D> recHits1D;
169 if(phiRecHits.size() < 7 || phiRecHits.size() > 8 ) {
171 cout <<
"[DTEfficiencyTask] Phi segments has: " << phiRecHits.size()
172 <<
" hits, skipping" << endl;
175 copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D));
177 if((*segment4D).dimension() == 4) {
179 zSeg = (*segment4D).zSegment();
181 if(zRecHits.size() < 3 || zRecHits.size() > 4 ) {
183 cout <<
"[DTEfficiencyTask] Theta segments has: " << zRecHits.size()
184 <<
" hits, skipping" << endl;
187 copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D));
191 vector<DTWireId> wireMap;
192 for(vector<DTRecHit1D>::const_iterator recHit1D = recHits1D.begin();
193 recHit1D != recHits1D.end();
195 wireMap.push_back((*recHit1D).wireId());
198 bool hitsOnSameLayer =
false;
199 for(vector<DTWireId>::const_iterator channelId = wireMap.begin();
200 channelId != wireMap.end(); channelId++) {
201 vector<DTWireId>::const_iterator
next = channelId;
203 for(vector<DTWireId>::const_iterator ite = next; ite != wireMap.end(); ite++) {
204 if((*channelId).layerId() == (*ite).layerId()) {
205 hitsOnSameLayer =
true;
209 if(hitsOnSameLayer) {
211 cout <<
"[DTEfficiencyTask] This RecHit has 2 hits on the same layer, skipping!" << endl;
217 LocalVector phiDirectionInChamber = (*phiSeg).localDirection();
218 if(rPhi && fabs(phiDirectionInChamber.
x()/phiDirectionInChamber.
z()) > 1) {
220 cout <<
" RPhi segment has angle > 45 deg, skipping! " << endl;
221 cout <<
" Theta = " << phiDirectionInChamber.
theta() << endl;
226 LocalVector zDirectionInChamber = (*zSeg).localDirection();
227 if(fabs(zDirectionInChamber.
y()/zDirectionInChamber.
z()) > 1) {
229 cout <<
" RZ segment has angle > 45 deg, skipping! " << endl;
230 cout <<
" Theta = " << zDirectionInChamber.
theta() << endl;
238 if(recHits1D.size() == 10) {
240 cout <<
"[DTEfficiencyTask] 4D Segment with only 10 hits, skipping!" << endl;
246 if((rPhi && recHits1D.size() == 7) || (rZ && recHits1D.size() == 11)) {
249 if(rPhi && recHits1D.size() == 7)
250 cout <<
"[DTEfficiencyTask] MB4 Segment with only 7 hits!" << endl;
251 if(rZ && recHits1D.size() == 11)
252 cout <<
"[DTEfficiencyTask] 4D Segment with only 11 hits!" << endl;
256 const vector<const DTSuperLayer*> SupLayers = chamber->
superLayers();
257 map<DTLayerId, bool> layerMap;
258 map<DTWireId, float> wireAndPosInChamberAtLayerZ;
260 for(vector<const DTSuperLayer*>::const_iterator superlayer = SupLayers.begin();
261 superlayer != SupLayers.end();
263 const vector<const DTLayer*> Layers = (*superlayer)->layers();
264 for(vector<const DTLayer*>::const_iterator layer = Layers.begin();
265 layer != Layers.end();
267 layerMap.insert(make_pair((*layer)->id(),
false));
268 const int firstWire = dtGeom->layer((*layer)->id())->specificTopology().firstChannel();
269 const int lastWire = dtGeom->layer((*layer)->id())->specificTopology().lastChannel();
270 for(
int i=firstWire;
i - lastWire <= 0;
i++) {
272 float wireX = (*layer)->specificTopology().wirePosition(wireId.wire());
274 GlobalPoint wirePosGlob = (*layer)->toGlobal(wirePosInLay);
276 if((*superlayer)->id().superlayer() == 1 || (*superlayer)->id().superlayer() == 3) {
277 wireAndPosInChamberAtLayerZ.insert(make_pair(wireId, wirePosInChamber.
x()));
279 wireAndPosInChamberAtLayerZ.insert(make_pair(wireId, wirePosInChamber.
y()));
286 map<DTLayerId, int> NumWireMap;
287 for(vector<DTRecHit1D>::const_iterator recHit = recHits1D.begin();
288 recHit != recHits1D.end();
290 layerMap[(*recHit).wireId().layerId()]=
true;
291 NumWireMap[(*recHit).wireId().layerId()]= (*recHit).wireId().wire();
296 for(map<DTLayerId, bool>::const_iterator
iter = layerMap.begin();
298 if(!(*iter).second) missLayerId = (*iter).first;
301 cout <<
"[DTEfficiencyTask] Layer without recHits is: " << missLayerId << endl;
311 LocalPoint segPosAtZLayer = (*segment4D).localPosition()
312 + (*segment4D).localDirection()*missLayerPosInChamber.
z()/
cos((*segment4D).localDirection().theta());
317 for(map<DTWireId, float>::const_iterator wireAndPos = wireAndPosInChamberAtLayerZ.begin();
318 wireAndPos != wireAndPosInChamberAtLayerZ.end();
320 DTWireId wireId = (*wireAndPos).first;
321 if(wireId.
layerId() == missLayerId) {
323 if(fabs(segPosAtZLayer.
x() - (*wireAndPos).second) < 2.1)
326 if(fabs(segPosAtZLayer.
y() - (*wireAndPos).second) < 2.1)
332 cout <<
"[DTEfficiencyTask] Cell without hit is: " << missWireId << endl;
336 bool foundUnAssRechit =
false;
339 if(wireAnd1DRecHits.find(missWireId) != wireAnd1DRecHits.end()) {
341 cout <<
"[DTEfficiencyTask] Unassociated Hit found!" << endl;
342 foundUnAssRechit =
true;
346 for(map<DTLayerId, bool>::const_iterator
iter = layerMap.begin();
349 fillHistos((*iter).first, dtGeom->layer((*iter).first)->specificTopology().firstChannel(), dtGeom->layer((*iter).first)->specificTopology().lastChannel(), NumWireMap[(*iter).first]);
351 fillHistos((*iter).first, dtGeom->layer((*iter).first)->specificTopology().firstChannel(), dtGeom->layer((*iter).first)->specificTopology().lastChannel(), missWireId.wire(), foundUnAssRechit);
356 if((rPhi && recHits1D.size() == 8) || (rZ && recHits1D.size() == 12)) {
357 map<DTLayerId, int> NumWireMap;
359 for(vector<DTRecHit1D>::const_iterator recHit = recHits1D.begin();
360 recHit != recHits1D.end();
362 LayerID = (*recHit).wireId().layerId();
363 NumWireMap[LayerID]= (*recHit).wireId().wire();
365 for(map<DTLayerId, int>::const_iterator
iter = NumWireMap.begin();
367 fillHistos((*iter).first, dtGeom->layer((*iter).first)->specificTopology().firstChannel(), dtGeom->layer((*iter).first)->specificTopology().lastChannel(), NumWireMap[(*iter).first]);
std::pair< const_iterator, const_iterator > range
iterator range
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.
const DTLayer * layer(DTLayerId id) const
Return the layer corresponding to the given id.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
void fillHistos(DTLayerId lId, int firstWire, int lastWire, int numWire)
Geom::Theta< T > theta() const
edm::EDGetTokenT< DTRecHitCollection > recHitToken_
edm::EDGetTokenT< DTRecSegment4DCollection > recHits4DToken_
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.