93 cout <<
"[DTEfficiencyTask] Analyze #Run: " <<
event.id().run()
94 <<
" #Event: " <<
event.id().event() << endl;
111 for (chamberId = all4DSegments->id_begin();
112 chamberId != all4DSegments->id_end();
116 const DTChamber* chamber = dtGeom->chamber(*chamberId);
119 const vector<const DTSuperLayer*> SLayers = chamber->
superLayers();
120 map<DTWireId, int> wireAnd1DRecHits;
121 for(vector<const DTSuperLayer*>::const_iterator superlayer = SLayers.begin();
122 superlayer != SLayers.end();
127 rechit!=range.second;
129 wireAnd1DRecHits[(*rechit).wireId()] = (*rechit).wireId().wire();
136 int nsegm = distance(range.first, range.second);
138 cout <<
" Chamber: " << *chamberId <<
" has " << nsegm
139 <<
" 4D segments" << endl;
144 segment4D!=range.second;
147 cout <<
" == RecSegment dimension: " << (*segment4D).dimension() << endl;
151 if((*chamberId).station() != 4 && (*segment4D).dimension() != 4) {
153 cout <<
"[DTEfficiencyTask]***Warning: RecSegment dimension is not 4 but "
154 << (*segment4D).dimension() <<
", skipping!" << endl;
156 }
else if((*chamberId).station() == 4 && (*segment4D).dimension() != 2) {
158 cout <<
"[DTEfficiencyTask]***Warning: RecSegment dimension is not 2 but "
159 << (*segment4D).dimension() <<
", skipping!" << endl;
163 vector<DTRecHit1D> recHits1D;
171 if(phiRecHits.size() < 7 || phiRecHits.size() > 8 ) {
173 cout <<
"[DTEfficiencyTask] Phi segments has: " << phiRecHits.size()
174 <<
" hits, skipping" << endl;
177 copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D));
179 if((*segment4D).dimension() == 4) {
181 zSeg = (*segment4D).zSegment();
183 if(zRecHits.size() < 3 || zRecHits.size() > 4 ) {
185 cout <<
"[DTEfficiencyTask] Theta segments has: " << zRecHits.size()
186 <<
" hits, skipping" << endl;
189 copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D));
193 vector<DTWireId> wireMap;
194 for(vector<DTRecHit1D>::const_iterator recHit1D = recHits1D.begin();
195 recHit1D != recHits1D.end();
197 wireMap.push_back((*recHit1D).wireId());
200 bool hitsOnSameLayer =
false;
201 for(vector<DTWireId>::const_iterator channelId = wireMap.begin();
202 channelId != wireMap.end(); channelId++) {
203 vector<DTWireId>::const_iterator next = channelId;
205 for(vector<DTWireId>::const_iterator ite = next; ite != wireMap.end(); ite++) {
206 if((*channelId).layerId() == (*ite).layerId()) {
207 hitsOnSameLayer =
true;
211 if(hitsOnSameLayer) {
213 cout <<
"[DTEfficiencyTask] This RecHit has 2 hits on the same layer, skipping!" << endl;
219 LocalVector phiDirectionInChamber = (*phiSeg).localDirection();
220 if(rPhi && fabs(phiDirectionInChamber.
x()/phiDirectionInChamber.
z()) > 1) {
222 cout <<
" RPhi segment has angle > 45 deg, skipping! " << endl;
223 cout <<
" Theta = " << phiDirectionInChamber.
theta() << endl;
228 LocalVector zDirectionInChamber = (*zSeg).localDirection();
229 if(fabs(zDirectionInChamber.
y()/zDirectionInChamber.
z()) > 1) {
231 cout <<
" RZ segment has angle > 45 deg, skipping! " << endl;
232 cout <<
" Theta = " << zDirectionInChamber.
theta() << endl;
240 if(recHits1D.size() == 10) {
242 cout <<
"[DTEfficiencyTask] 4D Segment with only 10 hits, skipping!" << endl;
248 if((rPhi && recHits1D.size() == 7) || (rZ && recHits1D.size() == 11)) {
251 if(rPhi && recHits1D.size() == 7)
252 cout <<
"[DTEfficiencyTask] MB4 Segment with only 7 hits!" << endl;
253 if(rZ && recHits1D.size() == 11)
254 cout <<
"[DTEfficiencyTask] 4D Segment with only 11 hits!" << endl;
258 const vector<const DTSuperLayer*> SupLayers = chamber->
superLayers();
259 map<DTLayerId, bool> layerMap;
260 map<DTWireId, float> wireAndPosInChamberAtLayerZ;
262 for(vector<const DTSuperLayer*>::const_iterator superlayer = SupLayers.begin();
263 superlayer != SupLayers.end();
265 const vector<const DTLayer*> Layers = (*superlayer)->layers();
266 for(vector<const DTLayer*>::const_iterator layer = Layers.begin();
267 layer != Layers.end();
269 layerMap.insert(make_pair((*layer)->id(),
false));
270 const int firstWire = dtGeom->layer((*layer)->id())->specificTopology().firstChannel();
271 const int lastWire = dtGeom->layer((*layer)->id())->specificTopology().lastChannel();
272 for(
int i=firstWire;
i - lastWire <= 0;
i++) {
274 float wireX = (*layer)->specificTopology().wirePosition(wireId.wire());
276 GlobalPoint wirePosGlob = (*layer)->toGlobal(wirePosInLay);
278 if((*superlayer)->id().superlayer() == 1 || (*superlayer)->id().superlayer() == 3) {
279 wireAndPosInChamberAtLayerZ.insert(make_pair(wireId, wirePosInChamber.
x()));
281 wireAndPosInChamberAtLayerZ.insert(make_pair(wireId, wirePosInChamber.
y()));
288 map<DTLayerId, int> NumWireMap;
289 for(vector<DTRecHit1D>::const_iterator recHit = recHits1D.begin();
290 recHit != recHits1D.end();
292 layerMap[(*recHit).wireId().layerId()]=
true;
293 NumWireMap[(*recHit).wireId().layerId()]= (*recHit).wireId().wire();
298 for(map<DTLayerId, bool>::const_iterator iter = layerMap.begin();
299 iter != layerMap.end(); iter++) {
300 if(!(*iter).second) missLayerId = (*iter).first;
303 cout <<
"[DTEfficiencyTask] Layer without recHits is: " << missLayerId << endl;
313 LocalPoint segPosAtZLayer = (*segment4D).localPosition()
314 + (*segment4D).localDirection()*missLayerPosInChamber.
z()/
cos((*segment4D).localDirection().theta());
319 for(map<DTWireId, float>::const_iterator wireAndPos = wireAndPosInChamberAtLayerZ.begin();
320 wireAndPos != wireAndPosInChamberAtLayerZ.end();
322 DTWireId wireId = (*wireAndPos).first;
323 if(wireId.
layerId() == missLayerId) {
325 if(fabs(segPosAtZLayer.
x() - (*wireAndPos).second) < 2.1)
328 if(fabs(segPosAtZLayer.
y() - (*wireAndPos).second) < 2.1)
334 cout <<
"[DTEfficiencyTask] Cell without hit is: " << missWireId << endl;
338 bool foundUnAssRechit =
false;
341 if(wireAnd1DRecHits.find(missWireId) != wireAnd1DRecHits.end()) {
343 cout <<
"[DTEfficiencyTask] Unassociated Hit found!" << endl;
344 foundUnAssRechit =
true;
348 for(map<DTLayerId, bool>::const_iterator iter = layerMap.begin();
349 iter != layerMap.end(); iter++) {
351 fillHistos((*iter).first, dtGeom->layer((*iter).first)->specificTopology().firstChannel(), dtGeom->layer((*iter).first)->specificTopology().lastChannel(), NumWireMap[(*iter).first]);
353 fillHistos((*iter).first, dtGeom->layer((*iter).first)->specificTopology().firstChannel(), dtGeom->layer((*iter).first)->specificTopology().lastChannel(), missWireId.wire(), foundUnAssRechit);
358 if((rPhi && recHits1D.size() == 8) || (rZ && recHits1D.size() == 12)) {
359 map<DTLayerId, int> NumWireMap;
361 for(vector<DTRecHit1D>::const_iterator recHit = recHits1D.begin();
362 recHit != recHits1D.end();
364 LayerID = (*recHit).wireId().layerId();
365 NumWireMap[LayerID]= (*recHit).wireId().wire();
367 for(map<DTLayerId, int>::const_iterator iter = NumWireMap.begin();
368 iter != NumWireMap.end(); iter++) {
369 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
std::string theRecHitLabel
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
C::const_iterator const_iterator
constant access iterator type
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)
std::string theRecHits4DLabel
DTLayerId layerId() const
Return the corresponding LayerId.