35 debug =
pset.getUntrackedParameter<
bool>(
"debug",
false);
38 consumes<DTRecSegment4DCollection>(
edm::InputTag(
pset.getUntrackedParameter<
string>(
"recHits4DLabel")));
57 cout <<
"[DTTestPulseTask]: booking" << endl;
62 vector<const DTChamber*>::const_iterator ch_it =
muonGeom->
chambers().begin();
63 vector<const DTChamber*>::const_iterator ch_end =
muonGeom->
chambers().end();
65 for (; ch_it != ch_end; ++ch_it) {
67 vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
68 vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
70 for (; sl_it != sl_end; ++sl_it) {
72 stringstream superLayer;
76 vector<const DTLayer*>::const_iterator l_it = (*sl_it)->layers().begin();
77 vector<const DTLayer*>::const_iterator l_end = (*sl_it)->layers().end();
79 for (; l_it != l_end; ++l_it) {
82 cout <<
" Booking histos for L: " << layerId << endl;
87 stringstream superLayer;
96 const int firstWire = (*l_it)->specificTopology().firstChannel();
97 const int lastWire = (*l_it)->specificTopology().lastChannel();
99 string lHistoName =
"_W" +
wheel.str() +
"_St" +
station.str() +
"_Sec" +
sector.str() +
"_SL" +
100 superLayer.str() +
"_L" +
layer.str();
103 sector.str() +
"/SuperLayer" + superLayer.str());
106 vector<MonitorElement*>
histos;
108 histos.push_back(ibooker.
book1D(
"hEffOccupancy" + lHistoName,
109 "4D segments recHits occupancy",
110 lastWire - firstWire + 1,
114 histos.push_back(ibooker.
book1D(
"hEffUnassOccupancy" + lHistoName,
115 "4D segments recHits and Hits not associated occupancy",
116 lastWire - firstWire + 1,
120 histos.push_back(ibooker.
book1D(
"hRecSegmOccupancy" + lHistoName,
121 "4D segments cells occupancy",
122 lastWire - firstWire + 1,
137 int size = (*histo).second.size();
138 for (
int i = 0;
i <
size;
i++) {
139 (*histo).second[
i]->Reset();
147 cout <<
"[DTEfficiencyTask] Analyze #Run: " <<
event.id().run() <<
" #Event: " <<
event.id().event() << endl;
162 for (chamberId = all4DSegments->id_begin(); chamberId != all4DSegments->id_end(); ++chamberId) {
167 const vector<const DTSuperLayer*>& SLayers =
chamber->superLayers();
168 map<DTWireId, int> wireAnd1DRecHits;
169 for (vector<const DTSuperLayer*>::const_iterator superlayer = SLayers.begin(); superlayer != SLayers.end();
174 wireAnd1DRecHits[(*rechit).wireId()] = (*rechit).wireId().wire();
182 cout <<
" Chamber: " << *chamberId <<
" has " << nsegm <<
" 4D segments" << endl;
187 cout <<
" == RecSegment dimension: " << (*segment4D).dimension() << endl;
191 if ((*chamberId).station() != 4 && (*segment4D).dimension() != 4) {
193 cout <<
"[DTEfficiencyTask]***Warning: RecSegment dimension is not 4 but " << (*segment4D).dimension()
194 <<
", skipping!" << endl;
196 }
else if ((*chamberId).station() == 4 && (*segment4D).dimension() != 2) {
198 cout <<
"[DTEfficiencyTask]***Warning: RecSegment dimension is not 2 but " << (*segment4D).dimension()
199 <<
", skipping!" << endl;
203 vector<DTRecHit1D> recHits1D;
211 if (phiRecHits.size() < 7 || phiRecHits.size() > 8) {
213 cout <<
"[DTEfficiencyTask] Phi segments has: " << phiRecHits.size() <<
" hits, skipping" 217 copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D));
219 if ((*segment4D).dimension() == 4) {
221 zSeg = (*segment4D).zSegment();
223 if (zRecHits.size() < 3 || zRecHits.size() > 4) {
225 cout <<
"[DTEfficiencyTask] Theta segments has: " << zRecHits.size() <<
" hits, skipping" 229 copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D));
233 vector<DTWireId> wireMap;
234 for (vector<DTRecHit1D>::const_iterator recHit1D = recHits1D.begin(); recHit1D != recHits1D.end(); recHit1D++) {
235 wireMap.push_back((*recHit1D).wireId());
238 bool hitsOnSameLayer =
false;
242 for (vector<DTWireId>::const_iterator ite =
next; ite != wireMap.end(); ite++) {
243 if ((*channelId).layerId() == (*ite).layerId()) {
244 hitsOnSameLayer =
true;
248 if (hitsOnSameLayer) {
250 cout <<
"[DTEfficiencyTask] This RecHit has 2 hits on the same layer, skipping!" << endl;
255 LocalVector phiDirectionInChamber = (*phiSeg).localDirection();
256 if (rPhi && fabs(phiDirectionInChamber.
x() / phiDirectionInChamber.
z()) > 1) {
258 cout <<
" RPhi segment has angle > 45 deg, skipping! " << endl;
259 cout <<
" Theta = " << phiDirectionInChamber.
theta() << endl;
264 LocalVector zDirectionInChamber = (*zSeg).localDirection();
265 if (fabs(zDirectionInChamber.
y() / zDirectionInChamber.
z()) > 1) {
267 cout <<
" RZ segment has angle > 45 deg, skipping! " << endl;
268 cout <<
" Theta = " << zDirectionInChamber.
theta() << endl;
275 if (recHits1D.size() == 10) {
277 cout <<
"[DTEfficiencyTask] 4D Segment with only 10 hits, skipping!" << endl;
282 if ((rPhi && recHits1D.size() == 7) || (rZ && recHits1D.size() == 11)) {
284 if (rPhi && recHits1D.size() == 7)
285 cout <<
"[DTEfficiencyTask] MB4 Segment with only 7 hits!" << endl;
286 if (rZ && recHits1D.size() == 11)
287 cout <<
"[DTEfficiencyTask] 4D Segment with only 11 hits!" << endl;
291 const vector<const DTSuperLayer*>& SupLayers =
chamber->superLayers();
292 map<DTLayerId, bool> layerMap;
293 map<DTWireId, float> wireAndPosInChamberAtLayerZ;
295 for (vector<const DTSuperLayer*>::const_iterator superlayer = SupLayers.begin(); superlayer != SupLayers.end();
297 const vector<const DTLayer*> Layers = (*superlayer)->layers();
298 for (vector<const DTLayer*>::const_iterator
layer = Layers.begin();
layer != Layers.end();
layer++) {
299 layerMap.insert(make_pair((*layer)->id(),
false));
300 const int firstWire =
dtGeom->
layer((*layer)->id())->specificTopology().firstChannel();
301 const int lastWire =
dtGeom->
layer((*layer)->id())->specificTopology().lastChannel();
302 for (
int i = firstWire;
i - lastWire <= 0;
i++) {
304 float wireX = (*layer)->specificTopology().wirePosition(wireId.wire());
306 GlobalPoint wirePosGlob = (*layer)->toGlobal(wirePosInLay);
308 if ((*superlayer)->id().superlayer() == 1 || (*superlayer)->id().superlayer() == 3) {
309 wireAndPosInChamberAtLayerZ.insert(make_pair(wireId, wirePosInChamber.
x()));
311 wireAndPosInChamberAtLayerZ.insert(make_pair(wireId, wirePosInChamber.
y()));
318 map<DTLayerId, int> NumWireMap;
319 for (vector<DTRecHit1D>::const_iterator
recHit = recHits1D.begin();
recHit != recHits1D.end();
recHit++) {
320 layerMap[(*recHit).wireId().layerId()] =
true;
321 NumWireMap[(*recHit).wireId().layerId()] = (*recHit).wireId().wire();
326 for (map<DTLayerId, bool>::const_iterator iter = layerMap.begin(); iter != layerMap.end(); iter++) {
328 missLayerId = (*iter).first;
331 cout <<
"[DTEfficiencyTask] Layer without recHits is: " << missLayerId << endl;
339 LocalPoint segPosAtZLayer = (*segment4D).localPosition() + (*segment4D).localDirection() *
340 missLayerPosInChamber.
z() /
341 cos((*segment4D).localDirection().theta());
346 for (map<DTWireId, float>::const_iterator wireAndPos = wireAndPosInChamberAtLayerZ.begin();
347 wireAndPos != wireAndPosInChamberAtLayerZ.end();
349 DTWireId wireId = (*wireAndPos).first;
350 if (wireId.
layerId() == missLayerId) {
352 if (fabs(segPosAtZLayer.
x() - (*wireAndPos).second) < 2.1)
355 if (fabs(segPosAtZLayer.
y() - (*wireAndPos).second) < 2.1)
361 cout <<
"[DTEfficiencyTask] Cell without hit is: " << missWireId << endl;
364 bool foundUnAssRechit =
false;
367 if (wireAnd1DRecHits.find(missWireId) != wireAnd1DRecHits.end()) {
369 cout <<
"[DTEfficiencyTask] Unassociated Hit found!" << endl;
370 foundUnAssRechit =
true;
373 for (map<DTLayerId, bool>::const_iterator iter = layerMap.begin(); iter != layerMap.end(); iter++) {
378 NumWireMap[(*iter).first]);
389 if ((rPhi && recHits1D.size() == 8) || (rZ && recHits1D.size() == 12)) {
390 map<DTLayerId, int> NumWireMap;
392 for (vector<DTRecHit1D>::const_iterator
recHit = recHits1D.begin();
recHit != recHits1D.end();
recHit++) {
393 LayerID = (*recHit).wireId().layerId();
394 NumWireMap[LayerID] = (*recHit).wireId().wire();
396 for (map<DTLayerId, int>::const_iterator iter = NumWireMap.begin(); iter != NumWireMap.end(); iter++) {
400 NumWireMap[(*iter).first]);
420 histos[1]->Fill(missingWire);
421 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)
T getUntrackedParameter(std::string const &, T const &) const
int firstChannel() const
Returns the wire number of the first wire.
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
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.
uint8_t channelId(const VFATFrame &frame)
retrieve this channel identifier
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.