43 recHits4DToken_ = consumes<DTRecSegment4DCollection>(
46 recHitToken_ = consumes<DTRecHitCollection>(
51 theDbe->setCurrentFolder(
"DT/DTEfficiencyTask");
69 for(
map<
DTLayerId, vector<MonitorElement*> > ::const_iterator
histo = histosPerL.begin();
70 histo != histosPerL.end();
72 int size = (*histo).second.size();
74 (*histo).second[
i]->Reset();
83 theDbe->rmdir(
"DT/DTEfficiencyTask");
91 cout <<
"[DTEfficiencyTask] Analyze #Run: " <<
event.id().run()
92 <<
" #Event: " <<
event.id().event() << endl;
97 event.getByToken(recHits4DToken_, all4DSegments);
101 event.getByToken(recHitToken_, dtRecHits);
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();
297 iter != layerMap.end(); iter++) {
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();
347 iter != layerMap.end(); iter++) {
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();
366 iter != NumWireMap.end(); iter++) {
367 fillHistos((*iter).first, dtGeom->layer((*iter).first)->specificTopology().firstChannel(), dtGeom->layer((*iter).first)->specificTopology().lastChannel(), NumWireMap[(*iter).first]);
379 cout <<
" Booking histos for L: " << lId << endl;
386 stringstream layer; layer << lId.
layer();
390 "_St" + station.str() +
391 "_Sec" + sector.str() +
392 "_SL" + superLayer.str()+
395 theDbe->setCurrentFolder(
"DT/DTEfficiencyTask/Wheel" + wheel.str() +
396 "/Station" + station.str() +
397 "/Sector" + sector.str() +
398 "/SuperLayer" +superLayer.str());
400 vector<MonitorElement *>
histos;
402 histos.push_back(theDbe->book1D(
"hEffOccupancy"+lHistoName,
"4D segments recHits occupancy",lastWire-firstWire+1, firstWire-0.5, lastWire+0.5));
404 histos.push_back(theDbe->book1D(
"hEffUnassOccupancy"+lHistoName,
"4D segments recHits and Hits not associated occupancy",lastWire-firstWire+1, firstWire-0.5, lastWire+0.5));
406 histos.push_back(theDbe->book1D(
"hRecSegmOccupancy"+lHistoName,
"4D segments cells occupancy",lastWire-firstWire+1, firstWire-0.5, lastWire+0.5));
414 int firstWire,
int lastWire,
416 if(histosPerL.find(lId) == histosPerL.end()){
419 vector<MonitorElement *>
histos = histosPerL[lId];
420 histos[0]->Fill(numWire);
421 histos[1]->Fill(numWire);
422 histos[2]->Fill(numWire);
427 int firstWire,
int lastWire,
430 if(histosPerL.find(lId) == histosPerL.end()){
433 vector<MonitorElement *>
histos = histosPerL[lId];
435 histos[1]->Fill(missingWire);
436 histos[2]->Fill(missingWire);
LuminosityBlockID id() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::pair< const_iterator, const_iterator > range
iterator range
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
To reset the MEs.
DTChamberId chamberId() const
Return the corresponding ChamberId.
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.
int layer() const
Return the layer number.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
void fillHistos(DTLayerId lId, int firstWire, int lastWire, int numWire)
Geom::Theta< T > theta() const
const std::vector< const DTSuperLayer * > & superLayers() const
Return the superlayers in the chamber.
Cos< T >::type cos(const T &t)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void bookHistos(DTLayerId lId, int fisrtWire, int lastWire)
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
virtual ~DTEfficiencyTask()
Destructor.
int superlayer() const
Return the superlayer number (deprecated method name)
void analyze(const edm::Event &event, const edm::EventSetup &setup)
LuminosityBlockNumber_t luminosityBlock() const
DTLayerId layerId() const
Return the corresponding LayerId.
DTEfficiencyTask(const edm::ParameterSet &pset)
Constructor.
int station() const
Return the station number.
int wheel() const
Return the wheel number.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.