CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GEMOfflineMonitor.cc
Go to the documentation of this file.
6 
9  digi_token_ = consumes<GEMDigiCollection>(pset.getParameter<edm::InputTag>("digiTag"));
10  rechit_token_ = consumes<GEMRecHitCollection>(pset.getParameter<edm::InputTag>("recHitTag"));
11  do_digi_occupancy_ = pset.getUntrackedParameter<bool>("doDigiOccupancy");
12  do_hit_occupancy_ = pset.getUntrackedParameter<bool>("doHitOccupancy");
13  log_category_ = pset.getUntrackedParameter<std::string>("logCategory");
14 }
15 
17 
20  desc.add<edm::InputTag>("digiTag", edm::InputTag("muonGEMDigis"));
21  desc.add<edm::InputTag>("recHitTag", edm::InputTag("gemRecHits"));
22  desc.addUntracked<std::string>("logCategory", "GEMOfflineMonitor");
23  desc.addUntracked<bool>("doDigiOccupancy", true);
24  desc.addUntracked<bool>("doHitOccupancy", true);
25  descriptions.add("gemOfflineMonitorDefault", desc);
26 }
27 
30  gem = setup.getHandle(gemToken_);
31 
32  if (not gem.isValid()) {
33  edm::LogError(log_category_) << "GEMGeometry is invalid" << std::endl;
34  return;
35  }
36 
38  bookDigiOccupancy(ibooker, gem);
39 
41  bookHitOccupancy(ibooker, gem);
42 }
43 
45  ibooker.setCurrentFolder("GEM/GEMOfflineMonitor/DigiOccupancy");
46 
47  for (const GEMStation* station : gem->stations()) {
48  const int region_id = station->region();
49  const int station_id = station->station();
50  const GEMDetId&& key = getReStKey(region_id, station_id);
51  const auto&& name_suffix = GEMUtils::getSuffixName(region_id, station_id);
52  const auto&& title_suffix = GEMUtils::getSuffixTitle(region_id, station_id);
53 
54  const auto&& superchambers = station->superChambers();
55  if (not checkRefs(superchambers)) {
56  edm::LogError(log_category_) << "failed to get a valid vector of GEMSuperChamber ptrs" << std::endl;
57  return;
58  }
59 
60  // per station
61  const int num_superchambers = superchambers.size();
62  const int num_chambers = num_superchambers * superchambers.front()->nChambers();
63  // the numer of VFATs per GEMEtaPartition
64  const int max_vfat = getMaxVFAT(station->station());
65  // the number of eta partitions per GEMChamber
66  const int num_etas = getNumEtaPartitions(station);
67  // the number of VFATs per GEMChamber
68  const int num_vfat = num_etas * max_vfat;
69 
70  me_digi_det_[key] = ibooker.book2D("digi_det" + name_suffix,
71  "Digi Occupancy" + title_suffix,
72  num_chambers,
73  0.5,
74  num_chambers + 0.5,
75  num_vfat,
76  0.5,
77  num_vfat + 0.5);
79  } // station
80 }
81 
83  ibooker.setCurrentFolder("GEM/GEMOfflineMonitor/HitOccupancy");
84 
85  for (const GEMStation* station : gem->stations()) {
86  const int region_id = station->region();
87  const int station_id = station->station();
88 
89  const GEMDetId&& key = getReStKey(region_id, station_id);
90  const auto&& name_suffix = GEMUtils::getSuffixName(region_id, station_id);
91  const auto&& title_suffix = GEMUtils::getSuffixTitle(region_id, station_id);
92 
93  const auto&& superchambers = station->superChambers();
94  if (not checkRefs(superchambers)) {
95  edm::LogError(log_category_) << "failed to get a valid vector of GEMSuperChamber ptrs" << std::endl;
96  return;
97  }
98 
99  // per station
100  const int num_superchambers = superchambers.size();
101  const int num_chambers = num_superchambers * superchambers.front()->nChambers();
102  // the number of eta partitions per GEMChamber
103  const int num_etas = getNumEtaPartitions(station);
104 
105  me_hit_det_[key] = ibooker.book2D("hit_det" + name_suffix,
106  "Hit Occupancy" + title_suffix,
107  num_chambers,
108  0.5,
109  num_chambers + 0.5,
110  num_etas,
111  0.5,
112  num_etas + 0.5);
114  } // station
115 }
116 
118  edm::Handle<GEMDigiCollection> digi_collection;
119  if (do_digi_occupancy_) {
120  event.getByToken(digi_token_, digi_collection);
121  if (not digi_collection.isValid()) {
122  edm::LogError(log_category_) << "GEMDigiCollection is invalid!" << std::endl;
123  return;
124  }
125  }
126 
127  edm::Handle<GEMRecHitCollection> rechit_collection;
128  if (do_hit_occupancy_) {
129  event.getByToken(rechit_token_, rechit_collection);
130  if (not rechit_collection.isValid()) {
131  edm::LogError(log_category_) << "GEMRecHitCollection is invalid" << std::endl;
132  return;
133  }
134  }
135 
137  gem = setup.getHandle(gemToken_);
138 
139  if (not gem.isValid()) {
140  edm::LogError(log_category_) << "GEMGeometry is invalid" << std::endl;
141  return;
142  }
143 
144  if (do_digi_occupancy_)
145  doDigiOccupancy(gem, digi_collection);
146 
147  if (do_hit_occupancy_)
148  doHitOccupancy(gem, rechit_collection);
149 }
150 
152  const edm::Handle<GEMDigiCollection>& digi_collection) {
153  for (auto range_iter = digi_collection->begin(); range_iter != digi_collection->end(); range_iter++) {
154  const GEMDetId& gem_id = (*range_iter).first;
155  const GEMDigiCollection::Range& range = (*range_iter).second;
156 
157  const GEMDetId&& rs_key = getReStKey(gem_id);
158  for (auto digi = range.first; digi != range.second; ++digi) {
159  const int chamber_bin = getDetOccXBin(gem_id, gem);
160  const int vfat_number = getVFATNumberByStrip(gem_id.station(), gem_id.roll(), digi->strip());
161 
162  fillME(me_digi_det_, rs_key, chamber_bin, vfat_number);
163  } // digi
164  } // range
165 }
166 
168  const edm::Handle<GEMRecHitCollection>& rechit_collection) {
169  for (auto hit = rechit_collection->begin(); hit != rechit_collection->end(); hit++) {
170  const GEMDetId&& gem_id = hit->gemId();
171  const GEMDetId&& rs_key = getReStKey(gem_id);
172  const int chamber_bin = getDetOccXBin(gem_id, gem);
173  fillME(me_hit_det_, rs_key, chamber_bin, gem_id.roll());
174  }
175 }
T getUntrackedParameter(std::string const &, T const &) const
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
TString getSuffixName(Int_t region_id)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
void doHitOccupancy(const edm::ESHandle< GEMGeometry > &, const edm::Handle< GEMRecHitCollection > &)
int getDetOccXBin(const int, const int, const int)
void doDigiOccupancy(const edm::ESHandle< GEMGeometry > &, const edm::Handle< GEMDigiCollection > &)
constexpr int roll() const
Definition: GEMDetId.h:194
int getVFATNumberByStrip(const int, const int, const int)
Log< level::Error, false > LogError
TString getSuffixTitle(Int_t region_id)
std::string log_category_
void setDetLabelsEta(MonitorElement *, const GEMStation *)
const edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemToken_
const uint16_t range(const Frame &aFrame)
GEMOfflineMonitor(const edm::ParameterSet &)
bool checkRefs(const std::vector< T * > &)
int getMaxVFAT(const int)
int getNumEtaPartitions(const GEMStation *)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< GEMRecHitCollection > rechit_token_
tuple key
prepare the HTCondor submission files and eventually submit them
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:70
void fillME(MEMap &me_map, const GEMDetId &key, const float x)
void bookHitOccupancy(DQMStore::IBooker &, const edm::ESHandle< GEMGeometry > &)
std::pair< const_iterator, const_iterator > Range
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:177
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
constexpr int station() const
Definition: GEMDetId.h:179
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< GEMDigiCollection > digi_token_
~GEMOfflineMonitor() override
void bookDigiOccupancy(DQMStore::IBooker &, const edm::ESHandle< GEMGeometry > &)
void setDetLabelsVFAT(MonitorElement *, const GEMStation *)
GEMDetId getReStKey(const int, const int)
static void fillDescriptions(edm::ConfigurationDescriptions &)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
bool isValid() const
Definition: ESHandle.h:44
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
Definition: Run.h:45
int chamber_bin(int station, int ring, int chamber)