CMS 3D CMS Logo

GEMDQMSourceDigi.cc
Go to the documentation of this file.
9 
14 
16 
19 
20 #include <string>
21 
22 //----------------------------------------------------------------------------------------------------
23 
25 public:
27  ~GEMDQMSourceDigi() override{};
28  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
29 
30 protected:
31  void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override{};
32  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
33  void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override;
34 
35 private:
37 
38  const GEMGeometry* initGeometry(edm::EventSetup const& iSetup);
39  int findVFAT(float min_, float max_, float x_, int roll_);
40 
42 
43  std::vector<GEMChamber> gemChambers_;
44 
45  std::unordered_map<UInt_t, MonitorElement*> Digi_2D_;
46  std::unordered_map<UInt_t, MonitorElement*> Digi_1D_;
47  std::unordered_map<UInt_t, MonitorElement*> BxVsVFAT;
48 };
49 
50 using namespace std;
51 using namespace edm;
52 
53 int GEMDQMSourceDigi::findVFAT(float min_, float max_, float x_, int roll_) {
54  float step = max_ / 3;
55  if (x_ < (min_ + step)) {
56  return 8 - roll_;
57  } else if (x_ < (min_ + 2 * step)) {
58  return 16 - roll_;
59  } else {
60  return 24 - roll_;
61  }
62 }
63 
65  const GEMGeometry* GEMGeometry_ = nullptr;
66  try {
68  iSetup.get<MuonGeometryRecord>().get(hGeom);
69  GEMGeometry_ = &*hGeom;
71  edm::LogError("MuonGEMBaseValidation") << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
72  return nullptr;
73  }
74 
75  return GEMGeometry_;
76 }
77 
79  tagDigi_ = consumes<GEMDigiCollection>(cfg.getParameter<edm::InputTag>("digisInputLabel"));
80 }
81 
84  desc.add<edm::InputTag>("digisInputLabel", edm::InputTag("muonGEMDigis", ""));
85  descriptions.add("GEMDQMSourceDigi", desc);
86 }
87 
88 void GEMDQMSourceDigi::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const& iSetup) {
89  GEMGeometry_ = initGeometry(iSetup);
90  if (GEMGeometry_ == nullptr)
91  return;
92 
93  const std::vector<const GEMSuperChamber*>& superChambers_ = GEMGeometry_->superChambers();
94  for (auto sch : superChambers_) {
95  int n_lay = sch->nChambers();
96  for (int l = 0; l < n_lay; l++) {
97  Bool_t bExist = false;
98  for (auto ch : gemChambers_)
99  if (ch.id() == sch->chamber(l + 1)->id())
100  bExist = true;
101  if (bExist)
102  continue;
103 
104  gemChambers_.push_back(*sch->chamber(l + 1));
105  }
106  }
107  ibooker.cd();
108  ibooker.setCurrentFolder("GEM/digi");
109  for (auto ch : gemChambers_) {
110  GEMDetId gid = ch.id();
111 
112  std::string strIdxName = "Gemini_" + to_string(gid.chamber()) + "_GE" + (gid.region() > 0 ? "p" : "m") +
113  to_string(gid.station()) + "_" + to_string(gid.layer());
114  std::string strIdxTitle = "GEMINIm" + to_string(gid.chamber()) + " in GE" + (gid.region() > 0 ? "+" : "-") +
115  to_string(gid.station()) + "/" + to_string(gid.layer());
116 
117  string hName_digi = "Digi_Strips_" + strIdxName;
118  string hTitle_digi = "Digi Strip " + strIdxTitle;
119  string hAxis_digi = ";Strip;iEta";
120  Digi_2D_[ch.id()] = ibooker.book2D(hName_digi, hTitle_digi + hAxis_digi, 384, 1, 385, 8, 0.5, 8.5);
121  Digi_1D_[ch.id()] = ibooker.book1D(hName_digi + "_VFAT", hTitle_digi + " VFAT" + hAxis_digi, 24, 0, 24);
122 
123  string hNameBx = "bx_vs_VFAT_" + strIdxName;
124  string hTitleBx = "bx vs VFAT " + strIdxTitle;
125  hTitleBx += ";Bunch crossing;VFAT";
126  BxVsVFAT[ch.id()] = ibooker.book2D(hNameBx, hTitleBx, 10, -5, 5, 24, 0, 24);
127  }
128 }
129 
131  const GEMGeometry* GEMGeometry_ = initGeometry(eventSetup);
132  if (GEMGeometry_ == nullptr)
133  return;
134 
136  event.getByToken(this->tagDigi_, gemDigis);
137  for (auto ch : gemChambers_) {
138  GEMDetId cId = ch.id();
139  for (auto roll : ch.etaPartitions()) {
140  GEMDetId rId = roll->id();
141  const auto& digis_in_det = gemDigis->get(rId);
142  for (auto d = digis_in_det.first; d != digis_in_det.second; ++d) {
143  auto nVFAT = findVFAT(1, roll->nstrips(), d->strip(), rId.roll());
144  Digi_2D_[cId]->Fill(d->strip(), rId.roll());
145  Digi_1D_[cId]->Fill(nVFAT);
146  BxVsVFAT[cId]->Fill(d->bx(), nVFAT);
147  }
148  }
149  }
150 }
151 
T getParameter(std::string const &) const
int roll() const
Definition: GEMDetId.h:188
int chamber() const
Definition: GEMDetId.h:177
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const GEMGeometry * initGeometry(edm::EventSetup const &iSetup)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< GEMChamber > gemChambers_
int findVFAT(float min_, float max_, float x_, int roll_)
int layer() const
Definition: GEMDetId.h:184
int station() const
Definition: GEMDetId.h:173
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
const GEMGeometry * GEMGeometry_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int region() const
Definition: GEMDetId.h:165
d
Definition: ztail.py:151
const std::vector< const GEMSuperChamber * > & superChambers() const
Return a vector of all GEM super chambers.
Definition: GEMGeometry.cc:36
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
T get() const
Definition: EventSetup.h:73
std::unordered_map< UInt_t, MonitorElement * > Digi_1D_
step
Definition: StallMonitor.cc:94
~GEMDQMSourceDigi() override
std::unordered_map< UInt_t, MonitorElement * > BxVsVFAT
GEMDQMSourceDigi(const edm::ParameterSet &cfg)
edm::EDGetToken tagDigi_
Definition: event.py:1
Definition: Run.h:45
std::unordered_map< UInt_t, MonitorElement * > Digi_2D_