55 cout <<
"[DTTestPulseTask]: booking" << endl;
60 vector<const DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
61 vector<const DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
63 for (; ch_it != ch_end; ++ch_it) {
65 vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
66 vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
68 for (; sl_it != sl_end; ++sl_it) {
70 stringstream superLayer;
74 vector<const DTLayer*>::const_iterator l_it = (*sl_it)->layers().begin();
75 vector<const DTLayer*>::const_iterator l_end = (*sl_it)->layers().end();
77 for (; l_it != l_end; ++l_it) {
80 cout <<
" Booking histos for L: " << layerId << endl;
84 layer << layerId.
layer();
85 stringstream superLayer;
94 const int firstWire = (*l_it)->specificTopology().firstChannel();
95 const int lastWire = (*l_it)->specificTopology().lastChannel();
97 string lHistoName =
"_W" + wheel.str() +
"_St" + station.str() +
"_Sec" + sector.str() +
"_SL" +
98 superLayer.str() +
"_L" + layer.str();
100 ibooker.
setCurrentFolder(
"DT/DTEfficiencyTask/Wheel" + wheel.str() +
"/Station" + station.str() +
"/Sector" +
101 sector.str() +
"/SuperLayer" + superLayer.str());
104 vector<MonitorElement*>
histos;
106 histos.push_back(ibooker.
book1D(
"hEffOccupancy" + lHistoName,
107 "4D segments recHits occupancy",
108 lastWire - firstWire + 1,
112 histos.push_back(ibooker.
book1D(
"hEffUnassOccupancy" + lHistoName,
113 "4D segments recHits and Hits not associated occupancy",
114 lastWire - firstWire + 1,
118 histos.push_back(ibooker.
book1D(
"hRecSegmOccupancy" + lHistoName,
119 "4D segments cells occupancy",
120 lastWire - firstWire + 1,
124 histosPerL[layerId] =
histos;
133 for (
map<
DTLayerId, vector<MonitorElement*> >::const_iterator
histo = histosPerL.begin();
histo != histosPerL.end();
135 int size = (*histo).second.size();
136 for (
int i = 0;
i <
size;
i++) {
137 (*histo).second[
i]->Reset();
145 cout <<
"[DTEfficiencyTask] Analyze #Run: " <<
event.id().run() <<
" #Event: " <<
event.id().event() << endl;
149 event.getByToken(recHits4DToken_, all4DSegments);
153 event.getByToken(recHitToken_, dtRecHits);
161 for (chamberId = all4DSegments->id_begin(); chamberId != all4DSegments->id_end(); ++chamberId) {
166 const vector<const DTSuperLayer*>& SLayers = chamber->
superLayers();
167 map<DTWireId, int> wireAnd1DRecHits;
168 for (vector<const DTSuperLayer*>::const_iterator superlayer = SLayers.begin(); superlayer != SLayers.end();
173 wireAnd1DRecHits[(*rechit).wireId()] = (*rechit).wireId().wire();
179 int nsegm =
distance(range.first, range.second);
181 cout <<
" Chamber: " << *chamberId <<
" has " << nsegm <<
" 4D segments" << endl;
186 cout <<
" == RecSegment dimension: " << (*segment4D).dimension() << endl;
190 if ((*chamberId).station() != 4 && (*segment4D).dimension() != 4) {
192 cout <<
"[DTEfficiencyTask]***Warning: RecSegment dimension is not 4 but " << (*segment4D).dimension()
193 <<
", skipping!" << endl;
195 }
else if ((*chamberId).station() == 4 && (*segment4D).dimension() != 2) {
197 cout <<
"[DTEfficiencyTask]***Warning: RecSegment dimension is not 2 but " << (*segment4D).dimension()
198 <<
", skipping!" << endl;
202 vector<DTRecHit1D> recHits1D;
210 if (phiRecHits.size() < 7 || phiRecHits.size() > 8) {
212 cout <<
"[DTEfficiencyTask] Phi segments has: " << phiRecHits.size() <<
" hits, skipping" 216 copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D));
218 if ((*segment4D).dimension() == 4) {
220 zSeg = (*segment4D).zSegment();
222 if (zRecHits.size() < 3 || zRecHits.size() > 4) {
224 cout <<
"[DTEfficiencyTask] Theta segments has: " << zRecHits.size() <<
" hits, skipping" 228 copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D));
232 vector<DTWireId> wireMap;
233 for (vector<DTRecHit1D>::const_iterator recHit1D = recHits1D.begin(); recHit1D != recHits1D.end(); recHit1D++) {
234 wireMap.push_back((*recHit1D).wireId());
237 bool hitsOnSameLayer =
false;
238 for (vector<DTWireId>::const_iterator channelId = wireMap.begin(); channelId != wireMap.end(); channelId++) {
239 vector<DTWireId>::const_iterator
next = channelId;
241 for (vector<DTWireId>::const_iterator ite = next; ite != wireMap.end(); ite++) {
242 if ((*channelId).layerId() == (*ite).layerId()) {
243 hitsOnSameLayer =
true;
247 if (hitsOnSameLayer) {
249 cout <<
"[DTEfficiencyTask] This RecHit has 2 hits on the same layer, skipping!" << endl;
254 LocalVector phiDirectionInChamber = (*phiSeg).localDirection();
255 if (rPhi && fabs(phiDirectionInChamber.
x() / phiDirectionInChamber.
z()) > 1) {
257 cout <<
" RPhi segment has angle > 45 deg, skipping! " << endl;
258 cout <<
" Theta = " << phiDirectionInChamber.
theta() << endl;
263 LocalVector zDirectionInChamber = (*zSeg).localDirection();
264 if (fabs(zDirectionInChamber.
y() / zDirectionInChamber.
z()) > 1) {
266 cout <<
" RZ segment has angle > 45 deg, skipping! " << endl;
267 cout <<
" Theta = " << zDirectionInChamber.
theta() << endl;
274 if (recHits1D.size() == 10) {
276 cout <<
"[DTEfficiencyTask] 4D Segment with only 10 hits, skipping!" << endl;
281 if ((rPhi && recHits1D.size() == 7) || (rZ && recHits1D.size() == 11)) {
283 if (rPhi && recHits1D.size() == 7)
284 cout <<
"[DTEfficiencyTask] MB4 Segment with only 7 hits!" << endl;
285 if (rZ && recHits1D.size() == 11)
286 cout <<
"[DTEfficiencyTask] 4D Segment with only 11 hits!" << endl;
290 const vector<const DTSuperLayer*>& SupLayers = chamber->
superLayers();
291 map<DTLayerId, bool> layerMap;
292 map<DTWireId, float> wireAndPosInChamberAtLayerZ;
294 for (vector<const DTSuperLayer*>::const_iterator superlayer = SupLayers.begin(); superlayer != SupLayers.end();
296 const vector<const DTLayer*> Layers = (*superlayer)->layers();
297 for (vector<const DTLayer*>::const_iterator layer = Layers.begin(); layer != Layers.end(); layer++) {
298 layerMap.insert(make_pair((*layer)->id(),
false));
299 const int firstWire = dtGeom->
layer((*layer)->id())->specificTopology().firstChannel();
300 const int lastWire = dtGeom->
layer((*layer)->id())->specificTopology().lastChannel();
301 for (
int i = firstWire;
i - lastWire <= 0;
i++) {
303 float wireX = (*layer)->specificTopology().wirePosition(wireId.wire());
305 GlobalPoint wirePosGlob = (*layer)->toGlobal(wirePosInLay);
307 if ((*superlayer)->id().superlayer() == 1 || (*superlayer)->id().superlayer() == 3) {
308 wireAndPosInChamberAtLayerZ.insert(make_pair(wireId, wirePosInChamber.
x()));
310 wireAndPosInChamberAtLayerZ.insert(make_pair(wireId, wirePosInChamber.
y()));
317 map<DTLayerId, int> NumWireMap;
318 for (vector<DTRecHit1D>::const_iterator
recHit = recHits1D.begin();
recHit != recHits1D.end();
recHit++) {
319 layerMap[(*recHit).wireId().layerId()] =
true;
320 NumWireMap[(*recHit).wireId().layerId()] = (*recHit).wireId().wire();
325 for (map<DTLayerId, bool>::const_iterator iter = layerMap.begin(); iter != layerMap.end(); iter++) {
327 missLayerId = (*iter).first;
330 cout <<
"[DTEfficiencyTask] Layer without recHits is: " << missLayerId << endl;
338 LocalPoint segPosAtZLayer = (*segment4D).localPosition() + (*segment4D).localDirection() *
339 missLayerPosInChamber.
z() /
340 cos((*segment4D).localDirection().theta());
345 for (map<DTWireId, float>::const_iterator wireAndPos = wireAndPosInChamberAtLayerZ.begin();
346 wireAndPos != wireAndPosInChamberAtLayerZ.end();
348 DTWireId wireId = (*wireAndPos).first;
349 if (wireId.
layerId() == missLayerId) {
351 if (fabs(segPosAtZLayer.
x() - (*wireAndPos).second) < 2.1)
354 if (fabs(segPosAtZLayer.
y() - (*wireAndPos).second) < 2.1)
360 cout <<
"[DTEfficiencyTask] Cell without hit is: " << missWireId << endl;
363 bool foundUnAssRechit =
false;
366 if (wireAnd1DRecHits.find(missWireId) != wireAnd1DRecHits.end()) {
368 cout <<
"[DTEfficiencyTask] Unassociated Hit found!" << endl;
369 foundUnAssRechit =
true;
372 for (map<DTLayerId, bool>::const_iterator iter = layerMap.begin(); iter != layerMap.end(); iter++) {
374 fillHistos((*iter).first,
377 NumWireMap[(*iter).first]);
379 fillHistos((*iter).first,
388 if ((rPhi && recHits1D.size() == 8) || (rZ && recHits1D.size() == 12)) {
389 map<DTLayerId, int> NumWireMap;
391 for (vector<DTRecHit1D>::const_iterator
recHit = recHits1D.begin();
recHit != recHits1D.end();
recHit++) {
392 LayerID = (*recHit).wireId().layerId();
393 NumWireMap[LayerID] = (*recHit).wireId().wire();
395 for (map<DTLayerId, int>::const_iterator iter = NumWireMap.begin(); iter != NumWireMap.end(); iter++) {
396 fillHistos((*iter).first,
399 NumWireMap[(*iter).first]);
409 vector<MonitorElement*>
histos = histosPerL[lId];
410 histos[0]->Fill(numWire);
411 histos[1]->Fill(numWire);
412 histos[2]->Fill(numWire);
417 vector<MonitorElement*>
histos = histosPerL[lId];
419 histos[1]->Fill(missingWire);
420 histos[2]->Fill(missingWire);
LuminosityBlockID id() const
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
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.
void setCurrentFolder(std::string const &fullpath)
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.
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.
C::const_iterator const_iterator
constant access iterator type
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.
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
int superlayer() const
Return the superlayer number (deprecated method name)
~DTEfficiencyTask() override
Destructor.
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.