35 debug =
pset.getUntrackedParameter<
bool>(
"debug",
false);
56 cout <<
"[DTTestPulseTask]: booking" << endl;
61 vector<const DTChamber*>::const_iterator ch_it =
muonGeom->
chambers().begin();
62 vector<const DTChamber*>::const_iterator ch_end =
muonGeom->
chambers().end();
64 for (; ch_it != ch_end; ++ch_it) {
66 vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
67 vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
69 for (; sl_it != sl_end; ++sl_it) {
71 stringstream superLayer;
75 vector<const DTLayer*>::const_iterator l_it = (*sl_it)->layers().begin();
76 vector<const DTLayer*>::const_iterator l_end = (*sl_it)->layers().end();
78 for (; l_it != l_end; ++l_it) {
81 cout <<
" Booking histos for L: " << layerId << endl;
86 stringstream superLayer;
95 const int firstWire = (*l_it)->specificTopology().firstChannel();
96 const int lastWire = (*l_it)->specificTopology().lastChannel();
98 string lHistoName =
"_W" +
wheel.str() +
"_St" +
station.str() +
"_Sec" + sector.str() +
"_SL" +
99 superLayer.str() +
"_L" +
layer.str();
102 sector.str() +
"/SuperLayer" + superLayer.str());
105 vector<MonitorElement*>
histos;
107 histos.push_back(ibooker.
book1D(
"hEffOccupancy" + lHistoName,
108 "4D segments recHits occupancy",
109 lastWire - firstWire + 1,
113 histos.push_back(ibooker.
book1D(
"hEffUnassOccupancy" + lHistoName,
114 "4D segments recHits and Hits not associated occupancy",
115 lastWire - firstWire + 1,
119 histos.push_back(ibooker.
book1D(
"hRecSegmOccupancy" + lHistoName,
120 "4D segments cells occupancy",
121 lastWire - firstWire + 1,
136 int size = (*histo).second.size();
137 for (
int i = 0;
i <
size;
i++) {
138 (*histo).second[
i]->Reset();
146 cout <<
"[DTEfficiencyTask] Analyze #Run: " <<
event.id().run() <<
" #Event: " <<
event.id().event() << endl;
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();
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++) {
377 NumWireMap[(*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++) {
399 NumWireMap[(*iter).first]);
419 histos[1]->Fill(missingWire);
420 histos[2]->Fill(missingWire);
int station() const
Return the station number.
LuminosityBlockNumber_t luminosityBlock() const
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
BeginRun.
std::pair< const_iterator, const_iterator > range
iterator range
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context) override
To reset the MEs.
virtual void setCurrentFolder(std::string const &fullpath)
static std::pair< DTLayerId, DTSuperLayerIdComparator > layersBySuperLayer(DTSuperLayerId slId)
Access by SL objects written into a RangeMap by layer.
std::map< DTLayerId, std::vector< MonitorElement * > > histosPerL
void fillHistos(DTLayerId lId, int firstWire, int lastWire, int numWire)
constexpr std::array< uint8_t, layerIndexSize > layer
T getUntrackedParameter(std::string const &, T const &) const
int firstChannel() const
Returns the wire number of the first wire.
edm::EDGetTokenT< DTRecHitCollection > recHitToken_
edm::EDGetTokenT< DTRecSegment4DCollection > recHits4DToken_
C::const_iterator const_iterator
constant access iterator type
DTChamberId chamberId() const
Return the corresponding ChamberId.
Cos< T >::type cos(const T &t)
const DTGeometry * dtGeom
const DTTopology & specificTopology() const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
~DTEfficiencyTask() override
Destructor.
int superlayer() const
Return the superlayer number (deprecated method name)
LuminosityBlockID id() const
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
int layer() const
Return the layer number.
const DTGeometry * muonGeom
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
DTEfficiencyTask(const edm::ParameterSet &pset)
Constructor.
int wheel() const
Return the wheel number.
int lastChannel() const
Returns the wire number of the last wire.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
DTLayerId layerId() const
Return the corresponding LayerId.
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Geom::Theta< T > theta() const
edm::ParameterSet parameters
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.