41 recHits4DToken_ = consumes<DTRecSegment4DCollection>(
44 recHitToken_ = consumes<DTRecHitCollection>(
66 cout<<
"[DTTestPulseTask]: booking"<<endl;
72 vector<const DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
73 vector<const DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
75 for (; ch_it != ch_end; ++ch_it) {
78 vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
79 vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
81 for(; sl_it != sl_end; ++sl_it) {
83 stringstream superLayer; superLayer << sl.
superlayer();
86 vector<const DTLayer*>::const_iterator l_it = (*sl_it)->layers().begin();
87 vector<const DTLayer*>::const_iterator l_end = (*sl_it)->layers().end();
89 for(; l_it != l_end; ++l_it) {
92 if(
debug)
cout <<
" Booking histos for L: " << layerId << endl;
95 stringstream layer; layer << layerId.
layer();
96 stringstream superLayer; superLayer << layerId.
superlayer();
101 const int firstWire = (*l_it)->specificTopology().firstChannel();
102 const int lastWire = (*l_it)->specificTopology().lastChannel();
106 "_St" + station.str() +
107 "_Sec" + sector.str() +
108 "_SL" + superLayer.str()+
112 "/Station" + station.str() +
113 "/Sector" + sector.str() +
114 "/SuperLayer" +superLayer.str());
118 vector<MonitorElement *>
histos;
120 histos.push_back(ibooker.
book1D(
121 "hEffOccupancy"+lHistoName,
"4D segments recHits occupancy",lastWire-firstWire+1, firstWire-0.5, lastWire+0.5));
123 histos.push_back(ibooker.
book1D(
124 "hEffUnassOccupancy"+lHistoName,
"4D segments recHits and Hits not associated occupancy",
125 lastWire-firstWire+1, firstWire-0.5, lastWire+0.5));
127 histos.push_back(ibooker.
book1D(
128 "hRecSegmOccupancy"+lHistoName,
"4D segments cells occupancy",lastWire-firstWire+1, firstWire-0.5, lastWire+0.5));
130 histosPerL[layerId] =
histos;
141 for(
map<
DTLayerId, vector<MonitorElement*> > ::const_iterator
histo = histosPerL.begin();
142 histo != histosPerL.end();
144 int size = (*histo).second.size();
146 (*histo).second[
i]->Reset();
157 cout <<
"[DTEfficiencyTask] Analyze #Run: " <<
event.id().run()
158 <<
" #Event: " <<
event.id().event() << endl;
163 event.getByToken(recHits4DToken_, all4DSegments);
167 event.getByToken(recHitToken_, dtRecHits);
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++) {
441 int firstWire,
int lastWire,
444 vector<MonitorElement *>
histos = histosPerL[lId];
445 histos[0]->Fill(numWire);
446 histos[1]->Fill(numWire);
447 histos[2]->Fill(numWire);
452 int firstWire,
int lastWire,
456 vector<MonitorElement *>
histos = histosPerL[lId];
458 histos[1]->Fill(missingWire);
459 histos[2]->Fill(missingWire);
LuminosityBlockID id() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
BeginRun.
std::pair< const_iterator, const_iterator > range
iterator range
const DTLayer * layer(const DTLayerId &id) const
Return the layer corresponding to the given id.
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context) override
To reset the MEs.
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
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.
def setup(process, global_tag, zero_tesla=False)
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
int layer() const
Return the layer number.
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
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)
MonitorElement * book1D(Args &&...args)
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
virtual ~DTEfficiencyTask()
Destructor.
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
int superlayer() const
Return the superlayer number (deprecated method name)
void setCurrentFolder(const std::string &fullpath)
LuminosityBlockNumber_t luminosityBlock() const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
DTLayerId layerId() const
Return the corresponding LayerId.
DTEfficiencyTask(const edm::ParameterSet &pset)
Constructor.
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
int station() const
Return the station number.
int wheel() const
Return the wheel number.