CMS 3D CMS Logo

DTSegmentsTask.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author G. Mila - INFN Torino
5  */
6 
8 
9 // Framework
15 
17 
18 //Geometry
21 
22 #include <iterator>
23 
24 using namespace edm;
25 using namespace std;
26 
28  : statusMapToken_(esConsumes<DTStatusFlag, DTStatusFlagRcd>()) {
29  debug = pset.getUntrackedParameter<bool>("debug", false);
30  parameters = pset;
31 
32  // should be init from pset, but it was commented out...
33  // better false than undefined
34  checkNoisyChannels = false;
35 
36  // the name of the 4D rec hits collection
37  theRecHits4DLabel_ = consumes<DTRecSegment4DCollection>(parameters.getParameter<std::string>("recHits4DLabel"));
38 }
39 
41 
43  edm::Run const& /*iRun*/,
44  edm::EventSetup const& /* iSetup */) {
45  ibooker.cd();
46  ibooker.setCurrentFolder("Muons/DTSegmentsMonitor");
47 
48  // histos for phi segments
49  phiHistos.push_back(
50  ibooker.book2D("phiSegments_numHitsVsWheel", "phiSegments_numHitsVsWheel", 5, -2.5, 2.5, 20, 0, 20));
51  phiHistos[0]->setBinLabel(1, "W-2", 1);
52  phiHistos[0]->setBinLabel(2, "W-1", 1);
53  phiHistos[0]->setBinLabel(3, "W0", 1);
54  phiHistos[0]->setBinLabel(4, "W1", 1);
55  phiHistos[0]->setBinLabel(5, "W2", 1);
56  phiHistos.push_back(
57  ibooker.book2D("phiSegments_numHitsVsSector", "phiSegments_numHitsVsSector", 14, 0.5, 14.5, 20, 0, 20));
58  phiHistos[1]->setBinLabel(1, "Sec1", 1);
59  phiHistos[1]->setBinLabel(2, "Sec2", 1);
60  phiHistos[1]->setBinLabel(3, "Sec3", 1);
61  phiHistos[1]->setBinLabel(4, "Sec4", 1);
62  phiHistos[1]->setBinLabel(5, "Sec5", 1);
63  phiHistos[1]->setBinLabel(6, "Sec6", 1);
64  phiHistos[1]->setBinLabel(7, "Sec7", 1);
65  phiHistos[1]->setBinLabel(8, "Sec8", 1);
66  phiHistos[1]->setBinLabel(9, "Sec9", 1);
67  phiHistos[1]->setBinLabel(10, "Sec10", 1);
68  phiHistos[1]->setBinLabel(11, "Sec11", 1);
69  phiHistos[1]->setBinLabel(12, "Sec12", 1);
70  phiHistos[1]->setBinLabel(13, "Sec13", 1);
71  phiHistos[1]->setBinLabel(14, "Sec14", 1);
72  phiHistos.push_back(
73  ibooker.book2D("phiSegments_numHitsVsStation", "phiSegments_numHitsVsStation", 4, 0.5, 4.5, 20, 0, 20));
74  phiHistos[2]->setBinLabel(1, "St1", 1);
75  phiHistos[2]->setBinLabel(2, "St2", 1);
76  phiHistos[2]->setBinLabel(3, "St3", 1);
77  phiHistos[2]->setBinLabel(4, "St4", 1);
78 
79  // histos for theta segments
80  thetaHistos.push_back(
81  ibooker.book2D("thetaSegments_numHitsVsWheel", "thetaSegments_numHitsVsWheel", 5, -2.5, 2.5, 20, 0, 20));
82  thetaHistos[0]->setBinLabel(1, "W-2", 1);
83  thetaHistos[0]->setBinLabel(2, "W-1", 1);
84  thetaHistos[0]->setBinLabel(3, "W0", 1);
85  thetaHistos[0]->setBinLabel(4, "W1", 1);
86  thetaHistos[0]->setBinLabel(5, "W2", 1);
87  thetaHistos.push_back(
88  ibooker.book2D("thetaSegments_numHitsVsSector", "thetaSegments_numHitsVsSector", 14, 0.5, 14.5, 20, 0, 20));
89  thetaHistos[1]->setBinLabel(1, "Sec1", 1);
90  thetaHistos[1]->setBinLabel(2, "Sec2", 1);
91  thetaHistos[1]->setBinLabel(3, "Sec3", 1);
92  thetaHistos[1]->setBinLabel(4, "Sec4", 1);
93  thetaHistos[1]->setBinLabel(5, "Sec5", 1);
94  thetaHistos[1]->setBinLabel(6, "Sec6", 1);
95  thetaHistos[1]->setBinLabel(7, "Sec7", 1);
96  thetaHistos[1]->setBinLabel(8, "Sec8", 1);
97  thetaHistos[1]->setBinLabel(9, "Sec9", 1);
98  thetaHistos[1]->setBinLabel(10, "Sec10", 1);
99  thetaHistos[1]->setBinLabel(11, "Sec11", 1);
100  thetaHistos[1]->setBinLabel(12, "Sec12", 1);
101  thetaHistos[1]->setBinLabel(13, "Sec13", 1);
102  thetaHistos[1]->setBinLabel(14, "Sec14", 1);
103  thetaHistos.push_back(
104  ibooker.book2D("thetaSegments_numHitsVsStation", "thetaSegments_numHitsVsStation", 4, 0.5, 4.5, 20, 0, 20));
105  thetaHistos[2]->setBinLabel(1, "St1", 1);
106  thetaHistos[2]->setBinLabel(2, "St2", 1);
107  thetaHistos[2]->setBinLabel(3, "St3", 1);
108  thetaHistos[2]->setBinLabel(4, "St4", 1);
109 }
110 
112  // Get the map of noisy channels
113  // bool checkNoisyChannels = parameters.getUntrackedParameter<bool>("checkNoisyChannels",false);
114  ESHandle<DTStatusFlag> statusMap;
115  if (checkNoisyChannels) {
116  statusMap = setup.getHandle(statusMapToken_);
117  }
118 
119  // Get the 4D segment collection from the event
121  event.getByToken(theRecHits4DLabel_, all4DSegments);
122 
123  // Loop over all chambers containing a segment
125  for (chamberId = all4DSegments->id_begin(); chamberId != all4DSegments->id_end(); ++chamberId) {
126  // Get the range for the corresponding ChamerId
127  DTRecSegment4DCollection::range range = all4DSegments->get(*chamberId);
128  int nsegm = distance(range.first, range.second);
129  if (debug)
130  cout << " Chamber: " << *chamberId << " has " << nsegm << " 4D segments" << endl;
131 
132  // Loop over the rechits of this ChamerId
133  for (DTRecSegment4DCollection::const_iterator segment4D = range.first; segment4D != range.second; ++segment4D) {
134  //FOR NOISY CHANNELS////////////////////////////////
135  bool segmNoisy = false;
136  if ((*segment4D).hasPhi()) {
137  const DTChamberRecSegment2D* phiSeg = (*segment4D).phiSegment();
138  vector<DTRecHit1D> phiHits = phiSeg->specificRecHits();
139  map<DTSuperLayerId, vector<DTRecHit1D> > hitsBySLMap;
140  for (vector<DTRecHit1D>::const_iterator hit = phiHits.begin(); hit != phiHits.end(); ++hit) {
141  DTWireId wireId = (*hit).wireId();
142 
143  // Check for noisy channels to skip them
144  if (checkNoisyChannels) {
145  bool isNoisy = false;
146  bool isFEMasked = false;
147  bool isTDCMasked = false;
148  bool isTrigMask = false;
149  bool isDead = false;
150  bool isNohv = false;
151  statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
152  if (isNoisy) {
153  if (debug)
154  cout << "Wire: " << wireId << " is noisy, skipping!" << endl;
155  segmNoisy = true;
156  }
157  }
158  }
159  }
160 
161  if ((*segment4D).hasZed()) {
162  const DTSLRecSegment2D* zSeg = (*segment4D).zSegment(); // zSeg lives in the SL RF
163  // Check for noisy channels to skip them
164  vector<DTRecHit1D> zHits = zSeg->specificRecHits();
165  for (vector<DTRecHit1D>::const_iterator hit = zHits.begin(); hit != zHits.end(); ++hit) {
166  DTWireId wireId = (*hit).wireId();
167  if (checkNoisyChannels) {
168  bool isNoisy = false;
169  bool isFEMasked = false;
170  bool isTDCMasked = false;
171  bool isTrigMask = false;
172  bool isDead = false;
173  bool isNohv = false;
174  //cout<<"wire id "<<wireId<<endl;
175  statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
176  if (isNoisy) {
177  if (debug)
178  cout << "Wire: " << wireId << " is noisy, skipping!" << endl;
179  segmNoisy = true;
180  }
181  }
182  }
183  }
184 
185  if (segmNoisy) {
186  if (debug)
187  cout << "skipping the segment: it contains noisy cells" << endl;
188  continue;
189  }
190  //END FOR NOISY CHANNELS////////////////////////////////
191 
192  // Fill the histos
193  int nHits = 0;
194  if ((*segment4D).hasPhi()) {
195  nHits = (((*segment4D).phiSegment())->specificRecHits()).size();
196  if (debug)
197  cout << "Phi segment with number of hits: " << nHits << endl;
198  phiHistos[0]->Fill((*chamberId).wheel(), nHits);
199  phiHistos[1]->Fill((*chamberId).sector(), nHits);
200  phiHistos[2]->Fill((*chamberId).station(), nHits);
201  }
202  if ((*segment4D).hasZed()) {
203  nHits = (((*segment4D).zSegment())->specificRecHits()).size();
204  if (debug)
205  cout << "Zed segment with number of hits: " << nHits << endl;
206  thetaHistos[0]->Fill((*chamberId).wheel(), nHits);
207  thetaHistos[1]->Fill((*chamberId).sector(), nHits);
208  thetaHistos[2]->Fill((*chamberId).station(), nHits);
209  }
210 
211  } //loop over segments
212  } // loop over chambers
213 }
size
Write out results.
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
const edm::ESGetToken< DTStatusFlag, DTStatusFlagRcd > statusMapToken_
identifier iterator
Definition: RangeMap.h:130
edm::EDGetTokenT< DTRecSegment4DCollection > theRecHits4DLabel_
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
void analyze(const edm::Event &, const edm::EventSetup &) override
book the histos
DTSegmentsTask(const edm::ParameterSet &pset)
Constructor.
std::vector< MonitorElement * > thetaHistos
std::vector< MonitorElement * > phiHistos
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell const int32_t nHits
edm::ParameterSet parameters
HLT enums.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
~DTSegmentsTask() override
Destructor.
int cellStatus(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool &noiseFlag, bool &feMask, bool &tdcMask, bool &trigMask, bool &deadFlag, bool &nohvFlag) const
get content
Definition: DTStatusFlag.h:90
Definition: event.py:1
Definition: Run.h:45