CMS 3D CMS Logo

DTOccupancyEfficiency.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  */
5 
7 
8 // Framework
14 
16 
17 #include <iterator>
18 
19 using namespace edm;
20 using namespace std;
21 
23  debug = pset.getUntrackedParameter<bool>("debug", false);
24  // label for dtDigis
25  dtDigiToken_ = consumes<DTDigiCollection>(edm::InputTag(pset.getUntrackedParameter<string>("digiLabel")));
26  // the name of the 4D rec hits collection
27  recHits4DToken_ =
28  consumes<DTRecSegment4DCollection>(edm::InputTag(pset.getUntrackedParameter<string>("recHits4DLabel")));
29  // the name of the rechits collection
30  recHitToken_ = consumes<DTRecHitCollection>(edm::InputTag(pset.getUntrackedParameter<string>("recHitLabel")));
31 
32  parameters = pset;
33 }
34 
36 
38  edm::Run const& iRun,
39  edm::EventSetup const& context) {
40  ibooker.setCurrentFolder("DT/04-OccupancyEfficiency/digisPerRing");
41  // Digis per ring
42  for (int station = 1; station < 5; station++) {
43  string station_s = to_string(station);
44  for (int wheel = -2; wheel < 3; wheel++) {
45  string wheel_s = to_string(wheel);
46  if (wheel > 0)
47  wheel_s = "+" + wheel_s;
48  string histoName = "digisPerMB" + station_s + "W" + wheel_s;
49  string histoTitle = "Number of digis in MB" + station_s + "YB" + wheel_s;
50  (digisPerRing[station])[wheel] = ibooker.book1D(histoName, histoTitle, 100, 0, 150);
51  }
52  }
53 
54  ibooker.setCurrentFolder("DT/04-OccupancyEfficiency/timeBoxesPerRing");
55  // TimeBoxes per ring
56  for (int station = 1; station < 5; station++) {
57  string station_s = to_string(station);
58  for (int wheel = -2; wheel < 3; wheel++) {
59  string wheel_s = to_string(wheel);
60  if (wheel > 0)
61  wheel_s = "+" + wheel_s;
62  string histoName = "timeBoxesPerMB" + station_s + "W" + wheel_s;
63  string histoTitle = "Number of TDC counts in MB" + station_s + "YB" + wheel_s;
64  (timeBoxesPerRing[station])[wheel] = ibooker.book1D(histoName, histoTitle, 400, 0, 1600);
65  }
66  }
67 
68  ibooker.setCurrentFolder("DT/04-OccupancyEfficiency");
69 
70  // TimeBoxes
71  timeBoxesPerEvent = ibooker.book1D("timeBoxesPerEvent", "TDC counts per event", 400, 0, 1600);
72 
73  // Digis
74  digisPerEvent = ibooker.book1D("digisPerEvent", "Number of digis per event", 100, 0, 900);
75 
76  // RecHits
77  recHitsPerEvent = ibooker.book1D("recHitsPerEvent", "Number of RecHits per event", 100, 0, 250);
78 
79  // 4D segments
80  segments4DPerEvent = ibooker.book1D("segments4DPerEvent", "Number of 4D Segments per event", 50, 0, 50);
81 
82  recHitsPer4DSegment = ibooker.book1D("recHitsPer4DSegment", "Number of RecHits per segment", 16, 0.5, 16.5);
83 
84  // T0 from segements
85  t0From4DPhiSegment = ibooker.book1D("t0From4DPhiSegment", "T0 from 4D Phi segments", 100, -150, 150);
86  t0From4DZSegment = ibooker.book1D("t0From4DZSegment", "T0 from 4D Z segments", 100, -150, 150);
87 }
88 
90  if (debug)
91  cout << "[DTOccupancyEfficiency] Analyze #Run: " << event.id().run() << " #Event: " << event.id().event() << endl;
92 
93  // Digi collection
95  event.getByToken(dtDigiToken_, dtdigis);
96 
97  int numberOfDigis = 0;
98  std::map<int, std::map<int, int>> numberOfDigisPerRing;
99 
101  for (dtLayerId_It = dtdigis->begin(); dtLayerId_It != dtdigis->end(); ++dtLayerId_It) { // Loop over layers
102  for (DTDigiCollection::const_iterator digiIt = ((*dtLayerId_It).second).first;
103  digiIt != ((*dtLayerId_It).second).second;
104  ++digiIt) {
105  numberOfDigis++;
106  int wheelId = ((*dtLayerId_It).first).wheel();
107  int stationId = ((*dtLayerId_It).first).station();
108  (numberOfDigisPerRing[stationId])[wheelId] += 1;
109 
110  timeBoxesPerEvent->Fill((*digiIt).countsTDC());
111  (timeBoxesPerRing[stationId])[wheelId]->Fill((*digiIt).countsTDC());
112  }
113  }
114 
115  // Total number of Digis per Event
116  digisPerEvent->Fill(numberOfDigis);
117 
118  // Digis per Ring in every wheel
119  for (int station = 1; station < 5; station++)
120  for (int wheel = -2; wheel < 3; wheel++)
121  (digisPerRing[station])[wheel]->Fill((numberOfDigisPerRing[station])[wheel]);
122 
123  // Get the 4D segment collection from the event
125  event.getByToken(recHits4DToken_, all4DSegments);
126 
127  segments4DPerEvent->Fill(all4DSegments->size());
128 
129  // Get the rechit collection from the event
130  Handle<DTRecHitCollection> dtRecHits;
131  event.getByToken(recHitToken_, dtRecHits);
132 
133  recHitsPerEvent->Fill(dtRecHits->size());
134 
135  // Number of RecHits per segment and t0 from Segment
136  // Loop on all segments
137  for (DTRecSegment4DCollection::const_iterator segment = all4DSegments->begin(); segment != all4DSegments->end();
138  ++segment) {
139  unsigned int nHits = (segment->hasPhi() ? (segment->phiSegment())->recHits().size() : 0);
140  nHits += (segment->hasZed() ? (segment->zSegment())->recHits().size() : 0);
141  recHitsPer4DSegment->Fill(nHits);
142 
143  if (segment->hasPhi()) {
144  double segmentPhiT0 = segment->phiSegment()->t0();
145  if (segment->phiSegment()->ist0Valid())
146  t0From4DPhiSegment->Fill(segmentPhiT0);
147  }
148  if (segment->hasZed()) {
149  double segmentZT0 = segment->zSegment()->t0();
150  if (segment->zSegment()->ist0Valid())
151  t0From4DZSegment->Fill(segmentZT0);
152  }
153  }
154 }
155 
156 // Local Variables:
157 // show-trailing-whitespace: t
158 // truncate-lines: t
159 // End:
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
~DTOccupancyEfficiency() override
Destructor.
static std::string to_string(const XMLCh *ch)
U second(std::pair< T, U > const &p)
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
#define debug
Definition: HDRShower.cc:19
DTOccupancyEfficiency(const edm::ParameterSet &pset)
Constructor.
std::vector< DigiType >::const_iterator const_iterator
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
HLT enums.
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
Definition: event.py:1
Definition: Run.h:45
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override